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;
366 int flags_for_property;
368 double progress_size;
369 double progress_percentage;
370 char *app_icon_path = NULL;
371 char *app_name = NULL;
372 char *temp_title = NULL;
373 char *temp_content = NULL;
376 NOTIFICATION_ERR("invalid data");
377 return NOTIFICATION_ERROR_INVALID_DATA;
380 ret = packet_get(packet,
381 "iiiiisssssssssssssisisisiiiiiiddssss",
392 &b_service_responding,
393 &b_service_single_launch,
394 &b_service_multi_launch,
413 &progress_percentage,
420 NOTIFICATION_ERR("failed to create a noti from packet");
421 return NOTIFICATION_ERROR_INVALID_DATA;
425 * This is already allocated from the notification_create function.
426 * Before reallocate string to here.
427 * We have to release old one first.
429 free(noti->caller_pkgname);
430 noti->caller_pkgname = _dup_string(caller_pkgname);
431 noti->launch_pkgname = _dup_string(launch_pkgname);
432 noti->args = _create_bundle_from_string(args);
433 noti->group_args = _create_bundle_from_string(group_args);
434 noti->b_execute_option = _create_bundle_from_string(b_execute_option);
435 noti->b_service_responding = _create_bundle_from_string(b_service_responding);
436 noti->b_service_single_launch = _create_bundle_from_string(b_service_single_launch);
437 noti->b_service_multi_launch = _create_bundle_from_string(b_service_multi_launch);
438 noti->domain = _dup_string(domain);
439 noti->dir = _dup_string(dir);
440 noti->b_text = _create_bundle_from_string(b_text);
441 noti->b_key = _create_bundle_from_string(b_key);
442 noti->b_format_args = _create_bundle_from_string(b_format_args);
443 noti->b_image_path = _create_bundle_from_string(b_image_path);
444 noti->sound_path = _dup_string(sound_path);
445 noti->vibration_path = _dup_string(vibration_path);
446 noti->app_icon_path = _dup_string(app_icon_path);
447 noti->app_name = _dup_string(app_name);
448 noti->temp_title = _dup_string(temp_title);
449 noti->temp_content = _dup_string(temp_content);
452 noti->layout = layout;
453 noti->group_id = group_id;
454 noti->internal_group_id = internal_group_id;
455 noti->priv_id = priv_id;
456 noti->num_format_args = num_format_args;
457 noti->sound_type = sound_type;
458 noti->vibration_type = vibration_type;
459 noti->led_operation = led_operation;
460 noti->led_argb = led_argb;
462 noti->insert_time = insert_time;
463 noti->flags_for_property = flags_for_property;
464 noti->display_applist = display_applist;
465 noti->progress_size = progress_size;
466 noti->progress_percentage = progress_percentage;
468 return NOTIFICATION_ERROR_NONE;
471 EXPORT_API struct packet *notification_ipc_make_packet_from_noti(notification_h noti, const char *command, int packet_type)
473 struct packet *result = NULL;
475 char *group_args = NULL;
476 char *b_image_path = NULL;
477 char *b_execute_option = NULL;
478 char *b_service_responding = NULL;
479 char *b_service_single_launch = NULL;
480 char *b_service_multi_launch = NULL;
483 char *b_format_args = NULL;
484 int flag_simmode = 0;
485 struct packet *(*func_to_create_packet)(const char *command, const char *fmt, ...);
486 const char *title_key = NULL;
487 char buf_key[32] = { 0, };
489 /* Decode bundle to insert DB */
491 bundle_encode(noti->args, (bundle_raw **) & args, NULL);
493 if (noti->group_args) {
494 bundle_encode(noti->group_args, (bundle_raw **) & group_args,
498 if (noti->b_execute_option) {
499 bundle_encode(noti->b_execute_option,
500 (bundle_raw **) & b_execute_option, NULL);
502 if (noti->b_service_responding) {
503 bundle_encode(noti->b_service_responding,
504 (bundle_raw **) & b_service_responding, NULL);
506 if (noti->b_service_single_launch) {
507 bundle_encode(noti->b_service_single_launch,
508 (bundle_raw **) & b_service_single_launch, NULL);
510 if (noti->b_service_multi_launch) {
511 bundle_encode(noti->b_service_multi_launch,
512 (bundle_raw **) & b_service_multi_launch, NULL);
516 bundle_encode(noti->b_text, (bundle_raw **) & b_text, NULL);
519 bundle_encode(noti->b_key, (bundle_raw **) & b_key, NULL);
521 if (noti->b_format_args) {
522 bundle_encode(noti->b_format_args,
523 (bundle_raw **) & b_format_args, NULL);
526 if (noti->b_image_path) {
527 bundle_encode(noti->b_image_path,
528 (bundle_raw **) & b_image_path, NULL);
531 /* Check only simmode property is enable */
532 if (noti->flags_for_property & NOTIFICATION_PROP_DISPLAY_ONLY_SIMMODE) {
536 if (noti->b_key != NULL) {
537 snprintf(buf_key, sizeof(buf_key), "%d",
538 NOTIFICATION_TEXT_TYPE_TITLE);
540 title_key = bundle_get_val(noti->b_key, buf_key);
543 if (title_key == NULL && noti->b_text != NULL) {
544 snprintf(buf_key, sizeof(buf_key), "%d",
545 NOTIFICATION_TEXT_TYPE_TITLE);
547 title_key = bundle_get_val(noti->b_text, buf_key);
550 if (title_key == NULL) {
551 title_key = noti->caller_pkgname;
554 if (packet_type == 1)
555 func_to_create_packet = packet_create;
556 else if (packet_type == 2)
557 func_to_create_packet = packet_create_noack;
562 result = func_to_create_packet(command,
563 "iiiiisssssssssssssisisisiiiiiiddssss",
567 noti->internal_group_id,
569 NOTIFICATION_CHECK_STR(noti->caller_pkgname),
570 NOTIFICATION_CHECK_STR(noti->launch_pkgname),
571 NOTIFICATION_CHECK_STR(args),
572 NOTIFICATION_CHECK_STR(group_args),
573 NOTIFICATION_CHECK_STR(b_execute_option),
574 NOTIFICATION_CHECK_STR(b_service_responding),
575 NOTIFICATION_CHECK_STR(b_service_single_launch),
576 NOTIFICATION_CHECK_STR(b_service_multi_launch),
577 NOTIFICATION_CHECK_STR(noti->domain),
578 NOTIFICATION_CHECK_STR(noti->dir),
579 NOTIFICATION_CHECK_STR(b_text),
580 NOTIFICATION_CHECK_STR(b_key),
581 NOTIFICATION_CHECK_STR(b_format_args),
582 noti->num_format_args,
583 NOTIFICATION_CHECK_STR(b_image_path),
585 NOTIFICATION_CHECK_STR(noti->sound_path),
586 noti->vibration_type,
587 NOTIFICATION_CHECK_STR(noti->vibration_path),
592 noti->flags_for_property,
593 noti->display_applist,
595 noti->progress_percentage,
596 NOTIFICATION_CHECK_STR(noti->app_icon_path),
597 NOTIFICATION_CHECK_STR(noti->app_name),
598 NOTIFICATION_CHECK_STR(noti->temp_title),
599 NOTIFICATION_CHECK_STR(noti->temp_content));
602 /* Free decoded data */
610 if (b_execute_option) {
611 free(b_execute_option);
613 if (b_service_responding) {
614 free(b_service_responding);
616 if (b_service_single_launch) {
617 free(b_service_single_launch);
619 if (b_service_multi_launch) {
620 free(b_service_multi_launch);
641 * functions to handler services
643 static struct packet *_handler_insert(pid_t pid, int handle, const struct packet *packet)
645 notification_h noti = NULL;
648 NOTIFICATION_ERR("a packet is null");
651 noti = notification_create(NOTIFICATION_TYPE_NOTI);
653 NOTIFICATION_ERR("failed to create a notification");
656 notification_ipc_make_noti_from_packet(noti, packet);
658 if (noti->flags_for_property
659 & NOTIFICATION_PROP_DISABLE_UPDATE_ON_INSERT) {
660 /* Disable changed cb */
662 /* Enable changed cb */
663 notification_op *noti_op = notification_ipc_create_op(NOTIFICATION_OP_INSERT, 1, &(noti->priv_id), 1, ¬i);
664 if (noti_op != NULL) {
665 notification_call_changed_cb(noti_op, 1);
669 notification_free(noti);
674 static struct packet *_handler_update(pid_t pid, int handle, const struct packet *packet)
676 notification_h noti = NULL;
679 NOTIFICATION_ERR("a packet is null");
683 noti = notification_create(NOTIFICATION_TYPE_NOTI);
685 NOTIFICATION_ERR("failed to create a notification");
689 notification_ipc_make_noti_from_packet(noti, packet);
691 notification_op *noti_op = notification_ipc_create_op(NOTIFICATION_OP_UPDATE, 1, &(noti->priv_id), 1, ¬i);
692 if (noti_op != NULL) {
693 notification_call_changed_cb(noti_op, 1);
697 notification_free(noti);
702 static struct packet *_handler_refresh(pid_t pid, int handle, const struct packet *packet)
705 NOTIFICATION_ERR("a packet is null");
708 notification_op *noti_op = notification_ipc_create_op(NOTIFICATION_OP_REFRESH, 1, NULL, 0, NULL);
709 if (noti_op != NULL) {
710 notification_call_changed_cb(noti_op, 1);
717 static struct packet *_handler_delete_single(pid_t pid, int handle, const struct packet *packet)
720 int priv_id = NOTIFICATION_PRIV_ID_NONE;
723 NOTIFICATION_ERR("a packet is null");
726 if (packet_get(packet, "ii", &num_deleted, &priv_id) == 2) {
727 notification_op *noti_op = notification_ipc_create_op(NOTIFICATION_OP_DELETE, 1, &priv_id, 1, NULL);
728 if (noti_op != NULL) {
729 notification_call_changed_cb(noti_op, 1);
737 static struct packet *_handler_delete_multiple(pid_t pid, int handle, const struct packet *packet)
743 NOTIFICATION_ERR("delete_noti_multiple");
746 NOTIFICATION_ERR("a packet is null");
749 ret = packet_get(packet, "iiiiiiiiiii", &num_deleted,
761 NOTIFICATION_ERR("packet data count:%d", ret);
762 NOTIFICATION_ERR("packet data num deleted:%d", num_deleted);
765 for (i = 0 ; i < 10 ; i++) {
766 NOTIFICATION_ERR("packet data[%d]:%d",i, buf[i]);
770 notification_op *noti_op = notification_ipc_create_op(
771 NOTIFICATION_OP_DELETE, num_deleted, buf, num_deleted, NULL);
772 if (noti_op != NULL) {
773 notification_call_changed_cb(noti_op, num_deleted);
781 static int _handler_service_register(pid_t pid, int handle, const struct packet *packet, void *data)
786 NOTIFICATION_ERR("Packet is not valid\n");
787 ret = NOTIFICATION_ERROR_INVALID_DATA;
788 } else if (packet_get(packet, "i", &ret) != 1) {
789 NOTIFICATION_ERR("Packet is not valid\n");
790 ret = NOTIFICATION_ERROR_INVALID_DATA;
793 notification_op *noti_op = notification_ipc_create_op(NOTIFICATION_OP_SERVICE_READY, 1, NULL, 1, NULL);
794 if (noti_op != NULL) {
795 notification_call_changed_cb(noti_op, 1);
804 * functions to initialize and register a monitor
806 static notification_error_e notification_ipc_monitor_register(void)
809 struct packet *packet;
810 static struct method service_table[] = {
813 .handler = _handler_insert,
816 .cmd = "update_noti",
817 .handler = _handler_update,
820 .cmd = "refresh_noti",
821 .handler = _handler_refresh,
824 .cmd = "del_noti_single",
825 .handler = _handler_delete_single,
828 .cmd = "del_noti_multiple",
829 .handler = _handler_delete_multiple,
837 if (s_info.initialized == 1) {
838 return NOTIFICATION_ERROR_NONE;
840 s_info.initialized = 1;
843 NOTIFICATION_ERR("register a service\n");
845 s_info.server_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table);
846 if (s_info.server_fd < 0) {
847 NOTIFICATION_ERR("Failed to make a connection to the master\n");
848 return NOTIFICATION_ERROR_IO;
851 packet = packet_create("service_register", "");
853 NOTIFICATION_ERR("Failed to build a packet\n");
854 return NOTIFICATION_ERROR_IO;
857 ret = com_core_packet_async_send(s_info.server_fd, packet, 1.0, _handler_service_register, NULL);
858 NOTIFICATION_DBG("Service register sent: %d\n", ret);
859 packet_destroy(packet);
861 com_core_packet_client_fini(s_info.server_fd);
862 s_info.server_fd = NOTIFICATION_ERROR_INVALID_DATA;
863 ret = NOTIFICATION_ERROR_IO;
865 ret = NOTIFICATION_ERROR_NONE;
868 NOTIFICATION_DBG("Server FD: %d\n", s_info.server_fd);
872 notification_error_e notification_ipc_monitor_deregister(void)
874 if (s_info.initialized == 0) {
875 return NOTIFICATION_ERROR_NONE;
878 com_core_packet_client_fini(s_info.server_fd);
879 s_info.server_fd = NOTIFICATION_ERROR_INVALID_DATA;
881 s_info.initialized = 0;
883 return NOTIFICATION_ERROR_NONE;
886 notification_error_e notification_ipc_monitor_init(void)
888 int ret = NOTIFICATION_ERROR_NONE;
890 if (notification_ipc_is_master_ready()) {
891 ret = notification_ipc_monitor_register();
894 if (s_info.is_started_cb_set_svc == 0) {
895 _set_master_started_cb(_master_started_cb_service);
896 s_info.is_started_cb_set_svc = 1;
902 notification_error_e notification_ipc_monitor_fini(void)
904 int ret = NOTIFICATION_ERROR_NONE;
906 if (s_info.is_started_cb_set_svc == 1) {
907 _unset_master_started_cb(_master_started_cb_service);
908 s_info.is_started_cb_set_svc = 0;
911 ret = notification_ipc_monitor_deregister();
917 * functions to request the service
919 notification_error_e notification_ipc_request_insert(notification_h noti, int *priv_id)
922 int id = NOTIFICATION_PRIV_ID_NONE;
923 struct packet *packet;
924 struct packet *result;
926 /* Initialize private ID */
927 noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
928 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
929 noti->internal_group_id = NOTIFICATION_GROUP_ID_NONE;
931 packet = notification_ipc_make_packet_from_noti(noti, "add_noti", 1);
932 result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
934 NOTIFICATION_IPC_TIMEOUT);
935 packet_destroy(packet);
937 if (result != NULL) {
938 if (packet_get(result, "ii", &status, &id) != 2) {
939 NOTIFICATION_ERR("Failed to get a result packet");
940 packet_unref(result);
941 return NOTIFICATION_ERROR_IO;
944 if (status != NOTIFICATION_ERROR_NONE) {
948 notification_ipc_is_master_ready();
949 return NOTIFICATION_ERROR_SERVICE_NOT_READY;
952 if (priv_id != NULL) {
956 return NOTIFICATION_ERROR_NONE;
959 notification_error_e notification_ipc_request_delete_single(notification_type_e type, char *pkgname, int priv_id)
962 int id = NOTIFICATION_PRIV_ID_NONE;
963 struct packet *packet;
964 struct packet *result;
966 packet = packet_create("del_noti_single", "si", pkgname, priv_id);
967 result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
969 NOTIFICATION_IPC_TIMEOUT);
970 packet_destroy(packet);
972 if (result != NULL) {
973 if (packet_get(result, "ii", &status, &id) != 2) {
974 NOTIFICATION_ERR("Failed to get a result packet");
975 packet_unref(result);
976 return NOTIFICATION_ERROR_IO;
979 notification_ipc_is_master_ready();
980 return NOTIFICATION_ERROR_SERVICE_NOT_READY;
986 notification_error_e notification_ipc_request_delete_multiple(notification_type_e type, char *pkgname)
990 struct packet *packet;
991 struct packet *result;
993 packet = packet_create("del_noti_multiple", "si", pkgname, type);
994 result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
996 NOTIFICATION_IPC_TIMEOUT);
997 packet_destroy(packet);
999 if (result != NULL) {
1000 if (packet_get(result, "ii", &status, &num_deleted) != 2) {
1001 NOTIFICATION_ERR("Failed to get a result packet");
1002 packet_unref(result);
1003 return NOTIFICATION_ERROR_IO;
1005 NOTIFICATION_ERR("num deleted:%d", num_deleted);
1007 notification_ipc_is_master_ready();
1008 return NOTIFICATION_ERROR_SERVICE_NOT_READY;
1014 notification_error_e notification_ipc_request_update(notification_h noti)
1017 int id = NOTIFICATION_PRIV_ID_NONE;
1018 struct packet *packet;
1019 struct packet *result;
1021 packet = notification_ipc_make_packet_from_noti(noti, "update_noti", 1);
1022 result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
1024 NOTIFICATION_IPC_TIMEOUT);
1025 packet_destroy(packet);
1027 if (result != NULL) {
1028 if (packet_get(result, "ii", &status, &id) != 2) {
1029 NOTIFICATION_ERR("Failed to get a result packet");
1030 packet_unref(result);
1031 return NOTIFICATION_ERROR_IO;
1034 notification_ipc_is_master_ready();
1035 return NOTIFICATION_ERROR_SERVICE_NOT_READY;
1041 notification_error_e notification_ipc_request_refresh(void)
1044 struct packet *packet;
1045 struct packet *result;
1047 packet = packet_create("refresh_noti", "i", NOTIFICATION_OP_REFRESH);
1048 result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
1050 NOTIFICATION_IPC_TIMEOUT);
1051 packet_destroy(packet);
1053 if (result != NULL) {
1054 if (packet_get(result, "i", &status) != 1) {
1055 NOTIFICATION_ERR("Failed to get a result packet");
1056 packet_unref(result);
1057 return NOTIFICATION_ERROR_IO;
1060 notification_ipc_is_master_ready();
1061 return NOTIFICATION_ERROR_SERVICE_NOT_READY;