Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 295206
Collapse All | Expand All

(-)a/daemon/Makefile.am (-9 lines)
Lines 75-92 gdm-product-display-glue.h: gdm-product-display.xml Makefile.am Link Here
75
	dbus-binding-tool --prefix=gdm_product_display --mode=glib-server --output=gdm-product-display-glue.h $(srcdir)/gdm-product-display.xml
75
	dbus-binding-tool --prefix=gdm_product_display --mode=glib-server --output=gdm-product-display-glue.h $(srcdir)/gdm-product-display.xml
76
76
77
noinst_PROGRAMS = 		\
77
noinst_PROGRAMS = 		\
78
	test-hal-seats		\
79
	test-session		\
78
	test-session		\
80
	$(NULL)
79
	$(NULL)
81
80
82
test_hal_seats_SOURCES = 	\
83
	test-hal-seats.c	\
84
	$(NULL)
85
86
test_hal_seats_LDADD =		\
87
	$(DAEMON_LIBS)		\
88
	$(NULL)
89
90
test_session_SOURCES = 		\
81
test_session_SOURCES = 		\
91
	test-session.c	 	\
82
	test-session.c	 	\
92
	gdm-session.c		\
83
	gdm-session.c		\
(-)a/daemon/gdm-local-display-factory.c (-110 lines)
Lines 45-56 Link Here
45
#define GDM_LOCAL_DISPLAY_FACTORY_DBUS_PATH GDM_DBUS_PATH "/LocalDisplayFactory"
45
#define GDM_LOCAL_DISPLAY_FACTORY_DBUS_PATH GDM_DBUS_PATH "/LocalDisplayFactory"
46
#define GDM_MANAGER_DBUS_NAME               "org.gnome.DisplayManager.LocalDisplayFactory"
46
#define GDM_MANAGER_DBUS_NAME               "org.gnome.DisplayManager.LocalDisplayFactory"
47
47
48
#define HAL_DBUS_NAME                           "org.freedesktop.Hal"
49
#define HAL_DBUS_MANAGER_PATH                   "/org/freedesktop/Hal/Manager"
50
#define HAL_DBUS_MANAGER_INTERFACE              "org.freedesktop.Hal.Manager"
51
#define HAL_DBUS_DEVICE_INTERFACE               "org.freedesktop.Hal.Device"
52
#define SEAT_PCI_DEVICE_CLASS                   3
53
54
#define MAX_DISPLAY_FAILURES 5
48
#define MAX_DISPLAY_FAILURES 5
55
49
56
struct GdmLocalDisplayFactoryPrivate
50
struct GdmLocalDisplayFactoryPrivate
Lines 372-454 create_display (GdmLocalDisplayFactory *factory) Link Here
372
        return display;
366
        return display;
373
}
367
}
374
368
375
#if 0
376
static void
377
create_display_for_device (GdmLocalDisplayFactory *factory,
378
                           DBusGProxy             *device_proxy)
