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;
111 return notification_ipc_add_deffered_task(deferred_task_cb, user_data);
114 EXPORT_API int notification_del_deferred_task(
115 void (*deferred_task_cb)(void *data))
117 if (deferred_task_cb == NULL) {
118 return NOTIFICATION_ERROR_INVALID_PARAMETER;
121 return notification_ipc_del_deffered_task(deferred_task_cb);
124 EXPORT_API int notification_resister_changed_cb(void (*changed_cb)
125 (void *data, notification_type_e type),
128 notification_cb_list_s *noti_cb_list_new = NULL;
129 notification_cb_list_s *noti_cb_list = NULL;
131 if (changed_cb == NULL) {
132 return NOTIFICATION_ERROR_INVALID_PARAMETER;
134 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
135 return NOTIFICATION_ERROR_IO_ERROR;
139 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
141 if (noti_cb_list_new == NULL) {
142 NOTIFICATION_ERR("malloc failed");
143 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
146 noti_cb_list_new->next = NULL;
147 noti_cb_list_new->prev = NULL;
149 noti_cb_list_new->cb_type = NOTIFICATION_CB_NORMAL;
150 noti_cb_list_new->changed_cb = changed_cb;
151 noti_cb_list_new->detailed_changed_cb = NULL;
152 noti_cb_list_new->data = user_data;
154 if (g_notification_cb_list == NULL) {
155 g_notification_cb_list = noti_cb_list_new;
157 noti_cb_list = g_notification_cb_list;
159 while (noti_cb_list->next != NULL) {
160 noti_cb_list = noti_cb_list->next;
163 noti_cb_list->next = noti_cb_list_new;
164 noti_cb_list_new->prev = noti_cb_list;
166 return NOTIFICATION_ERROR_NONE;
169 EXPORT_API int notification_unresister_changed_cb(void (*changed_cb)
170 (void *data, notification_type_e type))
172 notification_cb_list_s *noti_cb_list = NULL;
173 notification_cb_list_s *noti_cb_list_prev = NULL;
174 notification_cb_list_s *noti_cb_list_next = NULL;
176 noti_cb_list = g_notification_cb_list;
178 if (changed_cb == NULL) {
179 return NOTIFICATION_ERROR_INVALID_PARAMETER;
181 if (noti_cb_list == NULL) {
182 return NOTIFICATION_ERROR_INVALID_PARAMETER;
185 while (noti_cb_list->prev != NULL) {
186 noti_cb_list = noti_cb_list->prev;
190 if (noti_cb_list->changed_cb == changed_cb) {
191 noti_cb_list_prev = noti_cb_list->prev;
192 noti_cb_list_next = noti_cb_list->next;
194 if (noti_cb_list_prev == NULL) {
195 g_notification_cb_list = noti_cb_list_next;
197 noti_cb_list_prev->next = noti_cb_list_next;
200 if (noti_cb_list_next == NULL) {
201 if (noti_cb_list_prev != NULL) {
202 noti_cb_list_prev->next = NULL;
205 noti_cb_list_next->prev = noti_cb_list_prev;
210 if (g_notification_cb_list == NULL)
211 notification_ipc_monitor_fini();
213 return NOTIFICATION_ERROR_NONE;
215 noti_cb_list = noti_cb_list->next;
216 } while (noti_cb_list != NULL);
218 return NOTIFICATION_ERROR_INVALID_PARAMETER;
221 EXPORT_API int notification_update_progress(notification_h noti,
225 char *caller_pkgname = NULL;
226 int input_priv_id = 0;
228 double input_progress = 0.0;
230 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
232 return NOTIFICATION_ERROR_INVALID_PARAMETER;
234 input_priv_id = noti->priv_id;
237 input_priv_id = priv_id;
241 caller_pkgname = notification_get_pkgname_by_pid();
243 caller_pkgname = strdup(noti->caller_pkgname);
246 if (progress < 0.0) {
247 input_progress = 0.0;
248 } else if (progress > 1.0) {
249 input_progress = 1.0;
251 input_progress = progress;
254 ret = notification_ongoing_update_progress(caller_pkgname, input_priv_id,
257 if (caller_pkgname) {
258 free(caller_pkgname);
264 EXPORT_API int notification_update_size(notification_h noti,
268 char *caller_pkgname = NULL;
269 int input_priv_id = 0;
271 double input_size = 0.0;
273 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
275 return NOTIFICATION_ERROR_INVALID_PARAMETER;
277 input_priv_id = noti->priv_id;
280 input_priv_id = priv_id;
284 caller_pkgname = notification_get_pkgname_by_pid();
286 caller_pkgname = strdup(noti->caller_pkgname);
295 ret = notification_ongoing_update_size(caller_pkgname, input_priv_id,
298 if (caller_pkgname) {
299 free(caller_pkgname);
305 EXPORT_API int notification_update_content(notification_h noti,
309 char *caller_pkgname = NULL;
310 int input_priv_id = 0;
313 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
315 return NOTIFICATION_ERROR_INVALID_PARAMETER;
317 input_priv_id = noti->priv_id;
320 input_priv_id = priv_id;
324 caller_pkgname = notification_get_pkgname_by_pid();
326 caller_pkgname = strdup(noti->caller_pkgname);
329 ret = notification_ongoing_update_content(caller_pkgname, input_priv_id,
332 if (caller_pkgname) {
333 free(caller_pkgname);
339 /* notification_set_icon will be removed */
340 EXPORT_API int notification_set_icon(notification_h noti,
341 const char *icon_path)
343 int ret_err = NOTIFICATION_ERROR_NONE;
346 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
352 /* notification_get_icon will be removed */
353 EXPORT_API int notification_get_icon(notification_h noti,
356 int ret_err = NOTIFICATION_ERROR_NONE;
357 char *ret_image_path = NULL;
360 notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
363 if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL) {
364 *icon_path = ret_image_path;
366 //NOTIFICATION_DBG("Get icon : %s", *icon_path);
372 EXPORT_API int notification_set_title(notification_h noti,
374 const char *loc_title)
376 int noti_err = NOTIFICATION_ERROR_NONE;
378 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
380 NOTIFICATION_VARIABLE_TYPE_NONE);
385 EXPORT_API int notification_get_title(notification_h noti,
389 int noti_err = NOTIFICATION_ERROR_NONE;
390 char *ret_text = NULL;
393 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
400 if (loc_title != NULL) {
407 EXPORT_API int notification_set_content(notification_h noti,
409 const char *loc_content)
411 int noti_err = NOTIFICATION_ERROR_NONE;
413 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
414 content, loc_content,
415 NOTIFICATION_VARIABLE_TYPE_NONE);
420 EXPORT_API int notification_get_content(notification_h noti,
424 int noti_err = NOTIFICATION_ERROR_NONE;
425 char *ret_text = NULL;
428 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
431 if (content != NULL) {
435 if (loc_content != NULL) {
444 (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
446 if (ret == -1 || boolval == 0) {
447 if (content != NULL && noti->default_content != NULL) {
448 *content = noti->default_content;
451 if (loc_content != NULL && noti->loc_default_content != NULL) {
452 *loc_content = noti->loc_default_content;
458 EXPORT_API int notification_set_application(notification_h noti,
461 if (noti == NULL || pkgname == NULL) {
462 return NOTIFICATION_ERROR_INVALID_PARAMETER;
465 if (noti->launch_pkgname) {
466 free(noti->launch_pkgname);
469 noti->launch_pkgname = strdup(pkgname);
471 return NOTIFICATION_ERROR_NONE;
474 EXPORT_API int notification_get_application(notification_h noti,
477 if (noti == NULL || pkgname == NULL) {
478 return NOTIFICATION_ERROR_INVALID_PARAMETER;
481 if (noti->launch_pkgname) {
482 *pkgname = noti->launch_pkgname;
484 *pkgname = noti->caller_pkgname;
487 return NOTIFICATION_ERROR_NONE;
490 EXPORT_API int notification_set_args(notification_h noti,
494 if (noti == NULL || args == NULL) {
495 return NOTIFICATION_ERROR_INVALID_PARAMETER;
499 bundle_free(noti->args);
502 noti->args = bundle_dup(args);
504 if (noti->group_args) {
505 bundle_free(noti->group_args);
506 noti->group_args = NULL;
509 if (group_args != NULL) {
510 noti->group_args = bundle_dup(group_args);
513 return NOTIFICATION_ERROR_NONE;
516 EXPORT_API int notification_get_args(notification_h noti,
518 bundle ** group_args)
520 if (noti == NULL || args == NULL) {
521 return NOTIFICATION_ERROR_INVALID_PARAMETER;
530 if (group_args != NULL && noti->group_args) {
531 *group_args = noti->group_args;
534 return NOTIFICATION_ERROR_NONE;
537 EXPORT_API int notification_get_grouping_list(notification_type_e type, int count,
538 notification_list_h * list)
540 notification_list_h get_list = NULL;
544 return NOTIFICATION_ERROR_INVALID_PARAMETER;
547 ret = notification_noti_get_grouping_list(type, count, &get_list);
548 if (ret != NOTIFICATION_ERROR_NONE) {
554 return NOTIFICATION_ERROR_NONE;
557 EXPORT_API int notification_delete_group_by_group_id(const char *pkgname,
558 notification_type_e type,
562 char *caller_pkgname = NULL;
564 if (pkgname == NULL) {
565 caller_pkgname = notification_get_pkgname_by_pid();
567 caller_pkgname = strdup(pkgname);
570 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
571 if (ret != NOTIFICATION_ERROR_NONE) {
572 if (caller_pkgname) {
573 free(caller_pkgname);
578 if (caller_pkgname) {
579 free(caller_pkgname);
581 return NOTIFICATION_ERROR_NONE;
584 EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
585 notification_type_e type,
589 char *caller_pkgname = NULL;
591 if (pkgname == NULL) {
592 caller_pkgname = notification_get_pkgname_by_pid();
594 caller_pkgname = strdup(pkgname);
597 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
598 if (ret != NOTIFICATION_ERROR_NONE) {
599 if (caller_pkgname) {
600 free(caller_pkgname);
605 if (caller_pkgname) {
606 free(caller_pkgname);
608 return NOTIFICATION_ERROR_NONE;
611 EXPORT_API int notification_get_count(notification_type_e type,
614 int priv_id, int *count)
620 return NOTIFICATION_ERROR_INVALID_PARAMETER;
624 notification_noti_get_count(type, pkgname, group_id, priv_id,
626 if (ret != NOTIFICATION_ERROR_NONE) {
632 return NOTIFICATION_ERROR_NONE;
635 EXPORT_API int notification_clear(notification_type_e type)
639 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
640 return NOTIFICATION_ERROR_INVALID_PARAMETER;
643 ret = notification_ipc_request_delete_multiple(type, NULL);
648 EXPORT_API int notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
651 if (noti_op == NULL || data == NULL) {
652 return NOTIFICATION_ERROR_INVALID_PARAMETER;
656 case NOTIFICATION_OP_DATA_TYPE:
657 *((int*)data) = noti_op->type;
659 case NOTIFICATION_OP_DATA_PRIV_ID:
660 *((int*)data) = noti_op->priv_id;
662 case NOTIFICATION_OP_DATA_NOTI:
663 *((notification_h *)data) = noti_op->noti;
665 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
666 *((int*)data) = noti_op->extra_info_1;
668 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
669 *((int*)data) = noti_op->extra_info_2;
672 return NOTIFICATION_ERROR_INVALID_PARAMETER;
676 return NOTIFICATION_ERROR_NONE;
679 EXPORT_API int notification_set_pkgname(notification_h noti,
682 /* check noti and pkgname are valid data */
683 if (noti == NULL || pkgname == NULL) {
684 return NOTIFICATION_ERROR_INVALID_PARAMETER;
687 /* Remove previous caller pkgname */
688 if (noti->caller_pkgname) {
689 free(noti->caller_pkgname);
690 noti->caller_pkgname = NULL;
693 noti->caller_pkgname = strdup(pkgname);
695 return NOTIFICATION_ERROR_NONE;
698 EXPORT_API int notification_delete_all_by_type(const char *pkgname,
699 notification_type_e type)
702 char *caller_pkgname = NULL;
704 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
705 return NOTIFICATION_ERROR_INVALID_PARAMETER;
708 if (pkgname == NULL) {
709 caller_pkgname = notification_get_pkgname_by_pid();
711 caller_pkgname = strdup(pkgname);
714 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
716 if (caller_pkgname) {
717 free(caller_pkgname);
723 EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
724 notification_type_e type,
728 char *caller_pkgname = NULL;
730 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
731 return NOTIFICATION_ERROR_INVALID_PARAMETER;
734 if (pkgname == NULL) {
735 caller_pkgname = notification_get_pkgname_by_pid();
737 caller_pkgname = strdup(pkgname);
740 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
742 if (caller_pkgname) {
743 free(caller_pkgname);
749 EXPORT_API int notification_set_execute_option(notification_h noti,
750 notification_execute_type_e type,
753 bundle *service_handle)
755 char buf_key[32] = { 0, };
756 char *ret_val = NULL;
760 return NOTIFICATION_ERROR_INVALID_PARAMETER;
763 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
764 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
765 return NOTIFICATION_ERROR_INVALID_PARAMETER;
768 /* Create execute option bundle if does not exist */
769 if (noti->b_execute_option == NULL) {
770 noti->b_execute_option = bundle_create();
773 b = noti->b_execute_option;
778 snprintf(buf_key, sizeof(buf_key), "text%d", type);
780 /* Check text key exist */
781 bundle_get_str(b, buf_key, &ret_val);
782 if (ret_val != NULL) {
783 /* Remove previous data */
784 bundle_del(b, buf_key);
788 bundle_add_str(b, buf_key, text);
794 snprintf(buf_key, sizeof(buf_key), "key%d", type);
796 /* Check key key exist */
797 bundle_get_str(b, buf_key, &ret_val);
798 if (ret_val != NULL) {
799 /* Remove previous data */
800 bundle_del(b, buf_key);
804 bundle_add_str(b, buf_key, key);
808 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
809 /* Remove previous data if exist */
810 if (noti->b_service_responding != NULL) {
811 bundle_free(noti->b_service_responding);
812 noti->b_service_responding = NULL;
815 /* Save service handle */
816 if (service_handle != NULL) {
817 noti->b_service_responding = bundle_dup(service_handle);
820 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
821 /* Remove previous data if exist */
822 if (noti->b_service_single_launch != NULL) {
823 bundle_free(noti->b_service_single_launch);
824 noti->b_service_single_launch = NULL;
827 /* Save service handle */
828 if (service_handle != NULL) {
829 noti->b_service_single_launch =
830 bundle_dup(service_handle);
833 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
834 /* Remove previous data if exist */
835 if (noti->b_service_multi_launch != NULL) {
836 bundle_free(noti->b_service_multi_launch);
837 noti->b_service_multi_launch = NULL;
840 /* Save service handle */
841 if (service_handle != NULL) {
842 noti->b_service_multi_launch =
843 bundle_dup(service_handle);
848 return NOTIFICATION_ERROR_NONE;
851 EXPORT_API int notification_get_id(notification_h noti,
852 int *group_id, int *priv_id)
854 /* check noti is valid data */
856 return NOTIFICATION_ERROR_INVALID_PARAMETER;
859 /* Check group_id is valid data */
862 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE) {
863 *group_id = NOTIFICATION_GROUP_ID_NONE;
865 *group_id = noti->group_id;
869 /* Check priv_id is valid data */
872 *priv_id = noti->priv_id;
875 return NOTIFICATION_ERROR_NONE;
878 EXPORT_API notification_h notification_load(char *pkgname,
882 notification_h noti = NULL;
884 noti = (notification_h) calloc(1, sizeof(struct _notification));
886 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
890 ret = notification_noti_get_by_priv_id(noti, pkgname, priv_id);
891 if (ret != NOTIFICATION_ERROR_NONE) {
892 notification_free(noti);
899 EXPORT_API notification_h notification_new(notification_type_e type,
900 int group_id, int priv_id)
902 return notification_create(type);
905 static void _notification_get_text_domain(notification_h noti)
907 if (noti->domain != NULL) {
911 if (noti->dir != NULL) {
916 EXPORT_API int notification_get_execute_option(notification_h noti,
917 notification_execute_type_e type,
919 bundle **service_handle)
921 char buf_key[32] = { 0, };
922 char *ret_val = NULL;
923 char *get_str = NULL;
927 return NOTIFICATION_ERROR_INVALID_PARAMETER;
930 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
931 || type >= NOTIFICATION_EXECUTE_TYPE_MAX) {
932 return NOTIFICATION_ERROR_INVALID_PARAMETER;
936 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
937 b = noti->b_service_responding;
939 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
940 b = noti->b_service_single_launch;
942 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
943 b = noti->b_service_multi_launch;
952 // Get text domain and dir
953 if (noti->domain == NULL || noti->dir == NULL) {
954 _notification_get_text_domain(noti);
958 snprintf(buf_key, sizeof(buf_key), "key%d", type);
960 /* Check key key exist */
961 bundle_get_str(b, buf_key, &ret_val);
962 if (ret_val != NULL && noti->domain != NULL
963 && noti->dir != NULL) {
964 /* Get application string */
965 bindtextdomain(noti->domain, noti->dir);
967 get_str = dgettext(noti->domain, ret_val);
970 } else if (ret_val != NULL) {
971 /* Get system string */
972 get_str = dgettext("sys_string", ret_val);
977 snprintf(buf_key, sizeof(buf_key), "text%d",
980 bundle_get_str(b, buf_key, &ret_val);
987 if (service_handle != NULL) {
991 return NOTIFICATION_ERROR_NONE;
994 EXPORT_API int notification_insert(notification_h noti,
1000 /* Check noti is vaild data */
1002 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1005 /* Check noti type is valid type */
1006 if (noti->type <= NOTIFICATION_TYPE_NONE
1007 || noti->type >= NOTIFICATION_TYPE_MAX) {
1008 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1011 /* Save insert time */
1012 noti->insert_time = time(NULL);
1013 ret = notification_ipc_request_insert(noti, &id);
1014 if (ret != NOTIFICATION_ERROR_NONE) {
1018 NOTIFICATION_DBG("from master:%d", id);
1020 /* If priv_id is valid data, set priv_id */
1021 if (priv_id != NULL) {
1022 *priv_id = noti->priv_id;
1025 return NOTIFICATION_ERROR_NONE;
1028 EXPORT_API int notification_update_async(notification_h noti,
1029 void (*result_cb)(int priv_id, int result, void *data), void *user_data)
1034 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1037 /* Update insert time ? */
1038 noti->insert_time = time(NULL);
1039 ret = notification_ipc_request_update_async(noti, result_cb, user_data);
1044 EXPORT_API int notification_register_detailed_changed_cb(
1045 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
1048 notification_cb_list_s *noti_cb_list_new = NULL;
1049 notification_cb_list_s *noti_cb_list = NULL;
1051 if (detailed_changed_cb == NULL) {
1052 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1054 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
1055 return NOTIFICATION_ERROR_IO_ERROR;
1059 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
1061 if (noti_cb_list_new == NULL) {
1062 NOTIFICATION_ERR("malloc failed");
1063 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
1066 noti_cb_list_new->next = NULL;
1067 noti_cb_list_new->prev = NULL;
1069 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
1070 noti_cb_list_new->changed_cb = NULL;
1071 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
1072 noti_cb_list_new->data = user_data;
1074 if (g_notification_cb_list == NULL) {
1075 g_notification_cb_list = noti_cb_list_new;
1077 noti_cb_list = g_notification_cb_list;
1079 while (noti_cb_list->next != NULL) {
1080 noti_cb_list = noti_cb_list->next;
1083 noti_cb_list->next = noti_cb_list_new;
1084 noti_cb_list_new->prev = noti_cb_list;
1086 return NOTIFICATION_ERROR_NONE;
1089 EXPORT_API int notification_unregister_detailed_changed_cb(
1090 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
1093 notification_cb_list_s *noti_cb_list = NULL;
1094 notification_cb_list_s *noti_cb_list_prev = NULL;
1095 notification_cb_list_s *noti_cb_list_next = NULL;
1097 noti_cb_list = g_notification_cb_list;
1099 if (detailed_changed_cb == NULL) {
1100 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1102 if (noti_cb_list == NULL) {
1103 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1106 while (noti_cb_list->prev != NULL) {
1107 noti_cb_list = noti_cb_list->prev;
1111 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
1112 noti_cb_list_prev = noti_cb_list->prev;
1113 noti_cb_list_next = noti_cb_list->next;
1115 if (noti_cb_list_prev == NULL) {
1116 g_notification_cb_list = noti_cb_list_next;
1118 noti_cb_list_prev->next = noti_cb_list_next;
1121 if (noti_cb_list_next == NULL) {
1122 if (noti_cb_list_prev != NULL) {
1123 noti_cb_list_prev->next = NULL;
1126 noti_cb_list_next->prev = noti_cb_list_prev;
1131 if (g_notification_cb_list == NULL)
1132 notification_ipc_monitor_fini();
1134 return NOTIFICATION_ERROR_NONE;
1136 noti_cb_list = noti_cb_list->next;
1137 } while (noti_cb_list != NULL);
1139 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1142 EXPORT_API int notification_is_service_ready(void)
1144 return notification_ipc_is_master_ready();