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.
31 #include <com-core_packet.h>
33 #include <notification_ipc.h>
34 #include <notification_db.h>
35 #include <notification_type.h>
36 #include <notification_internal.h>
37 #include <notification_debug.h>
39 #define NOTIFICATION_IPC_TIMEOUT 1.0
41 #if !defined(VCONFKEY_MASTER_STARTED)
42 #define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started"
48 const char *socket_file;
50 int (*request_cb)(const char *appid, const char *name, int type, const char *content, const char *icon, pid_t pid, double period, int allow_duplicate, void *data);
54 int is_started_cb_set_svc;
55 int is_started_cb_set_task;
59 .socket_file = NOTIFICATION_ADDR,
61 .is_started_cb_set_svc = 0,
62 .is_started_cb_set_task = 0,
65 typedef struct _task_list task_list;
70 void (*task_cb) (void *data);
74 static task_list *g_task_list;
76 static notification_error_e notification_ipc_monitor_register(void);
77 static notification_error_e notification_ipc_monitor_deregister(void);
78 static void _do_deffered_task(void);
79 static void _master_started_cb_task(keynode_t *node, void *data);
82 * functions to check state of master
84 static inline void _set_master_started_cb(vconf_callback_fn cb) {
87 ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED,
90 NOTIFICATION_ERR("failed to notify key(%s) : %d",
91 VCONFKEY_MASTER_STARTED, ret);
95 static inline void _unset_master_started_cb(vconf_callback_fn cb) {
98 ret = vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED,
101 NOTIFICATION_ERR("failed to notify key(%s) : %d",
102 VCONFKEY_MASTER_STARTED, ret);
106 int notification_ipc_is_master_ready(void)
108 int ret = -1, is_master_started = 0;
110 ret = vconf_get_bool(VCONFKEY_MASTER_STARTED, &is_master_started);
111 if (ret == 0 && is_master_started == 1) {
112 NOTIFICATION_ERR("the master has been started");
114 is_master_started = 0;
115 NOTIFICATION_ERR("the master has been stopped");
118 return is_master_started;
122 notification_ipc_add_deffered_task(
123 void (*deffered_task_cb)(void *data),
126 task_list *list = NULL;
127 task_list *list_new = NULL;
130 (task_list *) malloc(sizeof(task_list));
132 if (list_new == NULL) {
133 return NOTIFICATION_ERROR_NO_MEMORY;
136 if (s_info.is_started_cb_set_task == 0) {
137 _set_master_started_cb(_master_started_cb_task);
138 s_info.is_started_cb_set_task = 1;
141 list_new->next = NULL;
142 list_new->prev = NULL;
144 list_new->task_cb = deffered_task_cb;
145 list_new->data = user_data;
147 if (g_task_list == NULL) {
148 g_task_list = list_new;
152 while (list->next != NULL) {
156 list->next = list_new;
157 list_new->prev = list;
159 return NOTIFICATION_ERROR_NONE;
163 notification_ipc_del_deffered_task(
164 void (*deffered_task_cb)(void *data))
166 task_list *list_del = NULL;
167 task_list *list_prev = NULL;
168 task_list *list_next = NULL;
170 list_del = g_task_list;
172 if (list_del == NULL) {
173 return NOTIFICATION_ERROR_INVALID_DATA;
176 while (list_del->prev != NULL) {
177 list_del = list_del->prev;
181 if (list_del->task_cb == deffered_task_cb) {
182 list_prev = list_del->prev;
183 list_next = list_del->next;
185 if (list_prev == NULL) {
186 g_task_list = list_next;
188 list_prev->next = list_next;
191 if (list_next == NULL) {
192 if (list_prev != NULL) {
193 list_prev->next = NULL;
196 list_next->prev = list_prev;
201 if (g_task_list == NULL) {
202 if (s_info.is_started_cb_set_task == 1) {
203 _unset_master_started_cb(_master_started_cb_task);
204 s_info.is_started_cb_set_task = 0;
208 return NOTIFICATION_ERROR_NONE;
210 list_del = list_del->next;
211 } while (list_del != NULL);
213 return NOTIFICATION_ERROR_INVALID_DATA;
216 static void _do_deffered_task(void) {
217 task_list *list_do = NULL;
218 task_list *list_temp = NULL;
220 if (g_task_list == NULL) {
224 list_do = g_task_list;
226 if (s_info.is_started_cb_set_task == 1) {
227 _unset_master_started_cb(_master_started_cb_task);
228 s_info.is_started_cb_set_task = 0;
231 while (list_do->prev != NULL) {
232 list_do = list_do->prev;
235 while (list_do != NULL) {
236 if (list_do->task_cb != NULL) {
237 list_do->task_cb(list_do->data);
238 NOTIFICATION_DBG("called:%p", list_do->task_cb);
240 list_temp = list_do->next;
246 static void _master_started_cb_service(keynode_t *node,
248 int ret = NOTIFICATION_ERROR_NONE;
250 if (notification_ipc_is_master_ready()) {
251 ret = notification_ipc_monitor_register();
252 if (ret != NOTIFICATION_ERROR_NONE) {
253 NOTIFICATION_ERR("failed to register a monitor");
256 ret = notification_ipc_monitor_deregister();
257 if (ret != NOTIFICATION_ERROR_NONE) {
258 NOTIFICATION_ERR("failed to deregister a monitor");
263 static void _master_started_cb_task(keynode_t *node,
266 if (notification_ipc_is_master_ready()) {
272 * functions to create operation list
274 notification_op *notification_ipc_create_op(notification_op_type_e type, int num_op, int *list_priv_id, int num_priv_id, notification_h *noti_list)
277 notification_op *op_list = NULL;
283 op_list = (notification_op *)malloc(sizeof(notification_op) * num_op);
284 memset(op_list, 0x0, sizeof(notification_op) * num_op);
286 for (i = 0; i < num_op; i++) {
287 (op_list + i)->type = type;
288 if (list_priv_id != NULL) {
289 (op_list + i)->priv_id = *(list_priv_id + i);
291 if (noti_list != NULL) {
292 (op_list + i)->noti = *(noti_list + i);
300 * utility functions creating notification packet
302 static inline char *_dup_string(const char *string)
306 if (string == NULL) {
309 if (string[0] == '\0') {
313 ret = strdup(string);
315 NOTIFICATION_ERR("Error: %s\n", strerror(errno));
320 static inline bundle *_create_bundle_from_string(unsigned char *string)
322 if (string == NULL) {
325 if (string[0] == '\0') {
329 return bundle_decode(string, strlen((char *)string));
333 * functions creating notification packet
335 EXPORT_API notification_error_e notification_ipc_make_noti_from_packet(notification_h noti, const struct packet *packet)
341 int internal_group_id;
343 char *caller_pkgname = NULL;
344 char *launch_pkgname = NULL;
345 unsigned char *args = NULL;
346 unsigned char *group_args = NULL;
347 unsigned char *b_execute_option = NULL;
348 unsigned char *b_service_responding = NULL;
349 unsigned char *b_service_single_launch = NULL;
350 unsigned char *b_service_multi_launch = NULL;
353 unsigned char *b_text = NULL;
354 unsigned char *b_key = NULL;
355 unsigned char *b_format_args = NULL;
357 unsigned char *b_image_path = NULL;
359 char *sound_path = NULL;
361 char *vibration_path = NULL;
368 int flags_for_property;
370 double progress_size;
371 double progress_percentage;
372 char *app_icon_path = NULL;
373 char *app_name = NULL;
374 char *temp_title = NULL;
375 char *temp_content = NULL;
378 NOTIFICATION_ERR("invalid data");
379 return NOTIFICATION_ERROR_INVALID_DATA;
382 ret = packet_get(packet,
383 "iiiiisssssssssssssisisisiiiiiiiiddssss",
394 &b_service_responding,
395 &b_service_single_launch,
396 &b_service_multi_launch,
417 &progress_percentage,
424 NOTIFICATION_ERR("failed to create a noti from packet");
425 return NOTIFICATION_ERROR_INVALID_DATA;
429 * This is already allocated from the notification_create function.
430 * Before reallocate string to here.
431 * We have to release old one first.
433 free(noti->caller_pkgname);
434 noti->caller_pkgname = _dup_string(caller_pkgname);
435 noti->launch_pkgname = _dup_string(launch_pkgname);
436 noti->args = _create_bundle_from_string(args);
437 noti->group_args = _create_bundle_from_string(group_args);
438 noti->b_execute_option = _create_bundle_from_string(b_execute_option);
439 noti->b_service_responding = _create_bundle_from_string(b_service_responding);
440 noti->b_service_single_launch = _create_bundle_from_string(b_service_single_launch);
441 noti->b_service_multi_launch = _create_bundle_from_string(b_service_multi_launch);
442 noti->domain = _dup_string(domain);
443 noti->dir = _dup_string(dir);
444 noti->b_text = _create_bundle_from_string(b_text);
445 noti->b_key = _create_bundle_from_string(b_key);
446 noti->b_format_args = _create_bundle_from_string(b_format_args);
447 noti->b_image_path = _create_bundle_from_string(b_image_path);
448 noti->sound_path = _dup_string(sound_path);
449 noti->vibration_path = _dup_string(vibration_path);
450 noti->app_icon_path = _dup_string(app_icon_path);
451 noti->app_name = _dup_string(app_name);
452 noti->temp_title = _dup_string(temp_title);
453 noti->temp_content = _dup_string(temp_content);
456 noti->layout = layout;
457 noti->group_id = group_id;
458 noti->internal_group_id = internal_group_id;
459 noti->priv_id = priv_id;
460 noti->num_format_args = num_format_args;
461 noti->sound_type = sound_type;
462 noti->vibration_type = vibration_type;
463 noti->led_operation = led_operation;
464 noti->led_argb = led_argb;
465 noti->led_on_ms = led_on_ms;
466 noti->led_off_ms = led_off_ms;
468 noti->insert_time = insert_time;
469 noti->flags_for_property = flags_for_property;
470 noti->display_applist = display_applist;
471 noti->progress_size = progress_size;
472 noti->progress_percentage = progress_percentage;
474 return NOTIFICATION_ERROR_NONE;
477 EXPORT_API struct packet *notification_ipc_make_packet_from_noti(notification_h noti, const char *command, int packet_type)
479 struct packet *result = NULL;
481 char *group_args = NULL;
482 char *b_image_path = NULL;
483 char *b_execute_option = NULL;
484 char *b_service_responding = NULL;
485 char *b_service_single_launch = NULL;
486 char *b_service_multi_launch = NULL;
489 char *b_format_args = NULL;
490 int flag_simmode = 0;
491 struct packet *(*func_to_create_packet)(const char *command, const char *fmt, ...);
492 const char *title_key = NULL;
493 char buf_key[32] = { 0, };
495 /* Decode bundle to insert DB */
497 bundle_encode(noti->args, (bundle_raw **) & args, NULL);
499 if (noti->group_args) {
500 bundle_encode(noti->group_args, (bundle_raw **) & group_args,
504 if (noti->b_execute_option) {
505 bundle_encode(noti->b_execute_option,
506 (bundle_raw **) & b_execute_option, NULL);
508 if (noti->b_service_responding) {
509 bundle_encode(noti->b_service_responding,
510 (bundle_raw **) & b_service_responding, NULL);
512 if (noti->b_service_single_launch) {
513 bundle_encode(noti->b_service_single_launch,
514 (bundle_raw **) & b_service_single_launch, NULL);
516 if (noti->b_service_multi_launch) {
517 bundle_encode(noti->b_service_multi_launch,
518 (bundle_raw **) & b_service_multi_launch, NULL);
522 bundle_encode(noti->b_text, (bundle_raw **) & b_text, NULL);
525 bundle_encode(noti->b_key, (bundle_raw **) & b_key, NULL);
527 if (noti->b_format_args) {
528 bundle_encode(noti->b_format_args,
529 (bundle_raw **) & b_format_args, NULL);
532 if (noti->b_image_path) {
533 bundle_encode(noti->b_image_path,
534 (bundle_raw **) & b_image_path, NULL);
537 /* Check only simmode property is enable */
538 if (noti->flags_for_property & NOTIFICATION_PROP_DISPLAY_ONLY_SIMMODE) {
542 if (noti->b_key != NULL) {
543 snprintf(buf_key, sizeof(buf_key), "%d",
544 NOTIFICATION_TEXT_TYPE_TITLE);
546 title_key = bundle_get_val(noti->b_key, buf_key);
549 if (title_key == NULL && noti->b_text != NULL) {
550 snprintf(buf_key, sizeof(buf_key), "%d",
551 NOTIFICATION_TEXT_TYPE_TITLE);
553 title_key = bundle_get_val(noti->b_text, buf_key);
556 if (title_key == NULL) {
557 title_key = noti->caller_pkgname;
560 if (packet_type == 1)
561 func_to_create_packet = packet_create;
562 else if (packet_type == 2)
563 func_to_create_packet = packet_create_noack;
568 result = func_to_create_packet(command,
569 "iiiiisssssssssssssisisisiiiiiiiiddssss",
573 noti->internal_group_id,
575 NOTIFICATION_CHECK_STR(noti->caller_pkgname),
576 NOTIFICATION_CHECK_STR(noti->launch_pkgname),
577 NOTIFICATION_CHECK_STR(args),
578 NOTIFICATION_CHECK_STR(group_args),
579 NOTIFICATION_CHECK_STR(b_execute_option),
580 NOTIFICATION_CHECK_STR(b_service_responding),
581 NOTIFICATION_CHECK_STR(b_service_single_launch),
582 NOTIFICATION_CHECK_STR(b_service_multi_launch),
583 NOTIFICATION_CHECK_STR(noti->domain),
584 NOTIFICATION_CHECK_STR(noti->dir),
585 NOTIFICATION_CHECK_STR(b_text),
586 NOTIFICATION_CHECK_STR(b_key),
587 NOTIFICATION_CHECK_STR(b_format_args),
588 noti->num_format_args,
589 NOTIFICATION_CHECK_STR(b_image_path),
591 NOTIFICATION_CHECK_STR(noti->sound_path),
592 noti->vibration_type,
593 NOTIFICATION_CHECK_STR(noti->vibration_path),
600 noti->flags_for_property,
601 noti->display_applist,
603 noti->progress_percentage,
604 NOTIFICATION_CHECK_STR(noti->app_icon_path),
605 NOTIFICATION_CHECK_STR(noti->app_name),
606 NOTIFICATION_CHECK_STR(noti->temp_title),
607 NOTIFICATION_CHECK_STR(noti->temp_content));
610 /* Free decoded data */
618 if (b_execute_option) {
619 free(b_execute_option);
621 if (b_service_responding) {
622 free(b_service_responding);
624 if (b_service_single_launch) {
625 free(b_service_single_launch);
627 if (b_service_multi_launch) {
628 free(b_service_multi_launch);
649 * functions to handler services
651 static struct packet *_handler_insert(pid_t pid, int handle, const struct packet *packet)
653 notification_h noti = NULL;
656 NOTIFICATION_ERR("a packet is null");
659 noti = notification_create(NOTIFICATION_TYPE_NOTI);
661 NOTIFICATION_ERR("failed to create a notification");
664 notification_ipc_make_noti_from_packet(noti, packet);
666 if (noti->flags_for_property
667 & NOTIFICATION_PROP_DISABLE_UPDATE_ON_INSERT) {
668 /* Disable changed cb */
670 /* Enable changed cb */
671 notification_op *noti_op = notification_ipc_create_op(NOTIFICATION_OP_INSERT, 1, &(noti->priv_id), 1, ¬i);
672 if (noti_op != NULL) {
673 notification_call_changed_cb(noti_op, 1);
677 notification_free(noti);
682 static struct packet *_handler_update(pid_t pid, int handle, const struct packet *packet)
684 notification_h noti = NULL;
687 NOTIFICATION_ERR("a packet is null");
691 noti = notification_create(NOTIFICATION_TYPE_NOTI);
693 NOTIFICATION_ERR("failed to create a notification");
697 notification_ipc_make_noti_from_packet(noti, packet);
699 notification_op *noti_op = notification_ipc_create_op(NOTIFICATION_OP_UPDATE, 1, &(noti->priv_id), 1, ¬i);
700 if (noti_op != NULL) {
701 notification_call_changed_cb(noti_op, 1);
705 notification_free(noti);
710 static struct packet *_handler_refresh(pid_t pid, int handle, const struct packet *packet)
713 NOTIFICATION_ERR("a packet is null");
716 notification_op *noti_op = notification_ipc_create_op(NOTIFICATION_OP_REFRESH, 1, NULL, 0, NULL);
717 if (noti_op != NULL) {
718 notification_call_changed_cb(noti_op, 1);
725 static struct packet *_handler_delete_single(pid_t pid, int handle, const struct packet *packet)
728 int priv_id = NOTIFICATION_PRIV_ID_NONE;
731 NOTIFICATION_ERR("a packet is null");
734 if (packet_get(packet, "ii", &num_deleted, &priv_id) == 2) {
735 notification_op *noti_op = notification_ipc_create_op(NOTIFICATION_OP_DELETE, 1, &priv_id, 1, NULL);
736 if (noti_op != NULL) {
737 notification_call_changed_cb(noti_op, 1);
745 static struct packet *_handler_delete_multiple(pid_t pid, int handle, const struct packet *packet)
751 NOTIFICATION_ERR("delete_noti_multiple");
754 NOTIFICATION_ERR("a packet is null");
757 ret = packet_get(packet, "iiiiiiiiiii", &num_deleted,
769 NOTIFICATION_ERR("packet data count:%d", ret);
770 NOTIFICATION_ERR("packet data num deleted:%d", num_deleted);
773 for (i = 0 ; i < 10 ; i++) {
774 NOTIFICATION_ERR("packet data[%d]:%d",i, buf[i]);
778 notification_op *noti_op = notification_ipc_create_op(
779 NOTIFICATION_OP_DELETE, num_deleted, buf, num_deleted, NULL);
780 if (noti_op != NULL) {
781 notification_call_changed_cb(noti_op, num_deleted);
789 static int _handler_service_register(pid_t pid, int handle, const struct packet *packet, void *data)
794 NOTIFICATION_ERR("Packet is not valid\n");
795 ret = NOTIFICATION_ERROR_INVALID_DATA;
796 } else if (packet_get(packet, "i", &ret) != 1) {
797 NOTIFICATION_ERR("Packet is not valid\n");
798 ret = NOTIFICATION_ERROR_INVALID_DATA;
801 notification_op *noti_op = notification_ipc_create_op(NOTIFICATION_OP_SERVICE_READY, 1, NULL, 1, NULL);
802 if (noti_op != NULL) {
803 notification_call_changed_cb(noti_op, 1);
812 * functions to initialize and register a monitor
814 static notification_error_e notification_ipc_monitor_register(void)
817 struct packet *packet;
818 static struct method service_table[] = {
821 .handler = _handler_insert,
824 .cmd = "update_noti",
825 .handler = _handler_update,
828 .cmd = "refresh_noti",
829 .handler = _handler_refresh,
832 .cmd = "del_noti_single",
833 .handler = _handler_delete_single,
836 .cmd = "del_noti_multiple",
837 .handler = _handler_delete_multiple,
845 if (s_info.initialized == 1) {
846 return NOTIFICATION_ERROR_NONE;
848 s_info.initialized = 1;
851 NOTIFICATION_ERR("register a service\n");
853 s_info.server_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table);
854 if (s_info.server_fd < 0) {
855 NOTIFICATION_ERR("Failed to make a connection to the master\n");
856 return NOTIFICATION_ERROR_IO;
859 packet = packet_create("service_register", "");
861 NOTIFICATION_ERR("Failed to build a packet\n");
862 return NOTIFICATION_ERROR_IO;
865 ret = com_core_packet_async_send(s_info.server_fd, packet, 1.0, _handler_service_register, NULL);
866 NOTIFICATION_DBG("Service register sent: %d\n", ret);
867 packet_destroy(packet);
869 com_core_packet_client_fini(s_info.server_fd);
870 s_info.server_fd = NOTIFICATION_ERROR_INVALID_DATA;
871 ret = NOTIFICATION_ERROR_IO;
873 ret = NOTIFICATION_ERROR_NONE;
876 NOTIFICATION_DBG("Server FD: %d\n", s_info.server_fd);
880 notification_error_e notification_ipc_monitor_deregister(void)
882 if (s_info.initialized == 0) {
883 return NOTIFICATION_ERROR_NONE;
886 com_core_packet_client_fini(s_info.server_fd);
887 s_info.server_fd = NOTIFICATION_ERROR_INVALID_DATA;
889 s_info.initialized = 0;
891 return NOTIFICATION_ERROR_NONE;
894 notification_error_e notification_ipc_monitor_init(void)
896 int ret = NOTIFICATION_ERROR_NONE;
898 if (notification_ipc_is_master_ready()) {
899 ret = notification_ipc_monitor_register();
902 if (s_info.is_started_cb_set_svc == 0) {
903 _set_master_started_cb(_master_started_cb_service);
904 s_info.is_started_cb_set_svc = 1;
910 notification_error_e notification_ipc_monitor_fini(void)
912 int ret = NOTIFICATION_ERROR_NONE;
914 if (s_info.is_started_cb_set_svc == 1) {
915 _unset_master_started_cb(_master_started_cb_service);
916 s_info.is_started_cb_set_svc = 0;
919 ret = notification_ipc_monitor_deregister();
925 * functions to request the service
927 notification_error_e notification_ipc_request_insert(notification_h noti, int *priv_id)
930 int id = NOTIFICATION_PRIV_ID_NONE;
931 struct packet *packet;
932 struct packet *result;
934 /* Initialize private ID */
935 noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
936 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
937 noti->internal_group_id = NOTIFICATION_GROUP_ID_NONE;
939 packet = notification_ipc_make_packet_from_noti(noti, "add_noti", 1);
940 result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
942 NOTIFICATION_IPC_TIMEOUT);
943 packet_destroy(packet);
945 if (result != NULL) {
946 if (packet_get(result, "ii", &status, &id) != 2) {
947 NOTIFICATION_ERR("Failed to get a result packet");
948 packet_unref(result);
949 return NOTIFICATION_ERROR_IO;
952 if (status != NOTIFICATION_ERROR_NONE) {
953 packet_unref(result);
956 packet_unref(result);
958 notification_ipc_is_master_ready();
959 return NOTIFICATION_ERROR_SERVICE_NOT_READY;
962 if (priv_id != NULL) {
966 return NOTIFICATION_ERROR_NONE;
969 notification_error_e notification_ipc_request_delete_single(notification_type_e type, char *pkgname, int priv_id)
972 int id = NOTIFICATION_PRIV_ID_NONE;
973 struct packet *packet;
974 struct packet *result;
976 packet = packet_create("del_noti_single", "si", pkgname, priv_id);
977 result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
979 NOTIFICATION_IPC_TIMEOUT);
980 packet_destroy(packet);
982 if (result != NULL) {
983 if (packet_get(result, "ii", &status, &id) != 2) {
984 NOTIFICATION_ERR("Failed to get a result packet");
985 packet_unref(result);
986 return NOTIFICATION_ERROR_IO;
988 packet_unref(result);
990 notification_ipc_is_master_ready();
991 return NOTIFICATION_ERROR_SERVICE_NOT_READY;
997 notification_error_e notification_ipc_request_delete_multiple(notification_type_e type, char *pkgname)
1000 int num_deleted = 0;
1001 struct packet *packet;
1002 struct packet *result;
1004 packet = packet_create("del_noti_multiple", "si", pkgname, type);
1005 result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
1007 NOTIFICATION_IPC_TIMEOUT);
1008 packet_destroy(packet);
1010 if (result != NULL) {
1011 if (packet_get(result, "ii", &status, &num_deleted) != 2) {
1012 NOTIFICATION_ERR("Failed to get a result packet");
1013 packet_unref(result);
1014 return NOTIFICATION_ERROR_IO;
1016 NOTIFICATION_ERR("num deleted:%d", num_deleted);
1017 packet_unref(result);
1019 notification_ipc_is_master_ready();
1020 return NOTIFICATION_ERROR_SERVICE_NOT_READY;
1026 notification_error_e notification_ipc_request_update(notification_h noti)
1029 int id = NOTIFICATION_PRIV_ID_NONE;
1030 struct packet *packet;
1031 struct packet *result;
1033 packet = notification_ipc_make_packet_from_noti(noti, "update_noti", 1);
1034 result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
1036 NOTIFICATION_IPC_TIMEOUT);
1037 packet_destroy(packet);
1039 if (result != NULL) {
1040 if (packet_get(result, "ii", &status, &id) != 2) {
1041 NOTIFICATION_ERR("Failed to get a result packet");
1042 packet_unref(result);
1043 return NOTIFICATION_ERROR_IO;
1045 packet_unref(result);
1047 notification_ipc_is_master_ready();
1048 return NOTIFICATION_ERROR_SERVICE_NOT_READY;
1054 notification_error_e notification_ipc_request_refresh(void)
1057 struct packet *packet;
1058 struct packet *result;
1060 packet = packet_create("refresh_noti", "i", NOTIFICATION_OP_REFRESH);
1061 result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
1063 NOTIFICATION_IPC_TIMEOUT);
1064 packet_destroy(packet);
1066 if (result != NULL) {
1067 if (packet_get(result, "i", &status) != 1) {
1068 NOTIFICATION_ERR("Failed to get a result packet");
1069 packet_unref(result);
1070 return NOTIFICATION_ERROR_IO;
1072 packet_unref(result);
1074 notification_ipc_is_master_ready();
1075 return NOTIFICATION_ERROR_SERVICE_NOT_READY;