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 /* LCOV_EXCL_START */
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,
337 /* notification_get_icon will be removed */
338 /* LCOV_EXCL_START */
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;
356 EXPORT_API int notification_translate_localized_text(notification_h noti)
358 int noti_err = NOTIFICATION_ERROR_NONE;
359 char *ret_text = NULL;
361 char *bundle_val = NULL;
364 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_TITLE;
366 for (; type < NOTIFICATION_TEXT_TYPE_MAX; type++) {
367 noti_err = notification_get_text(noti, type, &ret_text);
368 if (noti_err == NOTIFICATION_ERROR_NONE && ret_text) {
369 if (noti->b_text == NULL) {
370 noti->b_text = bundle_create();
371 if (noti->b_text == NULL)
372 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
377 new_text = strdup(ret_text);
379 snprintf(buf_key, sizeof(buf_key), "%d", type);
380 bundle_get_str(b, buf_key, &bundle_val);
381 if (bundle_val != NULL)
382 bundle_del(b, buf_key);
384 bundle_add_str(b, buf_key, new_text);
388 noti->num_format_args = 0;
394 bundle_free(noti->b_key);
401 /* LCOV_EXCL_START */
402 EXPORT_API int notification_set_title(notification_h noti,
404 const char *loc_title)
406 int noti_err = NOTIFICATION_ERROR_NONE;
408 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
410 NOTIFICATION_VARIABLE_TYPE_NONE);
416 /* LCOV_EXCL_START */
417 EXPORT_API int notification_get_title(notification_h noti,
421 int noti_err = NOTIFICATION_ERROR_NONE;
422 char *ret_text = NULL;
425 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
431 if (loc_title != NULL)
438 /* LCOV_EXCL_START */
439 EXPORT_API int notification_set_content(notification_h noti,
441 const char *loc_content)
443 int noti_err = NOTIFICATION_ERROR_NONE;
445 noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
446 content, loc_content,
447 NOTIFICATION_VARIABLE_TYPE_NONE);
453 /* LCOV_EXCL_START */
454 EXPORT_API int notification_get_content(notification_h noti,
458 int noti_err = NOTIFICATION_ERROR_NONE;
459 char *ret_text = NULL;
462 notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
468 if (loc_content != NULL)
476 (VCONFKEY_SETAPPL_STATE_TICKER_NOTI_DISPLAY_CONTENT_BOOL, &boolval);
478 if (ret == -1 || boolval == 0) {
479 if (content != NULL && noti->default_content != NULL)
480 *content = noti->default_content;
482 if (loc_content != NULL && noti->loc_default_content != NULL)
483 *loc_content = noti->loc_default_content;
489 /* LCOV_EXCL_START */
490 EXPORT_API int notification_set_application(notification_h noti,
493 if (noti == NULL || pkgname == NULL)
494 return NOTIFICATION_ERROR_INVALID_PARAMETER;
496 if (noti->launch_pkgname)
497 free(noti->launch_pkgname);
499 noti->launch_pkgname = strdup(pkgname);
501 return NOTIFICATION_ERROR_NONE;
505 /* LCOV_EXCL_START */
506 EXPORT_API int notification_get_application(notification_h noti,
509 if (noti == NULL || pkgname == NULL)
510 return NOTIFICATION_ERROR_INVALID_PARAMETER;
512 if (noti->launch_pkgname)
513 *pkgname = noti->launch_pkgname;
515 *pkgname = noti->caller_pkgname;
517 return NOTIFICATION_ERROR_NONE;
521 /* LCOV_EXCL_START */
522 EXPORT_API int notification_set_args(notification_h noti, bundle *args,
525 if (noti == NULL || args == NULL)
526 return NOTIFICATION_ERROR_INVALID_PARAMETER;
529 bundle_free(noti->args);
531 noti->args = bundle_dup(args);
533 if (noti->group_args) {
534 bundle_free(noti->group_args);
535 noti->group_args = NULL;
538 if (group_args != NULL)
539 noti->group_args = bundle_dup(group_args);
541 return NOTIFICATION_ERROR_NONE;
545 /* LCOV_EXCL_START */
546 EXPORT_API int notification_get_args(notification_h noti,
550 if (noti == NULL || args == NULL)
551 return NOTIFICATION_ERROR_INVALID_PARAMETER;
558 if (group_args != NULL && noti->group_args)
559 *group_args = noti->group_args;
561 return NOTIFICATION_ERROR_NONE;
565 /* LCOV_EXCL_START */
566 EXPORT_API int notification_get_grouping_list(notification_type_e type, int count,
567 notification_list_h *list)
569 notification_list_h get_list = NULL;
573 return NOTIFICATION_ERROR_INVALID_PARAMETER;
575 ret = notification_noti_get_grouping_list(type, count, &get_list);
576 if (ret != NOTIFICATION_ERROR_NONE)
581 return NOTIFICATION_ERROR_NONE;
585 /* LCOV_EXCL_START */
586 EXPORT_API int notification_delete_group_by_group_id(const char *pkgname,
587 notification_type_e type,
591 char *caller_pkgname = NULL;
594 caller_pkgname = notification_get_pkgname_by_pid();
596 caller_pkgname = strdup(pkgname);
598 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
601 free(caller_pkgname);
607 /* LCOV_EXCL_START */
608 EXPORT_API int notification_delete_group_by_priv_id(const char *pkgname,
609 notification_type_e type,
613 char *caller_pkgname = NULL;
616 caller_pkgname = notification_get_pkgname_by_pid();
618 caller_pkgname = strdup(pkgname);
620 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
623 free(caller_pkgname);
629 /* LCOV_EXCL_START */
630 EXPORT_API int notification_get_count(notification_type_e type,
633 int priv_id, int *count)
636 char *caller_pkgname = NULL;
639 return NOTIFICATION_ERROR_INVALID_PARAMETER;
642 caller_pkgname = notification_get_pkgname_by_pid();
644 caller_pkgname = strdup(pkgname);
646 ret = notification_ipc_request_get_count(
654 free(caller_pkgname);
660 /* LCOV_EXCL_START */
661 EXPORT_API int notification_clear(notification_type_e type)
665 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
666 return NOTIFICATION_ERROR_INVALID_PARAMETER;
668 ret = notification_ipc_request_delete_multiple(type, NULL);
674 /* LCOV_EXCL_START */
675 EXPORT_API int notification_op_get_data(notification_op *noti_op, notification_op_data_type_e type,
678 if (noti_op == NULL || data == NULL)
679 return NOTIFICATION_ERROR_INVALID_PARAMETER;
682 case NOTIFICATION_OP_DATA_TYPE:
683 *((int *)data) = noti_op->type;
685 case NOTIFICATION_OP_DATA_PRIV_ID:
686 *((int *)data) = noti_op->priv_id;
688 case NOTIFICATION_OP_DATA_NOTI:
689 *((notification_h *)data) = noti_op->noti;
691 case NOTIFICATION_OP_DATA_EXTRA_INFO_1:
692 *((int *)data) = noti_op->extra_info_1;
694 case NOTIFICATION_OP_DATA_EXTRA_INFO_2:
695 *((int *)data) = noti_op->extra_info_2;
698 return NOTIFICATION_ERROR_INVALID_PARAMETER;
702 return NOTIFICATION_ERROR_NONE;
706 /* LCOV_EXCL_START */
707 EXPORT_API int notification_set_pkgname(notification_h noti,
710 /* check noti and pkgname are valid data */
711 if (noti == NULL || pkgname == NULL)
712 return NOTIFICATION_ERROR_INVALID_PARAMETER;
714 /* Remove previous caller pkgname */
715 if (noti->caller_pkgname) {
716 free(noti->caller_pkgname);
717 noti->caller_pkgname = NULL;
720 noti->caller_pkgname = strdup(pkgname);
722 return NOTIFICATION_ERROR_NONE;
726 /* LCOV_EXCL_START */
727 EXPORT_API int notification_delete_all_by_type(const char *pkgname,
728 notification_type_e type)
731 char *caller_pkgname = NULL;
733 if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
734 return NOTIFICATION_ERROR_INVALID_PARAMETER;
737 caller_pkgname = notification_get_pkgname_by_pid();
739 caller_pkgname = strdup(pkgname);
741 ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
744 free(caller_pkgname);
750 /* LCOV_EXCL_START */
751 EXPORT_API int notification_delete_by_priv_id(const char *pkgname,
752 notification_type_e type,
756 char *caller_pkgname = NULL;
758 if (priv_id <= NOTIFICATION_PRIV_ID_NONE)
759 return NOTIFICATION_ERROR_INVALID_PARAMETER;
762 caller_pkgname = notification_get_pkgname_by_pid();
764 caller_pkgname = strdup(pkgname);
766 ret = notification_ipc_request_delete_single(type, caller_pkgname, priv_id);
769 free(caller_pkgname);
775 /* LCOV_EXCL_START */
776 EXPORT_API int notification_set_execute_option(notification_h noti,
777 notification_execute_type_e type,
780 bundle *service_handle)
782 char buf_key[32] = { 0, };
783 char *ret_val = NULL;
787 return NOTIFICATION_ERROR_INVALID_PARAMETER;
789 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
790 || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
791 return NOTIFICATION_ERROR_INVALID_PARAMETER;
793 /* Create execute option bundle if does not exist */
794 if (noti->b_execute_option == NULL)
795 noti->b_execute_option = bundle_create();
797 b = noti->b_execute_option;
802 snprintf(buf_key, sizeof(buf_key), "text%d", type);
804 /* Check text key exist */
805 bundle_get_str(b, buf_key, &ret_val);
807 /* Remove previous data */
808 bundle_del(b, buf_key);
811 bundle_add_str(b, buf_key, text);
817 snprintf(buf_key, sizeof(buf_key), "key%d", type);
819 /* Check key key exist */
820 bundle_get_str(b, buf_key, &ret_val);
822 /* Remove previous data */
823 bundle_del(b, buf_key);
826 bundle_add_str(b, buf_key, key);
830 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
831 /* Remove previous data if exist */
832 if (noti->b_service_responding != NULL) {
833 bundle_free(noti->b_service_responding);
834 noti->b_service_responding = NULL;
837 /* Save service handle */
838 if (service_handle != NULL)
839 noti->b_service_responding = bundle_dup(service_handle);
842 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
843 /* Remove previous data if exist */
844 if (noti->b_service_single_launch != NULL) {
845 bundle_free(noti->b_service_single_launch);
846 noti->b_service_single_launch = NULL;
849 /* Save service handle */
850 if (service_handle != NULL)
851 noti->b_service_single_launch =
852 bundle_dup(service_handle);
855 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
856 /* Remove previous data if exist */
857 if (noti->b_service_multi_launch != NULL) {
858 bundle_free(noti->b_service_multi_launch);
859 noti->b_service_multi_launch = NULL;
862 /* Save service handle */
863 if (service_handle != NULL)
864 noti->b_service_multi_launch =
865 bundle_dup(service_handle);
870 return NOTIFICATION_ERROR_NONE;
874 /* LCOV_EXCL_START */
875 EXPORT_API int notification_get_id(notification_h noti,
876 int *group_id, int *priv_id)
878 /* check noti is valid data */
880 return NOTIFICATION_ERROR_INVALID_PARAMETER;
882 /* Check group_id is valid data */
885 if (noti->group_id < NOTIFICATION_GROUP_ID_NONE)
886 *group_id = NOTIFICATION_GROUP_ID_NONE;
888 *group_id = noti->group_id;
891 /* Check priv_id is valid data */
894 *priv_id = noti->priv_id;
896 return NOTIFICATION_ERROR_NONE;
900 /* LCOV_EXCL_START */
901 EXPORT_API notification_h notification_load(char *pkgname,
905 notification_h noti = NULL;
907 noti = (notification_h)calloc(1, sizeof(struct _notification));
909 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
913 ret = notification_ipc_request_load_noti_by_priv_id(noti, pkgname, priv_id);
914 if (ret != NOTIFICATION_ERROR_NONE) {
915 notification_free(noti);
923 EXPORT_API notification_h notification_new(notification_type_e type,
924 int group_id, int priv_id)
926 return notification_create(type); //LCOV_EXCL_LINE
929 static void _notification_get_text_domain(notification_h noti)
932 if (noti->domain != NULL) {
936 if (noti->dir != NULL) {
942 /* LCOV_EXCL_START */
943 EXPORT_API int notification_get_execute_option(notification_h noti,
944 notification_execute_type_e type,
946 bundle **service_handle)
948 char buf_key[32] = { 0, };
949 char *ret_val = NULL;
950 char *get_str = NULL;
954 return NOTIFICATION_ERROR_INVALID_PARAMETER;
956 if (type <= NOTIFICATION_EXECUTE_TYPE_NONE
957 || type >= NOTIFICATION_EXECUTE_TYPE_MAX)
958 return NOTIFICATION_ERROR_INVALID_PARAMETER;
962 case NOTIFICATION_EXECUTE_TYPE_RESPONDING:
963 b = noti->b_service_responding;
965 case NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH:
966 b = noti->b_service_single_launch;
968 case NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH:
969 b = noti->b_service_multi_launch;
978 /* Get text domain and dir */
979 if (noti->domain == NULL || noti->dir == NULL)
980 _notification_get_text_domain(noti);
983 snprintf(buf_key, sizeof(buf_key), "key%d", type);
985 /* Check key key exist */
986 bundle_get_str(b, buf_key, &ret_val);
987 if (ret_val != NULL && noti->domain != NULL
988 && noti->dir != NULL) {
989 /* Get application string */
990 bindtextdomain(noti->domain, noti->dir);
992 get_str = dgettext(noti->domain, ret_val);
995 } else if (ret_val != NULL) {
996 /* Get system string */
997 get_str = dgettext("sys_string", ret_val);
1001 /* Get basic text */
1002 snprintf(buf_key, sizeof(buf_key), "text%d",
1005 bundle_get_str(b, buf_key, &ret_val);
1012 if (service_handle != NULL)
1013 *service_handle = b;
1015 return NOTIFICATION_ERROR_NONE;
1017 /* LCOV_EXCL_STOP */
1019 EXPORT_API int notification_insert(notification_h noti,
1025 /* Check noti is vaild data */
1027 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1029 /* Check noti type is valid type */
1030 if (noti->type <= NOTIFICATION_TYPE_NONE
1031 || noti->type >= NOTIFICATION_TYPE_MAX)
1032 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1034 /* Save insert time */
1035 noti->insert_time = time(NULL);
1036 ret = notification_ipc_request_insert(noti, &id);
1037 if (ret != NOTIFICATION_ERROR_NONE)
1041 NOTIFICATION_DBG("from master:%d", id);
1043 /* If priv_id is valid data, set priv_id */
1044 if (priv_id != NULL)
1045 *priv_id = noti->priv_id;
1047 return NOTIFICATION_ERROR_NONE;
1050 EXPORT_API int notification_update_async(notification_h noti,
1051 void (*result_cb)(int priv_id, int result, void *data), void *user_data)
1056 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1058 /* Update insert time ? */
1059 noti->insert_time = time(NULL);
1060 ret = notification_ipc_request_update_async(noti, result_cb, user_data);
1065 EXPORT_API int notification_register_detailed_changed_cb(
1066 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
1069 notification_cb_list_s *noti_cb_list_new = NULL;
1070 notification_cb_list_s *noti_cb_list = NULL;
1072 if (detailed_changed_cb == NULL)
1073 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1075 if (notification_ipc_monitor_init() != NOTIFICATION_ERROR_NONE)
1076 return NOTIFICATION_ERROR_IO_ERROR;
1079 (notification_cb_list_s *) malloc(sizeof(notification_cb_list_s));
1081 if (noti_cb_list_new == NULL) {
1082 NOTIFICATION_ERR("malloc failed");
1083 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
1086 noti_cb_list_new->next = NULL;
1087 noti_cb_list_new->prev = NULL;
1089 noti_cb_list_new->cb_type = NOTIFICATION_CB_DETAILED;
1090 noti_cb_list_new->changed_cb = NULL;
1091 noti_cb_list_new->detailed_changed_cb = detailed_changed_cb;
1092 noti_cb_list_new->data = user_data;
1094 if (g_notification_cb_list == NULL) {
1095 g_notification_cb_list = noti_cb_list_new;
1097 noti_cb_list = g_notification_cb_list;
1099 while (noti_cb_list->next != NULL)
1100 noti_cb_list = noti_cb_list->next;
1103 noti_cb_list->next = noti_cb_list_new;
1104 noti_cb_list_new->prev = noti_cb_list;
1106 return NOTIFICATION_ERROR_NONE;
1109 EXPORT_API int notification_unregister_detailed_changed_cb(
1110 void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
1113 notification_cb_list_s *noti_cb_list = NULL;
1114 notification_cb_list_s *noti_cb_list_prev = NULL;
1115 notification_cb_list_s *noti_cb_list_next = NULL;
1117 noti_cb_list = g_notification_cb_list;
1119 if (detailed_changed_cb == NULL)
1120 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1122 if (noti_cb_list == NULL)
1123 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1126 while (noti_cb_list->prev != NULL)
1127 noti_cb_list = noti_cb_list->prev;
1131 if (noti_cb_list->detailed_changed_cb == detailed_changed_cb) {
1132 noti_cb_list_prev = noti_cb_list->prev;
1133 noti_cb_list_next = noti_cb_list->next;
1135 if (noti_cb_list_prev == NULL)
1136 g_notification_cb_list = noti_cb_list_next;
1138 noti_cb_list_prev->next = noti_cb_list_next;
1140 if (noti_cb_list_next == NULL) {
1141 if (noti_cb_list_prev != NULL)
1142 noti_cb_list_prev->next = NULL;
1145 noti_cb_list_next->prev = noti_cb_list_prev;
1150 if (g_notification_cb_list == NULL)
1151 notification_ipc_monitor_fini();
1153 return NOTIFICATION_ERROR_NONE;
1155 noti_cb_list = noti_cb_list->next;
1156 } while (noti_cb_list != NULL);
1158 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1161 EXPORT_API int notification_is_service_ready(void)
1163 return notification_ipc_is_master_ready();