iter = g_list_first(found_device_list);
while (NULL != iter) {
device = iter->data;
- if (device) {
+ if (!device) {
msgr("device list is null");
break;
}
companion_device_information_get_device_id(device, &deviceid);
companion_device_information_get_friendly_name(device, &name);
companion_device_information_get_device_type(device, &devicetype);
- msgb("[%d] type:%s, name: %s type: %s", i+1, deviceid, name, devicetype);
+ msgb("[%d] deviceid: %s, name: %s type: %s", i+1, deviceid, name, devicetype);
if (deviceid) {
free(deviceid);
return TRUE;
}
+
static int run_devices_find(MManager *mm, struct menu_data *menu)
{
int ret;
msg(" - companion_device_find() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
if (found_device_list) {
- g_list_free(found_device_list);
+ g_list_free_full(found_device_list, companion_device_information_destroy);
found_device_list = NULL;
}
iter = g_list_first(found_group_list);
while (NULL != iter) {
group = iter->data;
- if (group) {
+ if (!group) {
msgr("groups is null");
break;
}
companion_group_information_get_type(group, &type);
companion_group_information_get_uri_path(group, &uri);
companion_group_information_get_resource_type(group, &rt);
- msgb("[%d] type:%s, URI: %s RT: %s", i+1, comp_group_type_to_string(type), uri, rt);
+ msgb("[%d] type: %s, URI: %s RT: %s", i+1, comp_group_type_to_string(type), uri, rt);
if (uri) {
free(uri);
uri = NULL;
msg(" - companion_group_find() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
if (found_group_list) {
- g_list_free(found_group_list);
+ g_list_free_full(found_group_list, companion_group_information_destroy);
found_group_list = NULL;
}
companion_device_h device, companion_device_eject_result_cb callback, void *user_data);
/* Group Information Module */
+int companion_group_information_create(companion_group_h* group);
+int companion_group_information_clone(companion_group_h dst,
+ companion_group_h src);
+int companion_group_information_destroy(companion_group_h group);
+
int companion_group_information_get_type(companion_group_h group, companion_group_type_e *type);
int companion_group_information_get_resource_type(companion_group_h group, char **resource_type);
int companion_group_information_get_uri_path(companion_group_h group, char **uri_path);
/* Group Device Information Module */
/* I think the information in the group device is the same as the "device informations" */
+int companion_device_information_create(companion_device_h* device);
+int companion_device_information_clone(companion_device_h target,
+ companion_device_h source);
+int companion_device_information_destroy(companion_device_h data);
int companion_device_information_get_device_id(companion_device_h device, char **device_id);
int companion_device_information_get_friendly_name(companion_device_h device, char **friendly_name);
int companion_device_information_get_device_type(companion_device_h device, char **device_type);
} else if (g_strcmp0(key, "FriendlyName") == 0) {
friendly_name = (char *)g_variant_get_string(key_value, NULL);
} else if (g_strcmp0(key, "DeviceType") == 0) {
- device_type = g_variant_get_string(key_value, NULL);
+ device_type = (char *)g_variant_get_string(key_value, NULL);
}
}
g_variant_iter_free(iter_row);
int companion_group_create(char *group_name)
{
int ret = 0;
- companion_group_t *group;
GError *error = NULL;
/* create group to daemon using gdbus */
int companion_group_get_found_groups(companion_group_h **groups, int *count)
{
int ret = 0;
- bool result = false;
GVariant *va = NULL;
GError *error = NULL;
return ret;
}
+int companion_group_information_create(companion_group_h* group)
+{
+ companion_group_h _group = g_malloc0(sizeof(companion_group_t));
+ *group = _group;
+
+ return 0;
+}
+
+int companion_group_information_clone(companion_group_h target,
+ companion_group_h source)
+{
+ companion_group_t * dst = (companion_group_t *)target;
+ companion_group_t * src = (companion_group_t *)source;
+
+ if (!dst || !src) {
+ _ERR("Invaild parameters: dst=%p src=%p", dst, src);
+ return -1;
+ }
+
+ if (src->uri_path) {
+ dst->uri_path = g_strdup(src->uri_path);
+ }
+ if (src->device_id) {
+ dst->device_id = g_strdup(src->device_id);
+ }
+ if (src->group_name) {
+ dst->group_name = g_strdup(src->group_name);
+ }
+ if (src->host_addr) {
+ dst->host_addr = g_strdup(src->host_addr);
+ }
+ if (src->resource_type) {
+ dst->resource_type = g_strdup(src->resource_type);
+ }
+ dst->type = src->type;
+
+ return 0;
+}
+
+int companion_group_information_destroy(companion_group_h data)
+{
+ companion_group_t * group = (companion_group_t *)data;
+
+ if (!group)
+ return -1;
+
+ if (group->uri_path) {
+ g_free(group->uri_path);
+ group->uri_path = NULL;
+ }
+ if (group->device_id) {
+ g_free(group->device_id);
+ group->device_id = NULL;
+ }
+ if (group->group_name) {
+ g_free(group->group_name);
+ group->group_name = NULL;
+ }
+ if (group->host_addr) {
+ g_free((companion_group_t *)group->host_addr);
+ group->host_addr = NULL;
+ }
+ if (group->resource_type) {
+ g_free((companion_group_t *)group->resource_type);
+ group->resource_type = NULL;
+ }
+ g_free(group);
+ group = NULL;
+
+ return 0;
+}
+
int companion_group_information_get_type(companion_group_h group, companion_group_type_e *type)
{
*type = ((companion_group_t *)group)->type;
return 0;
}
+int companion_device_information_create(companion_device_h* device)
+{
+ companion_device_h _device = g_malloc0(sizeof(companion_device_t));
+ *device = _device;
+
+ return 0;
+}
+
+int companion_device_information_clone(companion_device_h target,
+ companion_device_h source)
+{
+ companion_device_t * dst = (companion_device_t *)target;
+ companion_device_t * src = (companion_device_t *)source;
+
+ if (!dst || !src) {
+ _ERR("Invaild parameters: dst=%p src=%p", dst, src);
+ return -1;
+ }
+
+ if (src->device_id) {
+ dst->device_id = g_strdup(src->device_id);
+ }
+ if (src->friendly_name) {
+ dst->friendly_name = g_strdup(src->friendly_name);
+ }
+ if (src->device_type) {
+ dst->device_type = g_strdup(src->device_type);
+ }
+
+ return 0;
+}
+
+int companion_device_information_destroy(companion_device_h data)
+{
+ companion_device_t * device = (companion_device_t *)data;
+
+ if (!device) {
+ _ERR("Invaild parameters: device=%p", device);
+ return -1;
+ }
+
+ if (device->device_id) {
+ g_free(device->device_id);
+ device->device_id = NULL;
+ }
+ if (device->friendly_name) {
+ g_free(device->friendly_name);
+ device->friendly_name = NULL;
+ }
+ if (device->device_type) {
+ g_free(device->device_type);
+ device->device_type = NULL;
+ }
+
+ g_free(device);
+ device = NULL;
+
+ return 0;
+}
+
int companion_device_information_get_device_id(companion_device_h device, char **device_id)
{
*device_id = g_strdup(((companion_device_t *)device)->device_id);