Commit dddeab1c authored by Giovanni Campagna's avatar Giovanni Campagna Committed by Ray Strode

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
parent 0478d422
......@@ -28,7 +28,9 @@ 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
gdm.pot
gdm-restart
......@@ -41,12 +43,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
......
......@@ -33,8 +33,7 @@ BUILT_SOURCES = \
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 \
......@@ -43,22 +42,41 @@ 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-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-local-display-factory-glue.h: gdm-local-display-factory.xml Makefile.am
dbus-binding-tool --prefix=gdm_local_display_factory --mode=glib-server --output=gdm-local-display-factory-glue.h $(srcdir)/gdm-local-display-factory.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 \
--c-namespace=GdmDBus \
--interface-prefix=org.gnome.DisplayManager \
--generate-c-code=gdm-local-display-factory-glue \
$(srcdir)/gdm-local-display-factory.xml
gdm-greeter-glue.c gdm-greeter-glue.h : gdm-greeter-server.xml Makefile.am
$(AM_V_GEN)gdbus-codegen \
......@@ -67,6 +85,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)
......@@ -129,6 +161,10 @@ gdm_simple_slave_SOURCES = \
nodist_gdm_simple_slave_SOURCES = \
gdm-greeter-glue.c \
gdm-greeter-glue.h \
gdm-display-glue.c \
gdm-display-glue.h \
gdm-slave-glue.c \
gdm-slave-glue.h \
$(NULL)
gdm_simple_slave_LDFLAGS = \
......@@ -168,6 +204,15 @@ gdm_xdmcp_chooser_slave_SOURCES = \
gdm-dbus-util.h \
$(NULL)
nodist_gdm_xdmcp_chooser_slave_SOURCES = \
gdm-greeter-glue.c \
gdm-greeter-glue.h \
gdm-display-glue.c \
gdm-display-glue.h \
gdm-slave-glue.c \
gdm-slave-glue.h \
$(NULL)
gdm_xdmcp_chooser_slave_LDADD = \
$(XLIB_LIBS) \
$(DAEMON_LIBS) \
......@@ -234,6 +279,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 \
......@@ -245,8 +301,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 = \
......@@ -284,9 +348,17 @@ sbin_SCRIPTS = \
gdm: $(srcdir)/gdm.in
sed -e 's,[@]sbindir[@],$(sbindir),g' <$(srcdir)/gdm.in >gdm
CLEANFILES = \
gdm \
$(BUILT_SOURCES) \
CLEANFILES = \
gdm \
gdm-display-glue.c \
gdm-greeter-glue.c \
gdm-local-display-factory-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)
EXTRA_DIST = \
......@@ -298,8 +370,7 @@ EXTRA_DIST = \
gdm-session.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 \
......
......@@ -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;
}
......@@ -933,22 +939,273 @@ 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;
seat_id = NULL;
gdm_display_get_seat_id (display, &seat_id, NULL);
if (seat_id == NULL) {
seat_id = g_strdup ("");
}
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;
}
......@@ -1115,8 +1372,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
......@@ -1149,6 +1404,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);
}
......@@ -1163,3 +1422,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;
}
......@@ -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,
......
......@@ -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>
......
......@@ -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,