I have made the following changes intended for : CE:UX:MTF / lipstick 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/8109 Thank You, vesuri [This message was auto-generated] --- Request # 8109: Messages from BOSS: State: review at 2013-02-18T17:14:38 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: home:vesuri:branches:CE:UX:MTF / lipstick -> CE:UX:MTF / lipstick changes files: -------------- --- lipstick.changes +++ lipstick.changes @@ -0,0 +1,3 @@ +* Mon Feb 18 2013 Vesa Halttunen <[email protected]> - 0.9.3 +- Add functionality to remove all user removable notifications (from Vesa) + old: ---- lipstick-0.9.2.tar.bz2 new: ---- lipstick-0.9.3.tar.bz2 spec files: ----------- --- lipstick.spec +++ lipstick.spec @@ -9,7 +9,7 @@ # << macros Summary: QML toolkit for homescreen creation -Version: 0.9.2 +Version: 0.9.3 Release: 1 Group: System/Libraries License: LGPLv2.1 other changes: -------------- ++++++ lipstick-0.9.2.tar.bz2 -> lipstick-0.9.3.tar.bz2 --- src/notifications/notificationlistmodel.cpp +++ src/notifications/notificationlistmodel.cpp @@ -25,6 +25,7 @@ connect(NotificationManager::instance(), SIGNAL(notificationModified(uint)), this, SLOT(updateNotification(uint))); connect(NotificationManager::instance(), SIGNAL(notificationRemoved(uint)), this, SLOT(removeNotification(uint))); + connect(this, SIGNAL(clearRequested()), NotificationManager::instance(), SLOT(removeUserRemovableNotifications())); } NotificationListModel::~NotificationListModel() --- src/notifications/notificationlistmodel.h +++ src/notifications/notificationlistmodel.h @@ -29,6 +29,9 @@ explicit NotificationListModel(QObject *parent = 0); virtual ~NotificationListModel(); +signals: + void clearRequested(); + private slots: void updateNotification(uint id); void removeNotification(uint id); --- src/notifications/notificationmanager.cpp +++ src/notifications/notificationmanager.cpp @@ -506,21 +506,34 @@ } } - QVariant userRemovable = notification->hints().value(HINT_USER_REMOVABLE); - if (!userRemovable.isValid() || userRemovable.toBool()) { - // The notification should be removed if user removability is not defined (defaults to true) or is set to true - QVariant userCloseable = notification->hints().value(HINT_USER_CLOSEABLE); - if (!userCloseable.isValid() || userCloseable.toBool()) { - // The notification should be closed if user closeability is not defined (defaults to true) or is set to true - CloseNotification(id, NotificationDismissedByUser); - } else { - // Uncloseable notifications should be only removed - emit notificationRemoved(id); + removeNotificationIfUserRemovable(id); + } + } +} - // Mark the notification as hidden - execSQL("INSERT INTO hints VALUES (?, ?, ?)", QVariantList() << id << HINT_HIDDEN << true); - } - } +void NotificationManager::removeNotificationIfUserRemovable(uint id) +{ + Notification *notification = notifications[id]; + QVariant userRemovable = notification->hints().value(HINT_USER_REMOVABLE); + if (!userRemovable.isValid() || userRemovable.toBool()) { + // The notification should be removed if user removability is not defined (defaults to true) or is set to true + QVariant userCloseable = notification->hints().value(HINT_USER_CLOSEABLE); + if (!userCloseable.isValid() || userCloseable.toBool()) { + // The notification should be closed if user closeability is not defined (defaults to true) or is set to true + CloseNotification(id, NotificationDismissedByUser); + } else { + // Uncloseable notifications should be only removed + emit notificationRemoved(id); + + // Mark the notification as hidden + execSQL("INSERT INTO hints VALUES (?, ?, ?)", QVariantList() << id << HINT_HIDDEN << true); } } } + +void NotificationManager::removeUserRemovableNotifications() +{ + foreach(uint id, notifications.keys()) { + removeNotificationIfUserRemovable(id); + } +} --- src/notifications/notificationmanager.h +++ src/notifications/notificationmanager.h @@ -214,6 +214,12 @@ */ void notificationRemoved(uint id); +public slots: + /*! + * Removes all notifications which are user removable. + */ + void removeUserRemovableNotifications(); + private slots: /*! * Removes all notifications with the specified category. @@ -332,6 +338,13 @@ */ void execSQL(const QString &command, const QVariantList &args = QVariantList()); + /*! + * Removes a notification if it is removable by the user. + * + * \param id the ID of the notification to be removed + */ + void removeNotificationIfUserRemovable(uint id); + //! The singleton notification manager instance static NotificationManager *instance_; --- src/src.pro +++ src/src.pro @@ -3,7 +3,7 @@ TEMPLATE = lib TARGET = lipstick -VERSION = 0.9.2 +VERSION = 0.9.3 DEFINES += LIPSTICK_BUILD_LIBRARY VERSION=\\\"$$VERSION\\\" --- tests/stubs/notificationmanager_stub.h +++ tests/stubs/notificationmanager_stub.h @@ -35,6 +35,7 @@ virtual void updateNotificationsWithCategory(const QString &category); virtual void commit(); virtual void invokeAction(const QString &action); + virtual void removeUserRemovableNotifications(); virtual void NotificationManagerConstructor(QObject *parent); virtual void NotificationManagerDestructor(); }; @@ -114,6 +115,10 @@ stubMethodEntered("invokeAction",params); } +void NotificationManagerStub::removeUserRemovableNotifications() { + stubMethodEntered("removeUserRemovableNotifications"); +} + void NotificationManagerStub::NotificationManagerConstructor(QObject *parent) { Q_UNUSED(parent); @@ -187,6 +192,10 @@ gNotificationManagerStub->invokeAction(action); } +void NotificationManager::removeUserRemovableNotifications() { + gNotificationManagerStub->removeUserRemovableNotifications(); +} + NotificationManager::NotificationManager(QObject *parent) { gNotificationManagerStub->NotificationManagerConstructor(parent); } --- tests/ut_notificationfeedbackplayer/ut_notificationfeedbackplayer.cpp +++ tests/ut_notificationfeedbackplayer/ut_notificationfeedbackplayer.cpp @@ -51,6 +51,10 @@ { } +void NotificationManager::removeUserRemovableNotifications() +{ +} + NotificationManager *notificationManagerInstance = 0; NotificationManager *NotificationManager::instance() { --- tests/ut_notificationlistmodel/ut_notificationlistmodel.cpp +++ tests/ut_notificationlistmodel/ut_notificationlistmodel.cpp @@ -27,6 +27,14 @@ gNotificationManagerStub->stubReset(); } +void Ut_NotificationListModel::testSignalConnections() +{ + NotificationListModel model; + QCOMPARE(disconnect(NotificationManager::instance(), SIGNAL(notificationModified(uint)), &model, SLOT(updateNotification(uint))), true); + QCOMPARE(disconnect(NotificationManager::instance(), SIGNAL(notificationRemoved(uint)), &model, SLOT(removeNotification(uint))), true); + QCOMPARE(disconnect(&model, SIGNAL(clearRequested()), NotificationManager::instance(), SLOT(removeUserRemovableNotifications())), true); +} + void Ut_NotificationListModel::testModelPopulatesOnConstruction() { Notification notification("appName", 1, "appIcon", "summary", "body", QStringList() << "action", QVariantHash(), 1); --- tests/ut_notificationlistmodel/ut_notificationlistmodel.h +++ tests/ut_notificationlistmodel/ut_notificationlistmodel.h @@ -24,6 +24,7 @@ private slots: void init(); void cleanup(); + void testSignalConnections(); void testModelPopulatesOnConstruction(); void testNotificationIsOnlyAddedIfNotAlreadyAdded(); void testNotificationIsNotAddedIfNoSummaryOrBody_data(); --- tests/ut_notificationmanager/ut_notificationmanager.cpp +++ tests/ut_notificationmanager/ut_notificationmanager.cpp @@ -724,30 +724,39 @@ QVariantHash hints1; QVariantHash hints2; QVariantHash hints3; + QVariantHash hints4; + QVariantHash hints5; hints2.insert(NotificationManager::HINT_USER_REMOVABLE, true); hints3.insert(NotificationManager::HINT_USER_REMOVABLE, false); + hints4.insert(NotificationManager::HINT_USER_CLOSEABLE, true); + hints5.insert(NotificationManager::HINT_USER_CLOSEABLE, false); uint id1 = manager->Notify("app1", 0, QString(), QString(), QString(), QStringList(), hints1, 0); uint id2 = manager->Notify("app2", 0, QString(), QString(), QString(), QStringList(), hints2, 0); uint id3 = manager->Notify("app3", 0, QString(), QString(), QString(), QStringList(), hints3, 0); - Notification *notification1 = manager->notification(id1); - Notification *notification2 = manager->notification(id2); - Notification *notification3 = manager->notification(id3); - connect(this, SIGNAL(actionInvoked(QString)), notification1, SIGNAL(actionInvoked(QString))); - connect(this, SIGNAL(actionInvoked(QString)), notification2, SIGNAL(actionInvoked(QString))); - connect(this, SIGNAL(actionInvoked(QString)), notification3, SIGNAL(actionInvoked(QString))); + uint id4 = manager->Notify("app4", 0, QString(), QString(), QString(), QStringList(), hints4, 0); + uint id5 = manager->Notify("app5", 0, QString(), QString(), QString(), QStringList(), hints5, 0); + connect(this, SIGNAL(actionInvoked(QString)), manager->notification(id1), SIGNAL(actionInvoked(QString))); + connect(this, SIGNAL(actionInvoked(QString)), manager->notification(id2), SIGNAL(actionInvoked(QString))); + connect(this, SIGNAL(actionInvoked(QString)), manager->notification(id3), SIGNAL(actionInvoked(QString))); + connect(this, SIGNAL(actionInvoked(QString)), manager->notification(id4), SIGNAL(actionInvoked(QString))); + connect(this, SIGNAL(actionInvoked(QString)), manager->notification(id5), SIGNAL(actionInvoked(QString))); // Make all notifications emit the actionInvoked() signal for action "action"; removable notifications should get removed QSignalSpy removedSpy(manager, SIGNAL(notificationRemoved(uint))); QSignalSpy closedSpy(manager, SIGNAL(NotificationClosed(uint,uint))); emit actionInvoked("action"); - QCOMPARE(removedSpy.count(), 2); + QCOMPARE(removedSpy.count(), 4); QCOMPARE(removedSpy.at(0).at(0).toUInt(), id1); QCOMPARE(removedSpy.at(1).at(0).toUInt(), id2); - QCOMPARE(closedSpy.count(), 2); + QCOMPARE(removedSpy.at(2).at(0).toUInt(), id4); + QCOMPARE(removedSpy.at(3).at(0).toUInt(), id5); + QCOMPARE(closedSpy.count(), 3); QCOMPARE(closedSpy.at(0).at(0).toUInt(), id1); QCOMPARE(closedSpy.at(0).at(1).toInt(), (int)NotificationManager::NotificationDismissedByUser); QCOMPARE(closedSpy.at(1).at(0).toUInt(), id2); QCOMPARE(closedSpy.at(1).at(1).toInt(), (int)NotificationManager::NotificationDismissedByUser); + QCOMPARE(closedSpy.at(2).at(0).toUInt(), id4); + QCOMPARE(closedSpy.at(2).at(1).toInt(), (int)NotificationManager::NotificationDismissedByUser); } void Ut_NotificationManager::testInvokingActionRemovesNotificationIfUserRemovableAndNotCloseable() @@ -827,4 +836,39 @@ QCOMPARE(notifications.at(0).expireTimeout(), 3); } +void Ut_NotificationManager::testRemoveUserRemovableNotifications() +{ + NotificationManager *manager = NotificationManager::instance(); + QVariantHash hints1; + QVariantHash hints2; + QVariantHash hints3; + QVariantHash hints4; + QVariantHash hints5; + hints2.insert(NotificationManager::HINT_USER_REMOVABLE, true); + hints3.insert(NotificationManager::HINT_USER_REMOVABLE, false); + hints4.insert(NotificationManager::HINT_USER_CLOSEABLE, true); + hints5.insert(NotificationManager::HINT_USER_CLOSEABLE, false); + uint id1 = manager->Notify("app1", 0, QString(), QString(), QString(), QStringList(), hints1, 0); + uint id2 = manager->Notify("app2", 0, QString(), QString(), QString(), QStringList(), hints2, 0); + manager->Notify("app3", 0, QString(), QString(), QString(), QStringList(), hints3, 0); + uint id4 = manager->Notify("app4", 0, QString(), QString(), QString(), QStringList(), hints4, 0); + uint id5 = manager->Notify("app5", 0, QString(), QString(), QString(), QStringList(), hints5, 0); + + QSignalSpy removedSpy(manager, SIGNAL(notificationRemoved(uint))); + QSignalSpy closedSpy(manager, SIGNAL(NotificationClosed(uint,uint))); + manager->removeUserRemovableNotifications(); + QCOMPARE(removedSpy.count(), 4); + QCOMPARE(removedSpy.at(0).at(0).toUInt(), id1); + QCOMPARE(removedSpy.at(1).at(0).toUInt(), id2); + QCOMPARE(removedSpy.at(2).at(0).toUInt(), id4); + QCOMPARE(removedSpy.at(3).at(0).toUInt(), id5); + QCOMPARE(closedSpy.count(), 3); + QCOMPARE(closedSpy.at(0).at(0).toUInt(), id1); + QCOMPARE(closedSpy.at(0).at(1).toInt(), (int)NotificationManager::NotificationDismissedByUser); + QCOMPARE(closedSpy.at(1).at(0).toUInt(), id2); + QCOMPARE(closedSpy.at(1).at(1).toInt(), (int)NotificationManager::NotificationDismissedByUser); + QCOMPARE(closedSpy.at(2).at(0).toUInt(), id4); + QCOMPARE(closedSpy.at(2).at(1).toInt(), (int)NotificationManager::NotificationDismissedByUser); +} + QTEST_MAIN(Ut_NotificationManager) --- tests/ut_notificationmanager/ut_notificationmanager.h +++ tests/ut_notificationmanager/ut_notificationmanager.h @@ -46,6 +46,7 @@ void testInvokingActionClosesNotificationIfUserRemovable(); void testInvokingActionRemovesNotificationIfUserRemovableAndNotCloseable(); void testListingNotifications(); + void testRemoveUserRemovableNotifications(); signals: void actionInvoked(QString action); --- tests/ut_notificationpreviewpresenter/ut_notificationpreviewpresenter.cpp +++ tests/ut_notificationpreviewpresenter/ut_notificationpreviewpresenter.cpp @@ -123,6 +123,10 @@ return notificationManagerNotification.value(id); } +void NotificationManager::removeUserRemovableNotifications() +{ +} + Notification *createNotification(uint id) { Notification *notification = new Notification; ++++++ lipstick.yaml --- lipstick.yaml +++ lipstick.yaml @@ -1,6 +1,6 @@ Name: lipstick Summary: QML toolkit for homescreen creation -Version: 0.9.2 +Version: 0.9.3 Release: 1 Group: System/Libraries License: LGPLv2.1
