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>
31 #include <vconf-keys.h>
34 #include <notification.h>
35 #include <notification_list.h>
36 #include <notification_debug.h>
37 #include <notification_private.h>
38 #include <notification_noti.h>
39 #include <notification_ongoing.h>
40 #include <notification_group.h>
41 #include <notification_ipc.h>
42 #include <notification_internal.h>
44 typedef struct _notification_cb_list notification_cb_list_s;
46 typedef enum __notification_cb_type {
47 NOTIFICATION_CB_NORMAL = 1,
48 NOTIFICATION_CB_DETAILED,
49 } _notification_cb_type_e;
51 struct _notification_cb_list {
52 notification_cb_list_s *prev;
53 notification_cb_list_s *next;
55 _notification_cb_type_e cb_type;
56 void (*changed_cb) (void *data, notification_type_e type);
57 void (*detailed_changed_cb) (void *data, notification_type_e type, notification_op *op_list, int num_op);
61 static notification_cb_list_s *g_notification_cb_list = NULL;
63 void notification_call_changed_cb(notification_op *op_list, int op_num)
65 notification_cb_list_s *noti_cb_list = NULL;
66 notification_type_e type = 0;
68 if (g_notification_cb_list == NULL)
71 noti_cb_list = g_notification_cb_list;
73 while (noti_cb_list->prev != NULL)
74 noti_cb_list = noti_cb_list->prev;
77 if (op_list == NULL) {
78 NOTIFICATION_ERR("invalid data");
82 notification_get_type(op_list->noti, &type);
84 while (noti_cb_list != NULL) {
85 if (noti_cb_list->cb_type == NOTIFICATION_CB_NORMAL && noti_cb_list->changed_cb) {
86 noti_cb_list->changed_cb(noti_cb_list->data,
89 if (noti_cb_list->cb_type == NOTIFICATION_CB_DETAILED && noti_cb_list->detailed_changed_cb) {
90 noti_cb_list->detailed_changed_cb(noti_cb_list->data,
91 type, op_list, op_num);
94 noti_cb_list = noti_cb_list->next;
98 EXPORT_API int notification_add_deferred_task(
99 void (*deferred_task_cb)(void *data), void *user_data)
101 if (deferred_task_cb == NULL)
102 return NOTIFICATION_ERROR_INVALID_PARAMETER;
104 return notification_ipc_add_deffered_task(deferred_task_cb, user_data);
107 EXPORT_API int notification_del_deferred_task(
108 void (*deferred_task_cb)(void *data))
110 if (deferred_task_cb == NULL)
111 return NOTIFICATION_ERROR_INVALID_PARAMETER;
113 return notification_ipc_del_deffered_task(deferred_task_cb);
116 EXPORT_API int notification_resister_changed_cb(void (*changed_cb)
117 (void *data, notification_type_e type),
120 notification_cb_list_s *noti_cb_list_new = NULL;
121 notification_cb_list_s *noti_cb_list = NULL;
123 if (changed_cb == NULL)
124 return NOTIFICATION_ERROR_INVALID_PARAMETER;
127 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
129 if (noti_cb_list_new == NULL) {
130 NOTIFICATION_ERR("malloc failed");
131 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
134 noti_cb_list_new->next = NULL;
135 noti_cb_list_new->prev = NULL;
137 noti_cb_list_new->cb_type = NOTIFICATION_CB_NORMAL;
138 noti_cb_list_new->changed_cb = changed_cb;
139 noti_cb_list_new->detailed_changed_cb = NULL;
140 noti_cb_list_new->data = user_data;
142 if (g_notification_cb_list == NULL) {
143 g_notification_cb_list = noti_cb_list_new;
145 noti_cb_list = g_notification_cb_list;
147 while (noti_cb_list->next != NULL)
148 noti_cb_list = noti_cb_list->next;
151 noti_cb_list->next = noti_cb_list_new;
152 noti_cb_list_new->prev = noti_cb_list;
155 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE) {
156 notification_unresister_changed_cb(changed_cb);
157 return NOTIFICATION_ERROR_IO_ERROR;
160 return NOTIFICATION_ERROR_NONE;
163 EXPORT_API int notification_unresister_changed_cb(void (*changed_cb)
164 (void *data, notification_type_e type))
166 notification_cb_list_s *noti_cb_list = NULL;
167 notification_cb_list_s *noti_cb_list_prev = NULL;
168 notification_cb_list_s *noti_cb_list_next = NULL;
170 noti_cb_list = g_notification_cb_list;
172 if (changed_cb == NULL)
173 return NOTIFICATION_ERROR_INVALID_PARAMETER;
175 if (noti_cb_list == NULL)
176 return NOTIFICATION_ERROR_INVALID_PARAMETER;
178 while (noti_cb_list->prev != NULL)
179 noti_cb_list = noti_cb_list->prev;
183 if (noti_cb_list->changed_cb == changed_cb) {
184 noti_cb_list_prev = noti_cb_list->prev;
185 noti_cb_list_next = noti_cb_list->next;
187 if (noti_cb_list_prev == NULL)
188 g_notification_cb_list = noti_cb_list_next;
190 noti_cb_list_prev->next = noti_cb_list_next;
192 if (noti_cb_list_next == NULL) {
193 if (noti_cb_list_prev != NULL)
194 noti_cb_list_prev->next = NULL;
197 noti_cb_list_next->prev = noti_cb_list_prev;
202 if (g_notification_cb_list == NULL)
203 notification_ipc_monitor_fini();
205 return NOTIFICATION_ERROR_NONE;
207 noti_cb_list = noti_cb_list->next;
208 } while (noti_cb_list != NULL);
210 return NOTIFICATION_ERROR_INVALID_PARAMETER;
213 EXPORT_API int notification_update_progress(notification_h noti,
217 char *caller_pkgname = NULL;
218 int input_priv_id = 0;
220 double input_progress = 0.0;
222 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
224 return NOTIFICATION_ERROR_INVALID_PARAMETER;
226 input_priv_id = noti->priv_id;
229 input_priv_id = priv_id;
233 caller_pkgname = notification_get_pkgname_by_pid();
235 caller_pkgname = strdup(noti->caller_pkgname);
238 input_progress = 0.0;
239 else if (progress > 1.0)
240 input_progress = 1.0;
242 input_progress = progress;
244 ret = notification_ongoing_update_progress(caller_pkgname, input_priv_id,
248 free(caller_pkgname);
253 EXPORT_API int notification_update_size(notification_h noti,
257 char *caller_pkgname = NULL;
258 int input_priv_id = 0;
260 double input_size = 0.0;
262 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
264 return NOTIFICATION_ERROR_INVALID_PARAMETER;
266 input_priv_id = noti->priv_id;
268 input_priv_id = priv_id;
272 caller_pkgname = notification_get_pkgname_by_pid();
274 caller_pkgname = strdup(noti->caller_pkgname);
281 ret = notification_ongoing_update_size(caller_pkgname, input_priv_id,
285 free(caller_pkgname);
290 EXPORT_API int notification_update_content(notification_h noti,
294 char *caller_pkgname = NULL;
295 int input_priv_id = 0;
298 if (priv_id <= NOTIFICATION_PRIV_ID_NONE) {
300 return NOTIFICATION_ERROR_INVALID_PARAMETER;
302 input_priv_id = noti->priv_id;
305 input_priv_id = priv_id;
309 caller_pkgname = notification_get_pkgname_by_pid();
311 caller_pkgname = strdup(noti->caller_pkgname);
313 ret = notification_ongoing_update_content(caller_pkgname, input_priv_id,
317 free(caller_pkgname);
322 /* notification_set_icon will be removed */
323 EXPORT_API int notification_set_icon(notification_h noti,
324 const char *icon_path)
326 int ret_err = NOTIFICATION_ERROR_NONE;
329 notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
335 /* notification_get_icon will be removed */
336 EXPORT_API int notification_get_icon(notification_h noti,
339 int ret_err = NOTIFICATION_ERROR_NONE;
340 char *ret_image_path = NULL;
343 notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
346 if (ret_err == NOTIFICATION_ERROR_NONE && icon_path != NULL)
347 *icon_path = ret_image_path;
352 EXPORT_API int notification_translate_localized_text(notification_h noti)
354 int noti_err = NOTIFICATION_ERROR_NONE;
355 char *ret_text = NULL;
357 char *bundle_val = NULL;
360 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_TITLE;
362 for (; type < NOTIFICATION_TEXT_TYPE_MAX; type++) {
363 noti_err = notification_get_text(noti, type, &ret_text);
364 if (noti_err == NOTIFICATION_ERROR_NONE && ret_text) {
369 new_text = strdup(ret_text);
371 snprintf(buf_key, sizeof(buf_key), "%d", type);
372 bundle_get_str(b, buf_key, &bundle_val);
373 if (bundle_val != NULL)
374 bundle_del(b, buf_key);
376 bundle_add_str(b, buf_key, new_text);
380 noti->num_format_args = 0;
386 bundle_free(noti->b_key);
393 EXPORT_API int notification_set_title(notification_h noti,
395 const char *loc_title)
397 int noti_err = NOTIFICATION_ERROR_NONE;
399 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
401 NOTIFICATION_VARIABLE_TYPE_NONE);
406 EXPORT_API int notification_get_title(notification_h noti,
410 int noti_err = NOTIFICATION_ERROR_NONE;
411 char *ret_text = NULL;
414 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
420 if (loc_title != NULL)
426 EXPORT_API int notification_set_content(notification_h noti,
428 const char *loc_content)
430 int noti_err = NOTIFICATION_ERROR_NONE;
432 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
433 content, loc_content,
434 NOTIFICATION_VARIABLE_TYPE_NONE);
439 EXPORT_API int notification_get_content(notification_h noti,
443 int noti_err = NOTIFICATION_ERROR_NONE;
444 char *ret_text = NULL;
447 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
453 if (loc_content != NULL)
461 (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
463 if (ret == -1 || boolval == 0) {
464 if (content != NULL && noti->default_content != NULL)
465 *content = noti->default_content;
467 if (loc_content != NULL && noti->loc_default_content != NULL)
468 *loc_content = noti->loc_default_content;
473 EXPORT_API int notification_set_application(notification_h noti,
476 if (noti == NULL || pkgname == NULL)
477 return NOTIFICATION_ERROR_INVALID_PARAMETER;
479 if (noti->launch_pkgname)
480 free(noti->launch_pkgname);
482 noti->launch_pkgname = strdup(pkgname);
484 return NOTIFICATION_ERROR_NONE;
487 EXPORT_API int notification_get_application(notification_h noti,
490 if (noti == NULL || pkgname == NULL)
491 return NOTIFICATION_ERROR_INVALID_PARAMETER;
493 if (noti->launch_pkgname)
494 *pkgname = noti->launch_pkgname;
496 *pkgname = noti->caller_pkgname;
498 return NOTIFICATION_ERROR_NONE;
501 EXPORT_API int notification_set_args(notification_h noti, bundle *args,
504 if (noti == NULL || args == NULL)
505 return NOTIFICATION_ERROR_INVALID_PARAMETER;
508 bundle_free(noti->args);
510 noti->args = bundle_dup(args);
512 if (noti->group_args) {
513 bundle_free(noti->group_args);
514 noti->group_args = NULL;
517 if (group_args != NULL)
518 noti->group_args = bundle_dup(group_args);
520 return NOTIFICATION_ERROR_NONE;
523 EXPORT_API int notification_get_args(notification_h noti,
527 if (noti == NULL || args == NULL)
528 return NOTIFICATION_ERROR_INVALID_PARAMETER;
535 if (group_args != NULL && noti->group_args)
536 *group_args = noti->group_args;
538 return NOTIFICATION_ERROR_NONE;
541 EXPORT_API int notification_get_grouping_list(notification_type_e type, int count,
542 notification_list_h *list)
544 notification_list_h get_list = NULL;
548 return NOTIFICATION_ERROR_INVALID_PARAMETER;
550 ret = notification_noti_get_grouping_list(type, count, &get_list);
551 if (ret != NOTIFICATION_ERROR_NONE)
556 return NOTIFICATION_ERROR_NONE;
559 EXPORT_API int notification_delete_group_by_group_id(const char *pkgname,
560 notification_type_e type,
564 char *caller_pkgname = NULL;
567 caller_pkgname = notification_get_pkgname_by_pid();
569 caller_pkgname = strdup(pkgname);
571 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
574 free(caller_pkgname);
579 EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
580 notification_type_e type,
584 char *caller_pkgname = NULL;
587 caller_pkgname = notification_get_pkgname_by_pid();
589 caller_pkgname = strdup(pkgname);
591 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
594 free(caller_pkgname);
599 EXPORT_API int notification_get_count(notification_type_e type,
602 int priv_id, int *count)
605 char *caller_pkgname = NULL;
608 return NOTIFICATION_ERROR_INVALID_PARAMETER;
611 caller_pkgname = notification_get_pkgname_by_pid();
613 caller_pkgname = strdup(pkgname);
615 ret = notification_ipc_request_get_count(
623 free(caller_pkgname);
628 EXPORT_API int notification_clear(notification_type_e type)
632 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
633 return NOTIFICATION_ERROR_INVALID_PARAMETER;
635 ret = notification_ipc_request_delete_multiple(type, NULL);
640 EXPORT_API int notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
643 if (noti_op == NULL || data == NULL)
644 return NOTIFICATION_ERROR_INVALID_PARAMETER;
647 case NOTIFICATION_OP_DATA_TYPE:
648 *((int *)data) = noti_op->type;
650 case NOTIFICATION_OP_DATA_PRIV_ID:
651 *((int *)data) = noti_op->priv_id;
653 case NOTIFICATION_OP_DATA_NOTI:
654 *((notification_h *)data) = noti_op->noti;
656 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
657 *((int *)data) = noti_op->extra_info_1;
659 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
660 *((int *)data) = noti_op->extra_info_2;
663 return NOTIFICATION_ERROR_INVALID_PARAMETER;
667 return NOTIFICATION_ERROR_NONE;
670 EXPORT_API int notification_set_pkgname(notification_h noti,
673 /* check noti and pkgname are valid data */
674 if (noti == NULL || pkgname == NULL)
675 return NOTIFICATION_ERROR_INVALID_PARAMETER;
677 /* Remove previous caller pkgname */
678 if (noti->caller_pkgname) {
679 free(noti->caller_pkgname);
680 noti->caller_pkgname = NULL;
683 noti->caller_pkgname = strdup(pkgname);
685 return NOTIFICATION_ERROR_NONE;
688 EXPORT_API int notification_delete_all_by_type(const char *pkgname,
689 notification_type_e type)
692 char *caller_pkgname = NULL;
694 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
695 return NOTIFICATION_ERROR_INVALID_PARAMETER;
698 caller_pkgname = notification_get_pkgname_by_pid();
700 caller_pkgname = strdup(pkgname);
702 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
705 free(caller_pkgname);
710 EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
711 notification_type_e type,
715 char *caller_pkgname = NULL;
717 if (priv_id <= NOTIFICATION_PRIV_ID_NONE)
718 return NOTIFICATION_ERROR_INVALID_PARAMETER;
721 caller_pkgname = notification_get_pkgname_by_pid();
723 caller_pkgname = strdup(pkgname);
725 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
728 free(caller_pkgname);
733 EXPORT_API int notification_set_execute_option(notification_h noti,
734 notification_execute_type_e type,
737 bundle *service_handle)
739 char buf_key[32] = { 0, };
740 char *ret_val = NULL;
744 return NOTIFICATION_ERROR_INVALID_PARAMETER;
746 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
747 || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
748 return NOTIFICATION_ERROR_INVALID_PARAMETER;
750 /* Create execute option bundle if does not exist */
751 if (noti->b_execute_option == NULL)
752 noti->b_execute_option = bundle_create();
754 b = noti->b_execute_option;
759 snprintf(buf_key, sizeof(buf_key), "text%d", type);
761 /* Check text key exist */
762 bundle_get_str(b, buf_key, &ret_val);
764 /* Remove previous data */
765 bundle_del(b, buf_key);
768 bundle_add_str(b, buf_key, text);
774 snprintf(buf_key, sizeof(buf_key), "key%d", type);
776 /* Check key key exist */
777 bundle_get_str(b, buf_key, &ret_val);
779 /* Remove previous data */
780 bundle_del(b, buf_key);
783 bundle_add_str(b, buf_key, key);
787 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
788 /* Remove previous data if exist */
789 if (noti->b_service_responding != NULL) {
790 bundle_free(noti->b_service_responding);
791 noti->b_service_responding = NULL;
794 /* Save service handle */
795 if (service_handle != NULL)
796 noti->b_service_responding = bundle_dup(service_handle);
799 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
800 /* Remove previous data if exist */
801 if (noti->b_service_single_launch != NULL) {
802 bundle_free(noti->b_service_single_launch);
803 noti->b_service_single_launch = NULL;
806 /* Save service handle */
807 if (service_handle != NULL)
808 noti->b_service_single_launch =
809 bundle_dup(service_handle);
812 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
813 /* Remove previous data if exist */
814 if (noti->b_service_multi_launch != NULL) {
815 bundle_free(noti->b_service_multi_launch);
816 noti->b_service_multi_launch = NULL;
819 /* Save service handle */
820 if (service_handle != NULL)
821 noti->b_service_multi_launch =
822 bundle_dup(service_handle);
827 return NOTIFICATION_ERROR_NONE;
830 EXPORT_API int notification_get_id(notification_h noti,
831 int *group_id, int *priv_id)
833 /* check noti is valid data */
835 return NOTIFICATION_ERROR_INVALID_PARAMETER;
837 /* Check group_id is valid data */
840 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE)
841 *group_id = NOTIFICATION_GROUP_ID_NONE;
843 *group_id = noti->group_id;
846 /* Check priv_id is valid data */
849 *priv_id = noti->priv_id;
851 return NOTIFICATION_ERROR_NONE;
854 EXPORT_API notification_h notification_load(char *pkgname,
858 notification_h noti = NULL;
860 noti = (notification_h)calloc(1, sizeof(struct _notification));
862 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
866 ret = notification_ipc_request_load_noti_by_priv_id(noti, pkgname, priv_id);
867 if (ret != NOTIFICATION_ERROR_NONE) {
868 notification_free(noti);
875 EXPORT_API notification_h notification_new(notification_type_e type,
876 int group_id, int priv_id)
878 return notification_create(type);
881 static void _notification_get_text_domain(notification_h noti)
884 if (noti->domain != NULL) {
888 if (noti->dir != NULL) {
894 EXPORT_API int notification_get_execute_option(notification_h noti,
895 notification_execute_type_e type,
897 bundle **service_handle)
899 char buf_key[32] = { 0, };
900 char *ret_val = NULL;
901 char *get_str = NULL;
905 return NOTIFICATION_ERROR_INVALID_PARAMETER;
907 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
908 || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
909 return NOTIFICATION_ERROR_INVALID_PARAMETER;
913 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
914 b = noti->b_service_responding;
916 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
917 b = noti->b_service_single_launch;
919 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
920 b = noti->b_service_multi_launch;
929 /* Get text domain and dir */
930 if (noti->domain == NULL || noti->dir == NULL)
931 _notification_get_text_domain(noti);
934 snprintf(buf_key, sizeof(buf_key), "key%d", type);
936 /* Check key key exist */
937 bundle_get_str(b, buf_key, &ret_val);
938 if (ret_val != NULL && noti->domain != NULL
939 && noti->dir != NULL) {
940 /* Get application string */
941 bindtextdomain(noti->domain, noti->dir);
943 get_str = dgettext(noti->domain, ret_val);
946 } else if (ret_val != NULL) {
947 /* Get system string */
948 get_str = dgettext("sys_string", ret_val);
953 snprintf(buf_key, sizeof(buf_key), "text%d",
956 bundle_get_str(b, buf_key, &ret_val);
963 if (service_handle != NULL)
966 return NOTIFICATION_ERROR_NONE;
969 EXPORT_API int notification_insert(notification_h noti,
975 /* Check noti is vaild data */
977 return NOTIFICATION_ERROR_INVALID_PARAMETER;
979 /* Check noti type is valid type */
980 if (noti->type <= NOTIFICATION_TYPE_NONE
981 || noti->type >= NOTIFICATION_TYPE_MAX)
982 return NOTIFICATION_ERROR_INVALID_PARAMETER;
984 /* Save insert time */
985 noti->insert_time = time(NULL);
986 ret = notification_ipc_request_insert(noti, &id);
987 if (ret != NOTIFICATION_ERROR_NONE)
991 NOTIFICATION_DBG("from master:%d", id);
993 /* If priv_id is valid data, set priv_id */
995 *priv_id = noti->priv_id;
997 return NOTIFICATION_ERROR_NONE;
1000 EXPORT_API int notification_update_async(notification_h noti,
1001 void (*result_cb)(int priv_id, int result, void *data), void *user_data)
1006 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1008 /* Update insert time ? */
1009 noti->insert_time = time(NULL);
1010 ret = notification_ipc_request_update_async(noti, result_cb, user_data);
1015 EXPORT_API int notification_register_detailed_changed_cb(
1016 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
1019 notification_cb_list_s *noti_cb_list_new = NULL;
1020 notification_cb_list_s *noti_cb_list = NULL;
1022 if (detailed_changed_cb == NULL)
1023 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1025 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE)
1026 return NOTIFICATION_ERROR_IO_ERROR;
1029 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
1031 if (noti_cb_list_new == NULL) {
1032 NOTIFICATION_ERR("malloc failed");
1033 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
1036 noti_cb_list_new->next = NULL;
1037 noti_cb_list_new->prev = NULL;
1039 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
1040 noti_cb_list_new->changed_cb = NULL;
1041 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
1042 noti_cb_list_new->data = user_data;
1044 if (g_notification_cb_list == NULL) {
1045 g_notification_cb_list = noti_cb_list_new;
1047 noti_cb_list = g_notification_cb_list;
1049 while (noti_cb_list->next != NULL)
1050 noti_cb_list = noti_cb_list->next;
1053 noti_cb_list->next = noti_cb_list_new;
1054 noti_cb_list_new->prev = noti_cb_list;
1056 return NOTIFICATION_ERROR_NONE;
1059 EXPORT_API int notification_unregister_detailed_changed_cb(
1060 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
1063 notification_cb_list_s *noti_cb_list = NULL;
1064 notification_cb_list_s *noti_cb_list_prev = NULL;
1065 notification_cb_list_s *noti_cb_list_next = NULL;
1067 noti_cb_list = g_notification_cb_list;
1069 if (detailed_changed_cb == NULL)
1070 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1072 if (noti_cb_list == NULL)
1073 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1076 while (noti_cb_list->prev != NULL)
1077 noti_cb_list = noti_cb_list->prev;
1081 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
1082 noti_cb_list_prev = noti_cb_list->prev;
1083 noti_cb_list_next = noti_cb_list->next;
1085 if (noti_cb_list_prev == NULL)
1086 g_notification_cb_list = noti_cb_list_next;
1088 noti_cb_list_prev->next = noti_cb_list_next;
1090 if (noti_cb_list_next == NULL) {
1091 if (noti_cb_list_prev != NULL)
1092 noti_cb_list_prev->next = NULL;
1095 noti_cb_list_next->prev = noti_cb_list_prev;
1100 if (g_notification_cb_list == NULL)
1101 notification_ipc_monitor_fini();
1103 return NOTIFICATION_ERROR_NONE;
1105 noti_cb_list = noti_cb_list->next;
1106 } while (noti_cb_list != NULL);
1108 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1111 EXPORT_API int notification_is_service_ready(void)
1113 return notification_ipc_is_master_ready();