comp-manager: Added dbus method to pair/unpair resources
authorSaurav Babu <saurav.babu@samsung.com>
Mon, 15 Jan 2018 08:47:14 +0000 (14:17 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:40 +0000 (19:38 +0900)
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
src/companion-manager/include/comp_gdbus_group.h
src/companion-manager/include/comp_group.h
src/companion-manager/src/comp_gdbus.c
src/companion-manager/src/comp_gdbus_group.c
src/companion-manager/src/comp_group.c
src/companion-manager/src/comp_mot_agent.c
src/companion-manager/src/companion_gdbus.xml

index 5f7e568d93b28858fd8a9d507853ab566b8dcb77..dce74d389a3561c5d7b3eae5fb421f513a01dcc8 100755 (executable)
@@ -35,6 +35,15 @@ gboolean group_device_eject(Group *group, GDBusMethodInvocation *invocation,
 gboolean group_get_remote_device(Group *group, GDBusMethodInvocation *invocation,
        gpointer user_data);
 
+gboolean group_pair_resource(Group *group, GDBusMethodInvocation *invocation,
+       gchar *target_1, gchar *subject_1, gchar *uri_1, gchar *rt_1,
+       gchar *interface_1, int permission_1, gchar *target_2, gchar *subject_2,
+       gchar *uri_2, gchar *rt_2, gchar *interface_2, int permission_2,
+       gpointer user_data);
+
+gboolean group_unpair_resource(Group *group, GDBusMethodInvocation *invocation,
+       gchar *uuid_dev1, gchar *uuid_dev2, 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);
index 241722db5a427934b410da24995febc7bcfe59e1..7a421a39719fbd987021759f76ab71f9405742f4 100755 (executable)
@@ -58,6 +58,12 @@ void comp_group_notify_group_invite(int result);
 int comp_group_dismiss(gchar *uuid);
 void comp_group_notify_group_dismiss(int result);
 
+int comp_group_pair_resource(char* target1, char *subject1, char *uri1,
+       char *rt1, char *interface1, int permission1, char* target2, char *subject2,
+       char *uri2, char *rt2, char *interface2, int permission2);
+
+int comp_group_unpair_resource(gchar *uuid_dev1, gchar *uuid_dev2);
+
 GVariant *comp_group_get_remote_mot_enabled_devices();
 int comp_group_get_mot_device_count();
 
index 82e5215a4db55377314bc2b69d056c8979c7241d..2c18863232ce8a6d4f77a58903e452bd5db76900 100755 (executable)
@@ -69,6 +69,16 @@ static bool __group_init(GDBusConnection *connection)
                G_CALLBACK(group_get_remote_device),
                NULL);
 
+       g_signal_connect(group_skeleton,
+               "handle-pair-resource",
+               G_CALLBACK(group_pair_resource),
+               NULL);
+
+       g_signal_connect(group_skeleton,
+               "handle-unpair-resource",
+               G_CALLBACK(group_unpair_resource),
+               NULL);
+
        group = g_dbus_object_manager_server_new(COMP_DBUS_GROUP_PATH);
 
        // Set connection to 'manager'
index 94b02ca16d765c24516c2b38295b39c8b9327b5f..ea7b2c77ffbef91dcb713f4d4976cb767c5e461d 100755 (executable)
@@ -124,6 +124,39 @@ gboolean group_get_remote_device(Group *group, GDBusMethodInvocation *invocation
        return TRUE;
 }
 
+gboolean group_pair_resource(Group *group, GDBusMethodInvocation *invocation,
+       gchar *target_1, gchar *subject_1, gchar *uri_1, gchar *rt_1,
+       gchar *interface_1, int permission_1, gchar *target_2, gchar *subject_2,
+       gchar *uri_2, gchar *rt_2, gchar *interface_2, int permission_2,
+       gpointer user_data)
+{
+       int ret = 0;
+
+       LOG_DEBUG("pair resource called using dbus successful");
+
+       ret = comp_group_pair_resource(target_1, subject_1, uri_1, rt_1,
+                                          interface_1, permission_1, target_2, subject_2, uri_2,
+                                          rt_2, interface_2, permission_2);
+
+       group_complete_pair_resource(group, invocation, ret);
+
+       return TRUE;
+}
+
+gboolean group_unpair_resource(Group *group, GDBusMethodInvocation *invocation,
+       gchar *uuid_dev1, gchar *uuid_dev2, gpointer user_data)
+{
+       int ret = 0;
+
+       LOG_DEBUG("unpair resource called using dbus successful");
+
+       ret = comp_group_unpair_resource(uuid_dev1, uuid_dev2);
+
+       group_complete_unpair_resource(group, invocation, ret);
+
+       return TRUE;
+}
+
 void notify_group_found(GVariant *group_data)
 {
        group_emit_group_found(group_dbus_get_object(), group_data);
index 409be02f977c1ae4322c8ede12ee27bce1361141..f6672c1addf80e4f878157e1e4c11cc6b851920f 100755 (executable)
@@ -355,6 +355,35 @@ int comp_group_dismiss(gchar *uuid)
        return ret;
 }
 
+int comp_group_pair_resource(char* target1, char *subject1, char *uri1,
+       char *rt1, char *interface1, int permission1, char* target2, char *subject2,
+       char *uri2, char *rt2, char *interface2, int permission2)
+{
+       int ret;
+
+       LOG_BEGIN();
+
+       ret = agent_pairwise(target1, subject1, uri1, rt1, interface1, permission1,
+                                                target2, subject2, uri2, rt2, interface2, permission2);
+
+       LOG_END();
+
+       return ret;
+}
+
+int comp_group_unpair_resource(gchar *uuid_dev1, gchar *uuid_dev2)
+{
+       int ret;
+
+       LOG_BEGIN();
+
+       ret = agent_remove_myowned_device(uuid_dev1, uuid_dev2);
+
+       LOG_END();
+
+       return ret;
+}
+
 /* Join to remote device group */
 
 int comp_group_join_to(/* callback */){} //Join this device to in certain remote group (Async)
index 413004e4a6f249d4722d09e8a31a9f8c9d7c5515..318a6e6d9df6ab38806f02b78760e7767fc0e50d 100755 (executable)
@@ -228,8 +228,7 @@ int agent_remove_cred_at_local(char* uuid_str)
        return result;
 }
 
