wok view xorg-server-tinyX/stuff/xorg-server-tinyX-1.5.3-hal_parallel.u @ rev 3917

syslinux/ifmem: pre-94 bioses support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Aug 18 18:21:24 2009 +0200 (2009-08-18)
parents
children
line source
1 diff --git xorg-server-1.5.3/config/hal.c xorg-server-1.5.3/config/hal.c
2 index 8dfbb07..36fa839 100644
3 --- xorg-server-1.5.3/config/hal.c
4 +++ xorg-server-1.5.3/config/hal.c
5 @@ -467,11 +467,10 @@ disconnect_hook(void *data)
6 info->system_bus = NULL;
7 }
8 -static void
9 -connect_hook(DBusConnection *connection, void *data)
10 +static BOOL
11 +connect_and_register(DBusConnection *connection, struct config_hal_info *info)
12 {
13 DBusError error;
14 - struct config_hal_info *info = data;
15 char **devices;
16 int num_devices, i;
17 @@ -479,8 +478,10 @@ connect_hook(DBusConnection *connection, void *data)
18 dbus_error_init(&error);
19 - if (!info->hal_ctx)
20 - info->hal_ctx = libhal_ctx_new();
21 + if (info->hal_ctx)
22 + return TRUE; /* already registered, pretend we did something */
23 +
24 + info->hal_ctx = libhal_ctx_new();
25 if (!info->hal_ctx) {
26 LogMessage(X_ERROR, "config/hal: couldn't create HAL context\n");
27 goto out_err;
28 @@ -512,7 +513,7 @@ connect_hook(DBusConnection *connection, void *data)
29 dbus_error_free(&error);
30 - return;
31 + return TRUE;
32 out_ctx2:
33 if (!libhal_ctx_shutdown(info->hal_ctx, &error))
34 @@ -525,6 +526,104 @@ out_err:
35 info->hal_ctx = NULL;
36 info->system_bus = NULL;
37 + return FALSE;
38 +}
39 +
40 +
41 +/**
42 + * Handle NewOwnerChanged signals to deal with HAL startup at X server runtime.
43 + *
44 + * NewOwnerChanged is send once when HAL shuts down, and once again when it
45 + * comes back up. Message has three arguments, first is the name
46 + * (org.freedesktop.Hal), the second one is the old owner, third one is new
47 + * owner.
48 + */
49 +static DBusHandlerResult
50 +ownerchanged_handler(DBusConnection *connection, DBusMessage *message, void *data)
51 +{
52 + int ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
53 +
54 + if (dbus_message_is_signal(message,
55 + "org.freedesktop.DBus",
56 + "NameOwnerChanged")) {
57 + DBusError error;
58 + char *name, *old_owner, *new_owner;
59 +
60 + dbus_error_init(&error);
61 + dbus_message_get_args(message, &error,
62 + DBUS_TYPE_STRING, &name,
63 + DBUS_TYPE_STRING, &old_owner,
64 + DBUS_TYPE_STRING, &new_owner,
65 + DBUS_TYPE_INVALID);
66 +
67 + if (dbus_error_is_set(&error)) {
68 + ErrorF("[config/hal] failed to get NameOwnerChanged args: %s (%s)\n",
69 + error.name, error.message);
70 + } else if (name && strcmp(name, "org.freedesktop.Hal") == 0) {
71 +
72 + if (!old_owner || !strlen(old_owner)) {
73 + DebugF("[config/hal] HAL startup detected.\n");
74 + if (connect_and_register(connection, (struct config_hal_info*)data))
75 + dbus_connection_unregister_object_path(connection,
76 + "/org/freedesktop/DBus");
77 + else
78 + ErrorF("[config/hal] Failed to connect to HAL bus.\n");
79 + }
80 +
81 + ret = DBUS_HANDLER_RESULT_HANDLED;
82 + }
83 + dbus_error_free(&error);
84 + }
85 +
86 + return ret;
87 +}
88 +
89 +/**
90 + * Register a handler for the NameOwnerChanged signal.
91 + */
92 +static BOOL
93 +listen_for_startup(DBusConnection *connection, void *data)
94 +{
95 + DBusObjectPathVTable vtable = { .message_function = ownerchanged_handler, };
96 + DBusError error;
97 + const char MATCH_RULE[] = "sender='org.freedesktop.DBus',"
98 + "interface='org.freedesktop.DBus',"
99 + "type='signal',"
100 + "path='/org/freedesktop/DBus',"
101 + "member='NameOwnerChanged'";
102 + int rc = FALSE;
103 +
104 + dbus_error_init(&error);
105 + dbus_bus_add_match(connection, MATCH_RULE, &error);
106 + if (!dbus_error_is_set(&error)) {
107 + if (dbus_connection_register_object_path(connection,
108 + "/org/freedesktop/DBus",
109 + &vtable,
110 + data))
111 + rc = TRUE;
112 + else
113 + ErrorF("[config/hal] cannot register object path.\n");
114 + } else {
115 + ErrorF("[config/hal] couldn't add match rule: %s (%s)\n", error.name,
116 + error.message);
117 + ErrorF("[config/hal] cannot detect a HAL startup.\n");
118 + }
119 +
120 + dbus_error_free(&error);
121 +
122 + return rc;
123 +}
124 +
125 +static void
126 +connect_hook(DBusConnection *connection, void *data)
127 +{
128 + struct config_hal_info *info = data;
129 +
130 + if (listen_for_startup(connection, data) &&
131 + connect_and_register(connection, info))
132 + dbus_connection_unregister_object_path(connection,
133 + "/org/freedesktop/DBus");
134 +
135 return;
136 }