gdm r5632 - in trunk: . daemon



Author: mccann
Date: Fri Jan 25 01:39:44 2008
New Revision: 5632
URL: http://svn.gnome.org/viewvc/gdm?rev=5632&view=rev

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

	* daemon/Makefile.am:
	* daemon/gdm-display-store.c: (gdm_display_store_clear),
	(gdm_display_store_remove), (gdm_display_store_finalize):
	* daemon/gdm-factory-slave.c: (create_product_display),
	(gdm_factory_slave_stop):
	* daemon/gdm-local-display-factory.c: (listify_hash), (sort_nums),
	(take_next_display_number), (on_display_disposed), (store_display),
	(gdm_local_display_factory_create_transient_display),
	(gdm_local_display_factory_create_product_display),
	(create_display_for_device), (register_factory), (connect_to_hal),
	(gdm_local_display_factory_constructor),
	(gdm_local_display_factory_class_init),
	(gdm_local_display_factory_init),
	(gdm_local_display_factory_finalize):
	* daemon/gdm-local-display-factory.h:
	* daemon/gdm-local-display-factory.xml:
	* daemon/gdm-static-factory-display.c:
	(gdm_static_factory_display_set_property),
	(gdm_static_factory_display_get_property),
	(gdm_static_factory_display_class_init),
	(gdm_static_factory_display_new):
	* daemon/gdm-static-factory-display.h:
	* daemon/gdm-static-factory-display.xml:
	* daemon/gdm-transient-display.c:
	(gdm_transient_display_create_authority),
	(gdm_transient_display_add_user_authorization),
	(gdm_transient_display_remove_user_authorization),
	(gdm_transient_display_manage), (gdm_transient_display_finish),
	(gdm_transient_display_unmanage),
	(gdm_transient_display_set_property),
	(gdm_transient_display_get_property),
	(gdm_transient_display_class_init), (gdm_transient_display_init),
	(gdm_transient_display_finalize), (gdm_transient_display_new):
	* daemon/gdm-transient-display.h:
	* daemon/gdm-transient-display.xml:
	Use the LocalDisplayFactory to assign X11 Display numbers
	to all local displays.  Try to assign the lowest available.
	Add a stub for a TransientDisplay that can be used to
	do FUS logins.



Added:
   trunk/daemon/gdm-local-display-factory.xml
   trunk/daemon/gdm-transient-display.c
   trunk/daemon/gdm-transient-display.h
   trunk/daemon/gdm-transient-display.xml
Modified:
   trunk/ChangeLog
   trunk/daemon/Makefile.am
   trunk/daemon/gdm-display-store.c
   trunk/daemon/gdm-factory-slave.c
   trunk/daemon/gdm-local-display-factory.c
   trunk/daemon/gdm-local-display-factory.h
   trunk/daemon/gdm-static-factory-display.c
   trunk/daemon/gdm-static-factory-display.h
   trunk/daemon/gdm-static-factory-display.xml

Modified: trunk/daemon/Makefile.am
==============================================================================
--- trunk/daemon/Makefile.am	(original)
+++ trunk/daemon/Makefile.am	Fri Jan 25 01:39:44 2008
@@ -36,6 +36,8 @@
 	gdm-display-glue.h			\
 	gdm-xdmcp-display-glue.h		\
 	gdm-static-display-glue.h		\
+	gdm-transient-display-glue.h		\
+	gdm-local-display-factory-glue.h	\
 	gdm-static-factory-display-glue.h	\
 	gdm-product-display-glue.h		\
 	$(NULL)
@@ -56,6 +58,10 @@
 	dbus-binding-tool --prefix=gdm_xdmcp_display --mode=glib-server --output=gdm-xdmcp-display-glue.h $(srcdir)/gdm-xdmcp-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-static-factory-display-glue.h: gdm-static-factory-display.xml Makefile.am
 	dbus-binding-tool --prefix=gdm_static_factory_display --mode=glib-server --output=gdm-static-factory-display-glue.h $(srcdir)/gdm-static-factory-display.xml
 gdm-product-display-glue.h: gdm-product-display.xml Makefile.am
@@ -237,6 +243,8 @@
 	gdm-xdmcp-display.h		\
 	gdm-static-display.c		\
 	gdm-static-display.h		\
+	gdm-transient-display.c		\
+	gdm-transient-display.h		\
 	gdm-static-factory-display.c	\
 	gdm-static-factory-display.h	\
 	gdm-product-display.c		\
@@ -305,6 +313,8 @@
 	gdm-display.xml			\
 	gdm-xdmcp-display.xml		\
 	gdm-static-display.xml		\
+	gdm-transient-display.xml	\
+	gdm-local-display-factory.xml	\
 	gdm-static-factory-display.xml	\
 	gdm-product-display.xml		\
 	$(NULL)

