[gdm/wip/gdbus-port: 5/13] Continue porting GdmFactorySlave / GdmProductSlave to GDBus



commit 6c5255e60a58b08d1f018040357216ca0affc77c
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon May 7 18:58:11 2012 +0200

    Continue porting GdmFactorySlave / GdmProductSlave to GDBus
    
    This commit tackles the GdmSession infrastructure, trying to
    consolidate GdmSessionRelay and GdmSessionDirect into a single
    generated class. For now, only GdmSessionRelay is ported (both
    client and server side).

 daemon/Makefile.am         |   28 +-
 daemon/gdm-factory-slave.c |  533 +++++++++++--------
 daemon/gdm-product-slave.c |  918 +++++++++----------------------
 daemon/gdm-session-relay.c | 1299 --------------------------------------------
 daemon/gdm-session-relay.h |   64 ---
 daemon/gdm-session.xml     |  160 ++++++
 6 files changed, 764 insertions(+), 2238 deletions(-)
---
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 2226631..945e91d 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -42,10 +42,10 @@ BUILT_SOURCES =					\
 	gdm-static-display-glue.h		\
 	gdm-transient-display-glue.h		\
 	gdm-local-display-factory-glue.h	\
-	gdm-local-display-factory-glue.c	\
 	gdm-product-display-glue.h		\
 	gdm-slave-resources.h			\
 	gdm-greeter-glue.h			\
+	gdm-session-glue.h			\
 	$(NULL)
 
 gdm-manager-glue.h: gdm-manager.xml Makefile.am
@@ -73,8 +73,12 @@ gdm-static-display-glue.h: gdm-static-display.xml Makefile.am
 gdm-transient-display-glue.h: gdm-transient-display.xml Makefile.am
 	dbus-binding-tool --prefix=gdm_transient_display --mode=glib-server --output=gdm-transient-display-glue.h $(srcdir)/gdm-transient-display.xml
 
-gdm-product-display-glue.h: gdm-product-display.xml Makefile.am
-	dbus-binding-tool --prefix=gdm_product_display --mode=glib-server --output=gdm-product-display-glue.h $(srcdir)/gdm-product-display.xml
+gdm-product-display-glue.c gdm-product-display-glue.h: gdm-product-display.xml Makefile.am
+	gdbus-codegen 							\
+		--c-namespace=GdmDBus					\
+		--interface-prefix=org.gnome.DisplayManager		\
+		--generate-c-code=gdm-product-display-glue		\
+		$(srcdir)/gdm-product-display.xml
 
 gdm-local-display-factory-glue.c gdm-local-display-factory-glue.h : gdm-local-display-factory.xml Makefile.am
 	gdbus-codegen 							\
@@ -83,6 +87,13 @@ gdm-local-display-factory-glue.c gdm-local-display-factory-glue.h : gdm-local-di
 		--generate-c-code=gdm-local-display-factory-glue	\
 		$(srcdir)/gdm-local-display-factory.xml
 
+gdm-session-glue.c gdm-session-glue.h : gdm-session.xml Makefile.am
+	gdbus-codegen 							\
+		--c-namespace=GdmDBus					\
+		--interface-prefix=org.gnome.DisplayManager		\
+		--generate-c-code=gdm-session-glue			\
+		$(srcdir)/gdm-session.xml
+
 gdm-greeter-glue.c gdm-greeter-glue.h : gdm-greeter-server.xml Makefile.am
 	gdbus-codegen 							\
 		--c-namespace=GdmDBus					\
@@ -192,8 +203,6 @@ gdm_factory_slave_SOURCES = 		\
 	gdm-session-private.h		\
 	gdm-session-record.c		\
 	gdm-session-record.h		\
-	gdm-session-relay.c		\
-	gdm-session-relay.h		\
 	gdm-session-worker-job.c	\
 	gdm-session-worker-job.h	\
 	gdm-xerrors.h			\
@@ -211,6 +220,8 @@ nodist_gdm_factory_slave_SOURCES =		\
 	gdm-greeter-glue.h			\
 	gdm-local-display-factory-glue.h	\
 	gdm-local-display-factory-glue.c	\
+	gdm-session-glue.c			\
+	gdm-session-glue.h			\
 	$(NULL)
 
 gdm_factory_slave_LDFLAGS =		\
@@ -246,6 +257,13 @@ gdm_product_slave_SOURCES = 		\
 	gdm-product-slave.h		\
 	$(NULL)
 
+nodist_gdm_product_slave_SOURCES = 	\
+	gdm-product-display-glue.c	\
+	gdm-product-display-glue.h	\
+	gdm-session-glue.c		\
+	gdm-session-glue.h		\
+	$(NULL)
+
 gdm_product_slave_LDFLAGS =		\
 	$(PAM_LIBS)			\
 	$(LIBXKLAVIER_LIBS)		\
diff --git a/daemon/gdm-factory-slave.c b/daemon/gdm-factory-slave.c
index 1c5dfdd..cdaae3a 100644
--- a/daemon/gdm-factory-slave.c
+++ b/daemon/gdm-factory-slave.c
@@ -47,9 +47,9 @@
 #include "gdm-greeter-session.h"
 #include "gdm-greeter-server.h"
 
-#include "gdm-session-relay.h"
-
+#include "gdm-session-glue.h"
 #include "gdm-local-display-factory-glue.h"
+#include "gdm-dbus-util.h"
 
 extern char **environ;
 
@@ -71,8 +71,12 @@ struct GdmFactorySlavePrivate
         Display           *server_display;
         guint              connection_attempts;
 
+        GHashTable        *pending_queries;
+
+        GdmDBusSession    *session;
+        GDBusServer       *session_server;
+
         GdmServer         *server;
-        GdmSessionRelay   *session;
         GdmGreeterServer  *greeter_server;
         GdmGreeterSession *greeter;
         GdmDBusLocalDisplayFactory *factory_proxy;
@@ -139,150 +143,197 @@ on_greeter_session_died (GdmGreeterSession    *greeter,
 }
 
 
