int run_get_my_id(MManager *mm, struct menu_data *menu)
{
- msg("");
-#if 0
- ret = companion_device_my_deviceid(&devices, &count);
+ msg("Get Device ID of my device");
+
+ int ret;
+ char *uuid;
+ ret = companion_device_get_my_uuid(&uuid);
+
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
+ msgb("[ID] : [%s]", uuid);
+
return RET_SUCCESS;
}
return RET_SUCCESS;
}
-int run_device_get_found_mine(MManager *mm, struct menu_data *menu)
+int run_device_get_my_device(MManager *mm, struct menu_data *menu)
{
int ret = 0;
int count = 0;
- companion_device_h *devices = NULL;
+ companion_device_h device = NULL;
- msg("");
-#if 0
- ret = companion_device_get_found_my_devices(&devices, &count);
+ msg("Get My Device");
+
+ ret = companion_device_get_my_device(&device);
if (COMP_ERROR_NONE != ret) {
- msgr("Failed to Get Found My Devices: [%s(0x%X)]", comp_error_to_string(ret), ret);
+ msgr("Failed to Get My Device: [%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++) {
+ msg(" - companion_device_get_my_device() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
+
+ if (ret == 0) {
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);
+ 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);
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");
{ 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 },
{ "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 },
+ { "13", "Get My Device", NULL, run_device_get_my_device, NULL },
+ { "14", "Send Message", menu_send_data, NULL, NULL },
{ NULL, NULL, },
};
int companion_device_eject(companion_group_h group,
companion_device_h device, companion_device_eject_result_cb callback, void *user_data);
+int companion_device_get_my_device(companion_device_h *device);
+int companion_device_get_my_uuid(char **uuid);
+
/* Group Information Module */
int companion_group_information_create(companion_group_h* group);
int companion_group_information_clone(companion_group_h dst,
return ret;
}
+int companion_device_get_my_device(companion_device_h *device)
+{
+ int ret = 0;
+ GError *error = NULL;
+ GVariant *va = NULL;
+ GVariantIter *iter = NULL;
+ const gchar *key;
+ GVariant *key_value;
+ char *deviceid;
+ char *addr;
+ char *ver;
+
+ group_call_get_my_mowned_device_sync(group_proxy, &va, NULL, &error);
+
+ g_variant_get(va, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{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);
+ }
+ }
+
+ if (deviceid == NULL || addr == NULL || ver == NULL)
+ return -1;
+
+ *device = (companion_device_h)_create_device_handle(deviceid, addr, ver);
+
+ g_variant_iter_free(iter);
+
+ return ret;
+}
+int companion_device_get_my_uuid(char **uuid)
+{
+ int ret = 0;
+ GError *error = NULL;
+
+ group_call_get_my_uuid_sync(group_proxy, uuid, NULL, &error);
+
+ return ret;
+}
+
/* group merge */
int companion_group_merge(companion_group_h dest_group, companion_group_h src_group)
{
<arg type="i" name="device_count" direction="out" />
<arg type="aa{sv}" name="device_info" direction="out" />
</method>
+ <method name="GetMyMownedDevice">
+ <arg type="a{sv}" name="device_info" direction="out" />
+ </method>
+ <method name="GetMyUuid">
+ <arg type="s" name="uuid" direction="out" />
+ </method>
<!-- Signal (D-Bus) definitions -->
<signal name="GroupFound">
<arg type="a{sv}" name="group_info" direction="out" />
gboolean group_get_mowned_device(Group *group,
GDBusMethodInvocation *invocation, gpointer user_data);
+gboolean group_get_my_mowned_device(Group *group,
+ GDBusMethodInvocation *invocation, gpointer user_data);
+
+gboolean group_get_my_uuid(Group *group,
+ GDBusMethodInvocation *invocation, gpointer user_data);
+
void notify_group_found(GVariant *group_data);
void notify_group_find_finish(int ret);
void notify_device_found(int device_count, GVariant *device_data);
int comp_group_find_mowned_devices();
GVariant *comp_group_get_mowned_devices();
int comp_group_get_mowned_device_count();
+GVariant *comp_group_get_my_mowned_devices();
+void comp_group_change_mowned_device(comp_mot_device_t *device);
/* Join to remote device group */
int comp_group_join();
G_CALLBACK(group_get_mowned_device),
NULL);
+ g_signal_connect(group_skeleton,
+ "handle-get-my-mowned-device",
+ G_CALLBACK(group_get_my_mowned_device),
+ NULL);
+
+ g_signal_connect(group_skeleton,
+ "handle-get-my-uuid",
+ G_CALLBACK(group_get_my_uuid),
+ NULL);
+
group = g_dbus_object_manager_server_new(COMP_DBUS_GROUP_PATH);
// Set connection to 'manager'
return TRUE;
}
+gboolean group_get_my_mowned_device(Group *group,
+ GDBusMethodInvocation *invocation, gpointer user_data)
+{
+ GVariant *device_data;
+
+ LOG_DEBUG("get mowned device called using dbus successful");
+
+ device_data = comp_group_get_my_mowned_devices();
+ LOG_DEBUG("get mowned device called end ");
+
+ group_complete_get_my_mowned_device(group, invocation, device_data);
+
+ return TRUE;
+}
+
+gboolean group_get_my_uuid(Group *group,
+ GDBusMethodInvocation *invocation, gpointer user_data)
+{
+ LOG_DEBUG("get my uuid called using dbus successful");
+
+ comp_context_t *comp_ctx = comp_context_get_context();
+ group_complete_get_my_uuid(group, invocation, comp_ctx->device_uuid);
+
+ return TRUE;
+}
+
void notify_group_found(GVariant *group_data)
{
group_emit_group_found(group_dbus_get_object(), group_data);
GList *mot_enb_dev_list = NULL;
GList *mowned_dev_list = NULL;
comp_group_invite_info_t *group_invite_info = NULL;
+comp_mot_device_t *my_device = NULL;
/* Called when daemon is start. */
int comp_group_initialize()
return group_data;
}
+void comp_group_change_mowned_device(comp_mot_device_t *device)
+{
+ LOG_BEGIN();
+
+ my_device = device;
+
+ LOG_END();
+}
+
+GVariant *comp_group_get_my_mowned_devices()
+{
+ GVariantBuilder builder;
+ GVariant *group_data;
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
+
+ if (my_device != NULL) {
+ g_variant_builder_add(&builder, "{sv}", "DeviceID",
+ g_variant_new_string(my_device->device_id));
+ g_variant_builder_add(&builder, "{sv}", "Adapter",
+ g_variant_new_int32(my_device->adapter));
+ g_variant_builder_add(&builder, "{sv}", "Flags",
+ g_variant_new_int32(my_device->flags));
+ g_variant_builder_add(&builder, "{sv}", "Port",
+ g_variant_new_uint16(my_device->port));
+ g_variant_builder_add(&builder, "{sv}", "Address",
+ g_variant_new_string(my_device->addr));
+ g_variant_builder_add(&builder, "{sv}", "Ifindex",
+ g_variant_new_int32(my_device->ifindex));
+ g_variant_builder_add(&builder, "{sv}", "RouteData",
+ g_variant_new_string(my_device->route_data));
+ g_variant_builder_add(&builder, "{sv}", "ConnType",
+ g_variant_new_int32(my_device->conn_type));
+ g_variant_builder_add(&builder, "{sv}", "SecurePort",
+ g_variant_new_uint16(my_device->secure_port));
+ g_variant_builder_add(&builder, "{sv}", "TcpPort",
+ g_variant_new_uint16(my_device->tcp_port));
+ g_variant_builder_add(&builder, "{sv}", "SecVer",
+ g_variant_new_string(my_device->sec_ver));
+ g_variant_builder_add(&builder, "{sv}", "DeviceStatus",
+ g_variant_new_int32(my_device->dev_status));
+ }
+
+ group_data = g_variant_builder_end(&builder);
+
+ return group_data;
+}
+
int comp_group_get_mowned_device_count()
{
if (mowned_dev_list)
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)
mot_enb_devs_cnt += 1;
comp_group_add_new_mot_device(device);
} else {
- LOG_DEBUG("It is my device. Ignore it.");
+ LOG_DEBUG("It is my mowned device. Store the mowned device in daemon");
+ comp_group_change_mowned_device(device);
}
}
mowned_devs_cnt += 1;
comp_group_add_new_mowned_device(device);
} else {
- LOG_DEBUG("It is my device. Ignore it.");
+ LOG_DEBUG("It is my mowned device. Store the mowned device in daemon");
+ comp_group_change_mowned_device(device);
}
}
<arg type="i" name="device_count" direction="out" />
<arg type="aa{sv}" name="device_info" direction="out" />
</method>
+ <method name="GetMyMownedDevice">
+ <arg type="a{sv}" name="device_info" direction="out" />
+ </method>
+ <method name="GetMyUuid">
+ <arg type="s" name="uuid" direction="out" />
+ </method>
<!-- Signal (D-Bus) definitions -->
<signal name="GroupFound">
<arg type="a{sv}" name="group_info" direction="out" />