} message_port_pkt_s;
typedef struct message_port_callback_info {
- message_port_message_cb callback;
- void *user_data;
+ message_port_local_port_info_s *local_info;
int local_id;
char *remote_app_id;
GIOChannel *gio_read;
int fd = 0;
message_port_callback_info_s *mi;
message_port_pkt_s *pkt;
+ message_port_local_port_info_s *local_port_info;
bundle *kb = NULL;
GError *error = NULL;
return FALSE;
}
- if (cond == G_IO_HUP) {
+ local_port_info = mi->local_info;
+ if (local_port_info == NULL || local_port_info->callback == NULL) {
+ _LOGE("Failed to get callback info");
+ __callback_info_free_by_info(mi);
+ return FALSE;
+ }
+ if (cond == G_IO_HUP) {
_LOGI("socket G_IO_HUP");
__callback_info_free_by_info(mi);
return FALSE;
+ }
- } else {
+ if ((fd = g_io_channel_unix_get_fd(gio)) < 0) {
+ _LOGE("fail to get fd from io channel");
+ __callback_info_free_by_info(mi);
+ return FALSE;
+ }
- if ((fd = g_io_channel_unix_get_fd(gio)) < 0) {
- _LOGE("fail to get fd from io channel");
- __callback_info_free_by_info(mi);
- return FALSE;
- }
+ if ((pkt = __message_port_recv_raw(fd)) == NULL) {
+ _LOGE("recv error on SOCKET");
+ __callback_info_free_by_info(mi);
+ return FALSE;
+ }
- if ((pkt = __message_port_recv_raw(fd)) == NULL) {
- _LOGE("recv error on SOCKET");
- __callback_info_free_by_info(mi);
- return FALSE;
- }
+ kb = bundle_decode(pkt->data, pkt->data_len);
+ if (pkt->is_bidirection)
+ local_port_info->callback(mi->local_id, mi->remote_app_id,
+ pkt->remote_port_name, pkt->is_trusted, kb, local_port_info->user_data);
- kb = bundle_decode(pkt->data, pkt->data_len);
- if (pkt->is_bidirection) {
- if (mi->callback)
- mi->callback(mi->local_id, mi->remote_app_id, pkt->remote_port_name, pkt->is_trusted, kb, mi->user_data);
- } else {
- if (mi->callback)
- mi->callback(mi->local_id, mi->remote_app_id, NULL, pkt->is_trusted, kb, mi->user_data);
- }
+ else
+ local_port_info->callback(mi->local_id, mi->remote_app_id,
+ NULL, pkt->is_trusted, kb, local_port_info->user_data);
- bundle_free(kb);
- if (pkt) {
- if (pkt->remote_port_name)
- free(pkt->remote_port_name);
- if (pkt->data)
- free(pkt->data);
- free(pkt);
- }
+ bundle_free(kb);
+ if (pkt) {
+ if (pkt->remote_port_name)
+ free(pkt->remote_port_name);
+ if (pkt->data)
+ free(pkt->data);
+ free(pkt);
}
return TRUE;
}
callback_info->local_id = mi->local_id;
+ callback_info->local_info = mi;
callback_info->remote_app_id = strdup(local_appid);
if (callback_info->remote_app_id == NULL) {
_LOGE("out of memory");
goto out;
}
- callback_info->callback = mi->callback;
- callback_info->user_data = mi->user_data;
msg = g_dbus_method_invocation_get_message(invocation);
fd_list = g_dbus_message_get_unix_fd_list(msg);
}
head_callback_info->local_id = 0;
head_callback_info->remote_app_id = NULL;
- head_callback_info->callback = NULL;
+ head_callback_info->local_info = NULL;
head_callback_info->gio_read = NULL;
head_callback_info->g_src_id = 0;
callback_info_list = g_list_append(callback_info_list, head_callback_info);
LOGD("call calback %s", local_appid);
if (bi_dir)
- mi->callback(mi->local_id, local_appid, local_port, local_trusted, data, NULL);
+ mi->callback(mi->local_id, local_appid, local_port, local_trusted, data, mi->user_data);
else
- mi->callback(mi->local_id, local_appid, NULL, false, data, NULL);
+ mi->callback(mi->local_id, local_appid, NULL, false, data, mi->user_data);
bundle_free(data);
ret = true;