Merge "Added tools - mockup of cloud and injector. Changed code to support task-worker."
[apps/native/tizen-things-daemon.git] / daemon / src / ttd-parse-cmd.c
index f8789e9..54c4ec2 100644 (file)
@@ -29,6 +29,7 @@
 #define TTD_CMD_KEY_CONTENT "content"
 #define TTD_CMD_KEY_CONTENT_ACTION "action"
 #define TTD_CMD_KEY_CONTENT_INFO "info"
+#define TTD_CMD_KEY_CONTENT_JSON "json"
 #define TTD_CMD_KEY_EXTRA "extra"
 
 static int __parse_cmd_get_action(json_object *obj)
@@ -183,6 +184,9 @@ static int __parse_cmd_diagnosis(json_object *obj, ttd_cmd_data *cmd)
 
 static int __parse_cmd_info(json_object *obj, ttd_cmd_data *cmd)
 {
+       json_object *content_obj = NULL;
+       json_object *json_obj = NULL;
+       void *json_data = NULL;
        int action = 0;
        int ret = 0;
 
@@ -192,6 +196,20 @@ static int __parse_cmd_info(json_object *obj, ttd_cmd_data *cmd)
        switch (action) {
        case TTD_CMD_INFO_GET_SYSINFO:
        case TTD_CMD_INFO_GET_TASKINFO:
+
+               content_obj = json_object_object_get(obj, TTD_CMD_KEY_CONTENT);
+               retvm_if(!content_obj, -1, "%s", "failed to get content");
+
+               json_obj = json_object_object_get(content_obj, TTD_CMD_KEY_CONTENT_JSON);
+               retvm_if(!json_obj, -1, "failed to get content json");
+               json_data = g_strdup(json_object_get_string(json_obj));
+               if (json_data)
+                       ttd_cmd_set_data(cmd, json_data, strlen(json_data), g_free);
+               else {
+                       _E("failed to get json from content");
+                       return -1;
+               }
+
                ret = ttd_cmd_set_command(cmd, action);
                break;
        case TTD_CMD_INFO_GET_MAX:
@@ -264,7 +282,7 @@ int ttd_parse_json_to_cmd(const char *json_str, GList **cmd_list)
 
        items_type = json_object_get_type(items_obj);
        if (items_type != json_type_array) {
-               _E("cmd items are not array type");
+               _E("cmd items are not array type (is %d)", items_type);
                json_object_put(root_obj);
                return -1;
        }