From 0faf3bd8cdc2e6e3c7018a90a6e6ab00ccf65611 Mon Sep 17 00:00:00 2001 From: Yong Song Date: Thu, 25 Jul 2013 10:31:12 +0900 Subject: [PATCH] applying new badge API Change-Id: Iaf81ef582dda0b1f3ee57ae60d94ba75c94fb8f4 Signed-off-by: Yong Song --- packaging/osp-appfw.spec | 1 + src/CMakeLists.txt | 1 + src/app/FApp_NotificationManagerImpl.cpp | 46 ++++++++++++++++++++++++++------ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/packaging/osp-appfw.spec b/packaging/osp-appfw.spec index 237b684..2a843d7 100755 --- a/packaging/osp-appfw.spec +++ b/packaging/osp-appfw.spec @@ -72,6 +72,7 @@ BuildRequires: capi-security-privilege-manager-devel BuildRequires: boost-devel BuildRequires: gettext-tools BuildRequires: pkgconfig(security-server) +BuildRequires: badge # runtime requires Requires: capi-appfw-application diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df31c8d..17baaec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,6 +15,7 @@ pkg_check_modules(pkgs REQUIRED glib-2.0 haptic heynoti + badge icu-i18n libpcre libsoup-2.4 diff --git a/src/app/FApp_NotificationManagerImpl.cpp b/src/app/FApp_NotificationManagerImpl.cpp index 8ea0ca1..c88337a 100644 --- a/src/app/FApp_NotificationManagerImpl.cpp +++ b/src/app/FApp_NotificationManagerImpl.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -135,8 +136,23 @@ _NotificationManagerImpl::GetInstance(NotificationManager& notiMgr) int _NotificationManagerImpl::GetBadgeNumber(void) const { - int count = -1; - notification_get_badge(NULL, NOTIFICATION_GROUP_ID_NONE, &count); + unsigned int count = 0; + + const AppId appId = _AppInfo::GetApplicationId(); + + std::unique_ptr pAppId(_StringConverter::CopyToCharArrayN(appId)); + + badge_error_e badgeError = badge_get_count(pAppId.get(), &count); + + if (badgeError == BADGE_ERROR_NONE) + { + SysLog(NID_APP, "badge_get_count(%d)", count); + } + else + { + SysLog(NID_APP, "badge_get_count failed(%d).", badgeError); + return -1; + } return count; } @@ -217,8 +233,10 @@ _NotificationManagerImpl::NotifyImpl(const String& messageText, int badgeNumber, if (badgeNumber >= 0) { - notification_set_badge(NULL, NOTIFICATION_GROUP_ID_NONE, badgeNumber); - SysLog(NID_APP, "Badge number is set to %d.", badgeNumber); + const AppId appId = _AppInfo::GetApplicationId(); + std::unique_ptr pAppId(_StringConverter::CopyToCharArrayN(appId)); + badge_error_e badgeError = badge_set_count(pAppId.get(), badgeNumber); + SysTryLog(NID_APP, badgeError == BADGE_ERROR_NONE, "badge_set_count failed(%d).", badgeError); } CATCH: @@ -326,8 +344,8 @@ _NotificationManagerImpl::NotifyImpl(const AppId& appId, const String& messageTe if (badgeNumber >= 0) { - notification_set_badge(buffer, NOTIFICATION_GROUP_ID_NONE, badgeNumber); - SysLog(NID_APP, "Badge number is set to %d.", badgeNumber); + badge_error_e badgeError = badge_set_count(buffer, badgeNumber); + SysTryLog(NID_APP, badgeError == BADGE_ERROR_NONE, "badge_set_count failed(%d).", badgeError); } CATCH: @@ -454,13 +472,25 @@ _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const appId.GetPointer()); char buffer[256]; - int count = -1; + unsigned int count = 0; memset(buffer, 0, 256); snprintf(buffer, 256, "%ls", appId.GetPointer()); - notification_get_badge(buffer, NOTIFICATION_GROUP_ID_NONE, &count); + std::unique_ptr pAppId(_StringConverter::CopyToCharArrayN(appId)); + + badge_error_e badgeError = badge_get_count(pAppId.get(), &count); + + if (badgeError == BADGE_ERROR_NONE) + { + SysLog(NID_APP, "badge_get_count(%d)", count); + } + else + { + SysLog(NID_APP, "badge_get_count failed(%d).", badgeError); + return -1; + } return count; } -- 2.7.4