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.
23 #include <dbus/dbus.h>
24 #include <dbus/dbus-glib-lowlevel.h>
27 #include <app_control_internal.h>
32 #include <vconf-keys.h>
35 #include <notification.h>
36 #include <notification_list.h>
37 #include <notification_debug.h>
38 #include <notification_private.h>
39 #include <notification_noti.h>
40 #include <notification_ongoing.h>
41 #include <notification_group.h>
42 #include <notification_ipc.h>
43 #include <notification_internal.h>
45 typedef struct _notification_cb_list notification_cb_list_s;
47 typedef enum __notification_cb_type {
48 NOTIFICATION_CB_NORMAL = 1,
49 NOTIFICATION_CB_DETAILED,
50 } _notification_cb_type_e;
52 struct _notification_cb_list {
53 notification_cb_list_s *prev;
54 notification_cb_list_s *next;
56 _notification_cb_type_e cb_type;
57 void (*changed_cb) (void *data, notification_type_e type);
58 void (*detailed_changed_cb) (void *data, notification_type_e type, notification_op *op_list, int num_op);
62 static notification_cb_list_s *g_notification_cb_list = NULL;
64 void notification_call_changed_cb(notification_op *op_list, int op_num)
66 notification_cb_list_s *noti_cb_list = NULL;
67 notification_type_e type = 0;
69 if (g_notification_cb_list == NULL)
72 noti_cb_list = g_notification_cb_list;
74 while (noti_cb_list->prev != NULL)
75 noti_cb_list = noti_cb_list->prev;
78 if (op_list == NULL) {
79 NOTIFICATION_ERR("invalid data");
83 notification_get_type(op_list->noti, &type);
85 while (noti_cb_list != NULL) {
86 if (noti_cb_list->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_list->changed_cb) {
87 noti_cb_list->changed_cb(noti_cb_list->data,
90 if (noti_cb_list->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_list->detailed_changed_cb) {
91 noti_cb_list->detailed_changed_cb(noti_cb_list->data,
92 type, op_list, op_num);
95 noti_cb_list = noti_cb_list->next;
99 EXPORT_API int notification_add_deferred_task(
100 void (*deferred_task_cb)(void *data), void *user_data)
102 if (deferred_task_cb == NULL)
103 return NOTIFICATION_ERROR_INVALID_PARAMETER;
105 return notification_ipc_add_deffered_task(deferred_task_cb, user_data);
108 EXPORT_API int notification_del_deferred_task(
109 void (*deferred_task_cb)(void *data))
111 if (deferred_task_cb == NULL)
112 return NOTIFICATION_ERROR_INVALID_PARAMETER;
114 return notification_ipc_del_deffered_task(deferred_task_cb);
117 EXPORT_API int notification_resister_changed_cb(void (*changed_cb)
118 (void *data, notification_type_e type),
121 notification_cb_list_s *noti_cb_list_new = NULL;
122 notification_cb_list_s *noti_cb_list = NULL;
124 if (changed_cb == NULL)
125 return NOTIFICATION_ERROR_INVALID_PARAMETER;
128 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
130 if (noti_cb_list_new == NULL) {
131 NOTIFICATION_ERR("malloc failed");
132 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
135 noti_cb_list_new->next = NULL;
136 noti_cb_list_new->prev = NULL;
138 noti_cb_list_new->cb_type = NOTIFICATION_CB_NORMAL;
139 noti_cb_list_new->changed_cb = changed_cb;
140 noti_cb_list_new->detailed_changed_cb = NULL;
141 noti_cb_list_new->data = user_data;
143 if (g_notification_cb_list == NULL) {
144 g_notification_cb_list = noti_cb_list_new;
146 noti_cb_list = g_notification_cb_list;
148 while (noti_cb_list->next != NULL)
149 noti_cb_list = noti_cb_list->next;
152 noti_cb_list->next = noti_cb_list_new;
153 noti_cb_list_new->prev = noti_cb_list;
156 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
157 notification_unresister_changed_cb(changed_cb);
158 return NOTIFICATION_ERROR_IO_ERROR;
161 return NOTIFICATION_ERROR_NONE;
164 EXPORT_API int notification_unresister_changed_cb(void (*changed_cb)
165 (void *data, notification_type_e type))
167 notification_cb_list_s *noti_cb_list = NULL;
168 notification_cb_list_s *noti_cb_list_prev = NULL;
169 notification_cb_list_s *noti_cb_list_next = NULL;
171 noti_cb_list = g_notification_cb_list;
173 if (changed_cb == NULL)
174 return NOTIFICATION_ERROR_INVALID_PARAMETER;
176 if (noti_cb_list == NULL)
177 return NOTIFICATION_ERROR_INVALID_PARAMETER;
179 while (noti_cb_list->prev != NULL)
180 noti_cb_list = noti_cb_list->prev;
184 if (noti_cb_list->changed_cb == changed_cb) {
185 noti_cb_list_prev = noti_cb_list->prev;
186 noti_cb_list_next = noti_cb_list->next;
188 if (noti_cb_list_prev == NULL)
189 g_notification_cb_list = noti_cb_list_next;
191 noti_cb_list_prev->next = noti_cb_list_next;
193 if (noti_cb_list_next == NULL) {
194 if (noti_cb_list_prev != NULL)
195 noti_cb_list_prev->next = NULL;
198 noti_cb_list_next->prev = noti_cb_list_prev;
203 if (g_notification_cb_list == NULL)
204 notification_ipc_monitor_fini();
206 return NOTIFICATION_ERROR_NONE;
208 noti_cb_list = noti_cb_list->next;
209 } while (noti_cb_list != NULL);
211 return NOTIFICATION_ERROR_INVALID_PARAMETER;
214 EXPORT_API int notification_update_progress(notification_h noti,
218 char *caller_pkgname = NULL;
219 int input_priv_id = 0;
221 double input_progress = 0.0;
223 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
225 return NOTIFICATION_ERROR_INVALID_PARAMETER;
227 input_priv_id = noti->priv_id;
230 input_priv_id = priv_id;
234 caller_pkgname = notification_get_pkgname_by_pid();
236 caller_pkgname = strdup(noti->caller_pkgname);
239 input_progress = 0.0;
240 else if (progress > 1.0)
241 input_progress = 1.0;
243 input_progress = progress;
245 ret = notification_ongoing_update_progress(caller_pkgname, input_priv_id,
249 free(caller_pkgname);
254 EXPORT_API int notification_update_size(notification_h noti,
258 char *caller_pkgname = NULL;
259 int input_priv_id = 0;
261 double input_size = 0.0;
263 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
265 return NOTIFICATION_ERROR_INVALID_PARAMETER;
267 input_priv_id = noti->priv_id;
269 input_priv_id = priv_id;
273 caller_pkgname = notification_get_pkgname_by_pid();
275 caller_pkgname = strdup(noti->caller_pkgname);
282 ret = notification_ongoing_update_size(caller_pkgname, input_priv_id,
286 free(caller_pkgname);
291 EXPORT_API int notification_update_content(notification_h noti,
295 char *caller_pkgname = NULL;
296 int input_priv_id = 0;
299 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
301 return NOTIFICATION_ERROR_INVALID_PARAMETER;
303 input_priv_id = noti->priv_id;
306 input_priv_id = priv_id;
310 caller_pkgname = notification_get_pkgname_by_pid();
312 caller_pkgname = strdup(noti->caller_pkgname);
314 ret = notification_ongoing_update_content(caller_pkgname, input_priv_id,
318 free(caller_pkgname);
323 /* notification_set_icon will be removed */
324 EXPORT_API int notification_set_icon(notification_h noti,
325 const char *icon_path)
327 int ret_err = NOTIFICATION_ERROR_NONE;
330 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
336 /* notification_get_icon will be removed */
337 EXPORT_API int notification_get_icon(notification_h noti,
340 int ret_err = NOTIFICATION_ERROR_NONE;
341 char *ret_image_path = NULL;
344 notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
347 if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL)
348 *icon_path = ret_image_path;
353 EXPORT_API int notification_translate_localized_text(notification_h noti)
355 int noti_err = NOTIFICATION_ERROR_NONE;
356 char *ret_text = NULL;
358 char *bundle_val = NULL;
361 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_TITLE;
363 for (; type < NOTIFICATION_TEXT_TYPE_MAX; type++) {
364 noti_err = notification_get_text(noti, type, &ret_text);
365 if (noti_err == NOTIFICATION_ERROR_NONE && ret_text) {
370 new_text = strdup(ret_text);
372 snprintf(buf_key, sizeof(buf_key), "%d", type);
373 bundle_get_str(b, buf_key, &bundle_val);
374 if (bundle_val != NULL)
375 bundle_del(b, buf_key);
377 bundle_add_str(b, buf_key, new_text);
381 noti->num_format_args = 0;
387 bundle_free(noti->b_key);
394 EXPORT_API int notification_set_title(notification_h noti,
396 const char *loc_title)
398 int noti_err = NOTIFICATION_ERROR_NONE;
400 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
402 NOTIFICATION_VARIABLE_TYPE_NONE);
407 EXPORT_API int notification_get_title(notification_h noti,
411 int noti_err = NOTIFICATION_ERROR_NONE;
412 char *ret_text = NULL;
415 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
421 if (loc_title != NULL)
427 EXPORT_API int notification_set_content(notification_h noti,
429 const char *loc_content)
431 int noti_err = NOTIFICATION_ERROR_NONE;
433 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
434 content, loc_content,
435 NOTIFICATION_VARIABLE_TYPE_NONE);
440 EXPORT_API int notification_get_content(notification_h noti,
444 int noti_err = NOTIFICATION_ERROR_NONE;
445 char *ret_text = NULL;
448 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
454 if (loc_content != NULL)
462 (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
464 if (ret == -1 || boolval == 0) {
465 if (content != NULL && noti->default_content != NULL)
466 *content = noti->default_content;
468 if (loc_content != NULL && noti->loc_default_content != NULL)
469 *loc_content = noti->loc_default_content;
474 EXPORT_API int notification_set_application(notification_h noti,
477 if (noti == NULL || pkgname == NULL)
478 return NOTIFICATION_ERROR_INVALID_PARAMETER;
480 if (noti->launch_pkgname)
481 free(noti->launch_pkgname);
483 noti->launch_pkgname = strdup(pkgname);
485 return NOTIFICATION_ERROR_NONE;
488 EXPORT_API int notification_get_application(notification_h noti,
491 if (noti == NULL || pkgname == NULL)
492 return NOTIFICATION_ERROR_INVALID_PARAMETER;
494 if (noti->launch_pkgname)
495 *pkgname = noti->launch_pkgname;
497 *pkgname = noti->caller_pkgname;
499 return NOTIFICATION_ERROR_NONE;
502 EXPORT_API int notification_set_args(notification_h noti, bundle *args,
505 if (noti == NULL || args == NULL)
506 return NOTIFICATION_ERROR_INVALID_PARAMETER;
509 bundle_free(noti->args);
511 noti->args = bundle_dup(args);
513 if (noti->group_args) {
514 bundle_free(noti->group_args);
515 noti->group_args = NULL;
518 if (group_args != NULL)
519 noti->group_args = bundle_dup(group_args);
521 return NOTIFICATION_ERROR_NONE;
524 EXPORT_API int notification_get_args(notification_h noti,
528 if (noti == NULL || args == NULL)
529 return NOTIFICATION_ERROR_INVALID_PARAMETER;
536 if (group_args != NULL && noti->group_args)
537 *group_args = noti->group_args;
539 return NOTIFICATION_ERROR_NONE;
542 EXPORT_API int notification_get_grouping_list(notification_type_e type, int count,
543 notification_list_h *list)
545 notification_list_h get_list = NULL;
549 return NOTIFICATION_ERROR_INVALID_PARAMETER;
551 ret = notification_noti_get_grouping_list(type, count, &get_list);
552 if (ret != NOTIFICATION_ERROR_NONE)
557 return NOTIFICATION_ERROR_NONE;
560 EXPORT_API int notification_delete_group_by_group_id(const char *pkgname,
561 notification_type_e type,
565 char *caller_pkgname = NULL;
568 caller_pkgname = notification_get_pkgname_by_pid();
570 caller_pkgname = strdup(pkgname);
572 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
575 free(caller_pkgname);
580 EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
581 notification_type_e type,
585 char *caller_pkgname = NULL;
588 caller_pkgname = notification_get_pkgname_by_pid();
590 caller_pkgname = strdup(pkgname);
592 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
595 free(caller_pkgname);
600 EXPORT_API int notification_get_count(notification_type_e type,
603 int priv_id, int *count)
606 char *caller_pkgname = NULL;
609 return NOTIFICATION_ERROR_INVALID_PARAMETER;
612 caller_pkgname = notification_get_pkgname_by_pid();
614 caller_pkgname = strdup(pkgname);
616 ret = notification_ipc_request_get_count(
624 free(caller_pkgname);
629 EXPORT_API int notification_clear(notification_type_e type)
633 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
634 return NOTIFICATION_ERROR_INVALID_PARAMETER;
636 ret = notification_ipc_request_delete_multiple(type, NULL);
641 EXPORT_API int notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
644 if (noti_op == NULL || data == NULL)
645 return NOTIFICATION_ERROR_INVALID_PARAMETER;
648 case NOTIFICATION_OP_DATA_TYPE:
649 *((int *)data) = noti_op->type;
651 case NOTIFICATION_OP_DATA_PRIV_ID:
652 *((int *)data) = noti_op->priv_id;
654 case NOTIFICATION_OP_DATA_NOTI:
655 *((notification_h *)data) = noti_op->noti;
657 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
658 *((int *)data) = noti_op->extra_info_1;
660 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
661 *((int *)data) = noti_op->extra_info_2;
664 return NOTIFICATION_ERROR_INVALID_PARAMETER;
668 return NOTIFICATION_ERROR_NONE;
671 EXPORT_API int notification_set_pkgname(notification_h noti,
674 /* check noti and pkgname are valid data */
675 if (noti == NULL || pkgname == NULL)
676 return NOTIFICATION_ERROR_INVALID_PARAMETER;
678 /* Remove previous caller pkgname */
679 if (noti->caller_pkgname) {
680 free(noti->caller_pkgname);
681 noti->caller_pkgname = NULL;
684 noti->caller_pkgname = strdup(pkgname);
686 return NOTIFICATION_ERROR_NONE;
689 EXPORT_API int notification_delete_all_by_type(const char *pkgname,
690 notification_type_e type)
693 char *caller_pkgname = NULL;
695 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
696 return NOTIFICATION_ERROR_INVALID_PARAMETER;
699 caller_pkgname = notification_get_pkgname_by_pid();
701 caller_pkgname = strdup(pkgname);
703 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
706 free(caller_pkgname);
711 EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
712 notification_type_e type,
716 char *caller_pkgname = NULL;
718 if (priv_id <= NOTIFICATION_PRIV_ID_NONE)
719 return NOTIFICATION_ERROR_INVALID_PARAMETER;
722 caller_pkgname = notification_get_pkgname_by_pid();
724 caller_pkgname = strdup(pkgname);
726 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
729 free(caller_pkgname);
734 EXPORT_API int notification_set_execute_option(notification_h noti,
735 notification_execute_type_e type,
738 bundle *service_handle)
740 char buf_key[32] = { 0, };
741 char *ret_val = NULL;
745 return NOTIFICATION_ERROR_INVALID_PARAMETER;
747 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
748 || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
749 return NOTIFICATION_ERROR_INVALID_PARAMETER;
751 /* Create execute option bundle if does not exist */
752 if (noti->b_execute_option == NULL)
753 noti->b_execute_option = bundle_create();
755 b = noti->b_execute_option;
760 snprintf(buf_key, sizeof(buf_key), "text%d", type);
762 /* Check text key exist */
763 bundle_get_str(b, buf_key, &ret_val);
765 /* Remove previous data */
766 bundle_del(b, buf_key);
769 bundle_add_str(b, buf_key, text);
775 snprintf(buf_key, sizeof(buf_key), "key%d", type);
777 /* Check key key exist */
778 bundle_get_str(b, buf_key, &ret_val);
780 /* Remove previous data */
781 bundle_del(b, buf_key);
784 bundle_add_str(b, buf_key, key);
788 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
789 /* Remove previous data if exist */
790 if (noti->b_service_responding != NULL) {
791 bundle_free(noti->b_service_responding);
792 noti->b_service_responding = NULL;
795 /* Save service handle */
796 if (service_handle != NULL)
797 noti->b_service_responding = bundle_dup(service_handle);
800 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
801 /* Remove previous data if exist */
802 if (noti->b_service_single_launch != NULL) {
803 bundle_free(noti->b_service_single_launch);
804 noti->b_service_single_launch = NULL;
807 /* Save service handle */
808 if (service_handle != NULL)
809 noti->b_service_single_launch =
810 bundle_dup(service_handle);
813 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
814 /* Remove previous data if exist */
815 if (noti->b_service_multi_launch != NULL) {
816 bundle_free(noti->b_service_multi_launch);
817 noti->b_service_multi_launch = NULL;
820 /* Save service handle */
821 if (service_handle != NULL)
822 noti->b_service_multi_launch =
823 bundle_dup(service_handle);
828 return NOTIFICATION_ERROR_NONE;
831 EXPORT_API int notification_get_id(notification_h noti,
832 int *group_id, int *priv_id)
834 /* check noti is valid data */
836 return NOTIFICATION_ERROR_INVALID_PARAMETER;
838 /* Check group_id is valid data */
841 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE)
842 *group_id = NOTIFICATION_GROUP_ID_NONE;
844 *group_id = noti->group_id;
847 /* Check priv_id is valid data */
850 *priv_id = noti->priv_id;
852 return NOTIFICATION_ERROR_NONE;
855 EXPORT_API notification_h notification_load(char *pkgname,
859 notification_h noti = NULL;
861 noti = (notification_h)calloc(1, sizeof(struct _notification));
863 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
867 ret = notification_ipc_request_load_noti_by_priv_id(noti, pkgname, priv_id);
868 if (ret != NOTIFICATION_ERROR_NONE) {
869 notification_free(noti);
876 EXPORT_API notification_h notification_new(notification_type_e type,
877 int group_id, int priv_id)
879 return notification_create(type);
882 static void _notification_get_text_domain(notification_h noti)
885 if (noti->domain != NULL) {
889 if (noti->dir != NULL) {
895 EXPORT_API int notification_get_execute_option(notification_h noti,
896 notification_execute_type_e type,
898 bundle **service_handle)
900 char buf_key[32] = { 0, };
901 char *ret_val = NULL;
902 char *get_str = NULL;
906 return NOTIFICATION_ERROR_INVALID_PARAMETER;
908 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
909 || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
910 return NOTIFICATION_ERROR_INVALID_PARAMETER;
914 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
915 b = noti->b_service_responding;
917 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
918 b = noti->b_service_single_launch;
920 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
921 b = noti->b_service_multi_launch;
930 /* Get text domain and dir */
931 if (noti->domain == NULL || noti->dir == NULL)
932 _notification_get_text_domain(noti);
935 snprintf(buf_key, sizeof(buf_key), "key%d", type);
937 /* Check key key exist */
938 bundle_get_str(b, buf_key, &ret_val);
939 if (ret_val != NULL && noti->domain != NULL
940 && noti->dir != NULL) {
941 /* Get application string */
942 bindtextdomain(noti->domain, noti->dir);
944 get_str = dgettext(noti->domain, ret_val);
947 } else if (ret_val != NULL) {
948 /* Get system string */
949 get_str = dgettext("sys_string", ret_val);
954 snprintf(buf_key, sizeof(buf_key), "text%d",
957 bundle_get_str(b, buf_key, &ret_val);
964 if (service_handle != NULL)
967 return NOTIFICATION_ERROR_NONE;
970 EXPORT_API int notification_insert(notification_h noti,
976 /* Check noti is vaild data */
978 return NOTIFICATION_ERROR_INVALID_PARAMETER;
980 /* Check noti type is valid type */
981 if (noti->type <= NOTIFICATION_TYPE_NONE
982 || noti->type >= NOTIFICATION_TYPE_MAX)
983 return NOTIFICATION_ERROR_INVALID_PARAMETER;
985 /* Save insert time */
986 noti->insert_time = time(NULL);
987 ret = notification_ipc_request_insert(noti, &id);
988 if (ret != NOTIFICATION_ERROR_NONE)
992 NOTIFICATION_DBG("from master:%d", id);
994 /* If priv_id is valid data, set priv_id */
996 *priv_id = noti->priv_id;
998 return NOTIFICATION_ERROR_NONE;
1001 EXPORT_API int notification_update_async(notification_h noti,
1002 void (*result_cb)(int priv_id, int result, void *data), void *user_data)
1007 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1009 /* Update insert time ? */
1010 noti->insert_time = time(NULL);
1011 ret = notification_ipc_request_update_async(noti, result_cb, user_data);
1016 EXPORT_API int notification_register_detailed_changed_cb(
1017 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
1020 notification_cb_list_s *noti_cb_list_new = NULL;
1021 notification_cb_list_s *noti_cb_list = NULL;
1023 if (detailed_changed_cb == NULL)
1024 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1026 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE)
1027 return NOTIFICATION_ERROR_IO_ERROR;
1030 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
1032 if (noti_cb_list_new == NULL) {
1033 NOTIFICATION_ERR("malloc failed");
1034 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
1037 noti_cb_list_new->next = NULL;
1038 noti_cb_list_new->prev = NULL;
1040 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
1041 noti_cb_list_new->changed_cb = NULL;
1042 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
1043 noti_cb_list_new->data = user_data;
1045 if (g_notification_cb_list == NULL) {
1046 g_notification_cb_list = noti_cb_list_new;
1048 noti_cb_list = g_notification_cb_list;
1050 while (noti_cb_list->next != NULL)
1051 noti_cb_list = noti_cb_list->next;
1054 noti_cb_list->next = noti_cb_list_new;
1055 noti_cb_list_new->prev = noti_cb_list;
1057 return NOTIFICATION_ERROR_NONE;
1060 EXPORT_API int notification_unregister_detailed_changed_cb(
1061 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
1064 notification_cb_list_s *noti_cb_list = NULL;
1065 notification_cb_list_s *noti_cb_list_prev = NULL;
1066 notification_cb_list_s *noti_cb_list_next = NULL;
1068 noti_cb_list = g_notification_cb_list;
1070 if (detailed_changed_cb == NULL)
1071 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1073 if (noti_cb_list == NULL)
1074 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1077 while (noti_cb_list->prev != NULL)
1078 noti_cb_list = noti_cb_list->prev;
1082 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
1083 noti_cb_list_prev = noti_cb_list->prev;
1084 noti_cb_list_next = noti_cb_list->next;
1086 if (noti_cb_list_prev == NULL)
1087 g_notification_cb_list = noti_cb_list_next;
1089 noti_cb_list_prev->next = noti_cb_list_next;
1091 if (noti_cb_list_next == NULL) {
1092 if (noti_cb_list_prev != NULL)
1093 noti_cb_list_prev->next = NULL;
1096 noti_cb_list_next->prev = noti_cb_list_prev;
1101 if (g_notification_cb_list == NULL)
1102 notification_ipc_monitor_fini();
1104 return NOTIFICATION_ERROR_NONE;
1106 noti_cb_list = noti_cb_list->next;
1107 } while (noti_cb_list != NULL);
1109 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1112 EXPORT_API int notification_is_service_ready(void)
1114 return notification_ipc_is_master_ready();