plugins: use d-bus properties instead of GetInfo() for plugin type and mechanisms
authorAlexander Kanavin <alexander.kanavin@intel.com>
Thu, 6 Feb 2014 14:32:12 +0000 (16:32 +0200)
committerAlexander Kanavin <alexander.kanavin@intel.com>
Thu, 6 Feb 2014 14:32:12 +0000 (16:32 +0200)
src/daemon/dbus/interfaces/com.google.code.AccountsSSO.gSingleSignOn.RemotePlugin.xml
src/daemon/plugins/gsignond-plugin-remote-private.h
src/daemon/plugins/gsignond-plugin-remote.c
src/daemon/plugins/plugind/gsignond-plugin-daemon.c

index ef09de0..ba0fa43 100644 (file)
@@ -1,6 +1,8 @@
 <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
 <node>
   <interface name="com.google.code.AccountsSSO.gSingleSignOn.RemotePlugin">
+    <property type='s' name='method' access='read'/>
+    <property type='as' name='mechanisms' access='read'/>
     <method name="cancel">
     </method>
     <method name="requestInitial">
     <method name="refresh">
       <arg name="uiData" type="a{sv}" direction="in"/>
     </method>
-    <method name="getInfo">
-      <arg name="type" type="s" direction="out"/>
-      <arg name="mechanisms" type="as" direction="out"/>
-    </method>
         
     <signal name="response">
       <arg name="sessionData" type="a{sv}" direction="out"/>
