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
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));
59 * @brief This function will be removed.
60 * @see notification_unresister_changed_cb()
63 notification_resister_changed_cb(
64 void (*changed_cb)(void *data, notification_type_e type),
68 * @brief This function will be removed.
69 * @see notification_resister_changed_cb()
72 notification_unresister_changed_cb(
73 void (*changed_cb)(void *data, notification_type_e type));
76 * @brief Updates the progress of the inserted notification. This only works for the ongoing notification (NOTIFICATION_TYPE_ONGOING).
77 * @details The Notification view on the notification area could be updated.
78 * @param[in] noti Notification handle or NULL if priv_id is valid
79 * @param[in] priv_id Private ID
80 * @param[in] progress Percentage value of progressive data
81 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
82 * @retval NOTIFICATION_ERROR_NONE Success
83 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
86 #include <notification.h>
89 int noti_err = NOTIFICATION_ERROR_NONE;
91 noti_err = notification_update_progress(NULL, APP_NOTI_PRIV_ID, 0.6);
92 if(noti_err != NOTIFICATION_ERROR_NONE) {
98 int notification_update_progress(notification_h noti,
103 * @brief Updates the size of inserted notification data. This only works for the ongoing notification (NOTIFICATION_TYPE_ONGOING).
104 * @details Notification view on notification area could be updated.
105 * @param[in] noti Notification handle or NULL if priv_id is valid
106 * @param[in] priv_id Private ID
107 * @param[in] size Bytes of progressive data
108 * @return NOTIFICATION_ERROR_NONE if success, other value if failure
109 * @retval NOTIFICATION_ERROR_NONE Success
110 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
113 #include <notification.h>
116 int noti_err = NOTIFICATION_ERROR_NONE;
118 noti_err = notification_update_size(NULL, APP_NOTI_PRIV_ID, 3000000);
119 if(noti_err != NOTIFICATION_ERROR_NONE) {
125 int notification_update_size(notification_h noti,
126 int priv_id, double size);
129 * @brief Updates the content of the inserted notification data. This is only for the ongoing notification (NOTIFICATION_TYPE_ONGOING).
130 * @details Notification view on notification area could be updated.
131 * @param[in] noti Notification handle or NULL if priv_id is valid
132 * @param[in] priv_id Private ID
133 * @param[in] content Text to update
134 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
135 * @retval NOTIFICATION_ERROR_NONE Success
136 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
139 #include <notification.h>
142 int noti_err = NOTIFICATION_ERROR_NONE;
144 noti_err = notification_update_content(NULL, APP_NOTI_PRIV_ID, "updated string");
145 if(noti_err != NOTIFICATION_ERROR_NONE) {
151 int notification_update_content(notification_h noti,
153 const char *content);
156 * @brief This function will be deprecated.
157 * @see notification_set_image()
160 NOTIFICATION_DEPRECATED_API int notification_set_icon(notification_h noti,
161 const char *icon_path);
164 * @brief This function will be deprecated.
165 * @see notification_get_image()
168 NOTIFICATION_DEPRECATED_API int notification_get_icon(notification_h noti,
172 * @brief This function will be deprecated.
173 * @see notification_set_text()
176 NOTIFICATION_DEPRECATED_API int notification_set_title(notification_h noti,
178 const char *loc_title);
181 * @brief This function will be deprecated.
182 * @see notification_get_text()
185 NOTIFICATION_DEPRECATED_API int notification_get_title(notification_h noti,
190 * @brief This function will be deprecated.
191 * @see notification_set_text()
194 NOTIFICATION_DEPRECATED_API int notification_set_content(notification_h noti,
196 const char *loc_content);
199 * @brief This function will be deprecated.
200 * @see notification_get_text()
203 NOTIFICATION_DEPRECATED_API int notification_get_content(notification_h noti,
208 * @brief This function will be removed.
209 * @see notification_set_execute_option()
212 NOTIFICATION_DEPRECATED_API int notification_set_application(notification_h noti, const char *pkgname); /* Do not use this */
215 * @brief This function will be removed.
216 * @see notification_get_execute_option()
219 NOTIFICATION_DEPRECATED_API int notification_get_application(notification_h noti, char **pkgname); /* Do not use this */
222 * @brief This function will be deprecated.
223 * @see notification_set_execute_option()
226 NOTIFICATION_DEPRECATED_API int notification_set_args(notification_h noti, bundle *args, bundle *group_args); /* Do not use this */
229 * @brief This function will be deprecated.
230 * @see notification_get_execute_option()
233 NOTIFICATION_DEPRECATED_API int notification_get_args(notification_h noti, bundle **args, bundle **group_args); /* Do not use this */
236 * @brief This function is deprecated.
237 * @see notification_get_grouping_list()
240 NOTIFICATION_DEPRECATED_API int notification_get_grouping_list(notification_type_e type,
242 notification_list_h *list);
245 * @brief This function will be deprecated.
246 * @see notification_delete_by_priv_id()
249 NOTIFICATION_DEPRECATED_API int notification_delete_group_by_group_id(const char *pkgname,
250 notification_type_e type,
254 * @brief This function will be deprecated.
255 * @see notification_delete_by_priv_id()
258 NOTIFICATION_DEPRECATED_API int notification_delete_group_by_priv_id(const char *pkgname,
259 notification_type_e type,
262 * @brief This function will be deprecated.
265 NOTIFICATION_DEPRECATED_API int notification_get_count(notification_type_e type,
267 int group_id, int priv_id,
271 * @brief This function will be deprecated.
274 NOTIFICATION_DEPRECATED_API int notifiation_clear(notification_type_e type);
278 * @brief This function will be deprecated.
279 * @details Use only for the notification tray's clear button operation.
280 * @param[in] type Notification type
281 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
282 * @retval NOTIFICATION_ERROR_NONE Success
283 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
284 * @see #notification_type_e
287 #include <notification.h>
290 int noti_err = NOTIFICATION_ERROR_NONE;
292 noti_err = notification_clear(NOTIFICATION_TYPE_NOTI);
293 if(noti_err != NOTIFICATION_ERROR_NONE) {
299 NOTIFICATION_DEPRECATED_API int notification_clear(notification_type_e type);
303 * @brief This function will be deprecated.
304 * @return 1 on ready, other value on not ready
306 NOTIFICATION_DEPRECATED_API int notification_is_service_ready(void);
310 * @brief This function will be deprecated.
311 * @param[in] list Notification list handle
312 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
313 * @retval NOTIFICATION_ERROR_NONE Success
314 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
315 * @pre notification_get_grouping_list() or notification_get_detail_list().
316 * @see #notification_op
318 NOTIFICATION_DEPRECATED_API int notification_op_get_data(notification_op *noti_op,
319 notification_op_data_type_e type,
324 * @brief This function will be deprecated.
325 * @details Caller_pkgname is set automatically when notification_new() is called. We do not recommend to use this API.
326 * @param[in] noti Notification handle
327 * @param[in] pkgname Caller package name
328 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
329 * @retval NOTIFICATION_ERROR_NONE Success
330 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
333 #include <notification.h>
336 notification_h noti = NULL;
337 int noti_err = NOTIFICATION_ERROR_NONE;
339 noti = notification_new(NOTIFICATION_TYPE_NOTI, APP_GROUP_ID, NOTIFICATION_PRIV_ID_NONE);
344 noti_err = notification_set_pkgname(noti, "org.tizen.phone");
345 if(noti_err != NOTIFICATION_ERROR_NONE) {
346 notification_free(noti);
352 NOTIFICATION_DEPRECATED_API int notification_set_pkgname(notification_h noti,
353 const char *pkgname);
357 * @brief This function will be deprecated.
358 * @details If @a pkgname is NULL, caller_pkgname is set internally.
359 * @param[in] pkgname Caller application package name or NULL
360 * @param[in] type Notification type
361 * @return NOTIFICATION_ERROR_NONE if success, other value if failure
362 * @retval NOTIFICATION_ERROR_NONE Success
363 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
366 #include <notification.h>
369 int noti_err = NOTIFICATION_ERROR_NONE;
371 noti_err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI);
372 if(noti_err != NOTIFICATION_ERROR_NONE) {
378 NOTIFICATION_DEPRECATED_API int notification_delete_all_by_type(const char *pkgname,
379 notification_type_e type);
383 * @brief This function will be deprecated.
384 * @details If @a pkgname is NULL, caller_pkgname is set internally.
385 * @param[in] pkgname Caller application package name or NULL
386 * @param[in] type Notification type
387 * @param[in] priv_id Priv ID
388 * @return NOTIFICATION_ERROR_NONE if success, other value if failure
389 * @retval NOTIFICATION_ERROR_NONE Success
390 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
393 #include <notification.h>
396 int noti_err = NOTIFICATION_ERROR_NONE;
398 noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, APP_PRIV_ID);
399 if(noti_err != NOTIFICATION_ERROR_NONE) {
405 NOTIFICATION_DEPRECATED_API int notification_delete_by_priv_id(const char *pkgname,
406 notification_type_e type,
411 * @brief This function will be deprecated.
412 * @details When notification data selected in display application, application launched by appsvc_run_service with service_handle.
413 * @param[in] noti Notification handle
414 * @param[in] type Notification execute type
415 * @param[in] text Basic text for button
416 * @param[in] key Value for localized text
417 * @param[in] service_handle Appsvc bundle data
418 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
419 * @retval NOTIFICATION_ERROR_NONE Success
420 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
423 #include <notification.h>
426 notification_h noti = NULL;
427 int noti_err = NOTIFICATION_ERROR_NONE;
433 appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
434 appsvc_set_uri(b,"http://www.samsung.com");
436 noti_err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, b);
437 if(noti_err != NOTIFICATION_ERROR_NONE) {
438 notification_free(noti);
446 NOTIFICATION_DEPRECATED_API int notification_set_execute_option(notification_h noti,
447 notification_execute_type_e type,
450 bundle *service_handle);
454 * @brief This function will be deprecated.
455 * @remarks ID is valid only after inserting the notification.
456 * @param[in] noti Notification handle
457 * @param[out] group_id Group ID
458 * @param[out] priv_id Private ID
459 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
460 * @retval NOTIFICATION_ERROR_NONE Success
461 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
464 #include <notification.h>
467 int noti_err = NOTIFICATION_ERROR_NONE;
468 int group_id, priv_id;
470 noti_err = notification_get_id(noti, &group_id, &priv_id);
471 if(noti_err != NOTIFICATION_ERROR_NONE) {
477 NOTIFICATION_DEPRECATED_API int notification_get_id(notification_h noti,
478 int *group_id, int *priv_id);
482 * @brief This function will be deprecated.
483 * @param[in] type Notification type
484 * @param[in] group_id Group ID
485 * @param[in] priv_id Priv ID
486 * @return Notification handle(#notification_h) on success, NULL on failure
487 * @retval #notification_h Success
488 * @retval NULL Failure
489 * @see #notification_type_e
490 * @see #notification_h
493 #include <notification.h>
496 notification_h noti = NULL;
498 noti = notification_load("org.tizen.app", priv_id);
506 NOTIFICATION_DEPRECATED_API notification_h notification_load(char *pkgname,
511 * @brief This function will be deprecated.
512 * @details Available types are #NOTIFICATION_TYPE_NOTI and #NOTIFICATION_TYPE_ONGOING.
513 * #NOTIFICATION_TYPE_NOTI is remaining notification data even if device is restarted.
514 * #NOTIFICATION_TYPE_ONGOING can display progressive feather, but notification data is removed after device is restarted.
515 * If group_id is #NOTIFICATION_GROUP_ID_NONE, notification data is not grouped. #NOTIFICATION_GROUP_ID_DEFAULT,
516 * notification data is grouped with same title. Positive number ( > 0 ) is grouped with same number.
517 * If priv_id is #NOTIFICATION_PRIV_ID_NONE, priv_id is set internally and return it when notification_insert() call.
518 * Positive number and zero ( >= 0 ) is application set private ID. These ID should have be unique each application package.
519 * @param[in] type Notification type
520 * @param[in] group_id Group ID
521 * @param[in] priv_id Priv ID
522 * @return Notification handle(#notification_h) on success, NULL on failure
523 * @retval #notification_h Success
524 * @retval NULL Failure
525 * @see #notification_type_e
526 * @see #notification_h
529 #include <notification.h>
532 notification_h noti = NULL;
534 noti = notification_new(NOTIFICATION_TYPE_NOTI, APP_GROUP_ID, NOTIFICATION_PRIV_ID_NONE);
542 NOTIFICATION_DEPRECATED_API notification_h notification_new(notification_type_e type, int group_id,
547 * @brief This function will be deprecated.
548 * @param[in] noti Notification handle
549 * @param[in] type Notification execute type
550 * @param[out] text Text for button
551 * @param[out] service_handle Appsvc bundle data
552 * @return NOTIFICATION_ERROR_NONE on success, other value on failure
553 * @retval NOTIFICATION_ERROR_NONE Success
554 * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
557 #include <notification.h>
560 notification_h noti = NULL;
561 int noti_err = NOTIFICATION_ERROR_NONE;
566 noti_err = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, &b);
567 if(noti_err != NOTIFICATION_ERROR_NONE) {
568 notification_free(noti);
574 NOTIFICATION_DEPRECATED_API int notification_get_execute_option(notification_h noti,
575 notification_execute_type_e type,
577 bundle **service_handle);
581 * @brief Inserts a notification.
582 * @details The notification will be inserted to the database and then it will appear in the notification area.
583 * When notification_create() is called, if priv_id is #NOTIFICATION_PRIV_ID_NONE, priv_id returns the internally set priv_id.
584 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
586 * @privilege %http://tizen.org/privilege/notification
587 * @param[in] noti The notification handle
588 * @param[out] priv_id The private ID
589 * @return #NOTIFICATION_ERROR_NONE on success,
590 * otherwise any other value on failure
591 * @retval #NOTIFICATION_ERROR_NONE Success
592 * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
593 * @retval NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
594 * @pre Notification handle should be created by notification_create().
595 * @post notification_free().
598 #include <notification.h>
601 int noti_err = NOTIFICATION_ERROR_NONE;
603 noti_err = notification_insert(noti, NULL);
604 if(noti_err != NOTIFICATION_ERROR_NONE) {
610 int notification_insert(notification_h noti,
615 * @brief Updates a notification, asynchronously.
616 * @details The updated notification will appear in the notification area.
617 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
619 * @privilege %http://tizen.org/privilege/notification
620 * @remarks This function updates the notification asynchronously.
621 * @param[in] noti The notification handle that is created by notification_create()
622 * @param[in] result_cb The callback called when an update completed
623 * @param[in] user_data The user data which you want to use in callback
624 * @return #NOTIFICATION_ERROR_NONE on success,
625 * otherwise any other value on failure
626 * @retval #NOTIFICATION_ERROR_NONE Success
627 * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
628 * @retval #NOTIFICATION_ERROR_NOT_EXIST_ID Priv ID does not exist
629 * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
632 #include <notification.h>
635 int noti_err = NOTIFICATION_ERROR_NONE;
637 noti_err = notification_update_async(NULL, result_cb, data);
638 if(noti_err != NOTIFICATION_ERROR_NONE) {
644 int notification_update_async(notification_h noti,
645 void (*result_cb)(int priv_id, int result, void *data), void *user_data);
649 * @brief Registers a callback for all notification events.
650 * @details The registered callback could be called for all notification events.
651 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
653 * @privilege %http://tizen.org/privilege/notification
654 * @param[in] changed_cb The callback function
655 * @param[in] user_data The user data
656 * @return #NOTIFICATION_ERROR_NONE on success,
657 * otherwise any other value on failure
658 * @retval #NOTIFICATION_ERROR_NONE Success
659 * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
660 * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
661 * @see notification_unregister_detailed_changed_cb()
664 #include <notification.h>
667 noti_err = notification_register_detailed_changed_cb(app_changed_cb, user_data);
668 if(noti_err != NOTIFICATION_ERROR_NONE) {
674 int notification_register_detailed_changed_cb(
675 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
680 * @brief Unregisters a callback for all notification events.
681 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
683 * @privilege %http://tizen.org/privilege/notification
684 * @param[in] changed_cb The callback function
685 * @return #NOTIFICATION_ERROR_NONE on success,
686 * otherwise any other value on failure
687 * @retval #NOTIFICATION_ERROR_NONE Success
688 * @retval #NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
689 * @retval #NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
690 * @see notification_register_detailed_changed_cb()
693 #include <notification.h>
696 noti_err = notification_register_detailed_changed_cb(app_changed_cb, user_data);
697 if(noti_err != NOTIFICATION_ERROR_NONE) {
703 int notification_unregister_detailed_changed_cb(
704 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
708 * @brief This function translate localized texts
709 * @param[in] noti The notification handle that is created by notification_create()
710 * @return #NOTIFICATION_ERROR_NONE if success, other value if failure
711 * @see notification_create()
713 int notification_translate_localized_text(notification_h noti);