2 * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __NOTIFICATION_INTERNAL_H__
18 #define __NOTIFICATION_INTERNAL_H__
20 #include <notification_error.h>
21 #include <notification_type.h>
22 #include <notification_list.h>
29 * @addtogroup NOTIFICATION_INTERNAL
32 #define NOTIFICATION_GLOBAL_UID -1
33 #define NOTIFICATION_DISPLAY_APP_HEADS_UP NOTIFICATION_DISPLAY_APP_ACTIVE /* To avoid build error */
34 #define NOTIFICATION_ERROR (notification_error_quark())
35 GQuark notification_error_quark(void);
38 * @brief This function add deferred task. the registered task will be executed when notification service become ready
39 * @param[in] deferred_task_cb The callback function
40 * @param[in] user_data The user data to be passed to the callback function
41 * @return #NOTIFICATION_ERROR_NONE if success, other value if failure
42 * @see #notification_error_e
43 * @see notification_is_service_ready()
45 int notification_add_deferred_task(
46 void (*deferred_task_cb)(void *data), void *user_data);
49 * @brief This function remove deferred task.
50 * @param[in] deferred_task_cb The callback function
51 * @return #NOTIFICATION_ERROR_NONE if success, other value if failure
52 * @see #notification_error_e
53 * @see notification_is_service_ready()
55 int notification_del_deferred_task(
56 void (*deferred_task_cb)(void *data));
60 notification_resister_changed_cb_for_uid(
61 void (*changed_cb)(void *data, notification_type_e type),
62 void *user_data, uid_t uid);
65 * @brief This function will be removed.
66 * @see notification_unresister_changed_cb()
69 notification_resister_changed_cb(
70 void (*changed_cb)(void *data, notification_type_e type),
74 * @brief This function will be removed.
75 * @see notification_resister_changed_cb()
78 notification_unresister_changed_cb(
79 void (*changed_cb)(void *data, notification_type_e type));
82 * @brief Updates the progress of the inserted notification. This only works for the ongoing notification (NOTIFICATION_TYPE_ONGOING).
83 * @details The Notification view on the notification area could be updated.
84 * @param[in] noti Notification handle or NULL if priv_id is valid
85 * @param[in] priv_id Private ID
86 * @param[in] progress Percentage value of progressive data
87 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
88 * @retval NOTIFICATION_ERROR_NONE Success
89 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
92 #include <notification.h>
95 int noti_err = NOTIFICATION_ERROR_NONE;
97 noti_err = notification_update_progress(NULL, APP_NOTI_PRIV_ID, 0.6);
98 if(noti_err != NOTIFICATION_ERROR_NONE) {
104 int notification_update_progress(notification_h noti,
109 * @brief Updates the size of inserted notification data. This only works for the ongoing notification (NOTIFICATION_TYPE_ONGOING).
110 * @details Notification view on notification area could be updated.
111 * @param[in] noti Notification handle or NULL if priv_id is valid
112 * @param[in] priv_id Private ID
113 * @param[in] size Bytes of progressive data
114 * @return NOTIFICATION_ERROR_NONE if success, other value if failure
115 * @retval NOTIFICATION_ERROR_NONE Success
116 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
119 #include <notification.h>
122 int noti_err = NOTIFICATION_ERROR_NONE;
124 noti_err = notification_update_size(NULL, APP_NOTI_PRIV_ID, 3000000);
125 if(noti_err != NOTIFICATION_ERROR_NONE) {
131 int notification_update_size(notification_h noti,
132 int priv_id, double size);
135 * @brief Updates the content of the inserted notification data. This is only for the ongoing notification (NOTIFICATION_TYPE_ONGOING).
136 * @details Notification view on notification area could be updated.
137 * @param[in] noti Notification handle or NULL if priv_id is valid
138 * @param[in] priv_id Private ID
139 * @param[in] content Text to update
140 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
141 * @retval NOTIFICATION_ERROR_NONE Success
142 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
145 #include <notification.h>
148 int noti_err = NOTIFICATION_ERROR_NONE;
150 noti_err = notification_update_content(NULL, APP_NOTI_PRIV_ID, "updated string");
151 if(noti_err != NOTIFICATION_ERROR_NONE) {
157 int notification_update_content(notification_h noti,
159 const char *content);
162 * @brief This function will be deprecated.
163 * @see notification_set_image()
166 NOTIFICATION_DEPRECATED_API int notification_set_icon(notification_h noti,
167 const char *icon_path);
170 * @brief This function will be deprecated.
171 * @see notification_get_image()
174 NOTIFICATION_DEPRECATED_API int notification_get_icon(notification_h noti,
178 * @brief This function will be deprecated.
179 * @see notification_set_text()
182 NOTIFICATION_DEPRECATED_API int notification_set_title(notification_h noti,
184 const char *loc_title);
187 * @brief This function will be deprecated.
188 * @see notification_get_text()
191 NOTIFICATION_DEPRECATED_API int notification_get_title(notification_h noti,
196 * @brief This function will be deprecated.
197 * @see notification_set_text()
200 NOTIFICATION_DEPRECATED_API int notification_set_content(notification_h noti,
202 const char *loc_content);
205 * @brief This function will be deprecated.
206 * @see notification_get_text()
209 NOTIFICATION_DEPRECATED_API int notification_get_content(notification_h noti,
214 * @brief This function will be removed.
215 * @see notification_set_execute_option()
218 NOTIFICATION_DEPRECATED_API int notification_set_application(notification_h noti, const char *pkgname); /* Do not use this */
221 * @brief This function will be removed.
222 * @see notification_get_execute_option()
225 NOTIFICATION_DEPRECATED_API int notification_get_application(notification_h noti, char **pkgname); /* Do not use this */
228 * @brief This function will be deprecated.
229 * @see notification_set_execute_option()
232 NOTIFICATION_DEPRECATED_API int notification_set_args(notification_h noti, bundle *args, bundle *group_args); /* Do not use this */
235 * @brief This function will be deprecated.
236 * @see notification_get_execute_option()
239 NOTIFICATION_DEPRECATED_API int notification_get_args(notification_h noti, bundle **args, bundle **group_args); /* Do not use this */
242 * @brief This function is deprecated.
243 * @see notification_get_grouping_list()
246 NOTIFICATION_DEPRECATED_API int notification_get_grouping_list(notification_type_e type,
248 notification_list_h *list);
251 * @brief This function will be deprecated.
252 * @see notification_delete_by_priv_id()
255 NOTIFICATION_DEPRECATED_API int notification_delete_group_by_group_id(const char *pkgname,
256 notification_type_e type,
260 * @brief This function will be deprecated.
261 * @see notification_delete_by_priv_id()
264 NOTIFICATION_DEPRECATED_API int notification_delete_group_by_priv_id(const char *pkgname,
265 notification_type_e type,
268 * @brief This function will be deprecated.
271 NOTIFICATION_DEPRECATED_API int notification_get_count(notification_type_e type,
273 int group_id, int priv_id,
277 * @brief This function will be deprecated.
280 NOTIFICATION_DEPRECATED_API int notifiation_clear(notification_type_e type);
284 * @brief This function will be deprecated.
285 * @details Use only for the notification tray's clear button operation.
286 * @param[in] type Notification type
287 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
288 * @retval NOTIFICATION_ERROR_NONE Success
289 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
290 * @see #notification_type_e
293 #include <notification.h>
296 int noti_err = NOTIFICATION_ERROR_NONE;
298 noti_err = notification_clear(NOTIFICATION_TYPE_NOTI);
299 if(noti_err != NOTIFICATION_ERROR_NONE) {
305 NOTIFICATION_DEPRECATED_API int notification_clear(notification_type_e type);
309 * @brief This function will be deprecated.
310 * @return 1 on ready, other value on not ready
312 NOTIFICATION_DEPRECATED_API int notification_is_service_ready(void);
316 * @brief This function will be deprecated.
317 * @param[in] list Notification list handle
318 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
319 * @retval NOTIFICATION_ERROR_NONE Success
320 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
321 * @pre notification_get_grouping_list() or notification_get_detail_list().
322 * @see #notification_op
324 NOTIFICATION_DEPRECATED_API int notification_op_get_data(notification_op *noti_op,
325 notification_op_data_type_e type,
330 * @brief This function will be deprecated.
331 * @details Caller_pkgname is set automatically when notification_new() is called. We do not recommend to use this API.
332 * @param[in] noti Notification handle
333 * @param[in] pkgname Caller package name
334 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
335 * @retval NOTIFICATION_ERROR_NONE Success
336 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
339 #include <notification.h>
342 notification_h noti = NULL;
343 int noti_err = NOTIFICATION_ERROR_NONE;
345 noti = notification_new(NOTIFICATION_TYPE_NOTI, APP_GROUP_ID, NOTIFICATION_PRIV_ID_NONE);
350 noti_err = notification_set_pkgname(noti, "org.tizen.phone");
351 if(noti_err != NOTIFICATION_ERROR_NONE) {
352 notification_free(noti);
358 NOTIFICATION_DEPRECATED_API int notification_set_pkgname(notification_h noti,
359 const char *pkgname);
363 * @brief This function will be deprecated.
364 * @details If @a pkgname is NULL, caller_pkgname is set internally.
365 * @param[in] pkgname Caller application package name or NULL
366 * @param[in] type Notification type
367 * @return NOTIFICATION_ERROR_NONE if success, other value if failure
368 * @retval NOTIFICATION_ERROR_NONE Success
369 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
372 #include <notification.h>
375 int noti_err = NOTIFICATION_ERROR_NONE;
377 noti_err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI);
378 if(noti_err != NOTIFICATION_ERROR_NONE) {
384 NOTIFICATION_DEPRECATED_API int notification_delete_all_by_type(const char *pkgname,
385 notification_type_e type);
389 * @brief This function will be deprecated.
390 * @details If @a pkgname is NULL, caller_pkgname is set internally.
391 * @param[in] pkgname Caller application package name or NULL
392 * @param[in] type Notification type
393 * @param[in] priv_id Priv ID
394 * @return NOTIFICATION_ERROR_NONE if success, other value if failure
395 * @retval NOTIFICATION_ERROR_NONE Success
396 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
399 #include <notification.h>
402 int noti_err = NOTIFICATION_ERROR_NONE;
404 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, APP_PRIV_ID);
405 if(noti_err != NOTIFICATION_ERROR_NONE) {
411 NOTIFICATION_DEPRECATED_API int notification_delete_by_priv_id(const char *pkgname,
412 notification_type_e type,
417 * @brief This function will be deprecated.
418 * @details When notification data selected in display application, application launched by appsvc_run_service with service_handle.
419 * @param[in] noti Notification handle
420 * @param[in] type Notification execute type
421 * @param[in] text Basic text for button
422 * @param[in] key Value for localized text
423 * @param[in] service_handle Appsvc bundle data
424 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
425 * @retval NOTIFICATION_ERROR_NONE Success
426 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
429 #include <notification.h>
432 notification_h noti = NULL;
433 int noti_err = NOTIFICATION_ERROR_NONE;
439 appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
440 appsvc_set_uri(b,"http://www.samsung.com");
442 noti_err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, b);
443 if(noti_err != NOTIFICATION_ERROR_NONE) {
444 notification_free(noti);
452 NOTIFICATION_DEPRECATED_API int notification_set_execute_option(notification_h noti,
453 notification_execute_type_e type,
456 bundle *service_handle);
460 * @brief This function will be deprecated.
461 * @remarks ID is valid only after inserting the notification.
462 * @param[in] noti Notification handle
463 * @param[out] group_id Group ID
464 * @param[out] priv_id Private ID
465 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
466 * @retval NOTIFICATION_ERROR_NONE Success
467 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
470 #include <notification.h>
473 int noti_err = NOTIFICATION_ERROR_NONE;
474 int group_id, priv_id;
476 noti_err = notification_get_id(noti, &group_id, &priv_id);
477 if(noti_err != NOTIFICATION_ERROR_NONE) {
483 NOTIFICATION_DEPRECATED_API int notification_get_id(notification_h noti,
484 int *group_id, int *priv_id);
488 * @brief This function will be deprecated.
489 * @param[in] type Notification type
490 * @param[in] group_id Group ID
491 * @param[in] priv_id Priv ID
492 * @return Notification handle(#notification_h) on success, NULL on failure
493 * @retval #notification_h Success
494 * @retval NULL Failure
495 * @see #notification_type_e
496 * @see #notification_h
499 #include <notification.h>
502 notification_h noti = NULL;
504 noti = notification_load("org.tizen.app", priv_id);
512 NOTIFICATION_DEPRECATED_API notification_h notification_load(char *pkgname,
517 * @brief This function will be deprecated.
518 * @details Available types are #NOTIFICATION_TYPE_NOTI and #NOTIFICATION_TYPE_ONGOING.
519 * #NOTIFICATION_TYPE_NOTI is remaining notification data even if device is restarted.
520 * #NOTIFICATION_TYPE_ONGOING can display progressive feather, but notification data is removed after device is restarted.
521 * If group_id is #NOTIFICATION_GROUP_ID_NONE, notification data is not grouped. #NOTIFICATION_GROUP_ID_DEFAULT,
522 * notification data is grouped with same title. Positive number ( > 0 ) is grouped with same number.
523 * If priv_id is #NOTIFICATION_PRIV_ID_NONE, priv_id is set internally and return it when notification_insert() call.
524 * Positive number and zero ( >= 0 ) is application set private ID. These ID should have be unique each application package.
525 * @param[in] type Notification type
526 * @param[in] group_id Group ID
527 * @param[in] priv_id Priv ID
528 * @return Notification handle(#notification_h) on success, NULL on failure
529 * @retval #notification_h Success
530 * @retval NULL Failure
531 * @see #notification_type_e
532 * @see #notification_h
535 #include <notification.h>
538 notification_h noti = NULL;
540 noti = notification_new(NOTIFICATION_TYPE_NOTI, APP_GROUP_ID, NOTIFICATION_PRIV_ID_NONE);
548 NOTIFICATION_DEPRECATED_API notification_h notification_new(notification_type_e type, int group_id,
553 * @brief This function will be deprecated.
554 * @param[in] noti Notification handle
555 * @param[in] type Notification execute type
556 * @param[out] text Text for button
557 * @param[out] service_handle Appsvc bundle data
558 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
559 * @retval NOTIFICATION_ERROR_NONE Success
560 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
563 #include <notification.h>
566 notification_h noti = NULL;
567 int noti_err = NOTIFICATION_ERROR_NONE;
572 noti_err = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, &b);
573 if(noti_err != NOTIFICATION_ERROR_NONE) {
574 notification_free(noti);
580 NOTIFICATION_DEPRECATED_API int notification_get_execute_option(notification_h noti,
581 notification_execute_type_e type,
583 bundle **service_handle);
587 * @brief Inserts a notification.
588 * @details The notification will be inserted to the database and then it will appear in the notification area.
589 * When notification_create() is called, if priv_id is #NOTIFICATION_PRIV_ID_NONE, priv_id returns the internally set priv_id.
590 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
592 * @privilege %http://tizen.org/privilege/notification
593 * @param[in] noti The notification handle
594 * @param[out] priv_id The private ID
595 * @return #NOTIFICATION_ERROR_NONE on success,
596 * otherwise any other value on failure
597 * @retval #NOTIFICATION_ERROR_NONE Success
598 * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
599 * @retval NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
600 * @pre Notification handle should be created by notification_create().
601 * @post notification_free().
604 #include <notification.h>
607 int noti_err = NOTIFICATION_ERROR_NONE;
609 noti_err = notification_insert(noti, NULL);
610 if(noti_err != NOTIFICATION_ERROR_NONE) {
616 int notification_insert(notification_h noti,
619 int notification_insert_for_uid(notification_h noti,
620 int *priv_id, uid_t uid);
624 * @brief Updates a notification, asynchronously.
625 * @details The updated notification will appear in the notification area.
626 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
628 * @privilege %http://tizen.org/privilege/notification
629 * @remarks This function updates the notification asynchronously.
630 * @param[in] noti The notification handle that is created by notification_create()
631 * @param[in] result_cb The callback called when an update completed
632 * @param[in] user_data The user data which you want to use in callback
633 * @return #NOTIFICATION_ERROR_NONE on success,
634 * otherwise any other value on failure
635 * @retval #NOTIFICATION_ERROR_NONE Success
636 * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
637 * @retval #NOTIFICATION_ERROR_NOT_EXIST_ID Priv ID does not exist
638 * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
641 #include <notification.h>
644 int noti_err = NOTIFICATION_ERROR_NONE;
646 noti_err = notification_update_async(NULL, result_cb, data);
647 if(noti_err != NOTIFICATION_ERROR_NONE) {
653 int notification_update_async(notification_h noti,
654 void (*result_cb)(int priv_id, int result, void *data), void *user_data);
655 int notification_update_async_for_uid(notification_h noti,
656 void (*result_cb)(int priv_id, int result, void *data), void *user_data, uid_t uid);
660 * @brief Registers a callback for all notification events.
661 * @details The registered callback could be called for all notification events.
662 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
664 * @privilege %http://tizen.org/privilege/notification
665 * @param[in] changed_cb The callback function
666 * @param[in] user_data The user data
667 * @return #NOTIFICATION_ERROR_NONE on success,
668 * otherwise any other value on failure
669 * @retval #NOTIFICATION_ERROR_NONE Success
670 * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
671 * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
672 * @see notification_unregister_detailed_changed_cb()
675 #include <notification.h>
678 noti_err = notification_register_detailed_changed_cb(app_changed_cb, user_data);
679 if(noti_err != NOTIFICATION_ERROR_NONE) {
685 int notification_register_detailed_changed_cb(
686 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
688 int notification_register_detailed_changed_cb_for_uid(
689 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
690 void *user_data, uid_t uid);
694 * @brief Unregisters a callback for all notification events.
695 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
697 * @privilege %http://tizen.org/privilege/notification
698 * @param[in] changed_cb The callback function
699 * @return #NOTIFICATION_ERROR_NONE on success,
700 * otherwise any other value on failure
701 * @retval #NOTIFICATION_ERROR_NONE Success
702 * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
703 * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
704 * @see notification_register_detailed_changed_cb()
707 #include <notification.h>
710 noti_err = notification_register_detailed_changed_cb(app_changed_cb, user_data);
711 if(noti_err != NOTIFICATION_ERROR_NONE) {
717 int notification_unregister_detailed_changed_cb(
718 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
722 * @brief This function translate localized texts
723 * @param[in] noti The notification handle that is created by notification_create()
724 * @return #NOTIFICATION_ERROR_NONE if success, other value if failure
725 * @see notification_create()
727 int notification_translate_localized_text(notification_h noti);
728 int notification_set_uid(notification_h noti, uid_t uid);
729 int notification_get_uid(notification_h noti, uid_t *uid);
730 int notification_post_for_uid(notification_h noti, uid_t uid);
731 int notification_update_for_uid(notification_h noti, uid_t uid);
732 int notification_delete_for_uid(notification_h noti, uid_t uid);
733 int notification_delete_all_for_uid(notification_type_e type, uid_t uid);
734 notification_h notification_load_by_tag_for_uid(const char *tag, uid_t uid);