return RET_SUCCESS;
}
-void _device_finish_cb(int result, void *user_data)
+int run_device_get_found(MManager *mm, struct menu_data *menu)
{
- msgb("Find Devices Finished [%s]", comp_error_to_string(result) );
+ int ret;
+ int count;
+ companion_device_h *devices = NULL;
+
+ msg("");
+
+ ret = companion_device_get_found_devices(&devices, &count);
+ if (COMP_ERROR_NONE != ret) {
+ msgr("Failed to Get Found Devices: [%s(0x%X)]", comp_error_to_string(ret), ret);
+ return RET_FAILURE;
+ }
+ msg(" - companion_device_get_found_devices() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+
+ for (int i = 0; i < count; i++) {
+ char *device_id = NULL;
+ char *friendly_name = NULL;
+ char *device_type = NULL;
+
+ companion_device_information_get_device_id(devices[i], &device_id);
+ companion_device_information_get_friendly_name(devices[i], &friendly_name);
+ companion_device_information_get_device_type(devices[i], &device_type);
+
+ msgb("\n[deviceiid] %s [address] %s [ver] %s", device_id, friendly_name, device_type);
+
+ if (device_id)
+ free(device_id);
+ if (friendly_name)
+ free(friendly_name);
+ if (device_type)
+ free(device_type);
+
+ found_device_list = g_list_prepend(found_device_list, devices[i]);
+ }
+
+ return RET_SUCCESS;
+}
+
+void _device_finish_cb(int num_of_devs, void *user_data)
+{
+ msgb("%d Device(s) Found", num_of_devs);
}
bool _device_found_cb(companion_device_h device, void *user_data)
companion_device_information_get_friendly_name(device, &friendly_name);
companion_device_information_get_device_type(device, &device_type);
- msg("");
- msgb("device_id : %s, name : %s, type : %s", device_id, friendly_name, device_type);
+ msgb("\n[deviceiid] %s [address] %s [ver] %s", device_id, friendly_name, device_type);
if (device_id)
free(device_id);
found_device_list = NULL;
}
- msg("");
-
return RET_SUCCESS;
}
void _group_finish_cb(int result, void *user_data)
{
- msgb("find operation finished");
+ msgb("Find Group Finished = %d", result);
}
static void _destroy_comp_group_info(gpointer data)
companion_group_information_destroy((companion_group_h)data);
}
-
static int run_group_find(MManager *mm, struct menu_data *menu)
{
int ret;
{ NULL, NULL, },
};
-static struct menu_data menu_devices_find[] = {
- { "0", "Timeout", NULL, NULL, timeout },
- { "2", "Run", NULL, run_devices_find, NULL },
- { NULL, NULL, },
-};
-
static struct menu_data menu_group_delete[] = {
{ "0", "Show Found Group(s)", NULL, run_group_show, NULL },
{ "1", "Index", NULL, NULL, group_idx },
static struct menu_data menu_group_merge[] = {
{ "0", "Show Found Group(s)", NULL, run_group_show, NULL },
{ "1", "A Index", NULL, NULL, group_idx_a },
- { "1", "B Index", NULL, NULL, group_idx_b },
- { "2", "Run", NULL, run_group_merge, NULL },
+ { "2", "B Index", NULL, NULL, group_idx_b },
+ { "3", "Run", NULL, run_group_merge, NULL },
{ NULL, NULL, },
};
{ NULL, NULL, },
};
+static struct menu_data menu_devices_find[] = {
+ { "0", "Timeout", NULL, NULL, timeout },
+ { "1", "Run", NULL, run_devices_find, NULL },
+ { NULL, NULL, },
+};
+
static struct menu_data menu_group_invite_device[] = {
{ "0", "Show Found Device(s)", NULL, run_devices_show, NULL },
{ "1", "Index", NULL, NULL, group_idx },
{ "7", "Merge Group B to A", menu_group_merge, NULL, NULL },
{ "8", "Get Group Member Devices", menu_group_get_members, NULL, NULL },
{ "9", "Find Devices", menu_devices_find, NULL, NULL },
- { "10", "Invite Device", menu_group_invite_device, NULL, NULL },
- { "11", "Eject Device", menu_group_eject_device, NULL, NULL },
+ { "10", "Get Found Devices", NULL, run_device_get_found, NULL },
+ { "11", "Invite Device", menu_group_invite_device, NULL, NULL },
+ { "12", "Eject Device", menu_group_eject_device, NULL, NULL },
{ NULL, NULL, },
};
while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) {
if (g_strcmp0(key, "DeviceID") == 0) {
device_id = (char *)g_variant_get_string(key_value, NULL);
- } else if (g_strcmp0(key, "FriendlyName") == 0) {
+ } else if (g_strcmp0(key, "Address") == 0) {
friendly_name = (char *)g_variant_get_string(key_value, NULL);
- } else if (g_strcmp0(key, "DeviceType") == 0) {
+ } else if (g_strcmp0(key, "SecVer") == 0) {
device_type = (char *)g_variant_get_string(key_value, NULL);
}
}
/* companion_group_join : join to remote group. if group handle is my daemon's, then the api return fail error */
int companion_device_get_found_devices(companion_device_h **devices, int *count)
{
- return 0;
+ int ret = 0;
+ int num = 0;
+ GVariant *va = NULL;
+ GError *error = NULL;
+
+ /* get groups from daemon using gdbus */
+ group_call_get_remote_device_sync(group_proxy, &num, &va, NULL, &error);
+ /* *count = g_variant_n_children(va); */
+ *count = num;
+
+ _ERR("get found devices : %d", *count);
+
+ if (*count > 0) {
+ GVariantIter *iter = NULL, *iter_row = NULL;
+ GVariant *key_value;
+ const gchar *key;
+ guint i = 0;
+
+ *devices = g_new0(companion_group_h, *count);
+
+ g_variant_get(va, "aa{sv}", &iter);
+ while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
+ char *deviceid = NULL;
+ char *addr = NULL;
+ char *ver = NULL;
+ companion_device_t *device = NULL;
+
+ while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) {
+ if (g_strcmp0(key, "DeviceID") == 0) {
+ 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);
+ }
+ }
+ g_variant_iter_free(iter_row);
+
+ device = _create_device_handle(deviceid, addr, ver);
+
+ (*devices)[i++] = (companion_device_h)device;
+ }
+ g_variant_iter_free(iter);
+ }
+ g_variant_unref(va);
+
+ return ret;
}
/* group merge */