From f615dd925e7c457337e9e3fed94d63c1820b5f50 Mon Sep 17 00:00:00 2001 From: "mk5004.lee" Date: Fri, 13 Mar 2020 17:59:32 +0900 Subject: [PATCH] Add noti_ex_manager_delete_by_appid Change-Id: Ia2350fe58a808605c7bca41ea1299ab8d7d6fd58 Signed-off-by: mk5004.lee --- notification-ex/api/notification_ex_internal.h | 12 +++++++----- notification-ex/manager.cc | 8 ++++++++ notification-ex/manager.h | 1 + notification-ex/stub.cc | 24 +++++++++++++++++++++--- 4 files changed, 37 insertions(+), 8 deletions(-) mode change 100644 => 100755 notification-ex/api/notification_ex_internal.h diff --git a/notification-ex/api/notification_ex_internal.h b/notification-ex/api/notification_ex_internal.h old mode 100644 new mode 100755 index 5d199e5..52ad052 --- a/notification-ex/api/notification_ex_internal.h +++ b/notification-ex/api/notification_ex_internal.h @@ -40,18 +40,20 @@ int noti_ex_item_icon_create(noti_ex_item_h *handle, const char *id, const char *icon_path); int noti_ex_item_icon_get_icon_path(noti_ex_item_h handle, char **icon_path); -int noti_ex_item_button_set_image(noti_ex_item_h handle, char *path); +int noti_ex_item_button_set_image(noti_ex_item_h handle, const char *path); int noti_ex_item_button_get_image(noti_ex_item_h handle, char **path); int noti_ex_reporter_find_by_channel(noti_ex_reporter_h handle, const char *channel, noti_ex_item_h **noti_list, int *count); 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, char *channel, - int *request_id); +int noti_ex_reporter_delete_by_channel(noti_ex_reporter_h handle, + const char *channel, int *request_id); -int noti_ex_manager_delete_by_channel(noti_ex_manager_h handle, char *channel, - int *request_id); +int noti_ex_manager_delete_by_channel(noti_ex_manager_h handle, + const char *channel, int *request_id); +int noti_ex_manager_delete_by_appid(noti_ex_manager_h handle, + const char *app_id, int *request_id); #ifdef __cplusplus } diff --git a/notification-ex/manager.cc b/notification-ex/manager.cc index 29ea066..36fd034 100644 --- a/notification-ex/manager.cc +++ b/notification-ex/manager.cc @@ -114,6 +114,14 @@ int Manager::DeleteByChannel(string channel) { return info.GetRequestId(); } +int Manager::DeleteByAppId(string appId) { + Bundle serialized; + EventInfo info(EventInfo::DeleteAll, util::GetAppId(), "", appId); + list serialized_list {serialized}; + impl_->sender_->Notify(info, serialized_list, util::GetAppId()); + return info.GetRequestId(); +} + int Manager::GetCount() const { EventInfo info(EventInfo::Count, util::GetAppId(), ""); int num = impl_->sender_->RequestNumber(info); diff --git a/notification-ex/manager.h b/notification-ex/manager.h index a663308..f4d3cdf 100644 --- a/notification-ex/manager.h +++ b/notification-ex/manager.h @@ -44,6 +44,7 @@ class EXPORT_API Manager : public IEventObserver { int Delete(std::shared_ptr noti); int DeleteAll(); int DeleteByChannel(std::string channel); + int DeleteByAppId(std::string appId); int Hide(std::shared_ptr noti); std::unique_ptr FindByRootID(std::string id); int SendEvent(const IEventInfo& info, std::shared_ptr noti); diff --git a/notification-ex/stub.cc b/notification-ex/stub.cc index 0478bc3..41269c3 100644 --- a/notification-ex/stub.cc +++ b/notification-ex/stub.cc @@ -433,7 +433,7 @@ extern "C" EXPORT_API int noti_ex_item_button_set_multi_language_title( } extern "C" EXPORT_API int noti_ex_item_button_set_image( - noti_ex_item_h handle, char *path) { + noti_ex_item_h handle, const char *path) { if (handle == nullptr || path == nullptr) { LOGE("Invalid parameter"); return NOTI_EX_ERROR_INVALID_PARAMETER; @@ -2724,7 +2724,7 @@ extern "C" EXPORT_API int noti_ex_manager_delete_all(noti_ex_manager_h handle, } extern "C" EXPORT_API int noti_ex_manager_delete_by_channel( - noti_ex_manager_h handle, char* channel, int* request_id) { + noti_ex_manager_h handle, const char* channel, int* request_id) { if (handle == nullptr || channel == nullptr || request_id == nullptr) { LOGE("Invalid parameter"); return NOTI_EX_ERROR_INVALID_PARAMETER; @@ -2741,6 +2741,24 @@ extern "C" EXPORT_API int noti_ex_manager_delete_by_channel( return NOTI_EX_ERROR_NONE; } +extern "C" EXPORT_API int noti_ex_manager_delete_by_appid( + noti_ex_manager_h handle, const char* app_id, int* request_id) { + if (handle == nullptr || app_id == nullptr || request_id == nullptr) { + LOGE("Invalid parameter"); + return NOTI_EX_ERROR_INVALID_PARAMETER; + } + + try { + ManagerStub* stub = static_cast(handle); + *request_id = stub->DeleteByAppId(app_id); + } 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_manager_hide(noti_ex_manager_h handle, noti_ex_item_h noti, int *request_id) { if (handle == nullptr || noti == nullptr || request_id == nullptr) { @@ -3107,7 +3125,7 @@ extern "C" EXPORT_API int noti_ex_reporter_delete_all( } extern "C" EXPORT_API int noti_ex_reporter_delete_by_channel( - noti_ex_reporter_h handle, char* channel, int* request_id) { + noti_ex_reporter_h handle, const char* channel, int* request_id) { if (handle == nullptr || channel == nullptr || request_id == nullptr) { LOGE("Invalid parameter"); return NOTI_EX_ERROR_INVALID_PARAMETER; -- 2.7.4