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)
{
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);
{
char *deviceid = NULL;
char *ip = NULL;
- char *devicetype = NULL;
+ companion_device_type_e devicetype;
companion_device_h device;
int ret;
int count;
free(ip);
ip = NULL;
}
- if (devicetype) {
- free(devicetype);
- devicetype = NULL;
- }
/* Next item */
iter = g_list_next(iter);
i++;
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;
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;
{
char *ip = NULL;
char *device_id = NULL;
- char *device_type = NULL;
+ companion_device_type_e device_type;
GList *iter = NULL;
gboolean is_exist = FALSE;
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;
}
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;
{
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);
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;
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 },
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)
{
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);
}
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]);
}
} 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 */
+
/**
* @}
*/
*/
/**
- * @brief Device hande which represents a companion device.
+ * @brief Group hande.
*
* @since_tizen 5.0
*/
typedef void *companion_group_h; /**< Group 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);
-
-/**
* @}
*/
*/
/**
+ * @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.
*
* @{
*/
-
/**
* @brief Creates a group.
* @details This function is to allocate new group in local companion-manager.
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.
*
* @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
* @{
*/
+/**
+ * @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().
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.
* @{
*/
+/**
+ * @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.
*
*/
int companion_device_information_get_device_type(companion_device_h device,
- char **device_type);
+ companion_device_type_e *device_type);
/**
* @}
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.
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;
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)
}
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;
}
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;
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)
}
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;
}
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;
GVariant *key_value = NULL;
char *deviceid = NULL;
char *addr = NULL;
- char *ver = NULL;
+ int device_type = 0;
int port = -1;
int sec_port = -1;
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);
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)
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;
}
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_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;
}
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;
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)
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;
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)
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;
}
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) {
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;
free(device->ip);
device->ip = NULL;
}
- if (device->device_type) {
- free(device->device_type);
- device->device_type = NULL;
- }
free(device);
device = NULL;
}
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
}