gdm r5621 - in trunk: . common daemon gui/simple-chooser gui/simple-greeter



Author: mccann
Date: Mon Jan 21 21:32:33 2008
New Revision: 5621
URL: http://svn.gnome.org/viewvc/gdm?rev=5621&view=rev

Log:
2008-01-21  William Jon McCann  <mccann jhu edu>

	* common/gdm-address.c: (gdm_address_peek_local_list):
	* daemon/gdm-xdmcp-display-factory.c:
	(gdm_xdmcp_display_factory_class_init),
	(gdm_xdmcp_display_factory_finalize):
	Merge a few changes from the 2.20 branch.

	* gui/simple-chooser/chooser-main.c: (main):
	* gui/simple-greeter/Makefile.am:
	* gui/simple-greeter/gdm-remote-login-window.c: (start_xephyr),
	(gdm_remote_login_window_connect),
	(gdm_remote_login_window_set_property),
	(gdm_remote_login_window_get_property),
	(gdm_remote_login_window_constructor),
	(gdm_remote_login_window_class_init),
	(gdm_remote_login_window_init), (gdm_remote_login_window_finalize),
	(gdm_remote_login_window_new):
	* gui/simple-greeter/gdm-remote-login-window.h:
	* gui/simple-greeter/test-remote-login-window.c: (main):
	Add initial remote login (xdmcp) client window.



Added:
   trunk/gui/simple-greeter/gdm-remote-login-window.c
   trunk/gui/simple-greeter/gdm-remote-login-window.h
   trunk/gui/simple-greeter/test-remote-login-window.c
Modified:
   trunk/ChangeLog
   trunk/common/gdm-address.c
   trunk/daemon/gdm-xdmcp-display-factory.c
   trunk/gui/simple-chooser/chooser-main.c
   trunk/gui/simple-greeter/Makefile.am

Modified: trunk/common/gdm-address.c
==============================================================================
--- trunk/common/gdm-address.c	(original)
+++ trunk/common/gdm-address.c	Mon Jan 21 21:32:33 2008
@@ -286,7 +286,6 @@
         static GList *the_list = NULL;
         static time_t last_time = 0;
         char hostbuf[BUFSIZ];
-        struct addrinfo hints;
         struct addrinfo *result;
         struct addrinfo *res;
 
@@ -307,14 +306,8 @@
                 snprintf (hostbuf, BUFSIZ-1, "localhost");
         }
 
-        memset (&hints, 0, sizeof (hints));
-        hints.ai_family = AF_INET;
-#ifdef ENABLE_IPV6
-        hints.ai_family |= AF_INET6;
-#endif
-
         result = NULL;
