return RET_SUCCESS;
}
-int run_device_get_found(MManager *mm, struct menu_data *menu)
+int run_device_show_found(MManager *mm, struct menu_data *menu)
{
int ret;
int count;
return RET_SUCCESS;
}
-int run_device_get_my_device(MManager *mm, struct menu_data *menu)
+int run_device_show_my_device(MManager *mm, struct menu_data *menu)
{
int ret = 0;
companion_device_h device = NULL;
return RET_SUCCESS;
}
-
bool _device_found_mine_cb(companion_device_h device, void *user_data)
{
char *device_id = NULL;
return RET_SUCCESS;
}
+void _mowned_device_finish_cb(int num_of_devs, void *user_data)
+{
+ msgp("%d Device(s) Found", num_of_devs);
+}
+
+bool _mowned_device_found_cb(companion_device_h device, void *user_data)
+{
+ char *device_id = NULL;
+ char *friendly_name = NULL;
+ char *device_type = NULL;
+
+ companion_device_information_get_device_id(device, &device_id);
+ companion_device_information_get_friendly_name(device, &friendly_name);
+ companion_device_information_get_device_type(device, &device_type);
+
+ msgb("\n[ID] %s [IP] %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);
+
+ my_devices_list = g_list_prepend(my_devices_list, device);
+
+ return TRUE;
+}
+
+
+static int run_devices_find_mowned_device(MManager *mm, struct menu_data *menu)
+{
+ int ret;
+
+ msg("Find My Owned Devices");
+
+ ret = companion_device_find_mowned_device(_mowned_device_found_cb, _mowned_device_finish_cb, NULL);
+ if (COMP_ERROR_NONE != ret) {
+ msgr("Failed to Find My Owned Devices: [%s(0x%X)]", comp_error_to_string(ret), ret);
+ return RET_FAILURE;
+ }
+ msg(" - companion_device_find_mowned_device() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+
+ if (my_devices_list) {
+ g_list_free_full(my_devices_list, _destroy_comp_device_info);
+ my_devices_list = NULL;
+ }
+
+ return RET_SUCCESS;
+}
+
+int run_device_show_mowned_device(MManager *mm, struct menu_data *menu)
+{
+ 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[ID] %s [IP] %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);
+ }
+
+ return RET_SUCCESS;
+}
+
+
static struct menu_data menu_group_create[] = {
{ "0", "Group Name", NULL, NULL, groupid },
{ "1", "Run", NULL, run_group_create, NULL },
{ NULL, NULL, },
};
+static struct menu_data menu_devices_find_mownd_device[] = {
+ { "0", "Timeout", NULL, NULL, timeout },
+ { "1", "Run", NULL, run_devices_find_mowned_device, NULL },
+ { NULL, NULL, },
+};
+
struct menu_data menu_comp_manager[] = {
{ "0", "Get My Device ID", NULL, run_get_my_id, NULL },
{ "1", "Group Create", menu_group_create, NULL, NULL },
{ "6", "Delete Group", menu_group_delete, NULL, NULL },
{ "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", "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 },
- { "13", "Get My Device", NULL, run_device_get_my_device, NULL },
- { "14", "Send Message", menu_send_data, NULL, NULL },
+ { "9", "Show My Local Device", NULL, run_device_show_my_device, NULL },
+ { "10", "Find Device(s)", menu_devices_find, NULL, NULL },
+ { "11", "Show Found Device(s)", NULL, run_device_show_found, NULL },
+ { "12", "Invite Device", menu_group_invite_device, NULL, NULL },
+ { "13", "Eject Device", menu_group_eject_device, NULL, NULL },
+ { "14", "Find My Onwed Device(s)", menu_devices_find_mownd_device, NULL, NULL },
+ { "15", "Show My Onwed Device(s)", NULL, run_device_show_mowned_device, NULL},
+ { "16", "Send Message", menu_send_data, NULL, NULL },
{ NULL, NULL, },
};
g_signal_connect(group_proxy, "group-find-finish", G_CALLBACK(_group_find_finish_cb), NULL);
g_signal_connect(group_proxy, "device-found", G_CALLBACK(__device_found_cb), NULL);
g_signal_connect(group_proxy, "device-find-finish", G_CALLBACK(_device_find_finish_cb), NULL);
+ g_signal_connect(group_proxy, "mowned-device-found", G_CALLBACK(__device_found_cb), NULL);
g_signal_connect(group_proxy, "device-invite-result", G_CALLBACK(__device_invite_result_cb), NULL);
g_signal_connect(group_proxy, "device-eject-result", G_CALLBACK(__device_eject_result_cb), NULL);
g_signal_connect(group_proxy, "send-data-finish", G_CALLBACK(__send_data_finish_cb), NULL);
return ret;
}
+int companion_device_find_mowned_device(
+ companion_device_found_cb found_cb, companion_device_find_finish_cb finish_cb, void *user_data)
+{
+ int ret = 0;
+ GError *error = NULL;
+
+ device_found_cb.found_cb = found_cb;
+ device_found_cb.user_data = user_data;
+ device_find_finish_cb.finish_cb= finish_cb;
+ device_find_finish_cb.user_data = user_data;
+
+ /* get groups from daemon using gdbus */
+ group_call_find_mowned_devices_sync(group_proxy, &ret, NULL, &error);
+
+ return ret;
+}
+
int companion_send_data(companion_device_h device, char *data, companion_send_data_finish_cb finish_cb, void *user_data)
{
int ret = 0;
return ret;
}
+int companion_device_get_found_mowned_devices(
+ companion_device_h **devices, int *count)
+{
+ int ret = 0;
+ int num = 0;
+ GVariant *va = NULL;
+ GError *error = NULL;
+
+ /* get groups from daemon using gdbus */
+ group_call_get_mowned_device_sync(group_proxy, &num, &va, NULL, &error);
+ /* *count = g_variant_n_children(va); */
+ *count = num;
+
+ _ERR("get found mowned 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;
+}
+
int companion_device_get_my_device(companion_device_h *device)
{
int ret = 0;