[gnome-online-accounts/wip/rishi/issue-43] daemon, dbus: Enable checking if a provider type is supported



commit 19c467490c24916712b0068ee6ef48c06e2f7b62
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Feb 3 20:01:18 2020 +0100

    daemon, dbus: Enable checking if a provider type is supported
    
    With the advent of Flatpak, applications can no longer be expected to
    be updated in lockstep with the operating system. In this case,
    applications are meant to link against libgoa-1.0.so, while goa-daemon
    and libgoa-backend-1.0.so are considered part of the OS.
    
    Therefore, when a newer version of an application is running against
    an older operating system, it needs to introspect the provider types
    supported by the backend daemon so that features not supported by the
    OS can be disabled at run-time.
    
    Based on initial work done by Jean Felder.
    
    https://gitlab.gnome.org/GNOME/gnome-online-accounts/issues/43

 data/dbus-interfaces.xml | 14 ++++++++++++++
 doc/goa-sections.txt     |  4 ++++
 src/daemon/goadaemon.c   | 27 +++++++++++++++++++++++++++
 3 files changed, 45 insertions(+)
---
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml
index 2fa79824..21c42c13 100644
--- a/data/dbus-interfaces.xml
+++ b/data/dbus-interfaces.xml
@@ -421,6 +421,20 @@
       <arg name="account_object_path" type="o" direction="out"/>
     </method>
 
+    <!--
+        IsSupportedProvider:
+        @provider_type: A provider of online accounts
+        @is_supported: Whether the provider is supported or not
+
+        Checks if a certain type of provider of online accounts (for example,
+        "google" or "lastfm") is supported. If @provider_type is supported,
+        then @is_supported is set to %TRUE.
+    -->
+    <method name="IsSupportedProvider">
+      <arg name="provider_type" type="s" direction="in"/>
+      <arg name="is_supported" type="b" direction="out"/>
+    </method>
+
   </interface>
 
 
diff --git a/doc/goa-sections.txt b/doc/goa-sections.txt
index 306846ee..6f96d69e 100644
--- a/doc/goa-sections.txt
+++ b/doc/goa-sections.txt
@@ -7,7 +7,11 @@ goa_manager_override_properties
 goa_manager_call_add_account
 goa_manager_call_add_account_finish
 goa_manager_call_add_account_sync
+goa_manager_call_is_supported_provider
+goa_manager_call_is_supported_provider_finish
+goa_manager_call_is_supported_provider_sync
 goa_manager_complete_add_account
+goa_manager_complete_is_supported_provider
 GoaManagerProxy
 GoaManagerProxyClass
 goa_manager_proxy_new
diff --git a/src/daemon/goadaemon.c b/src/daemon/goadaemon.c
index bfbe41c8..0eb372eb 100644
--- a/src/daemon/goadaemon.c
+++ b/src/daemon/goadaemon.c
@@ -76,6 +76,12 @@ static gboolean on_manager_handle_add_account (GoaManager            *object,
                                                GVariant              *details,
                                                gpointer               user_data);
 
+static gboolean
+on_manager_handle_is_supported_provider (GoaManager             *manager,
+                                         GDBusMethodInvocation  *invocation,
+                                         const gchar            *provider_type,
+                                         gpointer                user_data);
+
 static gboolean on_account_handle_remove (GoaAccount            *account,
                                           GDBusMethodInvocation *invocation,
                                           gpointer               user_data);
@@ -265,6 +271,7 @@ goa_daemon_init (GoaDaemon *self)
                     "handle-add-account",
                     G_CALLBACK (on_manager_handle_add_account),
                     self);
+  g_signal_connect (self->manager, "handle-is-supported-provider", G_CALLBACK 
(on_manager_handle_is_supported_provider), NULL);
   object = goa_object_skeleton_new ("/org/gnome/OnlineAccounts/Manager");
   goa_object_skeleton_set_manager (object, self->manager);
   g_dbus_object_manager_server_export (self->object_manager, G_DBUS_OBJECT_SKELETON (object));
@@ -1292,6 +1299,26 @@ on_manager_handle_add_account (GoaManager             *manager,
 
 /* ---------------------------------------------------------------------------------------------------- */
 
+static gboolean
+on_manager_handle_is_supported_provider (GoaManager             *manager,
+                                         GDBusMethodInvocation  *invocation,
+                                         const gchar            *provider_type,
+                                         gpointer                user_data)
+{
+  GoaProvider *provider = NULL;
+  gboolean is_supported;
+
+  provider = goa_provider_get_for_provider_type (provider_type);
+  is_supported = provider == NULL ? FALSE : TRUE;
+
+  goa_manager_complete_is_supported_provider (manager, invocation, is_supported);
+
+  g_clear_object (&provider);
+  return TRUE;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
 typedef struct
 {
   GoaObject *object;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]