GList *found_device_list;
static char groupid[MENU_DATA_SIZE + 1] = "mygroup";
-static char timeout[MENU_DATA_SIZE + 1] = "1";
+static char timeout[MENU_DATA_SIZE + 1] = "5";
static char group_idx[MENU_DATA_SIZE + 1] = "1";
+void _device_finish_cb(int result, void *user_data)
+{
+ msgb("Find Devices Finished");
+}
+
+bool _device_found_cb(companion_device_h device, void *user_data)
+{
+ char *device_id;
+ char *friendly_name;
+ char *device_type;
+
+ 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("device_id : %s, name : %s, type : %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, device);
+
+ return TRUE;
+}
+static int run_devices_find(MManager *mm, struct menu_data *menu)
+{
+ int ret;
+ int duration;
+ msg("Find Devices");
+
+ if (strlen(timeout))
+ duration = (unsigned short)strtol(timeout, NULL, 10);
+
+ ret = companion_device_find(duration, _device_found_cb, _device_finish_cb, NULL);
+ if (COMP_ERROR_NONE != ret) {
+ msgr("Failed to Find Devices: [%s(0x%X)]", comp_error_to_string(ret), ret);
+ return RET_FAILURE;
+ }
+ msg(" - companion_device_find() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+
+ if (found_device_list)
+ g_list_free(found_device_list);
+
+ msg("");
+
+ return RET_SUCCESS;
+}
+
static void _group_leave_finish_cb(int result, void *user_data)
{
msgb("leave operation finished");
}
msg(" - companion_group_find() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+ if (found_group_list)
+ g_list_free(found_group_list);
+
return RET_SUCCESS;
}
{ NULL, NULL, },
};
+static struct menu_data menu_devices_find[] = {
+ { "0", "Timeout", NULL, NULL, timeout },
+ { "2", "Run", NULL, run_devices_find, NULL },
+ { NULL, NULL, },
+};
+
struct menu_data menu_comp_manager[] = {
{ "1", "Group Create", menu_group_create, NULL, NULL },
{ "2", "Find Groups", menu_group_find, NULL, NULL },
{ "6", "Delete Group", NULL, NULL, NULL },
{ "7", "Merge Group", NULL, NULL, NULL },
{ "8", "Get Group Member Devices", NULL, NULL, NULL },
- { "9", "Find Devices", NULL, NULL, NULL },
+ { "9", "Find Devices", menu_devices_find, NULL, NULL },
{ "10", "Invite Device", NULL, NULL, NULL },
{ "11", "Eject Device", NULL, NULL, NULL },
{ NULL, NULL, },
#include <comp_enum.h>
#include <comp_group.h>
+#include <comp_mot_agent.h>
#include <comp_gdbus_group.h>
GList *found_group_list;
int comp_group_initialize()
{
//Initialize memory of context
-
+ return COMP_ERROR_NONE;
}
/* create group and destroy */
int comp_group_destroy(comp_group_t *handle)
{
-
+ int ret = COMP_ERROR_NONE;
+ NOTUSED(handle);
+ return ret;
}
void _free_func (gpointer data)
int comp_group_add_new(char *uri_path, char *device_id, char *device_name,
char *host_addr, char *resource_type, comp_group_type_e type)
{
- int ret;
comp_group_t *group;
GVariantBuilder builder;
GVariant *group_data;
/* Join to remote device group */
-int comp_group_join_to(/* callback */){} //Join this device to in certain remote group (Async)
-int comp_group_leave_from(/* callback */){} //leave from certain remote group (Async)
+int comp_group_join_to(/* callback */) //Join this device to in certain remote group (Async)
+{
+ int ret = COMP_ERROR_NONE;
+ return ret;
+}
+
+int comp_group_leave_from(/* callback */) //leave from certain remote group (Async)
+{
+ int ret = COMP_ERROR_NONE;
+ return ret;
+}
/* Called when daemon is end. */
int comp_group_deinitialize()