json_object *action_obj = NULL;
int action = -1;
- content_obj = json_object_object_get(obj, TTD_CMD_KEY_CONTENT);
+ json_object_object_get_ex(obj, TTD_CMD_KEY_CONTENT, &content_obj);
retvm_if(!content_obj, -1, "%s", "failed to get content");
- action_obj =
- json_object_object_get(content_obj, TTD_CMD_KEY_CONTENT_ACTION);
+ json_object_object_get_ex(
+ content_obj, TTD_CMD_KEY_CONTENT_ACTION, &action_obj);
retvm_if(!action_obj, -1, "%s", "failed to get action");
action = json_object_get_int(action_obj);
static int __parse_cmd_config(json_object *obj, ttd_cmd_data *cmd)
{
- json_object *content_obj = NULL;
- json_object *info_obj = NULL;
- void *info_data = NULL;
int action = -1;
- int ret = 0;
action = __parse_cmd_get_action(obj);
retv_if(action < 0, -1);
case TTD_CMD_CONFIG_SET_SERVER_URL:
case TTD_CMD_CONFIG_SET_APP_ID:
{
+ json_object *content_obj = NULL;
+ json_object *info_obj = NULL;
+ void *info_data = NULL;
+ int ret = 0;
+
ret = ttd_cmd_set_command(cmd, action);
if (ret < 0) {
_E("Failed to set action");
return -1;
}
- content_obj = json_object_object_get(obj, TTD_CMD_KEY_CONTENT);
+ json_object_object_get_ex(obj, TTD_CMD_KEY_CONTENT, &content_obj);
retvm_if(!content_obj, -1, "%s", "failed to get content");
- info_obj = json_object_object_get(content_obj, TTD_CMD_KEY_CONTENT_INFO);
+ json_object_object_get_ex(
+ content_obj, TTD_CMD_KEY_CONTENT_INFO, &info_obj);
retvm_if(!info_obj, -1, "failed to get content information");
info_data = g_strdup(json_object_to_json_string(info_obj));
gchar *extra_data = NULL;
ret = ttd_cmd_set_command(cmd, action);
- extra_obj = json_object_object_get(obj, TTD_CMD_KEY_EXTRA);
+ json_object_object_get_ex(obj, TTD_CMD_KEY_EXTRA, &extra_obj);
retvm_if(!extra_obj, -1, "failed to get extra information");
extra_data = g_strdup(json_object_to_json_string(extra_obj));
return -1;
}
- items_obj = json_object_object_get(root_obj, TTD_CMD_KEY_ITEMS);
+ json_object_object_get_ex(root_obj, TTD_CMD_KEY_ITEMS, &items_obj);
+ if (!items_obj) {
+ _E("There are no cmd items");
+ json_object_put(root_obj);
+ return -1;
+ }
+
items_type = json_object_get_type(items_obj);
if (items_type != json_type_array) {
_E("cmd items are not array type (is %d)", items_type);
continue;
}
- temp_obj = json_object_object_get(obj, TTD_CMD_KEY_ID);
+ json_object_object_get_ex(obj, TTD_CMD_KEY_ID, &temp_obj);
+ if (!temp_obj) {
+ _E("failed to get cmd id object - %s", json_object_get_string(obj));
+ continue;
+ }
+
cmd_id = json_object_get_string(temp_obj);
if (!cmd_id) {
_E("failed to get cmd id - %s", json_object_get_string(obj));
continue;
}
+ temp_obj = NULL;
+
+ json_object_object_get_ex(obj, TTD_CMD_KEY_TYPE, &temp_obj);
+ if (!temp_obj) {
+ _E("failed to get cmd type object - %s", json_object_get_string(obj));
+ continue;
+ }
+ cmd_type = json_object_get_int(temp_obj);
+ temp_obj = NULL;
cmd_data = ttd_cmd_new(cmd_id);
if (!cmd_data) {
}
ttd_cmd_set_state(cmd_data, TTD_CMD_STATE_CREATED);
-
- temp_obj = json_object_object_get(obj, TTD_CMD_KEY_TYPE);
- cmd_type = json_object_get_int(temp_obj);
ttd_cmd_set_type(cmd_data, cmd_type);
ret = __parse_cmd_by_type(obj, cmd_data);