4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
28 #include <dbus/dbus.h>
29 #include <dbus/dbus-glib-lowlevel.h>
32 #include <app_control_internal.h>
37 #include <vconf-keys.h>
40 #include <notification.h>
41 #include <notification_list.h>
42 #include <notification_debug.h>
43 #include <notification_private.h>
44 #include <notification_noti.h>
45 #include <notification_ongoing.h>
46 #include <notification_group.h>
47 #include <notification_ipc.h>
48 #include <notification_internal.h>
50 typedef struct _notification_cb_list notification_cb_list_s;
52 typedef enum __notification_cb_type {
53 NOTIFICATION_CB_NORMAL = 1,
54 NOTIFICATION_CB_DETAILED,
55 } _notification_cb_type_e;
57 struct _notification_cb_list {
58 notification_cb_list_s *prev;
59 notification_cb_list_s *next;
61 _notification_cb_type_e cb_type;
62 void (*changed_cb) (void *data, notification_type_e type);
63 void (*detailed_changed_cb) (void *data, notification_type_e type, notification_op *op_list, int num_op);
67 static notification_cb_list_s *g_notification_cb_list = NULL;
69 void notification_call_changed_cb(notification_op *op_list, int op_num)
71 notification_cb_list_s *noti_cb_list = NULL;
72 notification_type_e type = 0;
74 if (g_notification_cb_list == NULL)
77 noti_cb_list = g_notification_cb_list;
79 while (noti_cb_list->prev != NULL)
80 noti_cb_list = noti_cb_list->prev;
83 if (op_list == NULL) {
84 NOTIFICATION_ERR("invalid data");
88 notification_get_type(op_list->noti, &type);
90 while (noti_cb_list != NULL) {
91 if (noti_cb_list->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_list->changed_cb) {
92 noti_cb_list->changed_cb(noti_cb_list->data,
95 if (noti_cb_list->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_list->detailed_changed_cb) {
96 noti_cb_list->detailed_changed_cb(noti_cb_list->data,
97 type, op_list, op_num);
100 noti_cb_list = noti_cb_list->next;
104 EXPORT_API int notification_add_deferred_task(
105 void (*deferred_task_cb)(void *data), void *user_data)
107 if (deferred_task_cb == NULL)
108 return NOTIFICATION_ERROR_INVALID_PARAMETER;
110 return notification_ipc_add_deffered_task(deferred_task_cb, user_data);
113 EXPORT_API int notification_del_deferred_task(
114 void (*deferred_task_cb)(void *data))
116 if (deferred_task_cb == NULL)
117 return NOTIFICATION_ERROR_INVALID_PARAMETER;
119 return notification_ipc_del_deffered_task(deferred_task_cb);
122 EXPORT_API int notification_resister_changed_cb(void (*changed_cb)
123 (void *data, notification_type_e type),
126 notification_cb_list_s *noti_cb_list_new = NULL;
127 notification_cb_list_s *noti_cb_list = NULL;
129 if (changed_cb == NULL)
130 return NOTIFICATION_ERROR_INVALID_PARAMETER;
132 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE)
133 return NOTIFICATION_ERROR_IO_ERROR;
136 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
138 if (noti_cb_list_new == NULL) {
139 NOTIFICATION_ERR("malloc failed");
140 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
143 noti_cb_list_new->next = NULL;
144 noti_cb_list_new->prev = NULL;
146 noti_cb_list_new->cb_type = NOTIFICATION_CB_NORMAL;
147 noti_cb_list_new->changed_cb = changed_cb;
148 noti_cb_list_new->detailed_changed_cb = NULL;
149 noti_cb_list_new->data = user_data;
151 if (g_notification_cb_list == NULL) {
152 g_notification_cb_list = noti_cb_list_new;
154 noti_cb_list = g_notification_cb_list;
156 while (noti_cb_list->next != NULL)
157 noti_cb_list = noti_cb_list->next;
160 noti_cb_list->next = noti_cb_list_new;
161 noti_cb_list_new->prev = noti_cb_list;
163 return NOTIFICATION_ERROR_NONE;
166 EXPORT_API int notification_unresister_changed_cb(void (*changed_cb)
167 (void *data, notification_type_e type))
169 notification_cb_list_s *noti_cb_list = NULL;
170 notification_cb_list_s *noti_cb_list_prev = NULL;
171 notification_cb_list_s *noti_cb_list_next = NULL;
173 noti_cb_list = g_notification_cb_list;
175 if (changed_cb == NULL)
176 return NOTIFICATION_ERROR_INVALID_PARAMETER;
178 if (noti_cb_list == NULL)
179 return NOTIFICATION_ERROR_INVALID_PARAMETER;
181 while (noti_cb_list->prev != NULL)
182 noti_cb_list = noti_cb_list->prev;
186 if (noti_cb_list->changed_cb == changed_cb) {
187 noti_cb_list_prev = noti_cb_list->prev;
188 noti_cb_list_next = noti_cb_list->next;
190 if (noti_cb_list_prev == NULL)
191 g_notification_cb_list = noti_cb_list_next;
193 noti_cb_list_prev->next = noti_cb_list_next;
195 if (noti_cb_list_next == NULL) {
196 if (noti_cb_list_prev != NULL)
197 noti_cb_list_prev->next = NULL;
200 noti_cb_list_next->prev = noti_cb_list_prev;
205 if (g_notification_cb_list == NULL)
206 notification_ipc_monitor_fini();
208 return NOTIFICATION_ERROR_NONE;
210 noti_cb_list = noti_cb_list->next;
211 } while (noti_cb_list != NULL);
213 return NOTIFICATION_ERROR_INVALID_PARAMETER;
216 EXPORT_API int notification_update_progress(notification_h noti,
220 char *caller_pkgname = NULL;
221 int input_priv_id = 0;
223 double input_progress = 0.0;
225 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
227 return NOTIFICATION_ERROR_INVALID_PARAMETER;
229 input_priv_id = noti->priv_id;
232 input_priv_id = priv_id;
236 caller_pkgname = notification_get_pkgname_by_pid();
238 caller_pkgname = strdup(noti->caller_pkgname);
241 input_progress = 0.0;
242 else if (progress > 1.0)
243 input_progress = 1.0;
245 input_progress = progress;
247 ret = notification_ongoing_update_progress(caller_pkgname, input_priv_id,
251 free(caller_pkgname);
256 EXPORT_API int notification_update_size(notification_h noti,
260 char *caller_pkgname = NULL;
261 int input_priv_id = 0;
263 double input_size = 0.0;
265 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
267 return NOTIFICATION_ERROR_INVALID_PARAMETER;
269 input_priv_id = noti->priv_id;
271 input_priv_id = priv_id;
275 caller_pkgname = notification_get_pkgname_by_pid();
277 caller_pkgname = strdup(noti->caller_pkgname);
284 ret = notification_ongoing_update_size(caller_pkgname, input_priv_id,
288 free(caller_pkgname);
293 EXPORT_API int notification_update_content(notification_h noti,
297 char *caller_pkgname = NULL;
298 int input_priv_id = 0;
301 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
303 return NOTIFICATION_ERROR_INVALID_PARAMETER;
305 input_priv_id = noti->priv_id;
308 input_priv_id = priv_id;
312 caller_pkgname = notification_get_pkgname_by_pid();
314 caller_pkgname = strdup(noti->caller_pkgname);
316 ret = notification_ongoing_update_content(caller_pkgname, input_priv_id,
320 free(caller_pkgname);
325 /* notification_set_icon will be removed */
326 EXPORT_API int notification_set_icon(notification_h noti,
327 const char *icon_path)
329 int ret_err = NOTIFICATION_ERROR_NONE;
332 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
338 /* notification_get_icon will be removed */
339 EXPORT_API int notification_get_icon(notification_h noti,
342 int ret_err = NOTIFICATION_ERROR_NONE;
343 char *ret_image_path = NULL;
346 notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
349 if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL)
350 *icon_path = ret_image_path;
355 EXPORT_API int notification_set_title(notification_h noti,
357 const char *loc_title)
359 int noti_err = NOTIFICATION_ERROR_NONE;
361 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
363 NOTIFICATION_VARIABLE_TYPE_NONE);
368 EXPORT_API int notification_get_title(notification_h noti,
372 int noti_err = NOTIFICATION_ERROR_NONE;
373 char *ret_text = NULL;
376 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
382 if (loc_title != NULL)
388 EXPORT_API int notification_set_content(notification_h noti,
390 const char *loc_content)
392 int noti_err = NOTIFICATION_ERROR_NONE;
394 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
395 content, loc_content,
396 NOTIFICATION_VARIABLE_TYPE_NONE);
401 EXPORT_API int notification_get_content(notification_h noti,
405 int noti_err = NOTIFICATION_ERROR_NONE;
406 char *ret_text = NULL;
409 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
415 if (loc_content != NULL)
423 (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
425 if (ret == -1 || boolval == 0) {
426 if (content != NULL && noti->default_content != NULL)
427 *content = noti->default_content;
429 if (loc_content != NULL && noti->loc_default_content != NULL)
430 *loc_content = noti->loc_default_content;
435 EXPORT_API int notification_set_application(notification_h noti,
438 if (noti == NULL || pkgname == NULL)
439 return NOTIFICATION_ERROR_INVALID_PARAMETER;
441 if (noti->launch_pkgname)
442 free(noti->launch_pkgname);
444 noti->launch_pkgname = strdup(pkgname);
446 return NOTIFICATION_ERROR_NONE;
449 EXPORT_API int notification_get_application(notification_h noti,
452 if (noti == NULL || pkgname == NULL)
453 return NOTIFICATION_ERROR_INVALID_PARAMETER;
455 if (noti->launch_pkgname)
456 *pkgname = noti->launch_pkgname;
458 *pkgname = noti->caller_pkgname;
460 return NOTIFICATION_ERROR_NONE;
463 EXPORT_API int notification_set_args(notification_h noti,
467 if (noti == NULL || args == NULL)
468 return NOTIFICATION_ERROR_INVALID_PARAMETER;
471 bundle_free(noti->args);
473 noti->args = bundle_dup(args);
475 if (noti->group_args) {
476 bundle_free(noti->group_args);
477 noti->group_args = NULL;
480 if (group_args != NULL)
481 noti->group_args = bundle_dup(group_args);
483 return NOTIFICATION_ERROR_NONE;
486 EXPORT_API int notification_get_args(notification_h noti,
488 bundle ** group_args)
490 if (noti == NULL || args == NULL)
491 return NOTIFICATION_ERROR_INVALID_PARAMETER;
498 if (group_args != NULL && noti->group_args)
499 *group_args = noti->group_args;
501 return NOTIFICATION_ERROR_NONE;
504 EXPORT_API int notification_get_grouping_list(notification_type_e type, int count,
505 notification_list_h * list)
507 notification_list_h get_list = NULL;
511 return NOTIFICATION_ERROR_INVALID_PARAMETER;
513 ret = notification_noti_get_grouping_list(type, count, &get_list);
514 if (ret != NOTIFICATION_ERROR_NONE)
519 return NOTIFICATION_ERROR_NONE;
522 EXPORT_API int notification_delete_group_by_group_id(const char *pkgname,
523 notification_type_e type,
527 char *caller_pkgname = NULL;
530 caller_pkgname = notification_get_pkgname_by_pid();
532 caller_pkgname = strdup(pkgname);
534 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
535 if (ret != NOTIFICATION_ERROR_NONE) {
537 free(caller_pkgname);
543 free(caller_pkgname);
545 return NOTIFICATION_ERROR_NONE;
548 EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
549 notification_type_e type,
553 char *caller_pkgname = NULL;
556 caller_pkgname = notification_get_pkgname_by_pid();
558 caller_pkgname = strdup(pkgname);
560 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
561 if (ret != NOTIFICATION_ERROR_NONE) {
563 free(caller_pkgname);
569 free(caller_pkgname);
571 return NOTIFICATION_ERROR_NONE;
574 EXPORT_API int notification_get_count(notification_type_e type,
577 int priv_id, int *count)
583 return NOTIFICATION_ERROR_INVALID_PARAMETER;
586 notification_noti_get_count(type, pkgname, group_id, priv_id,
588 if (ret != NOTIFICATION_ERROR_NONE)
593 return NOTIFICATION_ERROR_NONE;
596 EXPORT_API int notification_clear(notification_type_e type)
600 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
601 return NOTIFICATION_ERROR_INVALID_PARAMETER;
603 ret = notification_ipc_request_delete_multiple(type, NULL);
608 EXPORT_API int notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
611 if (noti_op == NULL || data == NULL)
612 return NOTIFICATION_ERROR_INVALID_PARAMETER;
615 case NOTIFICATION_OP_DATA_TYPE:
616 *((int*)data) = noti_op->type;
618 case NOTIFICATION_OP_DATA_PRIV_ID:
619 *((int*)data) = noti_op->priv_id;
621 case NOTIFICATION_OP_DATA_NOTI:
622 *((notification_h *)data) = noti_op->noti;
624 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
625 *((int*)data) = noti_op->extra_info_1;
627 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
628 *((int*)data) = noti_op->extra_info_2;
631 return NOTIFICATION_ERROR_INVALID_PARAMETER;
635 return NOTIFICATION_ERROR_NONE;
638 EXPORT_API int notification_set_pkgname(notification_h noti,
641 /* check noti and pkgname are valid data */
642 if (noti == NULL || pkgname == NULL)
643 return NOTIFICATION_ERROR_INVALID_PARAMETER;
645 /* Remove previous caller pkgname */
646 if (noti->caller_pkgname) {
647 free(noti->caller_pkgname);
648 noti->caller_pkgname = NULL;
651 noti->caller_pkgname = strdup(pkgname);
653 return NOTIFICATION_ERROR_NONE;
656 EXPORT_API int notification_delete_all_by_type(const char *pkgname,
657 notification_type_e type)
660 char *caller_pkgname = NULL;
662 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
663 return NOTIFICATION_ERROR_INVALID_PARAMETER;
666 caller_pkgname = notification_get_pkgname_by_pid();
668 caller_pkgname = strdup(pkgname);
670 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
673 free(caller_pkgname);
678 EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
679 notification_type_e type,
683 char *caller_pkgname = NULL;
685 if (priv_id <= NOTIFICATION_PRIV_ID_NONE)
686 return NOTIFICATION_ERROR_INVALID_PARAMETER;
689 caller_pkgname = notification_get_pkgname_by_pid();
691 caller_pkgname = strdup(pkgname);
693 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
696 free(caller_pkgname);
701 EXPORT_API int notification_set_execute_option(notification_h noti,
702 notification_execute_type_e type,
705 bundle *service_handle)
707 char buf_key[32] = { 0, };
708 char *ret_val = NULL;
712 return NOTIFICATION_ERROR_INVALID_PARAMETER;
714 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
715 || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
716 return NOTIFICATION_ERROR_INVALID_PARAMETER;
718 /* Create execute option bundle if does not exist */
719 if (noti->b_execute_option == NULL)
720 noti->b_execute_option = bundle_create();
722 b = noti->b_execute_option;
727 snprintf(buf_key, sizeof(buf_key), "text%d", type);
729 /* Check text key exist */
730 bundle_get_str(b, buf_key, &ret_val);
732 /* Remove previous data */
733 bundle_del(b, buf_key);
736 bundle_add_str(b, buf_key, text);
742 snprintf(buf_key, sizeof(buf_key), "key%d", type);
744 /* Check key key exist */
745 bundle_get_str(b, buf_key, &ret_val);
747 /* Remove previous data */
748 bundle_del(b, buf_key);
751 bundle_add_str(b, buf_key, key);
755 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
756 /* Remove previous data if exist */
757 if (noti->b_service_responding != NULL) {
758 bundle_free(noti->b_service_responding);
759 noti->b_service_responding = NULL;
762 /* Save service handle */
763 if (service_handle != NULL)
764 noti->b_service_responding = bundle_dup(service_handle);
767 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
768 /* Remove previous data if exist */
769 if (noti->b_service_single_launch != NULL) {
770 bundle_free(noti->b_service_single_launch);
771 noti->b_service_single_launch = NULL;
774 /* Save service handle */
775 if (service_handle != NULL)
776 noti->b_service_single_launch =
777 bundle_dup(service_handle);
780 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
781 /* Remove previous data if exist */
782 if (noti->b_service_multi_launch != NULL) {
783 bundle_free(noti->b_service_multi_launch);
784 noti->b_service_multi_launch = NULL;
787 /* Save service handle */
788 if (service_handle != NULL)
789 noti->b_service_multi_launch =
790 bundle_dup(service_handle);
795 return NOTIFICATION_ERROR_NONE;
798 EXPORT_API int notification_get_id(notification_h noti,
799 int *group_id, int *priv_id)
801 /* check noti is valid data */
803 return NOTIFICATION_ERROR_INVALID_PARAMETER;
805 /* Check group_id is valid data */
808 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE)
809 *group_id = NOTIFICATION_GROUP_ID_NONE;
811 *group_id = noti->group_id;
814 /* Check priv_id is valid data */
817 *priv_id = noti->priv_id;
819 return NOTIFICATION_ERROR_NONE;
822 EXPORT_API notification_h notification_load(char *pkgname,
826 notification_h noti = NULL;
828 noti = (notification_h) calloc(1, sizeof(struct _notification));
830 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
834 ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id);
835 if (ret != NOTIFICATION_ERROR_NONE) {
836 notification_free(noti);
843 EXPORT_API notification_h notification_new(notification_type_e type,
844 int group_id, int priv_id)
846 return notification_create(type);
849 static void _notification_get_text_domain(notification_h noti)
852 if (noti->domain != NULL) {
856 if (noti->dir != NULL) {
862 EXPORT_API int notification_get_execute_option(notification_h noti,
863 notification_execute_type_e type,
865 bundle **service_handle)
867 char buf_key[32] = { 0, };
868 char *ret_val = NULL;
869 char *get_str = NULL;
873 return NOTIFICATION_ERROR_INVALID_PARAMETER;
875 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
876 || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
877 return NOTIFICATION_ERROR_INVALID_PARAMETER;
881 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
882 b = noti->b_service_responding;
884 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
885 b = noti->b_service_single_launch;
887 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
888 b = noti->b_service_multi_launch;
897 /* Get text domain and dir */
898 if (noti->domain == NULL || noti->dir == NULL)
899 _notification_get_text_domain(noti);
902 snprintf(buf_key, sizeof(buf_key), "key%d", type);
904 /* Check key key exist */
905 bundle_get_str(b, buf_key, &ret_val);
906 if (ret_val != NULL && noti->domain != NULL
907 && noti->dir != NULL) {
908 /* Get application string */
909 bindtextdomain(noti->domain, noti->dir);
911 get_str = dgettext(noti->domain, ret_val);
914 } else if (ret_val != NULL) {
915 /* Get system string */
916 get_str = dgettext("sys_string", ret_val);
921 snprintf(buf_key, sizeof(buf_key), "text%d",
924 bundle_get_str(b, buf_key, &ret_val);
931 if (service_handle != NULL)
934 return NOTIFICATION_ERROR_NONE;
937 EXPORT_API int notification_insert(notification_h noti,
943 /* Check noti is vaild data */
945 return NOTIFICATION_ERROR_INVALID_PARAMETER;
947 /* Check noti type is valid type */
948 if (noti->type <= NOTIFICATION_TYPE_NONE
949 || noti->type >= NOTIFICATION_TYPE_MAX)
950 return NOTIFICATION_ERROR_INVALID_PARAMETER;
952 /* Save insert time */
953 noti->insert_time = time(NULL);
954 ret = notification_ipc_request_insert(noti, &id);
955 if (ret != NOTIFICATION_ERROR_NONE)
959 NOTIFICATION_DBG("from master:%d", id);
961 /* If priv_id is valid data, set priv_id */
963 *priv_id = noti->priv_id;
965 return NOTIFICATION_ERROR_NONE;
968 EXPORT_API int notification_update_async(notification_h noti,
969 void (*result_cb)(int priv_id, int result, void *data), void *user_data)
974 return NOTIFICATION_ERROR_INVALID_PARAMETER;
976 /* Update insert time ? */
977 noti->insert_time = time(NULL);
978 ret = notification_ipc_request_update_async(noti, result_cb, user_data);
983 EXPORT_API int notification_register_detailed_changed_cb(
984 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
987 notification_cb_list_s *noti_cb_list_new = NULL;
988 notification_cb_list_s *noti_cb_list = NULL;
990 if (detailed_changed_cb == NULL)
991 return NOTIFICATION_ERROR_INVALID_PARAMETER;
993 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE)
994 return NOTIFICATION_ERROR_IO_ERROR;
997 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
999 if (noti_cb_list_new == NULL) {
1000 NOTIFICATION_ERR("malloc failed");
1001 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
1004 noti_cb_list_new->next = NULL;
1005 noti_cb_list_new->prev = NULL;
1007 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
1008 noti_cb_list_new->changed_cb = NULL;
1009 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
1010 noti_cb_list_new->data = user_data;
1012 if (g_notification_cb_list == NULL) {
1013 g_notification_cb_list = noti_cb_list_new;
1015 noti_cb_list = g_notification_cb_list;
1017 while (noti_cb_list->next != NULL)
1018 noti_cb_list = noti_cb_list->next;
1021 noti_cb_list->next = noti_cb_list_new;
1022 noti_cb_list_new->prev = noti_cb_list;
1024 return NOTIFICATION_ERROR_NONE;
1027 EXPORT_API int notification_unregister_detailed_changed_cb(
1028 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
1031 notification_cb_list_s *noti_cb_list = NULL;
1032 notification_cb_list_s *noti_cb_list_prev = NULL;
1033 notification_cb_list_s *noti_cb_list_next = NULL;
1035 noti_cb_list = g_notification_cb_list;
1037 if (detailed_changed_cb == NULL)
1038 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1040 if (noti_cb_list == NULL)
1041 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1044 while (noti_cb_list->prev != NULL)
1045 noti_cb_list = noti_cb_list->prev;
1049 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
1050 noti_cb_list_prev = noti_cb_list->prev;
1051 noti_cb_list_next = noti_cb_list->next;
1053 if (noti_cb_list_prev == NULL)
1054 g_notification_cb_list = noti_cb_list_next;
1056 noti_cb_list_prev->next = noti_cb_list_next;
1058 if (noti_cb_list_next == NULL) {
1059 if (noti_cb_list_prev != NULL)
1060 noti_cb_list_prev->next = NULL;
1063 noti_cb_list_next->prev = noti_cb_list_prev;
1068 if (g_notification_cb_list == NULL)
1069 notification_ipc_monitor_fini();
1071 return NOTIFICATION_ERROR_NONE;
1073 noti_cb_list = noti_cb_list->next;
1074 } while (noti_cb_list != NULL);
1076 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1079 EXPORT_API int notification_is_service_ready(void)
1081 return notification_ipc_is_master_ready();