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