#include "notification-ex/dbus_connection_manager.h"
#include "notification-ex/ex_util.h"
#include "notification-ex/item_info_internal.h"
+#include "notification-ex/shared_file.h"
#ifdef LOG_TAG
#undef LOG_TAG
int Reporter::Post(std::shared_ptr<item::AbstractItem> noti) {
LOGI("Post noti");
static_pointer_cast<IItemInfoInternal>(noti->GetInfo())->SetTime(time(NULL));
+ SharedFile* shared_file = new SharedFile();
+ shared_file->CopyPrivateFile(noti);
+ delete shared_file;
+
return impl_->SendNotify(noti, EventInfo::Post);
}
static_pointer_cast<IItemInfoInternal>(i->GetInfo())->SetTime(time(NULL));
Bundle b = i->Serialize();
serialized_list.push_back(b);
+
+ SharedFile* shared_file = new SharedFile();
+ shared_file->CopyPrivateFile(i);
+ delete shared_file;
}
impl_->sender_->Notify(info, serialized_list);
return info.GetRequestId();
int Reporter::Update(std::shared_ptr<AbstractItem> noti) {
static_pointer_cast<IItemInfoInternal>(noti->GetInfo())->SetTime(time(NULL));
+ SharedFile* shared_file = new SharedFile();
+ shared_file->CopyPrivateFile(noti);
+ delete shared_file;
+
return impl_->SendNotify(noti, EventInfo::Update);
}
return info.GetRequestId();
}
+int Reporter::DeleteByChannel(string channel) {
+ Bundle serialized;
+ EventInfo info(EventInfo::DeleteAll, util::GetAppId(), channel);
+ list<Bundle> serialized_list {serialized};
+ impl_->sender_->Notify(info, serialized_list, util::GetAppId());
+ return info.GetRequestId();
+}
+
std::unique_ptr<AbstractItem> Reporter::FindByRootID(std::string id) {
Bundle serialized;
EventInfo info(EventInfo::Get, util::GetAppId(), "", id);
}
Bundle b = result.front();
unique_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
- return move(gen_item);
+ return gen_item;
+}
+
+list<unique_ptr<AbstractItem>> Reporter::FindByChannel(string channel) {
+ Bundle serialized;
+ EventInfo info(EventInfo::Get, util::GetAppId(), channel, "");
+ list<Bundle> result = impl_->sender_->Request(info);
+ if (result.size() == 0) {
+ LOGE("Fail to get noti");
+ return list<unique_ptr<item::AbstractItem>>{};
+ }
+
+ list<unique_ptr<AbstractItem>> gen_item_list;
+ for (auto& i : result)
+ gen_item_list.push_back(ItemInflator::Create(i));
+
+ return gen_item_list;
+}
+
+list<unique_ptr<AbstractItem>> Reporter::FindAll() {
+ Bundle serialized;
+ EventInfo info(EventInfo::Get, util::GetAppId(), "", "");
+ list<Bundle> result = impl_->sender_->Request(info);
+ if (result.size() == 0) {
+ LOGE("Fail to get noti");
+ return list<unique_ptr<item::AbstractItem>>{};
+ }
+
+ list<unique_ptr<AbstractItem>> gen_item_list;
+ for (auto& i : result)
+ gen_item_list.push_back(ItemInflator::Create(i));
+
+ return gen_item_list;
}
int Reporter::SendEvent(const IEventInfo& info,
return NOTIFICATION_EX_REPORTER_OBJECT_PATH;
}
+void Reporter::OnRegister(const IEventInfo& info) {
+}
+
} // namespace notification