Add exception handling
[platform/core/api/notification.git] / include / notification.h
1 /*
2  * Copyright (c) 2000 - 2017 Samsung Electronics Co., Ltd. All rights reserved.
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 #ifndef __NOTIFICATION_H__
19 #define __NOTIFICATION_H__
20
21
22 #include <time.h>
23 #include <bundle.h>
24 #include <app_control.h>
25
26
27 #include <notification_error.h>
28 #include <notification_type.h>
29 #include <notification_status.h>
30
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36
37 /**
38  * @file notification.h
39  * @brief This file contains the notification API.
40  */
41
42
43 /**
44  * @addtogroup NOTIFICATION_MODULE
45  * @{
46  */
47
48
49 /**
50  * @brief Sets an absolute path for an image file to display on the notification view.
51  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
52  * @param[in] noti The notification handle
53  * @param[in] type The notification image type
54  * @param[in] image_path The image file full path
55  * @return #NOTIFICATION_ERROR_NONE on success,
56  *         otherwise any other value on failure
57  * @retval #NOTIFICATION_ERROR_NONE Success
58  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
59  * @pre Notification handle should be created by notification_create().
60  * @see #notification_image_type_e
61  * @see notification_create()
62  * @par Sample code:
63  * @code
64 #include <notification.h>
65
66 {
67         notification_h noti = NULL;
68         int noti_err = NOTIFICATION_ERROR_NONE;
69
70         noti = notification_create(NOTIFICATION_TYPE_NOTI);
71         if (noti == NULL)
72                 return;
73
74         noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, APP_IMAGE_FULL_PATH);
75         if (noti_err != NOTIFICATION_ERROR_NONE) {
76                 notification_free(noti);
77                 return;
78         }
79 }
80  * @endcode
81  */
82 int notification_set_image(notification_h noti, notification_image_type_e type, const char *image_path);
83
84
85 /**
86  * @brief Gets the absolute path of an image file.
87  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
88  * @remarks Do not free @a image_path. It will be freed when notification_free() is called.
89  * @param[in] noti Notification handle
90  * @param[in] type Notification image type
91  * @param[out] image_path Image file full path
92  * @return NOTIFICATION_ERROR_NONE on success,
93  *         other value on failure
94  * @retval NOTIFICATION_ERROR_NONE Success
95  * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
96  * @pre Notification handle should be created by notification_create().
97  * @see #notification_image_type_e
98  * @see notification_create()
99  * @par Sample code:
100  * @code
101 #include <notification.h>
102
103 {
104         char *image_path = NULL;
105         int noti_err = NOTIFICATION_ERROR_NONE;
106
107         noti_err = notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, &image_path);
108         if (noti_err != NOTIFICATION_ERROR_NONE)
109                 return;
110 }
111  * @endcode
112  */
113 int notification_get_image(notification_h noti, notification_image_type_e type, char **image_path);
114
115
116 /**
117  * @brief Sets a timestamp.
118  * @details If input_time is @c 0, time information is taken from the current time.
119  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
120  * @param[in] noti The notification handle
121  * @param[in] input_time The input time. If you want the time stamp to not be shown, set this as NOTIFICATION_DO_NOT_SHOW_TIME_STAMP
122  * @return #NOTIFICATION_ERROR_NONE on success,
123  *         otherwise any other value on failure
124  * @retval #NOTIFICATION_ERROR_NONE Success
125  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
126  * @pre Notification handle should be created by notification_create().
127  * @see notification_create()
128  * @see NOTIFICATION_DO_NOT_SHOW_TIME_STAMP
129  * @par Sample code:
130  * @code
131 #include <notification.h>
132
133 {
134         notification_h noti = NULL;
135         int noti_err = NOTIFICATION_ERROR_NONE;
136
137         noti = notification_create(NOTIFICATION_TYPE_NOTI);
138         if (noti == NULL)
139                 return;
140
141         noti_err = notification_set_time(noti, time(NULL));
142         if (noti_err != NOTIFICATION_ERROR_NONE) {
143                 notification_free(noti);
144                 return;
145         }
146 }
147  * @endcode
148  */
149 int notification_set_time(notification_h noti, time_t input_time);
150
151
152 /**
153  * @brief Gets a timestamp.
154  * @details If ret_time is @c 0, time information is not set before.
155  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
156  * @param[in] noti The notification handle
157  * @param[out] ret_time The return time value
158  * @return #NOTIFICATION_ERROR_NONE on success,
159  *         otherwise any other value on failure
160  * @retval #NOTIFICATION_ERROR_NONE Success
161  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
162  * @pre Notification handle should be created by notification_create().
163  * @see notification_create()
164  * @par Sample code:
165  * @code
166 #include <notification.h>
167
168 {
169         time_t ret_time;
170         int noti_err = NOTIFICATION_ERROR_NONE;
171
172         noti_err = notification_get_time(noti, &ret_time);
173         if (noti_err != NOTIFICATION_ERROR_NONE)
174                 return;
175 }
176  * @endcode
177  */
178 int notification_get_time(notification_h noti, time_t *ret_time);
179
180
181 /**
182  * @brief Gets an insertion timestamp of the notification.
183  * @details If ret_time is @c 0, this notification data is not inserted before.
184  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
185  * @param[in] noti The notification handle
186  * @param[out] ret_time The return time value
187  * @return #NOTIFICATION_ERROR_NONE on success,
188  *         otherwise any other value on failure
189  * @retval #NOTIFICATION_ERROR_NONE Success
190  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
191  * @par Sample code:
192  * @code
193 #include <notification.h>
194
195 {
196         time_t ret_time;
197         int noti_err = NOTIFICATION_ERROR_NONE;
198
199         noti_err = notification_get_insert_time(noti, &ret_time);
200         if (noti_err != NOTIFICATION_ERROR_NONE)
201                 return;
202 }
203  * @endcode
204  */
205 int notification_get_insert_time(notification_h noti, time_t *ret_time);
206
207
208 /**
209  * @brief Sets the text to display on the notification view.
210  * @details Sets title, content string. If the text is formatted data (only %d, %f, %s are supported), type - value pair should be set.
211  *          If %d, the type #NOTIFICATION_VARIABLE_TYPE_INT and the value is an integer.
212  *          If %f, the type #NOTIFICATION_VARIABLE_TYPE_DOUBLE and the value is a double.
213  *          If %s, the type #NOTIFICATION_VARIABLE_TYPE_STRING and the value is a string.
214  *          If the type is #NOTIFICATION_VARIABLE_TYPE_COUNT, notification count is displaying with text.
215  *          If the value is #NOTIFICATION_COUNT_POS_LEFT, count is displayed at the left of the text.
216  *          If the value is #NOTIFICATION_COUNT_POS_IN, count is displayed in the text when text has %d format.
217  *          If the value is #NOTIFICATION_COUNT_POS_RIGHT, count is displayed at the right of the text.
218  *          Variable parameters should be terminated #NOTIFICATION_VARIABLE_TYPE_NONE.
219  *
220  *          Note that You can display the translated contents according to the language of the system.
221  *          The application must supply a String KEY as the fourth argument to support localization.
222  *          If the language on the system changes, the contents of the notification are also translated.
223  *
224  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
225  * @param[in] noti The notification handle
226  * @param[in] type The notification text type
227  * @param[in] text The basic text
228  * @param[in] key The text key for localization
229  * @param[in] args_type The variable parameter that type - value pair
230  * @return #NOTIFICATION_ERROR_NONE on success,
231  *         otherwise any other value on failure
232  * @retval #NOTIFICATION_ERROR_NONE Success
233  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
234  * @pre notification handle should be created by notification_create().
235  * @par Sample code:
236  * @code
237 #include <notification.h>
238
239 {
240         notification_h noti = NULL;
241         int noti_err = NOTIFICATION_ERROR_NONE;
242
243         noti = notification_create(NOTIFICATION_TYPE_NOTI);
244         if (noti == NULL)
245                 return;
246
247         noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
248                         "I'm Title", "IDS_APP_BODY_IM_TITLE", NOTIFICATION_VARIABLE_TYPE_NONE);
249         if (noti_err != NOTIFICATION_ERROR_NONE) {
250                 notification_free(noti);
251                 return;
252         }
253 }
254  * @endcode
255  */
256 int notification_set_text(notification_h noti, notification_text_type_e type,
257                 const char *text, const char *key, int args_type, ...);
258
259
260 /**
261  * @brief Gets the text from the notification handle.
262  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
263  * @param[in] noti The notification handle
264  * @param[in] type The notification text type
265  * @param[out] text The notification text
266  * @return #NOTIFICATION_ERROR_NONE on success,
267  *         otherwise any other value on failure
268  * @retval #NOTIFICATION_ERROR_NONE Success
269  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
270  * @par Sample code:
271  * @code
272 #include <notification.h>
273
274 {
275         notification_h noti = NULL;
276         int noti_err = NOTIFICATION_ERROR_NONE;
277         char *text = NULL;
278
279         noti_err = notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, &text);
280         if (noti_err != NOTIFICATION_ERROR_NONE)
281                 return;
282
283 }
284  * @endcode
285  */
286 int notification_get_text(notification_h noti, notification_text_type_e type, char **text);
287
288
289 /**
290  * @brief Sets the timestamp to display on the notification view.
291  * @details The timestamp will be converted to a formatted string and it will be displayed on the set text area.
292  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
293  * @param[in] noti The notification handle
294  * @param[in] type The notification text type
295  * @param[in] time The timestamp
296  * @return #NOTIFICATION_ERROR_NONE on success,
297  *         otherwise any other value on failure
298  * @retval #NOTIFICATION_ERROR_NONE Success
299  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
300  * @pre Notification handle should be created by notification_create().
301  */
302 int notification_set_time_to_text(notification_h noti, notification_text_type_e type, time_t time);
303
304
305 /**
306  * @brief Gets the timestamp from the notification handle.
307  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
308  * @param[in] noti The notification handle
309  * @param[in] type The notification text type
310  * @param[in] time The pointer of time stamp
311  * @return #NOTIFICATION_ERROR_NONE on success,
312  *         otherwise any other value on failure
313  * @retval #NOTIFICATION_ERROR_NONE Success
314  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
315  * @pre Notification handle should be created by notification_create().
316  */
317 int notification_get_time_from_text(notification_h noti, notification_text_type_e type, time_t *time);
318
319
320 /**
321  * @brief Sets the sound type for the notification.
322  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
323  * @param[in] noti The notification handle
324  * @param[in] type The notification sound type
325  * @param[in] path The user sound file path
326  * @return #NOTIFICATION_ERROR_NONE on success,
327  *         otherwise any other value on failure
328  * @retval #NOTIFICATION_ERROR_NONE Success
329  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
330  * @par Sample code:
331  * @code
332 #include <notification.h>
333
334 {
335         notification_h noti = NULL;
336         int noti_err = NOTIFICATION_ERROR_NONE;
337
338         noti_err = notification_set_sound(noti, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL);
339         if (noti_err != NOTIFICATION_ERROR_NONE)
340                 return;
341
342 }
343  * @endcode
344  */
345 int notification_set_sound(notification_h noti, notification_sound_type_e type, const char *path);
346
347
348 /**
349  * @brief Gets the sound type from the notification handle.
350  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
351  * @param[in] noti The notification handle
352  * @param[out] type The notification sound type
353  * @param[out] path The user sound file path
354  * @return #NOTIFICATION_ERROR_NONE on success,
355  *         otherwise any other value on failure
356  * @retval #NOTIFICATION_ERROR_NONE Success
357  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
358  * @par Sample code:
359  * @code
360 #include <notification.h>
361
362 {
363         notification_h noti = NULL;
364         int noti_err = NOTIFICATION_ERROR_NONE;
365         notification_sound_type_e type = NOTIFICATION_SOUND_TYPE_NONE;
366
367         noti_err = notification_get_sound(noti, &type, NULL);
368         if (noti_err != NOTIFICATION_ERROR_NONE)
369                 return;
370
371 }
372  * @endcode
373  */
374 int notification_get_sound(notification_h noti, notification_sound_type_e *type, const char **path);
375
376
377 /**
378  * @brief Sets the vibration type for the notification.
379  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
380  * @param[in] noti The notification handle
381  * @param[in] type The notification vibration type
382  * @param[in] path The user vibration file path
383  * @return #NOTIFICATION_ERROR_NONE on success,
384  *         otherwise any other value on failure
385  * @retval #NOTIFICATION_ERROR_NONE Success
386  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
387  * @par Sample code:
388  * @code
389 #include <notification.h>
390
391 {
392         notification_h noti = NULL;
393         int noti_err = NOTIFICATION_ERROR_NONE;
394
395         noti_err = notification_set_vibration(noti, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
396         if (noti_err != NOTIFICATION_ERROR_NONE)
397                 return;
398
399 }
400  * @endcode
401  */
402 int notification_set_vibration(notification_h noti, notification_vibration_type_e type, const char *path);
403
404
405 /**
406  * @brief Gets the vibrate type from the notification handle.
407  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
408  * @param[in] noti The notification handle
409  * @param[out] type The notification sound type
410  * @param[out] path The user vibration file path
411  * @return #NOTIFICATION_ERROR_NONE on success,
412  *         otherwise other value on failure
413  * @retval #NOTIFICATION_ERROR_NONE Success
414  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
415  * @par Sample code:
416  * @code
417 #include <notification.h>
418
419 {
420         notification_h noti = NULL;
421         int noti_err = NOTIFICATION_ERROR_NONE;
422         notification_vibration_type_e type = NOTIFICATION_VIBRATION_TYPE_NONE;
423
424         noti_err = notification_get_vibration(noti, &type, NULL);
425         if (noti_err != NOTIFICATION_ERROR_NONE)
426                 return;
427
428 }
429   * @endcode
430   */
431 int notification_get_vibration(notification_h noti, notification_vibration_type_e *type, const char **path);
432
433
434 /**
435  * @brief Sets the LED displaying option.
436  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
437  * @param[in] noti The notification handle
438  * @param[in] operation The LED notification operation
439  * @param[in] led_argb The notification LED color
440  * @return #NOTIFICATION_ERROR_NONE on success,
441  *         otherwise other value on failure
442  * @retval #NOTIFICATION_ERROR_NONE Success
443  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
444  * @par Sample code:
445  * @code
446 #include <notification.h>
447
448 {
449         notification_h noti = NULL;
450         int noti_err = NOTIFICATION_ERROR_NONE;
451
452         noti_err = notification_set_led(noti, NOTIFICATION_LED_OP_ON, NULL);
453         if (noti_err != NOTIFICATION_ERROR_NONE)
454                 return;
455
456 }
457  * @endcode
458  */
459 int notification_set_led(notification_h noti, notification_led_op_e operation, int led_argb);
460
461
462 /**
463  * @brief Gets the LED displaying option from the notification handle.
464  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
465  * @param[in] noti The notification handle
466  * @param[out] operation The LED notification operation
467  * @param[out] led_argb The notification LED color
468  * @return #NOTIFICATION_ERROR_NONE on success,
469  *         otherwise any other value on failure
470  * @retval #NOTIFICATION_ERROR_NONE Success
471  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
472  * @par Sample code:
473  * @code
474 #include <notification.h>
475
476 {
477         notification_h noti = NULL;
478         int noti_err = NOTIFICATION_ERROR_NONE;
479         notification_led_type_e type = NOTIFICATION_LED_OP_OFF;
480
481         noti_err = notification_get_led(noti, &type, NULL);
482         if (noti_err != NOTIFICATION_ERROR_NONE)
483                 return;
484
485 }
486   * @endcode
487   */
488 int notification_get_led(notification_h noti, notification_led_op_e *operation, int *led_argb);
489
490
491 /**
492  * @brief Sets the time period of flashing the LED.
493  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
494  * @param[in] noti The notification handle
495  * @param[in] on_ms The time for turning on the LED
496  * @param[in] off_ms The time for turning off the LED
497  * @return #NOTIFICATION_ERROR_NONE on success,
498  *         otherwise any other value on failure
499  * @retval #NOTIFICATION_ERROR_NONE Success
500  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
501  * @par Sample code:
502  * @code
503 #include <notification.h>
504
505 {
506         notification_h noti = NULL;
507         int noti_err = NOTIFICATION_ERROR_NONE;
508
509         noti_err = notification_set_led_time_period(noti, 100, 100);
510         if (noti_err != NOTIFICATION_ERROR_NONE)
511                 return;
512
513 }
514  * @endcode
515  */
516 int notification_set_led_time_period(notification_h noti, int on_ms, int off_ms);
517
518
519 /**
520  * @brief Gets the time period of flashing the LED from the notification handle.
521  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
522  * @param[in] noti The notification handle
523  * @param[out] on_ms The time for turning on the LED
524  * @param[out] off_ms The time for turning on the LED
525  * @return #NOTIFICATION_ERROR_NONE on success,
526  *         otherwise any other value on failure
527  * @retval #NOTIFICATION_ERROR_NONE Success
528  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
529  * @par Sample code:
530  * @code
531 #include <notification.h>
532
533 {
534         notification_h noti = NULL;
535         int noti_err = NOTIFICATION_ERROR_NONE;
536         int led_on_ms = 0;
537         int led_off_ms = 0;
538
539         noti_err = notification_get_led_time_period(noti, &led_on_ms, &led_off_ms);
540         if (noti_err != NOTIFICATION_ERROR_NONE)
541                 return;
542
543 }
544   * @endcode
545   */
546 int notification_get_led_time_period(notification_h noti, int *on_ms, int *off_ms);
547
548
549 /**
550  * @brief Sets the launch option for a notification.
551  * @details When notification data selected in display application, application launched by app_control_send_launch_request with app_control handle.
552  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
553  * @param[in] noti The notification handle
554  * @param[in] type Launching option type
555  * @param[in] option App Control handler
556  * @return #NOTIFICATION_ERROR_NONE on success,
557  *         otherwise any other value on failure
558  * @retval #NOTIFICATION_ERROR_NONE Success
559  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
560  * @par Sample code:
561  * @code
562 #include <notification.h>
563
564 {
565         notification_h noti = NULL;
566         app_control_h app_control = NULL;
567         int noti_err = NOTIFICATION_ERROR_NONE;
568
569         // Do something
570
571         app_control_create(&app_control);
572         app_control_set_app_id(app_control, "org.tizen.app");
573
574         // Do something
575
576         noti_err = notification_set_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, (void *)app_control);
577         if (noti_err != NOTIFICATION_ERROR_NONE) {
578                 app_control_destroy(app_control);
579                 notification_free(noti);
580                 return;
581         }
582
583         app_control_destroy(app_control);
584 }
585  * @endcode
586  */
587 int notification_set_launch_option(notification_h noti, notification_launch_option_type type, void *option);
588
589
590 /**
591  * @brief Gets the launch option from the notification handle.
592  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
593  * @remarks You must release @a app_control using app_control_destroy().
594  * @param[in] noti The notification handle
595  * @param[in] type Launching option type
596  * @param[out] option The pointer of App Control handler
597  * @return #NOTIFICATION_ERROR_NONE on success,
598  *         otherwise any other value on failure
599  * @retval #NOTIFICATION_ERROR_NONE Success
600  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
601  * @par Sample code:
602  * @code
603 #include <notification.h>
604
605 {
606         app_control_h app_control = NULL;
607         app_control_create(&app_control);
608
609         // Do something
610
611         noti_err = notification_get_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, (void *)&app_control);
612         if (noti_err != NOTIFICATION_ERROR_NONE)
613                 return;
614 }
615  * @endcode
616  */
617 int notification_get_launch_option(notification_h noti, notification_launch_option_type type, void *option);
618
619
620 /**
621  * @brief Sets the handler for a specific event.
622  * @details When some event occurs on notification, application launched by app_control_send_launch_request with app_control handle. \n
623  *          Setting event handler of a button means that the notification will show the button.
624  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
625  * @param[in] noti The notification handle
626  * @param[in] event_type Event type
627  * @param[in] event_handler App control handle
628  * @return #NOTIFICATION_ERROR_NONE on success,
629  *         otherwise any other value on failure
630  * @retval #NOTIFICATION_ERROR_NONE Success
631  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
632  * @see #notification_event_type_e
633  * @par Sample code:
634  * @code
635 #include <notification.h>
636
637 {
638         notification_h noti = NULL;
639         app_control_h app_control = NULL;
640         int noti_err = NOTIFICATION_ERROR_NONE;
641
642         // Do something
643
644         app_control_create(&app_control);
645         app_control_set_app_id(app_control, "org.tizen.app");
646
647         // Do something
648
649         noti_err = notification_set_event_handler(noti, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, app_control);
650         if (noti_err != NOTIFICATION_ERROR_NONE) {
651                 app_control_destroy(app_control);
652                 notification_free(noti);
653                 return;
654         }
655
656         app_control_destroy(app_control);
657 }
658  * @endcode
659  */
660 int notification_set_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h event_handler);
661
662
663 /**
664  * @brief Gets the event handler of a specific event.
665  * @remarks You must release @a app_control using app_control_destroy().
666  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
667  * @param[in] noti The notification handle
668  * @param[in] event_type Launching option type
669  * @param[out] event_handler The handler of App Control
670  * @return #NOTIFICATION_ERROR_NONE on success,
671  *         otherwise any other value on failure
672  * @retval #NOTIFICATION_ERROR_NONE Success
673  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
674  * @see #notification_event_type_e
675  * @par Sample code:
676  * @code
677 #include <notification.h>
678
679 {
680         app_control_h app_control = NULL;
681         app_control_create(&app_control);
682
683         // Do something
684
685         noti_err = notification_get_event_handler(noti, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, &app_control);
686         if (noti_err != NOTIFICATION_ERROR_NONE) {
687                 notification_free(noti);
688                 return;
689         }
690 }
691  * @endcode
692  */
693 int notification_get_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h *event_handler);
694
695
696 /**
697  * @brief Sets the property of the notification.
698  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
699  * @param[in] noti The notification handle
700  * @param[in] flags The property with | operation
701  * @return #NOTIFICATION_ERROR_NONE on success,
702  *         otherwise any other value on failure
703  * @retval #NOTIFICATION_ERROR_NONE Success
704  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
705  * @par Sample code:
706  * @code
707 #include <notification.h>
708
709 {
710         notification_h noti = NULL;
711         int noti_err = NOTIFICATION_ERROR_NONE;
712         bundle *b = NULL;
713
714         noti = notification_create(NOTIFICATION_TYPE_NOTI);
715         if (noti == NULL)
716                 return;
717
718         noti_err = notification_set_property(noti, NOTIFICATION_PROP_DISPLAY_ONLY_SIMMODE | NOTIFICATION_PROP_DISABLE_APP_LAUNCH);
719         if (noti_err != NOTIFICATION_ERROR_NONE) {
720                 notification_free(noti);
721                 return;
722         }
723 }
724  * @endcode
725  */
726 int notification_set_property(notification_h noti, int flags);
727
728
729 /**
730  * @brief Gets the property of the notification from the notification handle.
731  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
732  * @param[in] noti The notification handle
733  * @param[out] flags The notification property
734  * @return #NOTIFICATION_ERROR_NONE on success,
735  *         otherwise any other value on failure
736  * @retval #NOTIFICATION_ERROR_NONE Success
737  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
738  * @par Sample code:
739  * @code
740 #include <notification.h>
741
742 {
743         notification_h noti = NULL;
744         int noti_err = NOTIFICATION_ERROR_NONE;
745         int flags = 0;
746
747         noti_err = notification_get_property(noti, &flags);
748         if (noti_err != NOTIFICATION_ERROR_NONE)
749                 return;
750
751 }
752  * @endcode
753  */
754 int notification_get_property(notification_h noti, int *flags);
755
756
757 /**
758  * @brief Sets applications to display the notification.
759  * @details All display application is enabled(NOTIFICATION_DISPLAY_APP_ALL) if you do not call this API.
760  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
761  * @param[in] noti The notification handle
762  * @param[in] applist The with | operation
763  * @return #NOTIFICATION_ERROR_NONE on success,
764  *         otherwise any other value on failure
765  * @retval #NOTIFICATION_ERROR_NONE Success
766  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
767  * @par Sample code:
768  * @code
769 #include <notification.h>
770
771 {
772         notification_h noti = NULL;
773         int noti_err = NOTIFICATION_ERROR_NONE;
774         bundle *b = NULL;
775
776         noti = notification_create(NOTIFICATION_TYPE_NOTI);
777         if (noti == NULL)
778                 return;
779
780         noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY |
781                                                         NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR);
782         if (noti_err != NOTIFICATION_ERROR_NONE) {
783                 notification_free(noti);
784                 return;
785         }
786 }
787  * @endcode
788  */
789 int notification_set_display_applist(notification_h noti, int applist);
790
791
792 /**
793  * @brief Gets the application list displaying the notification from the notification handle.
794  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
795  * @param[in] noti The notification handle
796  * @param[out] applist The display application list
797  * @return #NOTIFICATION_ERROR_NONE on success,
798  *         otherwise any other value on failure
799  * @retval #NOTIFICATION_ERROR_NONE Success
800  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
801  * @par Sample code:
802  * @code
803 #include <notification.h>
804
805 {
806         notification_h noti = NULL;
807         int noti_err = NOTIFICATION_ERROR_NONE;
808         int applist = 0;
809
810         noti_err = notification_get_display_applist(noti, &applist);
811         if (noti_err != NOTIFICATION_ERROR_NONE)
812                 return;
813
814 }
815  * @endcode
816  */
817 int notification_get_display_applist(notification_h noti, int *applist);
818
819
820 /**
821  * @brief Sets the initial size for the ongoing type.
822  * @details After notification_post() call, the size is not updated.
823  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
824  * @param[in] noti The notification handle
825  * @param[in] size The double type size
826  * @return #NOTIFICATION_ERROR_NONE on success,
827  *         otherwise any other value on failure
828  * @retval #NOTIFICATION_ERROR_NONE Success
829  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
830  * @par Sample code:
831  * @code
832 #include <notification.h>
833
834 {
835         notification_h noti = NULL;
836         int noti_err = NOTIFICATION_ERROR_NONE;
837
838         noti = notification_create(NOTIFICATION_TYPE_NOTI);
839         if (noti == NULL)
840                 return;
841
842         noti_err = notification_set_size(noti, 0.0);
843         if (noti_err != NOTIFICATION_ERROR_NONE) {
844                 notification_free(noti);
845                 return;
846         }
847 }
848  * @endcode
849  */
850 int notification_set_size(notification_h noti, double size);
851
852
853 /**
854  * @brief Gets the progress size.
855  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
856  * @param[in] noti The notification handle
857  * @param[out] size The progress size
858  * @return #NOTIFICATION_ERROR_NONE on success,
859  *         otherwise any other value on failure
860  * @retval #NOTIFICATION_ERROR_NONE Success
861  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
862  * @par Sample code:
863  * @code
864 #include <notification.h>
865
866 {
867         notification_h noti = NULL;
868         int noti_err = NOTIFICATION_ERROR_NONE;
869         double size = 0.0;
870
871         noti_err = notification_get_size(noti, &size);
872         if (noti_err != NOTIFICATION_ERROR_NONE)
873                 return;
874 }
875  * @endcode
876  */
877 int notification_get_size(notification_h noti, double *size);
878
879
880 /**
881  * @brief Sets the initial progress for the ongoing type.
882  * @details After the notification_post() call, the progress is not updated.
883  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
884  * @param[in] noti The notification handle
885  * @param[in] percentage The progress percentage
886  * @return #NOTIFICATION_ERROR_NONE on success,
887  *         otherwise any other value on failure
888  * @retval #NOTIFICATION_ERROR_NONE Success
889  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
890  * @par Sample code:
891  * @code
892 #include <notification.h>
893
894 {
895         notification_h noti = NULL;
896         int noti_err = NOTIFICATION_ERROR_NONE;
897
898         noti = notification_create(NOTIFICATION_TYPE_NOTI);
899         if (noti == NULL)
900                 return;
901
902         noti_err = notification_set_progress(noti, 0.0);
903         if (noti_err != NOTIFICATION_ERROR_NONE) {
904                 notification_free(noti);
905                 return;
906         }
907 }
908  * @endcode
909  */
910 int notification_set_progress(notification_h noti, double percentage);
911
912
913 /**
914  * @brief Gets the progress from the notification handle.
915  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
916  * @remarks At the end of the operation, the progress should be @c 1.0.
917  * @param[in] noti The notification handle
918  * @param[out] percentage The progress percentage
919  * @return #NOTIFICATION_ERROR_NONE on success,
920  *         otherwise any other value on failure
921  * @retval #NOTIFICATION_ERROR_NONE Success
922  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
923  * @par Sample code:
924  * @code
925 #include <notification.h>
926
927 {
928         notification_h noti = NULL;
929         int noti_err = NOTIFICATION_ERROR_NONE;
930         double percentage = 0.0;
931
932         noti_err = notification_get_progress(noti, &percentage);
933         if (noti_err != NOTIFICATION_ERROR_NONE)
934                 return;
935
936 }
937  * @endcode
938  */
939 int notification_get_progress(notification_h noti, double *percentage);
940
941
942 /**
943  * @brief Sets the layout of the notification view.
944  * @details Caller can set displaying layout of notification.
945  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
946  * @param[in] noti The notification handle
947  * @param[in] layout The type of layout
948  * @return #NOTIFICATION_ERROR_NONE on success,
949  *         otherwise any other value on failure
950  * @retval #NOTIFICATION_ERROR_NONE Success
951  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
952  * @see #notification_ly_type_e
953  */
954 int notification_set_layout(notification_h noti, notification_ly_type_e layout);
955
956
957 /**
958  * @brief Gets the layout of the notification view from the notification handle.
959  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
960  * @param[in] noti The notification handle
961  * @param[out] layout The type of layout
962  * @return #NOTIFICATION_ERROR_NONE on success,
963  *         otherwise any other value on failure
964  * @retval #NOTIFICATION_ERROR_NONE Success
965  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
966  * @see #notification_ly_type_e
967  */
968 int notification_get_layout(notification_h noti, notification_ly_type_e *layout);
969
970
971 /**
972  * @brief Gets the type of a notification.
973  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
974  * @param[in] noti The notification handle
975  * @param[out] type The notification type
976  * @return #NOTIFICATION_ERROR_NONE on success,
977  *         otherwise any other value on failure
978  * @retval #NOTIFICATION_ERROR_NONE Success
979  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
980  * @par Sample code:
981  * @code
982 #include <notification.h>
983
984 {
985         int noti_err = NOTIFICATION_ERROR_NONE;
986         notification_type_e type;
987
988         noti_err = notification_get_type(noti, &type);
989         if (noti_err != NOTIFICATION_ERROR_NONE)
990                 return;
991 }
992  * @endcode
993  */
994 int notification_get_type(notification_h noti, notification_type_e *type);
995
996
997 /**
998  * @brief Updates notification data.
999  * @details The updated notification will appear in the notification area.
1000  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
1001  * @privlevel public
1002  * @privilege %http://tizen.org/privilege/notification
1003  * @param[in] noti The notification handle that is created by notification_create()
1004  * @return #NOTIFICATION_ERROR_NONE on success,
1005  *         otherwise any other value on failure
1006  * @retval #NOTIFICATION_ERROR_NONE Success
1007  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
1008  * @retval #NOTIFICATION_ERROR_NOT_EXIST_ID Priv ID does not exist
1009  * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
1010  * @par Sample code:
1011  * @code
1012 #include <notification.h>
1013
1014 {
1015         int noti_err = NOTIFICATION_ERROR_NONE;
1016
1017         noti_err = notification_update(NULL);
1018         if (noti_err != NOTIFICATION_ERROR_NONE)
1019                 return;
1020 }
1021  * @endcode
1022  */
1023 int notification_update(notification_h noti);
1024
1025
1026 /**
1027  * @brief Deletes a notification with the given handle.
1028  * @details notification_delete() removes notification data from database and notification_free() releases memory of notification data.
1029  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
1030  * @privlevel public
1031  * @privilege %http://tizen.org/privilege/notification
1032  * @param[in] noti The notification handle
1033  * @return #NOTIFICATION_ERROR_NONE on success,
1034  *         otherwise any other value on failure
1035  * @retval #NOTIFICATION_ERROR_NONE Success
1036  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
1037  * @retval NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
1038  * @par Sample code:
1039  * @code
1040 #include <notification.h>
1041
1042 {
1043         notification_h noti = NULL;
1044         int noti_err = NOTIFICATION_ERROR_NONE;
1045
1046         // Do something
1047
1048         noti_err = notification_delete(noti);
1049         if (noti_err != NOTIFICATION_ERROR_NONE)
1050                 return;
1051
1052 }
1053  * @endcode
1054  */
1055 int notification_delete(notification_h noti);
1056
1057
1058 /**
1059  * @brief Creates internal structure data and returns a notification handle.
1060  * @details Available type is #NOTIFICATION_TYPE_NOTI and #NOTIFICATION_TYPE_ONGOING.
1061  *          #NOTIFICATION_TYPE_NOTI is remaining notification data even if device is restarted.
1062  *          #NOTIFICATION_TYPE_ONGOING can display progress on a notification with #NOTIFICATION_LY_ONGOING_PROGRESS layout.
1063  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
1064  * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
1065  * @param[in] type The notification type
1066  * @return Notification handle(notification_h) on success,
1067  *         otherwise @c NULL on failure
1068  * @retval notification_h Success
1069  * @retval NULL Failure
1070  * @exception #NOTIFICATION_ERROR_NONE Success
1071  * @exception #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
1072  * @exception #NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
1073  * @exception #NOTIFICATION_ERROR_IO_ERROR I/O error
1074  * @see #notification_type_e
1075  * @par Sample code:
1076  * @code
1077 #include <notification.h>
1078
1079 {
1080         notification_h noti = NULL;
1081
1082         noti = notification_create(NOTIFICATION_TYPE_NOTI);
1083         if (noti == NULL)
1084                 return;
1085
1086         // Do something
1087
1088 }
1089  * @endcode
1090  */
1091 notification_h notification_create(notification_type_e type);
1092
1093
1094 /**
1095  * @brief Creates a notification clone.
1096  * @details Newly created notification handle is returned.
1097  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
1098  * @remarks This cloned notification handle should be freed using notification_free().
1099  * @param[in] noti The notification handle
1100  * @param[out] clone The newly created notification handle that has same with input @a noti
1101  * @return #NOTIFICATION_ERROR_NONE if success,
1102  *         otherwise any other value if failure
1103  * @retval #NOTIFICATION_ERROR_NONE Success
1104  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
1105  * @see #notification_type_e
1106  * @par Sample code:
1107  * @code
1108 #include <notification.h>
1109
1110 {
1111         notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI);
1112         notification_h clone = NULL;
1113
1114         notification_clone(noti, &clone);
1115
1116         // Do something
1117
1118 }
1119  * @endcode
1120  */
1121 int notification_clone(notification_h noti, notification_h *clone);
1122
1123
1124 /**
1125  * @brief Frees the internal structure data of a notification handle.
1126  * @details Internal data of a notification handle is released. Data of the inserted notification is not deleted.
1127  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
1128  * @param[in] noti The notification handle
1129  * @return #NOTIFICATION_ERROR_NONE on success,
1130  *         otherwise any other value on failure
1131  * @retval #NOTIFICATION_ERROR_NONE Success
1132  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
1133  * @pre Notification handle should be created by notification_create().
1134  * @par Sample code:
1135  * @code
1136 #include <notification.h>
1137
1138 {
1139         notification_h noti = NULL;
1140         int noti_err = NOTIFICATION_ERROR_NONE;
1141
1142         noti = notification_create(NOTIFICATION_TYPE_NOTI);
1143         if (noti == NULL)
1144                 return;
1145
1146         // Do something
1147
1148         noti_err = notification_free(noti);
1149         if (noti_err != NOTIFICATION_ERROR_NONE)
1150                 return;
1151
1152 }
1153  * @endcode
1154  */
1155 int notification_free(notification_h noti);
1156
1157
1158 /**
1159  * @}
1160  */
1161
1162
1163 /**
1164  * @addtogroup NOTIFICATION_MODULE
1165  * @{
1166  */
1167
1168
1169 /**
1170  * @brief Sets the tag of the notification handle.
1171  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
1172  * @param[in] noti Notification handle
1173  * @param[in] tag Tag for loading notification handle
1174  * @return #NOTIFICATION_ERROR_NONE on success,
1175  *         other value on failure
1176  * @retval #NOTIFICATION_ERROR_NONE Success
1177  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
1178  * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
1179  * @see notification_get_tag()
1180  * @par Sample code:
1181  * @code
1182 #include <notification.h>
1183
1184 {
1185         notification_h noti = NULL;
1186         int noti_err = NOTIFICATION_ERROR_NONE;
1187
1188         noti = notification_create(NOTIFICATION_TYPE_NOTI);
1189         if (noti == NULL)
1190                 return;
1191
1192         // Do something
1193
1194         noti_err = notification_set_tag(noti, tag);
1195         if (noti_err != NOTIFICATION_ERROR_NONE)
1196                 return;
1197
1198 }
1199  * @endcode
1200  */
1201 int notification_set_tag(notification_h noti, const char *tag);
1202
1203
1204 /**
1205  * @brief Gets the tag of the notification handle.
1206  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
1207  * @param[in] noti Notification handle
1208  * @param[out] tag Tag for loading notification handle
1209  * @return #NOTIFICATION_ERROR_NONE on success,
1210  *         other value on failure
1211  * @retval #NOTIFICATION_ERROR_NONE Success
1212  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
1213  * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
1214  * @see notification_set_tag()
1215  * @par Sample code:
1216  * @code
1217 #include <notification.h>
1218
1219 {
1220         int noti_err = NOTIFICATION_ERROR_NONE;
1221         const char *tag = NULL;
1222
1223         // Do something
1224
1225         noti_err = notification_get_tag(noti, &tag);
1226         if (noti_err != NOTIFICATION_ERROR_NONE)
1227                 return;
1228
1229 }
1230  * @endcode
1231  */
1232 int notification_get_tag(notification_h noti, const char **tag);
1233
1234
1235 /**
1236  * @brief Loads a notification from the notification's database with the tag.
1237  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
1238  * @privlevel public
1239  * @privilege %http://tizen.org/privilege/notification
1240  * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
1241  * @param[in] tag Tag for loading notification handle
1242  * @return Notification handle(notification_h) on success,
1243  *         NULL on failure
1244  * @retval notification_h Success
1245  * @retval NULL Failure
1246  * @exception #NOTIFICATION_ERROR_NONE Success
1247  * @exception #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
1248  * @exception #NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
1249  * @exception #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
1250  * @see #notification_type_e
1251  * @par Sample code:
1252  * @code
1253 #include <notification.h>
1254
1255 {
1256         notification_h noti = NULL;
1257
1258         noti = notification_load_by_tag(tag);
1259         if (noti == NULL)
1260                 return;
1261
1262         // Do something
1263
1264 }
1265  * @endcode
1266  */
1267 notification_h notification_load_by_tag(const char *tag);
1268
1269
1270 /**
1271  * @brief Deletes all notifications of the given type.
1272  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
1273  * @privlevel public
1274  * @privilege %http://tizen.org/privilege/notification
1275  * @param[in] type Notification type
1276  * @return #NOTIFICATION_ERROR_NONE if success,
1277  *         other value if failure
1278  * @retval #NOTIFICATION_ERROR_NONE Success
1279  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
1280  * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
1281  * @par Sample code:
1282  * @code
1283 #include <notification.h>
1284
1285 {
1286         int noti_err = NOTIFICATION_ERROR_NONE;
1287
1288         noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
1289         if (noti_err != NOTIFICATION_ERROR_NONE)
1290                 return;
1291
1292 }
1293  * @endcode
1294  */
1295 int notification_delete_all(notification_type_e type);
1296
1297
1298 /**
1299  * @brief Posts a notification.
1300  * @since_tizen @if WEARABLE 2.3.1 @elseif MOBILE 2.3 @endif
1301  * @privlevel public
1302  * @privilege %http://tizen.org/privilege/notification
1303  * @param[in] noti Notification handle
1304  * @return #NOTIFICATION_ERROR_NONE if success,
1305  *         other value if failure
1306  * @retval #NOTIFICATION_ERROR_NONE Success
1307  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
1308  * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
1309  * @pre Notification handle should be created by notification_create().
1310  * @post notification_free().
1311  * @par Sample code:
1312  * @code
1313 #include <notification.h>
1314
1315 {
1316         int noti_err = NOTIFICATION_ERROR_NONE;
1317
1318         noti_err = notification_post(noti);
1319         if (noti_err != NOTIFICATION_ERROR_NONE)
1320                 return;
1321
1322 }
1323  * @endcode
1324  */
1325 int notification_post(notification_h noti);
1326
1327
1328 /**
1329  * @brief Gets the package name of the notification.
1330  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
1331  * @param[in] noti Notification handle
1332  * @param[out] pkgname The package name of the notification
1333  * @return #NOTIFICATION_ERROR_NONE on success,
1334  *         otherwise a negative error value
1335  * @retval NOTIFICATION_ERROR_NONE Success
1336  * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
1337  * @par Sample code:
1338  * @code
1339 #include <notification.h>
1340
1341 {
1342         notification_h noti = NULL;
1343         int noti_err = NOTIFICATION_ERROR_NONE;
1344         char *pkgname = NULL;
1345
1346         // Do something
1347
1348         noti_err = notification_get_pkgname(noti, &pkgname);
1349
1350         if (noti_err != NOTIFICATION_ERROR_NONE) {
1351                 notification_free(noti);
1352                 return;
1353         }
1354 }
1355  * @endcode
1356  */
1357 int notification_get_pkgname(notification_h noti, char **pkgname);
1358
1359
1360 /**
1361  * @brief Adds a button on the notification.
1362  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
1363  * @param[in] noti Notification handle
1364  * @param[in] button_index Button index
1365  * @return #NOTIFICATION_ERROR_NONE on success,
1366  *         otherwise a negative error value
1367  * @retval NOTIFICATION_ERROR_NONE Success
1368  * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
1369  * @par Sample code:
1370  * @code
1371 #include <notification.h>
1372
1373 {
1374         notification_h noti = NULL;
1375         int noti_err = NOTIFICATION_ERROR_NONE;
1376         char *pkgname = NULL;
1377
1378         // Do something
1379
1380         noti_err = notification_add_button(noti, NOTIFICATION_BUTTON_1);
1381
1382         if (noti_err != NOTIFICATION_ERROR_NONE) {
1383                 notification_free(noti);
1384                 return;
1385         }
1386 }
1387  * @endcode
1388  */
1389 int notification_add_button(notification_h noti, notification_button_index_e button_index);
1390
1391 /**
1392  * @brief Removes a button on the notification.
1393  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
1394  * @param[in] noti Notification handle
1395  * @param[in] button_index Button index
1396  * @return #NOTIFICATION_ERROR_NONE on success,
1397  *         otherwise a negative error value
1398  * @retval NOTIFICATION_ERROR_NONE Success
1399  * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
1400  * @par Sample code:
1401  * @code
1402 #include <notification.h>
1403
1404 {
1405         notification_h noti = NULL;
1406         int noti_err = NOTIFICATION_ERROR_NONE;
1407         char *pkgname = NULL;
1408
1409         // Do something
1410
1411         noti_err = notification_remove_button(noti, NOTIFICATION_BUTTON_1);
1412
1413         if (noti_err != NOTIFICATION_ERROR_NONE) {
1414                 notification_free(noti);
1415                 return;
1416         }
1417 }
1418  * @endcode
1419  */
1420 int notification_remove_button(notification_h noti, notification_button_index_e button_index);
1421
1422
1423 /**
1424  * @brief Sets the 'auto remove' option of the active notification.
1425  * @details The 'auto remove' option lets the active notification be removed several seconds after it shows. Default value is true.
1426  * @remarks When 'auto_remove' is set as false, the active notification will not be removed
1427  *          as long as the user removes the active notification or the app which posted the active notification removes the active notification.
1428  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
1429  * @param[in] noti Notification handle
1430  * @param[in] auto_remove Auto remove option
1431  * @return #NOTIFICATION_ERROR_NONE On success,
1432  *         other value if failure
1433  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
1434  * @see #notification_h
1435  * @see #notification_get_auto_remove
1436  * @par Sample code:
1437  * @code
1438 #include <notification.h>
1439
1440 {
1441         notification_h noti = NULL;
1442         int noti_err = NOTIFICATION_ERROR_NONE;
1443
1444         // Do something
1445
1446         noti_err = notification_set_auto_remove(noti, false);
1447         if (noti_err != NOTIFICATION_ERROR_NONE)
1448                 return;
1449
1450 }
1451  * @endcode
1452  */
1453 int notification_set_auto_remove(notification_h noti, bool auto_remove);
1454
1455
1456 /**
1457  * @brief Gets the 'auto remove' option of the active notification.
1458  * @details The 'auto remove' option lets the active notification be removed several seconds after it shows. Default value is true.
1459  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
1460  * @param[in] noti Notification handle
1461  * @param[out] auto_remove Auto remove option
1462  * @return #NOTIFICATION_ERROR_NONE On success, other value on failure
1463  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
1464  * @see #notification_h
1465  * @see #notification_get_auto_remove
1466  * @par Sample code:
1467  * @code
1468 #include <notification.h>
1469
1470 {
1471         int noti_err = NOTIFICATION_ERROR_NONE;
1472         bool auto_remove;
1473
1474         // Do something
1475
1476         noti_err = notification_get_auto_remove(noti, &auto_remove);
1477         if (noti_err != NOTIFICATION_ERROR_NONE)
1478                 return;
1479
1480 }
1481  * @endcode
1482  */
1483 int notification_get_auto_remove(notification_h noti, bool *auto_remove);
1484
1485
1486 /**
1487  * @brief Saves a notification template to the notification database.
1488  * @details An application can save the created notification as a template for later reuse.
1489  *          If the template has the same name as a saved one, the saved template will be overwritten.
1490  *          A saved template can be loaded only by the application which saved it.
1491  *          All templates are removed when the application package is uninstalled.
1492  * @since_tizen 3.0
1493  * @privlevel public
1494  * @privilege %http://tizen.org/privilege/notification
1495  * @remarks The number of templates is limited to 10.
1496  *          When you try to add more than 10 templates, #NOTIFICATION_ERROR_MAX_EXCEEDED will be returned.
1497  * @param[in] noti Notification handle
1498  * @param[in] template_name Template name
1499  * @return #NOTIFICATION_ERROR_NONE On success, other value on failure
1500  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
1501  * @retval #NOTIFICATION_ERROR_IO_ERROR I/O error
1502  * @retval #NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
1503  * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The Permission denied
1504  * @retval #NOTIFICATION_ERROR_MAX_EXCEEDED Max notification count exceeded
1505  * @see #notification_h
1506  * @see notification_create_from_template()
1507  * @par Sample code:
1508  * @code
1509 #include <notification.h>
1510
1511 {
1512         int noti_err = NOTIFICATION_ERROR_NONE;
1513         notification_h noti = NULL;
1514
1515         noti = notification_create(NOTIFICATION_TYPE_NOTI);
1516         if (noti == NULL)
1517                 return;
1518
1519         // add the content you want to use for the template.
1520
1521         noti_err = notification_save_as_template(noti, "CALL_ACCEPT");
1522         if (noti_err != NOTIFICATION_ERROR_NONE)
1523                 return;
1524
1525         noti_err = notification_free(noti);
1526         if (noti_err != NOTIFICATION_ERROR_NONE)
1527                 return;
1528 }
1529  * @endcode
1530  */
1531 int notification_save_as_template(notification_h noti, const char *template_name);
1532
1533
1534 /**
1535  * @brief Loads a notification template from the notification database.
1536  * @details An application can load a saved template and post it.
1537  *          An application can load only templates that it has saved.
1538  * @since_tizen 3.0
1539  * @privlevel public
1540  * @privilege %http://tizen.org/privilege/notification
1541  * @remarks The returned handle should be destroyed using notification_free().
1542  *          The specific error code can be obtained using get_last_result().
1543  *          Error codes are described in the Exception section.
1544  *          If an invalid template name is given, the result will be set to #NOTIFICATION_ERROR_FROM_DB.
1545  * @param[in] template_name Template name
1546  * @return Notification handle on success, NULL on failure
1547  * @exception #NOTIFICATION_ERROR_NONE Success
1548  * @exception #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
1549  * @exception #NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
1550  * @exception #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
1551  * @exception #NOTIFICATION_ERROR_FROM_DB Error from DB query
1552  * @see #notification_h
1553  * @see notification_save_as_template()
1554  * @par Sample code:
1555  * @code
1556 #include <notification.h>
1557
1558 {
1559         notification_h noti = NULL;
1560
1561         noti = notification_create_from_template("CALL_ACCEPT");
1562         if (noti == NULL)
1563                 return;
1564
1565 }
1566  * @endcode
1567  */
1568 notification_h notification_create_from_template(const char *template_name);
1569
1570
1571 /**
1572  * @brief Gets notification block state.
1573  * @details     The user can set the notification block state in settings.
1574  *              The block state indicates whether or not notifications can be posted.
1575  *              Additionally only notifications to the notification panel are
1576  *              allowed in "Do not disturb mode". Sound, Vibrate and
1577  *              Active/Instant notifications are blocked.
1578  * @since_tizen 3.0
1579  * @privlevel public
1580  * @privilege %http://tizen.org/privilege/notification
1581  * @param[out] state Notification block state
1582  * @return #NOTIFICATION_ERROR_NONE On success, other value on failure
1583  * @retval #NOTIFICATION_ERROR_NONE Success
1584  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
1585  * @retval #NOTIFICATION_ERROR_OUT_OF_MEMORY out of memory
1586  * @retval #NOTIFICATION_ERROR_IO_ERROR I/O Error
1587  * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED Permission denied
1588  * @retval #NOTIFICATION_ERROR_SERVICE_NOT_READY No response from notification service
1589  * @see #notification_block_state_e
1590  * @par Sample code:
1591  * @code
1592 #include <notification.h>
1593
1594 {
1595         int noti_err = NOTIFICATION_ERROR_NONE;
1596         notification_block_state_e state;
1597
1598         // Do something
1599
1600         noti_err = notification_get_noti_block_state(&state);
1601         if (noti_err != NOTIFICATION_ERROR_NONE)
1602                 return;
1603
1604 }
1605  * @endcode
1606  */
1607 int notification_get_noti_block_state(notification_block_state_e *state);
1608
1609
1610 /**
1611  * @brief Sets a text input box to reply directly on the notification.
1612  * @details When you add a text input to the active notification, the notification UI will show a text input with a button.
1613  *          So, the user can enter any text and press the button to confirm the text as a input.
1614  *          You can edit some UI component that is related to the text input.
1615  *          First, you can add placeholder text to guide the user using notification_set_text() with #NOTIFICATION_TEXT_TYPE_TEXT_INPUT_PLACEHOLDER type.
1616  *          You also can edit button for the text input.
1617  *          For setting just a text to the button, you can set the text using notification_set_text() with #NOTIFICATION_TEXT_TYPE_TEXT_INPUT_BUTTON type.
1618  *          If you want to show image button, you can set an image for the button using notification_set_image() with #NOTIFICATION_IMAGE_TYPE_TEXT_INPUT_BUTTON type.
1619  *
1620  *          Note that you should set an app_control for handling the event for user input using notification_set_event_handler().
1621  *          #NOTIFICATION_EVENT_TYPE_CLICK_ON_TEXT_INPUT_BUTTON is the event type for the text input.
1622  *          You can get the text the user enters in the app_control handle that is passed as a result of the event.
1623  *          The app_control will contain APP_CONTROL_DATA_TEXT key, so you can get the text using app_control_get_extra_data() using APP_CONTROL_DATA_TEXT key.
1624  *          The value will contain the text user enters.
1625  *
1626  *          Note that you are able to make the switching button to the text input box.
1627  *          You have to set the app_control which you will set in a text input box to the switching button.
1628  *          Refer to the second sample code.
1629  * @since_tizen 3.0
1630  * @param[in] noti Notification handle
1631  * @param[in] text_input_max_length The maximum value which can be inputted
1632  * @return #NOTIFICATION_ERROR_NONE on success,
1633  *         otherwise any other value on failure
1634  * @retval #NOTIFICATION_ERROR_NONE         Success
1635  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
1636  * @par Sample code:
1637  * @code
1638 #include <notification.h>
1639
1640 {
1641         int noti_err = NOTIFICATION_ERROR_NONE;
1642         notification_h noti = NULL;
1643         app_control = NULL;
1644
1645         noti = notification_create(NOTIFICATION_TYPE_NOTI);
1646         if (noti == NULL)
1647                 return;
1648
1649         noti_err = notification_set_text_input(noti, 160);
1650         if (noti_err != NOTIFICATION_ERROR_NONE)
1651                 return;
1652
1653         noti_err = notification_set_text(noti,
1654                         NOTIFICATION_TEXT_TYPE_TEXT_INPUT_PLACEHOLDER,
1655                         "Text message",
1656                         NULL,
1657                         NOTIFICATION_VARIABLE_TYPE_NONE);
1658         if (noti_err != NOTIFICATION_ERROR_NONE)
1659                 return;
1660
1661         noti_err = notification_set_text(noti,
1662                         NOTIFICATION_TEXT_TYPE_TEXT_INPUT_BUTTON,
1663                         "SEND",
1664                         NULL,
1665                         NOTIFICATION_VARIABLE_TYPE_NONE);
1666         if (noti_err != NOTIFICATION_ERROR_NONE)
1667                 return;
1668
1669         noti_err = notification_set_display_applist(noti,
1670                         NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_ACTIVE);
1671         if (noti_err != NOTIFICATION_ERROR_NONE)
1672                 return;
1673
1674         // Do something
1675
1676         noti_err = app_control_create(&app_control);
1677         if (noti_err != APP_CONTROL_ERROR_NONE)
1678                 return;
1679
1680         noti_err = app_control_set_app_id(app_control, appid);
1681         if (noti_err != APP_CONTROL_ERROR_NONE)
1682                 return;
1683
1684         noti_err = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
1685         if (noti_err != APP_CONTROL_ERROR_NONE)
1686                 return;
1687
1688         noti_err = notification_set_event_handler(noti,
1689                         NOTIFICATION_EVENT_TYPE_CLICK_ON_TEXT_INPUT_BUTTON,
1690                         app_control);
1691         if (noti_err != NOTIFICATION_ERROR_NONE)
1692                 return;
1693
1694         noti_err = app_control_destroy(app_control);
1695         if (noti_err != APP_CONTROL_ERROR_NONE)
1696                 return;
1697
1698         noti_err  = notification_post(noti);
1699         if(noti_err != NOTIFICATION_ERROR_NONE)
1700                 return;
1701
1702 }
1703
1704
1705 {
1706         int noti_err = NOTIFICATION_ERROR_NONE;
1707         notification_h noti = NULL;
1708         app_control = NULL;
1709
1710         noti = notification_create(NOTIFICATION_TYPE_NOTI);
1711         if (noti == NULL) {
1712                 return;
1713         }
1714
1715         noti_err = notification_set_text_input(noti, 160);
1716         if (noti_err != NOTIFICATION_ERROR_NONE)
1717                 return;
1718
1719         noti_err = notification_set_text(noti,
1720                         NOTIFICATION_TEXT_TYPE_TEXT_INPUT_PLACEHOLDER,
1721                         "Text message",
1722                         NULL,
1723                         NOTIFICATION_VARIABLE_TYPE_NONE);
1724         if (noti_err != NOTIFICATION_ERROR_NONE)
1725                 return;
1726
1727         noti_err = notification_set_text(noti,
1728                         NOTIFICATION_TEXT_TYPE_TEXT_INPUT_BUTTON,
1729                         "SEND",
1730                         NULL,
1731                         NOTIFICATION_VARIABLE_TYPE_NONE);
1732         if (noti_err != NOTIFICATION_ERROR_NONE)
1733                 return;
1734
1735         noti_err = notification_add_button(notification, NOTIFICATION_BUTTON_1);
1736         if (noti_err != NOTIFICATION_ERROR_NONE)
1737                 return;
1738
1739         noti_err = notification_set_text(notification,
1740                         NOTIFICATION_TEXT_TYPE_BUTTON_1,
1741                         "reply",
1742                         NULL,
1743                         NOTIFICATION_VARIABLE_TYPE_NONE);
1744         if (noti_err != NOTIFICATION_ERROR_NONE)
1745                 return;
1746
1747         noti_err = notification_set_display_applist(noti,
1748                         NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_ACTIVE);
1749         if (noti_err != NOTIFICATION_ERROR_NONE)
1750                 return;
1751
1752         // Do something
1753
1754         noti_err = app_control_create(&app_control);
1755         if (noti_err != APP_CONTROL_ERROR_NONE)
1756                 return;
1757
1758         noti_err = app_control_set_app_id(app_control, appid);
1759         if (noti_err != APP_CONTROL_ERROR_NONE)
1760                 return;
1761
1762         noti_err = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
1763         if (noti_err != APP_CONTROL_ERROR_NONE)
1764                 return;
1765
1766         noti_err = notification_set_event_handler(notification,
1767                         NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1,
1768                         app_control);
1769         if (noti_err != NOTIFICATION_ERROR_NONE)
1770                 return;
1771
1772         noti_err = notification_set_event_handler(noti,
1773                         NOTIFICATION_EVENT_TYPE_CLICK_ON_TEXT_INPUT_BUTTON,
1774                         app_control);
1775         if (noti_err != NOTIFICATION_ERROR_NONE)
1776                 return;
1777
1778         noti_err = app_control_destroy(app_control);
1779         if (noti_err != APP_CONTROL_ERROR_NONE)
1780                 return;
1781
1782         noti_err  = notification_post(noti);
1783         if(noti_err != NOTIFICATION_ERROR_NONE)
1784                 return;
1785 }
1786  * @endcode
1787  */
1788 int notification_set_text_input(notification_h noti, int text_input_max_length);
1789
1790
1791 /**
1792  * @brief Sets the image height for the extended notification.
1793  * @details The image is shown under the notification's text. The application can set the image height.
1794  *          The image is modified to fit into the height set by this function.
1795  *          The image can be scaled down and/or cropped.
1796  *          If @a height is 0, the default value is used. The default height depends on the screen size.
1797  * @since_tizen 4.0
1798  * @param[in] noti   The notification handle
1799  * @param[in] height The image height
1800  * @return #NOTIFICATION_ERROR_NONE On success,
1801  *         otherwise a negative error value
1802  * @retval #NOTIFICATION_ERROR_NONE Success
1803  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
1804  * @see notification_get_extension_image_size()
1805  * @par Sample code:
1806  * @code
1807 #include <notification.h>
1808
1809 {
1810         notification_h noti = NULL;
1811         int noti_err = NOTIFICATION_ERROR_NONE;
1812
1813         noti = notification_create(NOTIFICATION_TYPE_NOTI);
1814         if (noti == NULL)
1815                 return;
1816
1817         noti_err = notification_set_text(noti,
1818                         NOTIFICATION_TEXT_TYPE_CONTENT_EXTENTION,
1819                         "message",
1820                         NULL,
1821                         NOTIFICATION_VARIABLE_TYPE_NONE);
1822         if (noti_err != NOTIFICATION_ERROR_NONE)
1823                 return;
1824
1825         noti_err = notification_set_image(noti,
1826                         NOTIFICATION_IMAGE_TYPE_EXTENTION,
1827                         image_path);
1828         if (noti_err != NOTIFICATION_ERROR_NONE)
1829                 return;
1830
1831         noti_err = notification_set_layout(noti, NOTIFICATION_LY_EXTENTION);
1832         if (noti_err != NOTIFICATION_ERROR_NONE)
1833                 return;
1834
1835         noti_err = notification_set_extension_image_size(noti, 20);
1836         if (noti_err != NOTIFICATION_ERROR_NONE)
1837                 return;
1838
1839         // Do something
1840 }
1841  * @endcode
1842  */
1843 int notification_set_extension_image_size(notification_h noti, int height);
1844
1845
1846 /**
1847  * @brief Gets the image height for the extended notification.
1848  * @since_tizen 4.0
1849  * @param[in] noti The notification handle
1850  * @param[out] height The image height
1851  * @return #NOTIFICATION_ERROR_NONE On success, otherwise a negative error value
1852  * @retval #NOTIFICATION_ERROR_NONE Success
1853  * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
1854  * @see notification_set_extension_image_size()
1855  * @par Sample code:
1856  * @code
1857 #include <notification.h>
1858
1859 {
1860         int noti_err = NOTIFICATION_ERROR_NONE;
1861         int height;
1862
1863         // Do something
1864
1865         noti_err = notification_get_extension_image_size(noti, &height);
1866         if (noti_err != NOTIFICATION_ERROR_NONE)
1867                 return;
1868 }
1869  * @endcode
1870  */
1871 int notification_get_extension_image_size(notification_h noti, int *height);
1872
1873 /**
1874  * @}
1875  */
1876
1877 #ifdef __cplusplus
1878 }
1879 #endif
1880 #endif /* __NOTIFICATION_H__ */
1881