[gdm/wip/slave-connection: 17/30] daemon: Port display handling to gdbus
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/wip/slave-connection: 17/30] daemon: Port display handling to gdbus
- Date: Mon, 9 Jul 2012 07:52:33 +0000 (UTC)
commit 344b691fbd01080eb18173c2214e92355d859a77
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Tue May 15 17:09:28 2012 +0200
daemon: Port display handling to gdbus
This is one big commit because it uses generated code both
in the daemon and in the slaves, so we need to port both at the
same time.
https://bugzilla.gnome.org/show_bug.cgi?id=622888
.gitignore | 7 +
daemon/Makefile.am | 98 ++-
daemon/gdm-display.c | 285 ++++++++-
daemon/gdm-display.h | 4 +-
daemon/gdm-display.xml | 3 +
daemon/gdm-local-display-factory.c | 256 ++++----
daemon/gdm-simple-slave.xml | 5 -
daemon/gdm-slave.c | 732 ++++++++------------
daemon/gdm-slave.h | 1 +
daemon/gdm-static-display.c | 36 +-
daemon/gdm-static-display.h | 1 -
daemon/gdm-transient-display.c | 38 +-
daemon/gdm-transient-display.h | 1 -
daemon/gdm-xdmcp-chooser-display.c | 106 ++--
daemon/gdm-xdmcp-chooser-display.h | 1 -
daemon/gdm-xdmcp-chooser-display.xml | 5 -
daemon/gdm-xdmcp-chooser-slave.c | 2 -
daemon/gdm-xdmcp-display.h | 1 -
...p-greeter-display.xml => gdm-xdmcp-display.xml} | 0
daemon/gdm-xdmcp-greeter-display.h | 1 -
20 files changed, 887 insertions(+), 696 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index d681463..9b0e977 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,7 @@ configure.lineno
gdm.conf
gdm.conf-custom
gdm-display-glue.h
+gdm-display-glue.c
gdm-local-display-factory-glue.h
gdm-local-display-factory-glue.c
gdm-manager-glue.h
@@ -43,12 +44,18 @@ gdm-simple-greeter.desktop.in
gdm-simple-greeter.schemas
gdm-simple-slave-glue.h
gdm-slave-glue.h
+gdm-slave-glue.c
gdm-static-display-glue.h
+gdm-static-display-glue.c
gdm-static-factory-display-glue.h
gdm-stop
gdm-transient-display-glue.h
+gdm-transient-display-glue.c
+gdm-xdmcp-display-glue.h
+gdm-xdmcp-display-glue.c
gdm-xdmcp-chooser-display-glue.h
gdm-xdmcp-chooser-slave-glue.h
+gdm-xdmcp-chooser-slave-glue.c
gdm-xdmcp-greeter-display-glue.h
gdm-greeter-glue.h
gdm-greeter-glue.c
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 6c11caa..0ac96ad 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -30,12 +30,10 @@ AM_CPPFLAGS = \
BUILT_SOURCES = \
gdm-slave-glue.h \
- gdm-simple-slave-glue.h \
gdm-xdmcp-chooser-slave-glue.h \
gdm-manager-glue.h \
gdm-display-glue.h \
- gdm-xdmcp-greeter-display-glue.h \
- gdm-xdmcp-chooser-display-glue.h \
+ gdm-xdmcp-display-glue.h \
gdm-static-display-glue.h \
gdm-transient-display-glue.h \
gdm-local-display-factory-glue.h \
@@ -45,22 +43,34 @@ BUILT_SOURCES = \
gdm-manager-glue.h: gdm-manager.xml Makefile.am
dbus-binding-tool --prefix=gdm_manager --mode=glib-server --output=gdm-manager-glue.h $(srcdir)/gdm-manager.xml
-gdm-slave-glue.h: gdm-slave.xml Makefile.am
- dbus-binding-tool --prefix=gdm_slave --mode=glib-server --output=gdm-slave-glue.h $(srcdir)/gdm-slave.xml
-gdm-simple-slave-glue.h: gdm-simple-slave.xml Makefile.am
- dbus-binding-tool --prefix=gdm_simple_slave --mode=glib-server --output=gdm-simple-slave-glue.h $(srcdir)/gdm-simple-slave.xml
-gdm-xdmcp-chooser-slave-glue.h: gdm-xdmcp-chooser-slave.xml Makefile.am
- dbus-binding-tool --prefix=gdm_xdmcp_chooser_slave --mode=glib-server --output=gdm-xdmcp-chooser-slave-glue.h $(srcdir)/gdm-xdmcp-chooser-slave.xml
-gdm-display-glue.h: gdm-display.xml Makefile.am
- dbus-binding-tool --prefix=gdm_display --mode=glib-server --output=gdm-display-glue.h $(srcdir)/gdm-display.xml
-gdm-xdmcp-greeter-display-glue.h: gdm-xdmcp-greeter-display.xml Makefile.am
- dbus-binding-tool --prefix=gdm_xdmcp_greeter_display --mode=glib-server --output=gdm-xdmcp-greeter-display-glue.h $(srcdir)/gdm-xdmcp-greeter-display.xml
-gdm-xdmcp-chooser-display-glue.h: gdm-xdmcp-chooser-display.xml Makefile.am
- dbus-binding-tool --prefix=gdm_xdmcp_chooser_display --mode=glib-server --output=gdm-xdmcp-chooser-display-glue.h $(srcdir)/gdm-xdmcp-chooser-display.xml
-gdm-static-display-glue.h: gdm-static-display.xml Makefile.am
- dbus-binding-tool --prefix=gdm_static_display --mode=glib-server --output=gdm-static-display-glue.h $(srcdir)/gdm-static-display.xml
-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-display-glue.c gdm-display-glue.h: gdm-display.xml Makefile.am
+ $(AM_V_GEN)gdbus-codegen \
+ --c-namespace=GdmDBus \
+ --interface-prefix=org.gnome.DisplayManager \
+ --generate-c-code=gdm-display-glue \
+ $(srcdir)/gdm-display.xml
+
+gdm-xdmcp-display-glue.c gdm-xdmcp-display-glue.h: gdm-xdmcp-display.xml Makefile.am
+ $(AM_V_GEN)gdbus-codegen \
+ --c-namespace=GdmDBus \
+ --interface-prefix=org.gnome.DisplayManager \
+ --generate-c-code=gdm-xdmcp-display-glue \
+ $(srcdir)/gdm-xdmcp-display.xml
+
+gdm-transient-display-glue.c gdm-transient-display-glue.h: gdm-transient-display.xml Makefile.am
+ $(AM_V_GEN)gdbus-codegen \
+ --c-namespace=GdmDBus \
+ --interface-prefix=org.gnome.DisplayManager \
+ --generate-c-code=gdm-transient-display-glue \
+ $(srcdir)/gdm-transient-display.xml
+
+gdm-static-display-glue.c gdm-static-display-glue.h: gdm-static-display.xml Makefile.am
+ $(AM_V_GEN)gdbus-codegen \
+ --c-namespace=GdmDBus \
+ --interface-prefix=org.gnome.DisplayManager \
+ --generate-c-code=gdm-static-display-glue \
+ $(srcdir)/gdm-static-display.xml
gdm-local-display-factory-glue.c gdm-local-display-factory-glue.h : gdm-local-display-factory.xml Makefile.am
$(AM_V_GEN)gdbus-codegen \
@@ -83,6 +93,20 @@ gdm-greeter-glue.c gdm-greeter-glue.h : gdm-greeter-server.xml Makefile.am
--generate-c-code=gdm-greeter-glue \
$(srcdir)/gdm-greeter-server.xml
+gdm-slave-glue.c gdm-slave-glue.h: gdm-slave.xml Makefile.am
+ $(AM_V_GEN)gdbus-codegen \
+ --c-namespace=GdmDBus \
+ --interface-prefix=org.gnome.DisplayManager \
+ --generate-c-code=gdm-slave-glue \
+ $(srcdir)/gdm-slave.xml
+
+gdm-xdmcp-chooser-slave-glue.c gdm-xdmcp-chooser-slave-glue.h: gdm-xdmcp-chooser-slave.xml Makefile.am
+ $(AM_V_GEN)gdbus-codegen \
+ --c-namespace=GdmDBus \
+ --interface-prefix=org.gnome.DisplayManager \
+ --generate-c-code=gdm-xdmcp-chooser-slave-glue \
+ $(srcdir)/gdm-xdmcp-chooser-slave.xml
+
noinst_PROGRAMS = \
test-session \
$(NULL)
@@ -154,6 +178,10 @@ nodist_gdm_simple_slave_SOURCES = \
gdm-greeter-glue.h \
gdm-session-glue.c \
gdm-session-glue.h \
+ gdm-display-glue.c \
+ gdm-display-glue.h \
+ gdm-slave-glue.c \
+ gdm-slave-glue.h \
$(NULL)
gdm_simple_slave_LDFLAGS = \
@@ -196,6 +224,10 @@ gdm_xdmcp_chooser_slave_SOURCES = \
nodist_gdm_xdmcp_chooser_slave_SOURCES = \
gdm-session-glue.c \
gdm-session-glue.h \
+ gdm-display-glue.c \
+ gdm-display-glue.h \
+ gdm-slave-glue.c \
+ gdm-slave-glue.h \
$(NULL)
gdm_xdmcp_chooser_slave_LDADD = \
@@ -269,6 +301,17 @@ gdm_binary_SOURCES = \
gdm-slave-proxy.h \
$(NULL)
+nodist_gdm_binary_SOURCES = \
+ gdm-display-glue.h \
+ gdm-display-glue.c \
+ gdm-local-display-factory-glue.h \
+ gdm-local-display-factory-glue.c \
+ gdm-transient-display-glue.h \
+ gdm-transient-display-glue.c \
+ gdm-static-display-glue.h \
+ gdm-static-display-glue.c \
+ $(NULL)
+
XDMCP_SOURCES = \
gdm-xdmcp-display-factory.c \
gdm-xdmcp-display-factory.h \
@@ -280,8 +323,16 @@ XDMCP_SOURCES = \
gdm-xdmcp-chooser-display.h \
$(NULL)
+XDMCP_nodist_SOURCES = \
+ gdm-xdmcp-display-glue.c \
+ gdm-xdmcp-display-glue.h \
+ gdm-xdmcp-chooser-slave-glue.c \
+ gdm-xdmcp-chooser-slave-glue.h \
+ $(NULL)
+
if XDMCP_SUPPORT
gdm_binary_SOURCES += $(XDMCP_SOURCES)
+nodist_gdm_binary_SOURCES += $(XDMCP_nodist_SOURCES)
endif
EXTRA_gdm_binary_SOURCES = \
@@ -321,9 +372,15 @@ gdm: $(srcdir)/gdm.in
CLEANFILES = \
gdm \
+ gdm-display-glue.c \
gdm-greeter-glue.c \
gdm-local-display-factory-glue.c \
gdm-session-glue.c \
+ gdm-slave-glue.c \
+ gdm-static-display-glue.c \
+ gdm-transient-display-glue.c \
+ gdm-xdmcp-chooser-slave-glue.c \
+ gdm-xdmcp-display-glue.c \
$(BUILT_SOURCES) \
$(NULL)
@@ -335,8 +392,7 @@ EXTRA_DIST = \
gdm-xdmcp-chooser-slave.xml \
gdm-manager.xml \
gdm-display.xml \
- gdm-xdmcp-greeter-display.xml \
- gdm-xdmcp-chooser-display.xml \
+ gdm-xdmcp-display.xml \
gdm-static-display.xml \
gdm-transient-display.xml \
gdm-local-display-factory.xml \
diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c
index ccc1ff6..017347d 100644
--- a/daemon/gdm-display.c
+++ b/daemon/gdm-display.c
@@ -69,8 +69,12 @@ struct GdmDisplayPrivate
guint finish_idle_id;
GdmSlaveProxy *slave_proxy;
- DBusGConnection *connection;
+ char *slave_bus_name;
+ GDBusConnection *connection;
GdmDisplayAccessFile *user_access_file;
+
+ GdmDBusDisplay *display_skeleton;
+ GDBusObjectSkeleton *object_skeleton;
};
enum {
@@ -280,6 +284,8 @@ gdm_display_real_set_slave_bus_name (GdmDisplay *display,
const char *name,
GError **error)
{
+ g_free (display->priv->slave_bus_name);
+ display->priv->slave_bus_name = g_strdup (name);
return TRUE;
}
@@ -934,21 +940,268 @@ gdm_display_get_property (GObject *object,
}
static gboolean
+handle_get_id (GdmDBusDisplay *skeleton,
+ GDBusMethodInvocation *invocation,
+ GdmDisplay *display)
+{
+ char *id;
+
+ gdm_display_get_id (display, &id, NULL);
+
+ gdm_dbus_display_complete_get_id (skeleton, invocation, id);
+
+ g_free (id);
+ return TRUE;
+}
+
+static gboolean
+handle_get_remote_hostname (GdmDBusDisplay *skeleton,
+ GDBusMethodInvocation *invocation,
+ GdmDisplay *display)
+{
+ char *hostname;
+
+ gdm_display_get_remote_hostname (display, &hostname, NULL);
+
+ gdm_dbus_display_complete_get_remote_hostname (skeleton,
+ invocation,
+ hostname ? hostname : "");
+
+ g_free (hostname);
+ return TRUE;
+}
+
+static gboolean
+handle_get_seat_id (GdmDBusDisplay *skeleton,
+ GDBusMethodInvocation *invocation,
+ GdmDisplay *display)
+{
+ char *seat_id;
+
+ gdm_display_get_seat_id (display, &seat_id, NULL);
+
+ gdm_dbus_display_complete_get_seat_id (skeleton, invocation, seat_id);
+
+ g_free (seat_id);
+ return TRUE;
+}
+
+static gboolean
+handle_get_timed_login_details (GdmDBusDisplay *skeleton,
+ GDBusMethodInvocation *invocation,
+ GdmDisplay *display)
+{
+ gboolean enabled;
+ char *username;
+ int delay;
+
+ gdm_display_get_timed_login_details (display, &enabled, &username, &delay, NULL);
+
+ gdm_dbus_display_complete_get_timed_login_details (skeleton,
+ invocation,
+ enabled,
+ username ? username : "",
+ delay);
+
+ g_free (username);
+ return TRUE;
+}
+
+static gboolean
+handle_get_x11_authority_file (GdmDBusDisplay *skeleton,
+ GDBusMethodInvocation *invocation,
+ GdmDisplay *display)
+{
+ char *file;
+
+ gdm_display_get_x11_authority_file (display, &file, NULL);
+
+ gdm_dbus_display_complete_get_x11_authority_file (skeleton, invocation, file);
+
+ g_free (file);
+ return TRUE;
+}
+
+static gboolean
+handle_get_x11_cookie (GdmDBusDisplay *skeleton,
+ GDBusMethodInvocation *invocation,
+ GdmDisplay *display)
+{
+ GArray *cookie = NULL;
+
+ gdm_display_get_x11_cookie (display, &cookie, NULL);
+
+ gdm_dbus_display_complete_get_x11_cookie (skeleton, invocation, cookie->data);
+
+ g_array_unref (cookie);
+ return TRUE;
+}
+
+static gboolean
+handle_get_x11_display_name (GdmDBusDisplay *skeleton,
+ GDBusMethodInvocation *invocation,
+ GdmDisplay *display)
+{
+ char *name;
+
+ gdm_display_get_x11_display_name (display, &name, NULL);
+
+ gdm_dbus_display_complete_get_x11_display_name (skeleton, invocation, name);
+
+ g_free (name);
+ return TRUE;
+}
+
+static gboolean
+handle_get_x11_display_number (GdmDBusDisplay *skeleton,
+ GDBusMethodInvocation *invocation,
+ GdmDisplay *display)
+{
+ int name;
+
+ gdm_display_get_x11_display_number (display, &name, NULL);
+
+ gdm_dbus_display_complete_get_x11_display_number (skeleton, invocation, name);
+
+ return TRUE;
+}
+
+static gboolean
+handle_is_local (GdmDBusDisplay *skeleton,
+ GDBusMethodInvocation *invocation,
+ GdmDisplay *display)
+{
+ gboolean is_local;
+
+ gdm_display_is_local (display, &is_local, NULL);
+
+ gdm_dbus_display_complete_is_local (skeleton, invocation, is_local);
+
+ return TRUE;
+}
+
+static gboolean
+handle_get_slave_bus_name (GdmDBusDisplay *skeleton,
+ GDBusMethodInvocation *invocation,
+ GdmDisplay *display)
+{
+ if (display->priv->slave_bus_name != NULL) {
+ gdm_dbus_display_complete_get_slave_bus_name (skeleton, invocation,
+ display->priv->slave_bus_name);
+ } else {
+ g_dbus_method_invocation_return_dbus_error (invocation,
+ "org.gnome.DisplayManager.NotReady",
+ "Slave is not yet registered");
+ }
+
+ return TRUE;
+}
+
+static gboolean
+handle_set_slave_bus_name (GdmDBusDisplay *skeleton,
+ GDBusMethodInvocation *invocation,
+ const char *bus_name,
+ GdmDisplay *display)
+{
+ GError *error;
+
+ if (gdm_display_set_slave_bus_name (display, bus_name, &error)) {
+ gdm_dbus_display_complete_set_slave_bus_name (skeleton, invocation);
+ } else {
+ g_dbus_method_invocation_return_gerror (invocation, error);
+ g_error_free (error);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+handle_add_user_authorization (GdmDBusDisplay *skeleton,
+ GDBusMethodInvocation *invocation,
+ const char *username,
+ GdmDisplay *display)
+{
+ char *filename;
+ GError *error;
+
+ if (gdm_display_add_user_authorization (display, username, &filename, &error)) {
+ gdm_dbus_display_complete_add_user_authorization (skeleton,
+ invocation,
+ filename);
+ g_free (filename);
+ } else {
+ g_dbus_method_invocation_return_gerror (invocation, error);
+ g_error_free (error);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+handle_remove_user_authorization (GdmDBusDisplay *skeleton,
+ GDBusMethodInvocation *invocation,
+ const char *username,
+ GdmDisplay *display)
+{
+ GError *error;
+
+ if (gdm_display_remove_user_authorization (display, username, &error)) {
+ gdm_dbus_display_complete_remove_user_authorization (skeleton, invocation);
+ } else {
+ g_dbus_method_invocation_return_gerror (invocation, error);
+ g_error_free (error);
+ }
+
+ return TRUE;
+}
+
+
+
+static gboolean
register_display (GdmDisplay *display)
{
GError *error = NULL;
error = NULL;
- display->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ display->priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (display->priv->connection == NULL) {
- if (error != NULL) {
- g_critical ("error getting system bus: %s", error->message);
- g_error_free (error);
- }
+ g_critical ("error getting system bus: %s", error->message);
+ g_error_free (error);
exit (1);
}
- dbus_g_connection_register_g_object (display->priv->connection, display->priv->id, G_OBJECT (display));
+ display->priv->object_skeleton = g_dbus_object_skeleton_new (display->priv->id);
+ display->priv->display_skeleton = GDM_DBUS_DISPLAY (gdm_dbus_display_skeleton_new ());
+
+ g_signal_connect (display->priv->display_skeleton, "handle-get-id",
+ G_CALLBACK (handle_get_id), display);
+ g_signal_connect (display->priv->display_skeleton, "handle-get-remote-hostname",
+ G_CALLBACK (handle_get_remote_hostname), display);
+ g_signal_connect (display->priv->display_skeleton, "handle-get-seat-id",
+ G_CALLBACK (handle_get_seat_id), display);
+ g_signal_connect (display->priv->display_skeleton, "handle-get-timed-login-details",
+ G_CALLBACK (handle_get_timed_login_details), display);
+ g_signal_connect (display->priv->display_skeleton, "handle-get-x11-authority-file",
+ G_CALLBACK (handle_get_x11_authority_file), display);
+ g_signal_connect (display->priv->display_skeleton, "handle-get-x11-cookie",
+ G_CALLBACK (handle_get_x11_cookie), display);
+ g_signal_connect (display->priv->display_skeleton, "handle-get-x11-display-name",
+ G_CALLBACK (handle_get_x11_display_name), display);
+ g_signal_connect (display->priv->display_skeleton, "handle-get-x11-display-number",
+ G_CALLBACK (handle_get_x11_display_number), display);
+ g_signal_connect (display->priv->display_skeleton, "handle-is-local",
+ G_CALLBACK (handle_is_local), display);
+ g_signal_connect (display->priv->display_skeleton, "handle-get-slave-bus-name",
+ G_CALLBACK (handle_get_slave_bus_name), display);
+ g_signal_connect (display->priv->display_skeleton, "handle-set-slave-bus-name",
+ G_CALLBACK (handle_set_slave_bus_name), display);
+ g_signal_connect (display->priv->display_skeleton, "handle-add-user-authorization",
+ G_CALLBACK (handle_add_user_authorization), display);
+ g_signal_connect (display->priv->display_skeleton, "handle-remove-user-authorization",
+ G_CALLBACK (handle_remove_user_authorization), display);
+
+ g_dbus_object_skeleton_add_interface (display->priv->object_skeleton,
+ G_DBUS_INTERFACE_SKELETON (display->priv->display_skeleton));
return TRUE;
}
@@ -1113,8 +1366,6 @@ gdm_display_class_init (GdmDisplayClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_type_class_add_private (klass, sizeof (GdmDisplayPrivate));
-
- dbus_g_object_type_install_info (GDM_TYPE_DISPLAY, &dbus_glib_gdm_display_object_info);
}
static void
@@ -1147,6 +1398,10 @@ gdm_display_finalize (GObject *object)
g_free (display->priv->x11_cookie);
g_free (display->priv->slave_command);
+ g_clear_object (&display->priv->display_skeleton);
+ g_clear_object (&display->priv->object_skeleton);
+ g_clear_object (&display->priv->connection);
+
if (display->priv->access_file != NULL) {
g_object_unref (display->priv->access_file);
}
@@ -1161,3 +1416,15 @@ gdm_display_finalize (GObject *object)
G_OBJECT_CLASS (gdm_display_parent_class)->finalize (object);
}
+
+GDBusConnection *
+gdm_display_get_bus_connection (GdmDisplay *display)
+{
+ return display->priv->connection;
+}
+
+GDBusObjectSkeleton *
+gdm_display_get_object_skeleton (GdmDisplay *display)
+{
+ return display->priv->object_skeleton;
+}
diff --git a/daemon/gdm-display.h b/daemon/gdm-display.h
index 607ea1d..6cbcca2 100644
--- a/daemon/gdm-display.h
+++ b/daemon/gdm-display.h
@@ -23,7 +23,7 @@
#define __GDM_DISPLAY_H
#include <glib-object.h>
-#include <dbus/dbus-glib.h>
+#include <gio/gio.h>
G_BEGIN_DECLS
@@ -97,6 +97,8 @@ gboolean gdm_display_manage (GdmDisplay *disp
gboolean gdm_display_finish (GdmDisplay *display);
gboolean gdm_display_unmanage (GdmDisplay *display);
+GDBusConnection *gdm_display_get_bus_connection (GdmDisplay *display);
+GDBusObjectSkeleton *gdm_display_get_object_skeleton (GdmDisplay *display);
/* exported to bus */
gboolean gdm_display_get_id (GdmDisplay *display,
diff --git a/daemon/gdm-display.xml b/daemon/gdm-display.xml
index a92e37f..13c734d 100644
--- a/daemon/gdm-display.xml
+++ b/daemon/gdm-display.xml
@@ -32,6 +32,9 @@
<method name="RemoveUserAuthorization">
<arg name="username" direction="in" type="s"/>
</method>
+ <method name="GetSlaveBusName">
+ <arg name="name" direction="out" type="s"/>
+ </method>
<method name="SetSlaveBusName">
<arg name="name" direction="in" type="s"/>
</method>
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
index 9cdf198..6360287 100644
--- a/daemon/gdm-local-display-factory.c
+++ b/daemon/gdm-local-display-factory.c
@@ -26,9 +26,7 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <glib-object.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <gio/gio.h>
#ifdef WITH_SYSTEMD
#include <systemd/sd-daemon.h>
@@ -55,12 +53,17 @@
struct GdmLocalDisplayFactoryPrivate
{
- DBusGConnection *connection;
- DBusGProxy *proxy;
+ GdmDBusLocalDisplayFactory *skeleton;
+ GDBusConnection *connection;
GHashTable *displays;
/* FIXME: this needs to be per seat? */
guint num_failures;
+
+#ifdef WITH_SYSTEMD
+ guint seat_new_id;
+ guint seat_removed_id;
+#endif
};
enum {
@@ -384,143 +387,108 @@ delete_display (GdmLocalDisplayFactory *factory,
static gboolean gdm_local_display_factory_sync_seats (GdmLocalDisplayFactory *factory)
{
- DBusError error;
- DBusMessage *message, *reply;
- DBusMessageIter iter, sub, sub2;
-
- dbus_error_init (&error);
-
- message = dbus_message_new_method_call (
- "org.freedesktop.login1",
- "/org/freedesktop/login1",
- "org.freedesktop.login1.Manager",
- "ListSeats");
- if (message == NULL) {
- g_warning ("GdmLocalDisplayFactory: Failed to allocate message");
- return FALSE;
- }
-
- reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (factory->priv->connection), message, -1, &error);
- dbus_message_unref (message);
-
- if (reply == NULL) {
- g_warning ("GdmLocalDisplayFactory: Failed to issue method call: %s", error.message);
- dbus_error_free (&error);
- return FALSE;
- }
-
- if (!dbus_message_iter_init (reply, &iter) ||
- dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY ||
- dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_STRUCT) {
- g_warning ("GdmLocalDisplayFactory: Failed to parse reply.");
- dbus_message_unref (reply);
+ GError *error = NULL;
+ GVariant *result;
+ GVariant *array;
+ GVariantIter iter;
+ const char *seat;
+
+ result = g_dbus_connection_call_sync (factory->priv->connection,
+ "org.freedesktop.login1",
+ "/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager",
+ "ListSeats",
+ NULL,
+ G_VARIANT_TYPE ("(a(so))"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, &error);
+
+ if (!result) {
+ g_warning ("GdmLocalDisplayFactory: Failed to issue method call: %s", error->message);
+ g_clear_error (&error);
return FALSE;
}
- dbus_message_iter_recurse (&iter, &sub);
-
- while (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_INVALID) {
- const char *seat;
-
- if (dbus_message_iter_get_arg_type (&sub) != DBUS_TYPE_STRUCT) {
- g_warning ("GdmLocalDisplayFactory: Failed to parse reply.");
- dbus_message_unref (reply);
- return FALSE;
- }
-
- dbus_message_iter_recurse (&sub, &sub2);
-
- if (dbus_message_iter_get_arg_type (&sub2) != DBUS_TYPE_STRING) {
- g_warning ("GdmLocalDisplayFactory: Failed to parse reply.");
- dbus_message_unref (reply);
- return FALSE;
- }
+ array = g_variant_get_child_value (result, 0);
+ g_variant_iter_init (&iter, array);
- dbus_message_iter_get_basic (&sub2, &seat);
+ while (g_variant_iter_loop (&iter, "(&so)", &seat, NULL))
create_display (factory, seat);
- dbus_message_iter_next (&sub);
- }
-
- dbus_message_unref (reply);
+ g_variant_unref (result);
+ g_variant_unref (array);
return TRUE;
}
-static DBusHandlerResult
-on_seat_signal (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
+static void
+on_seat_new (GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
{
- GdmLocalDisplayFactory *factory = user_data;
- DBusError error;
+ const char *seat;
- dbus_error_init (&error);
-
- if (dbus_message_is_signal (message, "org.freedesktop.login1.Manager", "SeatNew") ||
- dbus_message_is_signal (message, "org.freedesktop.login1.Manager", "SeatRemoved")) {
- const char *seat;
-
- dbus_message_get_args (message,
- &error,
- DBUS_TYPE_STRING, &seat,
- DBUS_TYPE_INVALID);
-
- if (dbus_error_is_set (&error)) {
- g_warning ("GdmLocalDisplayFactory: Failed to decode seat message: %s", error.message);
- dbus_error_free (&error);
- } else {
+ g_variant_get (parameters, "(&s)", &seat);
+ create_display (GDM_LOCAL_DISPLAY_FACTORY (user_data), seat);
+}
- if (strcmp (dbus_message_get_member (message), "SeatNew") == 0) {
- create_display (factory, seat);
- } else {
- delete_display (factory, seat);
- }
- }
- }
+static void
+on_seat_removed (GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ const char *seat;
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ g_variant_get (parameters, "(&s)", &seat);
+ delete_display (GDM_LOCAL_DISPLAY_FACTORY (user_data), seat);
}
static void
gdm_local_display_factory_start_monitor (GdmLocalDisplayFactory *factory)
{
- DBusError error;
-
- dbus_error_init (&error);
-
- dbus_bus_add_match (dbus_g_connection_get_connection (factory->priv->connection),
- "type='signal',"
- "sender='org.freedesktop.login1',"
- "path='/org/freedesktop/login1',"
- "interface='org.freedesktop.login1.Manager',"
- "member='SeatNew'",
- &error);
-
- if (dbus_error_is_set (&error)) {
- g_warning ("GdmLocalDisplayFactory: Failed to add match for SeatNew: %s", error.message);
- dbus_error_free (&error);
- }
-
- dbus_bus_add_match (dbus_g_connection_get_connection (factory->priv->connection),
- "type='signal',"
- "sender='org.freedesktop.login1',"
- "path='/org/freedesktop/login1',"
- "interface='org.freedesktop.login1.Manager',"
- "member='SeatRemoved'",
- &error);
-
- if (dbus_error_is_set (&error)) {
- g_warning ("GdmLocalDisplayFactory: Failed to add match for SeatNew: %s", error.message);
- dbus_error_free (&error);
- }
-
- dbus_connection_add_filter (dbus_g_connection_get_connection (factory->priv->connection), on_seat_signal, factory, NULL);
+ factory->priv->seat_new_id = g_dbus_connection_signal_subscribe (factory->priv->connection,
+ "org.freedesktop.login1",
+ "org.freedesktop.login1.Manager",
+ "SeatNew",
+ "/org/freedesktop/login1",
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ on_seat_new,
+ g_object_ref (factory),
+ g_object_unref);
+ factory->priv->seat_removed_id = g_dbus_connection_signal_subscribe (factory->priv->connection,
+ "org.freedesktop.login1",
+ "org.freedesktop.login1.Manager",
+ "SeatRemoved",
+ "/org/freedesktop/login1",
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ on_seat_removed,
+ g_object_ref (factory),
+ g_object_unref);
}
static void
gdm_local_display_factory_stop_monitor (GdmLocalDisplayFactory *factory)
{
- dbus_connection_remove_filter (dbus_g_connection_get_connection (factory->priv->connection), on_seat_signal, factory);
+ if (factory->priv->seat_new_id) {
+ g_dbus_connection_signal_unsubscribe (factory->priv->connection,
+ factory->priv->seat_new_id);
+ factory->priv->seat_new_id = 0;
+ }
+ if (factory->priv->seat_removed_id) {
+ g_dbus_connection_signal_unsubscribe (factory->priv->connection,
+ factory->priv->seat_removed_id);
+ factory->priv->seat_removed_id = 0;
+ }
}
#endif
@@ -587,21 +555,54 @@ gdm_local_display_factory_get_property (GObject *object,
}
static gboolean
+handle_create_transient_display (GdmDBusLocalDisplayFactory *skeleton,
+ GDBusMethodInvocation *invocation,
+ GdmLocalDisplayFactory *factory)
+{
+ GError *error = NULL;
+ gboolean created;
+ char *id = NULL;
+
+ created = gdm_local_display_factory_create_transient_display (factory,
+ &id,
+ &error);
+ if (!created) {
+ g_dbus_method_invocation_return_gerror (invocation, error);
+ } else {
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(s)", id));
+ }
+
+ g_free (id);
+ return TRUE;
+}
+
+static gboolean
register_factory (GdmLocalDisplayFactory *factory)
{
GError *error = NULL;
error = NULL;
- factory->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ factory->priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (factory->priv->connection == NULL) {
- if (error != NULL) {
- g_critical ("error getting system bus: %s", error->message);
- g_error_free (error);
- }
+ g_critical ("error getting system bus: %s", error->message);
+ g_error_free (error);
exit (1);
}
- dbus_g_connection_register_g_object (factory->priv->connection, GDM_LOCAL_DISPLAY_FACTORY_DBUS_PATH, G_OBJECT (factory));
+ factory->priv->skeleton = GDM_DBUS_LOCAL_DISPLAY_FACTORY (gdm_dbus_local_display_factory_skeleton_new ());
+
+ g_signal_connect (factory->priv->skeleton, "handle-create-transient-display",
+ G_CALLBACK (handle_create_transient_display), factory);
+
+ if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (factory->priv->skeleton),
+ factory->priv->connection,
+ GDM_LOCAL_DISPLAY_FACTORY_DBUS_PATH,
+ &error)) {
+ g_critical ("error exporting LocalDisplayFactory object: %s", error->message);
+ g_error_free (error);
+ exit (1);
+ }
return TRUE;
}
@@ -641,8 +642,6 @@ gdm_local_display_factory_class_init (GdmLocalDisplayFactoryClass *klass)
factory_class->stop = gdm_local_display_factory_stop;
g_type_class_add_private (klass, sizeof (GdmLocalDisplayFactoryPrivate));
-
- dbus_g_object_type_install_info (GDM_TYPE_LOCAL_DISPLAY_FACTORY, &dbus_glib_gdm_local_display_factory_object_info);
}
static void
@@ -665,6 +664,9 @@ gdm_local_display_factory_finalize (GObject *object)
g_return_if_fail (factory->priv != NULL);
+ g_clear_object (&factory->priv->connection);
+ g_clear_object (&factory->priv->skeleton);
+
g_hash_table_destroy (factory->priv->displays);
#ifdef WITH_SYSTEMD
diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c
index 53633c0..94c8d44 100644
--- a/daemon/gdm-slave.c
+++ b/daemon/gdm-slave.c
@@ -38,10 +38,6 @@
#include <glib/gi18n.h>
#include <glib-object.h>
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
#include <X11/Xlib.h> /* for Display */
#include <X11/Xatom.h> /* for XA_PIXMAP */
#include <X11/cursorfont.h> /* for watch cursor */
@@ -62,6 +58,7 @@
#include "gdm-slave.h"
#include "gdm-slave-glue.h"
+#include "gdm-display-glue.h"
#include "gdm-server.h"
@@ -83,7 +80,6 @@
struct GdmSlavePrivate
{
- char *id;
GPid pid;
guint output_watch_id;
guint error_watch_id;
@@ -102,11 +98,10 @@ struct GdmSlavePrivate
char *parent_display_name;
char *parent_display_x11_authority_file;
char *windowpath;
+ char *display_x11_cookie;
- GArray *display_x11_cookie;
-
- DBusGProxy *display_proxy;
- DBusGConnection *connection;
+ GdmDBusDisplay *display_proxy;
+ GDBusConnection *connection;
};
enum {
@@ -697,8 +692,8 @@ gdm_slave_connect_to_x11_display (GdmSlave *slave)
/* Give slave access to the display independent of current hostname */
XSetAuthorization ("MIT-MAGIC-COOKIE-1",
strlen ("MIT-MAGIC-COOKIE-1"),
- slave->priv->display_x11_cookie->data,
- slave->priv->display_x11_cookie->len);
+ slave->priv->display_x11_cookie,
+ strlen (slave->priv->display_x11_cookie));
slave->priv->server_display = XOpenDisplay (slave->priv->display_name);
@@ -737,15 +732,6 @@ gdm_slave_connect_to_x11_display (GdmSlave *slave)
return ret;
}
-static void
-display_proxy_destroyed_cb (DBusGProxy *display_proxy,
- GdmSlave *slave)
-{
- g_debug ("GdmSlave: Disconnected from display");
-
- slave->priv->display_proxy = NULL;
-}
-
static gboolean
gdm_slave_set_slave_bus_name (GdmSlave *slave)
{
@@ -753,23 +739,16 @@ gdm_slave_set_slave_bus_name (GdmSlave *slave)
GError *error;
const char *name;
- name = dbus_bus_get_unique_name (dbus_g_connection_get_connection (slave->priv->connection));
+ name = g_dbus_connection_get_unique_name (slave->priv->connection);
error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "SetSlaveBusName",
- &error,
- G_TYPE_STRING, name,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
-
+ res = gdm_dbus_display_call_set_slave_bus_name_sync (slave->priv->display_proxy,
+ name,
+ NULL,
+ &error);
if (! res) {
- if (error != NULL) {
- g_warning ("Failed to set slave bus name on parent: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to set slave bus name on parent");
- }
+ g_warning ("Failed to set slave bus name on parent: %s", error->message);
+ g_error_free (error);
}
return res;
@@ -788,42 +767,27 @@ gdm_slave_real_start (GdmSlave *slave)
g_debug ("GdmSlave: Creating proxy for %s", slave->priv->display_id);
error = NULL;
- slave->priv->display_proxy = dbus_g_proxy_new_for_name_owner (slave->priv->connection,
- GDM_DBUS_NAME,
- slave->priv->display_id,
- GDM_DBUS_DISPLAY_INTERFACE,
- &error);
- g_signal_connect (slave->priv->display_proxy,
- "destroy",
- G_CALLBACK (display_proxy_destroyed_cb),
- slave);
+ slave->priv->display_proxy = GDM_DBUS_DISPLAY (gdm_dbus_display_proxy_new_sync (slave->priv->connection,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ GDM_DBUS_NAME,
+ slave->priv->display_id,
+ NULL,
+ &error));
if (slave->priv->display_proxy == NULL) {
- if (error != NULL) {
- g_warning ("Failed to create display proxy %s: %s", slave->priv->display_id, error->message);
- g_error_free (error);
- } else {
- g_warning ("Unable to create display proxy");
- }
+ g_warning ("Failed to create display proxy %s: %s", slave->priv->display_id, error->message);
+ g_error_free (error);
return FALSE;
}
- /* Make sure display ID works */
error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetId",
- &error,
- G_TYPE_INVALID,
- DBUS_TYPE_G_OBJECT_PATH, &id,
- G_TYPE_INVALID);
+ res = gdm_dbus_display_call_get_id_sync (slave->priv->display_proxy,
+ &id,
+ NULL,
+ &error);
if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get display ID %s: %s", slave->priv->display_id, error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get display ID %s", slave->priv->display_id);
- }
-
+ g_warning ("Failed to get display ID %s: %s", slave->priv->display_id, error->message);
+ g_error_free (error);
return FALSE;
}
@@ -838,129 +802,79 @@ gdm_slave_real_start (GdmSlave *slave)
/* cache some values up front */
error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "IsLocal",
- &error,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &slave->priv->display_is_local,
- G_TYPE_INVALID);
+ res = gdm_dbus_display_call_is_local_sync (slave->priv->display_proxy,
+ &slave->priv->display_is_local,
+ NULL,
+ &error);
if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get value: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get value");
- }
-
+ g_warning ("Failed to get value: %s", error->message);
+ g_error_free (error);
return FALSE;
}
error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetX11DisplayName",
- &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &slave->priv->display_name,
- G_TYPE_INVALID);
+ res = gdm_dbus_display_call_get_x11_display_name_sync (slave->priv->display_proxy,
+ &slave->priv->display_name,
+ NULL,
+ &error);
if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get value: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get value");
- }
-
+ g_warning ("Failed to get value: %s", error->message);
+ g_error_free (error);
return FALSE;
}
error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetX11DisplayNumber",
- &error,
- G_TYPE_INVALID,
- G_TYPE_INT, &slave->priv->display_number,
- G_TYPE_INVALID);
+ res = gdm_dbus_display_call_get_x11_display_number_sync (slave->priv->display_proxy,
+ &slave->priv->display_number,
+ NULL,
+ &error);
if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get value: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get value");
- }
-
+ g_warning ("Failed to get value: %s", error->message);
+ g_error_free (error);
return FALSE;
}
error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetRemoteHostname",
- &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &slave->priv->display_hostname,
- G_TYPE_INVALID);
+ res = gdm_dbus_display_call_get_remote_hostname_sync (slave->priv->display_proxy,
+ &slave->priv->display_hostname,
+ NULL,
+ &error);
if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get value: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get value");
- }
-
+ g_warning ("Failed to get value: %s", error->message);
+ g_error_free (error);
return FALSE;
}
error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetX11Cookie",
- &error,
- G_TYPE_INVALID,
- dbus_g_type_get_collection ("GArray", G_TYPE_CHAR),
- &slave->priv->display_x11_cookie,
- G_TYPE_INVALID);
+ res = gdm_dbus_display_call_get_x11_cookie_sync (slave->priv->display_proxy,
+ &slave->priv->display_x11_cookie,
+ NULL,
+ &error);
if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get value: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get value");
- }
-
+ g_warning ("Failed to get value: %s", error->message);
+ g_error_free (error);
return FALSE;
}
error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetX11AuthorityFile",
- &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &slave->priv->display_x11_authority_file,
- G_TYPE_INVALID);
+ res = gdm_dbus_display_call_get_x11_authority_file_sync (slave->priv->display_proxy,
+ &slave->priv->display_x11_authority_file,
+ NULL,
+ &error);
if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get value: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get value");
- }
-
+ g_warning ("Failed to get value: %s", error->message);
+ g_error_free (error);
return FALSE;
}
error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetSeatId",
- &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &slave->priv->display_seat_id,
- G_TYPE_INVALID);
+ res = gdm_dbus_display_call_get_seat_id_sync (slave->priv->display_proxy,
+ &slave->priv->display_seat_id,
+ NULL,
+ &error);
if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get value: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get value");
- }
-
+ g_warning ("Failed to get value: %s", error->message);
+ g_error_free (error);
return FALSE;
}
@@ -972,9 +886,7 @@ gdm_slave_real_stop (GdmSlave *slave)
{
g_debug ("GdmSlave: Stopping slave");
- if (slave->priv->display_proxy != NULL) {
- g_object_unref (slave->priv->display_proxy);
- }
+ g_clear_object (&slave->priv->display_proxy);
return TRUE;
}
@@ -1039,21 +951,15 @@ gdm_slave_add_user_authorization (GdmSlave *slave,
g_debug ("GdmSlave: Requesting user authorization");
error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "AddUserAuthorization",
- &error,
- G_TYPE_STRING, username,
- G_TYPE_INVALID,
- G_TYPE_STRING, &filename,
- G_TYPE_INVALID);
+ res = gdm_dbus_display_call_add_user_authorization_sync (slave->priv->display_proxy,
+ username,
+ &filename,
+ NULL,
+ &error);
if (! res) {
- if (error != NULL) {
- g_warning ("Failed to add user authorization: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to add user authorization");
- }
+ g_warning ("Failed to add user authorization: %s", error->message);
+ g_error_free (error);
} else {
g_debug ("GdmSlave: Got user authorization: %s", filename);
}
@@ -1186,22 +1092,15 @@ gdm_slave_get_timed_login_details (GdmSlave *slave,
g_debug ("GdmSlave: Requesting timed login details");
error = NULL;
- res = dbus_g_proxy_call (slave->priv->display_proxy,
- "GetTimedLoginDetails",
- &error,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &enabled,
- G_TYPE_STRING, &username,
- G_TYPE_INT, &delay,
- G_TYPE_INVALID);
-
+ res = gdm_dbus_display_call_get_timed_login_details_sync (slave->priv->display_proxy,
+ &enabled,
+ &username,
+ &delay,
+ NULL,
+ &error);
if (! res) {
- if (error != NULL) {
- g_warning ("Failed to get timed login details: %s", error->message);
- g_error_free (error);
- } else {
- g_warning ("Failed to get timed login details");
- }
+ g_warning ("Failed to get timed login details: %s", error->message);
+ g_error_free (error);
} else {
g_debug ("GdmSlave: Got timed login details: %d %s %d", enabled, username, delay);
}
@@ -1282,61 +1181,66 @@ x11_session_is_on_seat (GdmSlave *slave,
const char *session_id,
const char *seat_id)
{
- DBusGProxy *proxy;
GError *error;
+ GVariant *reply;
char *sid;
- gboolean res;
gboolean ret;
char *x11_display_device;
char *x11_display;
ret = FALSE;
+ sid = NULL;
+ x11_display = NULL;
+ x11_display_device = NULL;
if (seat_id == NULL || seat_id[0] == '\0' || session_id == NULL || session_id[0] == '\0') {
return FALSE;
}
- proxy = dbus_g_proxy_new_for_name (slave->priv->connection,
- CK_NAME,
- session_id,
- CK_SESSION_INTERFACE);
- if (proxy == NULL) {
- g_warning ("Failed to connect to the ConsoleKit seat object");
- goto out;
- }
-
- sid = NULL;
- error = NULL;
- res = dbus_g_proxy_call (proxy,
- "GetSeatId",
- &error,
- G_TYPE_INVALID,
- DBUS_TYPE_G_OBJECT_PATH, &sid,
- G_TYPE_INVALID);
- if (! res) {
+ reply = g_dbus_connection_call_sync (slave->priv->connection,
+ CK_NAME,
+ session_id,
+ CK_SESSION_INTERFACE,
+ "GetSeatId",
+ NULL, /* parameters */
+ G_VARIANT_TYPE ("(o)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (reply == NULL) {
g_debug ("Failed to identify the current seat: %s", error->message);
g_error_free (error);
- goto out;
+ return FALSE;
}
+ g_variant_get (reply, "(o)", &sid);
+ g_variant_unref (reply);
+
if (sid == NULL || sid[0] == '\0' || strcmp (sid, seat_id) != 0) {
g_debug ("GdmSlave: session not on current seat: %s", seat_id);
goto out;
}
- x11_display = NULL;
- error = NULL;
- res = dbus_g_proxy_call (proxy,
- "GetX11Display",
- &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &x11_display,
- G_TYPE_INVALID);
- if (! res) {
+ reply = g_dbus_connection_call_sync (slave->priv->connection,
+ CK_NAME,
+ session_id,
+ CK_SESSION_INTERFACE,
+ "GetX11Display",
+ NULL, /* parameters */
+ G_VARIANT_TYPE ("(s)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (reply == NULL) {
g_error_free (error);
goto out;
}
+ g_variant_get (reply, "(s)", &x11_display);
+ g_variant_unref (reply);
+
/* don't try to switch to our own session */
if (x11_display == NULL || x11_display[0] == '\0'
|| strcmp (slave->priv->display_name, x11_display) == 0) {
@@ -1345,31 +1249,35 @@ x11_session_is_on_seat (GdmSlave *slave,
}
g_free (x11_display);
- x11_display_device = NULL;
- error = NULL;
- res = dbus_g_proxy_call (proxy,
- "GetX11DisplayDevice",
- &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &x11_display_device,
- G_TYPE_INVALID);
- if (! res) {
+ reply = g_dbus_connection_call_sync (slave->priv->connection,
+ CK_NAME,
+ session_id,
+ CK_SESSION_INTERFACE,
+ "GetX11DisplayDevice",
+ NULL, /* parameters */
+ G_VARIANT_TYPE ("(s)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (reply == NULL) {
g_error_free (error);
goto out;
}
+ g_variant_get (reply, "(s)", &x11_display_device);
+ g_variant_unref (reply);
+
if (x11_display_device == NULL || x11_display_device[0] == '\0') {
g_free (x11_display_device);
goto out;
}
- g_free (x11_display_device);
ret = TRUE;
-
out:
- if (proxy != NULL) {
- g_object_unref (proxy);
- }
+ g_free (x11_display_device);
+ g_free (x11_display);
+ g_free (sid);
return ret;
}
@@ -1465,96 +1373,79 @@ static char *
gdm_slave_get_primary_session_id_for_user_from_ck (GdmSlave *slave,
const char *username)
{
- gboolean res;
- gboolean can_activate_sessions;
- GError *error;
- DBusGProxy *manager_proxy;
- DBusGProxy *seat_proxy;
- GPtrArray *sessions;
- char *primary_ssid;
- int i;
- uid_t uid;
-
- manager_proxy = NULL;
+ gboolean can_activate_sessions;
+ GError *error;
+ char *primary_ssid;
+ uid_t uid;
+ GVariant *reply;
+ GVariant *array;
+ GVariantIter iter;
+ char *ssid;
+
primary_ssid = NULL;
- sessions = NULL;
g_debug ("GdmSlave: getting proxy for seat: %s", slave->priv->display_seat_id);
-
- seat_proxy = dbus_g_proxy_new_for_name (slave->priv->connection,
- CK_NAME,
- slave->priv->display_seat_id,
- CK_SEAT_INTERFACE);
-
g_debug ("GdmSlave: checking if seat can activate sessions");
- error = NULL;
- res = dbus_g_proxy_call (seat_proxy,
- "CanActivateSessions",
- &error,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN, &can_activate_sessions,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("unable to determine if seat can activate sessions: %s",
- error->message);
+ reply = g_dbus_connection_call_sync (slave->priv->connection,
+ CK_NAME,
+ slave->priv->display_seat_id,
+ CK_SEAT_INTERFACE,
+ "CanActivateSessions",
+ NULL, /* parameters */
+ G_VARIANT_TYPE ("(b)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (reply == NULL) {
+ g_warning ("unable to determine if seat can activate sessions: %s", error->message);
g_error_free (error);
- goto out;
+ return NULL;
}
+ g_variant_get (reply, "(b)", &can_activate_sessions);
+ g_variant_unref (reply);
+
if (! can_activate_sessions) {
g_debug ("GdmSlave: seat is unable to activate sessions");
- goto out;
+ return NULL;
}
- manager_proxy = dbus_g_proxy_new_for_name (slave->priv->connection,
- CK_NAME,
- CK_MANAGER_PATH,
- CK_MANAGER_INTERFACE);
-
if (! _get_uid_and_gid_for_user (username, &uid, NULL)) {
g_debug ("GdmSlave: unable to determine uid for user: %s", username);
- goto out;
+ return NULL;
}
- error = NULL;
- res = dbus_g_proxy_call (manager_proxy,
- "GetSessionsForUnixUser",
- &error,
- G_TYPE_UINT, uid,
- G_TYPE_INVALID,
- dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH), &sessions,
- G_TYPE_INVALID);
- if (! res) {
- g_warning ("unable to determine sessions for user: %s",
- error->message);
+ reply = g_dbus_connection_call_sync (slave->priv->connection,
+ CK_NAME,
+ CK_MANAGER_PATH,
+ CK_MANAGER_INTERFACE,
+ "CanSessionsForUnixUser",
+ g_variant_new ("(u)", uid),
+ G_VARIANT_TYPE ("(ao)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+ if (reply == NULL) {
+ g_warning ("unable to determine sessions for user: %s", error->message);
g_error_free (error);
- goto out;
+ return NULL;
}
- for (i = 0; i < sessions->len; i++) {
- char *ssid;
-
- ssid = g_ptr_array_index (sessions, i);
-
+ array = g_variant_get_child_value (reply, 0);
+ g_variant_iter_init (&iter, array);
+ while (g_variant_iter_loop (&iter, "(&s)", &ssid)) {
if (x11_session_is_on_seat (slave, ssid, slave->priv->display_seat_id)) {
primary_ssid = g_strdup (ssid);
break;
}
}
- g_ptr_array_foreach (sessions, (GFunc)g_free, NULL);
- g_ptr_array_free (sessions, TRUE);
-
- out:
-
- if (seat_proxy != NULL) {
- g_object_unref (seat_proxy);
- }
- if (manager_proxy != NULL) {
- g_object_unref (manager_proxy);
- }
-
+ g_variant_unref (reply);
+ g_variant_unref (array);
return primary_ssid;
}
#endif
@@ -1588,13 +1479,8 @@ activate_session_id_for_systemd (GdmSlave *slave,
const char *seat_id,
const char *session_id)
{
- DBusError local_error;
- DBusMessage *message;
- DBusMessage *reply;
- gboolean ret;
-
- ret = FALSE;
- reply = NULL;
+ GError *error = NULL;
+ GVariant *reply;
/* Can't activate what's already active. We want this
* to fail, because we don't want migration to succeed
@@ -1605,44 +1491,27 @@ activate_session_id_for_systemd (GdmSlave *slave,
return FALSE;
}
- dbus_error_init (&local_error);
-
- message = dbus_message_new_method_call ("org.freedesktop.login1",
- "/org/freedesktop/login1",
- "org.freedesktop.login1.Manager",
- "ActivateSessionOnSeat");
- if (message == NULL) {
- goto out;
- }
-
- if (! dbus_message_append_args (message,
- DBUS_TYPE_STRING, &session_id,
- DBUS_TYPE_STRING, &seat_id,
- DBUS_TYPE_INVALID)) {
- goto out;
- }
-
- reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (slave->priv->connection),
- message,
- -1,
- &local_error);
- if (dbus_error_is_set (&local_error)) {
- g_warning ("GdmSlave: Unable to activate session: %s", local_error.message);
- dbus_error_free (&local_error);
- goto out;
+ reply = g_dbus_connection_call_sync (slave->priv->connection,
+ "org.freedesktop.login1",
+ "/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager",
+ "ActivateSessionOnSeat",
+ g_variant_new ("(ss)", session_id, seat_id),
+ NULL, /* expected reply */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (reply == NULL) {
+ g_debug ("GdmSlave: logind %s raised:\n %s\n\n",
+ g_dbus_error_get_remote_error (error), error->message);
+ g_error_free (error);
+ return FALSE;
}
- ret = TRUE;
+ g_variant_unref (reply);
- out:
- if (message != NULL) {
- dbus_message_unref (message);
- }
- if (reply != NULL) {
- dbus_message_unref (reply);
- }
-
- return ret;
+ return TRUE;
}
#endif
@@ -1652,51 +1521,30 @@ activate_session_id_for_ck (GdmSlave *slave,
const char *seat_id,
const char *session_id)
{
- DBusError local_error;
- DBusMessage *message;
- DBusMessage *reply;
- gboolean ret;
-
- ret = FALSE;
- reply = NULL;
-
- dbus_error_init (&local_error);
- message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit",
- seat_id,
- "org.freedesktop.ConsoleKit.Seat",
- "ActivateSession");
- if (message == NULL) {
- goto out;
- }
-
- if (! dbus_message_append_args (message,
- DBUS_TYPE_OBJECT_PATH, &session_id,
- DBUS_TYPE_INVALID)) {
- goto out;
- }
-
- reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (slave->priv->connection),
- message,
- -1,
- &local_error);
+ GError *error = NULL;
+ GVariant *reply;
+
+ reply = g_dbus_connection_call_sync (slave->priv->connection,
+ CK_NAME,
+ seat_id,
+ "org.freedesktop.ConsoleKit.Seat",
+ "ActivateSession",
+ g_variant_new ("(o)", session_id),
+ NULL, /* expected reply */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
if (reply == NULL) {
- if (dbus_error_is_set (&local_error)) {
- g_warning ("Unable to activate session: %s", local_error.message);
- dbus_error_free (&local_error);
- goto out;
- }
+ g_debug ("GdmSlave: ConsoleKit %s raised:\n %s\n\n",
+ g_dbus_error_get_remote_error (error), error->message);
+ g_error_free (error);
+ return FALSE;
}
- ret = TRUE;
- out:
- if (message != NULL) {
- dbus_message_unref (message);
- }
- if (reply != NULL) {
- dbus_message_unref (reply);
- }
+ g_variant_unref (reply);
- return ret;
+ return TRUE;
}
#endif
@@ -1724,42 +1572,28 @@ static gboolean
session_unlock_for_systemd (GdmSlave *slave,
const char *ssid)
{
- DBusError error;
- DBusMessage *message;
- DBusMessage *reply;
-
- dbus_error_init (&error);
-
- message = dbus_message_new_method_call ("org.freedesktop.login1",
- "/org/freedesktop/login1",
- "org.freedesktop.login1.Manager",
- "UnlockSession");
-
- if (message == NULL) {
- g_debug ("GdmSlave: couldn't allocate the D-Bus message");
- return FALSE;
- }
-
- if (! dbus_message_append_args (message,
- DBUS_TYPE_STRING, &ssid,
- DBUS_TYPE_INVALID)) {
- g_debug ("GdmSlave: couldn't attach the D-Bus message data");
+ GError *error = NULL;
+ GVariant *reply;
+
+ reply = g_dbus_connection_call_sync (slave->priv->connection,
+ "org.freedesktop.login1",
+ "/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager",
+ "UnlockSession",
+ g_variant_new ("(s)", ssid),
+ NULL, /* expected reply */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (reply == NULL) {
+ g_debug ("GdmSlave: logind %s raised:\n %s\n\n",
+ g_dbus_error_get_remote_error (error), error->message);
+ g_error_free (error);
return FALSE;
}
- reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (slave->priv->connection),
- message,
- -1, &error);
- dbus_message_unref(message);
- if (reply != NULL) {
- dbus_message_unref(reply);
- }
-
- if (dbus_error_is_set (&error)) {
- g_warning ("GdmSlave: Unable to unlock session: %s", error.message);
- dbus_error_free (&error);
- return FALSE;
- }
+ g_variant_unref (reply);
return TRUE;
}
@@ -1770,34 +1604,28 @@ static gboolean
session_unlock_for_ck (GdmSlave *slave,
const char *ssid)
{
- DBusError error;
- DBusMessage *message;
- DBusMessage *reply;
-
- message = dbus_message_new_method_call (CK_NAME,
- ssid,
- CK_SESSION_INTERFACE,
- "Unlock");
- if (message == NULL) {
- g_debug ("GdmSlave: ConsoleKit couldn't allocate the D-Bus message");
+ GError *error = NULL;
+ GVariant *reply;
+
+ reply = g_dbus_connection_call_sync (slave->priv->connection,
+ CK_NAME,
+ ssid,
+ CK_SESSION_INTERFACE,
+ "Unlock",
+ NULL, /* parameters */
+ NULL, /* expected reply */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (reply == NULL) {
+ g_debug ("GdmSlave: ConsoleKit %s raised:\n %s\n\n",
+ g_dbus_error_get_remote_error (error), error->message);
+ g_error_free (error);
return FALSE;
}
- dbus_error_init (&error);
- reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (slave->priv->connection),
- message,
- -1, &error);
- dbus_message_unref (message);
- if (reply != NULL) {
- dbus_message_unref (reply);
- }
- dbus_connection_flush (dbus_g_connection_get_connection (slave->priv->connection));
-
- if (dbus_error_is_set (&error)) {
- g_debug ("GdmSlave: ConsoleKit %s raised:\n %s\n\n", error.name, error.message);
- dbus_error_free (&error);
- return FALSE;
- }
+ g_variant_unref (reply);
return TRUE;
}
@@ -1997,17 +1825,15 @@ register_slave (GdmSlave *slave)
GError *error;
error = NULL;
- slave->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ slave->priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM,
+ NULL,
+ &error);
if (slave->priv->connection == NULL) {
- if (error != NULL) {
- g_critical ("error getting system bus: %s", error->message);
- g_error_free (error);
- }
+ g_critical ("error getting system bus: %s", error->message);
+ g_error_free (error);
exit (1);
}
- dbus_g_connection_register_g_object (slave->priv->connection, slave->priv->id, G_OBJECT (slave));
-
return TRUE;
}
@@ -2018,22 +1844,11 @@ gdm_slave_constructor (GType type,
{
GdmSlave *slave;
gboolean res;
- const char *id;
slave = GDM_SLAVE (G_OBJECT_CLASS (gdm_slave_parent_class)->constructor (type,
n_construct_properties,
construct_properties));
- /* Always match the slave id with the master */
-
- id = NULL;
- if (g_str_has_prefix (slave->priv->display_id, "/org/gnome/DisplayManager/Display")) {
- id = slave->priv->display_id + strlen ("/org/gnome/DisplayManager/Display");
- }
-
- g_assert (id != NULL);
-
- slave->priv->id = g_strdup_printf ("/org/gnome/DisplayManager/Slave%s", id);
- g_debug ("GdmSlave: Registering %s", slave->priv->id);
+ g_debug ("GdmSlave: Registering");
res = register_slave (slave);
if (! res) {
@@ -2120,8 +1935,6 @@ gdm_slave_class_init (GdmSlaveClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
-
- dbus_g_object_type_install_info (GDM_TYPE_SLAVE, &dbus_glib_gdm_slave_object_info);
}
static void
@@ -2147,7 +1960,6 @@ gdm_slave_finalize (GObject *object)
gdm_slave_real_stop (slave);
- g_free (slave->priv->id);
g_free (slave->priv->display_id);
g_free (slave->priv->display_name);
g_free (slave->priv->display_hostname);
@@ -2156,9 +1968,7 @@ gdm_slave_finalize (GObject *object)
g_free (slave->priv->parent_display_name);
g_free (slave->priv->parent_display_x11_authority_file);
g_free (slave->priv->windowpath);
- if (slave->priv->display_x11_cookie != NULL) {
- g_array_free (slave->priv->display_x11_cookie, TRUE);
- }
+ g_free (slave->priv->display_x11_cookie);
G_OBJECT_CLASS (gdm_slave_parent_class)->finalize (object);
}
diff --git a/daemon/gdm-slave.h b/daemon/gdm-slave.h
index aaaa8f2..128ca3e 100644
--- a/daemon/gdm-slave.h
+++ b/daemon/gdm-slave.h
@@ -23,6 +23,7 @@
#define __GDM_SLAVE_H
#include <glib-object.h>
+#include <gio/gio.h>
G_BEGIN_DECLS
diff --git a/daemon/gdm-static-display.c b/daemon/gdm-static-display.c
index 16953f9..3065ce6 100644
--- a/daemon/gdm-static-display.c
+++ b/daemon/gdm-static-display.c
@@ -45,6 +45,7 @@
struct GdmStaticDisplayPrivate
{
+ GdmDBusStaticDisplay *skeleton;
gboolean first_login;
};
@@ -140,11 +141,44 @@ gdm_static_display_get_timed_login_details (GdmDisplay *display,
}
}
+static GObject *
+gdm_static_display_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
+{
+ GdmStaticDisplay *display;
+
+ display = GDM_STATIC_DISPLAY (G_OBJECT_CLASS (gdm_static_display_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_properties));
+
+ display->priv->skeleton = GDM_DBUS_STATIC_DISPLAY (gdm_dbus_static_display_skeleton_new ());
+
+ g_dbus_object_skeleton_add_interface (gdm_display_get_object_skeleton (GDM_DISPLAY (display)),
+ G_DBUS_INTERFACE_SKELETON (display->priv->skeleton));
+
+ return G_OBJECT (display);
+}
+
+static void
+gdm_static_display_finalize (GObject *object)
+{
+ GdmStaticDisplay *display = GDM_STATIC_DISPLAY (object);
+
+ g_clear_object (&display->priv->skeleton);
+
+ G_OBJECT_CLASS (gdm_static_display_parent_class)->finalize (object);
+}
+
static void
gdm_static_display_class_init (GdmStaticDisplayClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
+ object_class->constructor = gdm_static_display_constructor;
+ object_class->finalize = gdm_static_display_finalize;
+
display_class->create_authority = gdm_static_display_create_authority;
display_class->add_user_authorization = gdm_static_display_add_user_authorization;
display_class->remove_user_authorization = gdm_static_display_remove_user_authorization;
@@ -154,8 +188,6 @@ gdm_static_display_class_init (GdmStaticDisplayClass *klass)
display_class->get_timed_login_details = gdm_static_display_get_timed_login_details;
g_type_class_add_private (klass, sizeof (GdmStaticDisplayPrivate));
-
- dbus_g_object_type_install_info (GDM_TYPE_STATIC_DISPLAY, &dbus_glib_gdm_static_display_object_info);
}
static void
diff --git a/daemon/gdm-static-display.h b/daemon/gdm-static-display.h
index f5fd424..6c9356a 100644
--- a/daemon/gdm-static-display.h
+++ b/daemon/gdm-static-display.h
@@ -23,7 +23,6 @@
#define __GDM_STATIC_DISPLAY_H
#include <glib-object.h>
-#include <dbus/dbus-glib.h>
#include "gdm-display.h"
G_BEGIN_DECLS
diff --git a/daemon/gdm-transient-display.c b/daemon/gdm-transient-display.c
index 13d7bfe..2615440 100644
--- a/daemon/gdm-transient-display.c
+++ b/daemon/gdm-transient-display.c
@@ -35,6 +35,7 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <glib-object.h>
+#include <gio/gio.h>
#include "gdm-common.h"
#include "gdm-display.h"
@@ -45,7 +46,7 @@
struct GdmTransientDisplayPrivate
{
- gpointer dummy;
+ GdmDBusTransientDisplay *skeleton;
};
static void gdm_transient_display_class_init (GdmTransientDisplayClass *klass);
@@ -124,11 +125,44 @@ gdm_transient_display_get_timed_login_details (GdmDisplay *display,
*delayp = 0;
}
+static GObject *
+gdm_transient_display_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
+{
+ GdmTransientDisplay *display;
+
+ display = GDM_TRANSIENT_DISPLAY (G_OBJECT_CLASS (gdm_transient_display_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_properties));
+
+ display->priv->skeleton = GDM_DBUS_TRANSIENT_DISPLAY (gdm_dbus_transient_display_skeleton_new ());
+
+ g_dbus_object_skeleton_add_interface (gdm_display_get_object_skeleton (GDM_DISPLAY (display)),
+ G_DBUS_INTERFACE_SKELETON (display->priv->skeleton));
+
+ return G_OBJECT (display);
+}
+
+static void
+gdm_transient_display_finalize (GObject *object)
+{
+ GdmTransientDisplay *display = GDM_TRANSIENT_DISPLAY (object);
+
+ g_clear_object (&display->priv->skeleton);
+
+ G_OBJECT_CLASS (gdm_transient_display_parent_class)->finalize (object);
+}
+
static void
gdm_transient_display_class_init (GdmTransientDisplayClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
+ object_class->constructor = gdm_transient_display_constructor;
+ object_class->finalize = gdm_transient_display_finalize;
+
display_class->create_authority = gdm_transient_display_create_authority;
display_class->add_user_authorization = gdm_transient_display_add_user_authorization;
display_class->remove_user_authorization = gdm_transient_display_remove_user_authorization;
@@ -138,8 +172,6 @@ gdm_transient_display_class_init (GdmTransientDisplayClass *klass)
display_class->get_timed_login_details = gdm_transient_display_get_timed_login_details;
g_type_class_add_private (klass, sizeof (GdmTransientDisplayPrivate));
-
- dbus_g_object_type_install_info (GDM_TYPE_TRANSIENT_DISPLAY, &dbus_glib_gdm_transient_display_object_info);
}
static void
diff --git a/daemon/gdm-transient-display.h b/daemon/gdm-transient-display.h
index 36ef719..2e0dc1b 100644
--- a/daemon/gdm-transient-display.h
+++ b/daemon/gdm-transient-display.h
@@ -23,7 +23,6 @@
#define __GDM_TRANSIENT_DISPLAY_H
#include <glib-object.h>
-#include <dbus/dbus-glib.h>
#include "gdm-display.h"
G_BEGIN_DECLS
diff --git a/daemon/gdm-xdmcp-chooser-display.c b/daemon/gdm-xdmcp-chooser-display.c
index ba6c48b..efdcdf1 100644
--- a/daemon/gdm-xdmcp-chooser-display.c
+++ b/daemon/gdm-xdmcp-chooser-display.c
@@ -37,21 +37,23 @@
#include "gdm-display.h"
#include "gdm-xdmcp-chooser-display.h"
-#include "gdm-xdmcp-chooser-display-glue.h"
+#include "gdm-xdmcp-display-glue.h"
+#include "gdm-xdmcp-chooser-slave-glue.h"
#include "gdm-common.h"
#include "gdm-address.h"
#define DEFAULT_SLAVE_COMMAND LIBEXECDIR"/gdm-xdmcp-chooser-slave"
-#define GDM_DBUS_NAME "/org/gnome/DisplayManager"
-#define GDM_XDMCP_CHOOSER_SLAVE_DBUS_INTERFACE "org.gnome.DisplayManager.XdmcpChooserSlave"
+
+#define GDM_SLAVE_PATH "/org/gnome/DisplayManager/Slave"
#define GDM_XDMCP_CHOOSER_DISPLAY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_XDMCP_CHOOSER_DISPLAY, GdmXdmcpChooserDisplayPrivate))
struct GdmXdmcpChooserDisplayPrivate
{
- DBusGProxy *slave_proxy;
+ GdmDBusXdmcpDisplay *skeleton;
+ GdmDBusXdmcpChooserSlave *slave_proxy;
};
enum {
@@ -69,9 +71,9 @@ static gboolean gdm_xdmcp_chooser_display_finish (GdmDisplay *display);
G_DEFINE_TYPE (GdmXdmcpChooserDisplay, gdm_xdmcp_chooser_display, GDM_TYPE_XDMCP_DISPLAY)
static void
-on_hostname_selected (DBusGProxy *proxy,
- const char *hostname,
- GdmXdmcpChooserDisplay *display)
+on_hostname_selected (GdmDBusXdmcpChooserSlave *proxy,
+ const char *hostname,
+ GdmXdmcpChooserDisplay *display)
{
g_debug ("GdmXdmcpChooserDisplay: hostname selected: %s", hostname);
g_signal_emit (display, signals [HOSTNAME_SELECTED], 0, hostname);
@@ -82,63 +84,40 @@ gdm_xdmcp_chooser_display_set_slave_bus_name (GdmDisplay *display,
const char *name,
GError **error)
{
- char *display_id;
- const char *slave_num;
- char *slave_id;
- DBusGConnection *connection;
+ GDBusConnection *connection;
GError *local_error;
GdmXdmcpChooserDisplay *chooser_display;
- display_id = NULL;
- slave_id = NULL;
- slave_num = NULL;
-
chooser_display = GDM_XDMCP_CHOOSER_DISPLAY (display);
- if (chooser_display->priv->slave_proxy != NULL) {
- g_object_unref (chooser_display->priv->slave_proxy);
- }
-
- g_object_get (display, "id", &display_id, NULL);
-
- if (g_str_has_prefix (display_id, "/org/gnome/DisplayManager/Display")) {
- slave_num = display_id + strlen ("/org/gnome/DisplayManager/Display");
- }
-
- slave_id = g_strdup_printf ("/org/gnome/DisplayManager/Slave%s", slave_num);
+ g_clear_object (&chooser_display->priv->slave_proxy);
local_error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &local_error);
+ connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &local_error);
if (connection == NULL) {
- if (local_error != NULL) {
- g_critical ("error getting system bus: %s", local_error->message);
- g_error_free (local_error);
- }
+ g_critical ("error getting system bus: %s", local_error->message);
+ g_error_free (local_error);
}
- g_debug ("GdmXdmcpChooserDisplay: creating proxy for %s on %s", slave_id, name);
+ g_debug ("GdmXdmcpChooserDisplay: creating proxy for slave on %s" , name);
- chooser_display->priv->slave_proxy = dbus_g_proxy_new_for_name (connection,
- name,
- slave_id,
- GDM_XDMCP_CHOOSER_SLAVE_DBUS_INTERFACE);
+ chooser_display->priv->slave_proxy = GDM_DBUS_XDMCP_CHOOSER_SLAVE (
+ gdm_dbus_xdmcp_chooser_slave_proxy_new_sync (connection,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ name,
+ GDM_SLAVE_PATH,
+ NULL,
+ &local_error));
if (chooser_display->priv->slave_proxy == NULL) {
- g_warning ("Failed to connect to the slave object");
+ g_warning ("Failed to connect to the slave object: %s", local_error->message);
+ g_error_free (local_error);
goto out;
}
- dbus_g_proxy_add_signal (chooser_display->priv->slave_proxy,
- "HostnameSelected",
- G_TYPE_STRING,
- G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (chooser_display->priv->slave_proxy,
- "HostnameSelected",
- G_CALLBACK (on_hostname_selected),
- display,
- NULL);
- out:
-
- g_free (display_id);
- g_free (slave_id);
+ g_signal_connect (chooser_display->priv->slave_proxy,
+ "hostname-selected",
+ G_CALLBACK (on_hostname_selected),
+ display);
+ out:
return GDM_DISPLAY_CLASS (gdm_xdmcp_chooser_display_parent_class)->set_slave_bus_name (display, name, error);
}
@@ -152,12 +131,32 @@ gdm_xdmcp_chooser_display_manage (GdmDisplay *display)
return TRUE;
}
+static GObject *
+gdm_xdmcp_chooser_display_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
+{
+ GdmXdmcpChooserDisplay *display;
+
+ display = GDM_XDMCP_CHOOSER_DISPLAY (G_OBJECT_CLASS (gdm_xdmcp_chooser_display_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_properties));
+
+ display->priv->skeleton = GDM_DBUS_XDMCP_DISPLAY (gdm_dbus_xdmcp_display_skeleton_new ());
+
+ g_dbus_object_skeleton_add_interface (gdm_display_get_object_skeleton (GDM_DISPLAY (display)),
+ G_DBUS_INTERFACE_SKELETON (display->priv->skeleton));
+
+ return G_OBJECT (display);
+}
+
static void
gdm_xdmcp_chooser_display_class_init (GdmXdmcpChooserDisplayClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
+ object_class->constructor = gdm_xdmcp_chooser_display_constructor;
object_class->finalize = gdm_xdmcp_chooser_display_finalize;
display_class->manage = gdm_xdmcp_chooser_display_manage;
@@ -177,8 +176,6 @@ gdm_xdmcp_chooser_display_class_init (GdmXdmcpChooserDisplayClass *klass)
G_TYPE_STRING);
g_type_class_add_private (klass, sizeof (GdmXdmcpChooserDisplayPrivate));
-
- dbus_g_object_type_install_info (GDM_TYPE_XDMCP_CHOOSER_DISPLAY, &dbus_glib_gdm_xdmcp_chooser_display_object_info);
}
static void
@@ -200,9 +197,8 @@ gdm_xdmcp_chooser_display_finalize (GObject *object)
g_return_if_fail (chooser_display->priv != NULL);
- if (chooser_display->priv->slave_proxy != NULL) {
- g_object_unref (chooser_display->priv->slave_proxy);
- }
+ g_clear_object (&chooser_display->priv->slave_proxy);
+ g_clear_object (&chooser_display->priv->skeleton);
G_OBJECT_CLASS (gdm_xdmcp_chooser_display_parent_class)->finalize (object);
}
diff --git a/daemon/gdm-xdmcp-chooser-display.h b/daemon/gdm-xdmcp-chooser-display.h
index 8ab17b8..e061263 100644
--- a/daemon/gdm-xdmcp-chooser-display.h
+++ b/daemon/gdm-xdmcp-chooser-display.h
@@ -25,7 +25,6 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <glib-object.h>
-#include <dbus/dbus-glib.h>
#include "gdm-xdmcp-display.h"
#include "gdm-address.h"
diff --git a/daemon/gdm-xdmcp-chooser-slave.c b/daemon/gdm-xdmcp-chooser-slave.c
index fee3630..2dd6edc 100644
--- a/daemon/gdm-xdmcp-chooser-slave.c
+++ b/daemon/gdm-xdmcp-chooser-slave.c
@@ -340,8 +340,6 @@ gdm_xdmcp_chooser_slave_class_init (GdmXdmcpChooserSlaveClass *klass)
G_TYPE_STRING);
g_type_class_add_private (klass, sizeof (GdmXdmcpChooserSlavePrivate));
-
- dbus_g_object_type_install_info (GDM_TYPE_XDMCP_CHOOSER_SLAVE, &dbus_glib_gdm_xdmcp_chooser_slave_object_info);
}
static void
diff --git a/daemon/gdm-xdmcp-display.h b/daemon/gdm-xdmcp-display.h
index db9b401..8802a86 100644
--- a/daemon/gdm-xdmcp-display.h
+++ b/daemon/gdm-xdmcp-display.h
@@ -25,7 +25,6 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <glib-object.h>
-#include <dbus/dbus-glib.h>
#include "gdm-display.h"
#include "gdm-address.h"
diff --git a/daemon/gdm-xdmcp-greeter-display.xml b/daemon/gdm-xdmcp-display.xml
similarity index 100%
rename from daemon/gdm-xdmcp-greeter-display.xml
rename to daemon/gdm-xdmcp-display.xml
diff --git a/daemon/gdm-xdmcp-greeter-display.h b/daemon/gdm-xdmcp-greeter-display.h
index c4c82a5..b99cd99 100644
--- a/daemon/gdm-xdmcp-greeter-display.h
+++ b/daemon/gdm-xdmcp-greeter-display.h
@@ -24,7 +24,6 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <glib-object.h>
-#include <dbus/dbus-glib.h>
#include "gdm-xdmcp-display.h"
#include "gdm-address.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]