*/
static inline char *get_string(char *string)
{
- if (string == NULL) {
+ if (string == NULL)
return NULL;
- }
- if (string[0] == '\0') {
+ if (string[0] == '\0')
return NULL;
- }
return string;
}
writable_pkg = get_string(writable_pkg);
caller = get_string(caller);
- if (pkgname != NULL && writable_pkg != NULL && caller != NULL) {
+ if (pkgname != NULL && writable_pkg != NULL && caller != NULL)
ret = badge_db_insert(pkgname, writable_pkg, caller);
- } else {
+ else
ret = BADGE_ERROR_INVALID_PARAMETER;
- }
packet_reply = packet_create_reply(packet, "i", ret);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("Failed to send a reply packet:%d", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("Failed to create a reply packet");
if (ret == BADGE_ERROR_NONE) {
packet_service = packet_create("insert_badge", "is", ret, pkgname);
if (packet_service != NULL) {
- if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
ErrPrint("Failed to send a muticast packet:%d", ret_p);
- }
packet_destroy(packet_service);
} else {
ErrPrint("Failed to create a multicast packet");
caller = get_string(caller);
if (pkgname != NULL && caller != NULL) {
- if (service_check_privilege_by_socket_fd(tcb_svc_ctx(tcb), tcb_fd(tcb), "http://tizen.org/privilege/notification") == 1) {
+ if (service_check_privilege_by_socket_fd(tcb_svc_ctx(tcb), tcb_fd(tcb), "http://tizen.org/privilege/notification") == 1)
ret = badge_db_delete(pkgname, pkgname);
- } else {
+ else
ret = badge_db_delete(pkgname, caller);
- }
} else {
ret = BADGE_ERROR_INVALID_PARAMETER;
}
packet_reply = packet_create_reply(packet, "i", ret);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("Failed to send a reply packet:%d", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("Failed to create a reply packet");
if (ret == BADGE_ERROR_NONE) {
packet_service = packet_create("delete_badge", "is", ret, pkgname);
if (packet_service != NULL) {
- if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
ErrPrint("Failed to send a muticast packet:%d", ret_p);
- }
packet_destroy(packet_service);
} else {
ErrPrint("Failed to create a multicast packet");
pkgname = get_string(pkgname);
caller = get_string(caller);
- if (pkgname != NULL && caller != NULL) {
+ if (pkgname != NULL && caller != NULL)
ret = badge_db_set_count(pkgname, caller, count);
- } else {
+ else
ret = BADGE_ERROR_INVALID_PARAMETER;
- }
packet_reply = packet_create_reply(packet, "i", ret);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("Failed to send a reply packet:%d", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("Failed to create a reply packet");
if (ret == BADGE_ERROR_NONE) {
packet_service = packet_create("set_badge_count", "isi", ret, pkgname, count);
if (packet_service != NULL) {
- if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
ErrPrint("Failed to send a muticast packet:%d", ret_p);
- }
packet_destroy(packet_service);
} else {
ErrPrint("Failed to create a multicast packet");
pkgname = get_string(pkgname);
caller = get_string(caller);
- if (pkgname != NULL && caller != NULL) {
+ if (pkgname != NULL && caller != NULL)
ret = badge_db_set_display_option(pkgname, caller, is_display);
- } else {
+ else
ret = BADGE_ERROR_INVALID_PARAMETER;
- }
packet_reply = packet_create_reply(packet, "i", ret);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("Failed to send a reply packet:%d", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("Failed to create a reply packet");
if (ret == BADGE_ERROR_NONE) {
packet_service = packet_create("set_disp_option", "isi", ret, pkgname, is_display);
if (packet_service != NULL) {
- if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
ErrPrint("Failed to send a muticast packet:%d", ret_p);
- }
packet_destroy(packet_service);
} else {
ErrPrint("Failed to create a multicast packet");
property = get_string(property);
value = get_string(value);
- if (pkgname != NULL && property != NULL && value != NULL) {
+ if (pkgname != NULL && property != NULL && value != NULL)
ret = badge_setting_db_set(pkgname, property, value);
- } else {
+ else
ret = BADGE_ERROR_INVALID_PARAMETER;
- }
packet_reply = packet_create_reply(packet, "ii", ret, ret);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet:%d\n", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
if (ret == BADGE_ERROR_NONE) {
if (strcmp(property, "OPT_BADGE") == 0) {
- if (strcmp(value, "ON") == 0) {
+ if (strcmp(value, "ON") == 0)
is_display = 1;
- } else {
+ else
is_display = 0;
- }
packet_service = packet_create("set_disp_option", "isi", ret, pkgname, is_display);
if (packet_service != NULL) {
- if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
ErrPrint("Failed to send a muticast packet:%d", ret_p);
- }
packet_destroy(packet_service);
} else {
ErrPrint("Failed to create a multicast packet");
pkgname = get_string(pkgname);
property = get_string(property);
- if (pkgname != NULL && property != NULL) {
+ if (pkgname != NULL && property != NULL)
ret = badge_setting_db_get(pkgname, property, &value);
- } else {
+ else
ret = BADGE_ERROR_INVALID_PARAMETER;
- }
packet_reply = packet_create_reply(packet, "is", ret, value);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet:%d\n", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
}
- if (value != NULL) {
+ if (value != NULL)
DbgFree(value);
- }
}
}
struct packet *packet_reply;
ret = tcb_client_type_set(tcb, TCB_CLIENT_TYPE_SERVICE);
- if (ret < 0) {
+ if (ret < 0)
ErrPrint("Failed to set the type of client:%d", ret);
- }
packet_reply = packet_create_reply(packet, "i", ret);
if (packet_reply) {
- if ((ret = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("Failed to send a reply packet:%d", ret);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("Failed to create a reply packet");
packet_reply = packet_create_reply(packet, "i", BADGE_ERROR_PERMISSION_DENIED);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("Failed to send a reply packet:%d", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("Failed to create a reply packet");
case PACKET_REQ:
/* Need to send reply packet */
for (i = 0; service_req_table[i].cmd; i++) {
- if (strcmp(service_req_table[i].cmd, command)) {
+ if (strcmp(service_req_table[i].cmd, command))
continue;
- }
#if ENABLE_BS_ACCESS_CONTROL
- if (service_check_privilege_by_socket_fd(tcb_svc_ctx(tcb), tcb_fd(tcb), "http://tizen.org/privilege/notification") == 1) {
+ if (service_check_privilege_by_socket_fd(tcb_svc_ctx(tcb), tcb_fd(tcb), "http://tizen.org/privilege/notification") == 1)
service_req_table[i].handler(tcb, packet, data);
- } else {
+ else
_handler_access_control_error(tcb, packet);
- }
#else
service_check_privilege_by_socket_fd(tcb_svc_ctx(tcb), tcb_fd(tcb), "http://tizen.org/privilege/notification");
service_req_table[i].handler(tcb, packet, data);
HAPI int badge_service_fini(void)
{
- if (!s_info.svc_ctx) {
+ if (!s_info.svc_ctx)
return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
- }
service_common_destroy(s_info.svc_ctx);
s_info.svc_ctx = NULL;
char *filename;
int namelen;
- if (s_info.nr_of_lines < CONF_MAX_LOG_LINE) {
+ if (s_info.nr_of_lines < CONF_MAX_LOG_LINE)
return;
- }
s_info.file_id = (s_info.file_id + 1) % CONF_MAX_LOG_FILE;
filename = malloc(namelen);
if (filename) {
snprintf(filename, namelen, "%s/%d_%s.%d", CONF_LOG_PATH, s_info.file_id, s_info.filename, getpid());
-
if (s_info.fp) {
- if (fclose(s_info.fp) != 0) {
+ if (fclose(s_info.fp) != 0)
ErrPrint("fclose: %d\n", errno);
- }
}
s_info.fp = fopen(filename, "w+");
- if (!s_info.fp) {
+ if (!s_info.fp)
ErrPrint("Failed to open a file: %s\n", filename);
- }
DbgFree(filename);
}
va_list ap;
int ret;
- if (!s_info.fp) {
+ if (!s_info.fp)
return SERVICE_COMMON_ERROR_IO_ERROR;
- }
CRITICAL_SECTION_BEGIN(&s_info.cri_lock);
int namelen;
char *filename;
- if (s_info.fp) {
+ if (s_info.fp)
return SERVICE_COMMON_ERROR_NONE;
- }
s_info.filename = strdup(name);
if (!s_info.filename) {
}
if (s_info.fp) {
- if (fclose(s_info.fp) != 0) {
+ if (fclose(s_info.fp) != 0)
ErrPrint("fclose: %d\n", errno);
- }
s_info.fp = NULL;
}
}
int ret;
ret = shortcut_service_init();
- if (ret < 0) {
+ if (ret < 0)
DbgPrint("shortcut: %d\n", ret);
- }
ret = notification_service_init();
- if (ret < 0) {
+ if (ret < 0)
DbgPrint("noti: %d\n", ret);
- }
-
ret = badge_service_init();
- if (ret < 0) {
+ if (ret < 0)
DbgPrint("badge: %d\n", ret);
- }
return 0;
}
int ret;
ret = badge_service_fini();
- if (ret < 0) {
+ if (ret < 0)
DbgPrint("badge: %d\n", ret);
- }
ret = notification_service_fini();
- if (ret < 0) {
+ if (ret < 0)
DbgPrint("noti: %d\n", ret);
- }
ret = shortcut_service_fini();
- if (ret < 0) {
+ if (ret < 0)
DbgPrint("shortcut: %d\n", ret);
- }
DbgPrint("Terminated\n");
return 0;
{
struct signalfd_siginfo fdsi;
ssize_t size;
+ int cfd;
int fd;
fd = ecore_main_fd_handler_fd_get(handler);
}
if (fdsi.ssi_signo == SIGTERM) {
- int cfd;
-
CRITICAL_LOG("Terminated(SIGTERM)\n");
-
cfd = creat("/tmp/.stop.provider", 0644);
- if (cfd < 0 || close(cfd) < 0) {
+ if (cfd < 0 || close(cfd) < 0)
ErrPrint("stop.provider: %d\n", errno);
- }
vconf_set_bool(VCONFKEY_MASTER_STARTED, 0);
- //exit(0);
ecore_main_loop_quit();
} else {
CRITICAL_LOG("Unknown SIG[%d] received\n", fdsi.ssi_signo);
Ecore_Fd_Handler *signal_handler = NULL;
/* appcore_agent_terminate */
- if (ecore_init() <= 0) {
+ if (ecore_init() <= 0)
return -EFAULT;
- }
ecore_app_args_set(argc, (const char **)argv);
#endif
vconf_get_int(VCONFKEY_MASTER_RESTART_COUNT, &restart_count);
-
util_setup_log_disk();
/*!
* Is there any way to print something on the screen?
*/
ret = critical_log_init(util_basename(argv[0]));
- if (ret < 0) {
+ if (ret < 0)
ErrPrint("Failed to init the critical log\n");
- }
sigemptyset(&mask);
-
ret = sigaddset(&mask, SIGTERM);
- if (ret < 0) {
+ if (ret < 0)
CRITICAL_LOG("sigaddset: %d\n", errno);
- }
ret = sigprocmask(SIG_BLOCK, &mask, NULL);
- if (ret < 0) {
+ if (ret < 0)
CRITICAL_LOG("sigprocmask: %d\n", errno);
- }
ret = signalfd(-1, &mask, 0);
if (ret < 0) {
CRITICAL_LOG("signalfd: %d\n", errno);
} else {
- signal_handler = ecore_main_fd_handler_add(ret, ECORE_FD_READ, signal_cb, NULL, NULL, NULL);
+ signal_handler = ecore_main_fd_handler_add(
+ ret, ECORE_FD_READ, signal_cb,
+ NULL, NULL, NULL);
CRITICAL_LOG("Signal handler initiated: %d\n", ret);
}
app_terminate();
- if (signal_handler) {
+ if (signal_handler)
ecore_main_fd_handler_del(signal_handler);
- }
ecore_shutdown();
critical_log_fini();
static inline char *_string_get(char *string)
{
- if (string == NULL) {
+ if (string == NULL)
return NULL;
- }
- if (string[0] == '\0') {
+ if (string[0] == '\0')
return NULL;
- }
return string;
}
/*!
* FUNCTIONS to create packets
*/
-static inline int _priv_id_get_from_list(int num_data, int *list, int index) {
- if (index < num_data) {
+static inline int _priv_id_get_from_list(int num_data, int *list, int index)
+{
+ if (index < num_data)
return *(list + index);
- } else {
+ else
return -1;
- }
}
-static inline struct packet *_packet_create_with_list(int op_num, int *list, int start_index) {
+static inline struct packet *_packet_create_with_list(int op_num, int *list, int start_index)
+{
return packet_create(
"del_noti_multiple",
"iiiiiiiiiii",
DbgPrint("priv_id: [%d]\n", priv_id);
packet_reply = packet_create_reply(packet, "ii", ret, priv_id);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet: %d\n", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
if (ret != NOTIFICATION_ERROR_NONE) {
ErrPrint("failed to insert a notification: %d\n", ret);
- return ;
+ return;
}
packet_service = notification_ipc_make_packet_from_noti(noti, "add_noti", 2);
if (packet_service != NULL) {
- if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
ErrPrint("failed to send a multicast packet: %d\n", ret_p);
- }
packet_destroy(packet_service);
} else {
ErrPrint("failed to create a multicats packet\n");
DbgPrint("priv_id: [%d]\n", priv_id);
packet_reply = packet_create_reply(packet, "ii", ret, priv_id);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet:%d\n", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
if (ret != NOTIFICATION_ERROR_NONE) {
ErrPrint("failed to update a notification:%d\n", ret);
- return ;
+ return;
}
packet_service = notification_ipc_make_packet_from_noti(noti, "update_noti", 2);
if (packet_service != NULL) {
- if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
ErrPrint("failed to send a multicast packet: %d\n", ret_p);
- }
packet_destroy(packet_service);
}
}
noti = notification_create(NOTIFICATION_TYPE_NOTI);
if (noti != NULL) {
- if (notification_ipc_make_noti_from_packet(noti, packet) == NOTIFICATION_ERROR_NONE) {
+ if (notification_ipc_make_noti_from_packet(noti, packet) == NOTIFICATION_ERROR_NONE)
_handler_update_noti(tcb, packet, noti, data);
- } else {
+ else
ErrPrint("Failed to create the packet");
- }
notification_free(noti);
}
}
if (noti != NULL) {
if (notification_ipc_make_noti_from_packet(noti, packet) == NOTIFICATION_ERROR_NONE) {
ret = notification_noti_check_tag(noti);
- if (ret == NOTIFICATION_ERROR_NOT_EXIST_ID) {
+ if (ret == NOTIFICATION_ERROR_NOT_EXIST_ID)
_handler_insert_noti(tcb, packet, noti, data);
- } else if (ret == NOTIFICATION_ERROR_ALREADY_EXIST_ID) {
+ else if (ret == NOTIFICATION_ERROR_ALREADY_EXIST_ID)
_handler_update_noti(tcb, packet, noti, data);
- }
}
notification_free(noti);
}
static void _handler_load_noti_by_tag(struct tcb *tcb, struct packet *packet, void *data)
{
int ret = 0, ret_p = 0;
- char* tag;
- char* pkgname;
+ char *tag;
+ char *pkgname;
struct packet *packet_reply = NULL;
notification_h noti = NULL;
ret = notification_noti_get_by_tag(noti, pkgname, tag);
packet_reply = notification_ipc_make_reply_packet_from_noti(noti, packet);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet: %d\n", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
if (ret != NOTIFICATION_ERROR_NONE) {
ErrPrint("failed to load_noti_by_tag : %d\n", ret);
notification_free(noti);
- return ;
+ return;
}
} else {
ErrPrint("Failed to create the packet");
packet_reply = packet_create_reply(packet, "i", ret);
if (packet_reply) {
- if ((ret = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet:%d\n", ret);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
}
- if ((ret = service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ if ((ret = service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE)) < 0)
ErrPrint("failed to send a multicast packet:%d\n", ret);
- }
}
static void _handler_delete_single(struct tcb *tcb, struct packet *packet, void *data)
DbgPrint("priv_id: [%d] num_delete:%d\n", priv_id, num_changes);
packet_reply = packet_create_reply(packet, "ii", ret, priv_id);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet:%d\n", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
if (ret != NOTIFICATION_ERROR_NONE || num_changes <= 0) {
ErrPrint("failed to delete a notification:%d %d\n", ret, num_changes);
- return ;
+ return;
}
packet_service = packet_create("del_noti_single", "ii", 1, priv_id);
if (packet_service != NULL) {
- if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
ErrPrint("failed to send a multicast packet: %d\n", ret_p);
- }
packet_destroy(packet_service);
}
} else {
packet_reply = packet_create_reply(packet, "ii", ret, num_deleted);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet:%d\n", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
if (ret != NOTIFICATION_ERROR_NONE) {
ErrPrint("failed to delete notifications:%d\n", ret);
- if (list_deleted != NULL) {
+ if (list_deleted != NULL)
DbgFree(list_deleted);
- }
- return ;
+ return;
}
if (num_deleted > 0) {
packet_service = _packet_create_with_list(num_deleted, list_deleted, 0);
if (packet_service) {
- if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
ErrPrint("failed to send a multicast packet: %d\n", ret_p);
- }
packet_destroy(packet_service);
} else {
ErrPrint("failed to create a multicast packet\n");
list_deleted, set * NOTIFICATION_DEL_PACKET_UNIT);
if (packet_service) {
- if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0)
ErrPrint("failed to send a multicast packet:%d\n", ret_p);
- }
packet_destroy(packet_service);
} else {
ErrPrint("failed to create a multicast packet\n");
packet_reply = packet_create_reply(packet, "ii", ret, ret);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet:%d\n", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
}
- if (ret != NOTIFICATION_ERROR_NONE) {
+ if (ret != NOTIFICATION_ERROR_NONE)
ErrPrint("failed to set noti property:%d\n", ret);
- }
} else {
ErrPrint("Failed to get data from the packet");
}
packet_reply = packet_create_reply(packet, "is", ret, value);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet:%d\n", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
}
- if (value != NULL) {
+ if (value != NULL)
DbgFree(value);
- }
}
}
packet_reply = packet_create_reply(packet, "ii", ret, ret);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet:%d\n", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
}
- if (ret != NOTIFICATION_ERROR_NONE) {
+ if (ret != NOTIFICATION_ERROR_NONE)
ErrPrint("failed to update setting[%d]\n", ret);
- }
} else {
ErrPrint("Failed to get data from the packet");
}
packet_reply = packet_create_reply(packet, "ii", ret, ret);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet:%d\n", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
}
- if (ret != NOTIFICATION_ERROR_NONE) {
+ if (ret != NOTIFICATION_ERROR_NONE)
ErrPrint("failed to update system setting[%d]\n", ret);
- }
} else {
ErrPrint("Failed to get data from the packet");
}
packet_reply = packet_create_reply(packet, "i", ret);
if (packet_reply) {
- if ((ret = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet:%d\n", ret);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
packet_reply = packet_create_reply(packet, "i", ret);
if (packet_reply) {
- if ((ret = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("failed to send reply packet:%d\n", ret);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("failed to create a reply packet\n");
}
- if ((ret = service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ if ((ret = service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE)) < 0)
ErrPrint("failed to send a multicast packet:%d\n", ret);
- }
-
}
static void _handler_package_install(struct tcb *tcb, struct packet *packet, void *data)
DbgPrint("package_name [%s]\n", package_name);
/* TODO : add codes to add a record to setting table */
-
- if (ret != NOTIFICATION_ERROR_NONE) {
+ if (ret != NOTIFICATION_ERROR_NONE)
ErrPrint("failed to update setting[%d]\n", ret);
- }
} else {
ErrPrint("Failed to get data from the packet");
}
packet_reply = packet_create_reply(packet, "ii", NOTIFICATION_ERROR_PERMISSION_DENIED, 0);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("Failed to send a reply packet:%d", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("Failed to create a reply packet");
packet_reply = packet_create_reply(packet, "i", NOTIFICATION_ERROR_PERMISSION_DENIED);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("Failed to send a reply packet:%d", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("Failed to create a reply packet");
packet_reply = packet_create_reply(packet, "is", NOTIFICATION_ERROR_PERMISSION_DENIED, NULL);
if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0)
ErrPrint("Failed to send a reply packet:%d", ret_p);
- }
packet_destroy(packet_reply);
} else {
ErrPrint("Failed to create a reply packet");
noti_list = notification_list_get_next(noti_list);
}
- if (noti_list_head != NULL) {
+ if (noti_list_head != NULL)
notification_free_list(noti_list_head);
- }
}
-static void _notification_init(void) {
+static void _notification_init(void)
+{
int ret = -1;
int restart_count = 0;
ret = vconf_get_int(VCONFKEY_MASTER_RESTART_COUNT, &restart_count);
- if (ret == 0 && restart_count <= 1) {
+ if (ret == 0 && restart_count <= 1)
_notification_data_init();
- }
-
}
/*!
DbgPrint("%p REQ: Command: [%s]\n", tcb, command);
for (i = 0; service_req_table[i].cmd; i++) {
- if (strcmp(service_req_table[i].cmd, command)) {
+ if (strcmp(service_req_table[i].cmd, command))
continue;
- }
if (service_check_privilege_by_socket_fd(tcb_svc_ctx(tcb), tcb_fd(tcb), "http://tizen.org/privilege/notification") == 1) {
service_req_table[i].handler(tcb, packet, data);
} else {
- if (service_req_table[i].handler_access_error != NULL) {
+ if (service_req_table[i].handler_access_error != NULL)
service_req_table[i].handler_access_error(tcb, packet);
- }
}
break;
}
case PACKET_REQ_NOACK:
DbgPrint("%p PACKET_REQ_NOACK: Command: [%s]\n", tcb, command);
for (i = 0; service_req_no_ack_table[i].cmd; i++) {
- if (strcmp(service_req_no_ack_table[i].cmd, command)) {
+ if (strcmp(service_req_no_ack_table[i].cmd, command))
continue;
- }
service_req_no_ack_table[i].handler(tcb, packet, data);
break;
}
if (event_type == PKGMGR_EVENT_INSTALL) {
packet = packet_create_noack("package_install", "s", pkgname);
- }
- else if (event_type == PKGMGR_EVENT_UNINSTALL){
+ } else if (event_type == PKGMGR_EVENT_UNINSTALL) {
packet = packet_create_noack("package_uninstall", "s", pkgname);
- }
- else {
+ } else {
/* Ignore other events */
goto out;
}
if (packet == NULL) {
- ErrPrint("packet_create_noack failed\n");\
+ ErrPrint("packet_create_noack failed\n");
ret = -1;
goto out;
}
{
struct info *notification_service_info = (struct info *)data;
- if (status != PKGMGR_STATUS_END) {
+ if (status != PKGMGR_STATUS_END)
return 0;
- }
_invoke_package_change_event(notification_service_info, PKGMGR_EVENT_INSTALL, pkgname);
{
struct info *notification_service_info = (struct info *)data;
- if (status != PKGMGR_STATUS_END) {
+ if (status != PKGMGR_STATUS_END)
return 0;
- }
_invoke_package_change_event(notification_service_info, PKGMGR_EVENT_UNINSTALL, pkgname);
notification_setting_refresh_setting_table();
pkgmgr_init();
- pkgmgr_add_event_callback(PKGMGR_EVENT_INSTALL, _package_install_cb, (void*)&s_info);
- pkgmgr_add_event_callback(PKGMGR_EVENT_UPDATE, _package_install_cb, (void*)&s_info);
- pkgmgr_add_event_callback(PKGMGR_EVENT_UNINSTALL, _package_uninstall_cb, (void*)&s_info);
+ pkgmgr_add_event_callback(PKGMGR_EVENT_INSTALL, _package_install_cb, (void *)&s_info);
+ pkgmgr_add_event_callback(PKGMGR_EVENT_UPDATE, _package_install_cb, (void *)&s_info);
+ pkgmgr_add_event_callback(PKGMGR_EVENT_UNINSTALL, _package_uninstall_cb, (void *)&s_info);
DbgPrint("Successfully initiated\n");
return SERVICE_COMMON_ERROR_NONE;
}
HAPI int notification_service_fini(void)
{
- if (!s_info.svc_ctx) {
+ if (!s_info.svc_ctx)
return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
- }
pkgmgr_fini();
struct event_item *item;
EINA_LIST_FOREACH(s_info.install_event, l, item) {
- if (item->cb) {
+ if (item->cb)
item->cb(pkgname, status, value, item->data);
- }
}
}
struct event_item *item;
EINA_LIST_FOREACH(s_info.uninstall_event, l, item) {
- if (item->cb) {
+ if (item->cb)
item->cb(pkgname, status, value, item->data);
- }
}
}
struct event_item *item;
EINA_LIST_FOREACH(s_info.update_event, l, item) {
- if (item->cb) {
+ if (item->cb)
item->cb(pkgname, status, value, item->data);
- }
}
}
struct event_item *item;
EINA_LIST_FOREACH(s_info.download_event, l, item) {
- if (item->cb) {
+ if (item->cb)
item->cb(pkgname, status, value, item->data);
- }
}
}
struct event_item *item;
EINA_LIST_FOREACH(s_info.recover_event, l, item) {
- if (item->cb) {
+ if (item->cb)
item->cb(pkgname, status, value, item->data);
- }
}
}
}
EINA_LIST_FOREACH(s_info.item_list, l, item) {
- if (strcmp(item->pkgname, pkgname)) {
+ if (strcmp(item->pkgname, pkgname))
continue;
- }
return item;
}
DbgPrint("[%s] %s\n", pkgname, val);
item = find_item(pkgname);
- if (!item) {
+ if (!item)
return SERVICE_COMMON_ERROR_NOT_EXIST;
- }
- if (item->icon) {
+ if (item->icon)
DbgFree(item->icon);
- }
item->icon = strdup(val);
if (!item->icon) {
DbgPrint("[%s] %s\n", pkgname, val);
item = find_item(pkgname);
- if (!item) {
+ if (!item)
return SERVICE_COMMON_ERROR_NOT_EXIST;
- }
if (!is_valid_status(item, val)) {
DbgPrint("Invalid status: %d, %s\n", item->type, val);
DbgPrint("[%s] %s\n", pkgname, val);
item = find_item(pkgname);
- if (!item) {
+ if (!item)
return SERVICE_COMMON_ERROR_NOT_EXIST;
- }
item->status = PKGMGR_STATUS_ERROR;
invoke_callback(pkgname, item, 0.0f);
DbgPrint("[%s] %s\n", pkgname, val);
item = find_item(pkgname);
- if (!item) {
+ if (!item)
return SERVICE_COMMON_ERROR_NOT_EXIST;
- }
new_pkgname = strdup(val);
if (!new_pkgname) {
}
if (val) {
- if (sscanf(val, "%lf", &value) != 1) {
+ if (sscanf(val, "%lf", &value) != 1)
value = (double)SERVICE_COMMON_ERROR_INVALID_PARAMETER;
- }
} else {
value = (double)SERVICE_COMMON_ERROR_INVALID_PARAMETER;
}
}
if (val) {
- if (sscanf(val, "%lf", &value) != 1) {
+ if (sscanf(val, "%lf", &value) != 1)
value = (double)SERVICE_COMMON_ERROR_INVALID_PARAMETER;
- }
} else {
value = (double)SERVICE_COMMON_ERROR_INVALID_PARAMETER;
}
DbgPrint("[%s] %s\n", pkgname, val);
item = find_item(pkgname);
- if (!item) {
+ if (!item)
return SERVICE_COMMON_ERROR_NOT_EXIST;
- }
item->status = !strcasecmp(val, "ok") ? PKGMGR_STATUS_END : PKGMGR_STATUS_ERROR;
int ret;
for (i = 0; handler[i].key; i++) {
- if (strcasecmp(key, handler[i].key)) {
+ if (strcasecmp(key, handler[i].key))
continue;
- }
ret = handler[i].func(pkgname, val, data);
if (ret < 0) {
HAPI int pkgmgr_init(void)
{
- if (s_info.listen_pc) {
+ if (s_info.listen_pc)
return SERVICE_COMMON_ERROR_ALREADY_EXIST;
- }
s_info.listen_pc = pkgmgr_client_new(PC_LISTENING);
- if (!s_info.listen_pc) {
+ if (!s_info.listen_pc)
return SERVICE_COMMON_ERROR_FAULT;
- }
- if (pkgmgr_client_listen_status(s_info.listen_pc, pkgmgr_cb, NULL) != PKGMGR_R_OK) {
+ if (pkgmgr_client_listen_status(s_info.listen_pc, pkgmgr_cb, NULL) != PKGMGR_R_OK)
return SERVICE_COMMON_ERROR_FAULT;
- }
return SERVICE_COMMON_ERROR_NONE;
}
struct event_item *item;
struct item *ctx;
- if (!s_info.listen_pc) {
+ if (!s_info.listen_pc)
return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
- }
- if (pkgmgr_client_free(s_info.listen_pc) != PKGMGR_R_OK) {
+ if (pkgmgr_client_free(s_info.listen_pc) != PKGMGR_R_OK)
return SERVICE_COMMON_ERROR_FAULT;
- }
s_info.listen_pc = NULL;
/* Cynara structure init */
ret = cynara_initialize(&(svc_ctx->cynara_handle), NULL);
- if (ret != CYNARA_API_SUCCESS) {
+ if (ret != CYNARA_API_SUCCESS)
ErrPrint("cynara_initialize failed[%d]\n", ret);
- }
}
static void _finish_privilege_checker(struct service_context *svc_ctx)
int ret;
ret = cynara_finish(svc_ctx->cynara_handle);
- if (ret != CYNARA_API_SUCCESS) {
+ if (ret != CYNARA_API_SUCCESS)
ErrPrint("cynara_initialize failed[%d]\n", ret);
- }
}
HAPI int service_common_send_packet_to_service(struct service_context *svc_ctx, struct tcb *tcb, struct packet *packet)
}
out:
-
return ret;
}
case RECV_HEADER:
ret = secure_socket_recv(tcb->fd, ptr, size - recv_offset, &tcb->pid);
if (ret <= 0) {
- if (ret == 0) {
+ if (ret == 0)
ret = -ECANCELED;
- }
DbgFree(ptr);
ptr = NULL;
break;
case RECV_PAYLOAD:
ret = secure_socket_recv(tcb->fd, ptr, size - recv_offset, &tcb->pid);
if (ret <= 0) {
- if (ret == 0) {
+ if (ret == 0)
ret = -ECANCELED;
- }
DbgFree(ptr);
ptr = NULL;
break;
* \note
* Emit a signal to collect this TCB from the SERVER THREAD.
*/
- if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &tcb, sizeof(tcb)) != sizeof(tcb)) {
+ if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &tcb, sizeof(tcb)) != sizeof(tcb))
ErrPrint("write: %d\n", errno);
- }
if (ptr)
free(ptr);
switch (event) {
case TCB_EVENT_CREATE:
- if (tcb) {
+ if (tcb)
DbgPrint("To catch the create event of TCB does not requires \"tcb\" handle\n");
- }
svc_ctx->tcb_create_cb_list = eina_list_append(svc_ctx->tcb_create_cb_list, cbdata);
break;
case TCB_EVENT_DESTROY:
/*!
* ASSERT(tcb->fd >= 0);
*/
- if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch)) {
+ if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch))
ErrPrint("write: %d\n", errno);
- }
status = pthread_join(tcb->thid, &ret);
- if (status != 0) {
+ if (status != 0)
ErrPrint("Unable to join a thread: %d\n", status);
- } else {
+ else
DbgPrint("Thread returns: %p\n", ret);
- }
secure_socket_destroy_handle(tcb->fd);
HAPI int service_common_destroy_tcb(struct service_context *svc_ctx, struct tcb *tcb)
{
- if (!svc_ctx || !tcb) {
+ if (!svc_ctx || !tcb)
return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
- }
/**
* @note
* In this case, we just need to push terminate event to pipe.
*/
- if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &tcb, sizeof(tcb)) != sizeof(tcb)) {
+ if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &tcb, sizeof(tcb)) != sizeof(tcb))
ErrPrint("write: %d\n", errno);
- }
return SERVICE_COMMON_ERROR_NONE;
}
continue;
}
- if (cbdata->tcb != tcb) {
+ if (cbdata->tcb != tcb)
continue;
- }
cbdata->cb(svc_ctx, tcb, cbdata->data);
* ASSERT(tcb->fd >= 0);
* Close the connection, and then collecting the return value of thread
*/
- if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch)) {
+ if (write(tcb->ctrl_pipe[PIPE_WRITE], &ch, sizeof(ch)) != sizeof(ch))
ErrPrint("write: %d\n", errno);
- }
status = pthread_join(tcb->thid, &ret);
- if (status != 0) {
+ if (status != 0)
ErrPrint("Unable to join a thread: %d\n", status);
- } else {
+ else
DbgPrint("Thread returns: %p\n", ret);
- }
secure_socket_destroy_handle(tcb->fd);
fd = svc_ctx->fd;
FD_SET(svc_ctx->tcb_pipe[PIPE_READ], set);
- if (svc_ctx->tcb_pipe[PIPE_READ] > fd) {
+ if (svc_ctx->tcb_pipe[PIPE_READ] > fd)
fd = svc_ctx->tcb_pipe[PIPE_READ];
- }
FD_SET(svc_ctx->evt_pipe[PIPE_READ], set);
- if (svc_ctx->evt_pipe[PIPE_READ] > fd) {
+ if (svc_ctx->evt_pipe[PIPE_READ] > fd)
fd = svc_ctx->evt_pipe[PIPE_READ];
- }
EINA_LIST_FOREACH(svc_ctx->event_list, l, item) {
if (item->type == SERVICE_EVENT_TIMER) {
FD_SET(item->info.timer.fd, set);
- if (fd < item->info.timer.fd) {
+ if (fd < item->info.timer.fd)
fd = item->info.timer.fd;
- }
}
}
EINA_LIST_FOREACH_SAFE(svc_ctx->event_list, l, n, item) {
switch (item->type) {
case SERVICE_EVENT_TIMER:
- if (!FD_ISSET(item->info.timer.fd, set)) {
+ if (!FD_ISSET(item->info.timer.fd, set))
break;
- }
if (read(item->info.timer.fd, &expired_count, sizeof(expired_count)) == sizeof(expired_count)) {
DbgPrint("Expired %d times\n", expired_count);
- if (item->event_cb(svc_ctx, item->cbdata) >= 0) {
+ if (item->event_cb(svc_ctx, item->cbdata) >= 0)
break;
- }
} else {
ErrPrint("read: %d\n", errno);
}
- if (!eina_list_data_find(svc_ctx->event_list, item)) {
+ if (!eina_list_data_find(svc_ctx->event_list, item))
break;
- }
svc_ctx->event_list = eina_list_remove(svc_ctx->event_list, item);
- if (close(item->info.timer.fd) < 0) {
+ if (close(item->info.timer.fd) < 0)
ErrPrint("close: %d\n", errno);
- }
DbgFree(item);
break;
default:
svc_ctx->processing_service_handler = 1;
ret = svc_ctx->service_thread_main(packet_info->tcb, packet_info->packet, svc_ctx->service_thread_data);
svc_ctx->processing_service_handler = 0;
- if (ret < 0) {
+ if (ret < 0)
ErrPrint("Service thread returns: %d\n", ret);
- }
packet_destroy(packet_info->packet);
DbgFree(packet_info);
lockfree_packet_list = NULL;
CRITICAL_SECTION_BEGIN(&svc_ctx->packet_list_lock);
EINA_LIST_FOREACH_SAFE(svc_ctx->packet_list, l, n, packet_info) {
- if (packet_info->tcb != tcb) {
+ if (packet_info->tcb != tcb)
continue;
- }
svc_ctx->packet_list = eina_list_remove(svc_ctx->packet_list, packet_info);
lockfree_packet_list = eina_list_append(lockfree_packet_list, packet_info);
svc_ctx->processing_service_handler = 1;
ret = svc_ctx->service_thread_main(packet_info->tcb, packet_info->packet, svc_ctx->service_thread_data);
svc_ctx->processing_service_handler = 0;
- if (ret < 0) {
+ if (ret < 0)
ErrPrint("Service thread returns: %d\n", ret);
- }
+
packet_destroy(packet_info->packet);
DbgFree(packet_info);
}
svc_ctx->processing_service_handler = 1;
ret = svc_ctx->service_thread_main(packet_info->tcb, packet_info->packet, svc_ctx->service_thread_data);
svc_ctx->processing_service_handler = 0;
- if (ret < 0) {
+ if (ret < 0)
ErrPrint("Service thread returns: %d\n", ret);
- }
packet_destroy(packet_info->packet);
DbgFree(packet_info);
}
* So, find the scheme length first and then "unlink" it.
*/
offset = strlen(COM_CORE_LOCAL_SCHEME);
- if (strncmp(addr, COM_CORE_LOCAL_SCHEME, offset)) {
+ if (strncmp(addr, COM_CORE_LOCAL_SCHEME, offset))
offset = 0;
- }
- if (unlink(addr + offset) < 0) {
+ if (unlink(addr + offset) < 0)
ErrPrint("unlink [%s] - %d\n", addr, errno);
- }
}
svc_ctx = calloc(1, sizeof(*svc_ctx));
svc_ctx->service_thread_main = service_thread_main;
svc_ctx->service_thread_data = data;
- if (fcntl(svc_ctx->fd, F_SETFD, FD_CLOEXEC) < 0) {
+ if (fcntl(svc_ctx->fd, F_SETFD, FD_CLOEXEC) < 0)
ErrPrint("fcntl: %d\n", errno);
- }
- if (fcntl(svc_ctx->fd, F_SETFL, O_NONBLOCK) < 0) {
+ if (fcntl(svc_ctx->fd, F_SETFL, O_NONBLOCK) < 0)
ErrPrint("fcntl: %d\n", errno);
- }
if (pipe2(svc_ctx->evt_pipe, O_CLOEXEC) < 0) {
ErrPrint("pipe2: %d\n", errno);
if (status != 0) {
ErrPrint("Unable to create a thread for shortcut service: %d\n", status);
status = pthread_mutex_destroy(&svc_ctx->packet_list_lock);
- if (status != 0) {
+ if (status != 0)
ErrPrint("mutex_destroy: %d\n", status);
- }
+
CLOSE_PIPE(svc_ctx->evt_pipe);
CLOSE_PIPE(svc_ctx->tcb_pipe);
secure_socket_destroy_handle(svc_ctx->fd);
int status = 0;
void *ret;
- if (!svc_ctx) {
+ if (!svc_ctx)
return -EINVAL;
- }
/*!
* \note
* Terminate server thread
*/
- if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &status, sizeof(status)) != sizeof(status)) {
+ if (write(svc_ctx->tcb_pipe[PIPE_WRITE], &status, sizeof(status)) != sizeof(status))
ErrPrint("write: %d\n", errno);
- }
status = pthread_join(svc_ctx->server_thid, &ret);
- if (status != 0) {
+ if (status != 0)
ErrPrint("Join: %d\n", status);
- } else {
+ else
DbgPrint("Thread returns: %p\n", ret);
- }
_finish_privilege_checker(svc_ctx);
secure_socket_destroy_handle(svc_ctx->fd);
status = pthread_mutex_destroy(&svc_ctx->packet_list_lock);
- if (status != 0) {
+ if (status != 0)
ErrPrint("destroy_mutex: %d\n", status);
- }
CLOSE_PIPE(svc_ctx->evt_pipe);
CLOSE_PIPE(svc_ctx->tcb_pipe);
*/
HAPI int tcb_pid(struct tcb *tcb)
{
- if (!tcb) {
+ if (!tcb)
return -1;
- }
return tcb->pid;
}
*/
HAPI int tcb_fd(struct tcb *tcb)
{
- if (!tcb) {
+ if (!tcb)
return -EINVAL;
- }
return tcb->fd;
}
*/
HAPI int tcb_client_type(struct tcb *tcb)
{
- if (!tcb) {
+ if (!tcb)
return -EINVAL;
- }
return tcb->type;
}
*/
HAPI int tcb_client_type_set(struct tcb *tcb, enum tcb_type type)
{
- if (!tcb) {
+ if (!tcb)
return -EINVAL;
- }
DbgPrint("TCB[%p] Client type is changed to %d from %d\n", tcb, type, tcb->type);
tcb->type = type;
*/
HAPI struct service_context *tcb_svc_ctx(struct tcb *tcb)
{
- if (!tcb) {
+ if (!tcb)
return NULL;
- }
return tcb->svc_ctx;
}
}
ret = com_core_send(target->fd, (void *)packet_data(packet), packet_size(packet), DEFAULT_TIMEOUT);
- if (ret < 0) {
+ if (ret < 0)
ErrPrint("Failed to send packet: %d\n", ret);
- }
}
DbgPrint("Finish to multicast packet\n");
return 0;
}
if (service_common_update_timer(item, timer) < 0) {
- if (close(item->info.timer.fd) < 0) {
+ if (close(item->info.timer.fd) < 0)
ErrPrint("close: %d\n", errno);
- }
DbgFree(item);
return NULL;
}
svc_ctx->event_list = eina_list_remove(svc_ctx->event_list, item);
- if (close(item->info.timer.fd) < 0) {
+ if (close(item->info.timer.fd) < 0)
ErrPrint("close: %d\n", errno);
- }
DbgFree(item);
return 0;
}
if (ret == CYNARA_API_ACCESS_ALLOWED) {
DbgPrint("[%s] Access allowed.", privilege);
result = 1;
- }
- else {
+ } else {
DbgPrint("[%s] Access denied.[%d]", privilege, ret);
result = 0;
}
}
out:
- if (client_smack) {
+ if (client_smack)
free(client_smack);
- }
- if (session) {
+ if (session)
free(session);
- }
- if (uid) {
+ if (uid)
free(uid);
- }
return result;
}
tcb = NULL;
EINA_LIST_FOREACH_SAFE(s_info.context_list, l, n, ctx) {
- if (ctx->seq != seq) {
+ if (ctx->seq != seq)
continue;
- }
s_info.context_list = eina_list_remove(s_info.context_list, ctx);
tcb = ctx->tcb;
return;
}
- if (service_common_unicast_packet(tcb, reply_packet) < 0) {
+ if (service_common_unicast_packet(tcb, reply_packet) < 0)
ErrPrint("Unable to send reply packet\n");
- }
packet_destroy(reply_packet);
}
}
}
- if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0) {
+ if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0)
ErrPrint("Unable to send service request packet\n");
- } else {
+ else
(void)put_reply_context(tcb, packet_seq(packet));
- }
break;
case PACKET_REQ_NOACK:
/* Doesn't need to send reply packet */
break;
}
- if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0) {
+ if (service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE) < 0)
ErrPrint("Unable to send service reuqest packet\n");
- }
break;
case PACKET_ACK:
/* Okay, client(or app) send a reply packet to us. */
break;
}
- if (service_common_unicast_packet(tcb, packet) < 0) {
+ if (service_common_unicast_packet(tcb, packet) < 0)
ErrPrint("Unable to send reply packet\n");
- }
break;
default:
ErrPrint("Packet type is not valid[%s]\n", command);
HAPI int shortcut_service_fini(void)
{
- if (!s_info.svc_ctx) {
+ if (!s_info.svc_ctx)
return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
- }
service_common_destroy(s_info.svc_ctx);
s_info.svc_ctx = NULL;
HAPI void util_setup_log_disk(void)
{
-#if 0
- int ret;
-#endif
-
if (access(CONF_LOG_PATH, R_OK | W_OK | X_OK) == 0) {
DbgPrint("[%s] is already accessible\n", CONF_LOG_PATH);
return;
}
DbgPrint("Initiate the critical log folder [%s]\n", CONF_LOG_PATH);
- if (mkdir(CONF_LOG_PATH, 0755) < 0) {
+ if (mkdir(CONF_LOG_PATH, 0755) < 0)
ErrPrint("mkdir: %d\n", errno);
- } else {
-#if 0
- if (chmod(CONF_LOG_PATH, 0750) < 0) {
- ErrPrint("chmod: %d\n", errno);
- }
-
- if (chown(CONF_LOG_PATH, 5000, 5000) < 0) {
- ErrPrint("chown: %d\n", errno);
- }
-
- ret = smack_setlabel(CONF_LOG_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
- if (ret != 0) {
- ErrPrint("Failed to set SMACK for %s (%d)\n", CONF_LOG_PATH, ret);
- } else {
- ret = smack_setlabel(CONF_LOG_PATH, "1", SMACK_LABEL_TRANSMUTE);
- DbgPrint("[%s] is successfully created (t: %d)\n", CONF_LOG_PATH, ret);
- }
-#endif
- }
}
HAPI const char *util_basename(const char *name)
{
int length;
length = name ? strlen(name) : 0;
- if (!length) {
+ if (!length)
return ".";
- }
- while (--length > 0 && name[length] != '/');
+ while (--length > 0 && name[length] != '/')
+ ;
return length <= 0 ? name : (name + length + (name[length] == '/'));
}