[gdm/wip/slave-connection: 27/27] libgdmgreeter: generate implementation
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/wip/slave-connection: 27/27] libgdmgreeter: generate implementation
- Date: Sun, 8 Jul 2012 00:39:13 +0000 (UTC)
commit 06dc6ff6284c33b345822d3162df2c77d3607dd1
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Sun May 20 01:13:00 2012 +0200
libgdmgreeter: generate implementation
GdmGreeterClient is the interface greeters use to communicate
with their respective slaves.
The actual GdmGreeterClient code is a just a thin wrapper around
some DBus calls. Something very similar could be automatically
generated using gdbus-codegen.
This commit replaces the wrapper code with generated code, and
adds two small functions for creating servers, one for actual
greeters and one for session components that want to use the
greeter interface.
https://bugzilla.gnome.org/show_bug.cgi?id=676381
.gitignore | 4 +
configure.ac | 9 +-
gui/libgdmgreeter/Makefile.am | 36 +-
gui/libgdmgreeter/gdm-greeter-client.c | 1243 --------------------------------
gui/libgdmgreeter/gdm-greeter-client.h | 126 ----
gui/libgdmgreeter/gdm-greeter-util.c | 245 +++++++
gui/libgdmgreeter/gdm-greeter-util.h | 55 ++
7 files changed, 338 insertions(+), 1380 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index b2e253a..8a24ce0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -126,6 +126,10 @@ docs/gdm-oc.omf
docs/gdm-ru.omf
docs/gdm-sv.omf
docs/gdm-uk.omf
+gui/libgdmgreeter/gdm-display-glue.c
+gui/libgdmgreeter/gdm-display-glue.h
+gui/libgdmgreeter/gdm-greeter-server.c
+gui/libgdmgreeter/gdm-greeter-server.h
gui/simple-chooser/gdm-host-chooser
gui/simple-chooser/gdm-simple-chooser
gui/simple-greeter/gdm-simple-greeter
diff --git a/configure.ac b/configure.ac
index bee9437..53682ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,7 +19,7 @@ AM_PROG_CC_C_O
AC_PROG_LIBTOOL()
## increment if the plugin interface has additions, changes, removals.
-LT_CURRENT=1
+LT_CURRENT=2
## increment any time the source changes; set to
## 0 if you increment CURRENT
@@ -182,12 +182,9 @@ PKG_CHECK_MODULES(CHECK,
have_check=no)
AM_CONDITIONAL([HAVE_CHECK],[test "x$CHECK_CFLAGS" != "x"])
-LIBGDMGREETER_LIBS="$SIMPLE_GREETER_LIBS"
-AC_SUBST(LIBGDMGREETER_LIBS)
-LIBGDMGREETER_CFLAGS="$SIMPLE_GREETER_CFLAGS"
-AC_SUBST(LIBGDMGREETER_CFLAGS)
+PKG_CHECK_MODULES(LIBGDMGREETER, glib-2.0 gio-2.0 gio-unix-2.0);
GOBJECT_INTROSPECTION_CHECK([0.9.12])
-LIBGDMGREETER_GIR_INCLUDES="GLib-2.0 GObject-2.0 DBusGLib-1.0"
+LIBGDMGREETER_GIR_INCLUDES="GLib-2.0 GObject-2.0 Gio-2.0"
AC_SUBST(LIBGDMGREETER_GIR_INCLUDES)
dnl ---------------------------------------------------------------------------
diff --git a/gui/libgdmgreeter/Makefile.am b/gui/libgdmgreeter/Makefile.am
index f1e2a51..14e8a6e 100644
--- a/gui/libgdmgreeter/Makefile.am
+++ b/gui/libgdmgreeter/Makefile.am
@@ -1,11 +1,30 @@
END_OF_LIST =
-BUILT_SOURCES = $(END_OF_LIST)
-CLEANFILES = $(END_OF_LIST)
+BUILT_SOURCES = gdm-greeter-server.h gdm-display-glue.h
+CLEANFILES = \
+ $(BUILT_SOURCES) \
+ gdm-display-glue.c \
+ $(END_OF_LIST)
+
+gdm-greeter-server.c gdm-greeter-server.h : $(top_srcdir)/daemon/gdm-greeter-server.xml Makefile.am
+ $(AM_V_GEN)gdbus-codegen \
+ --interface-prefix=org.gnome.DisplayManager \
+ --generate-c-code=gdm-greeter-server \
+ --annotate "org.gnome.DisplayManager.GreeterServer" \
+ "org.gtk.GDBus.C.Name" GdmGreeterServer \
+ $(top_srcdir)/daemon/gdm-greeter-server.xml
+
+gdm-display-glue.c gdm-display-glue.h : $(top_srcdir)/daemon/gdm-display.xml Makefile.am
+ $(AM_V_GEN)gdbus-codegen \
+ --c-namespace GdmDBus \
+ --interface-prefix=org.gnome.DisplayManager \
+ --generate-c-code=gdm-display-glue \
+ $(top_srcdir)/daemon/gdm-display.xml
AM_CPPFLAGS = \
-I. \
-I.. \
+ -I$(srcdir) \
-DG_LOG_DOMAIN=\"GdmGreeter\" \
-DDMCONFDIR=\""$(dmconfdir)"\" \
-DDATADIR=\""$(datadir)"\" \
@@ -17,7 +36,8 @@ lib_LTLIBRARIES = \
libgdmgreeterdir = $(includedir)/gdm/greeter
libgdmgreeter_HEADERS = \
- gdm-greeter-client.h \
+ gdm-greeter-util.h \
+ gdm-greeter-server.h \
gdm-greeter-sessions.h \
$(END_OF_LIST)
@@ -36,10 +56,16 @@ libgdmgreeter_la_LIBADD = \
libgdmgreeter_la_SOURCES = \
$(libgdmgreeter_HEADERS) \
- gdm-greeter-client.c \
+ gdm-greeter-server.c \
+ gdm-greeter-util.c \
gdm-greeter-sessions.c \
$(END_OF_LIST)
+nodist_libgdmgreeter_la_SOURCES = \
+ gdm-display-glue.c \
+ gdm-display-glue.h \
+ $(END_OF_LIST)
+
pkgconfigdir = $(libdir)/pkgconfig
dist_pkgconfig_DATA = gdmgreeter.pc
@@ -62,6 +88,7 @@ GdmGreeter_1_0_gir_SCANNERFLAGS = \
--warn-all \
--namespace=GdmGreeter \
--identifier-prefix GdmGreeter \
+ $(AM_CPPFLAGS) \
$(libgdmgreeter_la_CFLAGS) \
$(END_OF_LIST)
@@ -69,7 +96,6 @@ GdmGreeter_1_0_gir_INCLUDES = $(LIBGDMGREETER_GIR_INCLUDES)
GdmGreeter_1_0_gir_LIBS = libgdmgreeter.la
GdmGreeter_1_0_gir_FILES = \
$(filter-out %-private.h, $(libgdmgreeter_la_SOURCES)) \
- $(BUILT_SOURCES) \
$(END_OF_LIST)
CLEANFILES += $(gir_DATA) $(typelibs_DATA)
diff --git a/gui/libgdmgreeter/gdm-greeter-util.c b/gui/libgdmgreeter/gdm-greeter-util.c
new file mode 100644
index 0000000..328ea1a
--- /dev/null
+++ b/gui/libgdmgreeter/gdm-greeter-util.c
@@ -0,0 +1,245 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Giovanni Campagna <scampa giovanni gmail com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "gdm-greeter-util.h"
+#include "gdm-display-glue.h"
+
+GQuark
+gdm_greeter_error_quark (void)
+{
+ static GQuark error_quark = 0;
+
+ if (error_quark == 0) {
+ error_quark = g_quark_from_static_string ("gdm-greeter-error-quark");
+ }
+
+ return error_quark;
+}
+
+/**
+ * gdm_greeter_server_new_for_greeter_sync:
+ *
+ * Utility functions that creates a new #GdmGreeterServer to be
+ * used inside the greeter session. It uses the environment to find the
+ * address to connect to.
+ *
+ * Returns: (transfer full): a new #GdmGreeterServer, or %NULL if
+ * connecting or creating the proxy failed.
+ */
+GdmGreeterServer *
+gdm_greeter_server_new_for_greeter_sync (GCancellable *cancellable,
+ GError **error)
+{
+ const char *address;
+ GDBusConnection *connection;
+ GdmGreeterServer *server;
+
+ address = g_getenv ("GDM_GREETER_DBUS_ADDRESS");
+
+ if (address == NULL) {
+ g_set_error (error, GDM_GREETER_ERROR, GDM_GREETER_ERROR_GENERIC,
+ "Missing GreeterServer DBus address. Not a greeter session?");
+ return NULL;
+ }
+
+ connection = g_dbus_connection_new_for_address_sync (address,
+ G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
+ NULL,
+ cancellable,
+ error);
+ if (connection == NULL) {
+ return NULL;
+ }
+
+ server = gdm_greeter_server_proxy_new_sync (connection,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ NULL,
+ "/org/gnome/DisplayManager/GreeterServer",
+ cancellable,
+ error);
+
+ g_object_unref (connection);
+
+ return server;
+}
+
+/**
+ * gdm_greeter_server_new_for_display_sync:
+ * @display_name: (allow-none): a X11 display name, or %NULL to use default
+ *
+ * Utility functions that creates a new #GdmGreeterServer to be used
+ * inside a logged session, for example to authenticate the user
+ * in front of a screen lock.
+ *
+ * Returns: (transfer full): a new #GdmGreeterServer, or %NULL if
+ * connecting or creating the proxy failed.
+ */
+GdmGreeterServer *
+gdm_greeter_server_new_for_display_sync (const char *display_name,
+ GCancellable *cancellable,
+ GError **error)
+{
+ char *canon_display_name;
+ char *display_id;
+ char *address;
+ GDBusConnection *connection;
+ GdmDBusDisplay *display;
+ GdmGreeterServer *server;
+
+ if (display_name == NULL) {
+ display_name = g_getenv ("DISPLAY");
+ }
+
+ g_warn_if_fail (display_name != NULL);
+
+ canon_display_name = g_strdelimit (g_strdup (display_name),
+ ":" G_STR_DELIMITERS, '_');
+ display_id = g_strdup_printf ("/org/gnome/DisplayManager/Displays/%s", canon_display_name);
+
+ display = gdm_dbus_display_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ "org.gnome.DisplayManager",
+ display_id,
+ cancellable,
+ error);
+
+ g_free (canon_display_name);
+ g_free (display_id);
+
+ if (display == NULL) {
+ return NULL;
+ }
+
+ address = NULL;
+ gdm_dbus_display_call_connect_to_slave_sync (display,
+ &address,
+ cancellable,
+ error);
+
+ g_object_unref (display);
+
+ if (address == NULL) {
+ return NULL;
+ }
+
+ connection = g_dbus_connection_new_for_address_sync (address,
+ G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
+ NULL,
+ cancellable,
+ error);
+ g_free (address);
+
+ if (connection == NULL) {
+ return NULL;
+ }
+
+ server = gdm_greeter_server_proxy_new_sync (connection,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ NULL,
+ "/org/gnome/DisplayManager/GreeterServer",
+ cancellable,
+ error);
+
+ g_object_unref (connection);
+
+ return server;
+}
+
+static void
+thread_func (GSimpleAsyncResult *res,
+ GObject *object,
+ GCancellable *cancellable)
+{
+ GError *error;
+ GdmGreeterServer *server;
+ const char *display;
+
+ error = NULL;
+
+ display = g_object_get_data (G_OBJECT (res), "x11-display-name");
+ server = gdm_greeter_server_new_for_display_sync (display,
+ cancellable,
+ &error);
+
+ if (server != NULL) {
+ g_simple_async_result_set_op_res_gpointer (res,
+ server,
+ NULL);
+ } else {
+ g_simple_async_result_take_error (res, error);
+ }
+}
+
+/**
+ * gdm_greeter_server_new_for_display:
+ * @display_name: (allow-none): a X11 display name, or %NULL to use default
+ *
+ * This is just the async version of gdm_greeter_server_new_for_display_sync()
+ */
+void
+gdm_greeter_server_new_for_display (const char *display_name,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+
+ result = g_simple_async_result_new (NULL,
+ callback,
+ user_data,
+ gdm_greeter_server_new_for_display);
+ g_simple_async_result_set_check_cancellable (result, cancellable);
+
+ g_object_set_data_full (G_OBJECT (result),
+ "x11-display-name",
+ g_strdup (display_name),
+ g_free);
+
+ g_simple_async_result_run_in_thread (result,
+ thread_func,
+ 0,
+ cancellable);
+}
+
+/**
+ * gdm_greeter_server_new_for_display_finish:
+ *
+ * Returns: (transfer full): the newly created #GdmGreeterServer
+ */
+GdmGreeterServer *
+gdm_greeter_server_new_for_display_finish (GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple;
+ GdmGreeterServer *server;
+
+ g_return_val_if_fail (g_simple_async_result_is_valid (result,
+ NULL,
+ gdm_greeter_server_new_for_display), NULL);
+
+ simple = G_SIMPLE_ASYNC_RESULT (result);
+
+ if (g_simple_async_result_propagate_error (simple, error)) {
+ return NULL;
+ }
+
+ server = g_simple_async_result_get_op_res_gpointer (simple);
+ return server;
+}
diff --git a/gui/libgdmgreeter/gdm-greeter-util.h b/gui/libgdmgreeter/gdm-greeter-util.h
new file mode 100644
index 0000000..3c23827
--- /dev/null
+++ b/gui/libgdmgreeter/gdm-greeter-util.h
@@ -0,0 +1,55 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Giovanni Campagna <scampa giovanni gmail com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GDM_GREETER_UTIL_H
+#define __GDM_GREETER_UTIL_H
+
+#include <gio/gio.h>
+#include <gdm-greeter-server.h>
+
+G_BEGIN_DECLS
+
+#define GDM_GREETER_ERROR (gdm_greeter_error_quark ())
+
+typedef enum _GdmGreeterError {
+ GDM_GREETER_ERROR_GENERIC = 0,
+} GdmGreeterError;
+
+GQuark gdm_greeter_error_quark (void);
+
+GdmGreeterServer * gdm_greeter_server_new_for_greeter_sync (GCancellable *cancellable,
+ GError **error);
+
+GdmGreeterServer * gdm_greeter_server_new_for_display_sync (const char *display_name,
+ GCancellable *cancellable,
+ GError **error);
+
+void gdm_greeter_server_new_for_display (const char *display_name,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+GdmGreeterServer * gdm_greeter_server_new_for_display_finish (GAsyncResult *result,
+ GError **error);
+
+
+G_END_DECLS
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]