From: saerome.kim Date: Tue, 10 Apr 2018 04:58:33 +0000 (+0900) Subject: capi: change APIs relevant devices X-Git-Tag: submit/tizen/20190131.065036~55 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=848bf5d92f49c2acf39042018084a5329a61743f;p=platform%2Fcore%2Fapi%2Fmulti-device-group.git capi: change APIs relevant devices -companion_device_get_my_uuid -> copanion_device_information_get_my_uuid -companion_device_get_my_device -> companion_device_informaion_get_my_device -change device_type from char* to enumeration value Signed-off-by: saerome.kim --- diff --git a/capi/demo/comp-manager.c b/capi/demo/comp-manager.c index e67c5a5..1ae75e5 100644 --- a/capi/demo/comp-manager.c +++ b/capi/demo/comp-manager.c @@ -45,6 +45,18 @@ static char message[MENU_DATA_SIZE + 1] = "Hello World!!"; static int run_group_find(MManager *mm, struct menu_data *menu); static int run_devices_find(MManager *mm, struct menu_data *menu); +#define CASE_TO_STR(x) case x: return #x; +static const char* __device_type_to_string(companion_device_type_e type) +{ + switch (type) { + /* CHECK: List all enum values here */ + CASE_TO_STR(COMPANION_DEVICE_TYPE_LOCAL) + CASE_TO_STR(COMPANION_DEVICE_TYPE_REMOTE) + default : + return "COMPANION_DEVICE_TYPE_ERROR"; + } +} + void receive_request_result(char *cmd, char *device_id, char *arg, int ret, void *user_data) { @@ -90,7 +102,7 @@ int run_get_my_id(MManager *mm, struct menu_data *menu) int ret; char *uuid; - ret = companion_device_get_my_uuid(handle, &uuid); + ret = companion_device_information_get_my_uuid(handle, &uuid); if (COMP_ERROR_NONE != ret) { msgr("Failed to Get My Device ID: [%s(0x%X)]", comp_error_to_string(ret), ret); @@ -230,7 +242,7 @@ static int run_devices_show(MManager *mm, struct menu_data *menu) { char *deviceid = NULL; char *ip = NULL; - char *devicetype = NULL; + companion_device_type_e devicetype; companion_device_h device; int ret; int count; @@ -276,10 +288,6 @@ static int run_devices_show(MManager *mm, struct menu_data *menu) free(ip); ip = NULL; } - if (devicetype) { - free(devicetype); - devicetype = NULL; - } /* Next item */ iter = g_list_next(iter); i++; @@ -320,26 +328,26 @@ static int run_group_get_members(MManager *mm, struct menu_data *menu) msgr("Failed to Delete Group: [%s(0x%X)]", comp_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - companion_group_get_member_devices() ret: [0x%X] [%s]", ret, comp_error_to_string(ret)); + msg(" - companion_group_get_member_devices() ret: [0x%X] [%s]", ret, + comp_error_to_string(ret)); for (int i = 0; i < count; i++) { char *device_id = NULL; char *ip = NULL; - char *device_type = NULL; + companion_device_type_e device_type; companion_device_information_get_device_id(devices[i], &device_id); companion_device_information_get_ip(devices[i], &ip); companion_device_information_get_device_type(devices[i], &device_type); - msgp("device_id : %s, name : %s, type : %s", device_id, ip, device_type); + msgp("device_id : %s, name : %s, type : %s", device_id, ip, + __device_type_to_string(device_type)); if (device_id) free(device_id); if (ip) free(ip); - if (device_type) - free(device_type); } return RET_SUCCESS; @@ -448,20 +456,19 @@ int run_device_show_found(MManager *mm, struct menu_data *menu) for (int i = 0; i < count; i++) { char *device_id = NULL; char *ip = NULL; - char *device_type = NULL; + companion_device_type_e device_type; companion_device_information_get_device_id(devices[i], &device_id); companion_device_information_get_ip(devices[i], &ip); companion_device_information_get_device_type(devices[i], &device_type); - msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type); + msgb("\n[ID] %s [IP] %s [Type] %s", device_id, ip, + __device_type_to_string(device_type)); if (device_id) free(device_id); if (ip) free(ip); - if (device_type) - free(device_type); } return RET_SUCCESS; @@ -476,7 +483,7 @@ bool _device_found_cb(companion_device_h device, void *user_data) { char *ip = NULL; char *device_id = NULL; - char *device_type = NULL; + companion_device_type_e device_type; GList *iter = NULL; gboolean is_exist = FALSE; @@ -504,15 +511,14 @@ bool _device_found_cb(companion_device_h device, void *user_data) if (is_exist == FALSE) { found_device_list = g_list_append(found_device_list, device); - msgp("\r[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type); + msgp("\r[ID] %s [IP] %s [TYPE] %s", device_id, ip, + __device_type_to_string(device_type)); } if (device_id) free(device_id); if (ip) free(ip); - if (device_type) - free(device_type); return TRUE; } @@ -548,30 +554,32 @@ int run_device_show_my_device(MManager *mm, struct menu_data *menu) msg("Get My Device"); - ret = companion_device_get_my_device(handle, &device); + ret = companion_device_information_get_my_device(handle, &device); if (COMP_ERROR_NONE != ret) { msgr("Failed to Get My Device: [%s(0x%X)]", comp_error_to_string(ret), ret); return RET_FAILURE; } - msg(" - companion_device_get_my_device() ret: [0x%X] [%s]", ret, comp_error_to_string(ret)); + msg(" - companion_device_information_get_my_device() ret: [0x%X] [%s]", ret, comp_error_to_string(ret)); if (ret == 0) { char *device_id = NULL; char *ip = NULL; - char *device_type = NULL; + companion_device_type_e device_type; companion_device_information_get_device_id(device, &device_id); companion_device_information_get_ip(device, &ip); companion_device_information_get_device_type(device, &device_type); - msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type); + msgb("\n[ID] %s [IP] %s [TYPE] %s", device_id, ip, + __device_type_to_string(device_type)); if (device_id) free(device_id); if (ip) free(ip); - if (device_type) - free(device_type); + + companion_device_information_destroy(device); + device = NULL; } return RET_SUCCESS; @@ -882,20 +890,19 @@ bool _mowned_device_found_cb(companion_device_h device, void *user_data) { char *ip = NULL; char *device_id = NULL; - char *device_type = NULL; + companion_device_type_e device_type; companion_device_information_get_device_id(device, &device_id); companion_device_information_get_ip(device, &ip); companion_device_information_get_device_type(device, &device_type); - msgp("\r[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type); + msgp("\r[ID] %s [IP] %s [TYPE] %s", device_id, ip, + __device_type_to_string(device_type)); if (device_id) free(device_id); if (ip) free(ip); - if (device_type) - free(device_type); my_devices_list = g_list_append(my_devices_list, device); @@ -947,20 +954,19 @@ int run_device_show_mowned_device(MManager *mm, struct menu_data *menu) for (int i = 0; i < count; i++) { char *device_id = NULL; char *ip = NULL; - char *device_type = NULL; + companion_device_type_e device_type; companion_device_information_get_device_id(devices[i], &device_id); companion_device_information_get_ip(devices[i], &ip); companion_device_information_get_device_type(devices[i], &device_type); - msgb("\n[ID] %s [IP] %s [Ver] %s", device_id, ip, device_type); + msgb("\n[ID] %s [IP] %s [TYPE] %s", device_id, ip, + __device_type_to_string(device_type)); if (device_id) free(device_id); if (ip) free(ip); - if (device_type) - free(device_type); } return RET_SUCCESS; @@ -1298,13 +1304,13 @@ static struct menu_data menu_request_delete_group[] = { struct menu_data menu_comp_manager[] = { { "0", "Show My Device ID", NULL, run_get_my_id, NULL }, - { "1", "Create Group", menu_group_create, NULL, NULL }, - { "2", "Find Group(s)", menu_group_find, NULL, NULL }, - { "3", "Show Found Group(s)", NULL, run_group_show_found , NULL }, - { "4", "Join Group (Not yet developed)", menu_group_join, NULL, NULL }, - { "5", "Leave Group (Not yet developed)", menu_group_leave, NULL, NULL }, - { "6", "Delete Group (Not yet developed)", menu_group_delete, NULL, NULL }, - { "7", "Merge Group B to A (Not yet developed)", menu_group_merge, NULL, NULL }, + { "1", "Show My Device", NULL, run_device_show_my_device, NULL }, + { "2", "Create Group", menu_group_create, NULL, NULL }, + { "3", "Find Group(s)", menu_group_find, NULL, NULL }, + { "4", "Show Found Group(s)", NULL, run_group_show_found , NULL }, + { "5", "Join Group (Not yet developed)", menu_group_join, NULL, NULL }, + { "6", "Leave Group (Not yet developed)", menu_group_leave, NULL, NULL }, + { "7", "Delete Group (Not yet developed)", menu_group_delete, NULL, NULL }, { "8", "Find Device(s)", menu_devices_find, NULL, NULL }, { "9", "Show Found Device(s)", NULL, run_device_show_found, NULL }, { "10", "Invite Device", menu_group_invite_device, NULL, NULL }, diff --git a/capi/demo/companion_demo.c b/capi/demo/companion_demo.c index ab76c16..ade3d06 100644 --- a/capi/demo/companion_demo.c +++ b/capi/demo/companion_demo.c @@ -46,6 +46,18 @@ GList *found_device_list; companion_h handle = NULL; +#define CASE_TO_STR(x) case x: return #x; +static const char* __device_type_to_string(companion_device_type_e type) +{ + switch (type) { + /* CHECK: List all enum values here */ + CASE_TO_STR(COMPANION_DEVICE_TYPE_LOCAL) + CASE_TO_STR(COMPANION_DEVICE_TYPE_REMOTE) + default : + return "COMPANION_DEVICE_TYPE_ERROR"; + } +} + static bool test_get_user_int(const char *msg, int *num) { if (msg == NULL || num == NULL) @@ -206,13 +218,14 @@ bool _device_found_cb(companion_device_h device, void *user_data) { char *device_id; char *ip; - char *device_type; + companion_device_type_e device_type; companion_device_information_get_device_id(device, &device_id); companion_device_information_get_ip(device, &ip); companion_device_information_get_device_type(device, &device_type); - TC_PRT("found device device_id : %s, ip : %s, device_type : %s", device_id, ip, device_type); + TC_PRT("found device device_id : %s, ip : %s, device_type : %s", device_id, ip, + __device_type_to_string(device_type)); found_device_list = g_list_append(found_device_list, device); } @@ -264,13 +277,14 @@ int companion_device_get_found_devices_test(void) for (int i = 0; i < count; i++) { char *uuid; char *ip; - char *device_type; + companion_device_type_e device_type; companion_device_information_get_device_id(devices[i], &uuid); companion_device_information_get_ip(devices[i], &ip); companion_device_information_get_device_type(devices[i], &device_type); - TC_PRT("%d. uuid : %s, ip : %s, device_type : %s", i+1, uuid, ip, device_type); + TC_PRT("%d. uuid : %s, ip : %s, device_type : %s", i+1, uuid, ip, + __device_type_to_string(device_type)); found_device_list = g_list_append(found_device_list, devices[i]); } diff --git a/capi/include/companion.h b/capi/include/companion.h index 8ae17f6..2582f79 100644 --- a/capi/include/companion.h +++ b/capi/include/companion.h @@ -72,27 +72,17 @@ typedef enum { } comp_error_e; /** - * @brief Group type. - * - * @since_tizen 5.0 - */ -typedef enum { - COMPANION_GROUP_TYPE_ERROR = 0, /**< Error */ - COMPANION_GROUP_TYPE_MINE = 1, /**< Local type */ - COMPANION_GROUP_TYPE_REMOTE = 2, /**< Remote type */ -} companion_group_type_e; - -/** * @addtogroup CAPI_NETWORK_COMPANION_DEVICE_MODULE * @{ */ /** - * @brief Group handle which represents a companion group. + * @brief Device handle. * * @since_tizen 5.0 */ typedef void *companion_device_h; /**< Device handle */ + /** * @} */ @@ -103,11 +93,12 @@ typedef void *companion_device_h; /**< Device handle */ */ /** - * @brief Device hande which represents a companion device. + * @brief Group hande. * * @since_tizen 5.0 */ typedef void *companion_group_h; /**< Group handle */ + /** * @} */ @@ -147,29 +138,6 @@ int companion_initialize(companion_h *handle); int companion_deinitialize(companion_h handle); /** - * @brief Gets my local device ID. - * @details This function returns current UUID of local device. - * - * @since_tizen 5.0 - * @privlevel public - * @privilege %http://tizen.org/privilege/internet - * - * @remarks The @a uuid should not be released. - * @remarks The @a uuid can be used only in the callback. To use outside, make a copy. - * - * @param[in] handle The companion manager handle - * @param[out] uuid Local device UUID - * - * @return 0 on success, otherwise a negative error value. - * @retval #COMP_ERROR_NONE Successful - * @retval #COMP_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see companion_device_get_my_device() - * - */ -int companion_device_get_my_uuid(companion_h handle, char **uuid); - -/** * @} */ @@ -180,6 +148,17 @@ int companion_device_get_my_uuid(companion_h handle, char **uuid); */ /** + * @brief Group type. + * + * @since_tizen 5.0 + */ +typedef enum { + COMPANION_GROUP_TYPE_ERROR = 0, /**< Error */ + COMPANION_GROUP_TYPE_MINE = 1, /**< Local group */ + COMPANION_GROUP_TYPE_REMOTE = 2, /**< Remote grojp */ +} companion_group_type_e; + +/** * @brief Called after companion_group_find(). * @details This function can receive a group resource found. * @@ -277,7 +256,6 @@ int companion_group_get_found_groups(companion_h handle, * @{ */ - /** * @brief Creates a group. * @details This function is to allocate new group in local companion-manager. @@ -325,33 +303,6 @@ int companion_group_create(companion_h handle, char *group_name); int companion_group_delete(companion_h handle, companion_group_h group); /** - * @brief Combines both groups to one. - * @details This function combines two groups into one. - * - * @since_tizen 5.0 - * @privlevel public - * @privilege %http://tizen.org/privilege/internet - * - * @param[in] handle The companion manager handle - * @param[in] dest_group Group handle to be united - * @param[in] src_group Group handle to be merged - * - * - * @return 0 on success, otherwise a negative error value. - * @retval #COMP_ERROR_NONE Successful - * @retval #COMP_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see companion_group_create() - * @see companion_request_join_group() - * @see companion_request_leave_group () - * @see companion_group_delete() - * @see companion_group_get_member_devices() - * - */ -int companion_group_merge(companion_h handle, companion_group_h dest_group, - companion_group_h src_group); - -/** * @brief Gets devices list in a group resource. * @details This function retrieves a devices list of group resources. * @@ -359,7 +310,7 @@ int companion_group_merge(companion_h handle, companion_group_h dest_group, * @privlevel public * @privilege %http://tizen.org/privilege/internet * - * @remarks The @a devices should be released using companion_device_destroy(). + * @remarks The @a devices should be released using companion_device_information_destroy(). * * @param[in] handle The companion manager handle * @param[in] group Group resource list @@ -886,6 +837,16 @@ int companion_group_information_get_host_addr(companion_group_h group, * @{ */ +/** + * @brief Device type. + * + * @since_tizen 5.0 + */ +typedef enum { + COMPANION_DEVICE_TYPE_ERROR = 0, /**< Error */ + COMPANION_DEVICE_TYPE_LOCAL = 1, /**< Local device */ + COMPANION_DEVICE_TYPE_REMOTE = 2, /**< Remote device */ +} companion_device_type_e; /** * @brief Called after companion_device_find(). @@ -1048,29 +1009,6 @@ int companion_device_find_mowned_device(companion_h handle, int timeout, int companion_device_get_found_mowned_devices(companion_h handle, companion_device_h **devices, int *count); - -/** - * @brief Gets my local device handle. - * @details This function returns the local device information handle. - * - * @since_tizen 5.0 - * @privlevel public - * @privilege %http://tizen.org/privilege/internet - * - * @param[in] handle The companion manager handle - * @param[in] device Local device handle - * - * @return 0 on success, otherwise a negative error value. - * @retval #COMP_ERROR_NONE Successful - * @retval #COMP_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #COMP_ERROR_NO_DATA No data - * - * @see companion_device_get_my_uuid() - * - */ -int companion_device_get_my_device(companion_h handle, - companion_device_h *device); - /** * @brief Sends data to the remote device. * @details We can send data to devices included in group. @@ -1110,6 +1048,49 @@ int companion_device_send_data(companion_h handle, companion_device_h device, ch * @{ */ +/** + * @brief Gets my local device ID. + * @details This function returns current UUID of local device. + * + * @since_tizen 5.0 + * + * @remarks The @a uuid should not be released. + * @remarks The @a uuid can be used only in the callback. To use outside, make a copy. + * + * @param[in] handle The companion manager handle + * @param[out] uuid Local device UUID + * + * @return 0 on success, otherwise a negative error value. + * @retval #COMP_ERROR_NONE Successful + * @retval #COMP_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see companion_device_information_get_my_device() + * + */ + +int companion_device_information_get_my_uuid(companion_h handle, char **uuid); + +/** + * @brief Gets my local device handle. + * @details This function returns the local device information handle. + * + * @since_tizen 5.0 + * + * @remarks The @a target should be released using companion_device_information_destroy(). + * + * @param[in] handle The companion manager handle + * @param[in] device Local device handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #COMP_ERROR_NONE Successful + * @retval #COMP_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #COMP_ERROR_NO_DATA No data + * + * @see companion_device_information_get_my_uuid() + * + */ +int companion_device_information_get_my_device(companion_h handle, + companion_device_h *device); /** * @brief Clones the device handle. @@ -1224,7 +1205,7 @@ int companion_device_information_get_ip(companion_device_h device, char **ip); * */ int companion_device_information_get_device_type(companion_device_h device, - char **device_type); + companion_device_type_e *device_type); /** * @} diff --git a/capi/include/companion_internal.h b/capi/include/companion_internal.h index e970fe8..05b0e93 100644 --- a/capi/include/companion_internal.h +++ b/capi/include/companion_internal.h @@ -73,6 +73,34 @@ int companion_group_information_create(companion_group_h* group); int companion_device_information_create(companion_device_h* device); /** + * @brief Combines both groups to one. + * @details This function combines two groups into one. + * + * @since_tizen 5.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/internet + * + * @param[in] handle The companion manager handle + * @param[in] dest_group Group handle to be united + * @param[in] src_group Group handle to be merged + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #COMP_ERROR_NONE Successful + * @retval #COMP_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see companion_group_create() + * @see companion_request_join_group() + * @see companion_request_leave_group () + * @see companion_group_delete() + * @see companion_group_get_member_devices() + * + */ +int companion_group_merge(companion_h handle, companion_group_h dest_group, + companion_group_h src_group); + + +/** * @brief Registers request result callback funtion. * @details This function registers the callback function for requested group management * functions and receive processing results after the request complete. diff --git a/capi/src/companion.c b/capi/src/companion.c index e368e60..4e320a6 100644 --- a/capi/src/companion.c +++ b/capi/src/companion.c @@ -372,7 +372,7 @@ EXPORT_API int companion_device_get_found_devices(companion_h handle, while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { char *deviceid = NULL; char *addr = NULL; - char *ver = NULL; + int device_type = 0; int port; int sec_port; companion_device_s *device = NULL; @@ -382,8 +382,10 @@ EXPORT_API int companion_device_get_found_devices(companion_h handle, deviceid = (char *)g_variant_get_string(key_value, NULL); else if (g_strcmp0(key, "Address") == 0) addr = (char *)g_variant_get_string(key_value, NULL); +/* else if (g_strcmp0(key, "SecVer") == 0) ver = (char *)g_variant_get_string(key_value, NULL); +*/ else if (g_strcmp0(key, "Port") == 0) port = g_variant_get_uint16(key_value); else if (g_strcmp0(key, "SecurePort") == 0) @@ -391,7 +393,7 @@ EXPORT_API int companion_device_get_found_devices(companion_h handle, } g_variant_iter_free(iter_row); - device = create_device_handle(deviceid, addr, ver, port, sec_port); + device = create_device_handle(deviceid, addr, device_type, port, sec_port); (*devices)[i++] = (companion_device_h)device; } @@ -436,7 +438,7 @@ EXPORT_API int companion_device_get_found_mowned_devices( while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { char *deviceid = NULL; char *addr = NULL; - char *ver = NULL; + int device_type = 0; int port; int sec_port; companion_device_s *device = NULL; @@ -446,8 +448,10 @@ EXPORT_API int companion_device_get_found_mowned_devices( deviceid = (char *)g_variant_get_string(key_value, NULL); else if (g_strcmp0(key, "Address") == 0) addr = (char *)g_variant_get_string(key_value, NULL); +/* else if (g_strcmp0(key, "SecVer") == 0) ver = (char *)g_variant_get_string(key_value, NULL); +*/ else if (g_strcmp0(key, "Port") == 0) port = g_variant_get_uint16(key_value); else if (g_strcmp0(key, "SecurePort") == 0) @@ -455,7 +459,7 @@ EXPORT_API int companion_device_get_found_mowned_devices( } g_variant_iter_free(iter_row); - device = create_device_handle(deviceid, addr, ver, port, sec_port); + device = create_device_handle(deviceid, addr, device_type, port, sec_port); (*devices)[i++] = (companion_device_h)device; } @@ -467,7 +471,22 @@ EXPORT_API int companion_device_get_found_mowned_devices( return ret; } -EXPORT_API int companion_device_get_my_device(companion_h handle, +EXPORT_API int companion_device_information_get_my_uuid(companion_h handle, char **uuid) +{ + int ret = 0; + GError *error = NULL; + + CHECK_FEATURE_SUPPORTED(COMPANION_FEATURE); + + comp_manager_s *_handle = handle; + companion_check_null_ret_error("handle", handle, COMP_ERROR_INVALID_PARAMETER); + + group_call_get_my_uuid_sync(_handle->group_proxy, uuid, NULL, &error); + + return ret; +} + +EXPORT_API int companion_device_information_get_my_device(companion_h handle, companion_device_h *device) { int ret = COMP_ERROR_NONE; @@ -478,7 +497,7 @@ EXPORT_API int companion_device_get_my_device(companion_h handle, GVariant *key_value = NULL; char *deviceid = NULL; char *addr = NULL; - char *ver = NULL; + int device_type = 0; int port = -1; int sec_port = -1; @@ -496,19 +515,21 @@ EXPORT_API int companion_device_get_my_device(companion_h handle, deviceid = (char *)g_variant_get_string(key_value, NULL); else if (g_strcmp0(key, "Address") == 0) addr = (char *)g_variant_get_string(key_value, NULL); +/* else if (g_strcmp0(key, "SecVer") == 0) ver = (char *)g_variant_get_string(key_value, NULL); +*/ else if (g_strcmp0(key, "Port") == 0) port = g_variant_get_uint16(key_value); else if (g_strcmp0(key, "SecurePort") == 0) sec_port = g_variant_get_uint16(key_value); } - if (deviceid == NULL || addr == NULL || ver == NULL) + if (deviceid == NULL || addr == NULL) return COMP_ERROR_NO_DATA; /* LCOV_EXCL_STOP */ - *device = (companion_device_h)create_device_handle(deviceid, addr, ver, + *device = (companion_device_h)create_device_handle(deviceid, addr, device_type, port, sec_port); g_variant_iter_free(iter); @@ -516,44 +537,6 @@ EXPORT_API int companion_device_get_my_device(companion_h handle, return ret; } -EXPORT_API void companion_device_destroy(companion_device_h device) -{ - CHECK_FEATURE_SUPPORTED(COMPANION_FEATURE); - - companion_device_s *_device = device; - companion_check_null_ret("device", device); - - if (_device->device_id) { - g_free(_device->device_id); - _device->device_id = NULL; - } - if (_device->ip) { - g_free(_device->ip); - _device->ip = NULL; - } - if (_device->device_type) { - g_free(_device->device_type); - _device->device_type = NULL; - } - g_free(_device); - _device = NULL; -} - -EXPORT_API int companion_device_get_my_uuid(companion_h handle, char **uuid) -{ - int ret = 0; - GError *error = NULL; - - CHECK_FEATURE_SUPPORTED(COMPANION_FEATURE); - - comp_manager_s *_handle = handle; - companion_check_null_ret_error("handle", handle, COMP_ERROR_INVALID_PARAMETER); - - group_call_get_my_uuid_sync(_handle->group_proxy, uuid, NULL, &error); - - return ret; -} - /* group merge */ EXPORT_API int companion_group_merge(companion_h hadnle, companion_group_h dest_group, companion_group_h src_group) @@ -843,7 +826,7 @@ EXPORT_API int companion_device_information_clone(companion_device_h target, if (src->ip) dst->ip = g_strdup(src->ip); if (src->device_type) - dst->device_type = g_strdup(src->device_type); + dst->device_type = src->device_type; return ret; } @@ -865,10 +848,6 @@ EXPORT_API int companion_device_information_destroy(companion_device_h data) g_free(device->ip); device->ip = NULL; } - if (device->device_type) { - g_free(device->device_type); - device->device_type = NULL; - } g_free(device); device = NULL; @@ -901,13 +880,13 @@ EXPORT_API int companion_device_information_get_ip( } EXPORT_API int companion_device_information_get_device_type( - companion_device_h device, char **device_type) + companion_device_h device, companion_device_type_e *device_type) { int ret = COMP_ERROR_NONE; CHECK_FEATURE_SUPPORTED(COMPANION_FEATURE); - *device_type = g_strdup(((companion_device_s *)device)->device_type); + *device_type = ((companion_device_s *)device)->device_type; return ret; } diff --git a/capi/src/companion_dbus.c b/capi/src/companion_dbus.c index 520792a..c33e6d1 100644 --- a/capi/src/companion_dbus.c +++ b/capi/src/companion_dbus.c @@ -106,7 +106,7 @@ static void __device_found_cb(Group *object, gint count, GVariant *va, while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { char *device_id = NULL; char *ip = NULL; - char *device_type = NULL; + int device_type = 0; int port = -1; int sec_port = -1; @@ -115,8 +115,10 @@ static void __device_found_cb(Group *object, gint count, GVariant *va, device_id = (char *)g_variant_get_string(key_value, NULL); else if (g_strcmp0(key, "Address") == 0) ip = (char *)g_variant_get_string(key_value, NULL); +/* else if (g_strcmp0(key, "SecVer") == 0) device_type = (char *)g_variant_get_string(key_value, NULL); +*/ else if (g_strcmp0(key, "Port") == 0) port = g_variant_get_uint16(key_value); else if (g_strcmp0(key, "SecurePort") == 0) @@ -162,7 +164,7 @@ static void __mowned_device_found_cb(Group *object, gint count, GVariant *va, while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { char *device_id = NULL; char *ip = NULL; - char *device_type = NULL; + int device_type = 0; int port = -1; int sec_port = -1; @@ -171,8 +173,10 @@ static void __mowned_device_found_cb(Group *object, gint count, GVariant *va, device_id = (char *)g_variant_get_string(key_value, NULL); else if (g_strcmp0(key, "Address") == 0) ip = (char *)g_variant_get_string(key_value, NULL); +/* else if (g_strcmp0(key, "SecVer") == 0) device_type = (char *)g_variant_get_string(key_value, NULL); +*/ else if (g_strcmp0(key, "Port") == 0) port = g_variant_get_uint16(key_value); else if (g_strcmp0(key, "SecurePort") == 0) diff --git a/capi/src/companion_private.h b/capi/src/companion_private.h index 37e2047..9046704 100644 --- a/capi/src/companion_private.h +++ b/capi/src/companion_private.h @@ -186,7 +186,7 @@ typedef struct _companion_group_s { typedef struct _companion_device_s { char *device_id; /**< Device ID */ char *ip; /**< Device IP */ - char *device_type; /**< Device Type */ + int device_type; /**< Device Type */ int port; /**< Port Number */ int sec_port; /**< Secure Port Number */ } companion_device_s; diff --git a/capi/src/companion_util.c b/capi/src/companion_util.c index 01fe0a5..2866fd2 100644 --- a/capi/src/companion_util.c +++ b/capi/src/companion_util.c @@ -78,7 +78,7 @@ CREATE_GROUP_HANDLER_ERROR: } companion_device_s *create_device_handle(char *device_id, char *ip, - char *device_type, int port, int sec_port) + int device_type, int port, int sec_port) { companion_device_s *device = calloc(1, sizeof(companion_device_s)); if (NULL == device) { @@ -90,7 +90,7 @@ companion_device_s *create_device_handle(char *device_id, char *ip, device->device_id = g_strdup(device_id); device->ip = g_strdup(ip); - device->device_type = g_strdup(device_type); + device->device_type = device_type; device->port = port; device->sec_port = sec_port; @@ -114,10 +114,6 @@ CREATE_DEVICE_HANDLER_ERROR: free(device->ip); device->ip = NULL; } - if (device->device_type) { - free(device->device_type); - device->device_type = NULL; - } free(device); device = NULL; } diff --git a/capi/src/companion_util.h b/capi/src/companion_util.h index 1cd4174..dfcf4a3 100644 --- a/capi/src/companion_util.h +++ b/capi/src/companion_util.h @@ -27,8 +27,8 @@ extern "C" companion_group_s *create_group_handle(char *uri_path, char *device_id, char *group_name, char *host_addr, char *resource_type, companion_group_type_e type); -companion_device_s *create_device_handle(char *device_id, char *ip, - char *device_type, int port, int sec_port); +companion_device_s *create_device_handle(char *device_id, char *ip, int device_type, + int port, int sec_port); #ifdef __cplusplus }