From: Youngsoo Choi Date: Thu, 26 Jan 2017 06:21:07 +0000 (+0900) Subject: Implement notification onclick event X-Git-Tag: submit/tizen_3.0/20170201.125229~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=28d7e3ffb4345e8e923c5e2e664db48c08baf30f;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Implement notification onclick event This CL enables notification onclick event. Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2866 Change-Id: Iecb07daaacea6d82abc2824cabcc9941c33f70d1 Signed-off-by: Youngsoo Choi --- diff --git a/runtime/browser/notification_manager.cc b/runtime/browser/notification_manager.cc index aebd6e4..cff02ad 100755 --- a/runtime/browser/notification_manager.cc +++ b/runtime/browser/notification_manager.cc @@ -22,6 +22,7 @@ #include #include "common/logger.h" +#include "EWebKit_internal.h" namespace runtime { @@ -33,6 +34,26 @@ NotificationManager* NotificationManager::GetInstance() { NotificationManager::NotificationManager() { } +static void notification_onclick_event_cb( + notification_h noti, int event_type, void* userdata) { + NotificationManager* thiz = + static_cast(userdata); + int notification_priv_id = NOTIFICATION_PRIV_ID_NONE; + int ret = notification_get_id(noti, nullptr, ¬ification_priv_id); + if (ret != NOTIFICATION_ERROR_NONE) + LOGGER(ERROR) << "Can't get notification ID" << ret; + ewk_notification_clicked(thiz->FindNotificationID(notification_priv_id)); +} + +uint64_t NotificationManager::FindNotificationID( + int notification_priv_id) { + for (auto it = keymapper_.begin(); it != keymapper_.end(); it++) + if (it->second == notification_priv_id) + return it->first; + LOGGER(ERROR) << "Can't find notification ID" << notification_priv_id; + return 0; +} + bool NotificationManager::Show(uint64_t tag, const std::string& title, const std::string& body, @@ -93,13 +114,21 @@ bool NotificationManager::Show(uint64_t tag, } // insert notification - int platform_key = NOTIFICATION_PRIV_ID_NONE; - ret = notification_insert(noti_h, &platform_key); + ret = notification_post_with_event_cb( + noti_h, notification_onclick_event_cb, this); + if (ret != NOTIFICATION_ERROR_NONE) { + LOGGER(ERROR) << "Can't insert notification " << ret; + return false; + } + + int notification_priv_id = NOTIFICATION_PRIV_ID_NONE; + + ret = notification_get_id(noti_h, nullptr, ¬ification_priv_id); if (ret != NOTIFICATION_ERROR_NONE) { - LOGGER(ERROR) << "Can't insert notification"; + LOGGER(ERROR) << "Can't get notification ID" << ret; return false; } - keymapper_[tag] = platform_key; + keymapper_[tag] = notification_priv_id; return true; } diff --git a/runtime/browser/notification_manager.h b/runtime/browser/notification_manager.h old mode 100644 new mode 100755 index da93524..da703bc --- a/runtime/browser/notification_manager.h +++ b/runtime/browser/notification_manager.h @@ -30,6 +30,7 @@ class NotificationManager { const std::string& body, const std::string& icon_path); bool Hide(uint64_t tag); + uint64_t FindNotificationID(int notification_priv_id); private: NotificationManager(); std::map keymapper_;