Set/Unset private sharing 77/207777/13
authormk5004.lee <mk5004.lee@samsung.com>
Wed, 12 Jun 2019 09:54:15 +0000 (18:54 +0900)
committerMyungKi Lee <mk5004.lee@samsung.com>
Wed, 30 Oct 2019 06:37:19 +0000 (06:37 +0000)
Change-Id: I22f9382ca96cc76365a32d855a62ad65db8ef9b3
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
CMakeLists.txt
packaging/data-provider-master.spec
src/notification_ex_service.cc

index 4bf8906..824361f 100644 (file)
@@ -30,6 +30,7 @@ pkg_check_modules(pkgs REQUIRED
        capi-appfw-app-manager
        alarm-service
        libtzplatform-config
+       security-manager
 )
 
 FOREACH(flag ${pkgs_CFLAGS})
index 925c836..96b1b9b 100755 (executable)
@@ -30,6 +30,7 @@ BuildRequires: pkgconfig(shortcut)
 BuildRequires: pkgconfig(libsystemd-daemon)
 BuildRequires: pkgconfig(alarm-service)
 BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(security-manager)
 
 Requires: notification-ex
 Requires(post): dbus
index 67faf91..5bd97b4 100644 (file)
@@ -38,6 +38,7 @@
 #include <notification-ex/ex_util.h>
 #include <notification-ex/ievent_info_internal.h>
 #include <notification-ex/iitem_info_internal.h>
+#include <notification-ex/shared_file.h>
 
 #include "debug.h"
 #include "notification_ex_service.h"
@@ -58,7 +59,8 @@ class DPMFacade {
     hide_map_ = DBManager::GetHideMap();
   }
 
-  void DelegateReporterEvent(const IEventInfo& info, shared_ptr<item::AbstractItem> item) {
+  void DelegateReporterEvent(const IEventInfo& info,
+        shared_ptr<item::AbstractItem> item) {
     reporter_->SendEvent(info, item);
   }
 
@@ -67,7 +69,8 @@ class DPMFacade {
     reporter_->SendEvent(info, itemList);
   }
 
-  void DelegateManagerEvent(const IEventInfo& info, shared_ptr<item::AbstractItem> noti) {
+  void DelegateManagerEvent(const IEventInfo& info,
+        shared_ptr<item::AbstractItem> noti) {
     manager_->SendEvent(info, noti);
   }
 
@@ -106,6 +109,8 @@ class DPMFacade {
   unique_ptr<Reporter> reporter_;
   unique_ptr<Manager> manager_;
   map<string, string> hide_map_;
+  multimap<string, string> receiver_group_list_;
+  SharedFile shared_file_;
 };
 
 static DPMFacade* facade_;
@@ -148,6 +153,9 @@ class DPMReporter : public Reporter {
 
       /* noti to viewers */
       facade_->DelegateReporterEvent(info, deletedItem);
+
+      facade_->shared_file_.RemovePrivateSharing(deletedItem,
+            facade_->receiver_group_list_);
     } else {
       SendError(info, static_cast<NotificationError>(ret));
     }
@@ -174,6 +182,9 @@ class DPMReporter : public Reporter {
     if (type == IEventInfo::EventType::DeleteAll) {
       OnDelete(info, nullptr);
       return;
+    } else if (type == IEventInfo::EventType::Register) {
+      OnRegister(info);
+      return;
     }
 
     for (auto& i : noti_list) {
@@ -191,10 +202,17 @@ class DPMReporter : public Reporter {
   }
 
   list<shared_ptr<item::AbstractItem>> OnRequestEvent(const IEventInfo& info) override {
+    list<shared_ptr<item::AbstractItem>> item_list;
+
     DBG("Get report !!! %s", info.GetItemId().c_str());
-    return DBManager::GetNotificationList(
-        ((const IEventInfoInternal&)info).GetUid(),
-        ((const IEventInfoInternal&)info).GetChannel().c_str());
+    item_list = DBManager::GetNotificationList(
+                ((const IEventInfoInternal&)info).GetUid(),
+                ((const IEventInfoInternal&)info).GetChannel().c_str());
+
+    facade_->shared_file_.SetPrivateSharing(item_list,
+                facade_->receiver_group_list_);
+
+    return item_list;
   }
 
   int OnRequestNumber(const IEventInfo& info) override {
@@ -249,6 +267,20 @@ class DPMReporter : public Reporter {
     return ERROR_NOT_EXIST_ID;
   }
 
+  void OnRegister(const IEventInfo& info) {
+    std::string receiver_group = info.GetChannel();
+    std::string appid = info.GetOwner();
+
+    std::multimap<std::string,std::string>::iterator it;
+    for(auto receiver_group_ : facade_->receiver_group_list_) {
+      if (receiver_group_.first.compare(receiver_group) == 0 &&
+          receiver_group_.second.compare(appid) == 0)
+        return;
+    }
+
+    facade_->receiver_group_list_.insert(make_pair(receiver_group, appid));
+  }
+
  public:
   DPMReporter(std::unique_ptr<IEventSender> sender,
       std::unique_ptr<IEventListener> listener)
@@ -289,6 +321,8 @@ class DPMManager : public Manager {
 
     ret = DBManager::InsertNotification(addedItem);
     if (ret == ERROR_NONE) {
+      facade_->shared_file_.SetPrivateSharing(addedItem,
+            facade_->receiver_group_list_);
       facade_->DelegateReporterEvent(info, addedItem);
       facade_->LaunchDefaultViewer(addedItem, NOTIFICATION_OP_INSERT);
     } else {
@@ -306,6 +340,8 @@ class DPMManager : public Manager {
 
     ret = DBManager::UpdateNotification(updatedItem);
     if (ret == ERROR_NONE) {
+      facade_->shared_file_.UpdatePrivateSharing(updatedItem,
+            facade_->receiver_group_list_);
       facade_->DelegateReporterEvent(info, updatedItem);
       facade_->LaunchDefaultViewer(updatedItem, NOTIFICATION_OP_UPDATE);
     } else {
@@ -315,9 +351,13 @@ class DPMManager : public Manager {
 
   int DoDelete(const IEventInfo& info,
       shared_ptr<item::AbstractItem> deletedItem) {
-    int ret = DBManager::DeleteNotification(deletedItem);
+    int ret;
+
+    ret = DBManager::DeleteNotification(deletedItem);
     if (ret == ERROR_NONE) {
       facade_->DelegateReporterEvent(info, deletedItem);
+      facade_->shared_file_.RemovePrivateSharing(deletedItem,
+            facade_->receiver_group_list_);
     } else {
       SendError(info, static_cast<NotificationError>(ret));
     }