adds command id to command data 52/177752/1
authorJeonghoon Park <jh1979.park@samsung.com>
Thu, 3 May 2018 10:07:42 +0000 (19:07 +0900)
committerJeonghoon Park <jh1979.park@samsung.com>
Thu, 3 May 2018 10:07:42 +0000 (19:07 +0900)
Change-Id: I3c37fd0fbce317357b1598fd2dc800c7fe1b15d4

daemon/src/ttd-cmd.c
daemon/src/ttd-parse-cmd.c

index c8f6e8c..d383a13 100644 (file)
@@ -110,8 +110,11 @@ void ttd_cmd_free(ttd_cmd_data *cmd)
        if (!cmd)
                return;
 
-       if (cmd->cmd_id)
+       _D("free cmd type - %d", cmd->type);
+       if (cmd->cmd_id) {
+               _D("free cmd id - %s", cmd->cmd_id);
                g_free(cmd->cmd_id);
+       }
 
        g_free(cmd);
 }
index 24cdef5..e9320a0 100644 (file)
@@ -22,6 +22,7 @@
 #include "ttd-cmd.h"
 
 #define TTD_CMD_KEY_TYPE "type"
+#define TTD_CMD_KEY_ID "id"
 #define TTD_CMD_KEY_STATE "state"
 #define TTD_CMD_KEY_STATE_CREATED "created"
 #define TTD_CMD_KEY_CONTENT "content"
@@ -238,6 +239,7 @@ int ttd_parse_json_to_cmd(const char *json_str, GList **cmd_list)
                json_object *temp_obj = NULL;
                int cmd_type = 0;
                const char *cmd_state = NULL;
+               const char *cmd_id = NULL;
                int ret = 0;
 
                obj = json_object_array_get_idx(root_obj, i);
@@ -263,6 +265,10 @@ int ttd_parse_json_to_cmd(const char *json_str, GList **cmd_list)
                        ttd_cmd_free(cmd_data);
                        continue;
                }
+               temp_obj = json_object_object_get(obj, TTD_CMD_KEY_ID);
+               cmd_id = json_object_get_string(temp_obj);
+               ttd_cmd_set_id(cmd_data, cmd_id);
+
                list = g_list_append(list, cmd_data);
        }
        json_object_put(root_obj);