From 4c913c68477ff885caf30ef1b849ab6b18f4069f Mon Sep 17 00:00:00 2001 From: Young Ik Cho Date: Thu, 31 Jan 2013 20:33:25 +0900 Subject: [PATCH] add internal text noti function Change-Id: I21dedcf9f7fb587b1a746905f3482135965adda0 Signed-off-by: Young Ik Cho --- inc/FShellNotificationManager.h | 16 ++++++++ src/core/FShellNotificationManager.cpp | 12 ++++++ src/core/FShell_NotificationManagerImpl.cpp | 32 ++++++++++++++- src/inc/FShell_NotificationManagerImpl.h | 63 +++++++---------------------- 4 files changed, 73 insertions(+), 50 deletions(-) diff --git a/inc/FShellNotificationManager.h b/inc/FShellNotificationManager.h index b07a4a3..e6a94ee 100644 --- a/inc/FShellNotificationManager.h +++ b/inc/FShellNotificationManager.h @@ -448,6 +448,22 @@ public: */ int GetBadgeNumberByAppId(const Tizen::App::AppId& appId); + /* + * Notifies the user with a message. + * + * @since 2.1 + * @privlevel user + * @privilege http://tizen.org/privilege/notification + * + * @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_OPERATION_FAILED The operation has failed. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + */ + result NotifyTextMessage(const Tizen::Base::String& messageText); + private: /** * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. diff --git a/src/core/FShellNotificationManager.cpp b/src/core/FShellNotificationManager.cpp index 590584b..ee7a1bc 100644 --- a/src/core/FShellNotificationManager.cpp +++ b/src/core/FShellNotificationManager.cpp @@ -236,5 +236,17 @@ NotificationManager::RemoveNotificationByAppId(const AppId& appId) return __pNotificationManagerImpl->RemoveNotificationByAppId(appId); } + +result +NotificationManager::NotifyTextMessage(const String& messageText) +{ + SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION); + SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method."); + + return __pNotificationManagerImpl->NotifyTextMessage(messageText); +} + }; }; // Tizen::Shell diff --git a/src/core/FShell_NotificationManagerImpl.cpp b/src/core/FShell_NotificationManagerImpl.cpp index 14b9503..bd718c5 100644 --- a/src/core/FShell_NotificationManagerImpl.cpp +++ b/src/core/FShell_NotificationManagerImpl.cpp @@ -751,5 +751,33 @@ _NotificationManagerImpl::RemoveNotificationByAppId(const AppId& appId) return __pNotificationManager->RemoveNotification(appId,false); } -}; -}; // Tizen::Shell +result +_NotificationManagerImpl::NotifyTextMessage(const String& messageText) const +{ + SysTryReturnResult(NID_APP, !messageText.IsEmpty(), E_INVALID_ARG, "MessageText is less than 0."); + + std::unique_ptr pMsg(_StringConverter::CopyToCharArrayN(messageText)); + int res = notification_status_message_post(pMsg.get()); + + result r = E_SUCCESS; + switch (res) + { + case NOTIFICATION_ERROR_NONE: + // success + break; + case NOTIFICATION_ERROR_INVALID_DATA: + r = E_INVALID_ARG; + break; + case NOTIFICATION_ERROR_IO: + r = E_SYSTEM; + break; + default: + r = E_SYSTEM; + break; + } + + SysLog(NID_APP, "[%s] %ls posted.", GetErrorMessage(r), messageText.GetPointer()); + return r; +} + +}} // Tizen::Shell diff --git a/src/inc/FShell_NotificationManagerImpl.h b/src/inc/FShell_NotificationManagerImpl.h index d012725..d1ed7cc 100644 --- a/src/inc/FShell_NotificationManagerImpl.h +++ b/src/inc/FShell_NotificationManagerImpl.h @@ -39,34 +39,26 @@ class _OSP_EXPORT_ _NotificationManagerImpl public: /** * This is the default constructor for this class. - * - * @since 1.0 */ _NotificationManagerImpl(void); /** * This is the destructor for this class. - * - * @since 1.0 */ virtual ~_NotificationManagerImpl(void); /** * Initializes this instance of %_NotificationManagerImpl. * - * @since 1.0 * @return An error code * @exception E_SUCCESS The method is successful. * @exception E_SYSTEM A system error has occurred. - * @exception E_OUT_OF_MEMORY The memory is insufficient. */ result Construct(void); /** * Gets the badge number of the application icon. * - * @since 1.0 - * * @return The current badge number * @exception E_SUCCESS The method is successful. * @exception E_SYSTEM A system error has occurred. @@ -81,8 +73,6 @@ public: /** * Notifies the user using a badge number. * - * @since 1.0 - * * @return An error code * @param[in] badgeNumber The badge number * @exception E_SUCCESS The method is successful. @@ -98,8 +88,6 @@ public: /** * Notifies the user using a message. * - * @since 1.0 - * * @return An error code * @param[in] messageText The notification message * @exception E_SUCCESS The method is successful. @@ -115,8 +103,6 @@ public: /** * Notifies the user using a message and badge number. * - * @since 1.0 - * * @return An error code * @param[in] messageText The notification message * @param[in] badgeNumber The badge number @@ -136,8 +122,6 @@ public: * @c launchArguments is specified as input parameter for Application::OnUserEventReceivedN() or can be obtained by * invoking Application::GetAppArgumentListN(), especially within Application::OnAppInitializing(). * - * @since 1.0 - * * @return An error code * @param[in] messageText The notification message * @param[in] badgeNumber The badge number @@ -160,8 +144,6 @@ public: * Notifies the user using a message. @n * The message may have various information like alert text, title text, launch arguments, and so on. * - * @since 2.1 - * * @return An error code * @param[in] message The notification message * @param[in] isOngoing Ongoing Notification @@ -178,8 +160,6 @@ public: * Notifies the user using a message. @n * The message may have various information like alert text, title text, launch arguments, and so on. * - * @since 2.1 - * * @return An error code * @param[in] appId The Application ID * @param[in] message The notification message @@ -194,8 +174,6 @@ public: /** * Removes the notification message. * - * @since 2.0 - * * @return An error code * @exception E_SUCCESS The method was successful. * @exception E_SYSTEM A system error occurred. @@ -208,8 +186,6 @@ public: /** * Notifies the user about the ongoing activity using a message. * - * @since 2.0 - * * @return An error code * @param[in] messageText The notification message * @exception E_SUCCESS The method is successful. @@ -227,8 +203,6 @@ public: * @c launchArguments is specified as input parameter for Application::OnUserEventReceivedN() or can be obtained by * invoking Application::GetAppArgumentListN(), especially within Application::OnAppInitializing(). * - * @since 2.0 - * * @return An error code * @param[in] messageText The notification message * @param[in] launchArguments The launch arguments for the application @@ -248,8 +222,6 @@ public: /** * Removes the notification message for the ongoing activity. * - * @since 2.0 - * * @return An error code * @exception E_SUCCESS The method is successful. * @exception E_SYSTEM A system error has occurred. @@ -262,8 +234,6 @@ public: /** * Gets the badge number of the application icon. * - * @since 1.0 - * * @return The current badge number * @param[in] appId The application ID * @exception E_SUCCESS The method is successful. @@ -279,8 +249,6 @@ public: /** * Notifies the user using a badge number on behalf of the specified application. * - * @since 1.0 - * * @return An error code * @param[in] appId The application ID * @param[in] badgeNumber The badge number @@ -298,8 +266,6 @@ public: /** * Notifies the user using a message on behalf of the specified application. * - * @since 1.0 - * * @return An error code * @param[in] appId The application ID * @param[in] messageText The notification message @@ -317,8 +283,6 @@ public: /** * Notifies the user using a message and badge number on behalf of the specified application. * - * @since 1.0 - * * @return An error code * @param[in] appId The application ID * @param[in] messageText The notification message @@ -340,8 +304,6 @@ public: * Notifies the user using a message and badge number on behalf of the specified application. @n * If the user checks the message, the @c launchArguments is delivered to the application. * - * @since 2.0 - * * @return An error code * @param[in] appId The application ID * @param[in] messageText The notification message @@ -363,8 +325,6 @@ public: * Notifies the user using a message and badge number on behalf of the specified application. @n * If the user checks the message, the @c launchArguments is delivered to the application. * - * @since 2.0 - * * @return An error code * @param[in] appId The application ID * @param[in] messageText The notification message @@ -387,8 +347,6 @@ public: /** * Notifies the user about the ongoing activity using a message on behalf of the specified application. * - * @since 2.0 - * * @return An error code * @param[in] appId The application ID * @param[in] messageText The notification message @@ -406,8 +364,6 @@ public: /** * Notifies the user about the ongoing activity using a message on behalf of the specified application. * - * @since 2.0 - * * @return An error code * @param[in] appId The application ID * @param[in] messageText The notification message @@ -428,8 +384,6 @@ public: /** * Removes the notification message for ongoing activity on behalf of the specified application. * - * @since 2.0 - * * @return An error code * @param[in] appId The application ID * @exception E_SUCCESS The method is successful. @@ -444,8 +398,6 @@ public: /** * Removes the notification message on behalf of the specified application. * - * @since 2.0 - * * @return An error code * @param[in] appId The application ID * @exception E_SUCCESS The method was successful. @@ -457,6 +409,21 @@ public: */ result RemoveNotificationByAppId(const Tizen::App::AppId& appId); + /** + * Notifies the user using a message. + * + * @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_SYSTEM A system error has occurred. + * @exception E_INVALID_OPERATION The type of application calling this method is invalid as per the Tizen platform policy. + * @exception E_INVALID_STATE This instance is in an invalid state. @n + * The Construct() method is not called. + */ + result NotifyTextMessage(const Tizen::Base::String& messageText) const; + static const _NotificationManagerImpl* GetInstance(const NotificationManager& notiMgr); static _NotificationManagerImpl* GetInstance(NotificationManager& notiMgr); -- 2.7.4