-_NotificationManagerImpl::~_NotificationManagerImpl(void)
-{
-}
-
-result
-_NotificationManagerImpl::Construct(void)
-{
- return E_SUCCESS;
-}
-
-const _NotificationManagerImpl*
-_NotificationManagerImpl::GetInstance(const NotificationManager& notiMgr)
-{
- return notiMgr.__pNotificationManagerImpl;
-}
-
-_NotificationManagerImpl*
-_NotificationManagerImpl::GetInstance(NotificationManager& notiMgr)
-{
- return notiMgr.__pNotificationManagerImpl;
-}
-
-int
-_NotificationManagerImpl::GetBadgeNumber(void) const
-{
- 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;
-}
-
-result
-_NotificationManagerImpl::OngoingImpl(const String& messageText, const String& launchArguments) const
-{
- return NotifyImpl(messageText, -1, launchArguments, true);
-}
-
-result
-_NotificationManagerImpl::OngoingImpl(const AppId& appId, const String& messageText, const String& launchArguments) const
-{
-
- return NotifyImpl(appId, messageText, -1, launchArguments, true);
-}
-
-result
-_NotificationManagerImpl::NotifyImpl(const String& messageText, int badgeNumber,
- const String& launchArguments,
- bool isOngoing) const
-{
- result r = E_SUCCESS;
- int retcode = 0;
- char* pMsg = null;
- char* pkgname = NULL;
- char* pIcon = NULL;
- bundle* pKb = NULL;
- service_h svc = NULL;
- _AppArg arg;
- String iconPath;
- ui_notification_h core = NULL;
- PackageAppInfo* pPackageAppInfo = NULL;
-
- if (!messageText.IsEmpty())
- {
- SysTryReturnResult(NID_APP,
- messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
- "MessageText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
-
- retcode = ui_notification_create(isOngoing, &core);
- SysTryReturnResult(NID_APP, retcode == UI_NOTIFICATION_ERROR_NONE, E_SYSTEM, "Notification creation error : 0x%x.", retcode);
-
- pMsg = _StringConverter::CopyToCharArrayN(messageText);
-
- int ret = ui_notification_set_content(core, pMsg);
- SysTryLog(NID_APP, ret == UI_NOTIFICATION_ERROR_NONE, "Setting notification content failure : %d.", ret);
-
- const String& currappId = _AppInfo::GetApplicationId();
-
- pPackageAppInfo = _PackageManagerImpl::GetInstance()->GetPackageAppInfoN(currappId);
- iconPath = _PackageAppInfoImpl::GetInstance(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));
- }
-
- app_get_package(&pkgname);
- SysTryCatch(NID_APP, pkgname != NULL, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Cannot acquire package name for current application.");
-
- r = arg.Construct(launchArguments);
- if (IsFailed(r))
- {
- SysPropagate(NID_APP, r);
- goto CATCH;
- }
-
- pKb = arg.GetBundle();
- service_create_request(pKb, &svc);
-
- service_set_package(svc, pkgname);
- r = ConvertNotificationResult(ui_notification_set_service(core, svc));
- SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set service failed.", GetErrorMessage(r));
-
- SysLog(NID_APP, "Sending notification[%ls] for package %s.", messageText.GetPointer(), pkgname);
-
- r = ConvertNotificationResult(ui_notification_post(core));
- SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
- }
-
- if (badgeNumber >= 0)
- {
- badge_error_e badgeError = badge_set_count(appinfo_get_appid(), badgeNumber);
- SysTryLog(NID_APP, badgeError == BADGE_ERROR_NONE, "badge_set_count failed(%d).", badgeError);
- }