Blob Blame History Raw
From 239bc98692187ca42dca7cf1a19800415afcf6cf Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 31 Mar 2017 15:01:06 -0400
Subject: [PATCH 05/13] launch-environment: implement hostname-selected signal

We're connecting to a signal that isn't implemented.  This
commit adds the implementation.

A slightly better fix might be to cut out some of the layers,
of middle men passing around hostname-selected, but for now this
is fine.
---
 daemon/gdm-launch-environment.c | 27 +++++++++++++++++++++++++++
 daemon/gdm-launch-environment.h |  2 ++
 2 files changed, 29 insertions(+)

diff --git a/daemon/gdm-launch-environment.c b/daemon/gdm-launch-environment.c
index 4372ac29..a7ae6728 100644
--- a/daemon/gdm-launch-environment.c
+++ b/daemon/gdm-launch-environment.c
@@ -76,60 +76,61 @@ struct GdmLaunchEnvironmentPrivate
         char           *x11_display_name;
         char           *x11_display_seat_id;
         char           *x11_display_device;
         char           *x11_display_hostname;
         char           *x11_authority_file;
         gboolean        x11_display_is_local;
 };
 
 enum {
         PROP_0,
         PROP_VERIFICATION_MODE,
         PROP_SESSION_TYPE,
         PROP_SESSION_MODE,
         PROP_X11_DISPLAY_NAME,
         PROP_X11_DISPLAY_SEAT_ID,
         PROP_X11_DISPLAY_DEVICE,
         PROP_X11_DISPLAY_HOSTNAME,
         PROP_X11_AUTHORITY_FILE,
         PROP_X11_DISPLAY_IS_LOCAL,
         PROP_USER_NAME,
         PROP_RUNTIME_DIR,
         PROP_COMMAND,
 };
 
 enum {
         OPENED,
         STARTED,
         STOPPED,
         EXITED,
         DIED,
+        HOSTNAME_SELECTED,
         LAST_SIGNAL
 };
 
 static guint signals [LAST_SIGNAL] = { 0, };
 
 static void     gdm_launch_environment_class_init    (GdmLaunchEnvironmentClass *klass);
 static void     gdm_launch_environment_init          (GdmLaunchEnvironment      *launch_environment);
 static void     gdm_launch_environment_finalize      (GObject                   *object);
 
 G_DEFINE_TYPE (GdmLaunchEnvironment, gdm_launch_environment, G_TYPE_OBJECT)
 
 static GHashTable *
 build_launch_environment (GdmLaunchEnvironment *launch_environment,
                           gboolean              start_session)
 {
         GHashTable    *hash;
         struct passwd *pwent;
         static const char * const optional_environment[] = {
                 "LANG", "LANGUAGE", "LC_CTYPE", "LC_NUMERIC", "LC_TIME",
                 "LC_COLLATE", "LC_MONETARY", "LC_MESSAGES", "LC_PAPER",
                 "LC_NAME", "LC_ADDRESS", "LC_TELEPHONE", "LC_MEASUREMENT",
                 "LC_IDENTIFICATION", "LC_ALL", "WINDOWPATH", "XCURSOR_PATH",
                 "XDG_CONFIG_DIRS", NULL
         };
         char *system_data_dirs;
         int i;
 
         /* create a hash table of current environment, then update keys has necessary */
         hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 
@@ -237,60 +238,69 @@ static void
 on_session_started (GdmSession           *session,
                     const char           *service_name,
                     int                   pid,
                     GdmLaunchEnvironment *launch_environment)
 {
         launch_environment->priv->pid = pid;
         g_signal_emit (G_OBJECT (launch_environment), signals [STARTED], 0);
 }
 
 static void
 on_session_exited (GdmSession           *session,
                    int                   exit_code,
                    GdmLaunchEnvironment *launch_environment)
 {
         gdm_session_stop_conversation (launch_environment->priv->session, "gdm-launch-environment");
 
         g_signal_emit (G_OBJECT (launch_environment), signals [EXITED], 0, exit_code);
 }
 
 static void
 on_session_died (GdmSession           *session,
                  int                   signal_number,
                  GdmLaunchEnvironment *launch_environment)
 {
         gdm_session_stop_conversation (launch_environment->priv->session, "gdm-launch-environment");
 
         g_signal_emit (G_OBJECT (launch_environment), signals [DIED], 0, signal_number);
 }
 
 static void
+on_hostname_selected (GdmSession               *session,
+                      const char               *hostname,
+		      GdmLaunchEnvironment     *launch_environment)
+{
+        g_debug ("GdmSession: hostname selected: %s", hostname);
+        g_signal_emit (launch_environment, signals [HOSTNAME_SELECTED], 0, hostname);
+}
+
+static void
 on_conversation_started (GdmSession           *session,
                          const char           *service_name,
                          GdmLaunchEnvironment *launch_environment)
 {
         char             *log_path;
         char             *log_file;
 
         log_file = g_strdup_printf ("%s-greeter.log", launch_environment->priv->x11_display_name);
         log_path = g_build_filename (LOGDIR, log_file, NULL);
         g_free (log_file);
 
         gdm_session_setup_for_program (launch_environment->priv->session,
                                        "gdm-launch-environment",
                                        launch_environment->priv->user_name,
                                        log_path);
         g_free (log_path);
 }
 
 static void
 on_conversation_stopped (GdmSession           *session,
                          const char           *service_name,
                          GdmLaunchEnvironment *launch_environment)
 {
         GdmSession *conversation_session;
 
         conversation_session = launch_environment->priv->session;
         launch_environment->priv->session = NULL;
 
         g_debug ("GdmLaunchEnvironment: conversation stopped");
 
@@ -382,60 +392,65 @@ gdm_launch_environment_start (GdmLaunchEnvironment *launch_environment)
         g_signal_connect_object (launch_environment->priv->session,
                                  "conversation-stopped",
                                  G_CALLBACK (on_conversation_stopped),
                                  launch_environment,
                                  0);
         g_signal_connect_object (launch_environment->priv->session,
                                  "setup-complete",
                                  G_CALLBACK (on_session_setup_complete),
                                  launch_environment,
                                  0);
         g_signal_connect_object (launch_environment->priv->session,
                                  "session-opened",
                                  G_CALLBACK (on_session_opened),
                                  launch_environment,
                                  0);
         g_signal_connect_object (launch_environment->priv->session,
                                  "session-started",
                                  G_CALLBACK (on_session_started),
                                  launch_environment,
                                  0);
         g_signal_connect_object (launch_environment->priv->session,
                                  "session-exited",
                                  G_CALLBACK (on_session_exited),
                                  launch_environment,
                                  0);
         g_signal_connect_object (launch_environment->priv->session,
                                  "session-died",
                                  G_CALLBACK (on_session_died),
                                  launch_environment,
                                  0);
+        g_signal_connect_object (launch_environment->priv->session,
+                                 "hostname-selected",
+                                 G_CALLBACK (on_hostname_selected),
+                                 launch_environment,
+                                 0);
 
         gdm_session_start_conversation (launch_environment->priv->session, "gdm-launch-environment");
         gdm_session_select_program (launch_environment->priv->session, launch_environment->priv->command);
 
         if (launch_environment->priv->session_type != NULL) {
                 g_object_set (G_OBJECT (launch_environment->priv->session),
                               "session-type",
                               launch_environment->priv->session_type,
                               NULL);
         }
 
         res = TRUE;
  out:
         if (local_error) {
                 g_critical ("GdmLaunchEnvironment: %s", local_error->message);
                 g_clear_error (&local_error);
         }
         return res;
 }
 
 gboolean
 gdm_launch_environment_stop (GdmLaunchEnvironment *launch_environment)
 {
         if (launch_environment->priv->pid > 1) {
                 gdm_signal_pid (-launch_environment->priv->pid, SIGTERM);
         }
 
         if (launch_environment->priv->session != NULL) {
                 gdm_session_close (launch_environment->priv->session);
 
@@ -780,60 +795,72 @@ gdm_launch_environment_class_init (GdmLaunchEnvironmentClass *klass)
                               G_OBJECT_CLASS_TYPE (object_class),
                               G_SIGNAL_RUN_FIRST,
                               G_STRUCT_OFFSET (GdmLaunchEnvironmentClass, stopped),
                               NULL,
                               NULL,
                               g_cclosure_marshal_VOID__VOID,
                               G_TYPE_NONE,
                               0);
         signals [EXITED] =
                 g_signal_new ("exited",
                               G_OBJECT_CLASS_TYPE (object_class),
                               G_SIGNAL_RUN_FIRST,
                               G_STRUCT_OFFSET (GdmLaunchEnvironmentClass, exited),
                               NULL,
                               NULL,
                               g_cclosure_marshal_VOID__INT,
                               G_TYPE_NONE,
                               1,
                               G_TYPE_INT);
         signals [DIED] =
                 g_signal_new ("died",
                               G_OBJECT_CLASS_TYPE (object_class),
                               G_SIGNAL_RUN_FIRST,
                               G_STRUCT_OFFSET (GdmLaunchEnvironmentClass, died),
                               NULL,
                               NULL,
                               g_cclosure_marshal_VOID__INT,
                               G_TYPE_NONE,
                               1,
                               G_TYPE_INT);
+
+        signals [HOSTNAME_SELECTED] =
+                g_signal_new ("hostname-selected",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_FIRST,
+                              G_STRUCT_OFFSET (GdmLaunchEnvironmentClass, hostname_selected),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__STRING,
+                              G_TYPE_NONE,
+                              1,
+                              G_TYPE_STRING);
 }
 
 static void
 gdm_launch_environment_init (GdmLaunchEnvironment *launch_environment)
 {
 
         launch_environment->priv = GDM_LAUNCH_ENVIRONMENT_GET_PRIVATE (launch_environment);
 
         launch_environment->priv->command = NULL;
         launch_environment->priv->session = NULL;
 }
 
 static void
 gdm_launch_environment_finalize (GObject *object)
 {
         GdmLaunchEnvironment *launch_environment;
 
         g_return_if_fail (object != NULL);
         g_return_if_fail (GDM_IS_LAUNCH_ENVIRONMENT (object));
 
         launch_environment = GDM_LAUNCH_ENVIRONMENT (object);
 
         g_return_if_fail (launch_environment->priv != NULL);
 
         gdm_launch_environment_stop (launch_environment);
 
         if (launch_environment->priv->session) {
                 g_object_unref (launch_environment->priv->session);
         }
 
diff --git a/daemon/gdm-launch-environment.h b/daemon/gdm-launch-environment.h
index 3fd875c2..c2a09d1c 100644
--- a/daemon/gdm-launch-environment.h
+++ b/daemon/gdm-launch-environment.h
@@ -32,55 +32,57 @@ G_BEGIN_DECLS
 #define GDM_LAUNCH_ENVIRONMENT_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_LAUNCH_ENVIRONMENT, GdmLaunchEnvironmentClass))
 #define GDM_IS_LAUNCH_ENVIRONMENT(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_LAUNCH_ENVIRONMENT))
 #define GDM_IS_LAUNCH_ENVIRONMENT_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_LAUNCH_ENVIRONMENT))
 #define GDM_LAUNCH_ENVIRONMENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_LAUNCH_ENVIRONMENT, GdmLaunchEnvironmentClass))
 
 typedef struct GdmLaunchEnvironmentPrivate GdmLaunchEnvironmentPrivate;
 
 typedef struct
 {
         GObject                   parent;
         GdmLaunchEnvironmentPrivate *priv;
 } GdmLaunchEnvironment;
 
 typedef struct
 {
         GObjectClass   parent_class;
 
         /* methods */
         gboolean (*start)          (GdmLaunchEnvironment  *launch_environment);
         gboolean (*stop)           (GdmLaunchEnvironment  *launch_environment);
 
 
         /* signals */
         void (* opened)            (GdmLaunchEnvironment  *launch_environment);
         void (* started)           (GdmLaunchEnvironment  *launch_environment);
         void (* stopped)           (GdmLaunchEnvironment  *launch_environment);
         void (* exited)            (GdmLaunchEnvironment  *launch_environment,
                                     int                    exit_code);
         void (* died)              (GdmLaunchEnvironment  *launch_environment,
                                     int                    signal_number);
+        void (* hostname_selected) (GdmLaunchEnvironment  *launch_environment,
+                                    const char            *hostname);
 } GdmLaunchEnvironmentClass;
 
 GType                 gdm_launch_environment_get_type           (void);
 
 gboolean              gdm_launch_environment_start              (GdmLaunchEnvironment *launch_environment);
 gboolean              gdm_launch_environment_stop               (GdmLaunchEnvironment *launch_environment);
 GdmSession *          gdm_launch_environment_get_session        (GdmLaunchEnvironment *launch_environment);
 char *                gdm_launch_environment_get_session_id     (GdmLaunchEnvironment *launch_environment);
 
 GdmLaunchEnvironment *gdm_create_greeter_launch_environment (const char *display_name,
                                                              const char *seat_id,
                                                              const char *session_type,
                                                              const char *display_hostname,
                                                              gboolean    display_is_local);
 GdmLaunchEnvironment *gdm_create_initial_setup_launch_environment (const char *display_name,
                                                                    const char *seat_id,
                                                                    const char *display_hostname,
                                                                    gboolean    display_is_local);
 GdmLaunchEnvironment *gdm_create_chooser_launch_environment (const char *display_name,
                                                              const char *seat_id,
                                                              const char *display_hostname);
 
 G_END_DECLS
 
 #endif /* __GDM_LAUNCH_ENVIRONMENT_H */
-- 
2.12.0