#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"
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);
}
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);
}
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_;
/* noti to viewers */
facade_->DelegateReporterEvent(info, deletedItem);
+
+ facade_->shared_file_.RemovePrivateSharing(deletedItem,
+ facade_->receiver_group_list_);
} else {
SendError(info, static_cast<NotificationError>(ret));
}
if (type == IEventInfo::EventType::DeleteAll) {
OnDelete(info, nullptr);
return;
+ } else if (type == IEventInfo::EventType::Register) {
+ OnRegister(info);
+ return;
}
for (auto& i : noti_list) {
}
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 {
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)
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 {
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 {
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));
}