diff options
author | mk5004.lee <mk5004.lee@samsung.com> | 2020-02-24 18:08:16 +0900 |
---|---|---|
committer | mk5004.lee <mk5004.lee@samsung.com> | 2020-02-25 11:26:41 +0900 |
commit | 31d55962dfd285c6b3a713680813fe0e542a0b7a (patch) | |
tree | 5ac2834351eff2a6cf356a0def304966ab40fd32 | |
parent | c047f271af4ee56ca3e8a02a6db4cd2b327e32b0 (diff) | |
download | notification-31d55962dfd285c6b3a713680813fe0e542a0b7a.tar.gz notification-31d55962dfd285c6b3a713680813fe0e542a0b7a.tar.bz2 notification-31d55962dfd285c6b3a713680813fe0e542a0b7a.zip |
Add icon item
- Add icon item
Set/get image path for button item
Add input selector reply key
Add delete by channel func
Change-Id: I111fe20f1b72051559577502ccaf3da97ec57e5a
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
-rw-r--r-- | notification-ex/api/notification_ex_internal.h | 14 | ||||
-rw-r--r-- | notification-ex/button_item.cc | 12 | ||||
-rw-r--r-- | notification-ex/button_item.h | 14 | ||||
-rw-r--r-- | notification-ex/button_item_implementation.h | 1 | ||||
-rw-r--r-- | notification-ex/db_manager.cc | 14 | ||||
-rw-r--r-- | notification-ex/db_manager.h | 2 | ||||
-rw-r--r-- | notification-ex/manager.cc | 8 | ||||
-rw-r--r-- | notification-ex/manager.h | 1 | ||||
-rw-r--r-- | notification-ex/reporter.cc | 8 | ||||
-rw-r--r-- | notification-ex/reporter.h | 1 | ||||
-rw-r--r-- | notification-ex/stub.cc | 127 |
11 files changed, 197 insertions, 5 deletions
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> 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<shared_ptr<item::AbstractItem>> DBManager::ExecuteGetList(char* query) { } list<shared_ptr<item::AbstractItem>> DBManager::GetNotificationList( - string app_id, uid_t uid) { + string app_id, uid_t uid, string channel) { char* query; list<shared_ptr<item::AbstractItem>> 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<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); + 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); static std::list<std::shared_ptr<item::AbstractItem>> 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<Bundle> 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<item::AbstractItem> noti); int Delete(std::shared_ptr<item::AbstractItem> noti); int DeleteAll(); + int DeleteByChannel(std::string channel); 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); 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<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); 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<item::AbstractItem> noti); int Delete(std::shared_ptr<item::AbstractItem> noti); int DeleteAll(); + int DeleteByChannel(std::string channel); std::unique_ptr<item::AbstractItem> FindByRootID(std::string id); virtual void OnEvent(const IEventInfo& info, std::list<std::shared_ptr<item::AbstractItem>> 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*>(handle); + if (!h->IsValidType(AbstractItem::Button)) { + LOGE("Invalid handle type"); + return NOTI_EX_ERROR_INVALID_PARAMETER; + } + + ButtonItem* p = static_cast<ButtonItem*>(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*>(handle); + if (!h->IsValidType(AbstractItem::Button)) { + LOGE("Invalid handle type"); + return NOTI_EX_ERROR_INVALID_PARAMETER; + } + + ButtonItem* p = static_cast<ButtonItem*>(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<ManagerStub*>(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<ReporterStub*>(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<AbstractItem>(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*>(handle); + if (!h->IsValidType(AbstractItem::Icon)) { + LOGE("Invalid handle type"); + return NOTI_EX_ERROR_INVALID_PARAMETER; + } + + IconItem* p = static_cast<IconItem*>(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; +} |