#include <appsvc/appsvc.h>
#include <bundle.h>
+#include <badge.h>
#include <notification/notification.h>
#include <appfw/app.h>
#include <appfw/app_ui_notification.h>
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<char[]> 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;
}
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<char[]> 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:
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:
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<char[]> 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;
}