Modified: trunk/daemon/gdm-display-store.c
==============================================================================
--- trunk/daemon/gdm-display-store.c	(original)
+++ trunk/daemon/gdm-display-store.c	Fri Jan 25 01:39:44 2008
@@ -37,7 +37,7 @@
 
 struct GdmDisplayStorePrivate
 {
-        GHashTable      *displays;
+        GHashTable *displays;
 };
 
 enum {
@@ -68,6 +68,7 @@
 void
 gdm_display_store_clear (GdmDisplayStore    *store)
 {
+        g_return_if_fail (store != NULL);
         g_debug ("GdmDisplayStore: Clearing display store");
         g_hash_table_remove_all (store->priv->displays);
 }
@@ -76,6 +77,8 @@
 gdm_display_store_remove (GdmDisplayStore    *store,
                           GdmDisplay         *display)
 {
+        g_return_val_if_fail (store != NULL, FALSE);
+
         g_warning ("GdmDisplayStore: Implement me");
         return FALSE;
 }
@@ -197,14 +200,16 @@
 static void
 gdm_display_store_finalize (GObject *object)
 {
-        GdmDisplayStore *display_store;
+        GdmDisplayStore *store;
 
         g_return_if_fail (object != NULL);
         g_return_if_fail (GDM_IS_DISPLAY_STORE (object));
 
-        display_store = GDM_DISPLAY_STORE (object);
+        store = GDM_DISPLAY_STORE (object);
+
+        g_return_if_fail (store->priv != NULL);
 
-        g_return_if_fail (display_store->priv != NULL);
+        g_hash_table_destroy (store->priv->displays);
 
         G_OBJECT_CLASS (gdm_display_store_parent_class)->finalize (object);
 }

Modified: trunk/daemon/gdm-factory-slave.c
==============================================================================
--- trunk/daemon/gdm-factory-slave.c	(original)
+++ trunk/daemon/gdm-factory-slave.c	Fri Jan 25 01:39:44 2008
@@ -57,8 +57,9 @@
 
 #define GDM_FACTORY_SLAVE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_FACTORY_SLAVE, GdmFactorySlavePrivate))
 
-#define GDM_DBUS_NAME                      "org.gnome.DisplayManager"
-#define GDM_DBUS_FACTORY_DISPLAY_INTERFACE "org.gnome.DisplayManager.StaticFactoryDisplay"
+#define GDM_DBUS_NAME                            "org.gnome.DisplayManager"
+#define GDM_DBUS_LOCAL_DISPLAY_FACTORY_PATH      "/org/gnome/DisplayManager/LocalDisplayFactory"
+#define GDM_DBUS_LOCAL_DISPLAY_FACTORY_INTERFACE "org.gnome.DisplayManager.LocalDisplayFactory"
 
 #define MAX_CONNECT_ATTEMPTS 10
 
@@ -78,7 +79,7 @@
         GdmSessionRelay   *session;
         GdmGreeterServer  *greeter_server;
         GdmGreeterSession *greeter;
-        DBusGProxy        *factory_display_proxy;
+        DBusGProxy        *factory_proxy;
         DBusGConnection   *connection;
 };
 
