diff options
author | Ray Strode <rstrode@redhat.com> | 2017-07-28 16:04:11 -0400 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2017-10-20 14:14:14 -0400 |
commit | 5683e5d5a6bc37c7a1b52a633cc79c70b60defb3 (patch) | |
tree | ef4b603dd5e6e991c2c6f5f570b7405559e97918 /daemon | |
parent | 932dd92bd4eddd2145db9131b01555987b793463 (diff) | |
download | gdm-5683e5d5a6bc37c7a1b52a633cc79c70b60defb3.tar.gz |
session: add new Initialize method
Right now the worker interface has three methods for starting
a conversation: Setup, SetupForUser, SetupForProgram
Each of these method calls take a large number of overlapping arguments.
Extending these argument lists is painful and breaks upgrades.
This commit adds a new, fourth call, Initialize, which supercedes the
others and just takes a vardict, which is much more extensible.
https://bugzilla.gnome.org/show_bug.cgi?id=788851
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/gdm-session-worker.c | 53 | ||||
-rw-r--r-- | daemon/gdm-session-worker.xml | 3 | ||||
-rw-r--r-- | daemon/gdm-session.c | 211 |
3 files changed, 98 insertions, 169 deletions
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c index 890fd91f..66d9e6d1 100644 --- a/daemon/gdm-session-worker.c +++ b/daemon/gdm-session-worker.c @@ -2818,6 +2818,57 @@ gdm_session_worker_handle_open (GdmDBusWorker *object, } static gboolean +gdm_session_worker_handle_initialize (GdmDBusWorker *object, + GDBusMethodInvocation *invocation, + GVariant *details) +{ + GdmSessionWorker *worker = GDM_SESSION_WORKER (object); + GVariantIter iter; + char *key; + GVariant *value; + + validate_and_queue_state_change (worker, invocation, GDM_SESSION_WORKER_STATE_SETUP_COMPLETE); + + g_variant_iter_init (&iter, details); + while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) { + if (g_strcmp0 (key, "service") == 0) { + worker->priv->service = g_strdup (g_variant_get_string (value, NULL)); + } else if (g_strcmp0 (key, "username") == 0) { + worker->priv->username = g_strdup (g_variant_get_string (value, NULL)); + } else if (g_strcmp0 (key, "is-program-session") == 0) { + worker->priv->is_program_session = g_variant_get_boolean (value); + } else if (g_strcmp0 (key, "log-file") == 0) { + worker->priv->log_file = g_strdup (g_variant_get_string (value, NULL)); + } else if (g_strcmp0 (key, "x11-display-name") == 0) { + worker->priv->x11_display_name = g_strdup (g_variant_get_string (value, NULL)); + } else if (g_strcmp0 (key, "x11-authority-file") == 0) { + worker->priv->x11_authority_file = g_strdup (g_variant_get_string (value, NULL)); + } else if (g_strcmp0 (key, "console") == 0) { + worker->priv->display_device = g_strdup (g_variant_get_string (value, NULL)); + } else if (g_strcmp0 (key, "seat-id") == 0) { + worker->priv->display_seat_id = g_strdup (g_variant_get_string (value, NULL)); + } else if (g_strcmp0 (key, "hostname") == 0) { + worker->priv->hostname = g_strdup (g_variant_get_string (value, NULL)); + } else if (g_strcmp0 (key, "display-is-local") == 0) { + worker->priv->display_is_local = g_variant_get_boolean (value); + } else if (g_strcmp0 (key, "display-is-initial") == 0) { + worker->priv->display_is_initial = g_variant_get_boolean (value); + } + } + + g_signal_connect_swapped (worker->priv->user_settings, + "notify::language-name", + G_CALLBACK (on_saved_language_name_read), + worker); + + g_signal_connect_swapped (worker->priv->user_settings, + "notify::session-name", + G_CALLBACK (on_saved_session_name_read), + worker); + return TRUE; +} + +static gboolean gdm_session_worker_handle_setup (GdmDBusWorker *object, GDBusMethodInvocation *invocation, const char *service, @@ -3189,6 +3240,8 @@ gdm_session_worker_constructor (GType type, static void worker_interface_init (GdmDBusWorkerIface *interface) { + interface->handle_initialize = gdm_session_worker_handle_initialize; + /* The next three are for backward compat only */ interface->handle_setup = gdm_session_worker_handle_setup; interface->handle_setup_for_user = gdm_session_worker_handle_setup_for_user; interface->handle_setup_for_program = gdm_session_worker_handle_setup_for_program; diff --git a/daemon/gdm-session-worker.xml b/daemon/gdm-session-worker.xml index 9f6d8b35..4280fe09 100644 --- a/daemon/gdm-session-worker.xml +++ b/daemon/gdm-session-worker.xml @@ -24,6 +24,9 @@ <arg name="command" direction="in" type="s"/> <arg name="child_pid" direction="out" type="i"/> </method> + <method name="Initialize"> + <arg name="details" direction="in" type="a{sv}"/> + </method> <method name="Setup"> <arg name="service_name" direction="in" type="s"/> <arg name="x11_display_name" direction="in" type="s"/> diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c index af9f6fb3..812c7be0 100644 --- a/daemon/gdm-session.c +++ b/daemon/gdm-session.c @@ -2050,9 +2050,9 @@ gdm_session_stop_conversation (GdmSession *self, } static void -on_setup_complete_cb (GdmDBusWorker *proxy, - GAsyncResult *res, - gpointer user_data) +on_initialization_complete_cb (GdmDBusWorker *proxy, + GAsyncResult *res, + gpointer user_data) { GdmSessionConversation *conversation = user_data; GdmSession *self; @@ -2094,188 +2094,59 @@ on_setup_complete_cb (GdmDBusWorker *proxy, } static void -send_setup (GdmSession *self, - const char *service_name) +initialize (GdmSession *self, + const char *service_name, + const char *username, + const char *log_file) { - const char *display_name; - const char *display_device; - const char *display_seat_id; - const char *display_hostname; - const char *display_x11_authority_file; + GVariantBuilder details; GdmSessionConversation *conversation; g_assert (service_name != NULL); - if (self->priv->display_name != NULL) { - display_name = self->priv->display_name; - } else { - display_name = ""; - } - if (self->priv->display_hostname != NULL) { - display_hostname = self->priv->display_hostname; - } else { - display_hostname = ""; - } - if (self->priv->display_device != NULL) { - display_device = self->priv->display_device; - } else { - display_device = ""; - } - if (self->priv->display_seat_id != NULL) { - display_seat_id = self->priv->display_seat_id; - } else { - display_seat_id = ""; - } - if (self->priv->display_x11_authority_file != NULL) { - display_x11_authority_file = self->priv->display_x11_authority_file; - } else { - display_x11_authority_file = ""; - } + g_variant_builder_init (&details, G_VARIANT_TYPE ("a{sv}")); - g_debug ("GdmSession: Beginning setup"); + g_variant_builder_add_parsed (&details, "{'service', <%s>}", service_name); + if (username != NULL) + g_variant_builder_add_parsed (&details, "{'username', <%s>}", username); - conversation = find_conversation_by_name (self, service_name); - if (conversation != NULL) { - gdm_dbus_worker_call_setup (conversation->worker_proxy, - service_name, - display_name, - display_x11_authority_file, - display_device, - display_seat_id, - display_hostname, - self->priv->display_is_local, - self->priv->display_is_initial, - conversation->worker_cancellable, - (GAsyncReadyCallback) on_setup_complete_cb, - conversation); - } -} + if (log_file != NULL) + g_variant_builder_add_parsed (&details, "{'log-file', <%s>}", log_file); -static void -send_setup_for_user (GdmSession *self, - const char *service_name) -{ - const char *display_name; - const char *display_device; - const char *display_seat_id; - const char *display_hostname; - const char *display_x11_authority_file; - const char *selected_user; - GdmSessionConversation *conversation; + if (self->priv->is_program_session) + g_variant_builder_add_parsed (&details, "{'is-program-session', <%b>}", self->priv->is_program_session); - g_assert (service_name != NULL); - - conversation = find_conversation_by_name (self, service_name); + if (self->priv->display_name != NULL) + g_variant_builder_add_parsed (&details, "{'x11-display-name', <%s>}", self->priv->display_name); - if (self->priv->display_name != NULL) { - display_name = self->priv->display_name; - } else { - display_name = ""; - } - if (self->priv->display_hostname != NULL) { - display_hostname = self->priv->display_hostname; - } else { - display_hostname = ""; - } - if (self->priv->display_device != NULL) { - display_device = self->priv->display_device; - } else { - display_device = ""; - } - if (self->priv->display_seat_id != NULL) { - display_seat_id = self->priv->display_seat_id; - } else { - display_seat_id = ""; - } - if (self->priv->display_x11_authority_file != NULL) { - display_x11_authority_file = self->priv->display_x11_authority_file; - } else { - display_x11_authority_file = ""; - } - if (self->priv->selected_user != NULL) { - selected_user = self->priv->selected_user; - } else { - selected_user = ""; - } + if (self->priv->display_hostname != NULL) + g_variant_builder_add_parsed (&details, "{'hostname', <%s>}", self->priv->display_hostname); - g_debug ("GdmSession: Beginning setup for user %s", self->priv->selected_user); + if (self->priv->display_is_local) + g_variant_builder_add_parsed (&details, "{'display-is-local', <%b>}", self->priv->display_is_local); - if (conversation != NULL) { - gdm_dbus_worker_call_setup_for_user (conversation->worker_proxy, - service_name, - selected_user, - display_name, - display_x11_authority_file, - display_device, - display_seat_id, - display_hostname, - self->priv->display_is_local, - self->priv->display_is_initial, - conversation->worker_cancellable, - (GAsyncReadyCallback) on_setup_complete_cb, - conversation); - } -} + if (self->priv->display_is_initial) + g_variant_builder_add_parsed (&details, "{'display-is-initial', <%b>}", self->priv->display_is_initial); -static void -send_setup_for_program (GdmSession *self, - const char *service_name, - const char *username, - const char *log_file) -{ - const char *display_name; - const char *display_device; - const char *display_seat_id; - const char *display_hostname; - const char *display_x11_authority_file; - GdmSessionConversation *conversation; + if (self->priv->display_device != NULL) + g_variant_builder_add_parsed (&details, "{'console', <%s>}", self->priv->display_device); - g_assert (service_name != NULL); + if (self->priv->display_seat_id != NULL) + g_variant_builder_add_parsed (&details, "{'seat-id', <%s>}", self->priv->display_seat_id); - if (self->priv->display_name != NULL) { - display_name = self->priv->display_name; - } else { - display_name = ""; - } - if (self->priv->display_hostname != NULL) { - display_hostname = self->priv->display_hostname; - } else { - display_hostname = ""; - } - if (self->priv->display_device != NULL) { - display_device = self->priv->display_device; - } else { - display_device = ""; - } - if (self->priv->display_seat_id != NULL) { - display_seat_id = self->priv->display_seat_id; - } else { - display_seat_id = ""; - } - if (self->priv->display_x11_authority_file != NULL) { - display_x11_authority_file = self->priv->display_x11_authority_file; - } else { - display_x11_authority_file = ""; - } + if (self->priv->display_x11_authority_file != NULL) + g_variant_builder_add_parsed (&details, "{'x11-authority-file', <%s>}", self->priv->display_x11_authority_file); - g_debug ("GdmSession: Beginning setup for session for program using PAM service %s", service_name); + g_debug ("GdmSession: Beginning initialization"); conversation = find_conversation_by_name (self, service_name); if (conversation != NULL) { - gdm_dbus_worker_call_setup_for_program (conversation->worker_proxy, - service_name, - username, - display_name, - display_x11_authority_file, - display_device, - display_seat_id, - display_hostname, - self->priv->display_is_local, - self->priv->display_is_initial, - log_file, - conversation->worker_cancellable, - (GAsyncReadyCallback) on_setup_complete_cb, - conversation); + gdm_dbus_worker_call_initialize (conversation->worker_proxy, + g_variant_builder_end (&details), + + conversation->worker_cancellable, + (GAsyncReadyCallback) on_initialization_complete_cb, + conversation); } } @@ -2288,7 +2159,8 @@ gdm_session_setup (GdmSession *self, update_session_type (self); - send_setup (self, service_name); + initialize (self, service_name, NULL, NULL); + gdm_session_defaults_changed (self); } @@ -2306,7 +2178,8 @@ gdm_session_setup_for_user (GdmSession *self, gdm_session_select_user (self, username); self->priv->is_program_session = FALSE; - send_setup_for_user (self, service_name); + initialize (self, service_name, self->priv->selected_user, NULL); + gdm_session_defaults_changed (self); } void @@ -2319,7 +2192,7 @@ gdm_session_setup_for_program (GdmSession *self, g_return_if_fail (GDM_IS_SESSION (self)); self->priv->is_program_session = TRUE; - send_setup_for_program (self, service_name, username, log_file); + initialize (self, service_name, username, log_file); } void |