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 FShellNotificationManager.h
20 * @brief This is the header file for the %NotificationManager class.
22 * This header file contains the declarations of the %NotificationManager class.
25 #ifndef _FSHELL_NOTIFICATION_MANAGER_H_
26 #define _FSHELL_NOTIFICATION_MANAGER_H_
29 #include <FAppTypes.h>
31 namespace Tizen { namespace Base
39 namespace Tizen { namespace Shell
42 class NotificationRequest;
43 class IBadgeEventListener;
46 * The maximum length of a notification message.
50 static const int MAX_NOTIFICATION_MESSAGE_LENGTH = 1024;
53 * The maximum length of the launch arguments for a notification in bytes.
57 static const int MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH = 1024;
60 * The maximum length of a notification badge number.
64 static const int MAX_NOTIFICATION_BADGE_NUMBER = 999;
67 * The maximum length of a title text.
71 static const int MAX_NOTIFICATION_TITLE_LENGTH = 1024;
74 * @enum OngoingActivityType
76 * Defines the notification type for an ongoing activity.
80 enum OngoingActivityType
82 ONGOING_ACTIVITY_TYPE_TEXT = 1, /**< The progress is indicated with a text */
83 ONGOING_ACTIVITY_TYPE_PROGRESS_BYTE, /**< The progress is indicated with the number of bytes */
84 ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE /**< The progress is indicated with percentage */
88 * @enum NotificationStyle
90 * Defines the notification style.
94 enum NotificationStyle
96 NOTIFICATION_STYLE_NORMAL = 1, /**< The notification is normal style */
97 NOTIFICATION_STYLE_THUMBNAIL /**< The notification is thumbnail style */
102 * @class NotificationManager
103 * @brief This class provides methods to alert the user about a notification.
107 * @final This class is not intended for extension.
109 * The %NotificationManager class provides methods to alert the user about notifications.
111 * For more information about the class features, see <a href="../org.tizen.native.appprogramming/html/guide/shell/notifications.htm">Notifications</a>.
113 * The following example demonstrates how to use the %NotificationManager class.
117 * MyClass::NotificationSample(void)
120 * NotificationManager notiMgr;
121 * notiMgr.Construct();
122 * badgeNumber = notiMgr.GetBadgeNumber();
124 * notiMgr.Notify(L"A new message has arrived.", badgeNumber);
129 class _OSP_EXPORT_ NotificationManager
130 : public Tizen::Base::Object
135 * This is the default constructor for this class.
139 NotificationManager(void);
142 * This destructor overrides Tizen::Base::Object::~Object().
146 virtual ~NotificationManager(void);
149 * Initializes this instance of %NotificationManager.
153 * @return An error code
154 * @exception E_SUCCESS The method is successful.
156 result Construct(void);
159 * Gets the current badge number of an application icon.
163 * @privilege %http://tizen.org/privilege/notification
165 * @return The current badge number if the method is successful, @n
166 * else @c -1 if the method fails
167 * @exception E_SUCCESS The method is successful.
168 * @exception E_OPERATION_FAILED The operation has failed.
169 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
170 * @remarks The specific error code can be accessed using the GetLastResult() method.
173 int GetBadgeNumber(void);
176 * Notifies the user who has @c badgeNumber as a badge number.
180 * @privilege %http://tizen.org/privilege/notification
182 * @return An error code
183 * @param[in] badgeNumber The badge number
184 * @exception E_SUCCESS The method is successful.
185 * @exception E_INVALID_ARG The specified input parameter is invalid, or
186 * the specified @c badgeNumber is less than @c 0.
187 * @exception E_OPERATION_FAILED The operation has failed.
188 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
190 result Notify(int badgeNumber);
193 * Notifies the user with a message.
197 * @privilege %http://tizen.org/privilege/notification
199 * @return An error code
200 * @param[in] messageText The notification message
201 * @exception E_SUCCESS The method is successful.
202 * @exception E_INVALID_ARG The specified input parameter is invalid, or
203 * the length of @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH.
204 * @exception E_OPERATION_FAILED The operation has failed.
205 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
207 result Notify(const Tizen::Base::String& messageText);
210 * Notifies the user who has @c badgeNumber as badge number with a message.
214 * @privilege %http://tizen.org/privilege/notification
216 * @return An error code
217 * @param[in] messageText The notification message
218 * @param[in] badgeNumber The badge number
219 * @exception E_SUCCESS The method is successful.
220 * @exception E_INVALID_ARG The specified @c badgeNumber is less than @c 0, or
221 * the length of @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH.
222 * @exception E_OPERATION_FAILED The operation has failed.
223 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
225 result Notify(const Tizen::Base::String& messageText, int badgeNumber);
228 * Notifies the user who has @c badgeNumber as badge number with a message. @n
229 * If the user selects this message, @c launchArguments is delivered to the application. @n
230 * @c launchArguments is delivered as the value of the http://tizen.org/appcontrol/data/notification key
231 * for IAppControlProviderEventListener::OnAppControlRequestReceived().
235 * @privilege %http://tizen.org/privilege/notification
237 * @return An error code
238 * @param[in] messageText The notification message
239 * @param[in] badgeNumber The badge number
240 * @param[in] launchArguments The message for the application
241 * @exception E_SUCCESS The method is successful.
242 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
243 * - A specified input parameter is invalid. @n
244 * - The specified @c badgeNumber is less than @c 0. @n
245 * - The length of the specified @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. @n
246 * - The length of the specified @c launchArguments is greater than Shell::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.
247 * @exception E_OPERATION_FAILED The operation has failed.
248 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
250 result Notify(const Tizen::Base::String& messageText, int badgeNumber, const Tizen::Base::String& launchArguments);
253 * Notifies the user with a request message. @n
254 * The notification request may have various pieces of information such as alert text, title text, launch arguments, and so on.
258 * @privilege %http://tizen.org/privilege/notification
260 * @return An error code
261 * @param[in] request The notification request
262 * @exception E_SUCCESS The method is successful.
263 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
264 * - The specified @c request does not have valid badge number value in @c request. @n
265 * - The specified @c request does not have alert text in @c request. @n
266 * - The specified @c request has invalid icon file path in @c request.
267 * @exception E_OPERATION_FAILED The operation has failed.
268 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
270 result Notify(const NotificationRequest& request);
273 * The user who is identified with the @c appId is notified with a request message. @n
274 * The request may have various pieces of information such as alert text, title text, launch arguments, and so on.
279 * @privilege %http://tizen.org/privilege/notification
281 * @return An error code
282 * @param[in] appId The application ID
283 * @param[in] request The notification request
284 * @exception E_SUCCESS The method is successful.
285 * @exception E_APP_NOT_INSTALLED The application is not installed.
286 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
287 * - The specified @c request does not have valid badge number value in @c request. @n
288 * - The specified @c request does not have alert text in @c request. @n
289 * - The specified @c request has invalid icon file path in @c request.
290 * @exception E_OPERATION_FAILED The operation has failed.
291 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
293 result NotifyByAppId(const Tizen::App::AppId& appId, const NotificationRequest& request);
296 * Removes the notification message.
300 * @privilege %http://tizen.org/privilege/notification
302 * @return An error code
303 * @exception E_SUCCESS The method is successful.
304 * @exception E_OPERATION_FAILED The operation has failed.
305 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
306 * @remarks This method returns @c E_SUCCESS when there is no outstanding notification.
308 result RemoveNotification(void);
311 * Removes the notification message on behalf of the specified application.
316 * @privilege %http://tizen.org/privilege/notification
318 * @return An error code
319 * @param[in] appId The application ID
320 * @exception E_SUCCESS The method is successful.
321 * @exception E_APP_NOT_INSTALLED The application is not installed.
322 * @exception E_OPERATION_FAILED The operation has failed.
323 * @exception E_PRIVILEGE_DENIED The application did not have the privilege to call this method.
324 * @remarks Although there is no outstanding notification for the calling application, this method returns @c E_SUCCESS.
326 result RemoveNotificationByAppId(const Tizen::App::AppId& appId);
329 * Notifies the user about the ongoing activity using a message.
333 * @privilege %http://tizen.org/privilege/notification
335 * @return An error code
336 * @param[in] messageText The notification message
337 * @exception E_SUCCESS The method is successful.
338 * @exception E_INVALID_ARG The specified input parameter is invalid, or
339 * the length of @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH.
340 * @exception E_OPERATION_FAILED The operation has failed.
341 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
343 result NotifyOngoingActivity(const Tizen::Base::String& messageText);
346 * Notifies the user about the ongoing activity using a message. @n
347 * If the user selects the message, @c launchArguments is delivered to the application. @n
348 * @c launchArguments is delivered as the value of the http://tizen.org/appcontrol/data/notification key
349 * for IAppControlProviderEventListener::OnAppControlRequestReceived().
353 * @privilege %http://tizen.org/privilege/notification
355 * @return An error code
356 * @param[in] messageText The notification message
357 * @param[in] launchArguments The launch arguments for the application
358 * @exception E_SUCCESS The method is successful.
359 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
360 * - A specified input parameter is invalid. @n
361 * - The length of the specified @c messageText is greater than Shell::MAX_NOTIFICATION_MESSAGE_LENGTH. @n
362 * - The length of the specified @c launchArguments is greater than Shell::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.
363 * @exception E_OPERATION_FAILED The operation has failed.
364 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
366 result NotifyOngoingActivity(const Tizen::Base::String& messageText, const Tizen::Base::String& launchArguments);
369 * Notifies the user about the ongoing activity using a request message. @n
370 * The request may have various pieces of information such as alert text, title text, launch arguments, and so on.
374 * @privilege %http://tizen.org/privilege/notification
376 * @return An error code
377 * @param[in] request The notification request
378 * @exception E_SUCCESS The method is successful.
379 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
380 * - The specified @c request does not have either alert text or progress value in @c request. @n
381 * - The specified @c request has invalid icon file path in @c request.
382 * @exception E_OPERATION_FAILED The operation has failed.
383 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
385 result NotifyOngoingActivity(const NotificationRequest& request);
388 * Notifies the user about the ongoing activity using a request message. @n
389 * The request may have various information like alert text, title text, launch arguments, and so on.
394 * @privilege %http://tizen.org/privilege/notification
396 * @return An error code
397 * @param[in] appId The application ID
398 * @param[in] request The notification request
399 * @exception E_SUCCESS The method is successful.
400 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
401 * - The specified @c request does not have either alert text or progress value in @c request. @n
402 * - The specified @c request has invalid icon file path in @c request.
403 * @exception E_APP_NOT_INSTALLED The application is not installed.
404 * @exception E_OPERATION_FAILED The operation has failed.
405 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
407 result NotifyOngoingActivityByAppId(const Tizen::App::AppId& appId, const NotificationRequest& request);
410 * Removes the notification message for the ongoing activity.
414 * @privilege %http://tizen.org/privilege/notification
416 * @return An error code
417 * @exception E_SUCCESS The method is successful.
418 * @exception E_OPERATION_FAILED The operation has failed.
419 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
420 * @remarks This method returns @c E_SUCCESS when there is no outstanding notification.
422 result RemoveOngoingActivityNotification(void);
425 * Removes the notification message for ongoing activity on behalf of the specified application.
430 * @privilege %http://tizen.org/privilege/notification
432 * @return An error code
433 * @param[in] appId The application ID
434 * @exception E_SUCCESS The method is successful.
435 * @exception E_APP_NOT_INSTALLED The application is not installed.
436 * @exception E_OPERATION_FAILED The operation has failed.
437 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
438 * @remarks Although there is no outstanding notification for the calling application, this method returns @c E_SUCCESS.
440 result RemoveOngoingActivityNotificationByAppId(const Tizen::App::AppId& appId);
443 * Gets the badge number of the application icon mentioned in the @c appId.
447 * @privilege %http://tizen.org/privilege/notification
449 * @return The current badge number if the method is successful, @n
450 else @c -1 if the method fails
451 * @param[in] appId The application ID
452 * @exception E_SUCCESS The method is successful.
453 * @exception E_OPERATION_FAILED The operation has failed.
454 * @exception E_APP_NOT_INSTALLED The application is not installed.
455 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
456 * @remarks The specific error code can be accessed using the GetLastResult() method. @n
459 int GetBadgeNumberByAppId(const Tizen::App::AppId& appId);
462 * Notifies the user with a message. It will disappear in a few seconds.
466 * @privilege %http://tizen.org/privilege/notification
468 * @return An error code
469 * @param[in] messageText The notification message
470 * @exception E_SUCCESS The method is successful.
471 * @exception E_INVALID_ARG The specified input parameter is invalid.
472 * @exception E_OPERATION_FAILED The operation has failed.
473 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
474 * @remarks Message is displayed in the status bar.
476 result NotifyTextMessage(const Tizen::Base::String& messageText);
479 * Notifies the user using a request message and try implicit AppControl resolution when the user selects the message on the notification area. @n
480 * The request may have various information like alert text, title text, launch arguments, and so on.
484 * @privilege %http://tizen.org/privilege/notification
486 * @return An error code
487 * @param[in] operationId The operation ID
488 * @param[in] pUriData A pointer to the URI data
489 * @param[in] pDataType A pointer to the MIME type (RFC 2046) data
490 * @param[in] pExtraData A pointer to an argument map of key and value pair where the key is of type Tizen::Base::String and the value is of type Tizen::Base::String to deliver to the resolved application @n
491 * The maximum size is 16 kilo bytes.
492 * @param[in] request The notification request
493 * @exception E_SUCCESS The method is successful.
494 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
495 * - The specified @c request does not have valid badge number value in @c request. @n
496 * - The specified @c request does not have alert text in @c request. @n
497 * - The specified @c request has invalid icon file path in @c request.
498 * @exception E_OPERATION_FAILED The operation has failed.
499 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
500 * @remarks For more information on the implicit AppControl resolution, see <a href="../org.tizen.native.appprogramming/html/guide/app/resolving_appcontrols.htm">Resolving AppControls</a>.
503 result NotifyByAppControl(const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pDataType,
504 const Tizen::Base::Collection::IMap* pExtraData, const NotificationRequest& request);
507 * Notifies the user about the ongoing activity using a request message and try implicit AppControl resolution when the user selects the message on the notification area. @n
508 * The request may have various information like alert text, title text, launch arguments, and so on.
512 * @privilege %http://tizen.org/privilege/notification
514 * @return An error code
515 * @param[in] operationId The operation ID
516 * @param[in] pUriData A pointer to the URI data
517 * @param[in] pDataType A pointer to the MIME type (RFC 2046) data
518 * @param[in] pExtraData A pointer to an argument map of key and value pair where the key is of type Tizen::Base::String and the value is of type Tizen::Base::String to deliver to the resolved application @n
519 * The maximum size is 16 kilo bytes.
520 * @param[in] request The notification request
521 * @exception E_SUCCESS The method is successful.
522 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
523 * - The specified @c request does not have either alert text or progress value in @c request. @n
524 * - The specified @c request has invalid icon file path in @c request.
525 * @exception E_OPERATION_FAILED The operation has failed.
526 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
527 * @remarks For more information on the implicit AppControl resolution, see <a href="../org.tizen.native.appprogramming/html/guide/app/resolving_appcontrols.htm">Resolving AppControls</a>.
529 result NotifyOngoingActivityByAppControl(const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pDataType,
530 const Tizen::Base::Collection::IMap* pExtraData, const NotificationRequest& request);
533 * Adds an IBadgeEventListener event listener to the NotificationManager @n
534 * The listener gets notified when a badge number is updated. @n
538 * @return An error code
539 * @param[in] listener The listener to be added.
540 * @exception E_SUCCESS The method is successful.
541 * @exception E_OBJ_ALREADY_EXIST The listener is already added.
542 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
544 * @see NotificationManager::Notify()
545 * @remarks Internally Platform does not have the ownership of this pointer, So caller should manage the listener object properly.
547 result AddBadgeEventListener(IBadgeEventListener& listener);
550 * Removes an IBadgeEventListener event listener from the NotificationManager @n
554 * @return An error code
555 * @param[in] listener The listener to be removed.
556 * @exception E_SUCCESS The method is successful.
557 * @exception E_OBJ_NOT_FOUND The listner is not found.
558 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
560 * @remarks Internally Platform does not have the ownership of this pointer, So caller should manage the listener object properly.
562 result RemoveBadgeEventListener(IBadgeEventListener& listener);
566 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
570 NotificationManager(const NotificationManager& rhs);
573 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
577 NotificationManager& operator =(const NotificationManager& rhs);
580 class _NotificationManagerImpl * __pNotificationManagerImpl;
582 friend class _NotificationManagerImpl;
583 }; // NotificationManager
587 #endif // _FSHELL_NOTIFICATION_MANAGER_H_