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"
39 #include "FAppPkg_PackageManagerImpl.h"
40 #include "FApp_AppArg.h"
41 #include "FShell_NotificationManagerImpl.h"
42 #include "FShell_NotificationManagerProxy.h"
44 using namespace Tizen::Base;
45 using namespace Tizen::App;
46 using namespace Tizen::App::Package;
47 using namespace Tizen::Shell;
49 extern "C" int service_create_request(bundle *data, service_h *service);
50 extern "C" int service_to_bundle(service_h service, bundle** data);
56 ConvertNotificationResult(int error)
60 case NOTIFICATION_ERROR_NONE:
62 case NOTIFICATION_ERROR_INVALID_DATA:
64 case NOTIFICATION_ERROR_NO_MEMORY:
65 return E_OUT_OF_MEMORY;
66 case NOTIFICATION_ERROR_FROM_DB:
68 case NOTIFICATION_ERROR_ALREADY_EXIST_ID:
69 return E_OPERATION_FAILED;
70 case NOTIFICATION_ERROR_NOT_EXIST_ID:
71 return E_OPERATION_FAILED;
73 return E_OPERATION_FAILED;
78 IsPosted(ui_notification_h handle)
80 struct ui_notification_s
100 ui_notification_s* pStruct = reinterpret_cast<ui_notification_s*>(handle);
102 return pStruct->posted;
107 namespace Tizen { namespace Shell
110 _NotificationManagerImpl::_NotificationManagerImpl(void)
111 : __pNotificationManager(null)
115 _NotificationManagerImpl::~_NotificationManagerImpl(void)
120 _NotificationManagerImpl::Construct(void)
122 result r = E_SUCCESS;
124 __pNotificationManager = new (std::nothrow) _NotificationManagerProxy;
125 SysTryReturnResult(NID_APP, __pNotificationManager != null, E_OUT_OF_MEMORY, "__pNotificationManagerProxy creation failed.");
127 r = __pNotificationManager->Construct();
128 SysTryCatch(NID_APP, !IsFailed(r), , r, "__pNotificationManager->Construct() failed [%s].", GetErrorMessage(r));
133 delete __pNotificationManager;
134 __pNotificationManager = null;
139 const _NotificationManagerImpl*
140 _NotificationManagerImpl::GetInstance(const NotificationManager& notiMgr)
142 return notiMgr.__pNotificationManagerImpl;
145 _NotificationManagerImpl*
146 _NotificationManagerImpl::GetInstance(NotificationManager& notiMgr)
148 return notiMgr.__pNotificationManagerImpl;
152 _NotificationManagerImpl::GetBadgeNumber(void) const
155 notification_get_badge(NULL, NOTIFICATION_GROUP_ID_NONE, &count);
160 _NotificationManagerImpl::OngoingImpl(const String& messageText, const String& launchArguments) const
162 return NotifyImpl(messageText, -1, launchArguments, true);
166 _NotificationManagerImpl::OngoingImpl(const AppId& appId, const String& messageText, const String& launchArguments) const
169 return NotifyImpl(appId, messageText, -1, launchArguments, true);
173 _NotificationManagerImpl::NotifyImpl(const String& messageText, int badgeNumber,
174 const String& launchArguments,
175 bool isOngoing) const
177 result r = E_SUCCESS;
179 notification_h core = NULL;
180 char* pkgname = NULL;
182 bundle* service_data = NULL;
183 service_h svc = NULL;
186 if (!messageText.IsEmpty())
188 SysTryReturnResult(NID_APP,
189 messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
190 "MessageText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
194 core = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
195 SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
199 core = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
200 SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
203 pMsg = _StringConverter::CopyToCharArrayN(messageText);
204 notification_set_text(core, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
206 app_get_package(&pkgname);
207 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.");
209 r = arg.Construct(launchArguments);
210 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
212 pKb = arg.GetBundle();
213 service_create_request(pKb, &svc);
214 service_set_package(svc, pkgname);
216 if (service_to_bundle(svc, &service_data) == SERVICE_ERROR_NONE)
218 notification_set_property(core, 0);
219 notification_set_execute_option(core, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data);
220 SysLog(NID_APP, "Sending notification[%ls] for package %s.", messageText.GetPointer(), pkgname);
223 r = ConvertNotificationResult(notification_insert(core, NULL));
224 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
227 if (badgeNumber >= 0)
229 notification_set_badge(NULL, NOTIFICATION_GROUP_ID_NONE, badgeNumber);
230 SysLog(NID_APP, "Badge number is set to %d.", badgeNumber);
242 notification_free(core);
244 service_destroy(svc);
249 _NotificationManagerImpl::NotifyImpl(const AppId& appId, const String& messageText, int badgeNumber,
250 const String& launchArguments,
251 bool isOngoing) const
253 result r = E_SUCCESS;
257 notification_h core = NULL;
260 bundle* service_data = NULL;
261 service_h svc = NULL;
264 memset(buffer, 0, 256);
266 bool b = _PackageManagerImpl::IsAppInstalled(appId);
268 SysTryReturnResult(NID_APP, b == true, E_APP_NOT_INSTALLED, "The application %ls is not installed", appId.GetPointer());
270 if (isOngoing || !messageText.IsEmpty())
272 SysTryReturnResult(NID_APP,
273 messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
274 "MessageText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
278 core = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
279 SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
283 core = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
284 SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
287 pMsg = _StringConverter::CopyToCharArrayN(messageText);
288 notification_set_text(core, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
290 snprintf(buffer, 256, "%ls", appId.GetPointer());
292 app_manager_get_app_icon_path(buffer, &pIcon);
293 r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pIcon));
294 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
296 app_manager_get_app_name(buffer, &pName);
297 r = ConvertNotificationResult(notification_set_text(core, NOTIFICATION_TEXT_TYPE_TITLE, pName, NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
298 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set title text failed.", GetErrorMessage(r));
300 r = arg.Construct(launchArguments);
301 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
303 pKb = arg.GetBundle();
304 service_create_request(pKb, &svc);
305 service_set_app_id(svc, buffer);
307 if (service_to_bundle(svc, &service_data) == SERVICE_ERROR_NONE)
309 notification_set_property(core, 0);
310 notification_set_execute_option(core, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data);
311 SysLog(NID_APP, "Sending notification[%ls] for package %s.", messageText.GetPointer(), buffer);
314 r = ConvertNotificationResult(notification_insert(core,NULL));
315 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
318 if (badgeNumber >= 0)
320 notification_set_badge(buffer, NOTIFICATION_GROUP_ID_NONE, badgeNumber);
321 SysLog(NID_APP, "Badge number is set to %d.", badgeNumber);
329 notification_free(core);
341 service_destroy(svc);
347 _NotificationManagerImpl::NotifyMessageImpl(const NotificationRequest& notiMessage, bool isOngoing)
349 result r = E_SUCCESS;
351 notification_h core = NULL;
352 char* pkgname = NULL;
353 char* pTitleText = NULL;
354 char* pIconPath = NULL;
355 char* pSoundPath = NULL;
357 bundle* service_data = NULL;
358 service_h svc = NULL;
361 const String& messageText = notiMessage.GetAlertText();
362 const String& launchArguments = notiMessage.GetAppMessage();
363 const String& titleText = notiMessage.GetTitleText();
364 const String& iconPath = notiMessage.GetIconFilePath();
365 const String& soundPath = notiMessage.GetSoundFilePath();
366 const int badgeNumber = notiMessage.GetBadgeNumber();
367 const int badgeOffset = notiMessage.GetBadgeOffset();
369 if (isOngoing || !messageText.IsEmpty())
371 SysTryReturnResult(NID_APP,
372 messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
373 "MessageText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
377 core = notification_new(NOTIFICATION_TYPE_ONGOING, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
378 SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
382 core = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_DEFAULT, NOTIFICATION_PRIV_ID_NONE);
383 SysTryReturnResult(NID_APP, core!= NULL , E_SYSTEM, "Notification creation failed ");
386 std::unique_ptr<char[]> pMsg(_StringConverter::CopyToCharArrayN(messageText));
390 r = ConvertNotificationResult(notification_set_text(core, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg.get(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
391 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set title text failed.", GetErrorMessage(r));
394 if (!titleText.IsEmpty())
396 pTitleText = _StringConverter::CopyToCharArrayN(titleText);
397 r = ConvertNotificationResult(notification_set_text(core, NOTIFICATION_TEXT_TYPE_TITLE, pTitleText, NULL, NOTIFICATION_VARIABLE_TYPE_NONE));
398 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set title text failed.", GetErrorMessage(r));
401 if (!iconPath.IsEmpty())
403 pIconPath = _StringConverter::CopyToCharArrayN(iconPath);
404 r = ConvertNotificationResult(notification_set_image(core, NOTIFICATION_IMAGE_TYPE_ICON, pIconPath));
405 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set icon failed.", GetErrorMessage(r));
408 if (!soundPath.IsEmpty())
410 pSoundPath = _StringConverter::CopyToCharArrayN(soundPath);
411 r = ConvertNotificationResult(notification_set_sound(core, NOTIFICATION_SOUND_TYPE_USER_DATA, pSoundPath));
412 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification set sound failed.", GetErrorMessage(r));
415 app_get_id(&pkgname);
416 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.");
418 r = arg.Construct(launchArguments);
419 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r));
421 pKb = arg.GetBundle();
422 service_create_request(pKb, &svc);
423 service_set_app_id(svc, pkgname);
425 if (service_to_bundle(svc, &service_data) == SERVICE_ERROR_NONE)
427 notification_set_property(core, 0);
428 notification_set_execute_option(core, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, service_data);
429 SysLog(NID_APP, "Sending notification[%ls] for package %s.", messageText.GetPointer(), pkgname);
434 OngoingActivityType activityType = notiMessage.GetOngoingActivityType();
435 progress = notiMessage.GetOngoingActivityProgress();
436 switch (activityType)
438 case ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE:
439 r = ConvertNotificationResult(notification_insert(core,NULL));
440 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
441 r = ConvertNotificationResult(notification_update_progress(core, NOTIFICATION_PRIV_ID_NONE, progress/100.));
442 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification update failure.", GetErrorMessage(r));
444 case ONGOING_ACTIVITY_TYPE_PROGRESS_BYTE:
445 r = ConvertNotificationResult(notification_insert(core,NULL));
446 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
447 r = ConvertNotificationResult(notification_update_size(core, NOTIFICATION_PRIV_ID_NONE, progress));
448 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification update failure.", GetErrorMessage(r));
450 case ONGOING_ACTIVITY_TYPE_TEXT:
451 r = ConvertNotificationResult(notification_insert(core,NULL));
452 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
455 r = E_OPERATION_FAILED;
456 // ui_notification_set_content() is done already
462 r = ConvertNotificationResult(notification_insert(core,NULL));
463 SysTryLog(NID_APP, !IsFailed(r), "[%s] Notification post failure.", GetErrorMessage(r));
468 SysTryReturnResult(NID_APP, 0, E_INVALID_ARG, "MessageText is Empty");
471 if (badgeNumber >= 0)
473 notification_set_badge(NULL, NOTIFICATION_GROUP_ID_NONE, badgeNumber);
474 SysLog(NID_APP, "Badge number is set to %d.", badgeNumber);
477 if (badgeOffset != 0)
479 // badge offset is exclusive to badge number
482 notification_error_e noti_err = notification_get_badge(NULL, NOTIFICATION_GROUP_ID_NONE, &count);
483 if (noti_err == NOTIFICATION_ERROR_NONE)
485 count += badgeOffset;
488 notification_set_badge(NULL, NOTIFICATION_GROUP_ID_NONE, count);
489 SysLog(NID_APP, "Badge number is set to %d.", count);
504 notification_free(core);
506 service_destroy(svc);
511 _NotificationManagerImpl::NotifyMessageImpl(const AppId& appId, const NotificationRequest& notiMessage, bool isOngoing)
513 return __pNotificationManager->NotifyMessage(appId, notiMessage, isOngoing);
518 _NotificationManagerImpl::Notify(int badgeNumber) const
520 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
522 if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER)
524 badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER;
527 String messageText = String(L"");
528 String appMessage = String(L"");
530 return NotifyImpl(messageText, badgeNumber, appMessage, false);
534 _NotificationManagerImpl::Notify(const String& messageText) const
536 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
538 String appMessage = String(L"");
540 return NotifyImpl(messageText, -1, appMessage, false);
544 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber) const
546 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
547 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
549 if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER)
551 badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER;
554 String appMessage = String(L"");
556 return NotifyImpl(messageText, badgeNumber, appMessage, false);
560 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, const String& launchArguments) const
562 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
563 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
564 SysTryReturnResult(NID_APP,
565 launchArguments != null && launchArguments.GetLength() > 0, E_INVALID_ARG,
566 "launchArguments is less than 0.");
568 SysTryReturnResult(NID_APP,
569 launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
570 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
572 if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER)
574 badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER;
577 return NotifyImpl(messageText, badgeNumber, launchArguments, false);
581 _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const
583 bool b = _PackageManagerImpl::IsAppInstalled(appId);
585 SysTryReturn(NID_APP, b == true, -1, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The application %ls is not installed",
591 memset(buffer, 0, 256);
593 snprintf(buffer, 256, "%ls", appId.GetPointer());
595 notification_get_badge(buffer, NOTIFICATION_GROUP_ID_NONE, &count);
602 _NotificationManagerImpl::NotifyByAppId(const AppId& appId, int badgeNumber) const
604 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
606 String messageText = String(L"");
607 String appMessage = String(L"");
608 return NotifyImpl(appId, messageText, badgeNumber, appMessage);
612 _NotificationManagerImpl::NotifyByAppId(const AppId& appId, const String& messageText) const
614 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
616 return NotifyImpl(appId, messageText, -1, String(L""));
620 _NotificationManagerImpl::NotifyByAppId(const AppId& appId, const String& messageText, int badgeNumber) const
622 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
623 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
625 return NotifyImpl(appId, messageText, badgeNumber, String(L""));
629 _NotificationManagerImpl::NotifyByAppId(const AppId& appId, const String& messageText, const String& launchArguments) const
631 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
632 SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0.");
633 SysTryReturnResult(NID_APP,
634 launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
635 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
637 return NotifyImpl(appId, messageText, -1, launchArguments);
641 _NotificationManagerImpl::NotifyByAppId(const AppId& appId, const String& messageText, int badgeNumber,
642 const String& launchArguments) const
644 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
645 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
646 SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0.");
647 SysTryReturnResult(NID_APP,
648 launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
649 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
651 return NotifyImpl(appId, messageText, badgeNumber, launchArguments);
655 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText) const
657 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
659 return OngoingImpl(messageText, String(L""));
663 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText, const String& launchArguments) const
665 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
666 SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0.");
667 SysTryReturnResult(NID_APP,
668 launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
669 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
671 return OngoingImpl(messageText, launchArguments);
675 _NotificationManagerImpl::NotifyOngoingActivityByAppId(const AppId& appId, const String& messageText) const
677 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
679 return OngoingImpl(appId, messageText, String(L""));
683 _NotificationManagerImpl::NotifyOngoingActivityByAppId(const AppId& appId, const String& messageText,
684 const String& launchArguments) const
686 SysTryReturnResult(NID_APP, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0.");
687 SysTryReturnResult(NID_APP, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0.");
688 SysTryReturnResult(NID_APP,
689 launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
690 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
692 return OngoingImpl(appId, messageText, launchArguments);
696 _NotificationManagerImpl::RemoveOngoingActivityNotification(void)
698 result r = E_SUCCESS;
700 notification_error_e err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_ONGOING);
703 case NOTIFICATION_ERROR_NONE:
707 case NOTIFICATION_ERROR_INVALID_DATA:
712 r = E_OPERATION_FAILED;
720 _NotificationManagerImpl::RemoveOngoingActivityNotificationByAppId(const AppId& appId)
722 return __pNotificationManager->RemoveNotification(appId, true);
726 _NotificationManagerImpl::RemoveNotification(void)
728 result r = E_SUCCESS;
730 notification_error_e err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI);
733 case NOTIFICATION_ERROR_NONE:
737 case NOTIFICATION_ERROR_INVALID_DATA:
742 r = E_OPERATION_FAILED;
750 _NotificationManagerImpl::RemoveNotificationByAppId(const AppId& appId)
752 return __pNotificationManager->RemoveNotification(appId,false);