From: saerome.kim Date: Thu, 18 Jan 2018 08:09:36 +0000 (+0900) Subject: demo: add menu X-Git-Tag: submit/tizen/20190131.065036~189 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bc211cb619e4583b788e1beebcdde9b67a1bdcfb;p=platform%2Fcore%2Fapi%2Fmulti-device-group.git demo: add menu 1. get my companion-manager's uuid 2. get my owned device list Signed-off-by: saerome.kim --- diff --git a/capi/demo/comp-manager.c b/capi/demo/comp-manager.c index 4528533..a463829 100644 --- a/capi/demo/comp-manager.c +++ b/capi/demo/comp-manager.c @@ -29,6 +29,7 @@ GList *found_group_list; GList *found_device_list; +GList *my_devices_list; static char groupid[MENU_DATA_SIZE + 1] = "mygroup"; static char timeout[MENU_DATA_SIZE + 1] = "5"; @@ -39,6 +40,20 @@ static char device_idx[MENU_DATA_SIZE + 1] = "1"; static char pin[MENU_DATA_SIZE + 1] = "11223344"; static char message[MENU_DATA_SIZE + 1] = "Hello World!!"; +int run_get_my_id(MManager *mm, struct menu_data *menu) +{ + msg(""); +#if 0 + ret = companion_device_my_deviceid(&devices, &count); + if (COMP_ERROR_NONE != ret) { + msgr("Failed to Get My Device ID: [%s(0x%X)]", comp_error_to_string(ret), ret); + return RET_FAILURE; + } + msg(" - companion_device_my_deviceid() ret: [0x%X] [%s]", ret, comp_error_to_string(ret)); +#endif + return RET_SUCCESS; +} + void _device_eject_result_cb(int result, void *user_data) { msg("Eject Device Complete [%s]", comp_error_to_string(result) ); @@ -432,6 +447,93 @@ static int run_devices_find(MManager *mm, struct menu_data *menu) return RET_SUCCESS; } +int run_device_get_found_mine(MManager *mm, struct menu_data *menu) +{ + int ret = 0; + int count = 0; + companion_device_h *devices = NULL; + + msg(""); +#if 0 + ret = companion_device_get_found_my_devices(&devices, &count); + if (COMP_ERROR_NONE != ret) { + msgr("Failed to Get Found My Devices: [%s(0x%X)]", comp_error_to_string(ret), ret); + return RET_FAILURE; + } + msg(" - companion_device_get_found_my_devices() ret: [0x%X] [%s]", ret, comp_error_to_string(ret)); +#endif + 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; +} + + +bool _device_found_mine_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); + + msgp("\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_mine(MManager *mm, struct menu_data *menu) +{ + int ret; + int duration; + msg("Find Devices"); + + if (strlen(timeout)) + duration = (unsigned short)strtol(timeout, NULL, 10); +#if 0 + ret = companion_device_find_mine(duration, _device_found_mine_cb, _device_finish_cb, NULL); + if (COMP_ERROR_NONE != ret) { + msgr("Failed to Find My Devices: [%s(0x%X)]", comp_error_to_string(ret), ret); + return RET_FAILURE; + } + msg(" - companion_device_find_mine() ret: [0x%X] [%s]", ret, comp_error_to_string(ret)); +#endif + if (my_devices_list) { + g_list_free_full(my_devices_list, _destroy_comp_device_info); + my_devices_list = NULL; + } + + return RET_SUCCESS; +} + + static void _group_leave_finish_cb(int result, void *user_data) { msgb("leave operation finished"); @@ -754,6 +856,12 @@ static struct menu_data menu_group_eject_device[] = { { NULL, NULL, }, }; +static struct menu_data menu_my_devices_find[] = { + { "0", "Timeout", NULL, NULL, timeout }, + { "1", "Run", NULL, run_devices_find_mine, NULL }, + { NULL, NULL, }, +}; + static struct menu_data menu_send_data[] = { { "0", "Message", NULL, NULL, message }, { "1", "Send (Broadcast)", NULL, run_send_data, NULL }, @@ -761,6 +869,7 @@ static struct menu_data menu_send_data[] = { }; 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 }, { "2", "Find Groups", menu_group_find, NULL, NULL }, { "3", "Get Found Groups", NULL, run_group_get_found , NULL }, @@ -773,6 +882,8 @@ struct menu_data menu_comp_manager[] = { { "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", "Find My Devices", menu_my_devices_find, NULL, NULL }, + { "14", "Get Found My Devices", NULL, run_device_get_found_mine, NULL }, { "13", "Send Message", menu_send_data, NULL, NULL }, { NULL, NULL, }, }; diff --git a/src/companion-manager/src/comp_mot_agent.c b/src/companion-manager/src/comp_mot_agent.c index 74955b4..419e24e 100644 --- a/src/companion-manager/src/comp_mot_agent.c +++ b/src/companion-manager/src/comp_mot_agent.c @@ -455,7 +455,6 @@ static gboolean __perform_remove_cred_at_local(gpointer data) return FALSE; } - static void _agent_signal_handler(GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer userdata)