int remote_port_name_len;
char *remote_port_name;
bool is_bidirection;
+ bool is_trusted;
int data_len;
unsigned char *data;
} message_port_pkt_s;
typedef struct message_port_callback_info {
messageport_message_cb callback;
- bool is_trusted;
int local_id;
char *remote_app_id;
GIOChannel *gio_read;
close(fd);
return NULL;
}
+
if (__read_string_from_socket(fd, (char **)&pkt->remote_port_name, &pkt->remote_port_name_len) != MESSAGEPORT_ERROR_NONE) {
LOGE("read socket fail: port_name");
free(pkt->remote_port_name);
close(fd);
return NULL;
}
+
if (__read_socket(fd, (char *)&pkt->is_bidirection, sizeof(pkt->is_bidirection), &nb) != MESSAGEPORT_ERROR_NONE) {
LOGE("read socket fail: is_bidirection");
free(pkt->remote_port_name);
close(fd);
return NULL;
}
+
+ if (__read_socket(fd, (char *)&pkt->is_trusted, sizeof(pkt->is_trusted), &nb) != MESSAGEPORT_ERROR_NONE) {
+ LOGE("read socket fail: is_trusted");
+ free(pkt->remote_port_name);
+ free(pkt);
+ close(fd);
+ return NULL;
+ }
+
if (__read_string_from_socket(fd, (char **)&pkt->data, &pkt->data_len) != MESSAGEPORT_ERROR_NONE) {
LOGE("read socket fail: data");
free(pkt->remote_port_name);
close(fd);
return NULL;
}
+
return pkt;
}
kb = bundle_decode(pkt->data, pkt->data_len);
if (pkt->is_bidirection)
- mi->callback(mi->local_id, mi->remote_app_id, pkt->remote_port_name, mi->is_trusted, kb, NULL);
+ mi->callback(mi->local_id, mi->remote_app_id, pkt->remote_port_name, pkt->is_trusted, kb, NULL);
else
- mi->callback(mi->local_id, mi->remote_app_id, NULL, mi->is_trusted, kb, NULL);
+ mi->callback(mi->local_id, mi->remote_app_id, NULL, pkt->is_trusted, kb, NULL);
if (pkt) {
if (pkt->remote_port_name)
callback_info->local_id = mi->local_id;
callback_info->remote_app_id = strdup(local_appid);
callback_info->callback = mi->callback;
- callback_info->is_trusted = local_trusted;
GError *error = NULL;
GDBusMessage *msg = g_dbus_method_invocation_get_message(invocation);
_LOGE("write local_port fail");
return MESSAGEPORT_ERROR_IO_ERROR;
}
+
if (__write_socket(sockfd, (char *)&is_bidirection, sizeof(is_bidirection), &nb) != MESSAGEPORT_ERROR_NONE) {
_LOGE("write is_bidirection fail");
return MESSAGEPORT_ERROR_IO_ERROR;
}
+ if (__write_socket(sockfd, (char *)&local_trusted, sizeof(local_trusted), &nb) != MESSAGEPORT_ERROR_NONE) {
+ _LOGE("write local_trusted fail");
+ return MESSAGEPORT_ERROR_IO_ERROR;
+ }
+
bundle_encode(kb, &kb_data, &data_len);
if (kb_data == NULL) {
_LOGE("bundle encode fail");
ret = MESSAGEPORT_ERROR_IO_ERROR;
goto out;
}
+
if (data_len > MAX_MESSAGE_SIZE) {
_LOGE("bigger than max size\n");
ret = MESSAGEPORT_ERROR_MAX_EXCEEDED;