TizenRefApp-7872 Dismiss all option does not work 91/108491/1
authorSergei Kobec <s.kobec@samsung.com>
Wed, 4 Jan 2017 13:24:50 +0000 (15:24 +0200)
committerSergei Kobec <s.kobec@samsung.com>
Wed, 4 Jan 2017 13:24:50 +0000 (15:24 +0200)
Change-Id: I9534c88e375a36f2ee8d2a5111d7b18954cbe1df
Signed-off-by: Sergei Kobec <s.kobec@samsung.com>
app-control/alert/CalAlertModel.cpp
app-control/alert/CalAlertModel.h

index 799efae..0f211bd 100644 (file)
@@ -79,8 +79,11 @@ void CalAlertModel::snoozeAll(void)
        for (int i = 0; i < count; i++) {
                std::shared_ptr<CalAlertNotificationItem> alertItem = __alertData->getAt(i);
                if (alertItem) {
+                       if (alertItem->isSnoozed()) {
+                               __unscheduleEvent(alertItem);
+                       }
+                       __scheduleEvent(alertItem);
                        alertItem->setSnoozed(true);
-                       __snooze(alertItem);
                }
        }
        CalStatusBarManager::getInstance().update(__alertData);
@@ -96,7 +99,10 @@ void CalAlertModel::snooze(int nth)
                return;
        }
 
-       __snooze(alertItem);
+       if (alertItem->isSnoozed()) {
+               __unscheduleEvent(alertItem);
+       }
+       __scheduleEvent(alertItem);
        alertItem->setSnoozed(true);
        CalStatusBarManager::getInstance().update(__alertData);
 }
@@ -109,7 +115,7 @@ void CalAlertModel::dismissAll(void)
                for (int i = 0; i < count; i++) {
                        std::shared_ptr<CalAlertNotificationItem> alertItem = __alertData->getAt(i);
                        if (alertItem->isSnoozed()) {
-                               __dismiss(alertItem);
+                               __unscheduleEvent(alertItem);
                        }
                }
                __alertData->clear();
@@ -127,7 +133,7 @@ void CalAlertModel::dismiss(int nth)
        }
 
        if (alertItem->isSnoozed()) {
-               __dismiss(alertItem);
+               __unscheduleEvent(alertItem);
        }
 
        __alertData->remove(nth);
@@ -138,6 +144,11 @@ void CalAlertModel::dismiss(std::vector<int> &nths)
 {
        WENTER();
        for (auto nth : nths) {
+               std::shared_ptr<CalAlertNotificationItem> alertItem = __alertData->getAt(nth);
+               if (alertItem->isSnoozed()) {
+                       __unscheduleEvent(alertItem);
+               }
+
                __alertData->remove(nth);
        }
        CalStatusBarManager::getInstance().update(__alertData);
@@ -222,7 +233,7 @@ int CalAlertModel::getSnoozeMinute(void)
        return min;
 }
 
-void CalAlertModel::__snooze(std::shared_ptr<CalAlertNotificationItem> &item)
+void CalAlertModel::__scheduleEvent(std::shared_ptr<CalAlertNotificationItem> &item)
 {
        WENTER();
        WDEBUG("index[%d]", item->getScheduleId());
@@ -263,7 +274,7 @@ void CalAlertModel::__snooze(std::shared_ptr<CalAlertNotificationItem> &item)
        app_control_destroy(service);
 }
 
-void CalAlertModel::__dismiss(std::shared_ptr<CalAlertNotificationItem> &item)
+void CalAlertModel::__unscheduleEvent(std::shared_ptr<CalAlertNotificationItem> &item)
 {
        WENTER();
        int alarmId = item->getAlarmId();
index 4a0f107..ff526d3 100644 (file)
@@ -152,8 +152,8 @@ public:
 private:
        WDISABLE_COPY_AND_ASSIGN(CalAlertModel);
 
-       void __snooze(std::shared_ptr<CalAlertNotificationItem> &item);
-       void __dismiss(std::shared_ptr<CalAlertNotificationItem> &item);
+       void __scheduleEvent(std::shared_ptr<CalAlertNotificationItem> &item);
+       void __unscheduleEvent(std::shared_ptr<CalAlertNotificationItem> &item);
 
        std::shared_ptr<CalAlertData> __alertData;
 };