noti_ex_item_h **noti_list, int *count);
int noti_ex_reporter_delete_by_channel(noti_ex_reporter_h handle,
const char *channel, int *request_id);
+int noti_ex_reporter_update_list(noti_ex_reporter_h handle,
+ noti_ex_item_h *noti_list, int count, int *request_id);
+int noti_ex_reporter_delete_list(noti_ex_reporter_h handle,
+ noti_ex_item_h *noti_list, int count, int *request_id);
int noti_ex_manager_delete_by_channel(noti_ex_manager_h handle,
const char *channel, int *request_id);
return ret;
}
-int DBManager::UpdateNotification(shared_ptr<item::AbstractItem> updatedItem) {
- int count, ret;
+int DBManager::UpdateNotification(list<shared_ptr<item::AbstractItem>> updatedItem) {
+ int ret = ERROR_NONE;
char* query;
- uid_t uid =
- static_pointer_cast<IItemInfoInternal>(updatedItem->GetInfo())->GetUid();
- int64_t priv_id = static_pointer_cast<IItemInfoInternal>(
- updatedItem->GetInfo())->GetPrivateId();
-
- ret = GetCount(priv_id,
- updatedItem->GetId(), updatedItem->GetSenderAppId(), uid, &count);
- if (ret != ERROR_NONE) {
- LOGE("fail to get count");
- return ret;
- }
-
- if (count <= 0) {
- LOGE("not exist priv_id(%" PRId64 ") id(%s) for appid(%s)", priv_id,
- updatedItem->GetId().c_str(), updatedItem->GetSenderAppId().c_str());
- return ERROR_NOT_EXIST_ID;
- }
-
sqlite3* db = OpenDB();
if (db == nullptr)
return ERROR_FROM_DB;
- Bundle b = updatedItem->Serialize();
- query = sqlite3_mprintf("UPDATE noti_ex_list SET"
- " pkg_id = %Q, channel = %Q, policy = %d, data = %Q, insert_time = %d"
- " WHERE priv_id = %" PRId64 "",
- GetPkgId(updatedItem->GetSenderAppId(), uid).c_str(),
- updatedItem->GetChannel().c_str(),
- static_cast<int>(updatedItem->GetPolicy()),
- reinterpret_cast<char*>(b.ToRaw().first.get()),
- static_pointer_cast<IItemInfo>(updatedItem->GetInfo())->GetTime(),
- priv_id);
-
- if (!query) {
- LOGE("OOM - sql query");
- CloseDB(db);
- return ERROR_OUT_OF_MEMORY;
- }
-
if (sqlite3_exec(db, "BEGIN TRANSACTION", nullptr, nullptr, nullptr)) {
LOGE("begin transaction error : %s", sqlite3_errmsg(db));
- sqlite3_free(query);
CloseDB(db);
return ERROR_FROM_DB;
}
- ret = ExecuteQuery(db, query, nullptr);
- sqlite3_free(query);
- if (ret != ERROR_NONE)
- goto out;
+ for (auto& i : updatedItem) {
+ uid_t uid = static_pointer_cast<IItemInfoInternal>(i->GetInfo())->GetUid();
+ list<shared_ptr<item::AbstractItem>> item_list =
+ GetNotificationList(i->GetSenderAppId(), i->GetId(), uid);
- ret = UpdateReceiverList(updatedItem, db);
+ if (item_list.empty()) {
+ LOGE("not exist id(%s) for appid(%s)", i->GetId().c_str(), i->GetSenderAppId().c_str());
+ ret = ERROR_NOT_EXIST_ID;
+ break;
+ }
+
+ Bundle b = i->Serialize();
+ query = sqlite3_mprintf("UPDATE noti_ex_list SET"
+ " pkg_id = %Q, channel = %Q, policy = %d, data = %Q, insert_time = %d"
+ " WHERE priv_id = %" PRId64 "",
+ GetPkgId(i->GetSenderAppId(), uid).c_str(),
+ i->GetChannel().c_str(),
+ static_cast<int>(i->GetPolicy()),
+ reinterpret_cast<char*>(b.ToRaw().first.get()),
+ static_pointer_cast<IItemInfo>(i->GetInfo())->GetTime(),
+ static_pointer_cast<IItemInfoInternal>(item_list.front()->GetInfo())->GetPrivateId());
+ if (!query) {
+ LOGE("OOM - sql query");
+ ret = ERROR_OUT_OF_MEMORY;
+ break;
+ }
+
+ ret = ExecuteQuery(db, query, nullptr);
+ sqlite3_free(query);
+ if (ret != ERROR_NONE)
+ break;
+
+ ret = UpdateReceiverList(i, db);
+ if (ret != ERROR_NONE)
+ break;
+ }
-out:
if (ret == ERROR_NONE) {
if (sqlite3_exec(db, "END TRANSACTION", nullptr, nullptr, nullptr)) {
LOGE("end transaction error : %s", sqlite3_errmsg(db));
}
} else {
if (sqlite3_exec(db, "ROLLBACK TRANSACTION", nullptr, nullptr, nullptr))
- LOGE("rollback transaction error : %s", sqlite3_errmsg(db));
+ LOGE("rollback transaction error : %s", sqlite3_errmsg(db));
}
CloseDB(db);
return item_list;
}
-list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList
- (string app_id, string root_id, uid_t uid) {
+list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList(
+ string app_id, string root_id, uid_t uid) {
char* query;
list<shared_ptr<item::AbstractItem>> item_list;
return item_list;
}
-list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList
- (string app_id, int64_t priv_id, uid_t uid) {
+list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList(
+ string app_id, int64_t priv_id, uid_t uid) {
char* query;
list<shared_ptr<item::AbstractItem>> item_list;
}
list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList(
- uid_t uid, string channel) {
+ uid_t uid, string channel) {
int ret, sim_mode;
char* query;
list<shared_ptr<item::AbstractItem>> item_list;
return item_list;
}
-int DBManager::DeleteNotification(shared_ptr<item::AbstractItem> deletedItem) {
- int ret;
+int DBManager::DeleteNotification(
+ list<shared_ptr<item::AbstractItem>> deletedItem) {
+ int ret = ERROR_NONE;
char* query;
- int64_t priv_id = static_pointer_cast<IItemInfoInternal>(
- deletedItem->GetInfo())->GetPrivateId();
+ sqlite3* db = OpenDB();
+ if (db == nullptr)
+ return ERROR_FROM_DB;
- query = sqlite3_mprintf("DELETE FROM noti_ex_list WHERE priv_id = %" PRId64 "",
- priv_id);
- if (!query) {
- LOGE("OOM - sql query");
- return ERROR_OUT_OF_MEMORY;
+ if (sqlite3_exec(db, "BEGIN TRANSACTION", nullptr, nullptr, nullptr)) {
+ LOGE("begin transaction error : %s", sqlite3_errmsg(db));
+ CloseDB(db);
+ return ERROR_FROM_DB;
}
- ret = ExecuteQuery(query, nullptr);
- sqlite3_free(query);
+ for (auto& i : deletedItem) {
+ query = sqlite3_mprintf("DELETE FROM noti_ex_list WHERE priv_id = %" PRId64 "",
+ static_pointer_cast<IItemInfoInternal>(i->GetInfo())->GetPrivateId());
+ if (!query) {
+ LOGE("OOM - sql query");
+ ret = ERROR_OUT_OF_MEMORY;
+ break;
+ }
+
+ ret = ExecuteQuery(db, query, nullptr);
+ sqlite3_free(query);
+ if (ret != ERROR_NONE)
+ break;
+ }
+
+ if (ret == ERROR_NONE) {
+ if (sqlite3_exec(db, "END TRANSACTION", nullptr, nullptr, nullptr)) {
+ LOGE("end transaction error : %s", sqlite3_errmsg(db));
+ ret = ERROR_FROM_DB;
+ }
+ } else {
+ if (sqlite3_exec(db, "ROLLBACK TRANSACTION", nullptr, nullptr, nullptr))
+ LOGE("rollback transaction error : %s", sqlite3_errmsg(db));
+ }
+
+ CloseDB(db);
return ret;
}
static int InsertNotification(std::list<std::shared_ptr<item::AbstractItem>> addedItem);
static std::map<std::string, std::string> GetHideMap();
static int UpdateHideList(std::shared_ptr<item::AbstractItem> updatedItem, const std::string& hide_list);
- static int UpdateNotification(std::shared_ptr<item::AbstractItem> updatedItem);
+ static int UpdateNotification(std::list<std::shared_ptr<item::AbstractItem>> updatedItem);
static int GetCount(int64_t priv_id, const std::string& root_id, const std::string& app_id, uid_t uid, int* count);
static int GetCount(const std::string& app_id, uid_t uid, int* count);
- static int DeleteNotification(std::shared_ptr<item::AbstractItem> deletedItem);
+ static int DeleteNotification(std::list<std::shared_ptr<item::AbstractItem>> deletedItem);
static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(uid_t uid, std::string channel = "");
static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(std::string app_id, uid_t uid, std::string channel = "");
static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(std::string app_id, std::string root_id, uid_t uid);
return info.GetRequestId();
}
+int Manager::SendEvent(const IEventInfo& info,
+ list<shared_ptr<item::AbstractItem>> notiList) {
+ list<Bundle> serialized_list;
+ for (auto& i : notiList) {
+ Bundle b = i->Serialize();
+ serialized_list.push_back(b);
+ }
+ impl_->sender_->Notify(info, serialized_list);
+ return info.GetRequestId();
+}
+
list<Bundle> Manager::OnRequest(const IEventInfo& info) {
list<shared_ptr<item::AbstractItem>> item_list = OnRequestEvent(info);
list<Bundle> serialized_list;
break;
}
case EventInfo::Update: {
+ list<shared_ptr<item::AbstractItem>> updated;
for (auto& i : serialized) {
gen_item = ItemInflator::Create(i);
if (std::static_pointer_cast<IItemInfoInternal>(gen_item->GetInfo())
->CanReceive(impl_->receiver_group_))
- OnUpdate(info, gen_item);
+ updated.emplace_back(gen_item);
}
+ if (updated.size() > 0)
+ OnUpdate(info, updated);
break;
}
case EventInfo::Delete: {
+ list<shared_ptr<item::AbstractItem>> deleted;
for (auto& i : serialized) {
gen_item = ItemInflator::Create(i);
if (std::static_pointer_cast<IItemInfoInternal>(gen_item->GetInfo())
->CanReceive(impl_->receiver_group_))
- OnDelete(info, gen_item);
+ deleted.emplace_back(gen_item);
}
+ if (deleted.size() > 0)
+ OnDelete(info, deleted);
break;
}
case EventInfo::Get:
break;
case EventInfo::Count:
break;
- case EventInfo::DeleteAll:
- OnDelete(info, shared_ptr<AbstractItem>(new NullItem()));
+ case EventInfo::DeleteAll: {
+ list<shared_ptr<item::AbstractItem>> deleted;
+ deleted.emplace_back(new NullItem());
+ OnDelete(info, deleted);
break;
+ }
case EventInfo::Custom:
break;
}
}
void Manager::OnUpdate(const IEventInfo& info,
- shared_ptr<item::AbstractItem> updatedItem) {
+ list<shared_ptr<item::AbstractItem>> updatedItem) {
}
void Manager::OnDelete(const IEventInfo& info,
- shared_ptr<item::AbstractItem> deletedItem) {
+ list<shared_ptr<item::AbstractItem>> deletedItem) {
}
void Manager::OnError(NotificationError error, int requestId) {
int Hide(std::shared_ptr<item::AbstractItem> noti);
std::unique_ptr<item::AbstractItem> FindByRootID(std::string id);
int SendEvent(const IEventInfo& info, std::shared_ptr<item::AbstractItem> noti);
+ int SendEvent(const IEventInfo& info, std::list<std::shared_ptr<item::AbstractItem>> notiList);
void OnEvent(const IEventInfo& info,
std::list<tizen_base::Bundle> serialized) override;
std::list<tizen_base::Bundle> OnRequest(const IEventInfo& info) override;
protected:
virtual void OnAdd(const IEventInfo& info, std::list<std::shared_ptr<item::AbstractItem>> addedItem);
- virtual void OnUpdate(const IEventInfo& info, std::shared_ptr<item::AbstractItem> updatedItem);
- virtual void OnDelete(const IEventInfo& info, std::shared_ptr<item::AbstractItem> deletedItem);
+ virtual void OnUpdate(const IEventInfo& info, std::list<std::shared_ptr<item::AbstractItem>> updatedItem);
+ virtual void OnDelete(const IEventInfo& info, std::list<std::shared_ptr<item::AbstractItem>> deletedItem);
virtual void OnError(NotificationError error, int requestId);
virtual std::list<std::shared_ptr<item::AbstractItem>> OnRequestEvent(
const IEventInfo& info);
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;
+ SharedFile::CopyPrivateFile(noti);
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;
+ SharedFile::CopyPrivateFile(i);
}
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;
+ SharedFile::CopyPrivateFile(noti);
return impl_->SendNotify(noti, EventInfo::Update);
}
+int Reporter::Update(std::list<std::shared_ptr<AbstractItem>> notiList) {
+ EventInfo info(EventInfo::Update, util::GetAppId(), "");
+ list<Bundle> serialized_list;
+ for (auto& i : notiList) {
+ static_pointer_cast<IItemInfoInternal>(i->GetInfo())->SetTime(time(NULL));
+ Bundle b = i->Serialize();
+ serialized_list.push_back(b);
+ SharedFile::CopyPrivateFile(i);
+ }
+ impl_->sender_->Notify(info, serialized_list);
+ return info.GetRequestId();
+}
+
int Reporter::Delete(std::shared_ptr<AbstractItem> noti) {
return impl_->SendNotify(noti, EventInfo::Delete);
}
+int Reporter::Delete(std::list<std::shared_ptr<AbstractItem>> notiList) {
+ EventInfo info(EventInfo::Delete, util::GetAppId(), "");
+ list<Bundle> serialized_list;
+ for (auto& i : notiList) {
+ static_pointer_cast<IItemInfoInternal>(i->GetInfo())->SetTime(time(NULL));
+ Bundle b = i->Serialize();
+ serialized_list.push_back(b);
+ SharedFile::CopyPrivateFile(i);
+ }
+ impl_->sender_->Notify(info, serialized_list);
+ return info.GetRequestId();
+}
+
int Reporter::DeleteAll() {
Bundle serialized;
EventInfo info(EventInfo::DeleteAll, util::GetAppId(), "");
}
int Reporter::SendEvent(const IEventInfo& info,
- shared_ptr<item::AbstractItem> noti) {
- Bundle serialized = noti->Serialize();
- list<Bundle> serialized_list {serialized};
- impl_->sender_->Notify(info, serialized_list);
- return info.GetRequestId();
-}
-
-int Reporter::SendEvent(const IEventInfo& info,
std::list<std::shared_ptr<item::AbstractItem>> notiList) {
list<Bundle> serialized_list;
for (auto& i : notiList) {
std::unique_ptr<IEventListener> listener);
virtual ~Reporter();
- int SendEvent(const IEventInfo& info, std::shared_ptr<item::AbstractItem> noti);
int SendEvent(const IEventInfo& info,
std::list<std::shared_ptr<item::AbstractItem>> notiList);
void SendError(const IEventInfo& info, NotificationError error);
int Post(std::shared_ptr<item::AbstractItem> noti);
int Post(std::list<std::shared_ptr<item::AbstractItem>> notiList);
int Update(std::shared_ptr<item::AbstractItem> noti);
+ int Update(std::list<std::shared_ptr<item::AbstractItem>> notiList);
int Delete(std::shared_ptr<item::AbstractItem> noti);
+ int Delete(std::list<std::shared_ptr<item::AbstractItem>> notiList);
int DeleteAll();
int DeleteByChannel(std::string channel);
std::unique_ptr<item::AbstractItem> FindByRootID(std::string id);
SharedFile::SharingTarget::SharingTarget() = default;
SharedFile::SharingTarget::~SharingTarget() = default;
-const char* SharedFile::GetLastIndex(const char* path, const char* search) const {
+const char* SharedFile::GetLastIndex(const char* path, const char* search) {
int i;
int search_len;
const char* index;
return {};
}
-int SharedFile::SetPrivateSharing(list<shared_ptr<AbstractItem>> item,
+int SharedFile::SetPrivateSharing(list<shared_ptr<AbstractItem>> notiList,
multimap<string, string> receiver_group_map) {
- int ret;
-
- if (item.empty() || receiver_group_map.empty()) {
+ if (notiList.empty() || receiver_group_map.empty()) {
LOGE("Invalid parameter");
return ERROR_INVALID_PARAMETER;
}
- for (auto& i : item) {
+ for (auto& i : notiList) {
SharingData sharing_data;
list<string> new_shared_file_list;
list<string> new_receiver_group_list;
new_receiver_group_list = i->GetReceiverList();
}
- ret = SetSharingData(sharing_data, new_shared_file_list,
- new_receiver_group_list, receiver_group_map);
- if (ret == ERROR_NONE)
+ if (SetSharingData(sharing_data, new_shared_file_list,
+ new_receiver_group_list, receiver_group_map) == ERROR_NONE)
i->SetSharedPath();
}
return ERROR_NONE;
}
-int SharedFile::UpdatePrivateSharing(shared_ptr<AbstractItem> item,
+int SharedFile::UpdatePrivateSharing(list<shared_ptr<AbstractItem>> notiList,
multimap<string, string> receiver_group_map) {
- list<string> new_shared_file_list;
- list<string> new_receiver_group_list;
- int ret;
-
- if (item == nullptr || receiver_group_map.empty()) {
+ if (notiList.empty() || receiver_group_map.empty()) {
LOGE("Invalid parameter");
return ERROR_INVALID_PARAMETER;
}
- list<string> shared_path_list = item->GetSharedPath();
- if (shared_path_list.empty())
- return ERROR_NONE;
+ for (auto& i : notiList) {
+ list<string> new_shared_file_list;
+ list<string> new_receiver_group_list;
+ list<string> shared_path_list = i->GetSharedPath();
+ if (shared_path_list.empty())
+ continue;
- string appid = item->GetSenderAppId();
- SharingData sharing_data = FindSharingData(appid);
- if (appid.empty() || sharing_data.app_id.empty())
- return ERROR_IO_ERROR;
+ string appid = i->GetSenderAppId();
+ SharingData sharing_data = FindSharingData(appid);
+ if (appid.empty() || sharing_data.app_id.empty())
+ continue;
- for (auto& shared_path : shared_path_list) {
- std::list<std::string>::iterator it;
- it = std::find_if(sharing_data.shared_file_list.begin(),
+ for (auto& shared_path : shared_path_list) {
+ std::list<std::string>::iterator it;
+ it = std::find_if(sharing_data.shared_file_list.begin(),
sharing_data.shared_file_list.end(),
[&shared_path](std::string shared_file){
return shared_file.compare(shared_path) == 0;
});
- if (it == sharing_data.shared_file_list.end()) {
- sharing_data.shared_file_list.push_back(shared_path);
- new_shared_file_list.push_back(shared_path);
+ if (it == sharing_data.shared_file_list.end()) {
+ sharing_data.shared_file_list.push_back(shared_path);
+ new_shared_file_list.push_back(shared_path);
+ }
}
- }
- new_receiver_group_list = item->GetReceiverList();
- ret = SetSharingData(sharing_data, new_shared_file_list,
- new_receiver_group_list, receiver_group_map);
- if (ret == ERROR_NONE)
- item->SetSharedPath();
+ new_receiver_group_list = i->GetReceiverList();
+ if (SetSharingData(sharing_data, new_shared_file_list,
+ new_receiver_group_list, receiver_group_map) == ERROR_NONE)
+ i->SetSharedPath();
+ }
LOGD("UpdatePrivateSharing");
return ERROR_NONE;
}
-int SharedFile::RemovePrivateSharing(shared_ptr<AbstractItem> item,
+int SharedFile::RemovePrivateSharing(list<shared_ptr<AbstractItem>> notiList,
multimap<string, string> receiver_group_map) {
- if (item == nullptr || receiver_group_map.empty()) {
+ if (notiList.empty() || receiver_group_map.empty()) {
LOGE("Invalid parameter");
return ERROR_INVALID_PARAMETER;
}
- string appid = item->GetSenderAppId();
- if (appid.empty())
- return ERROR_IO_ERROR;
+ for (auto& i : notiList) {
+ string appid = i->GetSenderAppId();
+ if (appid.empty())
+ continue;
- SharingData sharing_data = FindSharingData(appid);
- if (sharing_data.app_id.empty())
- return ERROR_NONE;
+ SharingData sharing_data = FindSharingData(appid);
+ if (sharing_data.app_id.empty())
+ continue;
- sharing_data.noti_id_list.remove(item->GetId());
- if (sharing_data.noti_id_list.size() == 0) {
- UnsetSharingData(sharing_data, receiver_group_map);
+ sharing_data.noti_id_list.remove(i->GetId());
+ if (sharing_data.noti_id_list.size() == 0) {
+ UnsetSharingData(sharing_data, receiver_group_map);
- vector<char*> path_array = ConvertListToArray(sharing_data.shared_file_list);
- if (!path_array.empty()) {
- for (int i = 0; i < static_cast<int>(path_array.size()); i++) {
- if (g_remove(path_array[i]) == -1)
+ vector<char*> path_array = ConvertListToArray(sharing_data.shared_file_list);
+ if (!path_array.empty()) {
+ for (int i = 0; i < static_cast<int>(path_array.size()); i++) {
+ if (g_remove(path_array[i]) == -1)
LOGE("Failed to remove shared_file(%s)", path_array[i]);
+ }
}
+ g_rmdir(sharing_data.dir.c_str());
}
- g_rmdir(sharing_data.dir.c_str());
}
LOGD("RemovePrivateSharing");
bool IsPrivatePath(std::string path) const;
std::string GetDataPath(std::string app_id, std::string path) const;
- int SetPrivateSharing(std::list<std::shared_ptr<AbstractItem>> item,
+ int SetPrivateSharing(std::list<std::shared_ptr<AbstractItem>> notiList,
std::multimap<std::string, std::string> receiver_group_map);
- int UpdatePrivateSharing(std::shared_ptr<AbstractItem>item,
+ int UpdatePrivateSharing(std::list<std::shared_ptr<AbstractItem>> notiList,
std::multimap<std::string, std::string> receiver_group_map);
- int RemovePrivateSharing(std::shared_ptr<AbstractItem>item,
+ int RemovePrivateSharing(std::list<std::shared_ptr<AbstractItem>> notiList,
std::multimap<std::string, std::string> receiver_group_map);
- int CopyPrivateFile(std::shared_ptr<item::AbstractItem>added_item);
+ static int CopyPrivateFile(std::shared_ptr<item::AbstractItem>added_item);
private:
class SharingData {
~SharingTarget();
std::string target_id;
};
- const char* GetLastIndex(const char* path, const char* search) const;
- bool MakeDir(const char* path);
- std::string GetDir(std::string path);
- int CopyFile(const char* source, const char* dest);
+ static const char* GetLastIndex(const char* path, const char* search);
+ static bool MakeDir(const char* path);
+ static std::string GetDir(std::string path);
+ static int CopyFile(const char* source, const char* dest);
std::vector<char*> ConvertListToArray(const std::list<std::string>& data);
SharingData FindSharingData(std::string appid);
int SetSharingData(SharingData sharing_data,
}
void InvokeUpdated(Manager* manager, const IEventInfo& info,
- shared_ptr<item::AbstractItem> updatedItem) {
+ list<shared_ptr<AbstractItem>> updatedItem) {
if (cb_.updated == nullptr)
return;
+
IEventInfo* c_info = const_cast<IEventInfo*>(&info);
- cb_.updated(static_cast<noti_ex_manager_h>(manager),
+ for (auto& i : updatedItem) {
+ cb_.updated(static_cast<noti_ex_manager_h>(manager),
static_cast<noti_ex_event_info_h>(c_info),
- static_cast<noti_ex_item_h>(new Handle(updatedItem)), user_data_);
+ static_cast<noti_ex_item_h>(new Handle(shared_ptr<AbstractItem>(i))),
+ user_data_);
+ }
}
void InvokeDeleted(Manager* manager, const IEventInfo& info,
- shared_ptr<item::AbstractItem> deletedItem) {
+ list<shared_ptr<AbstractItem>> deletedItem) {
if (cb_.deleted == nullptr)
return;
+
IEventInfo* c_info = const_cast<IEventInfo*>(&info);
- if (c_info->GetEventType() == static_cast<int>(IEventInfo::EventType::DeleteAll)) {
- cb_.deleted(static_cast<noti_ex_manager_h>(manager),
- static_cast<noti_ex_event_info_h>(c_info),
- nullptr, user_data_);
- } else {
+ for (auto& i : deletedItem) {
cb_.deleted(static_cast<noti_ex_manager_h>(manager),
static_cast<noti_ex_event_info_h>(c_info),
- static_cast<noti_ex_item_h>(
- new Handle(deletedItem)), user_data_);
+ static_cast<noti_ex_item_h>(new Handle(shared_ptr<AbstractItem>(i))),
+ user_data_);
}
}
}
void OnUpdate(const IEventInfo& info,
- std::shared_ptr<item::AbstractItem> updatedItem) override {
+ list<shared_ptr<AbstractItem>> updatedItem) override {
cb_->InvokeUpdated(this, info, updatedItem);
}
void OnDelete(const IEventInfo& info,
- shared_ptr<item::AbstractItem> deletedItem) override {
+ list<shared_ptr<AbstractItem>> deletedItem) override {
cb_->InvokeDeleted(this, info, deletedItem);
}
return NOTI_EX_ERROR_NONE;
}
+extern "C" EXPORT_API int noti_ex_reporter_update_list(
+ noti_ex_reporter_h handle, noti_ex_item_h *noti_list, int count,
+ int *request_id) {
+ if (handle == nullptr || noti_list == nullptr || request_id == nullptr) {
+ LOGE("Invalid parameter");
+ return NOTI_EX_ERROR_INVALID_PARAMETER;
+ }
+ try {
+ ReporterStub* stub = static_cast<ReporterStub*>(handle);
+ list<shared_ptr<item::AbstractItem>> notiList;
+ for (int i = 0; i < count; i++) {
+ Handle* item = static_cast<Handle*>(noti_list[i]);
+ notiList.push_back(item->GetPtr());
+ }
+ *request_id = stub->Update(notiList);
+ } catch (Exception &ex) {
+ LOGE("%s %d", ex.what(), ex.GetErrorCode());
+ return NOTI_EX_ERROR_IO_ERROR;
+ }
+ return NOTI_EX_ERROR_NONE;
+}
+
extern "C" EXPORT_API int noti_ex_reporter_delete(noti_ex_reporter_h handle,
noti_ex_item_h noti, int *request_id) {
if (handle == nullptr || noti == nullptr || request_id == nullptr) {
return NOTI_EX_ERROR_NONE;
}
+extern "C" EXPORT_API int noti_ex_reporter_delete_list(
+ noti_ex_reporter_h handle, noti_ex_item_h *noti_list, int count,
+ int *request_id) {
+ if (handle == nullptr || noti_list == nullptr || request_id == nullptr) {
+ LOGE("Invalid parameter");
+ return NOTI_EX_ERROR_INVALID_PARAMETER;
+ }
+ try {
+ ReporterStub* stub = static_cast<ReporterStub*>(handle);
+ list<shared_ptr<item::AbstractItem>> notiList;
+ for (int i = 0; i < count; i++) {
+ Handle* item = static_cast<Handle*>(noti_list[i]);
+ notiList.push_back(item->GetPtr());
+ }
+ *request_id = stub->Delete(notiList);
+ } catch (Exception &ex) {
+ LOGE("%s %d", ex.what(), ex.GetErrorCode());
+ return NOTI_EX_ERROR_IO_ERROR;
+ }
+ return NOTI_EX_ERROR_NONE;
+}
+
extern "C" EXPORT_API int noti_ex_reporter_delete_all(
noti_ex_reporter_h handle, int *request_id) {
if (handle == nullptr || request_id == nullptr) {
}
TEST_F(SharedFileTest, RemovePrivateSharing) {
+ list<shared_ptr<item::AbstractItem>> notiList;
+ notiList.push_back(SharedFileTest::item);
+
std::multimap<std::string, std::string> map_;
map_.insert(make_pair("tizen.org/receiver/popup", "test_appid"));
- ASSERT_EQ(shared_file->RemovePrivateSharing(SharedFileTest::item, map_), ERROR_NONE);
+ ASSERT_EQ(shared_file->RemovePrivateSharing(notiList, map_), ERROR_NONE);
}
} // namespace