wok-current diff xorg-server-tinyX/stuff/xorg-server-tinyX-1.5.3-hal_parallel.u @ rev 3977
Update: firefox (BUILD_DEPENDS)
author | Matthew Sheets <rcx@zoominternet.net> |
---|---|
date | Thu Aug 27 10:36:45 2009 +0000 (2009-08-27) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xorg-server-tinyX/stuff/xorg-server-tinyX-1.5.3-hal_parallel.u Thu Aug 27 10:36:45 2009 +0000 1.3 @@ -0,0 +1,136 @@ 1.4 +diff --git xorg-server-1.5.3/config/hal.c xorg-server-1.5.3/config/hal.c 1.5 +index 8dfbb07..36fa839 100644 1.6 +--- xorg-server-1.5.3/config/hal.c 1.7 ++++ xorg-server-1.5.3/config/hal.c 1.8 +@@ -467,11 +467,10 @@ disconnect_hook(void *data) 1.9 +info->system_bus = NULL; 1.10 +} 1.11 +-static void 1.12 +-connect_hook(DBusConnection *connection, void *data) 1.13 ++static BOOL 1.14 ++connect_and_register(DBusConnection *connection, struct config_hal_info *info) 1.15 +{ 1.16 +DBusError error; 1.17 +- struct config_hal_info *info = data; 1.18 +char **devices; 1.19 +int num_devices, i; 1.20 +@@ -479,8 +478,10 @@ connect_hook(DBusConnection *connection, void *data) 1.21 +dbus_error_init(&error); 1.22 +- if (!info->hal_ctx) 1.23 +- info->hal_ctx = libhal_ctx_new(); 1.24 ++ if (info->hal_ctx) 1.25 ++ return TRUE; /* already registered, pretend we did something */ 1.26 ++ 1.27 ++ info->hal_ctx = libhal_ctx_new(); 1.28 +if (!info->hal_ctx) { 1.29 +LogMessage(X_ERROR, "config/hal: couldn't create HAL context\n"); 1.30 +goto out_err; 1.31 +@@ -512,7 +513,7 @@ connect_hook(DBusConnection *connection, void *data) 1.32 +dbus_error_free(&error); 1.33 +- return; 1.34 ++ return TRUE; 1.35 +out_ctx2: 1.36 +if (!libhal_ctx_shutdown(info->hal_ctx, &error)) 1.37 +@@ -525,6 +526,104 @@ out_err: 1.38 +info->hal_ctx = NULL; 1.39 +info->system_bus = NULL; 1.40 ++ return FALSE; 1.41 ++} 1.42 ++ 1.43 ++ 1.44 ++/** 1.45 ++ * Handle NewOwnerChanged signals to deal with HAL startup at X server runtime. 1.46 ++ * 1.47 ++ * NewOwnerChanged is send once when HAL shuts down, and once again when it 1.48 ++ * comes back up. Message has three arguments, first is the name 1.49 ++ * (org.freedesktop.Hal), the second one is the old owner, third one is new 1.50 ++ * owner. 1.51 ++ */ 1.52 ++static DBusHandlerResult 1.53 ++ownerchanged_handler(DBusConnection *connection, DBusMessage *message, void *data) 1.54 ++{ 1.55 ++ int ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 1.56 ++ 1.57 ++ if (dbus_message_is_signal(message, 1.58 ++ "org.freedesktop.DBus", 1.59 ++ "NameOwnerChanged")) { 1.60 ++ DBusError error; 1.61 ++ char *name, *old_owner, *new_owner; 1.62 ++ 1.63 ++ dbus_error_init(&error); 1.64 ++ dbus_message_get_args(message, &error, 1.65 ++ DBUS_TYPE_STRING, &name, 1.66 ++ DBUS_TYPE_STRING, &old_owner, 1.67 ++ DBUS_TYPE_STRING, &new_owner, 1.68 ++ DBUS_TYPE_INVALID); 1.69 ++ 1.70 ++ if (dbus_error_is_set(&error)) { 1.71 ++ ErrorF("[config/hal] failed to get NameOwnerChanged args: %s (%s)\n", 1.72 ++ error.name, error.message); 1.73 ++ } else if (name && strcmp(name, "org.freedesktop.Hal") == 0) { 1.74 ++ 1.75 ++ if (!old_owner || !strlen(old_owner)) { 1.76 ++ DebugF("[config/hal] HAL startup detected.\n"); 1.77 ++ if (connect_and_register(connection, (struct config_hal_info*)data)) 1.78 ++ dbus_connection_unregister_object_path(connection, 1.79 ++ "/org/freedesktop/DBus"); 1.80 ++ else 1.81 ++ ErrorF("[config/hal] Failed to connect to HAL bus.\n"); 1.82 ++ } 1.83 ++ 1.84 ++ ret = DBUS_HANDLER_RESULT_HANDLED; 1.85 ++ } 1.86 ++ dbus_error_free(&error); 1.87 ++ } 1.88 ++ 1.89 ++ return ret; 1.90 ++} 1.91 ++ 1.92 ++/** 1.93 ++ * Register a handler for the NameOwnerChanged signal. 1.94 ++ */ 1.95 ++static BOOL 1.96 ++listen_for_startup(DBusConnection *connection, void *data) 1.97 ++{ 1.98 ++ DBusObjectPathVTable vtable = { .message_function = ownerchanged_handler, }; 1.99 ++ DBusError error; 1.100 ++ const char MATCH_RULE[] = "sender='org.freedesktop.DBus'," 1.101 ++ "interface='org.freedesktop.DBus'," 1.102 ++ "type='signal'," 1.103 ++ "path='/org/freedesktop/DBus'," 1.104 ++ "member='NameOwnerChanged'"; 1.105 ++ int rc = FALSE; 1.106 ++ 1.107 ++ dbus_error_init(&error); 1.108 ++ dbus_bus_add_match(connection, MATCH_RULE, &error); 1.109 ++ if (!dbus_error_is_set(&error)) { 1.110 ++ if (dbus_connection_register_object_path(connection, 1.111 ++ "/org/freedesktop/DBus", 1.112 ++ &vtable, 1.113 ++ data)) 1.114 ++ rc = TRUE; 1.115 ++ else 1.116 ++ ErrorF("[config/hal] cannot register object path.\n"); 1.117 ++ } else { 1.118 ++ ErrorF("[config/hal] couldn't add match rule: %s (%s)\n", error.name, 1.119 ++ error.message); 1.120 ++ ErrorF("[config/hal] cannot detect a HAL startup.\n"); 1.121 ++ } 1.122 ++ 1.123 ++ dbus_error_free(&error); 1.124 ++ 1.125 ++ return rc; 1.126 ++} 1.127 ++ 1.128 ++static void 1.129 ++connect_hook(DBusConnection *connection, void *data) 1.130 ++{ 1.131 ++ struct config_hal_info *info = data; 1.132 ++ 1.133 ++ if (listen_for_startup(connection, data) && 1.134 ++ connect_and_register(connection, info)) 1.135 ++ dbus_connection_unregister_object_path(connection, 1.136 ++ "/org/freedesktop/DBus"); 1.137 ++ 1.138 +return; 1.139 +}