From 263070feadaed205b2f2670107b69be360139527 Mon Sep 17 00:00:00 2001 From: Saurav Babu Date: Fri, 12 Jan 2018 18:02:07 +0530 Subject: [PATCH] comp-manager: Added GetRemoteDevice DBUS method to get mot enabled device Signed-off-by: Saurav Babu --- src/companion-manager/include/comp_gdbus_group.h | 3 +++ src/companion-manager/include/comp_group.h | 4 +++- src/companion-manager/src/comp_gdbus.c | 5 +++++ src/companion-manager/src/comp_gdbus_group.c | 16 ++++++++++++++++ src/companion-manager/src/comp_group.c | 10 +++++++++- src/companion-manager/src/companion_gdbus.xml | 4 ++++ 6 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/companion-manager/include/comp_gdbus_group.h b/src/companion-manager/include/comp_gdbus_group.h index d12dde6..b9d264e 100755 --- a/src/companion-manager/include/comp_gdbus_group.h +++ b/src/companion-manager/include/comp_gdbus_group.h @@ -32,6 +32,9 @@ gboolean group_device_invite(Group *group, GDBusMethodInvocation *invocation, gboolean group_device_eject(Group *group, GDBusMethodInvocation *invocation, gchar *uuid, gpointer user_data); +gboolean group_get_remote_device(Group *group, GDBusMethodInvocation *invocation, + gpointer user_data); + void notify_group_found(GVariant *group_data); void notify_group_finish(int ret); void notify_device_found(int device_count, GVariant *device_data); diff --git a/src/companion-manager/include/comp_group.h b/src/companion-manager/include/comp_group.h index 54826be..241722d 100755 --- a/src/companion-manager/include/comp_group.h +++ b/src/companion-manager/include/comp_group.h @@ -58,8 +58,10 @@ void comp_group_notify_group_invite(int result); int comp_group_dismiss(gchar *uuid); void comp_group_notify_group_dismiss(int result); +GVariant *comp_group_get_remote_mot_enabled_devices(); +int comp_group_get_mot_device_count(); + /* Join to remote device group */ -int comp_group_get_remote_groups(/* callback */); //Get all of group in network (Async) 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) diff --git a/src/companion-manager/src/comp_gdbus.c b/src/companion-manager/src/comp_gdbus.c index 9b6ced7..82e5215 100755 --- a/src/companion-manager/src/comp_gdbus.c +++ b/src/companion-manager/src/comp_gdbus.c @@ -64,6 +64,11 @@ static bool __group_init(GDBusConnection *connection) G_CALLBACK(group_device_eject), NULL); + g_signal_connect(group_skeleton, + "handle-get-remote-device", + G_CALLBACK(group_get_remote_device), + NULL); + group = g_dbus_object_manager_server_new(COMP_DBUS_GROUP_PATH); // Set connection to 'manager' diff --git a/src/companion-manager/src/comp_gdbus_group.c b/src/companion-manager/src/comp_gdbus_group.c index afa6039..89f851a 100755 --- a/src/companion-manager/src/comp_gdbus_group.c +++ b/src/companion-manager/src/comp_gdbus_group.c @@ -108,6 +108,22 @@ gboolean group_device_eject(Group *group, GDBusMethodInvocation *invocation, return TRUE; } +gboolean group_get_remote_device(Group *group, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + int dev_count = 0; + GVariant *device_data; + + LOG_DEBUG("get remote device called using dbus successful"); + + dev_count = comp_group_get_mot_device_count(); + device_data = comp_group_get_remote_mot_enabled_devices(); + + group_complete_get_remote_device(group, invocation, dev_count, device_data); + + return TRUE; +} + void notify_group_found(GVariant *group_data) { group_emit_group_found(group_dbus_get_object(), group_data); diff --git a/src/companion-manager/src/comp_group.c b/src/companion-manager/src/comp_group.c index bc1ce40..409be02 100755 --- a/src/companion-manager/src/comp_group.c +++ b/src/companion-manager/src/comp_group.c @@ -273,6 +273,14 @@ GVariant *comp_group_get_remote_mot_enabled_devices() return group_data; } +int comp_group_get_mot_device_count() +{ + if (mot_enb_dev_list) + return g_list_length(mot_enb_dev_list); + + return 0; +} + void comp_group_notify_mot_enable_device_done(int device_count) { GVariant *device_data; @@ -348,7 +356,7 @@ int comp_group_dismiss(gchar *uuid) } /* Join to remote device group */ -int comp_group_get_remote_groups(/* callback */){} //Get all of group in network (Async) + 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) diff --git a/src/companion-manager/src/companion_gdbus.xml b/src/companion-manager/src/companion_gdbus.xml index 96af362..c00926e 100755 --- a/src/companion-manager/src/companion_gdbus.xml +++ b/src/companion-manager/src/companion_gdbus.xml @@ -47,6 +47,10 @@ + + + + -- 2.7.4