fn-manager: Add new method to get already found groups
authorSaurav Babu <saurav.babu@samsung.com>
Tue, 9 Jan 2018 13:51:01 +0000 (19:21 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:38 +0000 (19:38 +0900)
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
src/fn-manager/include/fn_gdbus_group.h
src/fn-manager/include/fn_group.h
src/fn-manager/src/familynet_gdbus.xml
src/fn-manager/src/fn_gdbus.c
src/fn-manager/src/fn_gdbus_group.c
src/fn-manager/src/fn_group.c

index e709752..3d6135f 100644 (file)
@@ -11,6 +11,9 @@ gboolean group_create(Group *group, GDBusMethodInvocation *invocation, gchar *gr
 gboolean group_find(Group *group, GDBusMethodInvocation *invocation,
        gpointer user_data);
 
+gboolean group_get_found_groups(Group *group, GDBusMethodInvocation *invocation,
+       gpointer user_data);
+
 gboolean group_join(Group *group, GDBusMethodInvocation *invocation,
        gpointer user_data);
 
index 96bf9e0..f56481f 100644 (file)
@@ -21,6 +21,7 @@ int fn_group_destroy(fn_group_t *handle);
 
 /* Find Remote groups */
 int fn_group_find();
+GVariant *fn_group_get_found_groups();
 int fn_group_add_new(char *uri_path, char *device_id, char *device_name,
                                         char *host_addr, char *resource_type);
 
index d3a508d..7980be0 100644 (file)
                <method name="Find">
                        <arg type="i" name="result" direction="out" />
                </method>
+               <method name="GetFoundGroups">
+                       <arg type="i" name="result" direction="out" />
+                       <arg type="aa{sv}" name="groups" direction="out" />
+               </method>
                <method name="Join">
                        <arg type="i" name="group_count" direction="out" />
                        <arg type="aa{sv}" name="groups" direction="out" />
index 4e769ad..b333e2d 100644 (file)
@@ -30,6 +30,11 @@ static bool __group_init(GDBusConnection *connection)
                NULL);
 
        g_signal_connect(group_skeleton,
+               "handle-get-found-groups",
+               G_CALLBACK(group_get_found_groups),
+               NULL);
+
+       g_signal_connect(group_skeleton,
                "handle-join",
                G_CALLBACK(group_join),
                NULL);
index 54757ce..f6fd841 100644 (file)
@@ -26,9 +26,23 @@ gboolean group_find(Group *group, GDBusMethodInvocation *invocation,
 
        fn_group_find();
 
-       group_complete_create(group, invocation, result);
+       group_complete_find(group, invocation, result);
        return TRUE;
- }
+}
+
+gboolean group_get_found_groups(Group *group, GDBusMethodInvocation *invocation,
+       gpointer user_data)
+{
+       gint result = 0;
+       GVariant *group_data;
+
+       LOG_DEBUG("get found groups called using dbus successful");
+
+       group_data = fn_group_get_found_groups();
+
+       group_complete_get_found_groups(group, invocation, result, group_data);
+       return TRUE;
+}
 
 gboolean group_join(Group *group, GDBusMethodInvocation *invocation,
        gpointer user_data)
index 4f57299..3240e65 100644 (file)
@@ -67,6 +67,39 @@ int fn_group_find()
        return FN_ERROR_NONE;
 }
 
+GVariant *fn_group_get_found_groups()
+{
+       GVariantBuilder builder;
+       GVariant *group_data;
+       GList *iter = NULL;
+
+       g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
+
+       iter = found_group_list;
+       while(iter != NULL) {
+               fn_group_t *group = (fn_group_t *)iter->data;
+
+               g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
+               g_variant_builder_add(&builder, "{sv}", "URI",
+                                                         g_variant_new_string(group->uri_path));
+               g_variant_builder_add(&builder, "{sv}", "DeviceID",
+                                                         g_variant_new_string(group->device_id));
+               g_variant_builder_add(&builder, "{sv}", "GroupName",
+                                                         g_variant_new_string(group->group_name));
+               g_variant_builder_add(&builder, "{sv}", "HostAddress",
+                                                         g_variant_new_string(group->host_addr));
+               g_variant_builder_add(&builder, "{sv}", "GroupDeviceType",
+                                                         g_variant_new_string(group->resource_type));
+               g_variant_builder_close(&builder);
+
+               iter = g_list_next(iter);
+       }
+
+       group_data = g_variant_builder_end(&builder);
+
+       return group_data;
+}
+
 int fn_group_add_new(char *uri_path, char *device_id, char *device_name,
                                         char *host_addr, char *resource_type)
 {