-static void
-on_session_info (GdmSession      *session,
-                 const char      *service_name,
-                 const char      *text,
-                 GdmFactorySlave *slave)
+static gboolean
+on_session_handle_info (GdmDBusSession        *session,
+                        GDBusMethodInvocation *invocation,
+                        const char            *service_name,
+                        const char            *text,
+                        GdmFactorySlave       *slave)
 {
         g_debug ("GdmFactorySlave: Info: %s", text);
         gdm_greeter_server_info (slave->priv->greeter_server, service_name, text);
+
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
-static void
-on_session_problem (GdmSession      *session,
-                    const char      *service_name,
-                    const char      *text,
-                    GdmFactorySlave *slave)
+static gboolean
+on_session_handle_problem (GdmDBusSession        *session,
+                           GDBusMethodInvocation *invocation,
+                           const char            *service_name,
+                           const char            *text,
+                           GdmFactorySlave       *slave)
 {
         g_debug ("GdmFactorySlave: Problem: %s", text);
         gdm_greeter_server_problem (slave->priv->greeter_server, service_name, text);
+
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
-static void
-on_session_info_query (GdmSession      *session,
-                       const char      *service_name,
-                       const char      *text,
-                       GdmFactorySlave *slave)
+static gboolean
+on_session_handle_info_query (GdmDBusSession        *session,
+                              GDBusMethodInvocation *invocation,
+                              const char            *service_name,
+                              const char            *text,
+                              GdmFactorySlave       *slave)
 {
+        GDBusMethodInvocation *previous;
 
         g_debug ("GdmFactorySlave: Info query: %s", text);
+
+        if ((previous = g_hash_table_lookup (slave->priv->pending_queries, service_name))) {
+                g_dbus_method_invocation_return_dbus_error (invocation,
+                                                            "org.gnome.DisplayManager.SessionRelayCancelled",
+                                                            "Cancelled by another request for the same service");
+        }
+
+        g_hash_table_replace (slave->priv->pending_queries, g_strdup (service_name), g_object_ref (invocation));
         gdm_greeter_server_info_query (slave->priv->greeter_server, service_name, text);
+
+        return TRUE;
 }
 
-static void
-on_session_secret_info_query (GdmSession      *session,
-                              const char      *service_name,
-                              const char      *text,
-                              GdmFactorySlave *slave)
+static gboolean
+on_session_handle_secret_info_query (GdmDBusSession        *session,
+                                     GDBusMethodInvocation *invocation,
+                                     const char            *service_name,
+                                     const char            *text,
+                                     GdmFactorySlave       *slave)
 {
+        GDBusMethodInvocation *previous;
+
         g_debug ("GdmFactorySlave: Secret info query: %s", text);
+
+        if ((previous = g_hash_table_lookup (slave->priv->pending_queries, service_name))) {
+                g_dbus_method_invocation_return_dbus_error (invocation,
+                                                            "org.gnome.DisplayManager.SessionRelayCancelled",
+                                                            "Cancelled by another request for the same service");
+        }
+
+        g_hash_table_replace (slave->priv->pending_queries, g_strdup (service_name), g_object_ref (invocation));
         gdm_greeter_server_secret_info_query (slave->priv->greeter_server, service_name, text);
+
+        return TRUE;
 }
 
-static void
-on_session_conversation_started (GdmSession      *session,
-                                 const char      *service_name,
-                                 GdmFactorySlave *slave)
+static gboolean
+on_session_handle_conversation_started (GdmDBusSession        *session,
+                                        GDBusMethodInvocation *invocation,
+                                        const char            *service_name,
+                                        GdmFactorySlave       *slave)
 {
         g_debug ("GdmFactorySlave: session conversation started");
 
         gdm_greeter_server_ready (slave->priv->greeter_server,
                                   service_name);
+
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
-static void
-on_session_setup_complete (GdmSession      *session,
-                           const char      *service_name,
-                           GdmFactorySlave *slave)
+static gboolean
+on_session_handle_setup_complete (GdmDBusSession        *session,
+                                  GDBusMethodInvocation *invocation,
+                                  const char            *service_name,
+                                  GdmFactorySlave       *slave)
 {
-        gdm_session_authenticate (session, service_name);
+        gdm_dbus_session_emit_authenticate (session, service_name);
+
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
-static void
-on_session_setup_failed (GdmSession      *session,
-                         const char      *service_name,
-                         const char      *message,
-                         GdmFactorySlave *slave)
+static gboolean
+on_session_handle_setup_failed (GdmDBusSession        *session,
+                                GDBusMethodInvocation *invocation,
+                                const char            *service_name,
+                                const char            *message,
+                                GdmFactorySlave       *slave)
 {
         gdm_greeter_server_problem (slave->priv->greeter_server, service_name, _("Unable to initialize login system"));
 
         queue_greeter_reset (slave);
-}
 
-static void
-on_session_reset_complete (GdmSession      *session,
-                           GdmFactorySlave *slave)
-{
-        g_debug ("GdmFactorySlave: PAM reset");
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
-static void
-on_session_reset_failed (GdmSession      *session,
-                         const char      *message,
-                         GdmFactorySlave *slave)
+static gboolean
+on_session_handle_authenticated (GdmDBusSession        *session,
+                                 GDBusMethodInvocation *invocation,
+                                 const char            *service_name,
+                                 GdmFactorySlave       *slave)
 {
-        g_critical ("Unable to reset PAM");
-}
+        gdm_dbus_session_emit_authorize (session, service_name);
 
-static void
-on_session_authenticated (GdmSession      *session,
-                          const char      *service_name,
-                          GdmFactorySlave *slave)
-{
-        gdm_session_authorize (session, service_name);
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
-static void
-on_session_authentication_failed (GdmSession      *session,
-                                  const char      *service_name,
-                                  const char      *message,
-                                  GdmFactorySlave *slave)
+static gboolean
+on_session_handle_authentication_failed (GdmDBusSession        *session,
+                                         GDBusMethodInvocation *invocation,
+                                         const char            *service_name,
+                                         const char            *message,
+                                         GdmFactorySlave       *slave)
 {
         gdm_greeter_server_problem (slave->priv->greeter_server, service_name, _("Unable to authenticate user"));
 
         queue_greeter_reset (slave);
+
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
-static void
-on_session_authorized (GdmSession      *session,
-                       const char      *service_name,
-                       GdmFactorySlave *slave)
+static gboolean
+on_session_handle_authorized (GdmDBusSession        *session,
+                              GDBusMethodInvocation *invocation,
+                              const char            *service_name,
+                              GdmFactorySlave       *slave)
 {
-        int flag;
-
         /* FIXME: check for migration? */
-        flag = GDM_SESSION_CRED_ESTABLISH;
+        gdm_dbus_session_emit_establish_credentials (session, service_name);
 
-        gdm_session_accredit (session, service_name, flag);
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
-static void
-on_session_authorization_failed (GdmSession      *session,
-                                 const char      *service_name,
-                                 const char      *message,
-                                 GdmFactorySlave *slave)
+static gboolean
+on_session_handle_authorization_failed (GdmDBusSession        *session,
+                                        GDBusMethodInvocation *invocation,
+                                        const char            *service_name,
+                                        const char            *message,
+                                        GdmFactorySlave       *slave)
 {
         gdm_greeter_server_problem (slave->priv->greeter_server, service_name, _("Unable to authorize user"));
 
         queue_greeter_reset (slave);
+
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
-static void
-on_session_accredited (GdmSession      *session,
-                       const char      *service_name,
-                       GdmFactorySlave *slave)
+static gboolean
+on_session_handle_accredited (GdmDBusSession        *session,
+                              GDBusMethodInvocation *invocation,
+                              const char            *service_name,
+                              GdmFactorySlave       *slave)
 {
         g_debug ("GdmFactorySlave:  session user verified");
 
-        gdm_session_open_session (session, service_name);
+        gdm_dbus_session_emit_open_session (session, service_name);
+
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
-static void
-on_session_accreditation_failed (GdmSession      *session,
-                                 const char      *service_name,
-                                 const char      *message,
-                                 GdmFactorySlave *slave)
+static gboolean
+on_session_handle_accreditation_failed (GdmDBusSession        *session,
+                                        GDBusMethodInvocation *invocation,
+                                        const char            *service_name,
+                                        const char            *message,
+                                        GdmFactorySlave       *slave)
 {
         g_debug ("GdmFactorySlave: could not successfully authenticate user: %s",
                  message);
@@ -290,48 +341,65 @@ on_session_accreditation_failed (GdmSession      *session,
         gdm_greeter_server_problem (slave->priv->greeter_server, service_name, _("Unable to establish credentials"));
 
         queue_greeter_reset (slave);
+
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
-static void
-on_session_opened (GdmSession      *session,
-                   const char      *service_name,
-                   GdmFactorySlave *slave)
+static gboolean
+on_session_handle_opened (GdmDBusSession        *session,
+                          GDBusMethodInvocation *invocation,
+                          const char            *service_name,
+                          GdmFactorySlave       *slave)
 {
         g_debug ("GdmFactorySlave: session opened");
 
-        gdm_session_start_session (session, service_name);
+        gdm_dbus_session_emit_start_session (session, service_name);
 
         gdm_greeter_server_reset (slave->priv->greeter_server);
+
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
-static void
-on_session_open_failed (GdmSession      *session,
-                        const char      *service_name,
-                        const char      *message,
-                        GdmFactorySlave *slave)
+static gboolean
+on_session_handle_open_failed (GdmDBusSession        *session,
+                               GDBusMethodInvocation *invocation,
+                               const char            *service_name,
+                               const char            *message,
+                               GdmFactorySlave       *slave)
 {
         g_debug ("GdmFactorySlave: could not open session: %s", message);
 
         gdm_greeter_server_problem (slave->priv->greeter_server, service_name, _("Unable to open session"));
 
         queue_greeter_reset (slave);
+
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
-static void
-on_session_session_started (GdmSession      *session,
-                            int              pid,
-                            GdmFactorySlave *slave)
+static gboolean
+on_session_handle_session_started (GdmDBusSession        *session,
+                                   GDBusMethodInvocation *invocation,
+                                   const char            *service_name,
+                                   int                    pid,
+                                   const char           **environment,
+                                   GdmFactorySlave       *slave)
 {
         g_debug ("GdmFactorySlave: Relay session started");
 
         gdm_greeter_server_reset (slave->priv->greeter_server);
+
+        g_dbus_method_invocation_return_value (invocation, NULL);
+        return TRUE;
 }
 
 static gboolean
 create_product_display (GdmFactorySlave *slave)
 {
         char    *parent_display_id;
-        char    *server_address;
+        const char *server_address;
         char    *product_id;
         GError  *error = NULL;
         gboolean res;
@@ -354,7 +422,7 @@ create_product_display (GdmFactorySlave *slave)
                 goto out;
         }
 
-        server_address = gdm_session_relay_get_address (slave->priv->session);
+        server_address = g_dbus_server_get_client_address (slave->priv->session_server);
 
         g_object_get (slave,
                       "display-id", &parent_display_id,
@@ -365,7 +433,6 @@ create_product_display (GdmFactorySlave *slave)
                                                                                server_address,
                                                                                &product_id,
                                                                                NULL, &error);
-        g_free (server_address);
         g_free (parent_display_id);
 
         if (! res) {
@@ -385,21 +452,18 @@ create_product_display (GdmFactorySlave *slave)
 }
 
 static void
-on_session_relay_disconnected (GdmSessionRelay *session,
-                               GdmFactorySlave *slave)
+on_session_connection_closed (GDBusConnection *connection,
+                              gboolean         remote_peer_vanished,
+                              GdmFactorySlave *slave)
 {
         g_debug ("GdmFactorySlave: Relay disconnected");
 
         /* FIXME: do some kind of loop detection */
         gdm_greeter_server_reset (slave->priv->greeter_server);
         create_product_display (slave);
-}
 
-static void
-on_session_relay_connected (GdmSessionRelay *session,
-                            GdmFactorySlave *slave)
-{
-        g_debug ("GdmFactorySlave: Relay Connected");
+        /* pair the reference added in handle_new_connection */
+        g_object_unref (connection);
 }
 
 static void
@@ -409,7 +473,7 @@ on_greeter_start_conversation (GdmGreeterServer *greeter_server,
 {
         g_debug ("GdmFactorySlave: start conversation");
 
-        gdm_session_start_conversation (GDM_SESSION (slave->priv->session), service_name);
+        gdm_dbus_session_emit_start_conversation (slave->priv->session, service_name);
 }
 
 static void
@@ -418,8 +482,8 @@ on_greeter_begin_verification (GdmGreeterServer *greeter_server,
                                GdmFactorySlave  *slave)
 {
         g_debug ("GdmFactorySlave: begin verification");
-        gdm_session_setup (GDM_SESSION (slave->priv->session),
-                           service_name);
+        gdm_dbus_session_emit_setup (slave->priv->session,
+                                     service_name, "", "", "", "", "");
 }
 
 static void
@@ -429,9 +493,9 @@ on_greeter_begin_verification_for_user (GdmGreeterServer *greeter_server,
                                         GdmFactorySlave  *slave)
 {
         g_debug ("GdmFactorySlave: begin verification for user");
-        gdm_session_setup_for_user (GDM_SESSION (slave->priv->session),
-                                    service_name,
-                                    username);
+        gdm_dbus_session_emit_setup_for_user (slave->priv->session,
+                                              service_name, username,
+                                              "", "", "", "", "");
 }
 
 static void
@@ -440,8 +504,15 @@ on_greeter_answer (GdmGreeterServer *greeter_server,
                    const char       *text,
                    GdmFactorySlave  *slave)
 {
+        GDBusMethodInvocation *invocation;
+
         g_debug ("GdmFactorySlave: Greeter answer");
-        gdm_session_answer_query (GDM_SESSION (slave->priv->session), service_name, text);
+
+        invocation = g_hash_table_lookup (slave->priv->pending_queries, service_name);
+        g_dbus_method_invocation_return_value (invocation,
+                                               g_variant_new ("(s)", text));
+
+        g_hash_table_remove (slave->priv->pending_queries, service_name);
 }
 
 static void
@@ -449,7 +520,7 @@ on_greeter_session_selected (GdmGreeterServer *greeter_server,
                              const char       *text,
                              GdmFactorySlave  *slave)
 {
-        gdm_session_select_session (GDM_SESSION (slave->priv->session), text);
+        gdm_dbus_session_emit_set_session_name (slave->priv->session, text);
 }
 
 static void
@@ -457,7 +528,7 @@ on_greeter_language_selected (GdmGreeterServer *greeter_server,
                               const char       *text,
                               GdmFactorySlave  *slave)
 {
-        gdm_session_select_language (GDM_SESSION (slave->priv->session), text);
+        gdm_dbus_session_emit_set_language_name (slave->priv->session, text);
 }
 
 static void
@@ -465,14 +536,14 @@ on_greeter_user_selected (GdmGreeterServer *greeter_server,
                           const char       *text,
                           GdmFactorySlave  *slave)
 {
-        gdm_session_select_user (GDM_SESSION (slave->priv->session), text);
+        gdm_dbus_session_emit_set_user_name (slave->priv->session, text);
 }
 
 static void
 on_greeter_cancel (GdmGreeterServer *greeter_server,
                    GdmFactorySlave  *slave)
 {
-        gdm_session_cancel (GDM_SESSION (slave->priv->session));
+        gdm_dbus_session_emit_cancelled (slave->priv->session);
 }
 
 static void
@@ -726,102 +797,121 @@ gdm_factory_slave_run (GdmFactorySlave *slave)
 }
 
 static gboolean
+handle_new_connection (GDBusServer     *server,
+                       GDBusConnection *connection,
+                       GdmFactorySlave *slave)
+{
+        g_object_ref (connection);
+
+        slave->priv->session = GDM_DBUS_SESSION (gdm_dbus_session_skeleton_new ());
+
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-conversation-started",
+                                 G_CALLBACK (on_session_handle_conversation_started),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-setup-complete",
+                                 G_CALLBACK (on_session_handle_setup_complete),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-setup-failed",
+                                 G_CALLBACK (on_session_handle_setup_failed),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-authenticated",
+                                 G_CALLBACK (on_session_handle_authenticated),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-authentication-failed",
+                                 G_CALLBACK (on_session_handle_authentication_failed),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-authorized",
+                                 G_CALLBACK (on_session_handle_authorized),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-authorization-failed",
+                                 G_CALLBACK (on_session_handle_authorization_failed),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-accredited",
+                                 G_CALLBACK (on_session_handle_accredited),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-accreditation-failed",
+                                 G_CALLBACK (on_session_handle_accreditation_failed),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-session-opened",
+                                 G_CALLBACK (on_session_handle_opened),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-session-open-failed",
+                                 G_CALLBACK (on_session_handle_open_failed),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-info",
+                                 G_CALLBACK (on_session_handle_info),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-problem",
+                                 G_CALLBACK (on_session_handle_problem),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-info-query",
+                                 G_CALLBACK (on_session_handle_info_query),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-secret-info-query",
+                                 G_CALLBACK (on_session_handle_secret_info_query),
+                                 slave, 0);
+        g_signal_connect_object (slave->priv->session,
+                                 "handle-session-started",
+                                 G_CALLBACK (on_session_handle_session_started),
+                                 slave, 0);
+
+        g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (slave->priv->session),
+                                          connection,
+                                          "/org/gnome/DisplayManager/Session",
+                                          NULL);
+
+        g_signal_connect_object (connection, "closed",
+                                 G_CALLBACK (on_session_connection_closed), slave, 0);
+
+        return TRUE;
+}
+
+static gboolean
 gdm_factory_slave_start (GdmSlave *slave)
 {
+        GdmFactorySlave *self;
+        GError *error = NULL;
         gboolean ret;
 
         ret = FALSE;
 
+        self = GDM_FACTORY_SLAVE (slave);
+
         g_debug ("GdmFactorySlave: Starting factory slave");
 
         GDM_SLAVE_CLASS (gdm_factory_slave_parent_class)->start (slave);
 
-        GDM_FACTORY_SLAVE (slave)->priv->session = gdm_session_relay_new ();
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "conversation-started",
-                          G_CALLBACK (on_session_conversation_started),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "setup-complete",
-                          G_CALLBACK (on_session_setup_complete),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "setup-failed",
-                          G_CALLBACK (on_session_setup_failed),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "reset-complete",
-                          G_CALLBACK (on_session_reset_complete),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "reset-failed",
-                          G_CALLBACK (on_session_reset_failed),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "authenticated",
-                          G_CALLBACK (on_session_authenticated),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "authentication-failed",
-                          G_CALLBACK (on_session_authentication_failed),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "authorized",
-                          G_CALLBACK (on_session_authorized),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "authorization-failed",
-                          G_CALLBACK (on_session_authorization_failed),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "accredited",
-                          G_CALLBACK (on_session_accredited),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "accreditation-failed",
-                          G_CALLBACK (on_session_accreditation_failed),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "session-opened",
-                          G_CALLBACK (on_session_opened),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "session-open-failed",
-                          G_CALLBACK (on_session_open_failed),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "info",
-                          G_CALLBACK (on_session_info),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "problem",
-                          G_CALLBACK (on_session_problem),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "info-query",
-                          G_CALLBACK (on_session_info_query),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "secret-info-query",
-                          G_CALLBACK (on_session_secret_info_query),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "session-started",
-                          G_CALLBACK (on_session_session_started),
-                          slave);
+        self->priv->pending_queries = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                                              g_free, g_object_unref);
 
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "connected",
-                          G_CALLBACK (on_session_relay_connected),
-                          slave);
-        g_signal_connect (GDM_FACTORY_SLAVE (slave)->priv->session,
-                          "disconnected",
-                          G_CALLBACK (on_session_relay_disconnected),
-                          slave);
+        self->priv->session_server = gdm_dbus_setup_private_server (NULL,
+                                                                      &error);
+
+        if (self->priv->session_server == NULL) {
+                g_critical ("Failed to setup private DBus server: %s", error->message);
+                return FALSE;
+        }
+        g_signal_connect_object (self->priv->session_server, "new-connection",
+                                 G_CALLBACK (handle_new_connection), slave, 0);
 
-        gdm_session_relay_start (GDM_FACTORY_SLAVE (slave)->priv->session);
+        g_dbus_server_start (self->priv->session_server);
 
-        gdm_factory_slave_run (GDM_FACTORY_SLAVE (slave));
+        gdm_factory_slave_run (self);
 
         ret = TRUE;
 
@@ -831,34 +921,41 @@ gdm_factory_slave_start (GdmSlave *slave)
 static gboolean
 gdm_factory_slave_stop (GdmSlave *slave)
 {
+        GdmFactorySlave *self = GDM_FACTORY_SLAVE (slave);
+
         g_debug ("GdmFactorySlave: Stopping factory_slave");
 
         GDM_SLAVE_CLASS (gdm_factory_slave_parent_class)->stop (slave);
 
-        if (GDM_FACTORY_SLAVE (slave)->priv->session != NULL) {
-                gdm_session_relay_stop (GDM_FACTORY_SLAVE (slave)->priv->session);
-                g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->session);
-                GDM_FACTORY_SLAVE (slave)->priv->session = NULL;
+        if (self->priv->session != NULL) {
+                g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self->priv->session));
+                g_clear_object (&self->priv->session);
         }
 
-        if (GDM_FACTORY_SLAVE (slave)->priv->greeter_server != NULL) {
-                gdm_greeter_server_stop (GDM_FACTORY_SLAVE (slave)->priv->greeter_server);
-                g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->greeter_server);
-                GDM_FACTORY_SLAVE (slave)->priv->greeter_server = NULL;
+        if (self->priv->session_server != NULL) {
+                g_dbus_server_stop (self->priv->session_server);
+                g_clear_object (&self->priv->session_server);
         }
 
-        if (GDM_FACTORY_SLAVE (slave)->priv->greeter != NULL) {
-                gdm_welcome_session_stop (GDM_WELCOME_SESSION (GDM_FACTORY_SLAVE (slave)->priv->greeter));
+        if (self->priv->greeter_server != NULL) {
+                gdm_greeter_server_stop (self->priv->greeter_server);
+                g_clear_object (&self->priv->greeter_server);
         }
 
-        if (GDM_FACTORY_SLAVE (slave)->priv->server != NULL) {
-                gdm_server_stop (GDM_FACTORY_SLAVE (slave)->priv->server);
-                g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->server);
-                GDM_FACTORY_SLAVE (slave)->priv->server = NULL;
+        if (self->priv->greeter != NULL) {
+                gdm_welcome_session_stop (GDM_WELCOME_SESSION (self->priv->greeter));
         }
 
-        if (GDM_FACTORY_SLAVE (slave)->priv->factory_proxy != NULL) {
-                g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->factory_proxy);
+        if (self->priv->server != NULL) {
+                gdm_server_stop (self->priv->server);
+                g_clear_object (&self->priv->server);
+        }
+
+        g_clear_object (&self->priv->factory_proxy);
+
+        if (self->priv->pending_queries) {
+                g_hash_table_unref (self->priv->pending_queries);
+                self->priv->pending_queries = NULL;
         }
 
         return TRUE;
diff --git a/daemon/gdm-product-slave.c b/daemon/gdm-product-slave.c
index 844af48..da3b885 100644
--- a/daemon/gdm-product-slave.c
+++ b/daemon/gdm-product-slave.c
@@ -35,20 +35,18 @@
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
 #include <glib-object.h>
-
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
 
 #include <X11/Xlib.h> /* for Display */
 
 #include "gdm-common.h"
 
 #include "gdm-product-slave.h"
-#include "gdm-product-slave-glue.h"
 
 #include "gdm-server.h"
 #include "gdm-session-direct.h"
+#include "gdm-session-glue.h"
+#include "gdm-product-display-glue.h"
 
 extern char **environ;
 
@@ -75,10 +73,11 @@ struct GdmProductSlavePrivate
 
         GdmServer        *server;
         GdmSessionDirect *session;
-        DBusConnection   *session_relay_connection;
+        GdmDBusSession   *session_relay;
+        GDBusConnection  *session_connection;
 
-        DBusGProxy       *product_display_proxy;
-        DBusGConnection  *connection;
+        GdmDBusProductDisplay *product_display;
+        GDBusConnection  *connection;
 
         char             *start_session_service_name;
 };
@@ -89,227 +88,22 @@ static void     gdm_product_slave_finalize      (GObject             *object);
 
 G_DEFINE_TYPE (GdmProductSlave, gdm_product_slave, GDM_TYPE_SLAVE)
 
-static gboolean
-send_dbus_string_string_method (DBusConnection *connection,
-                                const char     *method,
-                                const char     *payload1,
-                                const char     *payload2)
-{
-        DBusError       error;
-        DBusMessage    *message;
-        DBusMessage    *reply;
-        DBusMessageIter iter;
-        const char     *str;
-
-        g_debug ("GdmProductSlave: Calling %s", method);
-        message = dbus_message_new_method_call (NULL,
-                                                RELAY_SERVER_DBUS_PATH,
-                                                RELAY_SERVER_DBUS_INTERFACE,
-                                                method);
-        if (message == NULL) {
-                g_warning ("Couldn't allocate the D-Bus message");
-                return FALSE;
-        }
-
-        dbus_message_iter_init_append (message, &iter);
-
-        if (payload1 != NULL) {
-                str = payload1;
-        } else {
-                str = "";
-        }
-        dbus_message_iter_append_basic (&iter,
-                                        DBUS_TYPE_STRING,
-                                        &str);
-        if (payload2 != NULL) {
-                str = payload2;
-        } else {
-                str = "";
-        }
-        dbus_message_iter_append_basic (&iter,
-                                        DBUS_TYPE_STRING,
-                                        &str);
-        dbus_error_init (&error);
-        reply = dbus_connection_send_with_reply_and_block (connection,
-                                                           message,
-                                                           -1,
-                                                           &error);
-
-        dbus_message_unref (message);
-
-        if (dbus_error_is_set (&error)) {
-                g_warning ("%s %s raised: %s\n",
-                           method,
-                           error.name,
-                           error.message);
-                return FALSE;
-        }
-        if (reply != NULL) {
-                dbus_message_unref (reply);
-        }
-        dbus_connection_flush (connection);
-
-        return TRUE;
-}
-static gboolean
-send_dbus_string_method (DBusConnection *connection,
-                         const char     *method,
-                         const char     *payload)
-{
-        DBusError       error;
-        DBusMessage    *message;
-        DBusMessage    *reply;
-        DBusMessageIter iter;
-        const char     *str;
-
-        if (payload != NULL) {
-                str = payload;
-        } else {
-                str = "";
-        }
-
-        g_debug ("GdmProductSlave: Calling %s", method);
-        message = dbus_message_new_method_call (NULL,
-                                                RELAY_SERVER_DBUS_PATH,
-                                                RELAY_SERVER_DBUS_INTERFACE,
-                                                method);
-        if (message == NULL) {
-                g_warning ("Couldn't allocate the D-Bus message");
-                return FALSE;
-        }
-
-        dbus_message_iter_init_append (message, &iter);
-        dbus_message_iter_append_basic (&iter,
-                                        DBUS_TYPE_STRING,
-                                        &str);
-
-        dbus_error_init (&error);
-        reply = dbus_connection_send_with_reply_and_block (connection,
-                                                           message,
-                                                           -1,
-                                                           &error);
-
-        dbus_message_unref (message);
-
-        if (dbus_error_is_set (&error)) {
-                g_warning ("%s %s raised: %s\n",
-                           method,
-                           error.name,
-                           error.message);
-                return FALSE;
-        }
-        if (reply != NULL) {
-                dbus_message_unref (reply);
-        }
-        dbus_connection_flush (connection);
-
-        return TRUE;
-}
-
-static gboolean
-send_dbus_void_method (DBusConnection *connection,
-                       const char     *method)
-{
-        DBusError       error;
-        DBusMessage    *message;
-        DBusMessage    *reply;
-
-        g_debug ("GdmProductSlave: Calling %s", method);
-        message = dbus_message_new_method_call (NULL,
-                                                RELAY_SERVER_DBUS_PATH,
-                                                RELAY_SERVER_DBUS_INTERFACE,
-                                                method);
-        if (message == NULL) {
-                g_warning ("Couldn't allocate the D-Bus message");
-                return FALSE;
-        }
-
-        dbus_error_init (&error);
-        reply = dbus_connection_send_with_reply_and_block (connection,
-                                                           message,
-                                                           -1,
-                                                           &error);
-
-        dbus_message_unref (message);
-
-        if (dbus_error_is_set (&error)) {
-                g_warning ("%s %s raised: %s\n",
-                           method,
-                           error.name,
-                           error.message);
-                return FALSE;
-        }
-        if (reply != NULL) {
-                dbus_message_unref (reply);
-        }
-        dbus_connection_flush (connection);
-
-        return TRUE;
-}
-
-
-static gboolean
-send_dbus_int_method (DBusConnection *connection,
-                      const char     *method,
-                      int             payload)
-{
-        DBusError       error;
-        DBusMessage    *message;
-        DBusMessage    *reply;
-        DBusMessageIter iter;
-
-        g_debug ("GdmSessionWorker: Calling %s", method);
-        message = dbus_message_new_method_call (NULL,
-                                                RELAY_SERVER_DBUS_PATH,
-                                                RELAY_SERVER_DBUS_INTERFACE,
-                                                method);
-        if (message == NULL) {
-                g_warning ("Couldn't allocate the D-Bus message");
-                return FALSE;
-        }
-
-        dbus_message_iter_init_append (message, &iter);
-        dbus_message_iter_append_basic (&iter,
-                                        DBUS_TYPE_INT32,
-                                        &payload);
-
-        dbus_error_init (&error);
-        reply = dbus_connection_send_with_reply_and_block (connection,
-                                                           message,
-                                                           -1,
-                                                           &error);
-        dbus_message_unref (message);
-        if (reply != NULL) {
-                dbus_message_unref (reply);
-        }
-        dbus_connection_flush (connection);
-
-        if (dbus_error_is_set (&error)) {
-                g_debug ("%s %s raised: %s\n",
-                         method,
-                         error.name,
-                         error.message);
-                return FALSE;
-        }
-
-        return TRUE;
-}
-
 static void
 relay_session_started (GdmProductSlave *slave,
                        int              pid)
 {
-        send_dbus_int_method (slave->priv->session_relay_connection,
-                              "SessionStarted",
-                              pid);
+        gdm_dbus_session_call_session_started_sync (slave->priv->session_relay,
+                                                    pid,
+                                                    NULL, NULL);
 }
 
 static void
 relay_session_conversation_started (GdmProductSlave *slave,
                                     const char      *service_name)
 {
-        send_dbus_string_method (slave->priv->session_relay_connection,
-                                 "ConversationStarted", service_name);
+        gdm_dbus_session_call_conversation_started_sync (slave->priv->session_relay,
+                                                         service_name,
+                                                         NULL, NULL);
 }
 
 static void
@@ -327,8 +121,8 @@ disconnect_relay (GdmProductSlave *slave)
 {
         /* drop the connection */
 
-        dbus_connection_close (slave->priv->session_relay_connection);
-        slave->priv->session_relay_connection = NULL;
+        g_dbus_connection_close_sync (slave->priv->session_connection, NULL, NULL);
+        g_clear_object (&slave->priv->session_connection);
 }
 
 static void
@@ -534,28 +328,31 @@ gdm_product_slave_create_server (GdmProductSlave *slave)
 
 static void
 on_session_setup_complete (GdmSession      *session,
+                           const char      *service_name,
                            GdmProductSlave *slave)
 {
-        send_dbus_void_method (slave->priv->session_relay_connection,
-                               "SetupComplete");
+        gdm_dbus_session_call_setup_complete_sync (slave->priv->session_relay,
+                                                   service_name,
+                                                   NULL, NULL);
 }
 
 static void
 on_session_setup_failed (GdmSession      *session,
+                         const char      *service_name,
                          const char      *message,
                          GdmProductSlave *slave)
 {
-        send_dbus_string_method (slave->priv->session_relay_connection,
-                                 "SetupFailed",
-                                 message);
+        gdm_dbus_session_call_setup_failed_sync (slave->priv->session_relay,
+                                                 service_name,
+                                                 message,
+                                                 NULL, NULL);
 }
 
 static void
 on_session_reset_complete (GdmSession      *session,
                            GdmProductSlave *slave)
 {
-        send_dbus_void_method (slave->priv->session_relay_connection,
-                               "ResetComplete");
+        g_debug ("Session reset complete");
 }
 
 static void
@@ -563,9 +360,7 @@ on_session_reset_failed (GdmSession      *session,
                          const char      *message,
                          GdmProductSlave *slave)
 {
-        send_dbus_string_method (slave->priv->session_relay_connection,
-                                 "ResetFailed",
-                                 message);
+        g_debug ("Session reset failed: %s", message);
 }
 
 static void
@@ -573,8 +368,9 @@ on_session_authenticated (GdmSession      *session,
                           const char      *service_name,
                           GdmProductSlave *slave)
 {
-        send_dbus_string_method (slave->priv->session_relay_connection,
-                                 "Authenticated", service_name);
+        gdm_dbus_session_call_authenticated_sync (slave->priv->session_relay,
+                                                  service_name,
+                                                  NULL, NULL);
 }
 
 static void
@@ -583,10 +379,10 @@ on_session_authentication_failed (GdmSession      *session,
                                   const char      *message,
                                   GdmProductSlave *slave)
 {
-        send_dbus_string_string_method (slave->priv->session_relay_connection,
-                                        "AuthenticationFailed",
-                                        service_name,
-                                        message);
+        gdm_dbus_session_call_authentication_failed_sync (slave->priv->session_relay,
+                                                          service_name,
+                                                          message,
+                                                          NULL, NULL);
 }
 
 static void
@@ -594,8 +390,9 @@ on_session_authorized (GdmSession      *session,
                        const char      *service_name,
                        GdmProductSlave *slave)
 {
-        send_dbus_string_method (slave->priv->session_relay_connection,
-                                 "Authorized", service_name);
+        gdm_dbus_session_call_authorized_sync (slave->priv->session_relay,
+                                               service_name,
+                                               NULL, NULL);
 }
 
 static void
@@ -604,10 +401,10 @@ on_session_authorization_failed (GdmSession      *session,
                                  const char      *message,
                                  GdmProductSlave *slave)
 {
-        send_dbus_string_string_method (slave->priv->session_relay_connection,
-                                        "AuthorizationFailed",
-                                        service_name,
-                                        message);
+        gdm_dbus_session_call_authorization_failed_sync (slave->priv->session_relay,
+                                                         service_name,
+                                                         message,
+                                                         NULL, NULL);
 }
 
 static void
@@ -615,8 +412,9 @@ on_session_accredited (GdmSession      *session,
                        const char      *service_name,
                        GdmProductSlave *slave)
 {
-        send_dbus_string_method (slave->priv->session_relay_connection,
-                                 "Accredited", service_name);
+        gdm_dbus_session_call_accredited_sync (slave->priv->session_relay,
+                                               service_name,
+                                               NULL, NULL);
 }
 
 static void
@@ -625,10 +423,10 @@ on_session_accreditation_failed (GdmSession      *session,
                                  const char      *message,
                                  GdmProductSlave *slave)
 {
-        send_dbus_string_string_method (slave->priv->session_relay_connection,
-                                        "AccreditationFailed",
-                                        service_name,
-                                        message);
+        gdm_dbus_session_call_accreditation_failed_sync (slave->priv->session_relay,
+                                                         service_name,
+                                                         message,
+                                                         NULL, NULL);
 }
 
 static void
@@ -636,8 +434,9 @@ on_session_opened (GdmSession      *session,
                    const char      *service_name,
                    GdmProductSlave *slave)
 {
-        send_dbus_string_method (slave->priv->session_relay_connection,
-                                 "SessionOpened", service_name);
+        gdm_dbus_session_call_opened_sync (slave->priv->session_relay,
+                                           service_name,
+                                           NULL, NULL);
 }
 
 static void
@@ -646,10 +445,10 @@ on_session_open_failed (GdmSession      *session,
                         const char      *message,
                         GdmProductSlave *slave)
 {
-        send_dbus_string_string_method (slave->priv->session_relay_connection,
-                                        "SessionOpenFailed",
-                                        service_name,
-                                        message);
+        gdm_dbus_session_call_open_failed_sync (slave->priv->session_relay,
+                                                service_name,
+                                                message,
+                                                NULL, NULL);
 }
 
 static void
@@ -658,10 +457,10 @@ on_session_info (GdmSession      *session,
                  const char      *text,
                  GdmProductSlave *slave)
 {
-        send_dbus_string_string_method (slave->priv->session_relay_connection,
-                                        "Info",
-                                        service_name,
-                                        text);
+        gdm_dbus_session_call_info_sync (slave->priv->session_relay,
+                                         service_name,
+                                         text,
+                                         NULL, NULL);
 }
 
 static void
@@ -670,10 +469,41 @@ on_session_problem (GdmSession      *session,
                     const char      *text,
                     GdmProductSlave *slave)
 {
-        send_dbus_string_string_method (slave->priv->session_relay_connection,
-                                        "Problem",
-                                        service_name,
-                                        text);
+        gdm_dbus_session_call_problem_sync (slave->priv->session_relay,
+                                            service_name,
+                                            text,
+                                            NULL, NULL);
+}
+
+typedef struct {
+        GdmProductSlave *slave;
+        char *service_name;
+} QueryClosure;
+
+static void
+on_session_query_finish (GObject      *object,
+                         GAsyncResult *result,
+                         gpointer      user_data)
+{
+        GVariant *res;
+        const char *text;
+        QueryClosure *closure;
+
+        closure = user_data;
+
+        res = g_dbus_proxy_call_finish (G_DBUS_PROXY (object),
+                                        result, NULL);
+        if (!res)
+                return;
+
+        g_variant_get (res, "(&s)", &text);
+
+        gdm_session_answer_query (GDM_SESSION (closure->slave->priv->session),
+                                  closure->service_name, text);
+
+        g_object_unref (closure->slave);
+        g_free (closure->service_name);
+        g_slice_free (QueryClosure, closure);
 }
 
 static void
@@ -682,9 +512,17 @@ on_session_info_query (GdmSession      *session,
                        const char      *text,
                        GdmProductSlave *slave)
 {
-        send_dbus_string_string_method (slave->priv->session_relay_connection,
-                                        "InfoQuery",
-                                        service_name, text);
+        QueryClosure *closure;
+
+        closure = g_slice_new (QueryClosure);
+        closure->slave = g_object_ref (slave);
+        closure->service_name = g_strdup (service_name);
+
+        gdm_dbus_session_call_info_query (slave->priv->session_relay,
+                                          service_name,
+                                          text,
+                                          NULL,
+                                          on_session_query_finish, closure);
 }
 
 static void
@@ -693,303 +531,141 @@ on_session_secret_info_query (GdmSession      *session,
                               const char      *text,
                               GdmProductSlave *slave)
 {
-        send_dbus_string_string_method (slave->priv->session_relay_connection,
-                                        "SecretInfoQuery",
-                                        service_name,
-                                        text);
-}
-
-static void
-on_relay_setup (GdmProductSlave *slave,
-                DBusMessage     *message)
-{
-        DBusError   error;
-        const char *service_name;
-        dbus_bool_t res;
+        QueryClosure *closure;
 
-        service_name = NULL;
+        closure = g_slice_new (QueryClosure);
+        closure->slave = g_object_ref (slave);
+        closure->service_name = g_strdup (service_name);
 
-        dbus_error_init (&error);
-        res = dbus_message_get_args (message,
-                                     &error,
-                                     DBUS_TYPE_STRING, &service_name,
-                                     DBUS_TYPE_INVALID);
-        if (res) {
-                g_debug ("GdmProductSlave: Relay Setup");
-                gdm_session_setup (GDM_SESSION (slave->priv->session),
-                                   service_name);
-        } else {
-                g_warning ("Unable to get arguments: %s", error.message);
-                dbus_error_free (&error);
-        }
+        gdm_dbus_session_call_secret_info_query (slave->priv->session_relay,
+                                                 service_name,
+                                                 text,
+                                                 NULL,
+                                                 on_session_query_finish, closure);
 }
 
 static void
-on_relay_setup_for_user (GdmProductSlave *slave,
-                         DBusMessage     *message)
+on_relay_setup (GdmDBusSession  *session_relay,
+                const gchar     *service_name,
+                const gchar     *x11_display_name,
+                const gchar     *x11_authority_file,
+                const gchar     *display_device,
+                const gchar     *display_seat,
+                const gchar     *hostname,
+                GdmProductSlave *slave)
 {
-        DBusError   error;
-        const char *service_name;
-        const char *username;
-        dbus_bool_t res;
-
-        username = NULL;
-        service_name = NULL;
-
-        dbus_error_init (&error);
-        res = dbus_message_get_args (message,
-                                     &error,
-                                     DBUS_TYPE_STRING, &service_name,
-                                     DBUS_TYPE_STRING, &username,
-                                     DBUS_TYPE_INVALID);
-        if (res) {
-                g_debug ("GdmProductSlave: Relay SetupForUser");
-                gdm_session_setup_for_user (GDM_SESSION (slave->priv->session),
-                                            service_name,
-                                            username);
-        } else {
-                g_warning ("Unable to get arguments: %s", error.message);
-                dbus_error_free (&error);
-        }
+        g_debug ("GdmProductSlave: Relay Setup");
+        gdm_session_setup (GDM_SESSION (slave->priv->session), service_name);
 }
 
 static void
-on_relay_authenticate (GdmProductSlave *slave,
-                       DBusMessage     *message)
+on_relay_setup_for_user (GdmDBusSession  *session_relay,
+                         const gchar     *service_name,
+                         const gchar     *user_name,
+                         const gchar     *x11_display_name,
+                         const gchar     *x11_authority_file,
+                         const gchar     *display_device,
+                         const gchar     *display_seat,
+                         const gchar     *hostname,
+                         GdmProductSlave *slave)
 {
-        DBusError   error;
-        char *service_name;
-        dbus_bool_t res;
-
-        dbus_error_init (&error);
-        res = dbus_message_get_args (message,
-                                     &error,
-                                     DBUS_TYPE_STRING, &service_name,
-                                     DBUS_TYPE_INVALID);
-        if (res) {
-                g_debug ("GdmProductSlave: Relay Authenticate");
-                gdm_session_authenticate (GDM_SESSION (slave->priv->session), service_name);
-        } else {
-                g_warning ("Unable to get arguments: %s", error.message);
-                dbus_error_free (&error);
-        }
-        dbus_error_free (&error);
+        g_debug ("GdmProductSlave: Relay SetupForUser");
+        gdm_session_setup_for_user (GDM_SESSION (slave->priv->session),
+                                    service_name, user_name);
 }
 
 static void
-on_relay_authorize (GdmProductSlave *slave,
-                    DBusMessage     *message)
+on_relay_authenticate (GdmDBusSession  *session_relay,
+                       const gchar     *service_name,
+                       GdmProductSlave *slave)
 {
-        DBusError   error;
-        char *service_name;
-        dbus_bool_t res;
-
-        dbus_error_init (&error);
-        res = dbus_message_get_args (message,
-                                     &error,
-                                     DBUS_TYPE_STRING, &service_name,
-                                     DBUS_TYPE_INVALID);
-        if (res) {
-                g_debug ("GdmProductSlave: Relay Authorize");
-                gdm_session_authorize (GDM_SESSION (slave->priv->session), service_name);
-        } else {
-                g_warning ("Unable to get arguments: %s", error.message);
-                dbus_error_free (&error);
-        }
-        dbus_error_free (&error);
+        g_debug ("GdmProductSlave: Relay Authenticate");
+        gdm_session_authenticate (GDM_SESSION (slave->priv->session), service_name);
 }
 
 static void
-on_relay_establish_credentials (GdmProductSlave *slave,
-                                DBusMessage     *message)
+on_relay_authorize (GdmDBusSession  *session_relay,
+                    const gchar     *service_name,
+                    GdmProductSlave *slave)
 {
-        DBusError   error;
-        char *service_name;
-        dbus_bool_t res;
-
-        dbus_error_init (&error);
-        res = dbus_message_get_args (message,
-                                     &error,
-                                     DBUS_TYPE_STRING, &service_name,
-                                     DBUS_TYPE_INVALID);
-        if (res) {
-                g_debug ("GdmProductSlave: Relay EstablishCredentials");
-                gdm_session_accredit (GDM_SESSION (slave->priv->session), service_name, GDM_SESSION_CRED_ESTABLISH);
-        } else {
-                g_warning ("Unable to get arguments: %s", error.message);
-                dbus_error_free (&error);
-        }
-        dbus_error_free (&error);
+        g_debug ("GdmProductSlave: Relay Authorize");
+        gdm_session_authorize (GDM_SESSION (slave->priv->session), service_name);
 }
 
 static void
-on_relay_refresh_credentials (GdmProductSlave *slave,
-                              DBusMessage     *message)
+on_relay_establish_credentials (GdmDBusSession  *session_relay,
+                                const gchar     *service_name,
+                                GdmProductSlave *slave)
 {
-        DBusError   error;
-        char *service_name;
-        dbus_bool_t res;
-
-        dbus_error_init (&error);
-        res = dbus_message_get_args (message,
-                                     &error,
-                                     DBUS_TYPE_STRING, &service_name,
-                                     DBUS_TYPE_INVALID);
-        if (res) {
-                g_debug ("GdmProductSlave: Relay RefreshCredentials");
-                gdm_session_accredit (GDM_SESSION (slave->priv->session), service_name, GDM_SESSION_CRED_REFRESH);
-        } else {
-                g_warning ("Unable to get arguments: %s", error.message);
-                dbus_error_free (&error);
-        }
-        dbus_error_free (&error);
+        g_debug ("GdmProductSlave: Relay Establish Credentials");
+        gdm_session_accredit (GDM_SESSION (slave->priv->session), service_name, GDM_SESSION_CRED_ESTABLISH);
 }
 
 static void
-on_relay_answer_query (GdmProductSlave *slave,
-                       DBusMessage     *message)
+on_relay_refresh_credentials (GdmDBusSession  *session_relay,
+                              const gchar     *service_name,
+                              GdmProductSlave *slave)
 {
-        DBusError   error;
-        const char *text;
-        const char *service_name;
-        dbus_bool_t res;
-
-        dbus_error_init (&error);
-        res = dbus_message_get_args (message,
-                                     &error,
-                                     DBUS_TYPE_STRING, &service_name,
-                                     DBUS_TYPE_STRING, &text,
-                                     DBUS_TYPE_INVALID);
-        if (res) {
-                g_debug ("GdmProductSlave: Relay AnswerQuery");
-                gdm_session_answer_query (GDM_SESSION (slave->priv->session), service_name, text);
-        } else {
-                g_warning ("Unable to get arguments: %s", error.message);
-                dbus_error_free (&error);
-        }
+        g_debug ("GdmProductSlave: Relay Refresh Credentials");
+        gdm_session_accredit (GDM_SESSION (slave->priv->session), service_name, GDM_SESSION_CRED_REFRESH);
 }
 
 static void
-on_relay_session_selected (GdmProductSlave *slave,
-                           DBusMessage     *message)
+on_relay_set_session_name (GdmDBusSession  *session_relay,
+                           const gchar     *session_name,
+                           GdmProductSlave *slave)
 {
-        DBusError   error;
-        const char *text;
-        dbus_bool_t res;
-
-        dbus_error_init (&error);
-        res = dbus_message_get_args (message,
-                                     &error,
-                                     DBUS_TYPE_STRING, &text,
-                                     DBUS_TYPE_INVALID);
-        if (res) {
-                g_debug ("GdmProductSlave: Session selected %s", text);
-                gdm_session_select_session (GDM_SESSION (slave->priv->session), text);
-        } else {
-                g_warning ("Unable to get arguments: %s", error.message);
-                dbus_error_free (&error);
-        }
+        g_debug ("GdmProductSlave: Relay Set Session Name");
+        gdm_session_select_session (GDM_SESSION (slave->priv->session), session_name);
 }
 
 static void
-on_relay_language_selected (GdmProductSlave *slave,
-                            DBusMessage     *message)
+on_relay_set_language_name (GdmDBusSession  *session_relay,
+                            const gchar     *language_name,
+                            GdmProductSlave *slave)
 {
-        DBusError   error;
-        const char *text;
-        dbus_bool_t res;
-
-        dbus_error_init (&error);
-        res = dbus_message_get_args (message,
-                                     &error,
-                                     DBUS_TYPE_STRING, &text,
-                                     DBUS_TYPE_INVALID);
-        if (res) {
-                g_debug ("GdmProductSlave: Language selected %s", text);
-                gdm_session_select_language (GDM_SESSION (slave->priv->session), text);
-        } else {
-                g_warning ("Unable to get arguments: %s", error.message);
-                dbus_error_free (&error);
-        }
+        g_debug ("GdmProductSlave: Relay Set Language Name");
+        gdm_session_select_language (GDM_SESSION (slave->priv->session), language_name);
 }
 
 static void
-on_relay_user_selected (GdmProductSlave *slave,
-                        DBusMessage     *message)
+on_relay_set_user_name (GdmDBusSession  *session_relay,
+                        const gchar     *user_name,
+                        GdmProductSlave *slave)
 {
-        g_debug ("GdmProductSlave: Greeter user selected");
+        g_debug ("GdmProductSlave: Relay Set User Name");
+
+        /* FIXME: and then? */
 }
 
 static void
-on_relay_start_conversation (GdmProductSlave *slave,
-                             DBusMessage     *message)
+on_relay_start_conversation (GdmDBusSession  *session_relay,
+                             const gchar     *service_name,
+                             GdmProductSlave *slave)
 {
-        DBusError   error;
-        char *service_name;
-        dbus_bool_t res;
-
-        dbus_error_init (&error);
-        res = dbus_message_get_args (message,
-                                     &error,
-                                     DBUS_TYPE_STRING, &service_name,
-                                     DBUS_TYPE_INVALID);
-        if (res) {
-                g_debug ("GdmProductSlave: Started conversation with %s service", service_name);
-                gdm_session_start_conversation (GDM_SESSION (slave->priv->session),
-                                                service_name);
-        } else {
-                g_warning ("Unable to get arguments: %s", error.message);
-        }
-
-        dbus_error_free (&error);
+        g_debug ("GdmProductSlave: Started Conversation with %s", service_name);
+        gdm_session_start_conversation (GDM_SESSION (slave->priv->session), service_name);
 }
 
 static void
-on_relay_open_session (GdmProductSlave *slave,
-                        DBusMessage     *message)
+on_relay_open_session (GdmDBusSession  *session_relay,
+                       const gchar     *service_name,
+                       GdmProductSlave *slave)
 {
-        DBusError   error;
-        const char *text;
-        dbus_bool_t res;
-
-        dbus_error_init (&error);
-        res = dbus_message_get_args (message,
-                                     &error,
-                                     DBUS_TYPE_STRING, &text,
-                                     DBUS_TYPE_INVALID);
-        if (res) {
-                g_debug ("GdmProductSlave: open session %s", text);
-                gdm_session_open_session (GDM_SESSION (slave->priv->session),
-                                          text);
-        } else {
-                g_warning ("Unable to get arguments: %s", error.message);
-                dbus_error_free (&error);
-        }
+        g_debug ("GdmProductSlave: open session for %s", service_name);
+        gdm_session_open_session (GDM_SESSION (slave->priv->session), service_name);
 }
 
 static void
-on_relay_start_session (GdmProductSlave *slave,
-                        DBusMessage     *message)
+on_relay_start_session (GdmDBusSession  *session_relay,
+                        const gchar     *service_name,
+                        GdmProductSlave *slave)
 {
-        DBusError   error;
-        const char *service_name;
-        dbus_bool_t res;
-
-        dbus_error_init (&error);
+        g_debug ("GdmProductSlave: Relay StartSession");
 
-        res = dbus_message_get_args (message,
-                                     &error,
-                                     DBUS_TYPE_STRING, &service_name,
-                                     DBUS_TYPE_INVALID);
-        if (res) {
-                g_debug ("GdmProductSlave: Relay StartSession");
-                g_free (slave->priv->start_session_service_name);
-                slave->priv->start_session_service_name = g_strdup (service_name);
-                gdm_product_slave_create_server (slave);
-        } else {
-                g_warning ("Unable to get arguments: %s", error.message);
-                dbus_error_free (&error);
-        }
+        g_free (slave->priv->start_session_service_name);
+        slave->priv->start_session_service_name = g_strdup (service_name);
+        gdm_product_slave_create_server (slave);
 }
 
 static void
@@ -1114,8 +790,8 @@ create_new_session (GdmProductSlave *slave)
 }
 
 static void
-on_relay_cancelled (GdmProductSlave *slave,
-                    DBusMessage     *message)
+on_relay_cancelled (GdmDBusSession  *session_relay,
+                    GdmProductSlave *slave)
 {
         g_debug ("GdmProductSlave: Relay cancelled");
 
@@ -1136,140 +812,78 @@ get_relay_address (GdmProductSlave *slave)
 
         text = NULL;
         error = NULL;
-        res = dbus_g_proxy_call (slave->priv->product_display_proxy,
-                                 "GetRelayAddress",
-                                 &error,
-                                 G_TYPE_INVALID,
-                                 G_TYPE_STRING, &text,
-                                 G_TYPE_INVALID);
+        res = gdm_dbus_product_display_call_get_relay_address_sync (slave->priv->product_display,
+                                                                    &text,
+                                                                    NULL, &error);
+
         if (! res) {
                 g_warning ("Unable to get relay address: %s", error->message);
                 g_error_free (error);
         } else {
                 g_free (slave->priv->relay_address);
-                slave->priv->relay_address = g_strdup (text);
+                slave->priv->relay_address = text;
                 g_debug ("GdmProductSlave: Got relay address: %s", slave->priv->relay_address);
         }
-
-        g_free (text);
-}
-
-static DBusHandlerResult
-relay_dbus_handle_message (DBusConnection *connection,
-                           DBusMessage    *message,
-                           void           *user_data,
-                           dbus_bool_t     local_interface)
-{
-        GdmProductSlave *slave = GDM_PRODUCT_SLAVE (user_data);
-
-#if 0
-        g_message ("obj_path=%s interface=%s method=%s destination=%s",
-                   dbus_message_get_path (message),
-                   dbus_message_get_interface (message),
-                   dbus_message_get_member (message),
-                   dbus_message_get_destination (message));
-#endif
-
-        g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
-        g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
-
-        if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "Setup")) {
-                on_relay_setup (slave, message);
-        } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "SetupForUser")) {
-                on_relay_setup_for_user (slave, message);
-        } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "Authenticate")) {
-                on_relay_authenticate (slave, message);
-        } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "Authorize")) {
-                on_relay_authorize (slave, message);
-        } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "EstablishCredentials")) {
-                on_relay_establish_credentials (slave, message);
-        } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "RefreshCredentials")) {
-                on_relay_refresh_credentials (slave, message);
-        } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "AnswerQuery")) {
-                on_relay_answer_query (slave, message);
-        } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "SessionSelected")) {
-                on_relay_session_selected (slave, message);
-        } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "LanguageSelected")) {
-                on_relay_language_selected (slave, message);
-        } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "UserSelected")) {
-                on_relay_user_selected (slave, message);
-        } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "OpenSession")) {
-                on_relay_open_session (slave, message);
-        } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "StartSession")) {
-                on_relay_start_session (slave, message);
-        } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "StartConversation")) {
-                on_relay_start_conversation (slave, message);
-        } else if (dbus_message_is_signal (message, RELAY_SERVER_DBUS_INTERFACE, "Cancelled")) {
-                on_relay_cancelled (slave, message);
-        } else {
-                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-        }
-
-        return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-static DBusHandlerResult
-relay_dbus_filter_function (DBusConnection *connection,
-                            DBusMessage    *message,
-                            void           *user_data)
-{
-        GdmProductSlave *slave = GDM_PRODUCT_SLAVE (user_data);
-        const char      *path;
-
-        path = dbus_message_get_path (message);
-
-        g_debug ("GdmProductSlave: obj_path=%s interface=%s method=%s",
-                 dbus_message_get_path (message),
-                 dbus_message_get_interface (message),
-                 dbus_message_get_member (message));
-
-        if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")
-            && strcmp (path, DBUS_PATH_LOCAL) == 0) {
-
-                g_debug ("GdmProductSlave: Got disconnected from the server");
-
-                dbus_connection_unref (connection);
-                slave->priv->connection = NULL;
-
-        } else if (dbus_message_is_signal (message,
-                                           DBUS_INTERFACE_DBUS,
-                                           "NameOwnerChanged")) {
-                g_debug ("GdmProductSlave: Name owner changed?");
-        } else {
-                return relay_dbus_handle_message (connection, message, user_data, FALSE);
-        }
-
-        return DBUS_HANDLER_RESULT_HANDLED;
 }
 
 static gboolean
 connect_to_session_relay (GdmProductSlave *slave)
 {
-        DBusError       error;
+        GError *error = NULL;
 
         get_relay_address (slave);
 
         g_debug ("GdmProductSlave: connecting to session relay address: %s", slave->priv->relay_address);
 
-        dbus_error_init (&error);
-        slave->priv->session_relay_connection = dbus_connection_open_private (slave->priv->relay_address, &error);
-        if (slave->priv->session_relay_connection == NULL) {
-                if (dbus_error_is_set (&error)) {
-                        g_warning ("error opening connection: %s", error.message);
-                        dbus_error_free (&error);
-                } else {
-                        g_warning ("Unable to open connection");
-                }
-                exit (1);
+        slave->priv->session_connection = g_dbus_connection_new_for_address_sync (slave->priv->relay_address,
+                                                                                  G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
+                                                                                  NULL, NULL, &error);
+        if (!slave->priv->session_connection) {
+                g_warning ("Unable to connect to session relay: %s", error->message);
+
+                g_clear_error (&error);
+                return FALSE;
         }
 
-        dbus_connection_setup_with_g_main (slave->priv->session_relay_connection, NULL);
-        dbus_connection_set_exit_on_disconnect (slave->priv->session_relay_connection, FALSE);
+        slave->priv->session_relay = GDM_DBUS_SESSION (gdm_dbus_session_proxy_new_sync (slave->priv->session_connection,
+                                                                                        G_DBUS_PROXY_FLAGS_NONE,
+                                                                                        NULL, /* dbus name */
+                                                                                        "/org/gnome/DisplayManager/Session",
+                                                                                        NULL, &error));
+        if (!slave->priv->session_relay) {
+                g_warning ("Unable to construct session relay: %s", error->message);
 
-        dbus_connection_add_filter (slave->priv->session_relay_connection,
-                                    relay_dbus_filter_function,
-                                    slave,
-                                    NULL);
+                g_clear_object (&slave->priv->session_connection);
+                g_clear_error (&error);
+                return FALSE;
+        }
+
+        g_signal_connect_object (slave->priv->session_relay, "setup",
+                                 G_CALLBACK (on_relay_setup), slave, 0);
+        g_signal_connect_object (slave->priv->session_relay, "setup-for-user",
+                                 G_CALLBACK (on_relay_setup_for_user), slave, 0);
+        g_signal_connect_object (slave->priv->session_relay, "authenticate",
+                                 G_CALLBACK (on_relay_authenticate), slave, 0);
+        g_signal_connect_object (slave->priv->session_relay, "authorize",
+                                 G_CALLBACK (on_relay_authorize), slave, 0);
+        g_signal_connect_object (slave->priv->session_relay, "establish-credentials",
+                                 G_CALLBACK (on_relay_establish_credentials), slave, 0);
+        g_signal_connect_object (slave->priv->session_relay, "refresh-credentials",
+                                 G_CALLBACK (on_relay_refresh_credentials), slave, 0);
+        g_signal_connect_object (slave->priv->session_relay, "set-language-name",
+                                 G_CALLBACK (on_relay_set_language_name), slave, 0);
+        g_signal_connect_object (slave->priv->session_relay, "set-session-name",
+                                 G_CALLBACK (on_relay_set_session_name), slave, 0);
+        g_signal_connect_object (slave->priv->session_relay, "set-user-name",
+                                 G_CALLBACK (on_relay_set_user_name), slave, 0);
+        g_signal_connect_object (slave->priv->session_relay, "start-conversation",
+                                 G_CALLBACK (on_relay_start_conversation), slave, 0);
+        g_signal_connect_object (slave->priv->session_relay, "open-session",
+                                 G_CALLBACK (on_relay_open_session), slave, 0);
+        g_signal_connect_object (slave->priv->session_relay, "start-session",
+                                 G_CALLBACK (on_relay_start_session), slave, 0);
+        g_signal_connect_object (slave->priv->session_relay, "cancelled",
+                                 G_CALLBACK (on_relay_cancelled), slave, 0);
 
         return TRUE;
 }
@@ -1277,11 +891,13 @@ connect_to_session_relay (GdmProductSlave *slave)
 static gboolean
 gdm_product_slave_start (GdmSlave *slave)
 {
+        GdmProductSlave *self;
         gboolean ret;
         GError  *error;
         char    *display_id;
 
         ret = FALSE;
+        self = GDM_PRODUCT_SLAVE (slave);
 
         GDM_SLAVE_CLASS (gdm_product_slave_parent_class)->start (slave);
 
@@ -1290,8 +906,8 @@ gdm_product_slave_start (GdmSlave *slave)
                       NULL);
 
         error = NULL;
-        GDM_PRODUCT_SLAVE (slave)->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-        if (GDM_PRODUCT_SLAVE (slave)->priv->connection == NULL) {
+        self->priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+        if (self->priv->connection == NULL) {
                 if (error != NULL) {
                         g_critical ("error getting system bus: %s", error->message);
                         g_error_free (error);
@@ -1300,12 +916,13 @@ gdm_product_slave_start (GdmSlave *slave)
         }
 
         error = NULL;
-        GDM_PRODUCT_SLAVE (slave)->priv->product_display_proxy = dbus_g_proxy_new_for_name_owner (GDM_PRODUCT_SLAVE (slave)->priv->connection,
-                                                                                                  GDM_DBUS_NAME,
-                                                                                                  display_id,
-                                                                                                  GDM_DBUS_PRODUCT_DISPLAY_INTERFACE,
-                                                                                                  &error);
-        if (GDM_PRODUCT_SLAVE (slave)->priv->product_display_proxy == NULL) {
+        self->priv->product_display = GDM_DBUS_PRODUCT_DISPLAY (
+                gdm_dbus_product_display_proxy_new_sync (self->priv->connection,
+                                                         G_DBUS_PROXY_FLAGS_NONE,
+                                                         GDM_DBUS_NAME,
+                                                         display_id,
+                                                         NULL, &error));
+        if (self->priv->product_display == NULL) {
                 if (error != NULL) {
                         g_warning ("Failed to create display proxy %s: %s", display_id, error->message);
                         g_error_free (error);
@@ -1315,9 +932,8 @@ gdm_product_slave_start (GdmSlave *slave)
                 goto out;
         }
 
-        create_new_session (GDM_PRODUCT_SLAVE (slave));
-
-        connect_to_session_relay (GDM_PRODUCT_SLAVE (slave));
+        create_new_session (self);
+        connect_to_session_relay (self);
 
         ret = TRUE;
 
@@ -1330,25 +946,25 @@ gdm_product_slave_start (GdmSlave *slave)
 static gboolean
 gdm_product_slave_stop (GdmSlave *slave)
 {
+        GdmProductSlave *self = GDM_PRODUCT_SLAVE (slave);
+
         g_debug ("GdmProductSlave: Stopping product_slave");
 
         GDM_SLAVE_CLASS (gdm_product_slave_parent_class)->stop (slave);
 
-        if (GDM_PRODUCT_SLAVE (slave)->priv->session != NULL) {
-                gdm_session_close (GDM_SESSION (GDM_PRODUCT_SLAVE (slave)->priv->session));
-                g_object_unref (GDM_PRODUCT_SLAVE (slave)->priv->session);
-                GDM_PRODUCT_SLAVE (slave)->priv->session = NULL;
+        if (self->priv->session != NULL) {
+                gdm_session_close (GDM_SESSION (self->priv->session));
+                g_clear_object (&self->priv->session);
         }
 
-        if (GDM_PRODUCT_SLAVE (slave)->priv->server != NULL) {
-                gdm_server_stop (GDM_PRODUCT_SLAVE (slave)->priv->server);
-                g_object_unref (GDM_PRODUCT_SLAVE (slave)->priv->server);
-                GDM_PRODUCT_SLAVE (slave)->priv->server = NULL;
+        if (self->priv->server != NULL) {
+                gdm_server_stop (self->priv->server);
+                g_clear_object (&self->priv->server);
         }
 
-        if (GDM_PRODUCT_SLAVE (slave)->priv->product_display_proxy != NULL) {
-                g_object_unref (GDM_PRODUCT_SLAVE (slave)->priv->product_display_proxy);
-        }
+        g_clear_object (&self->priv->product_display);
+        g_clear_object (&self->priv->session_connection);
+        g_clear_object (&self->priv->session_relay);
 
         return TRUE;
 }
@@ -1365,8 +981,6 @@ gdm_product_slave_class_init (GdmProductSlaveClass *klass)
         slave_class->stop = gdm_product_slave_stop;
 
         g_type_class_add_private (klass, sizeof (GdmProductSlavePrivate));
-
-        dbus_g_object_type_install_info (GDM_TYPE_PRODUCT_SLAVE, &dbus_glib_gdm_product_slave_object_info);
 }
 
 static void
diff --git a/daemon/gdm-session.xml b/daemon/gdm-session.xml
new file mode 100644
index 0000000..ac0d2e9
--- /dev/null
+++ b/daemon/gdm-session.xml
@@ -0,0 +1,160 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
+<node name="/org/gnome/DisplayManager/Session">
+  <!-- methods are called by the child (product slave or session worker),
+       signals are emitted by the parent (factory slave or simple slave) -->
+  <interface name="org.gnome.DisplayManager.Session">
+    <!-- only used by SessionRelay (factory slave to product slave) -->
+    <method name="ConversationStarted">
+      <arg name="service_name" direction="in" type="s"/>
+    </method>
+    <method name="ServiceUnavailable">
+      <arg name="message" direction="in" type="s"/>
+    </method>
+    <signal name="StartConversation">
+      <!-- XXX fold in Setup? -->
+      <arg name="service_name" type="s"/>
+    </signal>
+    <signal name="Close"/>
+    <signal name="Cancelled"/> <!-- XXX: fold in Reset? -->
+
+    <!-- only used by SessionDirect (simple slave to session worker) -->
+    <method name="CancelPendingQuery">
+      <!-- XXX why isn't this used by SessionRelay? -->
+    </method>
+    <signal name="StartProgram">
+      <arg name="command" type="s"/>
+    </signal>
+
+    <!-- used by both of them -->
+    <method name="SetupComplete">
+      <arg name="service_name" direction="in" type="s"/>
+    </method>
+    <method name="SetupFailed">
+      <arg name="service_name" direction="in" type="s"/>
+      <arg name="message" direction="in" type="s"/>
+    </method>
+    <method name="Authenticated">
+      <arg name="service_name" direction="in" type="s"/>
+    </method>
+    <method name="AuthenticationFailed">
+      <arg name="service_name" direction="in" type="s"/>
+      <arg name="message" direction="in" type="s"/>
+    </method>
+    <method name="Authorized">
+      <arg name="service_name" direction="in" type="s"/>
+    </method>
+    <method name="AuthorizationFailed">
+      <arg name="service_name" direction="in" type="s"/>
+      <arg name="message" direction="in" type="s"/>
+    </method>
+    <method name="Accredited">
+      <arg name="service_name" direction="in" type="s"/>
+    </method>
+    <method name="AccreditationFailed">
+      <arg name="service_name" direction="in" type="s"/>
+      <arg name="message" direction="in" type="s"/>
+    </method>
+    <method name="InfoQuery">
+      <arg name="service_name" direction="in" type="s"/>
+      <arg name="text" direction="in" type="s"/>
+      <arg name="answer" direction="out" type="s"/>
+    </method>
+    <method name="SecretInfoQuery">
+      <arg name="service_name" direction="in" type="s"/>
+      <arg name="text" direction="in" type="s"/>
+      <arg name="answer" direction="out" type="s"/>
+    </method>
+    <method name="Info">
+      <arg name="service_name" direction="in" type="s"/>
+      <arg name="text" direction="in" type="s"/>
+    </method>
+    <method name="Problem">
+      <arg name="service_name" direction="in" type="s"/>
+      <arg name="text" direction="in" type="s"/>
+    </method>
+    <method name="Opened">
+      <arg name="service_name" direction="in" type="s"/>
+    </method>
+    <method name="OpenFailed">
+      <arg name="service_name" direction="in" type="s"/>
+      <arg name="message" direction="in" type="s"/>
+    </method>
+    <method name="SessionStarted">
+      <arg name="pid" direction="in" type="i"/>
+    </method>
+    <method name="SessionExited">
+      <arg name="service_name" direction="in" type="s"/>
+      <!-- This is a combination of exit code and exit
+           signal. Use macros in sys/wait.h to handle it. -->
+      <arg name="status" direction="in" type="i"/>
+    </method>
+
+    <signal name="Reset" />
+    <signal name="Setup">
+      <!-- Only service_name is used by SessionRelay -->
+      <arg name="service_name" type="s"/>
+      <arg name="x11_display_name" type="s"/>
+      <arg name="x11_authority_file" type="s"/>
+      <arg name="display_device" type="s"/>
+      <arg name="display_seat" type="s"/>
+      <arg name="hostname" type="s"/>
+    </signal>
+    <signal name="SetupForUser">
+      <!-- Only service_name and username are used by SessionRelay -->
+      <arg name="service_name" type="s"/>
+      <arg name="user_name" type="s"/>
+      <arg name="x11_display_name" type="s"/>
+      <arg name="x11_authority_file" type="s"/>
+      <arg name="display_device" type="s"/>
+      <arg name="display_seat" type="s"/>
+      <arg name="hostname" type="s"/>
+    </signal>
+    <signal name="SetupForProgram">
+      <!-- not used by SessionRelay (but kept here because it's near
+	   the other Setup* signals -->
+      <arg name="service_name" type="s"/>
+      <arg name="x11_display_name" type="s"/>
+      <arg name="x11_authority_file" type="s"/>
+      <arg name="display_device" type="s"/>
+      <arg name="display_seat" type="s"/>
+      <arg name="hostname" type="s"/>
+      <arg name="log_file" type="s"/>
+    </signal>
+    <signal name="Authenticate">
+      <arg name="service_name" type="s"/>
+    </signal>
+    <signal name="Authorize">
+      <arg name="service_name" type="s"/>
+    </signal>
+    <signal name="EstablishCredentials">
+      <arg name="service_name" type="s"/>
+    </signal>
+    <signal name="RefreshCredentials">
+      <arg name="service_name" type="s"/>
+    </signal>
+    <signal name="OpenSession">
+      <arg name="service_name" type="s"/>
+    </signal>
+    <signal name="StartSession">
+      <arg name="service_name" type="s"/>
+    </signal>
+    <signal name="SetEnvironmentVariable">
+      <arg name="name" type="s" />
+      <arg name="value" type="s" />
+    </signal>
+    <signal name="SetLanguageName">
+      <arg name="language" type="s" />
+    </signal>
+    <signal name="SetSessionName">
+      <arg name="session_name" type="s" />
+    </signal>
+    <signal name="SetSessionType">
+      <!-- XXX session type? -->
+      <arg name="session_type" type="s" />
+    </signal>
+    <signal name="SetUserName">
+      <!-- XXX why isn't this used by SessionDirect? -->
+      <arg name="user_name" type="s" />
+    </signal>
+  </interface>
+</node>



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