77868e87d2c635c69b338d800d8e8901d352ccb1
[platform/framework/native/appfw.git] / src / app / FApp_NotificationManagerImpl.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        FApp_NotificationManagerImpl.h
19  * @brief       This is the header file for the %_NotificationManagerImpl class.
20  */
21
22 #ifndef _FAPP_INTERNAL_NOTIFICATION_MANAGER_IMPL_H_
23 #define _FAPP_INTERNAL_NOTIFICATION_MANAGER_IMPL_H_
24
25 #include <notification/notification_type.h>
26
27 #include <FBaseObject.h>
28 #include <FAppTypes.h>
29 #include <FOspConfig.h>
30
31 namespace Tizen { namespace App
32 {
33
34 class NotificationManager;
35
36 class _NotificationManagerImpl
37 {
38
39 public:
40         /**
41          * This is the default constructor for this class.
42          *
43          * @since               1.0
44          */
45         _NotificationManagerImpl(void);
46
47         /**
48          * This is the destructor for this class.
49          *
50          * @since               1.0
51          */
52         virtual ~_NotificationManagerImpl(void);
53
54         /**
55          * Initializes this instance of %_NotificationManagerImpl.
56          *
57          * @since                       1.0
58          * @return              An error code
59          * @exception   E_SUCCESS               The method is successful.
60          * @exception   E_SYSTEM                A system error has occurred.
61          * @exception   E_OUT_OF_MEMORY The memory is insufficient.
62          */
63         result Construct(void);
64
65         /**
66          * Gets the badge number of the application icon.
67          *
68          * @since                               1.0
69          *
70          * @return              The current badge number
71          * @exception   E_SUCCESS                       The method is successful.
72          * @exception   E_SYSTEM                        A system error has occurred.
73          * @exception   E_OBJ_NOT_FOUND     The application is not installed.
74          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
75          *                                  The Construct() method is not called.
76          * @remarks The specific error code can be accessed using the GetLastResult() method. @n
77          *          In case of failure, this method returns @c -1.
78          */
79         int GetBadgeNumber(void) const;
80
81         /**
82          * Notifies the user using a badge number.
83          *
84          * @since                               1.0
85          *
86          * @return              An error code
87          * @param[in]   badgeNumber                     The badge number
88          * @exception   E_SUCCESS                       The method is successful.
89          * @exception   E_INVALID_ARG           The specified input parameter is invalid, or
90          *                                  the specified @c badgeNumber is less than @c 0.
91          * @exception   E_SYSTEM                        A system error has occurred.
92          * @exception   E_INVALID_OPERATION     The type of application calling this method is invalid as per the Tizen platform policy.
93          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
94          *                                  The Construct() method is not called.
95          */
96         result Notify(int badgeNumber) const;
97
98         /**
99          * Notifies the user using a message.
100          *
101          * @since                               1.0
102          *
103          * @return              An error code
104          * @param[in]   messageText                     The notification message
105          * @exception   E_SUCCESS                       The method is successful.
106          * @exception   E_INVALID_ARG           The specified input parameter is invalid, or
107          *                                                                      the length of @c messageText is greater than App::MAX_NOTIFICATION_MESSAGE_LENGTH.
108          * @exception   E_SYSTEM                        A system error has occurred.
109          * @exception   E_INVALID_OPERATION     The type of application calling this method is invalid as per the Tizen platform policy.
110          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
111          *                                  The Construct() method is not called.
112          */
113         result Notify(const Tizen::Base::String& messageText) const;
114
115         /**
116          * Notifies the user using a message and badge number.
117          *
118          * @since                               1.0
119          *
120          * @return              An error code
121          * @param[in]   messageText                     The notification message
122          * @param[in]   badgeNumber                     The badge number
123          * @exception   E_SUCCESS                       The method is successful.
124          * @exception   E_INVALID_ARG           The specified @c badgeNumber is less than @c 0, or
125          *                                                                      the length of @c messageText is greater than App::MAX_NOTIFICATION_MESSAGE_LENGTH.
126          * @exception   E_SYSTEM                        A system error has occurred.
127          * @exception   E_INVALID_OPERATION     The type of application calling this method is invalid as per the Tizen platform policy.
128          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
129          *                                  The Construct() method is not called.
130          */
131         result Notify(const Tizen::Base::String& messageText, int badgeNumber) const;
132
133         /**
134          * Notifies the user using a message and badge number. @n
135          * If the user checks the message, @c launchArguments is delivered to the application. @n
136          * @c launchArguments is specified as input parameter for Application::OnUserEventReceivedN() or can be obtained by
137          * invoking Application::GetAppArgumentListN(), especially within Application::OnAppInitializing().
138          *
139          * @since                               1.0
140          *
141          * @return              An error code
142          * @param[in]   messageText                     The notification message
143          * @param[in]   badgeNumber                     The badge number
144          * @param[in]   launchArguments         The message for application
145          * @exception   E_SUCCESS                       The method is successful.
146          * @exception   E_INVALID_ARG           Either of the following conditions has occurred: @n
147          *                                                                      - A specified input parameter is invalid. @n
148          *                                                                      - The specified @c badgeNumber is less than @c 0. @n
149          *                                                                      - The length of the specified @c messageText is greater than App::MAX_NOTIFICATION_MESSAGE_LENGTH. @n
150          *                                                                      - The length of the specified @c launchArguments is greater than App::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.
151          * @exception   E_SYSTEM                        A system error has occurred.
152          * @exception   E_INVALID_OPERATION     The type of application calling this method is invalid as per the Tizen platform policy.
153          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
154          *                                                                              The Construct() method is not called.
155          * @see                 Application::OnUserEventReceivedN(), Application::GetAppArgumentListN()
156          */
157         result Notify(const Tizen::Base::String& messageText, int badgeNumber, const Tizen::Base::String& launchArguments) const;
158
159         /**
160          * Removes the notification message.
161          *
162          * @since                       2.0
163          *
164          * @return              An error code
165          * @exception   E_SUCCESS                       The method was successful.
166          * @exception   E_SYSTEM                        A system error occurred.
167          * @exception   E_INVALID_STATE         This instance is in an invalid state: @n
168          *                                  - The Construct() method is not called. @n
169          * @remarks      The method returns E_SUCCESS when there is no outstanding notification.
170          */
171         result RemoveNotification(void);
172
173         /**
174          * Notifies the user about the ongoing activity using a message.
175          *
176          * @since                               2.0
177          *
178          * @return              An error code
179          * @param[in]   messageText                     The notification message
180          * @exception   E_SUCCESS                       The method is successful.
181          * @exception   E_INVALID_ARG           The specified input parameter is invalid, or
182          *                                                                      the length of @c messageText is greater than App::MAX_NOTIFICATION_MESSAGE_LENGTH.
183          * @exception   E_SYSTEM                        A system error has occurred.
184          * @exception   E_INVALID_OPERATION     The type of application calling this method is invalid as per the Tizen platform policy.
185          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
186          *                                  The Construct() method is not called.
187          */
188         result NotifyOngoingActivity(const Tizen::Base::String& messageText) const;
189
190         /**
191          * Notifies the user about the ongoing activity using a message. @n
192          * @c launchArguments is specified as input parameter for Application::OnUserEventReceivedN() or can be obtained by
193          * invoking Application::GetAppArgumentListN(), especially within Application::OnAppInitializing().
194          *
195          * @since                               2.0
196          *
197          * @return              An error code
198          * @param[in]   messageText                     The notification message
199          * @param[in]  launchArguments  The launch arguments for the application
200          * @exception   E_SUCCESS                       The method is successful.
201          * @exception   E_INVALID_ARG           Either of the following conditions has occurred: @n
202          *                                                                      - A specified input parameter is invalid. @n
203          *                                                                      - The length of the specified @c messageText is greater than App::MAX_NOTIFICATION_MESSAGE_LENGTH. @n
204          *                                                                      - The length of the specified @c launchArguments is greater than App::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.
205          * @exception   E_SYSTEM                        A system error has occurred.
206          * @exception   E_INVALID_OPERATION     The type of application calling this method is invalid as per the Tizen platform policy.
207          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
208          *                                  The Construct() method is not called.
209          * @see                 Application::OnUserEventReceivedN(), Application::GetAppArgumentListN()
210          */
211         result NotifyOngoingActivity(const Tizen::Base::String& messageText, const Tizen::Base::String& launchArguments) const;
212
213         /**
214          * Removes the notification message for the ongoing activity.
215          *
216          * @since                       2.0
217          *
218          * @return              An error code
219          * @exception   E_SUCCESS                       The method is successful.
220          * @exception   E_SYSTEM                        A system error has occurred.
221          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
222          *                                  The Construct() method is not called.
223          * @remarks      The method returns E_SUCCESS when there is no outstanding notification.
224          */
225         result RemoveOngoingActivityNotification(void);
226
227         /**
228          * Gets the badge number of the application icon.
229          *
230          * @since                               1.0
231          *
232          * @return              The current badge number
233          * @param[in]   appId                           The application ID
234          * @exception   E_SUCCESS                       The method is successful.
235          * @exception   E_SYSTEM                        A system error has occurred.
236          * @exception   E_OBJ_NOT_FOUND     The application is not installed.
237          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
238          *                                  The Construct() method is not called.
239          * @remarks The specific error code can be accessed using the GetLastResult() method. @n
240          *                      In case of failure, this method returns @c -1.
241          */
242         int GetBadgeNumber(const AppId& appId) const;
243
244         /**
245          * Notifies the user using a badge number on behalf of the specified application.
246          *
247          * @since                                       1.0
248          *
249          * @return              An error code
250          * @param[in]   appId                           The application ID
251          * @param[in]   badgeNumber                     The badge number
252          * @exception   E_SUCCESS                       The method is successful.
253          * @exception   E_INVALID_ARG           A specified input parameter is invalid, or
254          *                                  the specified @c badgeNumber is less than @c 0.
255          * @exception   E_APP_NOT_INSTALLED  The application is not installed.
256          * @exception   E_INVALID_OPERATION     The target application with the specified application ID is not permitted to get any notification as per the Tizen platform policy.
257          * @exception   E_SYSTEM                        A system error has occurred.
258          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
259          *                                                                      The Construct() method is not called.
260          */
261         result NotifyOnBehalf(const AppId& appId, int badgeNumber) const;
262
263         /**
264          * Notifies the user using a message on behalf of the specified application.
265          *
266          * @since                                       1.0
267          *
268          * @return              An error code
269          * @param[in]   appId                           The application ID
270          * @param[in]   messageText                     The notification message
271          * @exception   E_SUCCESS                       The method is successful.
272          * @exception   E_INVALID_ARG           A specified input parameter is invalid, or
273          *                                                                      the length of @c messageText is greater than App::MAX_NOTIFICATION_MESSAGE_LENGTH.
274          * @exception   E_APP_NOT_INSTALLED  The application is not installed.
275          * @exception   E_INVALID_OPERATION     The target application with the specified application ID is not permitted to receive any notification as per the Tizen platform policy.
276          * @exception   E_SYSTEM                        A system error has occurred.
277          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
278          *                                                                      The Construct() method is not called.
279          */
280         result NotifyOnBehalf(const AppId& appId, const Tizen::Base::String& messageText) const;
281
282         /**
283          * Notifies the user using a message and badge number on behalf of the specified application.
284          *
285          * @since                                       1.0
286          *
287          * @return              An error code
288          * @param[in]   appId                           The application ID
289          * @param[in]   messageText                     The notification message
290          * @param[in]   badgeNumber                     The badge number
291          * @exception   E_SUCCESS                       The method is successful.
292          * @exception   E_INVALID_ARG           Either of the following conditions has occurred: @n
293          *                                                                      - A specified input parameter is invalid. @n
294          *                                                                      - The specified @c badgeNumber is less than @c 0. @n
295          *                                                                      - The length of @c messageText is greater than App::MAX_NOTIFICATION_MESSAGE_LENGTH.
296          * @exception   E_APP_NOT_INSTALLED  The application is not installed.
297          * @exception   E_INVALID_OPERATION     The target application with the specified application ID is not permitted to receive any notification as per the Tizen platform policy.
298          * @exception   E_SYSTEM                        A system error has occurred.
299          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
300          *                                  The Construct() method is not called.
301          */
302         result NotifyOnBehalf(const AppId& appId, const Tizen::Base::String& messageText, int badgeNumber) const;
303
304         /**
305         * Notifies the user using a message and badge number on behalf of the specified application. @n
306         * If the user checks the message, the @c launchArguments is delivered to the application.
307         *
308         * @since               2.0
309         *
310         * @return             An error code
311         * @param[in]  appId                             The application ID
312         * @param[in]  messageText               The notification message
313         * @param[in]  launchArguments   The launch arguments for the application
314         * @exception  E_SUCCESS                 The method is successful.
315         * @exception  E_INVALID_ARG             Either of the following conditions has occurred: @n
316         *                                                               - A specified input parameter is invalid. @n
317         *                                                               - The length of the specified @c messageText is greater than App::MAX_NOTIFICATION_MESSAGE_LENGTH. @n
318         *                                                               - The length of the specified @c launchArguments is greater than App::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.
319         * @exception  E_APP_NOT_INSTALLED       The application is not installed.
320         * @exception  E_INVALID_OPERATION       The target application with the specified application ID is not permitted to receive any notification as per the Tizen platform policy.
321         * @exception  E_SYSTEM                          A system error has occurred.
322         * @exception  E_INVALID_STATE           This instance is in an invalid state. @n
323          *                                  The Construct() method is not called.
324         */
325         result NotifyOnBehalf(const AppId& appId, const Tizen::Base::String& messageText, const Tizen::Base::String& launchArguments) const;
326
327         /**
328         * Notifies the user using a message and badge number on behalf of the specified application. @n
329         * If the user checks the message, the @c launchArguments is delivered to the application.
330         *
331         * @since               2.0
332         *
333         * @return             An error code
334         * @param[in]  appId                             The application ID
335         * @param[in]  messageText               The notification message
336         * @param[in]    badgeNumber                     The badge number
337         * @param[in]  launchArguments   The launch arguments for the application
338         * @exception  E_SUCCESS                 The method is successful.
339         * @exception  E_INVALID_ARG             Either of the following conditions has occurred: @n
340         *                                                               - A specified input parameter is invalid. @n
341         *                                                               - The specified @c badgeNumber is less than 0. @n
342         *                                                               - The length of the specified @c messageText is greater than App::MAX_NOTIFICATION_MESSAGE_LENGTH. @n
343         *                                                               - The length of the specified @c launchArguments is greater than App::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.
344         * @exception  E_APP_NOT_INSTALLED       The application is not installed.
345         * @exception  E_INVALID_OPERATION       The target application with the specified application ID is not permitted to receive any notification as per the Tizen platform policy.
346         * @exception  E_SYSTEM                          A system error has occurred.
347         * @exception  E_INVALID_STATE           This instance is in an invalid state. @n
348          *                                  The Construct() method is not called.
349         */
350         result NotifyOnBehalf(const AppId& appId, const Tizen::Base::String& messageText, int badgeNumber, const Tizen::Base::String& launchArguments) const;
351
352         /**
353          * Notifies the user about the ongoing activity using a message on behalf of the specified application.
354          *
355          * @since                               2.0
356          *
357          * @return              An error code
358          * @param[in]   appId                           The application ID
359          * @param[in]   messageText                     The notification message
360          * @exception   E_SUCCESS                       The method is successful.
361          * @exception   E_INVALID_ARG           The specified input parameter is invalid, or
362          *                                                                      the length of @c messageText is greater than App::MAX_NOTIFICATION_MESSAGE_LENGTH.
363          * @exception   E_APP_NOT_INSTALLED     The application is not installed.
364          * @exception   E_SYSTEM                        A system error has occurred.
365          * @exception   E_INVALID_OPERATION     The type of application calling this method is invalid as per the Tizen platform policy.
366          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
367          *                                  The Construct() method is not called.
368          */
369         result NotifyOngoingActivityOnBehalf(const AppId& appId, const Tizen::Base::String& messageText) const;
370
371         /**
372          * Notifies the user about the ongoing activity using a message on behalf of the specified application.
373          *
374          * @since                               2.0
375          *
376          * @return              An error code
377          * @param[in]   appId                           The application ID
378          * @param[in]   messageText                     The notification message
379          * @param[in]  launchArguments  The launch arguments for application
380          * @exception   E_SUCCESS                       The method is successful.
381          * @exception   E_INVALID_ARG           Either of the following conditions has occurred: @n
382          *                                                                      - A specified input parameter is invalid. @n
383          *                                                                      - The length of @c messageText is greater than App::MAX_NOTIFICATION_MESSAGE_LENGTH. @n
384          *                                                                      - The length of @c launchArguments is greater than App::MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.
385          * @exception   E_APP_NOT_INSTALLED     The application is not installed.
386          * @exception   E_SYSTEM                        A system error has occurred.
387          * @exception   E_INVALID_OPERATION     The type of application calling this method is invalid as per the Tizen platform policy.
388          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
389          *                                                                      The Construct() method is not called.
390          */
391         result NotifyOngoingActivityOnBehalf(const AppId& appId, const Tizen::Base::String& messageText, const Tizen::Base::String& launchArguments) const;
392
393         /**
394          * Removes the notification message for ongoing activity on behalf of the specified application.
395          *
396          * @since                       2.0
397          *
398          * @return              An error code
399          * @param[in]   appId                           The application ID
400          * @exception   E_SUCCESS                       The method is successful.
401          * @exception   E_APP_NOT_INSTALLED     The application is not installed.
402          * @exception   E_SYSTEM                        A system error has occurred.
403          * @exception   E_INVALID_STATE         This instance is in an invalid state. @n
404          *                                  The Construct() method is not called.
405          * @remarks             Although there is no outstanding notification for the calling application, this method returns E_SUCCESS.
406          */
407         result RemoveOngoingActivityNotificationOnBehalf(const AppId& appId);
408
409         /**
410          * Removes the notification message on behalf of the specified application.
411          *
412          * @since                       2.0
413          *
414          * @return              An error code
415          * @param[in]   appId                           The application ID
416          * @exception   E_SUCCESS                       The method was successful.
417          * @exception   E_APP_NOT_INSTALLED     The application is not installed.
418          * @exception   E_SYSTEM                        A system error occurred.
419          * @exception   E_INVALID_STATE         This instance is in an invalid state: @n
420          *                                                                      - The Construct() method is not called. @n
421          * @remarks             Although there is no outstanding notification for the calling application, this method returns E_SUCCESS.
422          */
423         result RemoveNotificationOnBehalf(const AppId& appId);
424
425         static const _NotificationManagerImpl* GetInstance(const NotificationManager& notiMgr);
426
427         static _NotificationManagerImpl* GetInstance(NotificationManager& notiMgr);
428
429 private:
430         result NotifyImpl(const Tizen::Base::String& messageText, int badgeNumber, const Tizen::Base::String& launchArguments, bool isOngoing = false) const;
431
432         result NotifyImpl(const AppId& appId, const Tizen::Base::String& messageText, int badgeNumber, const Tizen::Base::String& launchArguments, bool isOngoing = false) const;
433
434         inline result OngoingImpl(const Tizen::Base::String& messageText, const Tizen::Base::String& launchArguments) const;
435
436         inline result OngoingImpl(const AppId& appId, const Tizen::Base::String& messageText, const Tizen::Base::String& launchArguments) const;
437
438         result RemoveImpl(const AppId& appId, bool isOngoing);
439
440         result RemoveImpl(const char* pAppId, notification_type_e type);
441
442         _NotificationManagerImpl(const _NotificationManagerImpl& rhs);
443
444         _NotificationManagerImpl& operator =(const _NotificationManagerImpl& rhs);
445
446 private:
447 };      //_NotificationManagerImpl
448
449 } } // Tizen::App
450
451 #endif // _FAPP_INTERNAL_NOTIFICATION_MANAGER_IMPL_H_