From: mk5004.lee Date: Tue, 25 Feb 2020 04:33:28 +0000 (+0900) Subject: Merge branch 'tizen' into tizen_5.5 X-Git-Tag: accepted/tizen/5.5/unified/20200225.140247^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c07b039709c10eadc9c0f19be0d9694f0a4830c8;hp=a2af114210209310573919de5b185b447d412b65;p=platform%2Fcore%2Fapi%2Fnotification.git Merge branch 'tizen' into tizen_5.5 --- diff --git a/notification-ex/api/notification_ex_internal.h b/notification-ex/api/notification_ex_internal.h index 4725a3d..2a48647 100644 --- a/notification-ex/api/notification_ex_internal.h +++ b/notification-ex/api/notification_ex_internal.h @@ -21,6 +21,8 @@ extern "C" { #endif +#define NOTI_EX_INPUT_SELECTOR_REPLY "__NOTI_EX_INPUT_SELECTOR_REPLY__" + int noti_ex_item_free_string_list(char** list, int count); int noti_ex_item_group_remove_children(noti_ex_item_h handle); int noti_ex_item_time_set_time(noti_ex_item_h handle, time_t time); @@ -34,6 +36,18 @@ int noti_ex_style_set_padding(noti_ex_style_h handle, int noti_ex_led_info_set_color(noti_ex_led_info_h handle, noti_ex_color_h color); +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_get_image(noti_ex_item_h handle, char **path); + +int noti_ex_reporter_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, char *channel, + int *request_id); + #ifdef __cplusplus } #endif diff --git a/notification-ex/button_item.cc b/notification-ex/button_item.cc index 54c4a77..9e7cd4c 100644 --- a/notification-ex/button_item.cc +++ b/notification-ex/button_item.cc @@ -28,6 +28,7 @@ #define LOG_TAG "NOTIFICATION_EX" #define BUTTON_TITLE_KEY "__BUTTON_TITLE_KEY__" +#define BUTTON_IMAGE_KEY "__BUTTON_IMAGE_KEY__" using namespace std; using namespace tizen_base; @@ -60,12 +61,15 @@ Bundle ButtonItem::Serialize() const { Bundle b; b = AbstractItem::Serialize(); b.Add(BUTTON_TITLE_KEY, impl_->title_); + if (!impl_->img_path_.empty()) + b.Add(BUTTON_IMAGE_KEY, impl_->img_path_); return b; } void ButtonItem::Deserialize(Bundle b) { AbstractItem::Deserialize(b); impl_->title_ = b.GetString(BUTTON_TITLE_KEY); + impl_->img_path_ = b.GetString(BUTTON_IMAGE_KEY); } bool ButtonItem::IsItemTypeExist(int type) { @@ -78,5 +82,13 @@ std::string ButtonItem::GetTitle() const { return impl_->title_; } +void ButtonItem::SetImgPath(string path) { + impl_->img_path_ = path; +} + +std::string ButtonItem::GetImgPath() const { + return impl_->img_path_; +} + } // namespace item } // namespace notification diff --git a/notification-ex/button_item.h b/notification-ex/button_item.h index 6ab1831..620122f 100644 --- a/notification-ex/button_item.h +++ b/notification-ex/button_item.h @@ -96,6 +96,20 @@ class EXPORT_API ButtonItem : public AbstractItem { */ std::string GetTitle() const; + /** + * @brief Gets the image path of ButtonItem. + * @since_tizen 5.5 + * @return The path of image + */ + std::string GetImgPath() const; + + /** + * @brief Sets the image path of ButtonItem. + * @since_tizen 5.5 + * @param[in] path Image path + */ + void SetImgPath(std::string path); + private: class Impl; std::unique_ptr impl_; diff --git a/notification-ex/button_item_implementation.h b/notification-ex/button_item_implementation.h index bab5b46..701bd58 100644 --- a/notification-ex/button_item_implementation.h +++ b/notification-ex/button_item_implementation.h @@ -37,6 +37,7 @@ class ButtonItem::Impl { friend class ButtonItem; std::string title_; + std::string img_path_; ButtonItem* parent_; }; diff --git a/notification-ex/db_manager.cc b/notification-ex/db_manager.cc index 2ef7a1b..25a1996 100644 --- a/notification-ex/db_manager.cc +++ b/notification-ex/db_manager.cc @@ -715,13 +715,19 @@ list> DBManager::ExecuteGetList(char* query) { } list> DBManager::GetNotificationList( - string app_id, uid_t uid) { + string app_id, uid_t uid, string channel) { char* query; list> item_list; - query = sqlite3_mprintf("SELECT data FROM noti_ex_list" - " WHERE uid = %d AND app_id = %Q ORDER BY insert_time DESC", - uid, app_id.c_str()); + if (!channel.empty()) { + query = sqlite3_mprintf("SELECT data FROM noti_ex_list WHERE uid = %d " + "AND app_id = %Q AND channel = %Q ORDER BY insert_time DESC", uid, + app_id.c_str(), channel.c_str()); + } else { + query = sqlite3_mprintf("SELECT data FROM noti_ex_list WHERE uid = %d " + "AND app_id = %Q ORDER BY insert_time DESC", uid, app_id.c_str()); + } + if (!query) { LOGE("OOM - sql query"); return item_list; diff --git a/notification-ex/db_manager.h b/notification-ex/db_manager.h index 74f8480..5cf549f 100644 --- a/notification-ex/db_manager.h +++ b/notification-ex/db_manager.h @@ -44,7 +44,7 @@ class EXPORT_API DBManager { static int GetCount(const std::string& app_id, uid_t uid, int* count); static int DeleteNotification(std::shared_ptr deletedItem); static std::list> GetNotificationList(uid_t uid, std::string channel = ""); - static std::list> GetNotificationList(std::string app_id, uid_t uid); + static std::list> GetNotificationList(std::string app_id, uid_t uid, std::string channel = ""); static std::list> GetNotificationList(std::string app_id, std::string root_id, uid_t uid); static std::list> GetNotificationList(std::string app_id, int64_t private_id, uid_t uid); diff --git a/notification-ex/manager.cc b/notification-ex/manager.cc index 79df325..29ea066 100644 --- a/notification-ex/manager.cc +++ b/notification-ex/manager.cc @@ -106,6 +106,14 @@ int Manager::DeleteAll() { return info.GetRequestId(); } +int Manager::DeleteByChannel(string channel) { + Bundle serialized; + EventInfo info(EventInfo::DeleteAll, util::GetAppId(), channel); + 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 55148b3..a663308 100644 --- a/notification-ex/manager.h +++ b/notification-ex/manager.h @@ -43,6 +43,7 @@ class EXPORT_API Manager : public IEventObserver { int Update(std::shared_ptr noti); int Delete(std::shared_ptr noti); int DeleteAll(); + int DeleteByChannel(std::string channel); 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/reporter.cc b/notification-ex/reporter.cc index c8ce91a..11c0074 100644 --- a/notification-ex/reporter.cc +++ b/notification-ex/reporter.cc @@ -122,6 +122,14 @@ int Reporter::DeleteAll() { return info.GetRequestId(); } +int Reporter::DeleteByChannel(string channel) { + Bundle serialized; + EventInfo info(EventInfo::DeleteAll, util::GetAppId(), channel); + list serialized_list {serialized}; + impl_->sender_->Notify(info, serialized_list, util::GetAppId()); + return info.GetRequestId(); +} + std::unique_ptr Reporter::FindByRootID(std::string id) { Bundle serialized; EventInfo info(EventInfo::Get, util::GetAppId(), "", id); diff --git a/notification-ex/reporter.h b/notification-ex/reporter.h index e3dd3c1..d76292d 100644 --- a/notification-ex/reporter.h +++ b/notification-ex/reporter.h @@ -49,6 +49,7 @@ class EXPORT_API Reporter : public IEventObserver { int Update(std::shared_ptr noti); int Delete(std::shared_ptr noti); int DeleteAll(); + int DeleteByChannel(std::string channel); std::unique_ptr FindByRootID(std::string id); virtual void OnEvent(const IEventInfo& info, std::list> notiList); diff --git a/notification-ex/stub.cc b/notification-ex/stub.cc index 35da063..3a9b575 100644 --- a/notification-ex/stub.cc +++ b/notification-ex/stub.cc @@ -42,6 +42,7 @@ #include "notification-ex/dbus_event_listener.h" #include "notification-ex/exception.h" #include "notification-ex/iitem_info_internal.h" +#include "notification-ex/icon_item.h" #ifdef LOG_TAG #undef LOG_TAG @@ -431,6 +432,47 @@ extern "C" EXPORT_API int noti_ex_item_button_set_multi_language_title( return NOTI_EX_ERROR_NONE; } +extern "C" EXPORT_API int noti_ex_item_button_set_image( + noti_ex_item_h handle, char *path) { + if (handle == nullptr || path == nullptr) { + LOGE("Invalid parameter"); + return NOTI_EX_ERROR_INVALID_PARAMETER; + } + + Handle* h = static_cast(handle); + if (!h->IsValidType(AbstractItem::Button)) { + LOGE("Invalid handle type"); + return NOTI_EX_ERROR_INVALID_PARAMETER; + } + + ButtonItem* p = static_cast(h->Get()); + p->SetImgPath(path); + + return NOTI_EX_ERROR_NONE; +} + +extern "C" EXPORT_API int noti_ex_item_button_get_image( + noti_ex_item_h handle, char **path) { + if (handle == nullptr || path == nullptr) { + LOGE("Invalid parameter"); + return NOTI_EX_ERROR_INVALID_PARAMETER; + } + + Handle* h = static_cast(handle); + if (!h->IsValidType(AbstractItem::Button)) { + LOGE("Invalid handle type"); + return NOTI_EX_ERROR_INVALID_PARAMETER; + } + + ButtonItem* p = static_cast(h->Get()); + if (!p->GetImgPath().empty()) + *path = strdup(p->GetImgPath().c_str()); + else + *path = nullptr; + + return NOTI_EX_ERROR_NONE; +} + extern "C" EXPORT_API int noti_ex_item_chat_message_create( noti_ex_item_h *handle, const char *id, noti_ex_item_h name, noti_ex_item_h text, noti_ex_item_h image, noti_ex_item_h time, @@ -2681,6 +2723,24 @@ extern "C" EXPORT_API int noti_ex_manager_delete_all(noti_ex_manager_h handle, return NOTI_EX_ERROR_NONE; } +extern "C" EXPORT_API int noti_ex_manager_delete_by_channel( + noti_ex_manager_h handle, char* channel, int* request_id) { + if (handle == nullptr || channel == nullptr || request_id == nullptr) { + LOGE("Invalid parameter"); + return NOTI_EX_ERROR_INVALID_PARAMETER; + } + + try { + ManagerStub* stub = static_cast(handle); + *request_id = stub->DeleteByChannel(channel); + } 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) { @@ -3046,6 +3106,24 @@ extern "C" EXPORT_API int noti_ex_reporter_delete_all( return NOTI_EX_ERROR_NONE; } +extern "C" EXPORT_API int noti_ex_reporter_delete_by_channel( + noti_ex_reporter_h handle, char* channel, int* request_id) { + if (handle == nullptr || channel == nullptr || request_id == nullptr) { + LOGE("Invalid parameter"); + return NOTI_EX_ERROR_INVALID_PARAMETER; + } + + try { + ReporterStub* stub = static_cast(handle); + *request_id = stub->DeleteByChannel(channel); + } 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_find_by_root_id( noti_ex_reporter_h handle, const char *root_id, noti_ex_item_h *item) { if (handle == nullptr || root_id == nullptr || item == nullptr) { @@ -3413,3 +3491,52 @@ extern "C" EXPORT_API int noti_ex_item_group_remove_children(noti_ex_item_h hand return NOTI_EX_ERROR_NONE; } + +extern "C" EXPORT_API int noti_ex_item_icon_create(noti_ex_item_h *handle, + const char *id, const char *icon_path) { + if (handle == nullptr || icon_path == nullptr) { + LOGE("Invalid parameter"); + return NOTI_EX_ERROR_INVALID_PARAMETER; + } + + IconItem* p; + if (id) + p = new (std::nothrow) IconItem(id, icon_path); + else + p = new (std::nothrow) IconItem(icon_path); + + if (p == nullptr) { + LOGE("Out-of-memory"); + return NOTI_EX_ERROR_OUT_OF_MEMORY; + } + + *handle = new Handle(shared_ptr(p)); + + return NOTI_EX_ERROR_NONE; +} + +int noti_ex_item_icon_get_icon_path(noti_ex_item_h handle, char **icon_path) { + if (handle == nullptr || icon_path == nullptr) { + LOGE("Invalid parameter"); + return NOTI_EX_ERROR_INVALID_PARAMETER; + } + + Handle* h = static_cast(handle); + if (!h->IsValidType(AbstractItem::Icon)) { + LOGE("Invalid handle type"); + return NOTI_EX_ERROR_INVALID_PARAMETER; + } + + IconItem* p = static_cast(h->Get()); + if (!p->GetImagePath().empty()) { + *icon_path = strdup(p->GetImagePath().c_str()); + if (*icon_path == nullptr) { + LOGE("Out-of-memory"); + return NOTI_EX_ERROR_OUT_OF_MEMORY; + } + } else { + *icon_path = nullptr; + } + + return NOTI_EX_ERROR_NONE; +} diff --git a/packaging/notification.spec b/packaging/notification.spec index 74c4f6a..e707790 100644 --- a/packaging/notification.spec +++ b/packaging/notification.spec @@ -1,7 +1,7 @@ %bcond_with wayland Name: notification Summary: Notification library -Version: 0.5.51 +Version: 0.5.52 Release: 1 Group: Applications/Core Applications License: Apache-2.0