//
-// Open Service Platform
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
*/
#include <unique_ptr.h>
+
#include <appsvc/appsvc.h>
#include <bundle.h>
+#include <badge.h>
#include <notification/notification.h>
#include <appfw/app.h>
-#include <appfw/app_manager.h>
#include <appfw/app_ui_notification.h>
+#include <appinfo.h>
#include <FBaseSysLog.h>
#include <FAppNotificationManager.h>
int
_NotificationManagerImpl::GetBadgeNumber(void) const
{
- int count = -1;
- notification_get_badge(NULL, NOTIFICATION_GROUP_ID_NONE, &count);
+ unsigned int count = 0;
+
+ badge_error_e badgeError = badge_get_count(appinfo_get_appid(), &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);
+ badge_error_e badgeError = badge_set_count(appinfo_get_appid(), badgeNumber);
+ SysTryLog(NID_APP, badgeError == BADGE_ERROR_NONE, "badge_set_count failed(%d).", badgeError);
}
CATCH:
String iconPath;
char* pMsg = null;
char* pIcon = null;
- char* pDefaultIconPath = NULL;
- char* pName = NULL;
+ char* pName = null;
ui_notification_h core = NULL;
char buffer[256];
bundle* pKb = NULL;
snprintf(buffer, 256, "%ls", appId.GetPointer());
pPackageAppInfo = _PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId);
- iconPath = _PackageAppInfoImpl::GetInstance(pPackageAppInfo)->GetAppNotificationIconPath();
-
- if (!iconPath.IsEmpty() && File::IsFileExist(iconPath))
+ if (pPackageAppInfo)
{
- pIcon = _StringConverter::CopyToCharArrayN(iconPath);
- r = ConvertNotificationResult(ui_notification_set_icon(core, pIcon));
- SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
+ iconPath = pPackageAppInfo->GetAppNotificationIconPath();
+
+ if (!iconPath.IsEmpty() && File::IsFileExist(iconPath))
+ {
+ pIcon = _StringConverter::CopyToCharArrayN(iconPath);
+ r = ConvertNotificationResult(ui_notification_set_icon(core, pIcon));
+ SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
+ }
+ else
+ {
+ iconPath = pPackageAppInfo->GetAppMenuIconPath();
+ pIcon = _StringConverter::CopyToCharArrayN(iconPath);
+ r = ConvertNotificationResult(ui_notification_set_icon(core, pIcon));
+ SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification Set icon path failed.", GetErrorMessage(r));
+ }
+
+ const String& displayName = pPackageAppInfo->GetAppDisplayName();
+ pName = _StringConverter::CopyToCharArrayN(displayName);
+
+ r = ConvertNotificationResult(ui_notification_set_title(core, pName));
+ SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set title failed.", GetErrorMessage(r));
}
else
{
- app_manager_get_app_icon_path(buffer, &pDefaultIconPath);
- r = ConvertNotificationResult(ui_notification_set_icon(core, pDefaultIconPath));
- SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification Set icon path failed.", GetErrorMessage(r));
+ SysLog(NID_APP, "No packageInfo found for %ls", appId.GetPointer());
}
- app_manager_get_app_name(buffer, &pName);
- r = ConvertNotificationResult(ui_notification_set_title(core, pName));
- SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set title failed.", GetErrorMessage(r));
r = arg.Construct(launchArguments);
SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
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:
delete pPackageAppInfo;
delete[] pMsg;
delete[] pIcon;
- if (pDefaultIconPath)
- {
- free(pDefaultIconPath);
- }
+ delete[] pName;
+
if (core)
{
ui_notification_destroy(core);
}
- if (pName)
- {
- free(pName);
- }
service_destroy(svc);
return r;
}
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;
}