From: kyeongwoo.lee Date: Wed, 3 Apr 2013 14:44:01 +0000 (+0900) Subject: Revert "Revert "update codes for NotificationManager and NotificationRequest class"" X-Git-Tag: accepted/tizen_2.1/20130425.034720~47 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1c420cd2b47d43758cb580bd2846083a3add8a44;p=platform%2Fframework%2Fnative%2Fshell.git Revert "Revert "update codes for NotificationManager and NotificationRequest class"" This reverts commit 5209441c711996acc45863cc98878f96f2aaafc5 --- diff --git a/inc/FShellNotificationManager.h b/inc/FShellNotificationManager.h index f0c0c82..6919ddd 100644 --- a/inc/FShellNotificationManager.h +++ b/inc/FShellNotificationManager.h @@ -182,8 +182,9 @@ public: * @return An error code * @param[in] badgeNumber The badge number * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG The specified input parameter is invalid, or - * the specified @c badgeNumber is less than @c 0. + * @exception E_INVALID_ARG Either of the following conditions has occurred: @n + * - The specified input parameter is invalid. + * - The specified @c badgeNumber is less than @c 0 or the @c badgeNumber is greater than Shell::MAX_NOTIFICATION_BADGE_NUMBER. * @exception E_OPERATION_FAILED The operation has failed. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. */ @@ -199,8 +200,9 @@ public: * @return An error code * @param[in] messageText The notification message * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG The specified input parameter is invalid, or - * the length of @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. + * @exception E_INVALID_ARG Either of the following conditions has occurred: @n + * - The specified input parameter is invalid. + * - The specified @c messageText is empty or the length of @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. * @exception E_OPERATION_FAILED The operation has failed. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. */ @@ -217,8 +219,9 @@ public: * @param[in] messageText The notification message * @param[in] badgeNumber The badge number * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG The specified @c badgeNumber is less than @c 0, or - * the length of @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. + * @exception E_INVALID_ARG Either of the following conditions has occurred: @n + * - The specified @c messageText is empty or the length of @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. + * - The specified @c badgeNumber is less than @c 0 or the @c badgeNumber is greater than Shell::MAX_NOTIFICATION_BADGE_NUMBER. * @exception E_OPERATION_FAILED The operation has failed. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. */ @@ -240,10 +243,10 @@ public: * @param[in] launchArguments The message for the application * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG Either of the following conditions has occurred: @n - * - A specified input parameter is invalid. @n - * - The specified @c badgeNumber is less than @c 0. @n - * - The length of the specified @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. @n - * - The length of the specified @c launchArguments is greater than Shell::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH. + * - A specified input parameter is invalid. + * - The specified @c badgeNumber is less than @c 0 or the @c badgeNumber is greater than Shell::MAX_NOTIFICATION_BADGE_NUMBER. + * - The specified @c messageText is empty or the length of @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. @n + * - The specified @c launchArguments is empty or the length of @c launchArguments is greater than Shell::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH. * @exception E_OPERATION_FAILED The operation has failed. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. */ @@ -260,10 +263,7 @@ public: * @return An error code * @param[in] request The notification request * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG Either of the following conditions has occurred: @n - * - The specified @c request does not have valid badge number value in @c request. @n - * - The specified @c request does not have alert text in @c request. @n - * - The specified @c request has invalid icon file path in @c request. + * @exception E_INVALID_ARG A specified input parameter is invalid. * @exception E_OPERATION_FAILED The operation has failed. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. */ @@ -283,10 +283,7 @@ public: * @param[in] request The notification request * @exception E_SUCCESS The method is successful. * @exception E_APP_NOT_INSTALLED The application is not installed. - * @exception E_INVALID_ARG Either of the following conditions has occurred: @n - * - The specified @c request does not have valid badge number value in @c request. @n - * - The specified @c request does not have alert text in @c request. @n - * - The specified @c request has invalid icon file path in @c request. + * @exception E_INVALID_ARG A specified input parameter is invalid. * @exception E_OPERATION_FAILED The operation has failed. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. */ @@ -335,8 +332,9 @@ public: * @return An error code * @param[in] messageText The notification message * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG The specified input parameter is invalid, or - * the length of @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. + * @exception E_INVALID_ARG Either of the following conditions has occurred: @n + * - The specified input parameter is invalid. + * - The specified @c messageText is empty or the length of @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. * @exception E_OPERATION_FAILED The operation has failed. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. */ @@ -358,8 +356,8 @@ public: * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG Either of the following conditions has occurred: @n * - A specified input parameter is invalid. @n - * - The length of the specified @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. @n - * - The length of the specified @c launchArguments is greater than Shell::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH. + * - The specified @c messageText is empty or the length of @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. @n + * - The specified @c launchArguments is empty or the length of @c launchArguments is greater than Shell::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH. * @exception E_OPERATION_FAILED The operation has failed. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. */ @@ -376,9 +374,7 @@ public: * @return An error code * @param[in] request The notification request * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG Either of the following conditions has occurred: @n - * - The specified @c request does not have either alert text or progress value in @c request. @n - * - The specified @c request has invalid icon file path in @c request. + * @exception E_INVALID_ARG A specified input parameter is invalid. * @exception E_OPERATION_FAILED The operation has failed. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. */ @@ -397,9 +393,7 @@ public: * @param[in] appId The application ID * @param[in] request The notification request * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG Either of the following conditions has occurred: @n - * - The specified @c request does not have either alert text or progress value in @c request. @n - * - The specified @c request has invalid icon file path in @c request. + * @exception E_INVALID_ARG A specified input parameter is invalid. * @exception E_APP_NOT_INSTALLED The application is not installed. * @exception E_OPERATION_FAILED The operation has failed. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. @@ -468,7 +462,9 @@ public: * @return An error code * @param[in] messageText The notification message * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_ARG Either of the following conditions has occurred: @n + * - The specified input parameter is invalid. + * - The specified @c messageText is empty or the length of @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. * @exception E_OPERATION_FAILED The operation has failed. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @remarks Message is displayed in the status bar. @@ -491,10 +487,7 @@ public: * The maximum size is 16 kilo bytes. * @param[in] request The notification request * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG Either of the following conditions has occurred: @n - * - The specified @c request does not have valid badge number value in @c request. @n - * - The specified @c request does not have alert text in @c request. @n - * - The specified @c request has invalid icon file path in @c request. + * @exception E_INVALID_ARG A specified input parameter is invalid. * @exception E_OPERATION_FAILED The operation has failed. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @remarks For more information on the implicit AppControl resolution, see Resolving AppControls. @@ -519,9 +512,7 @@ public: * The maximum size is 16 kilo bytes. * @param[in] request The notification request * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG Either of the following conditions has occurred: @n - * - The specified @c request does not have either alert text or progress value in @c request. @n - * - The specified @c request has invalid icon file path in @c request. + * @exception E_INVALID_ARG A specified input parameter is invalid. * @exception E_OPERATION_FAILED The operation has failed. * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. * @remarks For more information on the implicit AppControl resolution, see Resolving AppControls. diff --git a/inc/FShellNotificationRequest.h b/inc/FShellNotificationRequest.h index 18dbbf4..2f59995 100644 --- a/inc/FShellNotificationRequest.h +++ b/inc/FShellNotificationRequest.h @@ -210,7 +210,7 @@ public: * @return An error code * @param[in] appMessage The message for the application * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG The length of @c appMessage is greater than Shell::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH. + * @exception E_INVALID_ARG The specified @c appMessage is empty or the length of @c appMessage is greater than Shell::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH. * @exception E_INVALID_OPERATION This instance is not bound to the application. * @remarks This method returns @c E_INVALID_OPERATION if %NotificationRequest instance is not bound to the application. */ @@ -233,7 +233,7 @@ public: * @return An error code * @param[in] title The title text * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG The length of @c title is greater than Shell::MAX_NOTIFICATION_TITLE_LENGTH. + * @exception E_INVALID_ARG The specified @c title is empty or the length of @c title is greater than Shell::MAX_NOTIFICATION_TITLE_LENGTH. */ result SetTitleText(const Tizen::Base::String& title); diff --git a/src/core/FShellNotificationManager.cpp b/src/core/FShellNotificationManager.cpp index 8c0b36c..8b38bc2 100644 --- a/src/core/FShellNotificationManager.cpp +++ b/src/core/FShellNotificationManager.cpp @@ -64,7 +64,7 @@ NotificationManager::GetBadgeNumber(void) SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use."); result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION); - SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method."); + SysTryReturn(NID_SHELL, !IsFailed(r), -1, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."); return __pNotificationManagerImpl->GetBadgeNumber(); } @@ -141,7 +141,7 @@ NotificationManager::GetBadgeNumberByAppId(const AppId& appId) SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use."); result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION); - SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method."); + SysTryReturn(NID_SHELL, !IsFailed(r), -1, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."); return __pNotificationManagerImpl->GetBadgeNumber(appId); } diff --git a/src/core/FShell_NotificationManagerImpl.cpp b/src/core/FShell_NotificationManagerImpl.cpp index e4229f5..89c4fad 100644 --- a/src/core/FShell_NotificationManagerImpl.cpp +++ b/src/core/FShell_NotificationManagerImpl.cpp @@ -245,6 +245,8 @@ _NotificationManagerImpl::GetInstance(NotificationManager& notiMgr) int _NotificationManagerImpl::GetBadgeNumber(void) const { + ClearLastResult(); + Tizen::App::App* pApp = Tizen::App::App::GetInstance(); std::unique_ptr pAppId(_StringConverter::CopyToCharArrayN(pApp->GetAppId())); @@ -252,7 +254,6 @@ _NotificationManagerImpl::GetBadgeNumber(void) const SysTryReturn(NID_SHELL, count != -1, count, E_OPERATION_FAILED, "[%s] The operation has failed. Badge may not exist.", GetErrorMessage(E_OPERATION_FAILED)); - ClearLastResult(); return count; } @@ -272,12 +273,8 @@ _NotificationManagerImpl::NotifyMessageImpl(const AppId& appId, const Notificati result _NotificationManagerImpl::Notify(int badgeNumber) { - SysTryReturnResult(NID_SHELL, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0."); - - if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER) - { - badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER; - } + SysTryReturnResult(NID_SHELL, badgeNumber >= 0 && badgeNumber <= MAX_NOTIFICATION_BADGE_NUMBER, E_INVALID_ARG, + "badgeNumber is less than 0 or greater than MAX_NOTIFICATION_BADGE_NUMBER."); Tizen::App::App* pApp = Tizen::App::App::GetInstance(); std::unique_ptr pAppId(_StringConverter::CopyToCharArrayN(pApp->GetAppId())); @@ -298,7 +295,8 @@ _NotificationManagerImpl::Notify(int badgeNumber) result _NotificationManagerImpl::Notify(const String& messageText) { - SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); + SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0 && messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, + "messageText is less than 1 or greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); NotificationRequest request; request.SetAlertText(messageText); @@ -310,13 +308,10 @@ _NotificationManagerImpl::Notify(const String& messageText) result _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber) { - SysTryReturnResult(NID_SHELL, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0."); - SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); - - if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER) - { - badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER; - } + SysTryReturnResult(NID_SHELL, badgeNumber >= 0 && badgeNumber <= MAX_NOTIFICATION_BADGE_NUMBER, E_INVALID_ARG, + "badgeNumber is less than 0 or greater than MAX_NOTIFICATION_BADGE_NUMBER."); + SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0 && messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, + "messageText is less than 1 or greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); NotificationRequest request; request.SetAlertText(messageText); @@ -329,18 +324,12 @@ _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber) result _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, const String& launchArguments) { - SysTryReturnResult(NID_SHELL, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0."); - SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); - SysTryReturnResult(NID_SHELL, launchArguments != null && launchArguments.GetLength() > 0, E_INVALID_ARG, - "launchArguments is less than 0."); - - SysTryReturnResult(NID_SHELL, launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG, - "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH."); - - if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER) - { - badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER; - } + SysTryReturnResult(NID_SHELL, badgeNumber >= 0 && badgeNumber <= MAX_NOTIFICATION_BADGE_NUMBER, E_INVALID_ARG, + "badgeNumber is less than 0 or greater than MAX_NOTIFICATION_BADGE_NUMBER."); + SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0 && messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, + "messageText is less than 1 or greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); + SysTryReturnResult(NID_SHELL, launchArguments.GetLength() > 0 && launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG, + "launchArguments is less than 1 or greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH."); NotificationRequest request; request.SetAlertText(messageText); @@ -353,6 +342,8 @@ _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, con int _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const { + ClearLastResult(); + bool b = _Aul::IsInstalled(appId); SysTryReturn(NID_SHELL, b == true, -1, E_APP_NOT_INSTALLED, "[E_OBJ_NOT_FOUND] The application %ls is not installed", appId.GetPointer()); @@ -361,7 +352,6 @@ _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const SysTryReturn(NID_SHELL, count != -1, count, E_OPERATION_FAILED, "[%s] The operation has failed. Badge may not exist.", GetErrorMessage(E_OPERATION_FAILED)); - ClearLastResult(); return count; } @@ -369,7 +359,8 @@ _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const result _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText) { - SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); + SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0 && messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, + "messageText is less than 1 or greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); NotificationRequest request; request.SetAlertText(messageText); @@ -380,7 +371,8 @@ _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText) result _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText, const String& launchArguments) { - SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0, E_INVALID_ARG, "MessageText is less than 0."); + SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0 && messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, + "messageText is less than 1 or greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); SysTryReturnResult(NID_SHELL, launchArguments.GetLength() > 0, E_INVALID_ARG, "launchArguments is less than 0."); SysTryReturnResult(NID_SHELL, launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG, "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH."); @@ -408,7 +400,8 @@ _NotificationManagerImpl::RemoveNotificationByAppId(const AppId& appId) result _NotificationManagerImpl::NotifyTextMessage(const String& messageText) const { - SysTryReturnResult(NID_SHELL, !messageText.IsEmpty(), E_INVALID_ARG, "MessageText is less than 0."); + SysTryReturnResult(NID_SHELL, messageText.GetLength() > 0 && messageText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, + "messageText is less than 1 or greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); std::unique_ptr pMsg(_StringConverter::CopyToCharArrayN(messageText)); int res = notification_status_message_post(pMsg.get()); @@ -423,10 +416,10 @@ _NotificationManagerImpl::NotifyTextMessage(const String& messageText) const r = E_INVALID_ARG; break; case NOTIFICATION_ERROR_IO: - r = E_SYSTEM; + r = E_OPERATION_FAILED; break; default: - r = E_SYSTEM; + r = E_OPERATION_FAILED; break; } @@ -629,7 +622,7 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing, // Set - content text if (pMsg.get()) { - r = notification_set_text(notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg.get(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE); + r = ConvertNotificationResult(notification_set_text(notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, pMsg.get(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE)); SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set Title Text failed.", GetErrorMessage(r)); } // Set - icon file path @@ -638,11 +631,25 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing, // Set - sound file path if (pSoundPath.get()) { - r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_USER_DATA, pSoundPath.get())); + if (isOngoing && needUpdate) + { + r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_NONE, NULL)); + } + else + { + r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_USER_DATA, pSoundPath.get())); + } } else { - r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL)); + if (isOngoing && needUpdate) + { + r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_NONE, NULL)); + } + else + { + r = ConvertNotificationResult(notification_set_sound(notiHandle, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL)); + } } SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Notification Set sound failed.", GetErrorMessage(r)); @@ -794,7 +801,7 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing, pBundle = arg.GetBundle(); service_create_request(pBundle, &hSvc); - SysTryCatch(NID_SHELL, hSvc != null, r = E_SYSTEM, r, "[%s] A system error has been occurred. service_create_request failed.", GetErrorMessage(E_SYSTEM)); + SysTryCatch(NID_SHELL, hSvc != null, r = E_OPERATION_FAILED, r, "[E_OPERATION_FAILED] A system error has been occurred. service_create_request failed."); if (notifyType == NOTIFY_TYPE_SIMPLE || notifyType == NOTIFY_TYPE_APP_ID) { @@ -803,9 +810,10 @@ _NotificationManagerImpl::NotifyMessage(_NotifyType notifyType, bool isOngoing, else if (notifyType == NOTIFY_TYPE_APP_CONTROL) { - std::unique_ptr pOperationIdChar(_StringConverter::CopyToCharArrayN(*pOperationId)); - service_set_operation(hSvc, pOperationIdChar.get()); + int retVal = service_set_operation(hSvc, pOperationIdChar.get()); + SysTryCatch(NID_SHELL, retVal == SERVICE_ERROR_NONE, r = E_OPERATION_FAILED, r, "[E_OPERATION_FAILED] A system error has been occurred. service_create_request failed."); + if (pUriData) { std::unique_ptr pUri(_StringConverter::CopyToCharArrayN(*pUriData)); @@ -994,21 +1002,7 @@ _NotificationManagerImpl::RemoveNotification(bool onGoing) SysLog(NID_SHELL, "All [%s] notification deleted.", onGoing ? "Ongoing" : "Normal"); } - switch (err) - { - case NOTIFICATION_ERROR_NONE: - r = E_SUCCESS; - break; - - case NOTIFICATION_ERROR_INVALID_DATA: - r = E_INVALID_ARG; - break; - - default: - r = E_SYSTEM; - break; - } - + SysTryReturnResult(NID_SHELL, err == NOTIFICATION_ERROR_NONE, E_OPERATION_FAILED, "Failed to RemoveNotification with reason (%d).", err); return r; } @@ -1044,21 +1038,7 @@ _NotificationManagerImpl::RemoveNotificationByAppId(const Tizen::App::AppId& app SysLog(NID_SHELL, "All [%s] notification deleted.", onGoing ? "Ongoing" : "Normal"); } - switch (err) - { - case NOTIFICATION_ERROR_NONE: - r = E_SUCCESS; - break; - - case NOTIFICATION_ERROR_INVALID_DATA: - r = E_INVALID_ARG; - break; - - default: - r = E_SYSTEM; - break; - } - + SysTryReturnResult(NID_SHELL, err == NOTIFICATION_ERROR_NONE, E_OPERATION_FAILED, "Failed to RemoveNotificationByAppId with reason (%d).", err); return r; } @@ -1114,7 +1094,7 @@ result _NotificationManagerImpl::AddBadgeEventListener(IBadgeEventListener& listener) { SysTryReturnResult(NID_SHELL, !__badgeEventListenerList.Contains(&listener), E_OBJ_ALREADY_EXIST, "The listener is already added."); - SysLog(NID_SHELL, "(%x)", &listener); + SysLog(NID_SHELL, "AddBadgeEventListener (%x)", &listener); result r = _BadgeManagerImpl::GetInstance()->AddPrimaryBadgeEventListener(*this); SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to AddPrimaryBadgeEventListener with reason (%s)", GetErrorMessage(r) ); @@ -1125,7 +1105,7 @@ _NotificationManagerImpl::AddBadgeEventListener(IBadgeEventListener& listener) result _NotificationManagerImpl::RemoveBadgeEventListener(IBadgeEventListener& listener) { - SysLog(NID_SHELL, "(%x)", &listener); + SysLog(NID_SHELL, "RemoveBadgeEventListener (%x)", &listener); result r = __badgeEventListenerList.Remove(&listener); SysTryReturn(NID_SHELL, !IsFailed(r), r, r, "Failed to RemoveBadgeEventListener with reason (%s)", GetErrorMessage(r) ); diff --git a/src/core/FShell_NotificationRequestImpl.cpp b/src/core/FShell_NotificationRequestImpl.cpp index bfc3193..42898dd 100644 --- a/src/core/FShell_NotificationRequestImpl.cpp +++ b/src/core/FShell_NotificationRequestImpl.cpp @@ -262,7 +262,7 @@ result _NotificationRequestImpl::SetAlertText(const String& alertText) { SysTryReturnResult(NID_SHELL, alertText.GetLength() > 0 && alertText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, - "AlertText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); + "alertText is less than 1 or alertText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); __alertText = alertText; return E_SUCCESS; @@ -278,8 +278,8 @@ _NotificationRequestImpl::GetAppMessage() const result _NotificationRequestImpl::SetAppMessage(const String& appMessage) { - SysTryReturnResult(NID_SHELL, appMessage.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, - "AppMessage is greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); + SysTryReturnResult(NID_SHELL, appMessage.GetLength() > 0 && appMessage.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, + "appMessage is less than 1 or appMessage is greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); SysTryReturnResult(NID_SHELL, __appBinding, E_INVALID_OPERATION, "The Notification instance is not bound to Application"); @@ -296,8 +296,9 @@ _NotificationRequestImpl::GetTitleText() const result _NotificationRequestImpl::SetTitleText(const String& titleText) { - SysTryReturnResult(NID_SHELL, titleText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, - "TitleText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); + SysTryReturnResult(NID_SHELL, titleText.GetLength() > 0 && titleText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, + "titleText is less than 1 or titleText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); + __titleText = titleText; return E_SUCCESS; } @@ -382,7 +383,7 @@ _NotificationRequestImpl::SetOngoingActivityProgress(int progressValue) // use int type instead of OngoingActivityType to evade weired gcc optimization int activitytype = static_cast(GetOngoingActivityType()); - SysTryReturnResult(NID_SHELL, activitytype >= ONGOING_ACTIVITY_TYPE_TEXT && activitytype <= ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE, + SysTryReturnResult(NID_SHELL, activitytype > ONGOING_ACTIVITY_TYPE_TEXT && activitytype <= ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE, E_INVALID_OPERATION,"Invalid activity Type %d.", activitytype); if (activitytype == ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE) @@ -514,8 +515,8 @@ _NotificationRequestImpl::GetNotificationCountText(void) const result _NotificationRequestImpl::SetNotificationCountText(const Tizen::Base::String& notificationCountText) { - SysTryReturnResult(NID_SHELL, notificationCountText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, - "Invalid argument is used. CountText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); + SysTryReturnResult(NID_SHELL, notificationCountText.GetLength() > 0 && notificationCountText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG, + "notificationCountText is less than 1 or notificationCountText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH."); __notificationCountText = notificationCountText; return E_SUCCESS; }