index 759c13a..d55eb68 100644 (file)
@@ -36,8 +36,6 @@ struct _GSignondPluginRemotePrivate
 {
     GDBusConnection   *connection;
     GSignondDbusRemotePlugin *dbus_plugin_proxy;
-    gchar *plugin_type;
-    gchar **plugin_mechanisms;
     GPid cpid;
     guint child_watch_id;
 
index 1de047a..6354584 100644 (file)
@@ -224,40 +224,13 @@ gsignond_plugin_remote_get_property (
 
     switch (property_id) {
         case PROP_TYPE: {
-            if (!self->priv->plugin_type) {
-                GError *error = NULL;
-                gsignond_dbus_remote_plugin_call_get_info_sync (
-                    self->priv->dbus_plugin_proxy, &self->priv->plugin_type,
-                    &self->priv->plugin_mechanisms, NULL, &error);
-                if (error) {
-                    DBG ("Plugin type retrieval error :: %s", error->message);
-                    g_error_free (error);
-                    if (self->priv->plugin_type) {
-                        g_free (self->priv->plugin_type);
-                        self->priv->plugin_type = NULL;
-                    }
-                }
-            }
-            g_value_set_string (value, self->priv->plugin_type);
+            g_value_set_string (value,
+                                gsignond_dbus_remote_plugin_get_method(self->priv->dbus_plugin_proxy));
             break;
         }
         case PROP_MECHANISMS: {
-            if (!self->priv->plugin_mechanisms) {
-                GError *error = NULL;
-                gsignond_dbus_remote_plugin_call_get_info_sync (
-                    self->priv->dbus_plugin_proxy, &self->priv->plugin_type,
-                    &self->priv->plugin_mechanisms, NULL, &error);
-                if (error) {
-                    DBG ("Plugin mechanisms retrieval error :: %s",
-                            error->message);
-                    g_error_free (error);
-                    if (self->priv->plugin_mechanisms) {
-                        g_strfreev (self->priv->plugin_mechanisms);
-                        self->priv->plugin_mechanisms = NULL;
-                    }
-                }
-            }
-            g_value_set_boxed (value, self->priv->plugin_mechanisms);
+            g_value_set_boxed (value,
+                               gsignond_dbus_remote_plugin_get_mechanisms(self->priv->dbus_plugin_proxy));
             break;
         }
         default:
@@ -344,17 +317,7 @@ gsignond_plugin_remote_dispose (GObject *object)
 static void
 gsignond_plugin_remote_finalize (GObject *object)
 {
-    GSignondPluginRemote *self = GSIGNOND_PLUGIN_REMOTE (object);
-
-    if (self->priv->plugin_type) {
-        g_free (self->priv->plugin_type);
-        self->priv->plugin_type = NULL;
-    }
-
-    if (self->priv->plugin_mechanisms) {
-        g_strfreev (self->priv->plugin_mechanisms);
-        self->priv->plugin_mechanisms = NULL;
-    }
+    //GSignondPluginRemote *self = GSIGNOND_PLUGIN_REMOTE (object);
 
     G_OBJECT_CLASS (gsignond_plugin_remote_parent_class)->finalize (object);
 }
@@ -385,8 +348,6 @@ gsignond_plugin_remote_init (GSignondPluginRemote *self)
 
     self->priv->connection = NULL;
     self->priv->dbus_plugin_proxy = NULL;
-    self->priv->plugin_type = NULL;
-    self->priv->plugin_mechanisms = NULL;
     self->priv->cpid = 0;
 
     self->priv->err_watch_ch = NULL;
@@ -739,7 +700,7 @@ gsignond_plugin_remote_new (
     plugin->priv->dbus_plugin_proxy =
             gsignond_dbus_remote_plugin_proxy_new_sync (
                     plugin->priv->connection,
-                    G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+                    G_DBUS_PROXY_FLAGS_NONE,
                     NULL,
                     GSIGNOND_PLUGIN_OBJECTPATH,
                     NULL,
index 11e6fc7..6629499 100644 (file)
@@ -236,27 +236,6 @@ _handle_refresh_from_dbus (
     return TRUE;
 }
 
-static gboolean
-_handle_get_info_from_dbus (
-        GSignondPluginDaemon *self,
-        GDBusMethodInvocation *invocation,
-        gpointer user_data)
-{
-    DBG ("");
-    g_return_val_if_fail (self && GSIGNOND_IS_PLUGIN_DAEMON (self), FALSE);
-    gchar *type = NULL;
-    gchar **mechanisms = NULL;
-
-    g_object_get (self->priv->plugin, "type", &type, "mechanisms", &mechanisms,
-            NULL);
-    gsignond_dbus_remote_plugin_complete_get_info (
-            self->priv->dbus_remote_plugin, invocation, (const gchar*)type,
-            (const gchar *const *)mechanisms);
-    g_free (type);
-    g_strfreev (mechanisms);
-    return TRUE;
-}
-
 static void
 _handle_response_from_plugin (
         GSignondPluginDaemon *self,
@@ -421,8 +400,6 @@ gsignond_plugin_daemon_new (
             G_CALLBACK(_handle_user_action_finished_from_dbus), daemon);
     g_signal_connect_swapped (daemon->priv->dbus_remote_plugin,
             "handle-refresh", G_CALLBACK(_handle_refresh_from_dbus), daemon);
-    g_signal_connect_swapped (daemon->priv->dbus_remote_plugin,
-            "handle-get-info", G_CALLBACK(_handle_get_info_from_dbus), daemon);
 
     /* Connect plugin signals to handlers */
     g_signal_connect_swapped (daemon->priv->plugin, "response",
@@ -443,6 +420,17 @@ gsignond_plugin_daemon_new (
     g_signal_connect (daemon->priv->connection, "closed",
             G_CALLBACK(_on_connection_closed), daemon);
 
+    /* Set DBus properties */
+    gchar* type;
+    gchar** mechanisms;
+
+    g_object_get(daemon->priv->plugin, "type", &type, "mechanisms", &mechanisms, NULL);
+    gsignond_dbus_remote_plugin_set_method(daemon->priv->dbus_remote_plugin, type);
+    gsignond_dbus_remote_plugin_set_mechanisms(daemon->priv->dbus_remote_plugin, (const gchar* const*) mechanisms);
+
+    g_free(type);
+    g_strfreev(mechanisms);
+
     g_dbus_connection_start_message_processing (daemon->priv->connection);
 
     return daemon;