return ret;
}
+/* Allocate memory and gets payload for message */
+static char *get_msg_payload(log_t *log)
+{
+ char *data_buf = NULL;
+ ssize_t recvlen;
+
+ if (log->length <= 0)
+ return NULL;
+
+ data_buf = malloc(log->length);
+ if (data_buf == NULL) {
+ PRINTERR("Cannot allocate buffer for message. Size %d",
+ log->length);
+ return NULL;
+ }
+
+ recvlen = recv(gTraceInfo.socket.daemonSock, data_buf, log->length,
+ MSG_WAITALL);
+ if (recvlen != log->length) {
+ PRINTERR("Cannot receive data!");
+ free(data_buf);
+ data_buf = NULL;
+ }
+
+ return data_buf;
+}
+
static void *recvThread(void __unused *data)
{
fd_set readfds, workfds;
if(recvlen > 0) // recv succeed
{
-
- if (log.length > 0 &&
- (unsigned int)log.length <= sizeof(log.data)) {
- data_buf = malloc(log.length);
- if (data_buf == NULL) {
- PRINTERR("cannot allocate buf to recv msg");
- break;
- }
- recvlen = recv(gTraceInfo.socket.daemonSock, data_buf,
- log.length, MSG_WAITALL);
- if (recvlen != log.length) {
- PRINTERR("Can not recv data from\n");
+ if (log.type == APP_MSG_CONFIG) {
+ data_buf = get_msg_payload(&log);
+ if (data_buf != NULL) {
+ _configure(data_buf);
goto free_data_buf;
}
- }
-
- if (log.type == APP_MSG_CONFIG) {
- _configure(data_buf);
} else if(log.type == APP_MSG_STOP) {
PRINTMSG("APP_MSG_STOP");
- if (data_buf) {
- free(data_buf);
- data_buf = NULL;
- }
application_exit();
break;
} else if(log.type == APP_MSG_TYPE_AND_INFO) {
PRINTMSG("APP_MSG_TYPE_AND_INFO");
} else if(log.type == APP_MSG_GET_UI_HIERARCHY) {
enum ErrorCode err_code = ERR_UNKNOWN;
+ Eina_Bool rendering;
print_log_ui_viewer_hierarchy_status(&err_code);
continue;
}
- if(log.length > 0) {
- Eina_Bool rendering;
-
- rendering = (enum rendering_option_t)*((uint8_t *)data_buf);
+ rendering = (enum rendering_option_t)
+ *((uint8_t *)get_msg_payload(&log));
+ if(rendering != 0) {
PRINTMSG("APP_MSG_GET_UI_HIERARCHY, rendering option <%d>", rendering);
ecore_set_data_get_uihv(rendering);
+ goto free_data_buf;
} else {
PRINTERR("WRONG APP_MSG_GET_UI_PROPERTIES");
}
set_hierarchy_status(HIERARCHY_CANCELLED);
continue;
} else if(log.type == APP_MSG_GET_UI_SCREENSHOT) {
- if(log.length > 0) {
- Evas_Object *obj;
+ Evas_Object *obj;
+ obj = (Evas_Object*)(unsigned long)
+ *((uint64_t *)get_msg_payload(&log));
+ if(obj != 0) {
- obj = (Evas_Object*)(unsigned long)*((uint64_t *)data_buf);
PRINTMSG("APP_MSG_GET_UI_SCREENSHOT <0x%lx>", obj);
ecore_set_data_get_obj_screenshot(obj);
+ goto free_data_buf;
} else {
PRINTERR("WRONG APP_MSG_GET_UI_SCREENSHOT");
}
}
}
- if (data_buf)
- free(data_buf);
-
return NULL;
}