@@ -277,7 +278,7 @@
 static gboolean
 create_product_display (GdmFactorySlave *slave)
 {
-        char    *display_id;
+        char    *parent_display_id;
         char    *server_address;
         char    *product_id;
         GError  *error;
@@ -288,33 +289,33 @@
 
         g_debug ("GdmFactorySlave: Create product display");
 
-        g_object_get (slave,
-                      "display-id", &display_id,
-                      NULL);
-
-        g_debug ("GdmFactorySlave: Connecting to display %s", display_id);
-        slave->priv->factory_display_proxy = dbus_g_proxy_new_for_name (slave->priv->connection,
-                                                                        GDM_DBUS_NAME,
-                                                                        display_id,
-                                                                        GDM_DBUS_FACTORY_DISPLAY_INTERFACE);
-        g_free (display_id);
-
-        if (slave->priv->factory_display_proxy == NULL) {
-                g_warning ("Failed to create display proxy %s", display_id);
+        g_debug ("GdmFactorySlave: Connecting to local display factory");
+        slave->priv->factory_proxy = dbus_g_proxy_new_for_name (slave->priv->connection,
+                                                                GDM_DBUS_NAME,
+                                                                GDM_DBUS_LOCAL_DISPLAY_FACTORY_PATH,
+                                                                GDM_DBUS_LOCAL_DISPLAY_FACTORY_INTERFACE);
+        if (slave->priv->factory_proxy == NULL) {
+                g_warning ("Failed to create local display factory proxy");
                 goto out;
         }
 
         server_address = gdm_session_relay_get_address (slave->priv->session);
 
+        g_object_get (slave,
+                      "display-id", &parent_display_id,
+                      NULL);
+
         error = NULL;
-        res = dbus_g_proxy_call (slave->priv->factory_display_proxy,
+        res = dbus_g_proxy_call (slave->priv->factory_proxy,
                                  "CreateProductDisplay",
                                  &error,
+                                 DBUS_TYPE_G_OBJECT_PATH, parent_display_id,
                                  G_TYPE_STRING, server_address,
                                  G_TYPE_INVALID,
                                  DBUS_TYPE_G_OBJECT_PATH, &product_id,
                                  G_TYPE_INVALID);
         g_free (server_address);
+        g_free (parent_display_id);
 
         if (! res) {
                 if (error != NULL) {
@@ -740,8 +741,8 @@
                 GDM_FACTORY_SLAVE (slave)->priv->server = NULL;
         }
 
-        if (GDM_FACTORY_SLAVE (slave)->priv->factory_display_proxy != NULL) {
-                g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->factory_display_proxy);
+        if (GDM_FACTORY_SLAVE (slave)->priv->factory_proxy != NULL) {
+                g_object_unref (GDM_FACTORY_SLAVE (slave)->priv->factory_proxy);
         }
 
         return TRUE;

Modified: trunk/daemon/gdm-local-display-factory.c
==============================================================================
--- trunk/daemon/gdm-local-display-factory.c	(original)
+++ trunk/daemon/gdm-local-display-factory.c	Fri Jan 25 01:39:44 2008
@@ -29,12 +29,20 @@
 
 #include "gdm-display-factory.h"
 #include "gdm-local-display-factory.h"
+#include "gdm-local-display-factory-glue.h"
+
 #include "gdm-display-store.h"
 #include "gdm-static-display.h"
+#include "gdm-transient-display.h"
 #include "gdm-static-factory-display.h"
+#include "gdm-product-display.h"
 
 #define GDM_LOCAL_DISPLAY_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_LOCAL_DISPLAY_FACTORY, GdmLocalDisplayFactoryPrivate))
 
+#define GDM_DBUS_PATH                       "/org/gnome/DisplayManager"
+#define GDM_LOCAL_DISPLAY_FACTORY_DBUS_PATH GDM_DBUS_PATH "/LocalDisplayFactory"
+#define GDM_MANAGER_DBUS_NAME               "org.gnome.DisplayManager.LocalDisplayFactory"
+
 #define HAL_DBUS_NAME                           "org.freedesktop.Hal"
 #define HAL_DBUS_MANAGER_PATH                   "/org/freedesktop/Hal/Manager"
 #define HAL_DBUS_MANAGER_INTERFACE              "org.freedesktop.Hal.Manager"
@@ -45,6 +53,7 @@
 {
         DBusGConnection *connection;
         DBusGProxy      *proxy;
+        GHashTable      *displays;
 };
 
 enum {
@@ -71,18 +80,210 @@
 }
 
 static void
-create_display_for_device (GdmLocalDisplayFactory *factory,
-                           DBusGProxy             *device_proxy)
+listify_hash (gpointer    key,
+              GdmDisplay *display,
+              GList     **list)
+{
+        *list = g_list_prepend (*list, key);
+}
+
+static int
+sort_nums (gpointer a,
+           gpointer b)
+{
+        guint32 num_a;
+        guint32 num_b;
+
+        num_a = GPOINTER_TO_UINT (a);
+        num_b = GPOINTER_TO_UINT (b);
+
+        if (num_a > num_b) {
+                return 1;
+        } else if (num_a < num_b) {
+                return -1;
+        } else {
+                return 0;
+        }
+}
+
+static guint32
+take_next_display_number (GdmLocalDisplayFactory *factory)
+{
+        GList  *list;
+        GList  *l;
+        guint32 ret;
+
+        ret = 0;
+        list = NULL;
+
+        g_hash_table_foreach (factory->priv->displays, (GHFunc)listify_hash, &list);
+        if (list == NULL) {
+                goto out;
+        }
+
+        /* sort low to high */
+        list = g_list_sort (list, (GCompareFunc)sort_nums);
+
+        g_debug ("GdmLocalDisplayFactory: Found the following X displays:");
+        for (l = list; l != NULL; l = l->next) {
+                g_debug ("%u", GPOINTER_TO_UINT (l->data));
+        }
+
+        for (l = list; l != NULL; l = l->next) {
+                guint32 num;
+                num = GPOINTER_TO_UINT (l->data);
+
+                /* always fill zero */
+                if (l->prev == NULL && num != 0) {
+                        ret = 0;
+                        break;
+                }
+                /* now find the first hole */
+                if (l->next == NULL || GPOINTER_TO_UINT (l->next->data) != (num + 1)) {
+                        ret = num + 1;
+                        break;
+                }
+        }
+ out:
+
+        /* now reserve this number */
+        g_debug ("GdmLocalDisplayFactory: Reserving X display: %u", ret);
+        g_hash_table_insert (factory->priv->displays, GUINT_TO_POINTER (ret), NULL);
+
+        return ret;
+}
+
+static void
+on_display_disposed (GdmLocalDisplayFactory *factory,
+                     GdmDisplay             *display)
+{
+        /* remove the display number from accounting */
+
+}
+
+static void
+store_display (GdmLocalDisplayFactory *factory,
+               guint32                 num,
+               GdmDisplay             *display)
 {
-        GdmDisplay      *display;
         GdmDisplayStore *store;
 
+        g_object_weak_ref (G_OBJECT (display), (GWeakNotify)on_display_disposed, factory);
+
         store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
+        gdm_display_store_add (store, display);
+
+        /* now fill our reserved spot */
+        g_hash_table_insert (factory->priv->displays, GUINT_TO_POINTER (num), NULL);
+
+}
+
+gboolean
+gdm_local_display_factory_create_transient_display (GdmLocalDisplayFactory *factory,
+                                                    char                  **id,
+                                                    GError                **error)
+{
+        gboolean         ret;
+        GdmDisplay      *display;
+        guint32          num;
+
+        g_return_val_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (factory), FALSE);
+
+        ret = FALSE;
+
+        num = take_next_display_number (factory);
+
+        g_debug ("GdmLocalDisplayFactory: Creating transient display %d", num);
+
+        display = gdm_transient_display_new (num);
+
+        if (! gdm_display_create_authority (display)) {
+                display = NULL;
+                goto out;
+        }
+
+        store_display (factory, num, display);
+
+        if (! gdm_display_manage (display)) {
+                display = NULL;
+                goto out;
+        }
+
+        if (! gdm_display_get_id (display, id, NULL)) {
+                display = NULL;
+                goto out;
+        }
+
+        ret = TRUE;
+ out:
+        /* ref either held by store or not at all */
+        g_object_unref (display);
+
+        return ret;
+}
+
+gboolean
+gdm_local_display_factory_create_product_display (GdmLocalDisplayFactory *factory,
+                                                  const char             *parent_display_id,
+                                                  const char             *relay_address,
+                                                  char                  **id,
+                                                  GError                **error)
+{
+        gboolean    ret;
+        GdmDisplay *display;
+        guint32     num;
+
+        g_return_val_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (factory), FALSE);
+
+        ret = FALSE;
+
+        g_debug ("GdmLocalDisplayFactory: Creating product display parent %s address:%s",
+                 parent_display_id, relay_address);
+
+        num = take_next_display_number (factory);
+
+        g_debug ("GdmLocalDisplayFactory: got display num %u", num);
+
+        display = gdm_product_display_new (num, relay_address);
+
+        if (! gdm_display_create_authority (display)) {
+                display = NULL;
+                goto out;
+        }
+
+        store_display (factory, num, display);
+
+        if (! gdm_display_manage (display)) {
+                display = NULL;
+                goto out;
+        }
+
+        if (! gdm_display_get_id (display, id, NULL)) {
+                display = NULL;
+                goto out;
+        }
+
+        ret = TRUE;
+ out:
+        /* ref either held by store or not at all */
+        g_object_unref (display);
+
+        return ret;
+}
+
+static void
+create_display_for_device (GdmLocalDisplayFactory *factory,
+                           DBusGProxy             *device_proxy)
+{
+        GdmDisplay *display;
+        guint32     num;
+
+        num = take_next_display_number (factory);
 
 #if 0
-        display = gdm_static_factory_display_new (0, store);
+        display = gdm_static_factory_display_new (num);
 #else
-        display = gdm_static_display_new (0);
+        display = gdm_static_display_new (num);
 #endif
         if (display == NULL) {
                 g_warning ("Unable to create display: %d", 0);
@@ -95,7 +296,8 @@
                 return;
         }
 
-        gdm_display_store_add (store, display);
+        store_display (factory, num, display);
+
         /* let store own the ref */
         g_object_unref (display);
 
@@ -232,37 +434,29 @@
         }
 }
 
-static void
-gdm_local_display_factory_class_init (GdmLocalDisplayFactoryClass *klass)
+static gboolean
+register_factory (GdmLocalDisplayFactory *factory)
 {
-        GObjectClass           *object_class = G_OBJECT_CLASS (klass);
-        GdmDisplayFactoryClass *factory_class = GDM_DISPLAY_FACTORY_CLASS (klass);
+        GError *error = NULL;
 
-        object_class->get_property = gdm_local_display_factory_get_property;
-        object_class->set_property = gdm_local_display_factory_set_property;
-        object_class->finalize = gdm_local_display_factory_finalize;
+        error = NULL;
+        factory->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+        if (factory->priv->connection == NULL) {
+                if (error != NULL) {
+                        g_critical ("error getting system bus: %s", error->message);
+                        g_error_free (error);
+                }
+                exit (1);
+        }
 
-        factory_class->start = gdm_local_display_factory_start;
-        factory_class->stop = gdm_local_display_factory_stop;
+        dbus_g_connection_register_g_object (factory->priv->connection, GDM_LOCAL_DISPLAY_FACTORY_DBUS_PATH, G_OBJECT (factory));
 
-        g_type_class_add_private (klass, sizeof (GdmLocalDisplayFactoryPrivate));
+        return TRUE;
 }
 
 static gboolean
 connect_to_hal (GdmLocalDisplayFactory *factory)
 {
-        GError *error;
-
-        error = NULL;
-        factory->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-        if (factory->priv->connection == NULL) {
-                g_critical ("Couldn't connect to system bus: %s",
-                           error->message);
-                g_error_free (error);
-
-                return FALSE;
-        }
-
         factory->priv->proxy = dbus_g_proxy_new_for_name (factory->priv->connection,
                                                           HAL_DBUS_NAME,
                                                           HAL_DBUS_MANAGER_PATH,
@@ -283,12 +477,56 @@
         }
 }
 
+static GObject *
+gdm_local_display_factory_constructor (GType                  type,
+                                       guint                  n_construct_properties,
+                                       GObjectConstructParam *construct_properties)
+{
+        GdmLocalDisplayFactory      *factory;
+        GdmLocalDisplayFactoryClass *klass;
+        gboolean                     res;
+
+        klass = GDM_LOCAL_DISPLAY_FACTORY_CLASS (g_type_class_peek (GDM_TYPE_LOCAL_DISPLAY_FACTORY));
+
+        factory = GDM_LOCAL_DISPLAY_FACTORY (G_OBJECT_CLASS (gdm_local_display_factory_parent_class)->constructor (type,
+                                                                                                                   n_construct_properties,
+                                                                                                                   construct_properties));
+
+        res = register_factory (factory);
+        if (! res) {
+                g_warning ("Unable to register local display factory with system bus");
+        }
+
+        connect_to_hal (factory);
+
+        return G_OBJECT (factory);
+}
+
+static void
+gdm_local_display_factory_class_init (GdmLocalDisplayFactoryClass *klass)
+{
+        GObjectClass           *object_class = G_OBJECT_CLASS (klass);
+        GdmDisplayFactoryClass *factory_class = GDM_DISPLAY_FACTORY_CLASS (klass);
+
+        object_class->get_property = gdm_local_display_factory_get_property;
+        object_class->set_property = gdm_local_display_factory_set_property;
+        object_class->finalize = gdm_local_display_factory_finalize;
+        object_class->constructor = gdm_local_display_factory_constructor;
+
+        factory_class->start = gdm_local_display_factory_start;
+        factory_class->stop = gdm_local_display_factory_stop;
+
+        g_type_class_add_private (klass, sizeof (GdmLocalDisplayFactoryPrivate));
+
+        dbus_g_object_type_install_info (GDM_TYPE_LOCAL_DISPLAY_FACTORY, &dbus_glib_gdm_local_display_factory_object_info);
+}
+
 static void
 gdm_local_display_factory_init (GdmLocalDisplayFactory *factory)
 {
         factory->priv = GDM_LOCAL_DISPLAY_FACTORY_GET_PRIVATE (factory);
 
-        connect_to_hal (factory);
+        factory->priv->displays = g_hash_table_new (NULL, NULL);
 }
 
 static void
@@ -303,6 +541,8 @@
 
         g_return_if_fail (factory->priv != NULL);
 
+        g_hash_table_destroy (factory->priv->displays);
+
         disconnect_from_hal (factory);
 
         G_OBJECT_CLASS (gdm_local_display_factory_parent_class)->finalize (object);

Modified: trunk/daemon/gdm-local-display-factory.h
==============================================================================
--- trunk/daemon/gdm-local-display-factory.h	(original)
+++ trunk/daemon/gdm-local-display-factory.h	Fri Jan 25 01:39:44 2008
@@ -56,10 +56,20 @@
 
 #define GDM_LOCAL_DISPLAY_FACTORY_ERROR gdm_local_display_factory_error_quark ()
 
-GQuark                     gdm_local_display_factory_error_quark             (void);
-GType                      gdm_local_display_factory_get_type                (void);
+GQuark                     gdm_local_display_factory_error_quark              (void);
+GType                      gdm_local_display_factory_get_type                 (void);
 
-GdmLocalDisplayFactory *   gdm_local_display_factory_new                     (GdmDisplayStore        *display_store);
+GdmLocalDisplayFactory *   gdm_local_display_factory_new                      (GdmDisplayStore        *display_store);
+
+gboolean                   gdm_local_display_factory_create_transient_display (GdmLocalDisplayFactory *factory,
+                                                                               char                  **id,
+                                                                               GError                **error);
+
+gboolean                   gdm_local_display_factory_create_product_display   (GdmLocalDisplayFactory *factory,
+                                                                               const char             *parent_display_id,
+                                                                               const char             *relay_address,
+                                                                               char                  **id,
+                                                                               GError                **error);
 
 G_END_DECLS
 

Added: trunk/daemon/gdm-local-display-factory.xml
==============================================================================
--- (empty file)
+++ trunk/daemon/gdm-local-display-factory.xml	Fri Jan 25 01:39:44 2008
@@ -0,0 +1,13 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
+<node name="/org/gnome/DisplayManager/LocalDisplayFactory">
+  <interface name="org.gnome.DisplayManager.LocalDisplayFactory">
+    <method name="CreateProductDisplay">
+      <arg name="parent_display_id" direction="in" type="o"/>
+      <arg name="relay_address" direction="in" type="s"/>
+      <arg name="id" direction="out" type="o"/>
+    </method>
+    <method name="CreateTransientDisplay">
+      <arg name="id" direction="out" type="o"/>
+    </method>
+  </interface>
+</node>

Modified: trunk/daemon/gdm-static-factory-display.c
==============================================================================
--- trunk/daemon/gdm-static-factory-display.c	(original)
+++ trunk/daemon/gdm-static-factory-display.c	Fri Jan 25 01:39:44 2008
@@ -37,9 +37,6 @@
 #include "gdm-display.h"
 #include "gdm-static-factory-display.h"
 #include "gdm-static-factory-display-glue.h"
-#include "gdm-product-display.h"
-
-#include "gdm-display-store.h"
 
 #define GDM_STATIC_FACTORY_DISPLAY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_STATIC_FACTORY_DISPLAY, GdmStaticFactoryDisplayPrivate))
 
@@ -47,81 +44,19 @@
 
 struct GdmStaticFactoryDisplayPrivate
 {
-        GdmDisplayStore *display_store;
+        gpointer dummy;
 };
 
 enum {
         PROP_0,
-        PROP_DISPLAY_STORE,
 };
 
 static void     gdm_static_factory_display_class_init   (GdmStaticFactoryDisplayClass *klass);
 static void     gdm_static_factory_display_init         (GdmStaticFactoryDisplay      *static_factory_display);
 static void     gdm_static_factory_display_finalize     (GObject                      *object);
 
-static guint32 display_number = 100;
-
 G_DEFINE_TYPE (GdmStaticFactoryDisplay, gdm_static_factory_display, GDM_TYPE_DISPLAY)
 
-static guint32
-get_next_display_number (void)
-{
-        guint32 num;
-
-        num = display_number++;
-
-        if ((gint32)display_number < 0) {
-                display_number = 100;
-        }
-
-        return num;
-}
-
-gboolean
-gdm_static_factory_display_create_product_display (GdmStaticFactoryDisplay *display,
-                                                   const char              *relay_address,
-                                                   char                   **id,
-                                                   GError                 **error)
-{
-        gboolean    ret;
-        GdmDisplay *product;
-        guint32     num;
-
-        g_return_val_if_fail (GDM_IS_STATIC_FACTORY_DISPLAY (display), FALSE);
-
-        ret = FALSE;
-
-        num = get_next_display_number ();
-
-        g_debug ("GdmStaticFactoryDisplay: Creating product display %d  address:%s", num, relay_address);
-
-        product = gdm_product_display_new (num, relay_address);
-
-        if (! gdm_display_create_authority (product)) {
-                product = NULL;
-                goto out;
-        }
-
-        gdm_display_store_add (display->priv->display_store, product);
-
-        if (! gdm_display_manage (product)) {
-                product = NULL;
-                goto out;
-        }
-
-        if (! gdm_display_get_id (product, id, NULL)) {
-                product = NULL;
-                goto out;
-        }
-
-        ret = TRUE;
- out:
-        /* ref either held by store or not at all */
-        g_object_unref (product);
-
-        return ret;
-}
-
 static gboolean
 gdm_static_factory_display_add_user_authorization (GdmDisplay *display,
                                                    const char *username,
@@ -184,20 +119,6 @@
 }
 
 static void
-gdm_static_factory_display_set_display_store (GdmStaticFactoryDisplay *display,
-                                              GdmDisplayStore         *display_store)
-{
-        if (display->priv->display_store != NULL) {
-                g_object_unref (display->priv->display_store);
-                display->priv->display_store = NULL;
-        }
-
-        if (display_store != NULL) {
-                display->priv->display_store = g_object_ref (display_store);
-        }
-}
-
-static void
 gdm_static_factory_display_set_property (GObject      *object,
                                          guint         prop_id,
                                          const GValue *value,
@@ -208,9 +129,6 @@
         self = GDM_STATIC_FACTORY_DISPLAY (object);
 
         switch (prop_id) {
-        case PROP_DISPLAY_STORE:
-                gdm_static_factory_display_set_display_store (self, g_value_get_object (value));
-                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                 break;
@@ -228,9 +146,6 @@
         self = GDM_STATIC_FACTORY_DISPLAY (object);
 
         switch (prop_id) {
-        case PROP_DISPLAY_STORE:
-                g_value_set_object (value, self->priv->display_store);
-                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                 break;
@@ -272,14 +187,6 @@
         display_class->finish = gdm_static_factory_display_finish;
         display_class->unmanage = gdm_static_factory_display_unmanage;
 
-        g_object_class_install_property (object_class,
-                                         PROP_DISPLAY_STORE,
-                                         g_param_spec_object ("display-store",
-                                                              "display store",
-                                                              "display store",
-                                                              GDM_TYPE_DISPLAY_STORE,
-                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
         g_type_class_add_private (klass, sizeof (GdmStaticFactoryDisplayPrivate));
 
         dbus_g_object_type_install_info (GDM_TYPE_STATIC_FACTORY_DISPLAY, &dbus_glib_gdm_static_factory_display_object_info);
@@ -308,8 +215,7 @@
 }
 
 GdmDisplay *
-gdm_static_factory_display_new (int              display_number,
-                                GdmDisplayStore *store)
+gdm_static_factory_display_new (int              display_number)
 {
         GObject *object;
         char    *x11_display;
@@ -319,7 +225,6 @@
                                "slave-command", DEFAULT_SLAVE_COMMAND,
                                "x11-display-number", display_number,
                                "x11-display-name", x11_display,
-                               "display-store", store,
                                NULL);
         g_free (x11_display);
 

Modified: trunk/daemon/gdm-static-factory-display.h
==============================================================================
--- trunk/daemon/gdm-static-factory-display.h	(original)
+++ trunk/daemon/gdm-static-factory-display.h	Fri Jan 25 01:39:44 2008
@@ -52,8 +52,7 @@
 } GdmStaticFactoryDisplayClass;
 
 GType               gdm_static_factory_display_get_type                (void);
-GdmDisplay *        gdm_static_factory_display_new                     (int                      display_number,
-                                                                        GdmDisplayStore         *store);
+GdmDisplay *        gdm_static_factory_display_new                     (int                      display_number);
 
 gboolean            gdm_static_factory_display_create_product_display  (GdmStaticFactoryDisplay *display,
                                                                         const char              *server_address,

Modified: trunk/daemon/gdm-static-factory-display.xml
==============================================================================
--- trunk/daemon/gdm-static-factory-display.xml	(original)
+++ trunk/daemon/gdm-static-factory-display.xml	Fri Jan 25 01:39:44 2008
@@ -1,9 +1,5 @@
 <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
 <node>
   <interface name="org.gnome.DisplayManager.StaticFactoryDisplay">
-    <method name="CreateProductDisplay">
-      <arg name="relay_address" direction="in" type="s"/>
-      <arg name="id" direction="out" type="o"/>
-    </method>
   </interface>
 </node>

Added: trunk/daemon/gdm-transient-display.c
==============================================================================
--- (empty file)
+++ trunk/daemon/gdm-transient-display.c	Fri Jan 25 01:39:44 2008
@@ -0,0 +1,213 @@
+/* -*- 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 <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <pwd.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+
+#include "gdm-common.h"
+#include "gdm-display.h"
+#include "gdm-transient-display.h"
+#include "gdm-transient-display-glue.h"
+
+#define GDM_TRANSIENT_DISPLAY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_TRANSIENT_DISPLAY, GdmTransientDisplayPrivate))
+
+struct GdmTransientDisplayPrivate
+{
+        gpointer dummy;
+};
+
+enum {
+        PROP_0,
+};
+
+static void     gdm_transient_display_class_init   (GdmTransientDisplayClass *klass);
+static void     gdm_transient_display_init         (GdmTransientDisplay      *display);
+static void     gdm_transient_display_finalize     (GObject                  *object);
+
+G_DEFINE_TYPE (GdmTransientDisplay, gdm_transient_display, GDM_TYPE_DISPLAY)
+
+static gboolean
+gdm_transient_display_create_authority (GdmDisplay *display)
+{
+        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+
+        GDM_DISPLAY_CLASS (gdm_transient_display_parent_class)->create_authority (display);
+
+        return TRUE;
+}
+
+static gboolean
+gdm_transient_display_add_user_authorization (GdmDisplay *display,
+                                              const char *username,
+                                              char      **filename,
+                                              GError    **error)
+{
+        return GDM_DISPLAY_CLASS (gdm_transient_display_parent_class)->add_user_authorization (display, username, filename, error);
+}
+
+static gboolean
+gdm_transient_display_remove_user_authorization (GdmDisplay *display,
+                                                 const char *username,
+                                                 GError    **error)
+{
+        return GDM_DISPLAY_CLASS (gdm_transient_display_parent_class)->remove_user_authorization (display, username, error);
+}
+
+static gboolean
+gdm_transient_display_manage (GdmDisplay *display)
+{
+        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+
+        GDM_DISPLAY_CLASS (gdm_transient_display_parent_class)->manage (display);
+
+        return TRUE;
+}
+
+static gboolean
+gdm_transient_display_finish (GdmDisplay *display)
+{
+        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+
+        GDM_DISPLAY_CLASS (gdm_transient_display_parent_class)->finish (display);
+
+        /* we don't restart/remanage transient displays */
+        gdm_display_unmanage (display);
+
+        return TRUE;
+}
+
+static gboolean
+gdm_transient_display_unmanage (GdmDisplay *display)
+{
+        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
+
+        GDM_DISPLAY_CLASS (gdm_transient_display_parent_class)->unmanage (display);
+
+        return TRUE;
+}
+
+static void
+gdm_transient_display_set_property (GObject      *object,
+                                    guint         prop_id,
+                                    const GValue *value,
+                                    GParamSpec   *pspec)
+{
+        GdmTransientDisplay *self;
+
+        self = GDM_TRANSIENT_DISPLAY (object);
+
+        switch (prop_id) {
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gdm_transient_display_get_property (GObject    *object,
+                                 guint       prop_id,
+                                 GValue     *value,
+                                 GParamSpec *pspec)
+{
+        GdmTransientDisplay *self;
+
+        self = GDM_TRANSIENT_DISPLAY (object);
+
+        switch (prop_id) {
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gdm_transient_display_class_init (GdmTransientDisplayClass *klass)
+{
+        GObjectClass    *object_class = G_OBJECT_CLASS (klass);
+        GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
+
+        object_class->get_property = gdm_transient_display_get_property;
+        object_class->set_property = gdm_transient_display_set_property;
+        object_class->finalize = gdm_transient_display_finalize;
+
+        display_class->create_authority = gdm_transient_display_create_authority;
+        display_class->add_user_authorization = gdm_transient_display_add_user_authorization;
+        display_class->remove_user_authorization = gdm_transient_display_remove_user_authorization;
+        display_class->manage = gdm_transient_display_manage;
+        display_class->finish = gdm_transient_display_finish;
+        display_class->unmanage = gdm_transient_display_unmanage;
+
+        g_type_class_add_private (klass, sizeof (GdmTransientDisplayPrivate));
+
+        dbus_g_object_type_install_info (GDM_TYPE_TRANSIENT_DISPLAY, &dbus_glib_gdm_transient_display_object_info);
+}
+
+static void
+gdm_transient_display_init (GdmTransientDisplay *display)
+{
+
+        display->priv = GDM_TRANSIENT_DISPLAY_GET_PRIVATE (display);
+}
+
+static void
+gdm_transient_display_finalize (GObject *object)
+{
+        GdmTransientDisplay *display;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GDM_IS_TRANSIENT_DISPLAY (object));
+
+        display = GDM_TRANSIENT_DISPLAY (object);
+
+        g_return_if_fail (display->priv != NULL);
+
+        G_OBJECT_CLASS (gdm_transient_display_parent_class)->finalize (object);
+}
+
+GdmDisplay *
+gdm_transient_display_new (int display_number)
+{
+        GObject *object;
+        char    *x11_display;
+
+        x11_display = g_strdup_printf (":%d", display_number);
+        object = g_object_new (GDM_TYPE_TRANSIENT_DISPLAY,
+                               "x11-display-number", display_number,
+                               "x11-display-name", x11_display,
+                               NULL);
+        g_free (x11_display);
+
+        return GDM_DISPLAY (object);
+}

Added: trunk/daemon/gdm-transient-display.h
==============================================================================
--- (empty file)
+++ trunk/daemon/gdm-transient-display.h	Fri Jan 25 01:39:44 2008
@@ -0,0 +1,58 @@
+/* -*- 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_TRANSIENT_DISPLAY_H
+#define __GDM_TRANSIENT_DISPLAY_H
+
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+#include "gdm-display.h"
+
+G_BEGIN_DECLS
+
+#define GDM_TYPE_TRANSIENT_DISPLAY         (gdm_transient_display_get_type ())
+#define GDM_TRANSIENT_DISPLAY(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_TRANSIENT_DISPLAY, GdmTransientDisplay))
+#define GDM_TRANSIENT_DISPLAY_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_TRANSIENT_DISPLAY, GdmTransientDisplayClass))
+#define GDM_IS_TRANSIENT_DISPLAY(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_TRANSIENT_DISPLAY))
+#define GDM_IS_TRANSIENT_DISPLAY_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_TRANSIENT_DISPLAY))
+#define GDM_TRANSIENT_DISPLAY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_TRANSIENT_DISPLAY, GdmTransientDisplayClass))
+
+typedef struct GdmTransientDisplayPrivate GdmTransientDisplayPrivate;
+
+typedef struct
+{
+        GdmDisplay                  parent;
+        GdmTransientDisplayPrivate *priv;
+} GdmTransientDisplay;
+
+typedef struct
+{
+        GdmDisplayClass   parent_class;
+
+} GdmTransientDisplayClass;
+
+GType               gdm_transient_display_get_type                (void);
+GdmDisplay *        gdm_transient_display_new                     (int display_number);
+
+
+G_END_DECLS
+
+#endif /* __GDM_TRANSIENT_DISPLAY_H */

Added: trunk/daemon/gdm-transient-display.xml
==============================================================================
--- (empty file)
+++ trunk/daemon/gdm-transient-display.xml	Fri Jan 25 01:39:44 2008
@@ -0,0 +1,5 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
+<node>
+  <interface name="org.gnome.DisplayManager.TransientDisplay">
+  </interface>
+</node>



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