From c64e1561a8ff9e2317062d96dd48ed45223ea025 Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Fri, 23 Mar 2018 15:55:20 +0530 Subject: [PATCH] comp-manager: Code cleanup after replacing iotcon with IoTivity C++ Stack Signed-off-by: Saurav Babu --- CMakeLists.txt | 2 +- packaging/d2d-manager.spec | 1 - src/companion-manager/include/comp_group.h | 2 +- src/companion-manager/include/comp_log.h | 4 +- src/companion-manager/include/comp_mot_agent.h | 12 +- src/companion-manager/include/comp_resource.h | 8 +- src/companion-manager/src/comp_group.c | 10 +- src/companion-manager/src/comp_iot.cpp | 435 +------------------------ src/companion-manager/src/comp_mot_agent.c | 8 +- src/companion-manager/src/comp_resource.c | 10 +- 10 files changed, 30 insertions(+), 462 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9ba4b9..5eb9531 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/include) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/capi/include) MESSAGE(" - Checking...packages dependency") -SET(COMMON_DEPS glib-2.0 gio-2.0 gio-unix-2.0 dlog dbus-1 iotivity uuid iotcon capi-base-common capi-system-info vconf boost gmock) +SET(COMMON_DEPS glib-2.0 gio-2.0 gio-unix-2.0 dlog dbus-1 iotivity uuid capi-base-common capi-system-info vconf boost gmock) IF (LINUX) PKG_CHECK_MODULES(daemon_pkgs REQUIRED ${COMMON_DEPS}) ADD_DEFINITIONS("-DLINUX") diff --git a/packaging/d2d-manager.spec b/packaging/d2d-manager.spec index 1b3ef30..84998fb 100644 --- a/packaging/d2d-manager.spec +++ b/packaging/d2d-manager.spec @@ -30,7 +30,6 @@ BuildRequires: pkgconfig(capi-network-wifi-manager) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(gmock) -BuildRequires: pkgconfig(iotcon) BuildRequires: pkgconfig(sqlite3) %description diff --git a/src/companion-manager/include/comp_group.h b/src/companion-manager/include/comp_group.h index 3e2c6ed..3b71e91 100644 --- a/src/companion-manager/include/comp_group.h +++ b/src/companion-manager/include/comp_group.h @@ -130,7 +130,7 @@ int comp_group_get_group_device_id(comp_group_t *handle); /* notify */ int comp_group_event_handler(/*callback*/); // event hadnler -int comp_group_add_device_in_group(char *group_name, char *uuid); +int comp_group_add_device_in_group(const char *group_name, const char *uuid); int comp_group_request_create_group(char *uuid, char *group_name); int comp_group_request_invite(char *uuid, char *group_name, char *target_uuid, char *PIN); diff --git a/src/companion-manager/include/comp_log.h b/src/companion-manager/include/comp_log.h index 1a72d9f..90f60b8 100644 --- a/src/companion-manager/include/comp_log.h +++ b/src/companion-manager/include/comp_log.h @@ -46,11 +46,11 @@ } while (0) #define LOG_BEGIN() \ do { \ - LOGD(COLOR_BLUE "BEGIN >>>>"COLOR_END); \ + LOGD(COLOR_BLUE "BEGIN" COLOR_END); \ } while (0) #define LOG_END() \ do { \ - LOGD(COLOR_BLUE "END <<<<"COLOR_END); \ + LOGD(COLOR_BLUE "END" COLOR_END); \ } while (0) #define NOTUSED(var) (var = var) diff --git a/src/companion-manager/include/comp_mot_agent.h b/src/companion-manager/include/comp_mot_agent.h index 5ef7109..d647610 100644 --- a/src/companion-manager/include/comp_mot_agent.h +++ b/src/companion-manager/include/comp_mot_agent.h @@ -32,15 +32,15 @@ int agent_find_mot_enable_devices(int timeout); int agent_find_mowned_devices(); int agent_mot(char* uuid_str, char *pin); int agent_resources_pairwise(char* target1, char *subject1, char *uri1, - char *rt1, char *interface1, int permission1, char* target2, char *subject2, char *uri2, - char *rt2, char *interface2, int permission2); + char *rt1, char *interface1, int permission1, char* target2, char *subject2, + char *uri2, char *rt2, char *interface2, int permission2); int agent_unlink_resources(char* uuid_str1, char *uuid_str2); int agent_remove_subowner(char* uuid_str); int agent_remove_subowned(char* uuid_str); -int agent_pair(char *pin, char* target1, char *subject1, char *uri1, - char *rt1, char *interface1, int permission1, char* target2, char *subject2, char *uri2, - char *rt2, char *interface2, int permission2); -int agent_unpair(char* uuid_str1, char *uuid_str2); +int agent_pair(const char *pin, char* target1, const char *subject1, char *uri1, + char *rt1, char *interface1, int permission1, const char* target2, + char *subject2, char *uri2, char *rt2, char *interface2, int permission2); +int agent_unpair(char* uuid_str1, const char *uuid_str2); #ifdef __cplusplus } diff --git a/src/companion-manager/include/comp_resource.h b/src/companion-manager/include/comp_resource.h index 27de9cb..2480aa0 100644 --- a/src/companion-manager/include/comp_resource.h +++ b/src/companion-manager/include/comp_resource.h @@ -18,8 +18,8 @@ #ifndef __COMP_RESOURCE_H__ #define __COMP_RESOURCE_H__ -#include #include +#include #ifdef __cplusplus extern "C" @@ -30,7 +30,7 @@ typedef struct { comp_resource_type_e resource_type; char *type; char *uri_prefix; - uint8_t policies; + unsigned char policies; } comp_rd_t; typedef struct { @@ -40,10 +40,8 @@ typedef struct { int comp_resource_append(comp_resource_type_e resource_type, const char *uri); char *comp_resource_get_type(comp_resource_type_e resource_type); char *comp_resource_get_uri_prefix(comp_resource_type_e resource_type); -uint8_t comp_resource_get_policies(comp_resource_type_e resource_type); +unsigned char comp_resource_get_policies(comp_resource_type_e resource_type); void comp_resource_print_list(); -int comp_resource_get_resource_from_uri(comp_resource_type_e resource_type, - char *uri, iotcon_resource_h *parent_resource); #ifdef __cplusplus } diff --git a/src/companion-manager/src/comp_group.c b/src/companion-manager/src/comp_group.c index f84f358..2c3bb04 100644 --- a/src/companion-manager/src/comp_group.c +++ b/src/companion-manager/src/comp_group.c @@ -459,7 +459,7 @@ int _is_pairwise_uuid(char *uuid) return -1; } -int comp_group_add_device_in_group(char *group_name, char *uuid) +int comp_group_add_device_in_group(const char *group_name, const char *uuid) { comp_context_t *comp_ctx = comp_context_get_context(); comp_check_null_ret_error("comp_ctx", comp_ctx, -1); @@ -533,8 +533,10 @@ int comp_group_invite(const char *group_name, const char *uuid, const char *pin) } #else - ret = agent_pair(pin, comp_ctx->device_uuid, uuid, "/comp/data/1", "core.comp.data", - "oic.if.baseline", FULL_PERMISSION, uuid, comp_ctx->device_uuid, "/comp/data/1", "core.comp.data", "oic.if.baseline", FULL_PERMISSION); + ret = agent_pair(pin, comp_ctx->device_uuid, uuid, "/comp/data/1", + "core.comp.data", "oic.if.baseline", FULL_PERMISSION, uuid, + comp_ctx->device_uuid, "/comp/data/1", "core.comp.data", + "oic.if.baseline", FULL_PERMISSION); #endif if (comp_group_add_device_in_group(group_name, uuid) < 0) @@ -552,7 +554,7 @@ void comp_group_notify_group_dismiss(int result) notify_group_device_eject_result(result); } -int comp_group_remove_device_in_group(char *uuid) +int comp_group_remove_device_in_group(const char *uuid) { comp_context_t *comp_ctx = comp_context_get_context(); comp_check_null_ret_error("comp_ctx", comp_ctx, -1); diff --git a/src/companion-manager/src/comp_iot.cpp b/src/companion-manager/src/comp_iot.cpp index 9273247..6443abc 100644 --- a/src/companion-manager/src/comp_iot.cpp +++ b/src/companion-manager/src/comp_iot.cpp @@ -228,15 +228,6 @@ int comp_iot_initialize() g_free(device_info.deviceName); -#if 0 - int ret = iotcon_initialize(data_dir); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("iotcon_initialize: Failed %s", get_error_message(ret)); - return false; - } - LOG_DEBUG("iotcon_initialize : %s", get_error_message(ret)); -#endif - OicUuid_t uuid; ret = GetDoxmDeviceID(&uuid); @@ -256,9 +247,6 @@ int comp_iot_initialize() /* Do Self-Ownership Transfer */ ret = OCSecure::configSelfOwnership(); -#if 0 - ret = OCConfigSelfOwnership(); -#endif if (OC_STACK_OK != ret ) { LOG_ERR( "OCConfigSelfOwnership() error = [%d][%s]", ret, get_error_message(ret)); } @@ -366,8 +354,6 @@ OCEntityHandlerResult _request_handler(std::shared_ptr reques memcpy(arg, out, len); LOG_DEBUG("successfully decoded to base64. %s", arg); - - iotcon_query_remove(query, "data"); #else if (!rep.getValue("data", data)) LOG_ERR("data not found"); @@ -442,164 +428,6 @@ OCEntityHandlerResult _request_handler(std::shared_ptr reques } return OC_EH_OK; - //get resource element from comp resource list or, parsing resource uri - - //if request type is "get" and resource type is "group", - //then OWNER send device information to CLIENT(Device info Exchange) - //if request type is "put" and resource type is "operation", - //then It is join request. CLIENT send device information to OWNER(Device info Exchange) - //resource type "operation" don't have "get" request type. - -#if 0 - int ret; - iotcon_request_type_e type; - - ret = iotcon_request_get_request_type(request, &type); - if (IOTCON_ERROR_NONE != ret) - return; - - LOG_DEBUG("iotcon request type %d", type); - if (IOTCON_REQUEST_POST == type) { - iotcon_response_h response = NULL; - iotcon_representation_h req_repr; - iotcon_attributes_h attributes; - char *cmd; - char *arg = NULL; - int result; - comp_request_type_e command; - - ret = iotcon_request_get_representation(request, &req_repr); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("iotcon_request_get_representation() Fail(%d)", ret); - return; - } - - ret = iotcon_representation_get_attributes(req_repr, &attributes); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("iotcon_representation_get_attributes() Fail(%d)", ret); - return; - } - - ret = iotcon_attributes_get_str(attributes, "CMD", &cmd); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("iotcon_attributes_get_bool() Fail(%d)", ret); - return; - } - - LOG_DEBUG("cmd %s", cmd); - - command = string2command(cmd); - - if (command == COMP_REQ_CREATE_GROUP) { - LOG_DEBUG("Request create group"); - char *group_name; - iotcon_attributes_get_str(attributes, "name", &group_name); - - LOG_DEBUG("group_name : %s", group_name); - result = comp_group_create(group_name); - arg = g_strdup(group_name); - - } else if (command == COMP_REQ_INVITE_DEVICE) { - LOG_DEBUG("Request invite"); - char *group_name; - char *uuid; - - iotcon_attributes_get_str(attributes, "name", &group_name); - iotcon_attributes_get_str(attributes, "id", &uuid); - - LOG_DEBUG("group_name : %s, UUID : %s", group_name, uuid); - - result = comp_group_invite(group_name, uuid, "12341234"); - arg = g_strdup(uuid); - - } else if (command == COMP_REQ_EJECT_DEVICE) { - LOG_DEBUG("Request eject"); - char *group_name; - char *uuid; - comp_context_t *comp_ctx = comp_context_get_context(); - - iotcon_attributes_get_str(attributes, "name", &group_name); - iotcon_attributes_get_str(attributes, "id", &uuid); - - LOG_DEBUG("group_name : %s, Self UUID : %s Target UUID : %s", - group_name, comp_ctx->device_uuid, uuid); - - result = comp_group_dismiss(comp_ctx->device_uuid, uuid); - arg = g_strdup(uuid); - - } else if (command == COMP_REQ_DELETE_GROUP) { - LOG_DEBUG("Request delete group"); - arg = g_strdup("DELETED"); - } else if (command == COMP_REQ_SEND_DATA) { -#ifdef SUPPORT_BASE64_ENCODING - int payload_len; - char *data = NULL; - - LOG_DEBUG("Receive Data"); - - iotcon_attributes_get_str(attributes, "data", &data); - /* - * BASE64 encoding/decoding system use '=' as padding byte - * But, query parameter does not allow use '=' character.Basically, - * So, in order to use BASE64 as query parameters, we need additioinal length param - * such as 'len=xx' - */ - payload_len = strlen(data); /* This data may be cliped the last padding 1~2 bytes ('='/'==') */ - - LOG_DEBUG("data = %s payload_len = %d", data, payload_len); - - size_t outSize = B64DECODE_OUT_SAFESIZE(payload_len + 1); - uint8_t* out = g_malloc0(outSize); - if (NULL == out) { - LOG_ERR("Can't allocate memory for base64 str"); - return; - } - uint32_t len = 0; - - if(B64_OK == b64Decode(data, payload_len, out, outSize, &len)) { - LOG_ERR("Base64 decoding failed."); - return; - } - memcpy(arg, out, len); - - LOG_DEBUG("successfully decoded to base64. %s", arg); - - iotcon_query_remove(query, "data"); -#else - char *data = NULL; - iotcon_attributes_get_str(attributes, "data", &data); - LOG_DEBUG("Receive Data = %s", data); - arg = g_strdup(data); -#endif - } else { - LOG_ERR("Unknown request command"); - } - - notify_request_result(cmd, arg, result); - - free(arg); - - ret = iotcon_response_create(request, &response); - if (IOTCON_ERROR_NONE != ret) - return; - - ret = iotcon_response_set_result(response, IOTCON_RESPONSE_OK); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("iotcon_response_set_result Faild = %d", ret); - iotcon_response_destroy(response); - return; - } - - ret = iotcon_response_send(response); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("iotcon_response_send Faild = %d", ret); - iotcon_response_destroy(response); - return; - } - - iotcon_response_destroy(response); - } -#endif } int comp_iot_add_resource(comp_resource_type_e resource_type, const char *uri) @@ -630,17 +458,6 @@ int comp_iot_add_resource(comp_resource_type_e resource_type, const char *uri) return COMP_ERROR_NONE; } -static bool _get_res_type_cb(const char *string, void *user_data) -{ - char **resource_type = (char **)user_data; - - *resource_type = g_strdup(string); - - LOG_DEBUG("resource type : %s", *resource_type); - - return IOTCON_FUNC_CONTINUE; -} - int found_group_count = 0; static void _clear_user_data(void *user_data) @@ -680,37 +497,6 @@ static void _clear_user_data(void *user_data) } } -#if 0 -static void _on_get(iotcon_remote_resource_h resource, iotcon_error_e err, - iotcon_request_type_e request_type, iotcon_response_h response, void *user_data) -{ - last_get_result = err; - - int ret; - iotcon_response_result_e response_result; - - ret = iotcon_response_get_result(response, &response_result); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("iotcon_response_get_result() Fail(%d)", ret); - return; - } - - if (IOTCON_RESPONSE_OK != response_result) { - LOG_ERR("_on_get Response error(%d)", response_result); - return; - } - - /* get the resource host address */ - char *resource_host = NULL; - iotcon_remote_resource_get_host_address(resource, &resource_host); - LOG_DEBUG("resource host : %s", resource_host); - - iotcon_remote_resource_destroy(resource); - - _clear_user_data(user_data); -} -#endif - static void _on_post(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep, const int eCode) { @@ -815,7 +601,7 @@ static bool _found_resource(std::shared_ptr resource, char* b64Buf = g_malloc0(b64BufSize); if (NULL == b64Buf) { _clear_user_data(cmd); - return IOTCON_FUNC_CONTINUE; + return TRUE; } b64Encode((const char *)cmd->arg1, cmd->arg1_len, b64Buf, b64BufSize, &outSize); @@ -846,184 +632,7 @@ static bool _found_resource(std::shared_ptr resource, LOG_ERR("Exception in foundResource: %s", e.what()); } - return IOTCON_FUNC_CONTINUE; -#if 0 - int ret; - char *resource_uri_path = NULL; - iotcon_resource_types_h resource_types; - char *resource_device_id; - char *resource_host; - char *resource_type; - comp_group_type_e group_type = COMP_GROUP_GROUP_ERROR; - - /* Callback: When no more resource available. - As timeout is configured by IOTCON Library*/ - if (resource == NULL) { - LOG_ERR("No more resource available to find !!"); - return IOTCON_FUNC_CONTINUE; - } - - /* get the resource URI */ - ret = iotcon_remote_resource_get_uri_path(resource, &resource_uri_path); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("Failed to get resource uri path"); - return IOTCON_FUNC_CONTINUE; - } - - - LOG_DEBUG("Resource Found: Resource uri : %s", resource_uri_path); - - /* get the resource device id */ - ret = iotcon_remote_resource_get_device_id(resource, &resource_device_id); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("Failed to get resource device id"); - return IOTCON_FUNC_CONTINUE; - } - LOG_DEBUG("resource device id : %s", resource_device_id); - - /* get the resource host address */ - ret = iotcon_remote_resource_get_host_address(resource, &resource_host); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("Failed to get resource host address"); - return IOTCON_FUNC_CONTINUE; - } - LOG_DEBUG("resource host : %s", resource_host); - - ret = iotcon_remote_resource_get_types(resource, &resource_types); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("Failed to get resource types"); - return IOTCON_FUNC_CONTINUE; - } - - ret = iotcon_resource_types_foreach(resource_types, _get_res_type_cb, - &resource_type); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("Failed to get foreach resource types"); - return IOTCON_FUNC_CONTINUE; - } - - if (strcmp(resource_type, "core.comp.group") == 0) { - comp_context_t *comp_ctx = comp_context_get_context(); - comp_check_null_ret_error("comp_ctx", comp_ctx, IOTCON_FUNC_CONTINUE); - - if (strcmp(resource_device_id, comp_ctx->device_uuid) == 0) - group_type = COMP_GROUP_GROUP_LOCAL; - else - group_type = COMP_GROUP_GROUP_REMOTE; - - char *sp = NULL; - char *temp = strdup(resource_uri_path); - char *ptr = strtok_r(temp, "/", &sp); - ptr = strtok_r(NULL, "/", &sp); - ptr = strtok_r(NULL, "/", &sp); - - LOG_DEBUG("group name is %s", ptr); - comp_group_add_new(resource_uri_path, resource_device_id, - ptr, resource_host, resource_type, group_type); - found_group_count++; - - g_free(resource_type); - if (temp) { - free(temp); - temp = NULL; - } - - return IOTCON_FUNC_CONTINUE; - } else if (strcmp(resource_type, "core.comp.data") == 0) { - comp_command_t *cmd = (comp_command_t *)user_data; - - if (cmd != NULL && strcmp(cmd->uuid, resource_device_id) == 0) { - LOG_DEBUG("Request to Remote Device"); - - iotcon_remote_resource_h resource_clone = NULL; - iotcon_representation_h repr; - iotcon_attributes_h attributes; - - ret = iotcon_remote_resource_clone(resource, &resource_clone); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("iotcon_remote_resource_clone failed = %d", ret); - return IOTCON_FUNC_CONTINUE; - } - - ret = iotcon_representation_create(&repr); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("iotcon_representation_create() Fail(%d)", ret); - return IOTCON_FUNC_CONTINUE; - } - - ret = iotcon_attributes_create(&attributes); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("iotcon_attributes_create() Fail(%d)", ret); - iotcon_representation_destroy(repr); - return IOTCON_FUNC_CONTINUE; - } - - LOG_DEBUG("CMD = %s", command2string(cmd->command)); - - if (cmd->command == COMP_REQ_CREATE_GROUP) { //request create group - iotcon_attributes_add_str(attributes, "CMD", "1"); - iotcon_attributes_add_str(attributes, "name", cmd->arg1); - } else if (cmd->command == COMP_REQ_INVITE_DEVICE) { //request invite - iotcon_attributes_add_str(attributes, "CMD", "2"); - iotcon_attributes_add_str(attributes, "name", cmd->arg1); - iotcon_attributes_add_str(attributes, "id", cmd->arg2); - iotcon_attributes_add_str(attributes, "PIN", cmd->arg3); - } else if (cmd->command == COMP_REQ_EJECT_DEVICE) { //request eject - iotcon_attributes_add_str(attributes, "CMD", "3"); - iotcon_attributes_add_str(attributes, "name", cmd->arg1); - iotcon_attributes_add_str(attributes, "id", cmd->arg2); - } else if (cmd->command == COMP_REQ_DELETE_GROUP) { //request delete group - iotcon_attributes_add_str(attributes, "CMD", "4"); - iotcon_attributes_add_str(attributes, "name", cmd->arg1); - } else { /* Send Data */ - iotcon_attributes_add_str(attributes, "CMD", "5"); -#ifdef SUPPORT_BASE64_ENCODING - uint32_t outSize = 0; - size_t b64BufSize = B64ENCODE_OUT_SAFESIZE((cmd->arg1_len + 1)); - char* b64Buf = g_malloc0(b64BufSize); - if (NULL == b64Buf) { - iotcon_remote_resource_destroy(resource_clone); - _clear_user_data(cmd); - return IOTCON_FUNC_CONTINUE; - } - b64Encode((const char *)cmd->arg1, cmd->arg1_len, b64Buf, - b64BufSize, &outSize); - b64Buf[b64BufSize] = '\0'; - iotcon_attributes_add_str(attributes, "data", b64Buf); - LOG_DEBUG("b64BufSize =%d outSize = %d b64Buf = %s", b64BufSize, - outSize, b64Buf); - g_free(b64Buf); -#else - iotcon_attributes_add_str(attributes, "data", cmd->arg1); -#endif - } - - ret = iotcon_representation_set_attributes(repr, attributes); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("iotcon_representation_set_attributes() Fail(%d)", ret); - iotcon_attributes_destroy(attributes); - iotcon_representation_destroy(repr); - return IOTCON_FUNC_CONTINUE; - } - - iotcon_attributes_destroy(attributes); - - ret = iotcon_remote_resource_post(resource_clone, repr, NULL, - _on_get, NULL); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("iotcon_remote_resource_put() Fail(%d)", ret); - iotcon_remote_resource_destroy(resource_clone); - _clear_user_data(cmd); - return IOTCON_FUNC_CONTINUE; - } - - iotcon_representation_destroy(repr); - } - - } - - return IOTCON_FUNC_CONTINUE; -#endif + return TRUE; } static gboolean _timeout_cb(gpointer data) @@ -1080,46 +689,6 @@ int comp_iot_discovery_resource(comp_resource_type_e resource_type, int timeout, ret = e.code(); } -#if 0 - ret = iotcon_set_timeout(timeout); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("Failed to set timeout value"); - _clear_user_data(user_data); - return COMP_ERROR_OPERATION_FAILED; - } - - ret = iotcon_query_create(&query); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("Failed to create iotcon query"); - _clear_user_data(user_data); - return COMP_ERROR_OPERATION_FAILED; - } - - ret = iotcon_query_set_resource_type(query, - comp_resource_get_type(resource_type)); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("Failed to set iotcon query resource type"); - _clear_user_data(user_data); - return COMP_ERROR_OPERATION_FAILED; - } - - LOG_DEBUG("Set Resource Type : %s", get_error_message(ret)); - - ret = iotcon_set_timeout(timeout); - if (IOTCON_ERROR_NONE != ret) { - LOG_ERR("iotcon_set_timeout: Failed %s", get_error_message(ret)); - } - - if (cmd->command == COMP_REQ_SEND_DATA_ALL) - ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, - IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP, - query, _found_resource, user_data); - else - ret = iotcon_find_resource(cmd->host, - IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP, - query, _found_resource, user_data); -#endif - cmd->resource_type = resource_type; cmd->tid = g_timeout_add_seconds(timeout + 1, _timeout_cb, cmd); diff --git a/src/companion-manager/src/comp_mot_agent.c b/src/companion-manager/src/comp_mot_agent.c index 13ee7ed..5fae8a9 100644 --- a/src/companion-manager/src/comp_mot_agent.c +++ b/src/companion-manager/src/comp_mot_agent.c @@ -296,9 +296,9 @@ int agent_remove_subowned(char* uuid_str) return result; } -int agent_pair(char *pin, char* target1, char *subject1, char *uri1, - char *rt1, char *interface1, int permission1, char* target2, char *subject2, char *uri2, - char *rt2, char *interface2, int permission2) +int agent_pair(const char *pin, char* target1, const char *subject1, char *uri1, + char *rt1, char *interface1, int permission1, const char* target2, + char *subject2, char *uri2, char *rt2, char *interface2, int permission2) { GVariant *variant = NULL; int result = COMP_ERROR_NONE; @@ -326,7 +326,7 @@ int agent_pair(char *pin, char* target1, char *subject1, char *uri1, return result; } -int agent_unpair(char* uuid_str1, char *uuid_str2) +int agent_unpair(char* uuid_str1, const char *uuid_str2) { GVariant *variant = NULL; int result = COMP_ERROR_NONE; diff --git a/src/companion-manager/src/comp_resource.c b/src/companion-manager/src/comp_resource.c index 16724a7..7502b0c 100644 --- a/src/companion-manager/src/comp_resource.c +++ b/src/companion-manager/src/comp_resource.c @@ -20,13 +20,13 @@ /* resource_type, type, uri, policies */ static comp_rd_t comp_rds[] = { {COMP_RESOURCE_TYPE_GROUP, "core.comp.group", "/comp/group/", - IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE}, + OC_DISCOVERABLE | OC_OBSERVABLE}, {COMP_RESOURCE_TYPE_DEVICE, "core.comp.device", "/comp/device/", - IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE}, + OC_DISCOVERABLE | OC_OBSERVABLE}, {COMP_RESOURCE_TYPE_OPERATION, "core.comp.operation", "/comp/operation/", - IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE}, + OC_DISCOVERABLE | OC_OBSERVABLE}, {COMP_RESOURCE_TYPE_DATA, "core.comp.data", "/comp/data/", - IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE | IOTCON_RESOURCE_SECURE}, + OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE}, }; int comp_resource_append(comp_resource_type_e resource_type, const char *uri) @@ -54,7 +54,7 @@ char *comp_resource_get_uri_prefix(comp_resource_type_e resource_type) return comp_rds[resource_type].uri_prefix; } -uint8_t comp_resource_get_policies(comp_resource_type_e resource_type) +unsigned char comp_resource_get_policies(comp_resource_type_e resource_type) { return comp_rds[resource_type].policies; } -- 2.7.4