demo: Always get devices from comp-manager in run_devices_show()
authorSaurav Babu <saurav.babu@samsung.com>
Mon, 19 Feb 2018 05:35:02 +0000 (11:05 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:48 +0000 (19:38 +0900)
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
capi/demo/comp-manager.c

index 43975aaca3935a976d2d0a8a8b83c667dd9ad9c3..697331cde369657b8bca1576634f843d04c384a7 100644 (file)
@@ -211,16 +211,38 @@ static int run_device_invite(MManager *mm, struct menu_data *menu)
        return RET_SUCCESS;
 }
 
+static void _destroy_comp_device_info(gpointer data)
+{
+       companion_device_information_destroy((companion_device_h)data);
+}
+
 static int run_devices_show(MManager *mm, struct menu_data *menu)
 {
        char *deviceid = NULL;
        char *ip = NULL;
        char *devicetype = NULL;
        companion_device_h device;
-
+       int ret;
+       int count;
+       companion_device_h *devices = NULL;
        int i;
        GList *iter = NULL;
 
+       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;
+       } else {
+               if (found_device_list) {
+                       g_list_free_full(found_device_list, _destroy_comp_device_info);
+                       found_device_list = NULL;
+               }
+
+               for (i = 0; i < count; i++)
+                       found_device_list = g_list_append(found_device_list, devices[i]);
+       }
+
        /* Get a first item */
        i = 0;
        iter = g_list_first(found_device_list);
@@ -229,11 +251,12 @@ static int run_devices_show(MManager *mm, struct menu_data *menu)
                if (!device) {
                        msgr("device list is null");
                        break;
-               }
-               companion_device_information_get_device_id(device, &deviceid);
+               }
+               companion_device_information_get_device_id(device, &deviceid);
                companion_device_information_get_ip(device, &ip);
                companion_device_information_get_device_type(device, &devicetype);
-               msgp("[%d] deviceid: %s, IP: %s type: %s", i+1, deviceid, ip, devicetype);
+               msgp("[%d] deviceid: %s, IP: %s type: %s", i+1, deviceid, ip,
+                        devicetype);
 
                if (deviceid) {
                        free(deviceid);
@@ -484,11 +507,6 @@ bool _device_found_cb(companion_device_h device, void *user_data)
        return TRUE;
 }
 
-static void _destroy_comp_device_info(gpointer data)
-{
-       companion_device_information_destroy((companion_device_h)data);
-}
-
 static int run_devices_find(MManager *mm, struct menu_data *menu)
 {
        int ret;