Add delete all, get count implementation 38/204738/1
authorhyunho <hhstark.kang@samsung.com>
Fri, 26 Apr 2019 04:47:42 +0000 (13:47 +0900)
committerhyunho <hhstark.kang@samsung.com>
Fri, 26 Apr 2019 04:47:42 +0000 (13:47 +0900)
Change-Id: Ieda636fbd0562f033e2e00b7497e4d1f863ab12e
Signed-off-by: hyunho <hhstark.kang@samsung.com>
src/notification_ex_service.cc

index f2f8c23..8d2e5ae 100755 (executable)
@@ -97,12 +97,9 @@ class DPMReporter : public Reporter {
     }
   }
 
-  void OnDelete(const IEventInfo& info,
+  void DoDelete(const IEventInfo& info,
       shared_ptr<item::AbstractItem> deletedItem) {
-    DBG("Delete !!!");
-    int ret;
-
-    ret = DBManager::DeleteNotification(deletedItem);
+    int ret = DBManager::DeleteNotification(deletedItem);
     if (ret == ERROR_NONE) {
       /* noti owner */
       facade_->DelegateManagerEvent(info, deletedItem);
@@ -114,10 +111,29 @@ class DPMReporter : public Reporter {
     }
   }
 
+  void OnDelete(const IEventInfo& info,
+      shared_ptr<item::AbstractItem> deletedItem) {
+    DBG("Delete !!!");
+    if (info.GetEventType() == IEventInfo::EventType::DeleteAll) {
+      list<shared_ptr<item::AbstractItem>> noti_list =
+          DBManager::GetNotificationList(((const IEventInfoInternal&)info).GetUid());
+      for (auto& i : noti_list) {
+        DoDelete(info, i);
+      }
+    } else {
+      DoDelete(info, deletedItem);
+    }
+  }
+
   void OnEvent(const IEventInfo& info,
       list<shared_ptr<item::AbstractItem>> noti_list) override {
     LOGI("Event received (%d) !!", (int)info.GetEventType());
     int type = info.GetEventType();
+    if (type == IEventInfo::EventType::DeleteAll) {
+      OnDelete(info, nullptr);
+      return;
+    }
+
     for (auto& i : noti_list) {
       switch (type) {
       case IEventInfo::EventType::Update:
@@ -137,6 +153,12 @@ class DPMReporter : public Reporter {
     return DBManager::GetNotificationList(((const IEventInfoInternal&)info).GetUid());
   }
 
+  int OnRequestNumber(const IEventInfo& info) override {
+    DBG("Get count !!! %s", info.GetItemId().c_str());
+    return DBManager::GetNotificationList(
+        ((const IEventInfoInternal&)info).GetUid()).size();
+  }
+
   int UpdateHideApp(shared_ptr<item::AbstractItem> updatedItem) {
     int ret;
     string hide_list;
@@ -246,12 +268,9 @@ class DPMManager : public Manager {
     }
   }
 
-  void OnDelete(const IEventInfo& info,
-      shared_ptr<item::AbstractItem> deletedItem) override {
-    DBG("Delete !!!");
-    int ret;
-
-    ret = DBManager::DeleteNotification(deletedItem);
+  void DoDelete(const IEventInfo& info,
+      shared_ptr<item::AbstractItem> deletedItem) {
+    int ret = DBManager::DeleteNotification(deletedItem);
     if (ret == ERROR_NONE) {
       facade_->DelegateReporterEvent(info, deletedItem);
     } else {
@@ -259,6 +278,21 @@ class DPMManager : public Manager {
     }
   }
 
+  void OnDelete(const IEventInfo& info,
+      shared_ptr<item::AbstractItem> deletedItem) override {
+    DBG("Delete !!!");
+    if (info.GetEventType() == IEventInfo::EventType::DeleteAll) {
+      list<shared_ptr<item::AbstractItem>> noti_list =
+          DBManager::GetNotificationList(info.GetOwner(),
+              ((const IEventInfoInternal&)info).GetUid());
+      for (auto& i : noti_list) {
+        DoDelete(info, i);
+      }
+    } else {
+      DoDelete(info, deletedItem);
+    }
+  }
+
   list<shared_ptr<item::AbstractItem>> OnRequestEvent(const IEventInfo& info) override {
     DBG("Get !!! %s", info.GetOwner().c_str());