From 5683e5d5a6bc37c7a1b52a633cc79c70b60defb3 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 28 Jul 2017 16:04:11 -0400 Subject: 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 --- daemon/gdm-session.c | 211 ++++++++++----------------------------------------- 1 file changed, 42 insertions(+), 169 deletions(-) (limited to 'daemon/gdm-session.c') 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 -- cgit v1.2.1