diff options
author | Jin Yoon <jinny.yoon@samsung.com> | 2017-07-18 11:00:15 +0900 |
---|---|---|
committer | Jin Yoon <jinny.yoon@samsung.com> | 2017-07-18 11:00:15 +0900 |
commit | 2df49ec289d410409d545e93280118661f0086f9 (patch) | |
tree | 9501b7b2d042688ed1e2538d8ce26d50ff3b34aa | |
parent | 1e6ec73300984e0a421e8d7e8919cc81ee8cb47b (diff) | |
download | position-finder-client-2df49ec289d410409d545e93280118661f0086f9.tar.gz position-finder-client-2df49ec289d410409d545e93280118661f0086f9.tar.bz2 position-finder-client-2df49ec289d410409d545e93280118661f0086f9.zip |
Remove unused query rotines
Change-Id: I02e3b3e297afffba7c0c83bfb05f84ff5f6fc0b1
-rw-r--r-- | src/connectivity.c | 235 |
1 files changed, 1 insertions, 234 deletions
diff --git a/src/connectivity.c b/src/connectivity.c index 0a2316b..8ed0524 100644 --- a/src/connectivity.c +++ b/src/connectivity.c @@ -50,9 +50,6 @@ static struct { .list = NULL, }; -static void _response_query_cb(iotcon_remote_resource_h resource, iotcon_error_e err, - iotcon_request_type_e request_type, iotcon_response_h response, void *user_data); - static void _observe_cb(iotcon_remote_resource_h resource, iotcon_error_e err, int sequence_number, iotcon_response_h response, void *user_data) { int ret = -1; @@ -90,183 +87,6 @@ static void _observe_cb(iotcon_remote_resource_h resource, iotcon_error_e err, i resource_info->cb_info->cb(resource_info, (void *)(int) opened, resource_info->cb_info->user_data); } -static void _response_delete_query(iotcon_remote_resource_h resource, iotcon_response_h response, void *user_data) -{ - int ret = -1; - iotcon_response_result_e response_result; - - ret = iotcon_response_get_result(response, &response_result); - ret_if(IOTCON_ERROR_NONE != ret); - - if (IOTCON_RESPONSE_OK != response_result - && IOTCON_RESPONSE_RESOURCE_DELETED != response_result) { - _E("_response_delete_query Response error(%d)", response_result); - return; - } - - _I("DELETE request was successful"); - /* FIXME : need to free resources? */ - iotcon_remote_resource_destroy(resource); -} - -static void _response_post_query(iotcon_remote_resource_h resource, iotcon_response_h response, void *user_data) -{ - int ret = -1; - char *host = NULL, *created_uri_path = NULL; - iotcon_connectivity_type_e connectivity_type; - iotcon_response_result_e response_result; - iotcon_attributes_h recv_attributes = NULL; - iotcon_resource_types_h types = NULL; - iotcon_resource_interfaces_h ifaces = NULL; - iotcon_remote_resource_h new_door_resource = NULL; - iotcon_representation_h recv_repr = NULL; - - ret = iotcon_response_get_result(response, &response_result); - ret_if(IOTCON_ERROR_NONE != ret); - - if (IOTCON_RESPONSE_RESOURCE_CREATED != response_result) { - _E("_response_post_query Response error(%d)", response_result); - return; - } - - _I("POST request was successful"); - - ret = iotcon_response_get_representation(response, &recv_repr); - ret_if(IOTCON_ERROR_NONE != ret); - - ret = iotcon_representation_get_attributes(recv_repr, &recv_attributes); - ret_if(IOTCON_ERROR_NONE != ret); - - ret = iotcon_attributes_get_str(recv_attributes, "createduripath", &created_uri_path); - ret_if(IOTCON_ERROR_NONE != ret); - - _D("New resource created : %s", created_uri_path); - - ret = iotcon_remote_resource_get_host_address(resource, &host); - if (IOTCON_ERROR_NONE != ret) { - _E("iotcon_remote_resource_get_host_address() Fail(%d)", ret); - return; - } - - ret = iotcon_remote_resource_get_connectivity_type(resource, &connectivity_type); - if (IOTCON_ERROR_NONE != ret) { - _E("iotcon_remote_resource_get_connectivity_type() Fail(%d)", ret); - return; - } - - ret = iotcon_remote_resource_get_types(resource, &types); - if (IOTCON_ERROR_NONE != ret) { - _E("iotcon_remote_resource_get_types() Fail(%d)", ret); - return; - } - - ret = iotcon_remote_resource_get_interfaces(resource, &ifaces); - if (IOTCON_ERROR_NONE != ret) { - _E("iotcon_remote_resource_get_interfaces() Fail(%d)", ret); - return; - } - - ret = iotcon_remote_resource_create(host, connectivity_type, created_uri_path, - IOTCON_RESOURCE_SECURE, types, ifaces, &new_door_resource); - if (IOTCON_ERROR_NONE != ret) { - _E("iotcon_remote_resource_create() Fail(%d)", ret); - return; - } - - ret = iotcon_remote_resource_delete(new_door_resource, _response_query_cb, NULL); - if (IOTCON_ERROR_NONE != ret) { - _E("iotcon_remote_resource_delete() Fail(%d)", ret); - iotcon_remote_resource_destroy(new_door_resource); - return; - } -} - -static void _response_put_query(iotcon_remote_resource_h resource, iotcon_response_h response, void *user_data) -{ - int ret = -1; - iotcon_response_result_e response_result; - iotcon_representation_h send_repr = NULL; - - ret = iotcon_response_get_result(response, &response_result); - if (IOTCON_ERROR_NONE != ret) { - _E("iotcon_response_get_result() Fail(%d)", ret); - return; - } - - if (IOTCON_RESPONSE_RESOURCE_CHANGED != response_result) { - _E("_response_put_query Response error(%d)", response_result); - return; - } - - _I("PUT request was successful"); - - ret = iotcon_representation_create(&send_repr); - ret_if(IOTCON_ERROR_NONE != ret); - - ret = iotcon_remote_resource_post(resource, send_repr, NULL, _response_query_cb, NULL); - goto_if(IOTCON_ERROR_NONE != ret, out); - -out: - iotcon_representation_destroy(send_repr); -} - -static void _response_get_query(iotcon_remote_resource_h resource, iotcon_response_h response, void *user_data) -{ - bool opened = true; - char *resource_host = NULL; - int ret = -1; - iotcon_response_result_e response_result; - iotcon_representation_h send_repr = NULL; - iotcon_representation_h recv_repr = NULL; - iotcon_attributes_h send_attributes = NULL; - iotcon_attributes_h recv_attributes = NULL; - - ret = iotcon_response_get_result(response, &response_result); - ret_if(IOTCON_ERROR_NONE != ret); - - if (IOTCON_RESPONSE_OK != response_result) { - _E("_response_get_query response error(%d)", response_result); - return; - } - - iotcon_remote_resource_get_host_address(resource, &resource_host); - _I("Resource host : %s", resource_host); - - ret = iotcon_response_get_representation(response, &recv_repr); - ret_if(IOTCON_ERROR_NONE != ret); - - ret = iotcon_representation_get_attributes(recv_repr, &recv_attributes); - ret_if(IOTCON_ERROR_NONE != ret); - - ret = iotcon_attributes_get_bool(recv_attributes, "opened", &opened); - ret_if(IOTCON_ERROR_NONE != ret); - - ret = iotcon_representation_create(&send_repr); - ret_if(IOTCON_ERROR_NONE != ret); - - ret = iotcon_attributes_create(&send_attributes); - goto_if(IOTCON_ERROR_NONE != ret, error); - - ret = iotcon_attributes_add_bool(send_attributes, "opened", !opened); - goto_if(IOTCON_ERROR_NONE != ret, error); - - ret = iotcon_representation_set_attributes(send_repr, send_attributes); - goto_if(IOTCON_ERROR_NONE != ret, error); - - ret = iotcon_remote_resource_put(resource, send_repr, NULL, _response_query_cb, NULL); - goto_if(IOTCON_ERROR_NONE != ret, error); - - iotcon_attributes_destroy(send_attributes); - iotcon_representation_destroy(send_repr); - - return; - -error: - if (send_attributes) iotcon_attributes_destroy(send_attributes); - if (send_repr) iotcon_representation_destroy(send_repr); - -} - static void _presence_cb(iotcon_presence_h presence, iotcon_error_e err, iotcon_presence_response_h response, void *user_data) { @@ -303,34 +123,6 @@ static void _presence_cb(iotcon_presence_h presence, iotcon_error_e err, _I("Resource type : %s", resource_type); } -static void _response_query_cb(iotcon_remote_resource_h resource, - iotcon_error_e err, - iotcon_request_type_e request_type, - iotcon_response_h response, - void *user_data) -{ - ret_if(IOTCON_ERROR_NONE != err); - - _I("Request type[%d]", request_type); - - switch (request_type) { - case IOTCON_REQUEST_GET: - _response_get_query(resource, response, user_data); - break; - case IOTCON_REQUEST_PUT: - _response_put_query(resource, response, user_data); - break; - case IOTCON_REQUEST_POST: - _response_post_query(resource, response, user_data); - break; - case IOTCON_REQUEST_DELETE: - _response_delete_query(resource, response, user_data); - break; - default: - _E("Invalid request type (%d)", request_type); - } -} - /* return values : -1 error, 0 not exist, 1 exist */ static int _exist_device_id_in_list(iotcon_remote_resource_h resource) { @@ -341,6 +133,7 @@ static int _exist_device_id_in_list(iotcon_remote_resource_h resource) retv_if(!resource, -1); + /* device_id is derived from subject id. */ ret = iotcon_remote_resource_get_device_id(resource, &device_id); retv_if(IOTCON_ERROR_NONE != ret, -1); @@ -575,28 +368,6 @@ static void _unregister_observe(connectivity_resource_s *info) } #endif -static int _request_query(connectivity_resource_s *info) -{ - int ret = -1; - iotcon_query_h query = NULL; - - ret = iotcon_query_create(&query); - retv_if(IOTCON_ERROR_NONE != ret, -1); - - ret = iotcon_query_add(query, "query_key", "query_value"); - goto_if(IOTCON_ERROR_NONE != ret, error); - - ret = iotcon_remote_resource_get(info->resource, query, _response_query_cb, NULL); - goto_if(IOTCON_ERROR_NONE != ret, error); - - iotcon_query_destroy(query); - return 0; - -error: - iotcon_query_destroy(query); - return -1; -} - static bool _found_resource_cb(iotcon_remote_resource_h resource, iotcon_error_e result, void *user_data) { int ret = -1; @@ -629,10 +400,6 @@ static bool _found_resource_cb(iotcon_remote_resource_h resource, iotcon_error_e _E("Cannot observe [%s:%s:%s:%s]", info->device_id, info->host_address, info->device_name, info->uri_path); } - if (-1 == _request_query(info)) { - _E("Cannot request query"); - } - ret = _add_resource_info_into_list(info); goto_if(-1 == ret, error); |