2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FShell_NotificationManagerImpl.cpp
20 * @brief This is the placeholder for _NotificationManagerImpl class.
23 #include <unique_ptr.h>
24 #include <appsvc/appsvc.h>
26 #include <notification/notification.h>
27 #include <appfw/app.h>
28 #include <appfw/app_manager.h>
29 #include <appfw/app_ui_notification.h>
31 #include <FBaseSysLog.h>
32 #include <FAppTypes.h>
33 #include <FShellNotificationManager.h>
34 #include <FShellNotificationRequest.h>
36 #include <FBaseInternalTypes.h>
37 #include <FBase_StringConverter.h>
38 #include "FApp_AppInfo.h"
41 #include "FAppPkg_PackageManagerImpl.h"
42 #include "FApp_AppArg.h"
43 #include "FShell_NotificationManagerImpl.h"
44 #include "FShell_NotificationManagerProxy.h"
45 #include "FAppPkgPackageAppInfo.h"
46 #include "FAppPkg_PackageAppInfoImpl.h"
48 using namespace Tizen::Base;
49 using namespace Tizen::App;
50 using namespace Tizen::App::Package;
51 using namespace Tizen::Io;
52 using namespace Tizen::Shell;
54 extern "C" int service_create_request(bundle *data, service_h *service);
55 extern "C" int service_to_bundle(service_h service, bundle** data);
61 ConvertNotificationResult(int error)
65 case NOTIFICATION_ERROR_NONE:
67 case NOTIFICATION_ERROR_INVALID_DATA:
69 case NOTIFICATION_ERROR_NO_MEMORY:
70 return E_OUT_OF_MEMORY;
71 case NOTIFICATION_ERROR_FROM_DB:
73 case NOTIFICATION_ERROR_ALREADY_EXIST_ID:
74 return E_OPERATION_FAILED;
75 case NOTIFICATION_ERROR_NOT_EXIST_ID:
76 return E_OPERATION_FAILED;
78 return E_OPERATION_FAILED;
83 IsPosted(ui_notification_h handle)
85 struct ui_notification_s
105 ui_notification_s* pStruct = reinterpret_cast<ui_notification_s*>(handle);
107 return pStruct->posted;
112 namespace Tizen { namespace Shell
115 _NotificationManagerImpl::_NotificationManagerImpl(void)
116 : __pNotificationManager(null)
120 _NotificationManagerImpl::~_NotificationManagerImpl(void)
125 _NotificationManagerImpl::Construct(void)
127 result r = E_SUCCESS;
129 __pNotificationManager = new (std::nothrow) _NotificationManagerProxy;
130 SysTryReturnResult(NID_APP, __pNotificationManager != null, E_OUT_OF_MEMORY, "__pNotificationManagerProxy creation failed.");
132 r = __pNotificationManager->Construct();
133 SysTryCatch(NID_APP, !IsFailed(r), , r, "__pNotificationManager->Construct() failed [%s].", GetErrorMessage(r));
138 delete __pNotificationManager;
139 __pNotificationManager = null;
144 const _NotificationManagerImpl*
145 _NotificationManagerImpl::GetInstance(const NotificationManager& notiMgr)
147 return notiMgr.__pNotificationManagerImpl;
150 _NotificationManagerImpl*
151 _NotificationManagerImpl::GetInstance(NotificationManager& notiMgr)
153 return notiMgr.__pNotificationManagerImpl;
157 _NotificationManagerImpl::GetBadgeNumber(void) const
160 notification_get_badge(NULL, NOTIFICATION_GROUP_ID_NONE, &count);
165 _NotificationManagerImpl::OngoingImpl(const String& messageText, const String& launchArguments) const
167 return NotifyImpl(messageText, -1, launchArguments, true);
171 _NotificationManagerImpl::OngoingImpl(const AppId& appId, const String& messageText, const String& launchArguments) const
174 return NotifyImpl(appId, messageText, -1, launchArguments, true);
178 _NotificationManagerImpl::NotifyImpl(const String& messageText, int badgeNumber,
179 const String& launchArguments,
180 bool isOngoing) const
182 result r = E_SUCCESS;
184 notification_h core = NULL;
185 char* pkgname = NULL;
188 bundle* service_data = NULL;
189 service_h svc = NULL;
192 PackageAppInfo* pPackageAppInfo = null;
194 if (!messageText.IsEmpty())
196 SysTryReturnResult(NID_APP,
197 messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
198 "MessageText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
202 core = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
203 SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
207 core = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
208 SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
211 pMsg = _StringConverter::CopyToCharArrayN(messageText);
212 notification_set_text(core, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
214 const String& currappId = _AppInfo::GetApplicationId();
216 pPackageAppInfo = _PackageManagerImpl::GetInstance()->GetPackageAppInfoN(currappId);
217 iconPath = _PackageAppInfoImpl::GetInstance(pPackageAppInfo)->GetAppNotificationIconPath();
219 if (!iconPath.IsEmpty() && File::IsFileExist(iconPath))
221 pIcon = _StringConverter::CopyToCharArrayN(iconPath);
222 r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pIcon));
223 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
226 app_get_package(&pkgname);
227 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.");
229 r = arg.Construct(launchArguments);
230 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
232 pKb = arg.GetBundle();
233 service_create_request(pKb, &svc);
234 service_set_package(svc, pkgname);
236 if (service_to_bundle(svc, &service_data) == SERVICE_ERROR_NONE)
238 notification_set_property(core, 0);
239 notification_set_execute_option(core, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data);
240 SysLog(NID_APP, "Sending notification[%ls] for package %s.", messageText.GetPointer(), pkgname);
243 r = ConvertNotificationResult(notification_insert(core, NULL));
244 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
247 if (badgeNumber >= 0)
249 notification_set_badge(NULL, NOTIFICATION_GROUP_ID_NONE, badgeNumber);
250 SysLog(NID_APP, "Badge number is set to %d.", badgeNumber);
254 delete pPackageAppInfo;
263 notification_free(core);
265 service_destroy(svc);
270 _NotificationManagerImpl::NotifyImpl(const AppId& appId, const String& messageText, int badgeNumber,
271 const String& launchArguments,
272 bool isOngoing) const
274 result r = E_SUCCESS;
277 char* pDefaultIconPath = NULL;
279 notification_h core = NULL;
282 bundle* service_data = NULL;
283 service_h svc = NULL;
286 PackageAppInfo* pPackageAppInfo = null;
288 memset(buffer, 0, 256);
290 bool isInstalled = _Aul::IsInstalled(appId);
291 SysTryReturnResult(NID_APP, isInstalled == true, E_APP_NOT_INSTALLED, "The application %ls is not installed", appId.GetPointer());
293 if (isOngoing || !messageText.IsEmpty())
295 SysTryReturnResult(NID_APP,
296 messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
297 "MessageText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
301 core = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
302 SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
306 core = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
307 SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
310 pMsg = _StringConverter::CopyToCharArrayN(messageText);
311 notification_set_text(core, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
313 snprintf(buffer, 256, "%ls", appId.GetPointer());
315 pPackageAppInfo = _PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId);
316 iconPath = _PackageAppInfoImpl::GetInstance(pPackageAppInfo)->GetAppNotificationIconPath();
318 if (!iconPath.IsEmpty() && File::IsFileExist(iconPath))
320 pIcon = _StringConverter::CopyToCharArrayN(iconPath);
321 r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pIcon));
322 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
326 app_manager_get_app_icon_path(buffer, &pDefaultIconPath);
327 r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pDefaultIconPath));
328 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification Set icon path failed.", GetErrorMessage(r));
331 app_manager_get_app_name(buffer, &pName);
332 r = ConvertNotificationResult(notification_set_text(core, NOTIFICATION_TEXT_TYPE_TITLE, pName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
333 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set title text failed.", GetErrorMessage(r));
335 r = arg.Construct(launchArguments);
336 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
338 pKb = arg.GetBundle();
339 service_create_request(pKb, &svc);
340 service_set_app_id(svc, buffer);
342 if (service_to_bundle(svc, &service_data) == SERVICE_ERROR_NONE)
344 notification_set_property(core, 0);
345 notification_set_execute_option(core, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data);
346 SysLog(NID_APP, "Sending notification[%ls] for package %s.", messageText.GetPointer(), buffer);
349 r = ConvertNotificationResult(notification_insert(core,NULL));
350 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
353 if (badgeNumber >= 0)
355 notification_set_badge(buffer, NOTIFICATION_GROUP_ID_NONE, badgeNumber);
356 SysLog(NID_APP, "Badge number is set to %d.", badgeNumber);
362 delete pPackageAppInfo;
363 if (pDefaultIconPath)
365 free(pDefaultIconPath);
369 notification_free(core);
376 service_destroy(svc);
382 _NotificationManagerImpl::NotifyMessageImpl(const NotificationRequest& notiMessage, bool isOngoing)
384 result r = E_SUCCESS;
386 notification_h core = NULL;
387 char* pkgname = NULL;
388 char* pTitleText = NULL;
389 char* pIconPath = null;
390 char* pSoundPath = NULL;
392 bundle* service_data = NULL;
393 service_h svc = NULL;
396 PackageAppInfo* pPackageAppInfo = null;
398 const String& messageText = notiMessage.GetAlertText();
399 const String& launchArguments = notiMessage.GetAppMessage();
400 const String& titleText = notiMessage.GetTitleText();
401 const String& iconPath = notiMessage.GetIconFilePath();
402 const String& soundPath = notiMessage.GetSoundFilePath();
403 const int badgeNumber = notiMessage.GetBadgeNumber();
404 const int badgeOffset = notiMessage.GetBadgeOffset();
406 if (isOngoing || !messageText.IsEmpty())
408 SysTryReturnResult(NID_APP,
409 messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
410 "MessageText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
414 core = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
415 SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
419 core = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
420 SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
423 std::unique_ptr<char[]> pMsg(_StringConverter::CopyToCharArrayN(messageText));
427 r = ConvertNotificationResult(notification_set_text(core, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg.get(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
428 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set title text failed.", GetErrorMessage(r));
431 if (!titleText.IsEmpty())
433 pTitleText = _StringConverter::CopyToCharArrayN(titleText);
434 r = ConvertNotificationResult(notification_set_text(core, NOTIFICATION_TEXT_TYPE_TITLE, pTitleText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
435 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set title text failed.", GetErrorMessage(r));
438 if (!iconPath.IsEmpty() )
440 pIconPath = _StringConverter::CopyToCharArrayN(iconPath);
441 r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pIconPath));
442 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
446 const String& currappId = _AppInfo::GetApplicationId();
447 pPackageAppInfo = _PackageManagerImpl::GetInstance()->GetPackageAppInfoN(currappId);
449 appiconPath = _PackageAppInfoImpl::GetInstance(pPackageAppInfo)->GetAppNotificationIconPath();
451 if (!appiconPath.IsEmpty() && File::IsFileExist(appiconPath))
453 pIconPath = _StringConverter::CopyToCharArrayN(appiconPath);
454 r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pIconPath));
455 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
459 if (!soundPath.IsEmpty())
461 pSoundPath = _StringConverter::CopyToCharArrayN(soundPath);
462 r = ConvertNotificationResult(notification_set_sound(core, NOTIFICATION_SOUND_TYPE_USER_DATA, pSoundPath));
463 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set sound failed.", GetErrorMessage(r));
466 app_get_id(&pkgname);
467 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.");
469 r = arg.Construct(launchArguments);
470 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
472 pKb = arg.GetBundle();
473 service_create_request(pKb, &svc);
474 service_set_app_id(svc, pkgname);
476 if (service_to_bundle(svc, &service_data) == SERVICE_ERROR_NONE)
478 notification_set_property(core, 0);
479 notification_set_execute_option(core, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data);
480 SysLog(NID_APP, "Sending notification[%ls] for package %s.", messageText.GetPointer(), pkgname);
485 OngoingActivityType activityType = notiMessage.GetOngoingActivityType();
486 progress = notiMessage.GetOngoingActivityProgress();
487 switch (activityType)
489 case ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE:
490 r = ConvertNotificationResult(notification_insert(core,NULL));
491 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
492 r = ConvertNotificationResult(notification_update_progress(core, NOTIFICATION_PRIV_ID_NONE, progress/100.));
493 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification update failure.", GetErrorMessage(r));
495 case ONGOING_ACTIVITY_TYPE_PROGRESS_BYTE:
496 r = ConvertNotificationResult(notification_insert(core,NULL));
497 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
498 r = ConvertNotificationResult(notification_update_size(core, NOTIFICATION_PRIV_ID_NONE, progress));
499 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification update failure.", GetErrorMessage(r));
501 case ONGOING_ACTIVITY_TYPE_TEXT:
502 r = ConvertNotificationResult(notification_insert(core,NULL));
503 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
506 r = E_OPERATION_FAILED;
507 // ui_notification_set_content() is done already
513 r = ConvertNotificationResult(notification_insert(core,NULL));
514 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
519 SysTryReturnResult(NID_APP, 0, E_INVALID_ARG, "MessageText is Empty");
522 if (badgeNumber >= 0)
524 notification_set_badge(NULL, NOTIFICATION_GROUP_ID_NONE, badgeNumber);
525 SysLog(NID_APP, "Badge number is set to %d.", badgeNumber);
528 if (badgeOffset != 0)
530 // badge offset is exclusive to badge number
533 notification_error_e noti_err = notification_get_badge(NULL, NOTIFICATION_GROUP_ID_NONE, &count);
534 if (noti_err == NOTIFICATION_ERROR_NONE)
536 count += badgeOffset;
539 notification_set_badge(NULL, NOTIFICATION_GROUP_ID_NONE, count);
540 SysLog(NID_APP, "Badge number is set to %d.", count);
549 delete pPackageAppInfo;
557 notification_free(core);
559 service_destroy(svc);
564 _NotificationManagerImpl::NotifyMessageImpl(const AppId& appId, const NotificationRequest& notiMessage, bool isOngoing)
566 return __pNotificationManager->NotifyMessage(appId, notiMessage, isOngoing);
571 _NotificationManagerImpl::Notify(int badgeNumber) const
573 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
575 if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER)
577 badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER;
580 String messageText = String(L"");
581 String appMessage = String(L"");
583 return NotifyImpl(messageText, badgeNumber, appMessage, false);
587 _NotificationManagerImpl::Notify(const String& messageText) const
589 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
591 String appMessage = String(L"");
593 return NotifyImpl(messageText, -1, appMessage, false);
597 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber) const
599 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
600 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
602 if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER)
604 badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER;
607 String appMessage = String(L"");
609 return NotifyImpl(messageText, badgeNumber, appMessage, false);
613 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, const String& launchArguments) const
615 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
616 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
617 SysTryReturnResult(NID_APP,
618 launchArguments != null && launchArguments.GetLength() > 0, E_INVALID_ARG,
619 "launchArguments is less than 0.");
621 SysTryReturnResult(NID_APP,
622 launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
623 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
625 if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER)
627 badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER;
630 return NotifyImpl(messageText, badgeNumber, launchArguments, false);
634 _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const
636 bool b = _Aul::IsInstalled(appId);
637 SysTryReturn(NID_APP, b == true, -1, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The application %ls is not installed",
643 memset(buffer, 0, 256);
645 snprintf(buffer, 256, "%ls", appId.GetPointer());
647 notification_get_badge(buffer, NOTIFICATION_GROUP_ID_NONE, &count);
654 _NotificationManagerImpl::NotifyByAppId(const AppId& appId, int badgeNumber) const
656 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
658 String messageText = String(L"");
659 String appMessage = String(L"");
660 return NotifyImpl(appId, messageText, badgeNumber, appMessage);
664 _NotificationManagerImpl::NotifyByAppId(const AppId& appId, const String& messageText) const
666 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
668 return NotifyImpl(appId, messageText, -1, String(L""));
672 _NotificationManagerImpl::NotifyByAppId(const AppId& appId, const String& messageText, int badgeNumber) const
674 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
675 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
677 return NotifyImpl(appId, messageText, badgeNumber, String(L""));
681 _NotificationManagerImpl::NotifyByAppId(const AppId& appId, const String& messageText, const String& launchArguments) const
683 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
684 SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0.");
685 SysTryReturnResult(NID_APP,
686 launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
687 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
689 return NotifyImpl(appId, messageText, -1, launchArguments);
693 _NotificationManagerImpl::NotifyByAppId(const AppId& appId, const String& messageText, int badgeNumber,
694 const String& launchArguments) const
696 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
697 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
698 SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0.");
699 SysTryReturnResult(NID_APP,
700 launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
701 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
703 return NotifyImpl(appId, messageText, badgeNumber, launchArguments);
707 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText) const
709 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
711 return OngoingImpl(messageText, String(L""));
715 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText, const String& launchArguments) const
717 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
718 SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0.");
719 SysTryReturnResult(NID_APP,
720 launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
721 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
723 return OngoingImpl(messageText, launchArguments);
727 _NotificationManagerImpl::NotifyOngoingActivityByAppId(const AppId& appId, const String& messageText) const
729 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
731 return OngoingImpl(appId, messageText, String(L""));
735 _NotificationManagerImpl::NotifyOngoingActivityByAppId(const AppId& appId, const String& messageText,
736 const String& launchArguments) const
738 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
739 SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0.");
740 SysTryReturnResult(NID_APP,
741 launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
742 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
744 return OngoingImpl(appId, messageText, launchArguments);
748 _NotificationManagerImpl::RemoveOngoingActivityNotification(void)
750 result r = E_SUCCESS;
752 notification_error_e err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_ONGOING);
755 case NOTIFICATION_ERROR_NONE:
759 case NOTIFICATION_ERROR_INVALID_DATA:
764 r = E_OPERATION_FAILED;
772 _NotificationManagerImpl::RemoveOngoingActivityNotificationByAppId(const AppId& appId)
774 return __pNotificationManager->RemoveNotification(appId, true);
778 _NotificationManagerImpl::RemoveNotification(void)
780 result r = E_SUCCESS;
782 notification_error_e err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI);
785 case NOTIFICATION_ERROR_NONE:
789 case NOTIFICATION_ERROR_INVALID_DATA:
794 r = E_OPERATION_FAILED;
802 _NotificationManagerImpl::RemoveNotificationByAppId(const AppId& appId)
804 return __pNotificationManager->RemoveNotification(appId,false);
808 _NotificationManagerImpl::NotifyTextMessage(const String& messageText) const
810 SysTryReturnResult(NID_APP, !messageText.IsEmpty(), E_INVALID_ARG, "MessageText is less than 0.");
812 std::unique_ptr<char[]> pMsg(_StringConverter::CopyToCharArrayN(messageText));
813 int res = notification_status_message_post(pMsg.get());
815 result r = E_SUCCESS;
818 case NOTIFICATION_ERROR_NONE:
821 case NOTIFICATION_ERROR_INVALID_DATA:
824 case NOTIFICATION_ERROR_IO:
832 SysLog(NID_APP, "[%s] %ls posted.", GetErrorMessage(r), messageText.GetPointer());