-        if (getaddrinfo (hostbuf, NULL, &hints, &result) != 0) {
+        if (getaddrinfo (hostbuf, NULL, NULL, &result) != 0) {
                 g_debug ("%s: Could not get address from hostname!", "gdm_peek_local_address_list");
 
                 return NULL;

Modified: trunk/daemon/gdm-xdmcp-display-factory.c
==============================================================================
--- trunk/daemon/gdm-xdmcp-display-factory.c	(original)
+++ trunk/daemon/gdm-xdmcp-display-factory.c	Mon Jan 21 21:32:33 2008
@@ -77,6 +77,7 @@
 #define DEFAULT_MAX_DISPLAYS          16
 #define DEFAULT_MAX_PENDING_DISPLAYS  4
 #define DEFAULT_MAX_WAIT              15
+#define DEFAULT_WILLING_SCRIPT        GDMCONFDIR "/Xwilling"
 
 #define GDM_MAX_FORWARD_QUERIES 10
 #define GDM_FORWARD_QUERY_TIMEOUT 30
@@ -193,7 +194,7 @@
 
 static void     gdm_xdmcp_display_factory_class_init    (GdmXdmcpDisplayFactoryClass *klass);
 static void     gdm_xdmcp_display_factory_init          (GdmXdmcpDisplayFactory      *manager);
-static void     gdm_xdmcp_display_factory_finalize      (GObject              *object);
+static void     gdm_xdmcp_display_factory_finalize      (GObject                     *object);
 
 static gpointer xdmcp_display_factory_object = NULL;
 
@@ -2947,7 +2948,7 @@
                                          g_param_spec_string ("willing-script",
                                                               "willing-script",
                                                               "willing-script",
-                                                              NULL,
+                                                              DEFAULT_WILLING_SCRIPT,
                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
         g_object_class_install_property (object_class,
                                          PROP_MAX_DISPLAYS_PER_HOST,
@@ -3036,6 +3037,11 @@
                 g_source_remove (factory->priv->socket_watch_id);
         }
 
+        if (factory->priv->socket_fd > 0) {
+                close (factory->priv->socket_fd);
+                factory->priv->socket_fd = -1;
+        }
+
         g_slist_free (factory->priv->forward_queries);
         g_slist_free (factory->priv->managed_forwards);
 

Modified: trunk/gui/simple-chooser/chooser-main.c
==============================================================================
--- trunk/gui/simple-chooser/chooser-main.c	(original)
+++ trunk/gui/simple-chooser/chooser-main.c	Mon Jan 21 21:32:33 2008
@@ -69,7 +69,7 @@
                 char *hostname;
 
                 hostname = gdm_host_chooser_dialog_get_current_hostname (GDM_HOST_CHOOSER_DIALOG (chooser));
-                g_message ("Hostname: %s", hostname);
+                g_print ("hostname: %s\n", hostname);
                 g_free (hostname);
         }
 

Modified: trunk/gui/simple-greeter/Makefile.am
==============================================================================
--- trunk/gui/simple-greeter/Makefile.am	(original)
+++ trunk/gui/simple-greeter/Makefile.am	Mon Jan 21 21:32:33 2008
@@ -29,6 +29,7 @@
 
 noinst_PROGRAMS = 			\
 	test-greeter-login-window	\
+	test-remote-login-window	\
 	test-greeter-panel		\
 	test-language-chooser		\
 	test-session-chooser		\
@@ -70,6 +71,16 @@
 	$(top_builddir)/gui/simple-greeter/libnotificationarea/libnotificationarea.la	\
 	$(NULL)
 
+test_remote_login_window_SOURCES = 	\
+	test-remote-login-window.c	\
+	gdm-remote-login-window.h	\
+	gdm-remote-login-window.c	\
+	$(NULL)
+
+test_remote_login_window_LDADD =	\
+	$(GTK_LIBS)			\
+	$(NULL)
+
 test_language_chooser_SOURCES = 	\
 	test-language-chooser.c		\
 	gdm-language-chooser-widget.h	\
@@ -146,6 +157,8 @@
 	gdm-session-client.c		\
 	gdm-greeter-login-window.c	\
 	gdm-greeter-login-window.h	\
+	gdm-remote-login-window.c	\
+	gdm-remote-login-window.h	\
 	gdm-greeter-panel.h		\
 	gdm-greeter-panel.c		\
 	gdm-session-chooser-widget.h	\

Added: trunk/gui/simple-greeter/gdm-remote-login-window.c
==============================================================================
--- (empty file)
+++ trunk/gui/simple-greeter/gdm-remote-login-window.c	Mon Jan 21 21:32:33 2008
@@ -0,0 +1,228 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann <jmccann redhat com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+#include <glib-object.h>
+
+#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
+
+#include "gdm-remote-login-window.h"
+
+#define GDM_REMOTE_LOGIN_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_REMOTE_LOGIN_WINDOW, GdmRemoteLoginWindowPrivate))
+
+struct GdmRemoteLoginWindowPrivate
+{
+        gboolean connected;
+        char    *hostname;
+        char    *display;
+};
+
+enum {
+        PROP_0,
+};
+
+enum {
+        DISCONNECTED,
+        LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0, };
+
+static void     gdm_remote_login_window_class_init   (GdmRemoteLoginWindowClass *klass);
+static void     gdm_remote_login_window_init         (GdmRemoteLoginWindow      *remote_login_window);
+static void     gdm_remote_login_window_finalize     (GObject                    *object);
+
+G_DEFINE_TYPE (GdmRemoteLoginWindow, gdm_remote_login_window, GTK_TYPE_WINDOW)
+
+static gboolean
+start_xephyr (GdmRemoteLoginWindow *login_window)
+{
+        char    *cmd;
+        gboolean res;
+        GError  *error;
+
+        cmd = g_strdup_printf ("Xephyr -query %s -parent 0x%x %s",
+                               login_window->priv->hostname,
+                               (unsigned int)GDK_WINDOW_XID (GTK_WIDGET (login_window)->window),
+                               login_window->priv->display);
+        g_debug ("Running: %s", cmd);
+
+        error = NULL;
+        res = g_spawn_command_line_async (cmd, &error);
+
+        g_free (cmd);
+
+        if (! res) {
+                g_warning ("Could not start nested X server: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        return TRUE;
+}
+
+gboolean
+gdm_remote_login_window_connect (GdmRemoteLoginWindow *login_window,
+                                 const char           *hostname)
+{
+        gboolean res;
+        char    *title;
+
+        title = g_strdup_printf (_("Remote Login (Connecting to %s...)"), hostname);
+
+        gtk_window_set_title (GTK_WINDOW (login_window), title);
+
+        login_window->priv->hostname = g_strdup (hostname);
+        login_window->priv->display = g_strdup (":300");
+
+        res = start_xephyr (login_window);
+        if (res) {
+                title = g_strdup_printf (_("Remote Login (Connected to %s)"), hostname);
+                gtk_window_set_title (GTK_WINDOW (login_window), title);
+                g_free (title);
+        }
+
+        return res;
+}
+
+static void
+gdm_remote_login_window_set_property (GObject      *object,
+                                      guint         prop_id,
+                                      const GValue *value,
+                                      GParamSpec   *pspec)
+{
+        GdmRemoteLoginWindow *self;
+
+        self = GDM_REMOTE_LOGIN_WINDOW (object);
+
+        switch (prop_id) {
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gdm_remote_login_window_get_property (GObject    *object,
+                                      guint       prop_id,
+                                      GValue     *value,
+                                      GParamSpec *pspec)
+{
+        GdmRemoteLoginWindow *self;
+
+        self = GDM_REMOTE_LOGIN_WINDOW (object);
+
+        switch (prop_id) {
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static GObject *
+gdm_remote_login_window_constructor (GType                  type,
+                                     guint                  n_construct_properties,
+                                     GObjectConstructParam *construct_properties)
+{
+        GdmRemoteLoginWindow      *login_window;
+        GdmRemoteLoginWindowClass *klass;
+
+        klass = GDM_REMOTE_LOGIN_WINDOW_CLASS (g_type_class_peek (GDM_TYPE_REMOTE_LOGIN_WINDOW));
+
+        login_window = GDM_REMOTE_LOGIN_WINDOW (G_OBJECT_CLASS (gdm_remote_login_window_parent_class)->constructor (type,
+                                                                                                                      n_construct_properties,
+                                                                                                                      construct_properties));
+
+
+        return G_OBJECT (login_window);
+}
+
+static void
+gdm_remote_login_window_class_init (GdmRemoteLoginWindowClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->get_property = gdm_remote_login_window_get_property;
+        object_class->set_property = gdm_remote_login_window_set_property;
+        object_class->constructor = gdm_remote_login_window_constructor;
+        object_class->finalize = gdm_remote_login_window_finalize;
+
+        signals [DISCONNECTED] =
+                g_signal_new ("disconnected",
+                              G_TYPE_FROM_CLASS (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GdmRemoteLoginWindowClass, disconnected),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE,
+                              0);
+
+        g_type_class_add_private (klass, sizeof (GdmRemoteLoginWindowPrivate));
+}
+
+static void
+gdm_remote_login_window_init (GdmRemoteLoginWindow *login_window)
+{
+        login_window->priv = GDM_REMOTE_LOGIN_WINDOW_GET_PRIVATE (login_window);
+
+        gtk_window_set_position (GTK_WINDOW (login_window), GTK_WIN_POS_CENTER_ALWAYS);
+        gtk_window_set_title (GTK_WINDOW (login_window), _("Remote Login"));
+        /*gtk_window_set_decorated (GTK_WINDOW (login_window), FALSE);*/
+        gtk_window_set_skip_taskbar_hint (GTK_WINDOW (login_window), TRUE);
+        gtk_window_set_skip_pager_hint (GTK_WINDOW (login_window), TRUE);
+        gtk_window_stick (GTK_WINDOW (login_window));
+        gtk_window_maximize (GTK_WINDOW (login_window));
+}
+
+static void
+gdm_remote_login_window_finalize (GObject *object)
+{
+        GdmRemoteLoginWindow *login_window;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GDM_IS_REMOTE_LOGIN_WINDOW (object));
+
+        login_window = GDM_REMOTE_LOGIN_WINDOW (object);
+
+        g_return_if_fail (login_window->priv != NULL);
+
+        G_OBJECT_CLASS (gdm_remote_login_window_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gdm_remote_login_window_new (gboolean is_local)
+{
+        GObject *object;
+
+        object = g_object_new (GDM_TYPE_REMOTE_LOGIN_WINDOW,
+                               NULL);
+
+        return GTK_WIDGET (object);
+}

Added: trunk/gui/simple-greeter/gdm-remote-login-window.h
==============================================================================
--- (empty file)
+++ trunk/gui/simple-greeter/gdm-remote-login-window.h	Mon Jan 21 21:32:33 2008
@@ -0,0 +1,61 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann <jmccann redhat com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GDM_REMOTE_LOGIN_WINDOW_H
+#define __GDM_REMOTE_LOGIN_WINDOW_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GDM_TYPE_REMOTE_LOGIN_WINDOW         (gdm_remote_login_window_get_type ())
+#define GDM_REMOTE_LOGIN_WINDOW(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_REMOTE_LOGIN_WINDOW, GdmRemoteLoginWindow))
+#define GDM_REMOTE_LOGIN_WINDOW_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_REMOTE_LOGIN_WINDOW, GdmRemoteLoginWindowClass))
+#define GDM_IS_REMOTE_LOGIN_WINDOW(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_REMOTE_LOGIN_WINDOW))
+#define GDM_IS_REMOTE_LOGIN_WINDOW_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_REMOTE_LOGIN_WINDOW))
+#define GDM_REMOTE_LOGIN_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_REMOTE_LOGIN_WINDOW, GdmRemoteLoginWindowClass))
+
+typedef struct GdmRemoteLoginWindowPrivate GdmRemoteLoginWindowPrivate;
+
+typedef struct
+{
+        GtkWindow                    parent;
+        GdmRemoteLoginWindowPrivate *priv;
+} GdmRemoteLoginWindow;
+
+typedef struct
+{
+        GtkWindowClass   parent_class;
+
+        /* signals */
+        void (* disconnected)                (GdmRemoteLoginWindow *login_window);
+
+} GdmRemoteLoginWindowClass;
+
+GType               gdm_remote_login_window_get_type           (void);
+GtkWidget *         gdm_remote_login_window_new                (gboolean display_is_local);
+
+gboolean            gdm_remote_login_window_connect            (GdmRemoteLoginWindow *login_window,
+                                                                const char           *host);
+gboolean            gdm_remote_login_window_discconnect        (GdmRemoteLoginWindow *login_window);
+
+G_END_DECLS
+
+#endif /* __GDM_REMOTE_LOGIN_WINDOW_H */

Added: trunk/gui/simple-greeter/test-remote-login-window.c
==============================================================================
--- (empty file)
+++ trunk/gui/simple-greeter/test-remote-login-window.c	Mon Jan 21 21:32:33 2008
@@ -0,0 +1,99 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <libintl.h>
+#include <locale.h>
+#include <string.h>
+#include <unistd.h>
+#include <signal.h>
+#include <errno.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "gdm-remote-login-window.h"
+
+int
+main (int argc, char *argv[])
+{
+        GtkWidget        *login_window;
+        char             *std_out;
+        char             *hostname;
+        GRegex           *re;
+        GMatchInfo       *match_info;
+        gboolean          res;
+        GError           *error;
+
+        bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+        textdomain (GETTEXT_PACKAGE);
+
+        std_out = NULL;
+        g_spawn_command_line_sync (LIBEXECDIR "/gdm-simple-chooser",
+                                   &std_out,
+                                   NULL, NULL, NULL);
+        if (std_out == NULL) {
+                exit (1);
+        }
+
+        error = NULL;
+        re = g_regex_new ("hostname: (?P<hostname>[a-zA-Z0-9.-]+)", 0, 0, &error);
+        if (re == NULL) {
+                g_warning (error->message);
+                goto out;
+        }
+
+        g_regex_match (re, std_out, 0, &match_info);
+
+        res = g_match_info_matches (match_info);
+        if (! res) {
+                g_warning ("Unable to parse output: %s", std_out);
+                goto out;
+        }
+
+        hostname = g_match_info_fetch_named (match_info, "hostname");
+
+        g_debug ("Got %s", hostname);
+
+        setlocale (LC_ALL, "");
+
+        gtk_init (&argc, &argv);
+
+        login_window = gdm_remote_login_window_new (TRUE);
+        gtk_widget_show (login_window);
+
+        gdm_remote_login_window_connect (GDM_REMOTE_LOGIN_WINDOW (login_window), hostname);
+
+        gtk_main ();
+ out:
+
+        if (match_info != NULL) {
+                g_match_info_free (match_info);
+        }
+        if (re != NULL) {
+                g_regex_unref (re);
+        }
+
+        g_free (std_out);
+
+        return 0;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]