-
-int agent_remove_myowned_device(char* uuid_str)
+int agent_remove_myowned_device(char* uuid_str1, char *uuid_str2)
 {
        GVariant *variant = NULL;
        int result = COMP_ERROR_NONE;
@@ -241,7 +240,8 @@ int agent_remove_myowned_device(char* uuid_str)
        }
 
        variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "unpair",
-                       g_variant_new("(s)", uuid_str), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+                       g_variant_new("(ss)", uuid_str1, uuid_str2), G_DBUS_CALL_FLAGS_NONE,
+                       -1, NULL, &error);
        if (variant) {
                g_variant_get(variant, "(i)", &result);
                LOGD("remove_mo status 0x%x", result);
index 0194923e0fd7cb4458064d63705fdd74c48053dc..0a3ea93752a92a4f4fe6006b24470c3bf6f79920 100755 (executable)
                        <arg type="i" name="device_count" direction="out" />
                        <arg type="aa{sv}" name="device_info" direction="out" />
                </method>
+               <method name="PairResource">
+                       <arg type="s" name="target_1" direction="in"/>
+                       <arg type="s" name="subject_1" direction="in"/>
+                       <arg type="s" name="uri_1" direction="in"/>
+                       <arg type="s" name="rt_1" direction="in"/>
+                       <arg type="s" name="interface_1" direction="in"/>
+                       <arg type="i" name="permission_1" direction="in"/>
+                       <arg type="s" name="target_2" direction="in"/>
+                       <arg type="s" name="subject_2" direction="in"/>
+                       <arg type="s" name="uri_2" direction="in"/>
+                       <arg type="s" name="rt_2" direction="in"/>
+                       <arg type="s" name="interface_2" direction="in"/>
+                       <arg type="i" name="permission_2" direction="in"/>
+                       <arg type="i" name="result" direction="out"/>
+               </method>
+               <method name="UnpairResource">
+                       <arg type="s" name="uuid_dev1" direction="in"/>
+                       <arg type="s" name="uuid_dev2" direction="in"/>
+                       <arg type="i" name="result" direction="out"/>
+               </method>
 
                <!-- Signal (D-Bus) definitions -->
                <signal name="GroupFound">