379
{
380
        create_display (factory);
381
}
382
383
static void
384
create_displays_for_pci_devices (GdmLocalDisplayFactory *factory)
385
{
386
        char      **devices;
387
        const char *key;
388
        const char *value;
389
        GError     *error;
390
        gboolean    res;
391
        int         i;
392
393
        g_debug ("GdmLocalDisplayFactory: Getting PCI seat devices");
394
395
        key = "info.bus";
396
        value = "pci";
397
398
        devices = NULL;
399
        error = NULL;
400
        res = dbus_g_proxy_call (factory->priv->proxy,
401
                                 "FindDeviceStringMatch",
402
                                 &error,
403
                                 G_TYPE_STRING, key,
404
                                 G_TYPE_STRING, value,
405
                                 G_TYPE_INVALID,
406
                                 G_TYPE_STRV, &devices,
407
                                 G_TYPE_INVALID);
408
        if (! res) {
409
                g_warning ("Unable to query HAL: %s", error->message);
410
                g_error_free (error);
411
        }
412
413
        /* now look for pci class 3 */
414
        key = "pci.device_class";
415
        for (i = 0; devices [i] != NULL; i++) {
416
                DBusGProxy *device_proxy;
417
                int         class_val;
418
419
                device_proxy = dbus_g_proxy_new_for_name (factory->priv->connection,
420
                                                          HAL_DBUS_NAME,
421
                                                          devices [i],
422
                                                          HAL_DBUS_DEVICE_INTERFACE);
423
                if (device_proxy == NULL) {
424
                        continue;
425
                }
426
427
                error = NULL;
428
                res = dbus_g_proxy_call (device_proxy,
429
                                         "GetPropertyInteger",
430
                                         &error,
431
                                         G_TYPE_STRING, key,
432
                                         G_TYPE_INVALID,
433
                                         G_TYPE_INT, &class_val,
434
                                         G_TYPE_INVALID);
435
                if (! res) {
436
                        g_warning ("Unable to query HAL: %s", error->message);
437
                        g_error_free (error);
438
                }
439
440
                if (class_val == SEAT_PCI_DEVICE_CLASS) {
441
                        g_debug ("GdmLocalDisplayFactory: Found device: %s", devices [i]);
442
                        create_display_for_device (factory, device_proxy);
443
                }
444
445
                g_object_unref (device_proxy);
446
        }
447
448
        g_strfreev (devices);
449
}
450
#endif
451
452
static gboolean
369
static gboolean
453
gdm_local_display_factory_start (GdmDisplayFactory *base_factory)
370
gdm_local_display_factory_start (GdmDisplayFactory *base_factory)
454
{
371
{
Lines 525-553 register_factory (GdmLocalDisplayFactory *factory) Link Here
525
        return TRUE;
442
        return TRUE;
526
}
443
}
527
444
528
static gboolean
529
connect_to_hal (GdmLocalDisplayFactory *factory)
530
{
531
        factory->priv->proxy = dbus_g_proxy_new_for_name (factory->priv->connection,
532
                                                          HAL_DBUS_NAME,
533
                                                          HAL_DBUS_MANAGER_PATH,
534
                                                          HAL_DBUS_MANAGER_INTERFACE);
535
        if (factory->priv->proxy == NULL) {
536
                g_warning ("Couldn't create proxy for HAL Manager");
537
                return FALSE;
538
        }
539
540
        return TRUE;
541
}
542
543
static void
544
disconnect_from_hal (GdmLocalDisplayFactory *factory)
545
{
546
        if (factory->priv->proxy == NULL) {
547
                g_object_unref (factory->priv->proxy);
548
        }
549
}
550
551
static GObject *
445
static GObject *
552
gdm_local_display_factory_constructor (GType                  type,
446
gdm_local_display_factory_constructor (GType                  type,
553
                                       guint                  n_construct_properties,
447
                                       guint                  n_construct_properties,
Lines 565-572 gdm_local_display_factory_constructor (GType type, Link Here
565
                g_warning ("Unable to register local display factory with system bus");
459
                g_warning ("Unable to register local display factory with system bus");
566
        }
460
        }
567
461
568
        connect_to_hal (factory);
569
570
        return G_OBJECT (factory);
462
        return G_OBJECT (factory);
571
}
463
}
572
464
Lines 611-618 gdm_local_display_factory_finalize (GObject *object) Link Here
611
503
612
        g_hash_table_destroy (factory->priv->displays);
504
        g_hash_table_destroy (factory->priv->displays);
613
505
614
        disconnect_from_hal (factory);
615
616
        G_OBJECT_CLASS (gdm_local_display_factory_parent_class)->finalize (object);
506
        G_OBJECT_CLASS (gdm_local_display_factory_parent_class)->finalize (object);
617
}
507
}
618
508
(-)a/daemon/test-hal-seats.c (-174 lines)
Lines 1-173 Link Here
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2
 *
3
 * This program is free software; you can redistribute it and/or
4
 * modify it under the terms of the GNU General Public License as
5
 * published by the Free Software Foundation; either version 2 of the
