[gdm/wip/initial-setup2] initial-setup: port to libgdmgreeter



commit be2f86a4db3c25dd6df106dfdb98171eae745397
Author: Ray Strode <rstrode redhat com>
Date:   Tue Apr 10 16:10:35 2012 -0400

    initial-setup: port to libgdmgreeter
    
    This gives us better type safety and a slightly more
    convenient api.

 gui/initial-setup/Makefile.am         |    6 ++-
 gui/initial-setup/gdm-initial-setup.c |   75 ++++++--------------------------
 2 files changed, 18 insertions(+), 63 deletions(-)
---
diff --git a/gui/initial-setup/Makefile.am b/gui/initial-setup/Makefile.am
index 0348e22..58b8397 100644
--- a/gui/initial-setup/Makefile.am
+++ b/gui/initial-setup/Makefile.am
@@ -8,9 +8,10 @@ AM_CPPFLAGS = \
 	$(INITIAL_SETUP_CFLAGS) \
 	-DUIDIR="\"$(uidir)\"" \
 	-DGNOMECC_DATA_DIR="\"$(datadir)/gnome-control-center\"" \
-	-DDATADIR="\"$(datadir)/gnome-control-center/ui/datetime\""
+	-DDATADIR="\"$(datadir)/gnome-control-center/ui/datetime\"" \
+	-I../libgdmgreeter
 
-LIBS = $(INITIAL_SETUP_LIBS) -lm
+LIBS = $(INITIAL_SETUP_LIBS) -lm ../libgdmgreeter/libgdmgreeter.la
 
 libexec_PROGRAMS = gdm-initial-setup
 
@@ -30,6 +31,7 @@ gdm_initial_setup_SOURCES =	\
 	cc-timezone-map.c cc-timezone-map.h \
 	um-utils.c um-utils.h \
 	tz.c tz.h \
+	../libgdmgreeter/gdm-greeter-client.c ../libgdmgreeter/gdm-greeter-client.h \
 	$(dbus_built_sources)
 
 ui_DATA = \
diff --git a/gui/initial-setup/gdm-initial-setup.c b/gui/initial-setup/gdm-initial-setup.c
index c1e7c3a..8f101dd 100644
--- a/gui/initial-setup/gdm-initial-setup.c
+++ b/gui/initial-setup/gdm-initial-setup.c
@@ -19,6 +19,7 @@
 #include "cc-timezone-map.h"
 #include "timedated.h"
 #include "um-utils.h"
+#include "gdm-greeter-client.h"
 
 #define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
 #include <libgweather/location-entry.h>
@@ -35,7 +36,7 @@ typedef struct {
         GtkBuilder *builder;
         GtkAssistant *assistant;
 
-        GDBusConnection *slave_connection;
+        GdmGreeterClient *greeter_client;
 
         /* network data */
         NMClient *nm_client;
@@ -1676,42 +1677,27 @@ copy_account_data (SetupData *setup)
 static void
 connect_to_slave (SetupData *setup)
 {
-        GDBusConnection *connection;
-        const gchar *address;
-        GError *error;
+        GError *error = NULL;
+        gboolean res;
 
-        address = g_getenv ("GDM_GREETER_DBUS_ADDRESS");
+        setup->greeter_client = gdm_greeter_client_new ();
 
-        if (address == NULL) {
-                g_warning ("GDM_GREETER_DBUS_ADDRESS not set; not initiating autologin");
-                return;
-        }
+        res = gdm_greeter_client_open_connection (setup->greeter_client, &error);
 
-        error = NULL;
-        connection = g_dbus_connection_new_for_address_sync (address,
-                                                             G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
-                                                             NULL,
-                                                             NULL,
-                                                             &error);
-        if (connection == NULL) {
-                g_warning ("Failed to create D-Bus connection for address '%s' (%s); not initiating autologin", address, error->message);
+        if (!res) {
+                g_warning ("Failed to open connection to slave: %s", error->message);
                 g_error_free (error);
+                g_clear_object (&setup->greeter_client);
                 return;
         }
-
-        g_dbus_connection_set_exit_on_close (connection, TRUE);
-
-        setup->slave_connection = connection;
 }
 
 static void
 begin_autologin (SetupData *setup)
 {
-        GError *error;
         const gchar *username;
-        GVariant *ret;
 
-        if (setup->slave_connection == NULL) {
+        if (setup->greeter_client == NULL) {
                 g_warning ("No slave connection; not initiating autologin");
                 return;
         }
@@ -1725,43 +1711,10 @@ begin_autologin (SetupData *setup)
 
         g_debug ("Initiating autologin for %s", username);
 
-        ret = g_dbus_connection_call_sync (setup->slave_connection,
-                                           NULL,
-                                           "/org/gnome/DisplayManager/GreeterServer",
-                                           "org.gnome.DisplayManager.GreeterServer",
-                                           "BeginAutoLogin",
-                                           g_variant_new ("(s)", username),
-                                           NULL, /* no reply checking */
-                                           G_DBUS_CALL_FLAGS_NONE,
-                                           G_MAXINT,
-                                           NULL,
-                                           &error);
-        if (ret == NULL) {
-                g_warning ("Calling org.gnome.DisplayManager.GreeterServer.BeginAutoLogin failed: %s", error->message);
-                g_error_free (error);
-                return;
-        }
-
-        g_variant_unref (ret);
-
-        ret = g_dbus_connection_call_sync (setup->slave_connection,
-                                           NULL,
-                                           "/org/gnome/DisplayManager/GreeterServer",
-                                           "org.gnome.DisplayManager.GreeterServer",
-                                           "StartSessionWhenReady",
-                                           g_variant_new ("(b)", TRUE),
-                                           NULL, /* no reply checking */
-                                           G_DBUS_CALL_FLAGS_NONE,
-                                           G_MAXINT,
-                                           NULL,
-                                           &error);
-        if (ret == NULL) {
-                g_warning ("Calling org.gnome.DisplayManager.GreeterServer.StartSessionWhenReady failed: %s", error->message);
-                g_error_free (error);
-                return;
-        }
-
-        g_variant_unref (ret);
+        gdm_greeter_client_call_begin_auto_login (setup->greeter_client, username);
+        gdm_greeter_client_call_start_session_when_ready (setup->greeter_client,
+                                                          "gdm-autologin",
+                                                          TRUE);
 }
 
 static void



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