From: Jeonghoon Park Date: Thu, 3 May 2018 10:07:42 +0000 (+0900) Subject: adds command id to command data X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6fad81192f0419377d135df961e132aa39adcd89;hp=69e80ac13a07a38af9873a7fe5605f0c0e40a8f0;p=apps%2Fnative%2Ftizen-things-daemon.git adds command id to command data Change-Id: I3c37fd0fbce317357b1598fd2dc800c7fe1b15d4 --- diff --git a/daemon/src/ttd-cmd.c b/daemon/src/ttd-cmd.c index c8f6e8c..d383a13 100644 --- a/daemon/src/ttd-cmd.c +++ b/daemon/src/ttd-cmd.c @@ -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); } diff --git a/daemon/src/ttd-parse-cmd.c b/daemon/src/ttd-parse-cmd.c index 24cdef5..e9320a0 100644 --- a/daemon/src/ttd-parse-cmd.c +++ b/daemon/src/ttd-parse-cmd.c @@ -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);