summaryrefslogtreecommitdiff
path: root/notification-ex
diff options
context:
space:
mode:
authormk5004.lee <mk5004.lee@samsung.com>2020-03-17 09:58:02 +0900
committermk5004.lee <mk5004.lee@samsung.com>2020-03-26 16:16:36 +0900
commite5fd3950a8665697a96fa3384f7078c9b42c6bbb (patch)
tree8d4f7117528336f28e26fe0758090afbfede7cb8 /notification-ex
parent65b8c04b96a0866c654e6fd0b09451b4ef93f71b (diff)
downloadnotification-e5fd3950a8665697a96fa3384f7078c9b42c6bbb.tar.gz
notification-e5fd3950a8665697a96fa3384f7078c9b42c6bbb.tar.bz2
notification-e5fd3950a8665697a96fa3384f7078c9b42c6bbb.zip
Add the list update and delete func for noti-ex
Change-Id: Ib11b110623004bc9bf25b19c7e4eecff7beb2bce Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
Diffstat (limited to 'notification-ex')
-rw-r--r--notification-ex/api/notification_ex_internal.h4
-rw-r--r--notification-ex/db_manager.cc140
-rw-r--r--notification-ex/db_manager.h4
-rw-r--r--notification-ex/manager.cc32
-rw-r--r--notification-ex/manager.h5
-rw-r--r--notification-ex/reporter.cc47
-rw-r--r--notification-ex/reporter.h3
-rw-r--r--notification-ex/shared_file.cc98
-rw-r--r--notification-ex/shared_file.h16
-rw-r--r--notification-ex/stub.cc71
10 files changed, 259 insertions, 161 deletions
diff --git a/notification-ex/api/notification_ex_internal.h b/notification-ex/api/notification_ex_internal.h
index c3e325a..7e4209e 100644
--- a/notification-ex/api/notification_ex_internal.h
+++ b/notification-ex/api/notification_ex_internal.h
@@ -51,6 +51,10 @@ int noti_ex_reporter_find_all(noti_ex_reporter_h handle,
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);
diff --git a/notification-ex/db_manager.cc b/notification-ex/db_manager.cc
index 32545e3..d0498c4 100644
--- a/notification-ex/db_manager.cc
+++ b/notification-ex/db_manager.cc
@@ -606,63 +606,56 @@ int DBManager::UpdateHideList(shared_ptr<item::AbstractItem> updatedItem,
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));
@@ -670,7 +663,7 @@ out:
}
} 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);
@@ -737,8 +730,8 @@ list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList(
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;
@@ -757,8 +750,8 @@ list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList
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;
@@ -778,7 +771,7 @@ list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList
}
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;
@@ -817,21 +810,46 @@ list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList(
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;
}
diff --git a/notification-ex/db_manager.h b/notification-ex/db_manager.h
index 5cf549f..1af21da 100644
--- a/notification-ex/db_manager.h
+++ b/notification-ex/db_manager.h
@@ -39,10 +39,10 @@ class EXPORT_API DBManager {
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);
diff --git a/notification-ex/manager.cc b/notification-ex/manager.cc
index 36fd034..112143c 100644
--- a/notification-ex/manager.cc
+++ b/notification-ex/manager.cc
@@ -165,6 +165,17 @@ int Manager::SendEvent(const IEventInfo& info,
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;
@@ -205,21 +216,27 @@ void Manager::OnEvent(const IEventInfo& info, list<Bundle> serialized) {
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:
@@ -228,9 +245,12 @@ void Manager::OnEvent(const IEventInfo& info, list<Bundle> serialized) {
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;
}
@@ -241,11 +261,11 @@ void Manager::OnAdd(const IEventInfo& info,
}
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) {
diff --git a/notification-ex/manager.h b/notification-ex/manager.h
index f4d3cdf..30318f6 100644
--- a/notification-ex/manager.h
+++ b/notification-ex/manager.h
@@ -48,6 +48,7 @@ class EXPORT_API Manager : public IEventObserver {
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;
@@ -58,8 +59,8 @@ class EXPORT_API Manager : public IEventObserver {
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);
diff --git a/notification-ex/reporter.cc b/notification-ex/reporter.cc
index d423682..17b5ae9 100644
--- a/notification-ex/reporter.cc
+++ b/notification-ex/reporter.cc
@@ -78,9 +78,7 @@ void Reporter::SendError(const IEventInfo& info, NotificationError error) {
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);
}
@@ -92,10 +90,7 @@ int Reporter::Post(std::list<std::shared_ptr<AbstractItem>> notiList) {
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();
@@ -103,17 +98,41 @@ int Reporter::Post(std::list<std::shared_ptr<AbstractItem>> notiList) {
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(), "");
@@ -176,14 +195,6 @@ list<unique_ptr<AbstractItem>> Reporter::FindAll() {
}
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) {
diff --git a/notification-ex/reporter.h b/notification-ex/reporter.h
index 91bde45..f80c20f 100644
--- a/notification-ex/reporter.h
+++ b/notification-ex/reporter.h
@@ -40,14 +40,15 @@ class EXPORT_API Reporter : public IEventObserver {
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);
diff --git a/notification-ex/shared_file.cc b/notification-ex/shared_file.cc
index 9ed7eff..d630a73 100644
--- a/notification-ex/shared_file.cc
+++ b/notification-ex/shared_file.cc
@@ -53,7 +53,7 @@ SharedFile::SharingData::~SharingData() = default;
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;
@@ -393,16 +393,14 @@ SharedFile::SharingData SharedFile::FindSharingData(string appid) {
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;
@@ -465,9 +463,8 @@ int SharedFile::SetPrivateSharing(list<shared_ptr<AbstractItem>> item,
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();
}
@@ -475,76 +472,77 @@ int SharedFile::SetPrivateSharing(list<shared_ptr<AbstractItem>> item,
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");
diff --git a/notification-ex/shared_file.h b/notification-ex/shared_file.h
index acf9fab..fdd6544 100644
--- a/notification-ex/shared_file.h
+++ b/notification-ex/shared_file.h
@@ -41,13 +41,13 @@ class EXPORT_API SharedFile {
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 {
@@ -66,10 +66,10 @@ class EXPORT_API SharedFile {
~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,
diff --git a/notification-ex/stub.cc b/notification-ex/stub.cc
index 34d9db2..cabc644 100644
--- a/notification-ex/stub.cc
+++ b/notification-ex/stub.cc
@@ -123,29 +123,30 @@ class ManagerCallbackInfo {
}
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_);
}
}
@@ -174,12 +175,12 @@ class ManagerStub : public Manager {
}
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);
}
@@ -3137,6 +3138,28 @@ extern "C" EXPORT_API int noti_ex_reporter_update(noti_ex_reporter_h handle,
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) {
@@ -3159,6 +3182,28 @@ extern "C" EXPORT_API int noti_ex_reporter_delete(noti_ex_reporter_h handle,
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) {