6
 * License, or (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful, but
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
 * General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
16
 * 02111-1307, USA.
17
 *
18
 * cc -o test-hal-seats `pkg-config --cflags --libs glib-2.0 dbus-glib-1` test-hal-seats.c
19
 */
20
21
#include <stdlib.h>
22
#include <stdio.h>
23
24
#include <glib.h>
25
#define DBUS_API_SUBJECT_TO_CHANGE
26
#include <dbus/dbus-glib.h>
27
#include <dbus/dbus-glib-lowlevel.h>
28
29
#define HAL_DBUS_NAME                           "org.freedesktop.Hal"
30
#define HAL_DBUS_MANAGER_PATH                   "/org/freedesktop/Hal/Manager"
31
#define HAL_DBUS_MANAGER_INTERFACE              "org.freedesktop.Hal.Manager"
32
#define HAL_DBUS_DEVICE_INTERFACE               "org.freedesktop.Hal.Device"
33
#define SEAT_PCI_DEVICE_CLASS                   3
34
35
static GMainLoop *loop;
36
37
static void
38
get_pci_seats (DBusGConnection *bus,
39
               DBusGProxy      *proxy,
40
               GList           *seats)
41
{
42
        char      **devices;
43
        const char *key;
44
        const char *value;
45
        GError     *error;
46
        gboolean    res;
47
        int         i;
48
49
        g_message ("Getting PCI seats");
50
51
        key = "info.bus";
52
        value = "pci";
53
54
        devices = NULL;
55
        error = NULL;
56
        res = dbus_g_proxy_call (proxy,
57
                                 "FindDeviceStringMatch",
58
                                 &error,
59
                                 G_TYPE_STRING, key,
60
                                 G_TYPE_STRING, value,
61
                                 G_TYPE_INVALID,
62
                                 G_TYPE_STRV, &devices,
63
                                 G_TYPE_INVALID);
64
        if (! res) {
65
                g_warning ("Unable to query HAL: %s", error->message);
66
                g_error_free (error);
67
        }
68
69
        /* now look for pci class 3 */
70
        key = "pci.device_class";
71
        for (i = 0; devices [i] != NULL; i++) {
72
                DBusGProxy *device_proxy;
73
                int         class_val;
74
75
                device_proxy = dbus_g_proxy_new_for_name (bus,
76
                                                          HAL_DBUS_NAME,
77
                                                          devices [i],
78
                                                          HAL_DBUS_DEVICE_INTERFACE);
79
                if (device_proxy == NULL) {
80
                        continue;
81
                }
82
83
                error = NULL;
84
                res = dbus_g_proxy_call (device_proxy,
85
                                         "GetPropertyInteger",
86
                                         &error,
87
                                         G_TYPE_STRING, key,
88
                                         G_TYPE_INVALID,
89
                                         G_TYPE_INT, &class_val,
90
                                         G_TYPE_INVALID);
91
                if (! res) {
92
                        g_warning ("Unable to query HAL: %s", error->message);
93
                        g_error_free (error);
94
                }
95
96
                if (class_val == SEAT_PCI_DEVICE_CLASS) {
97
                        g_message ("Found device: %s", devices [i]);
98
                        seats = g_list_prepend (seats, devices [i]);
99
                }
100
101
                g_object_unref (device_proxy);
102
        }
103
104
        g_strfreev (devices);
105
}
106
107
static void
108
list_seats (GList *seats)
109
{
110
        GList *l;
111
        for (l = seats; l != NULL; l = l->next) {
112
                g_message ("Found device: %s", (char *)l->data);
113
        }
114
}
115
116
static gboolean
117
test_hal_seats (void)
118
{
119
        GError          *error;
120
        DBusGConnection *bus;
121
        DBusGProxy      *proxy;
122
        GList           *seats;
123
124
        proxy = NULL;
125
126
        error = NULL;
127
        bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
128
        if (bus == NULL) {
129
                g_warning ("Couldn't connect to system bus: %s",
130
                           error->message);
131
                g_error_free (error);
132
                goto out;
133
        }
134
135
        proxy = dbus_g_proxy_new_for_name (bus,
136
                                           HAL_DBUS_NAME,
137
                                           HAL_DBUS_MANAGER_PATH,
138
                                           HAL_DBUS_MANAGER_INTERFACE);
139
        if (proxy == NULL) {
140
                g_warning ("Couldn't create proxy for HAL Manager");
141
                goto out;
142
        }
143
144
        seats = NULL;
145
146
        get_pci_seats (bus, proxy, seats);
147
148
        list_seats (seats);
149
150
 out:
151
        if (proxy != NULL) {
152
                g_object_unref (proxy);
153
        }
154
155
        return FALSE;
156
}
157
158
int
159
main (int   argc,
160
      char *argv[])
161
{
162
        g_log_set_always_fatal (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
163
164
        g_type_init ();
165
166
        g_idle_add ((GSourceFunc)test_hal_seats, NULL);
167
168
        loop = g_main_loop_new (NULL, FALSE);
169
        g_main_loop_run (loop);
170
        g_main_loop_unref (loop);
171
172
        return 0;
173
}
174
- 

Return to bug 295206