I have made the following changes intended for : CE:UX:MTF / eventfeed Please review and accept or decline. BOSS has already run some checks on this request. See the "Messages from BOSS" section below.
https://build.pub.meego.com//request/show/6843 Thank You, Marko Saukko [This message was auto-generated] --- Request # 6843: Messages from BOSS: State: review at 2012-10-01T04:17:55 by bossbot Reviews: accepted by bossbot : Prechecks succeeded. new for CE-maintainers : Please replace this text with a review and approve/reject the review (not the SR). BOSS will take care of the rest Changes: submit: Project:MTF:UX / eventfeed -> CE:UX:MTF / eventfeed changes files: -------------- --- eventfeed.changes +++ eventfeed.changes @@ -0,0 +1,7 @@ +* Tue Sep 25 2012 Dmitry Rozhkov <[email protected]> - 0.1.0 +- Repackaged to fewer binary packages. +- Dropped Thumbnailer related code. +- Exploited SQLite triggers for the sake of simpler code and better data consistency. +- Set image types properly. +- Code clean ups. + old: ---- eventfeed-0.0.1.tar.bz2 new: ---- eventfeed-0.1.0.tar.bz2 spec files: ----------- --- eventfeed.spec +++ eventfeed.spec @@ -1,6 +1,6 @@ # # Do NOT Edit the Auto-generated Part! -# Generated by: spectacle version 0.25 +# Generated by: spectacle version 0.24.1 # Name: eventfeed @@ -9,30 +9,26 @@ # << macros Summary: Event feed subsystem -Version: 0.0.1 +Version: 0.1.0 Release: 0 Group: System/GUI/Other -License: Apache License +License: BSD License URL: http://www.meego.com Source0: %{name}-%{version}.tar.bz2 Source100: eventfeed.yaml +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig BuildRequires: pkgconfig(QtCore) >= 4.6.0 BuildRequires: pkgconfig(QtDBus) BuildRequires: pkgconfig(QtGui) -BuildRequires: pkgconfig(dbus-1) BuildRequires: qt-devel-tools -BuildRequires: libthumbnailer-devel +Obsoletes: eventfeed-qmlapi +Obsoletes: libeventfeed +Obsoletes: libeventfeed-devel %description -Desc for event feed subsystem - - -%package qmlapi -Summary: QML widget for events -Group: System/GUI/Other - -%description qmlapi -This package provides QML widget for events. +This package provides a D-Bus service and a QML component needed to show | +event items. %package -n libmeegotouchevents @@ -48,31 +44,12 @@ %package -n libmeegotouchevents-devel Summary: Development files for libmeegotouchevents Group: Development/Libraries +Requires: libmeegotouchevents = %{version} %description -n libmeegotouchevents-devel This package contains development files for libmeegotouchevents. -%package -n libeventfeed -Summary: Event feed library -Group: Applications/System -Requires: %{name} = %{version}-%{release} -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig - -%description -n libeventfeed -This package contains library required to query event storage. - - -%package -n libeventfeed-devel -Summary: Development files for libeventfeed -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} - -%description -n libeventfeed-devel -This package contains development files for libeventfeed. - - %package -n fakefeeder Summary: Utility creating fake events with libmeegotouchevents Group: Applications/System @@ -111,27 +88,24 @@ # << install post -%post -n libmeegotouchevents -p /sbin/ldconfig +%post -p /sbin/ldconfig -%postun -n libmeegotouchevents -p /sbin/ldconfig +%postun -p /sbin/ldconfig -%post -n libeventfeed -p /sbin/ldconfig +%post -n libmeegotouchevents -p /sbin/ldconfig -%postun -n libeventfeed -p /sbin/ldconfig +%postun -n libmeegotouchevents -p /sbin/ldconfig %files %defattr(-,root,root,-) %{_usr}/bin/eventfeedd %{_datadir}/dbus-1/* +%{_libdir}/qt4/imports/org/nemomobile/events/* +%{_libdir}/libeventfeed.so.* +%exclude %{_libdir}/libeventfeed.so # >> files # << files -%files qmlapi -%defattr(-,root,root,-) -%{_libdir}/qt4/imports/org/nemomobile/events/* -# >> files qmlapi -# << files qmlapi - %files -n libmeegotouchevents %defattr(-,root,root,-) %{_libdir}/libmeegotouchevents.so.* @@ -146,20 +120,6 @@ # >> files libmeegotouchevents-devel # << files libmeegotouchevents-devel -%files -n libeventfeed -%defattr(-,root,root,-) -%{_libdir}/libeventfeed.so.* -# >> files libeventfeed -# << files libeventfeed - -%files -n libeventfeed-devel -%defattr(-,root,root,-) -%{_libdir}/libeventfeed.so -%{_includedir}/eventfeed/*.h -%{_datadir}/qt4/mkspecs/features/eventfeed.prf -# >> files libeventfeed-devel -# << files libeventfeed-devel - %files -n fakefeeder %defattr(-,root,root,-) %{_usr}/bin/fakefeeder other changes: -------------- ++++++ eventfeed-0.0.1.tar.bz2 -> eventfeed-0.1.0.tar.bz2 --- README.rst +++ README.rst @@ -7,7 +7,6 @@ - registering the D-Bus service `org.nemomobile.events.EventFeed`, - event storage maintenance, - - sending requests to a thumbnailer service, - emitting signals upon adding or removal events from the storage. 2. trivial wrapper library (libmeegotouchevents) around a proxy to @@ -26,26 +25,41 @@ ============= `eventfeed` uses SQLite database as a storage for event items. Its schema is -identical to what's been used in MeeGo Harmattan:: +very similar to what's been used in MeeGo Harmattan:: CREATE TABLE events (id INTEGER PRIMARY KEY, title TEXT, body TEXT, timestamp TEXT, footer TEXT, action TEXT, url TEXT, sourceName TEXT, sourceDisplayName TEXT); CREATE TABLE images (id INTEGER, position INTEGER, originalPath TEXT, - thumbnailPath TEXT, type TEXT, - PRIMARY KEY(id, position)); + type TEXT, PRIMARY KEY(id, position)); Notes ===== -Currently there is no working thumbnailer service in Nemo thus the code -using the libthumbnailer API is useless. The QtQuick component ignores -the content of the thumbnailPath field and uses the thumbnailer plugin -from the package `nemo-qml-plugins`. - If we decide not to use any D-Bus based thumbnailer, but to rely on the QML plugin then this separate daemon providing `org.nemomobile.events.EventFeed` service may be considered an overcomplication. Instead the service might be a part of the QtQuick component and the API library might be rewritten to update the event storage directly. + +So instead of:: + + --> event model 1 + v + client -> dumb library -> dbus -> event service -> dbus <-> event model 2 + ^ + ---> event model 3 + +the scheme might look like this:: + + client -> smart library -> dbus -> single event model + +OTOH if go this way then + +1. event feed bindings for other programming languages will get complicated, + +2. changes in one event view won't be reflected in all others given that + we want to allow running many event veiws in different processes at once. + +The field `events.action` seems to be redundant. --- makedist +++ makedist @@ -2,7 +2,7 @@ PROJECT="eventfeed" -VERSION="0.0.1" +VERSION=$(git describe --tags --abbrev=0) # Set name of toplevel directory for the archive PREFIX="${PROJECT}-${VERSION}/" --- org.nemomobile.events.EventFeed.xml +++ org.nemomobile.events.EventFeed.xml @@ -4,12 +4,12 @@ <method name="addItem"> <arg name="parameters" type="a{sv}" direction="in"/> <arg type="x" direction="out"/> - <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/> - <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="qint64"/> + <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/> + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="qint64"/> </method> <method name="removeItem"> <arg name="id" type="x" direction="in"/> - <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="qint64"/> + <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="qint64"/> </method> <method name="removeItemsBySourceName"> <arg name="sourceName" type="s" direction="in"/> @@ -17,11 +17,11 @@ <signal name="eventAdded"> <arg name="event" type="a{sv}" /> - <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/> + <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/> </signal> <signal name="eventsRemoved"> <arg name="events" type="ax" /> - <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QList < qlonglong > "/> + <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QList < qlonglong > "/> </signal> </interface> </node> --- src/eventfeed/eventfeed.pro +++ src/eventfeed/eventfeed.pro @@ -13,15 +13,14 @@ QT += dbus sql HEADERS = eventfeedservice.h \ - eventfeedadaptor.h \ - eventprocessor.h + eventfeedadaptor.h SOURCES = eventfeedservice.cpp \ eventfeedadaptor.cpp \ main.cpp INCLUDEPATH += ../libeventfeed -LIBS += -L../libeventfeed -leventfeed -lthumbnailer +LIBS += -L../libeventfeed -leventfeed services.files = *.service services.path = $$INSTALL_ROOT$$PREFIX/share/dbus-1/services --- src/eventfeed/eventfeedservice.cpp +++ src/eventfeed/eventfeedservice.cpp @@ -33,14 +33,10 @@ #include <QDBusConnection> #include "eventfeedservice.h" #include "eventfeedadaptor.h" -#include "eventprocessor.h" EventFeedService::EventFeedService(QObject *parent) - : QObject(parent), - m_thumbnailer(NULL) + : QObject(parent) { - m_thumbnailer = new Thumbnails::Thumbnailer(); - m_storage.open(); connect(&m_storage, SIGNAL(itemsOutdated(const QList<qlonglong>&)), this, SIGNAL(eventsRemoved(const QList<qlonglong>&))); @@ -64,27 +60,17 @@ EventFeedService::~EventFeedService() { m_storage.close(); - delete m_thumbnailer; } qlonglong EventFeedService::addItem(const QVariantMap ¶meters) { qlonglong id; + QVariantMap event_params = parameters; m_timer.stop(); id = m_storage.addItem(parameters); - EventProcessor *processor = new EventProcessor(id, parameters, this); - connect(processor, SIGNAL(thumbnailReady(const qlonglong&, const int&, const QString&)), - &m_storage, SLOT(saveThumbnail(const qlonglong&, const int&, const QString&))); - if (processor->process(m_thumbnailer)) { - emit eventAdded(processor->getEventData()); - processor->deleteLater(); - m_timer.start(); - return id; - } - // the processor will commit suicide and deallocate its memory when the event is ready - connect(processor, SIGNAL(eventReady(QVariantMap)), - this, SIGNAL(eventAdded(QVariantMap))); + event_params["id"] = id; + emit eventAdded(event_params); m_timer.start(); return id; --- src/eventfeed/eventfeedservice.h +++ src/eventfeed/eventfeedservice.h @@ -38,7 +38,6 @@ #include <QtCore/QString> #include <QtCore/QVariant> #include <eventstorage.h> -#include <thumbnailer/Thumbnailer> class EventFeedService : public QObject { @@ -60,7 +59,6 @@ private: EventStorage m_storage; QTimer m_timer; - Thumbnails::Thumbnailer *m_thumbnailer; }; #endif --- src/eventfeed/eventprocessor.h +++ src/eventfeed/eventprocessor.h @@ -1,186 +0,0 @@ -/* - * Copyright (C) 2012 Jolla Ltd. - * Contact: Dmitry Rozhkov <[email protected]> - * - * You may use this file under the terms of the BSD license as follows: - * - * "Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Nemo Mobile nor the names of its contributors - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." - */ - -// TODO: DROP THIS IF WE GO WITH nemo-qml-plugins-thumbnailer - -#include <QDebug> -#include <QString> -#include <QHash> -#include <QVariantMap> -#include <QUrl> -#include <QStringList> -#include <thumbnailer/Thumbnailer> - -static QString fileToMime(const QString &file) { - - static QHash<QString, QString> mimes; - - if(mimes.isEmpty()) { - mimes.insert(".jpeg", "image/jpeg"); - mimes.insert(".jpg", "image/jpeg"); - mimes.insert(".gif", "image/gif"); - mimes.insert(".png", "image/png"); - mimes.insert(".bmp", "image/bmp"); - mimes.insert(".tif", "image/tiff"); - mimes.insert(".tiff", "image/tiff"); - } - - foreach(QString mime, mimes.keys()) { - if(file.endsWith(mime, Qt::CaseInsensitive)) { - return mimes[mime]; - } - } - - return QString(); -} - - - - -class EventProcessor : public QObject -{ - Q_OBJECT -public: - EventProcessor(const qlonglong &id, QVariantMap eventdata, QObject *parent) - : QObject(parent), - m_event(eventdata) - { - m_event["id"] = id; - - } - - bool process(Thumbnails::Thumbnailer *thumbnailer) { - bool ready = true; - QString icon = m_event["icon"].toString(); - QStringList mimes; - QList<QUrl> urls; - - if (icon.startsWith("/")) { - m_imgpos.insert(icon, -1); - urls << QUrl(QString("file://") + icon); - mimes << fileToMime(icon); - ready = false; - qDebug() << __FILE__ << __LINE__ << "not ready"; - } - - int i = -1; - if (m_event.count("imageList") == 0) { // TODO optimize - m_event["imageList"] = QStringList(); - } - qDebug() << __FILE__ << __LINE__ << "imageList: " << m_event["imageList"].toStringList(); - foreach (const QString& img, m_event["imageList"].toStringList()) { - i++; - if (!img.isEmpty()) { - ready = false; - qDebug() << __FILE__ << __LINE__ << "img: " << img << "i:" << i; - m_imgpos.insert(img, i); - urls << img; - mimes << fileToMime(img); - } - } - - if (ready) { - qDebug() << "return from EventProcessor::process() (ready)"; - return true; - } - - connect(thumbnailer, SIGNAL(thumbnail(QUrl, QUrl, QPixmap, QString)), - this, SLOT(thumbnail(QUrl, QUrl))); - connect(thumbnailer, SIGNAL(error(QString, QUrl)), - this, SLOT(error(QString, QUrl))); - thumbnailer->request(urls, mimes); - qDebug() << "return from EventProcessor::process() (false)"; - return false; - } - - QVariantMap getEventData() const { // TODO: return reference - return m_event; - }; - -signals: - void thumbnailReady(const qlonglong &id, const int &position, const QString &image); - void eventReady(const QVariantMap &eventdata); - -private slots: - void thumbnail(const QUrl &fileUri, const QUrl &thumbUri) { - qDebug() << "fileUri: " << fileUri << "\nthumbUri: " << thumbUri; - - QString origFile = fileUri.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority); - QString thumbFile = thumbUri.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority); - int pos = m_imgpos.take(origFile); - m_imgmap.insert(origFile, thumbFile); - - emit thumbnailReady(m_event["id"].toLongLong(), pos, thumbFile); - - if (pos == -1) { - m_event["iconThumbnail"] = thumbFile; - } - - if (m_imgpos.empty()) { - fillThumbnailList(); - } - } - - void error(const QString &error, const QUrl &uri) { - qCritical() << __FILE__ << __LINE__ << m_event["id"] << uri << error; - - // For some reason this slot is called twice for the same error if - // the Thumbnailer1 service is unavailable. - if (m_imgpos.empty()) { - return; - } - - QString origFile = uri.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority); - m_imgpos.remove(origFile); - - if (m_imgpos.empty()) { - fillThumbnailList(); - } - } - -private: - void fillThumbnailList() { - QStringList thumbnails; - foreach (const QString &orig, m_event["imageList"].toStringList()) { - thumbnails << m_imgmap[orig]; - } - m_event["thumbnailList"] = thumbnails; - emit eventReady(m_event); - deleteLater(); // FIXME: is this right way to deallocate memory? - } - -private: - QVariantMap m_event; - QMap<QString, int> m_imgpos; - QMap<QString, QString> m_imgmap; -}; - --- src/fakefeeder/feeder.cpp +++ src/fakefeeder/feeder.cpp @@ -31,8 +31,6 @@ */ #include "feeder.h" -#include <stdlib.h> -#include <stdio.h> Feeder::Feeder() { @@ -53,7 +51,7 @@ QUrl("http://www.engadget.com/2012/05/07/mastercard-introduces-paypass-wallet-services-online-and-api-at/"), QString("fakefeeder"), QString("fakefeeder")); - fprintf(stderr, "Ret %d\n", ret); + qDebug() << "Ret" << ret; feed->addItem(QString("icon-m-content-document"), QString("Gogo grabs 1MHz spectrum from JetBlue subsidiary LiveTV, beefs up in-flight bandwidth "), @@ -61,7 +59,7 @@ QStringList("/home/nemo/merlogo.png"), QDateTime::currentDateTime(), QString("by Michael Gorman"), - false, + true, QUrl("http://www.engadget.com/2012/05/07/gogo-buys-1mhz-spectrum-inflight-wifi/"), QString("fakefeeder"), QString("fakefeeder")); --- src/libeventfeed/event.cpp +++ src/libeventfeed/event.cpp @@ -42,9 +42,7 @@ const bool &video, const QString &url, const QString &sourceName, - const QString &sourceDisplayName, - const QString &iconThumbnail, - const QStringList &thumbnailList) + const QString &sourceDisplayName) : id(eid), m_icon(icon), m_title(title), @@ -55,9 +53,7 @@ m_video(video), m_url(url), m_sourceName(sourceName), - m_sourceDisplayName(sourceDisplayName), - m_iconThumbnail(iconThumbnail), - m_thumbnailList(thumbnailList) + m_sourceDisplayName(sourceDisplayName) { } --- src/libeventfeed/event.h +++ src/libeventfeed/event.h @@ -49,9 +49,7 @@ const bool &video, const QString &url, const QString &sourceName, - const QString &sourceDisplayName, - const QString &iconThumbnail, - const QStringList &thumbnailList); + const QString &sourceDisplayName); const qlonglong id; @@ -77,8 +75,6 @@ QString m_url; QString m_sourceName; QString m_sourceDisplayName; - QString m_iconThumbnail; - QStringList m_thumbnailList; }; #endif /* EVENT_H */ --- src/libeventfeed/eventstorage.cpp +++ src/libeventfeed/eventstorage.cpp @@ -30,7 +30,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." */ -#include <QDebug> #include <QDir> #include <QtCore/QVariant> #include "eventstorage.h" @@ -63,6 +62,19 @@ if (!m_db.open() || !isSchemaValid()) { reset(); + } else { + QSqlQuery query; + + if (!query.exec("PRAGMA foreign_keys = ON")) { + qFatal("No foreign keys support in SQLite"); + } + + if (!query.exec("SELECT count(*) FROM events")) { + qFatal("Wrong DB schema"); + } + + query.next(); + m_itemCount = query.value(0).toLongLong(); } } @@ -102,23 +114,26 @@ id = last_id.toLongLong(); if (!icon.isEmpty()) { - query.prepare("INSERT INTO images (id, position, originalPath) VALUES " - "(:id, :position, :originalPath)"); + query.prepare("INSERT INTO images (id, position, originalPath, type) VALUES " + "(:id, :position, :originalPath, 'image')"); query.bindValue(":id", id); query.bindValue(":position", -1); query.bindValue(":originalPath", icon); query.exec(); } - qDebug() << __FILE__ << __LINE__ << "imageList:" << parameters["imageList"].toStringList(); int counter = 0; foreach (const QString &imgpath, parameters["imageList"].toStringList()) { - qDebug() << "Adding " << imgpath << " to event " << id; - query.prepare("INSERT INTO images (id, position, originalPath) VALUES " - "(:id, :position, :originalPath)"); + query.prepare("INSERT INTO images (id, position, originalPath, type) VALUES " + "(:id, :position, :originalPath, :type)"); query.bindValue(":id", id); query.bindValue(":position", counter); query.bindValue(":originalPath", imgpath); + if (counter == 0 && parameters["video"].toBool()) { + query.bindValue(":type", "video"); + } else { + query.bindValue(":type", "image"); + } query.exec(); counter++; } @@ -137,9 +152,6 @@ query.exec(); if (query.numRowsAffected() > 0) { m_itemCount--; - query.prepare("DELETE FROM images WHERE id = :id"); - query.bindValue(":id", id); - query.exec(); return true; } else { return false; @@ -160,10 +172,6 @@ query.prepare("DELETE FROM events WHERE sourceName = :sourceName"); query.bindValue(":sourceName", sourceName); query.exec(); - query.prepare("DELETE FROM images WHERE id IN " - "(SELECT id FROM events WHERE sourceName = :sourceName)"); - query.bindValue(":sourceName", sourceName); - query.exec(); m_db.commit(); m_itemCount -= ids.size(); return ids; @@ -175,7 +183,7 @@ QSqlQuery query, query_img; query.exec("SELECT e.id, e.title, e.body, e.timestamp, e.footer, " "e.url, e.sourceName, e.sourceDisplayName, " - "i.originalPath, i.thumbnailPath FROM events e " + "i.originalPath FROM events e " "LEFT OUTER JOIN images i ON i.id = e.id AND " "i.position = -1 " "ORDER BY e.timestamp DESC, e.id DESC"); @@ -189,42 +197,25 @@ QString sourceName = query.value(6).toString(); QString sourceDisplayName = query.value(7).toString(); QString icon = query.value(8).toString(); - QString iconThumbnail = query.value(9).toString(); - // TODO: try to reduce the amount of SQL queries - query_img.prepare("SELECT originalPath, thumbnailPath FROM images " + query_img.prepare("SELECT originalPath FROM images " "WHERE id = :id AND position >= 0 " "ORDER BY position ASC"); query_img.bindValue(":id", id); query_img.exec(); - QStringList images, thumbnails; + QStringList images; while (query_img.next()) { images.append(query_img.value(0).toString()); - thumbnails.append(query_img.value(1).toString()); } Event* event = new Event(id, icon, title, body, images, timestamp, footer, false, url, sourceName, - sourceDisplayName, iconThumbnail, - thumbnails); + sourceDisplayName); events.append(event); } return events; } -void EventStorage::saveThumbnail(const qlonglong &id, const int &position, - const QString &image) -{ - qDebug() << __FILE__ << __LINE__ << "updating " << id << position << image; - QSqlQuery query; - query.prepare("UPDATE images SET thumbnailPath = :path" - "WHERE id = :id AND " "position = :position"); - query.bindValue(":path", image); - query.bindValue(":id", id); - query.bindValue(":position", position); - query.exec(); -} - void EventStorage::reset() { if (QFile::exists(m_dbname)) { @@ -249,8 +240,10 @@ ret = ret && QSqlQuery().exec( "CREATE TABLE images (" "id INTEGER, position INTEGER, " - "originalPath TEXT, thumbnailPath TEXT, " - "type TEXT, PRIMARY KEY(id, position))"); + "originalPath TEXT, " + "type TEXT, PRIMARY KEY(id, position) " + "FOREIGN KEY(id) REFERENCES events(id) ON DELETE CASCADE)"); + ret = ret && QSqlQuery().exec("PRAGMA user_version=" STR(DB_SCHEMA_VERSION)); if (!ret) { qFatal("Can't create db schema"); } @@ -260,13 +253,14 @@ bool EventStorage::isSchemaValid() { QSqlQuery query; - if (!query.exec("SELECT count(*) FROM events")) { + + if (!query.exec("PRAGMA user_version")) { return false; } - // FIXME: this method should be free of side effects - // next two line semantically belong to instance initialization query.next(); - m_itemCount = query.value(0).toLongLong(); + if (query.value(0).toLongLong() != DB_SCHEMA_VERSION) { + return false; + } return true; } --- src/libeventfeed/eventstorage.h +++ src/libeventfeed/eventstorage.h @@ -41,6 +41,7 @@ #define MAX_EVENT_ITEMS 250 #define EVENT_COUNT_HYSTERESIS 20 +#define DB_SCHEMA_VERSION 2 class EventStorage : public QObject { @@ -56,8 +57,6 @@ bool removeItem(const qlonglong &id); const QList<qlonglong> removeItemsBySourceName(const QString &sourceName); QList<Event *> getAllItems(); - void saveThumbnail(const qlonglong &id, const int &position, - const QString &image); signals: void itemsOutdated(const QList<qlonglong>& ids); --- src/libeventfeed/libeventfeed.pro +++ src/libeventfeed/libeventfeed.pro @@ -17,12 +17,4 @@ SOURCES = eventstorage.cpp \ event.cpp -headers.files = $$HEADERS -headers.path = $$INSTALL_ROOT$$PREFIX/include/$$TARGET - -prf.path = $$[QT_INSTALL_DATA]/mkspecs/features -prf.files = eventfeed.prf - -INSTALLS += target \ - headers \ - prf +INSTALLS += target --- src/widget/eventmodel.cpp +++ src/widget/eventmodel.cpp @@ -82,6 +82,8 @@ int EventModel::rowCount(const QModelIndex &parent) const { + Q_UNUSED(parent); + return m_events.count(); } @@ -131,9 +133,7 @@ ev["video"].toBool(), ev["url"].toString(), ev["sourceName"].toString(), - ev["sourceDisplayName"].toString(), - ev["iconThumbnail"].toString(), - ev["thumbnailList"].toStringList()); + ev["sourceDisplayName"].toString()); beginInsertRows(QModelIndex(), 0, 0); m_events.prepend(event); endInsertRows(); @@ -151,8 +151,10 @@ } } -void EventModel::connectFeeder(QString str) +void EventModel::connectFeeder(const QString &serviceName) { + Q_UNUSED(serviceName); + if (m_feeder) { return; } @@ -165,7 +167,10 @@ this, SLOT(removeEvents(const QList<qlonglong>&))); } -void EventModel::disconnectFeeder(QString) { +void EventModel::disconnectFeeder(const QString &serviceName) +{ + Q_UNUSED(serviceName); + if (m_feeder) { delete m_feeder; m_feeder = NULL; --- src/widget/eventmodel.h +++ src/widget/eventmodel.h @@ -76,8 +76,8 @@ QDBusServiceWatcher *m_watcher; private slots: - void connectFeeder(QString = ""); - void disconnectFeeder(QString = ""); + void connectFeeder(const QString &serviceName = ""); + void disconnectFeeder(const QString &serviceName = ""); }; #endif /* EVENTMODEL_H */ --- src/widget/eventsqmlplugin.cpp +++ src/widget/eventsqmlplugin.cpp @@ -35,6 +35,11 @@ #include "eventsqmlplugin.h" #include "eventmodel.h" +EventsQmlPlugin::EventsQmlPlugin(QObject *parent) : + QDeclarativeExtensionPlugin(parent) +{ +} + void EventsQmlPlugin::registerTypes(const char *uri) { Q_ASSERT(uri == QLatin1String("org.nemomobile.events")); --- src/widget/eventsqmlplugin.h +++ src/widget/eventsqmlplugin.h @@ -39,6 +39,7 @@ { Q_OBJECT public: + explicit EventsQmlPlugin(QObject *parent = 0); void registerTypes(const char *uri); }; --- src/widget/widget.pro +++ src/widget/widget.pro @@ -3,7 +3,6 @@ TEMPLATE = lib CONFIG += qt plugin -# FIXME: is sql really needed here? QT += declarative dbus sql TARGET = qmleventsplugin ++++++ eventfeed.yaml --- eventfeed.yaml +++ eventfeed.yaml @@ -1,37 +1,36 @@ Name: eventfeed Summary: Event feed subsystem -Version: 0.0.1 +Version: 0.1.0 Release: 0 Group: System/GUI/Other -License: Apache License +License: BSD License URL: http://www.meego.com Sources: - "%{name}-%{version}.tar.bz2" Description: | - Desc for event feed subsystem + This package provides a D-Bus service and a QML component needed to show | + event items. +Obsoletes: + - eventfeed-qmlapi + - libeventfeed + - libeventfeed-devel PkgBR: - qt-devel-tools - - libthumbnailer-devel PkgConfigBR: - QtCore >= 4.6.0 - QtDBus - QtGui - - dbus-1 Configure: none Builder: qmake Files: - "%{_usr}/bin/eventfeedd" - "%{_datadir}/dbus-1/*" + - "%{_libdir}/qt4/imports/org/nemomobile/events/*" + - "%{_libdir}/libeventfeed.so.*" + - "%exclude %{_libdir}/libeventfeed.so" + SubPackages: - - Name: qmlapi - AutoDepend: no - Group: System/GUI/Other - Summary: QML widget for events - Description: | - This package provides QML widget for events. - Files: - - "%{_libdir}/qt4/imports/org/nemomobile/events/*" - Name: libmeegotouchevents AsWholeName: yes Summary: D-Bus interface for MeegoTouch Events @@ -46,30 +45,14 @@ AutoDepend: no Summary: Development files for libmeegotouchevents Group: Development/Libraries + Requires: + - libmeegotouchevents = %{version} Description: | This package contains development files for libmeegotouchevents. Files: - "%{_libdir}/libmeegotouchevents.so" - "%{_includedir}/meegotouchevents/*.h" - "%{_datadir}/qt4/mkspecs/features/meegotouchevents.prf" - - Name: libeventfeed - Group: Applications/System - Summary: Event feed library - AsWholeName: yes - Description: | - This package contains library required to query event storage. - Files: - - "%{_libdir}/libeventfeed.so.*" - - Name: libeventfeed-devel - Group: Development/Libraries - Summary: Development files for libeventfeed - AsWholeName: yes - Description: | - This package contains development files for libeventfeed. - Files: - - "%{_libdir}/libeventfeed.so" - - "%{_includedir}/eventfeed/*.h" - - "%{_datadir}/qt4/mkspecs/features/eventfeed.prf" - Name: fakefeeder AsWholeName: yes Group: Applications/System
