Hotplug: HAL: Fix error handling

Don't use our DBusError for property getting, because we simply don't care:
this fixes D-Bus error spew to stderr.  Thanks Michel Dänzer for debugging
and testing.
This commit is contained in:
Daniel Stone 2007-08-07 20:58:49 +03:00
parent aef255425a
commit 30259d5a4e

View File

@ -98,12 +98,11 @@ add_option(InputOption **options, const char *key, const char *value)
} }
static char * static char *
get_prop_string(LibHalContext *hal_ctx, const char *udi, const char *name, get_prop_string(LibHalContext *hal_ctx, const char *udi, const char *name)
DBusError *error)
{ {
char *prop, *ret; char *prop, *ret;
prop = libhal_device_get_property_string(hal_ctx, udi, name, error); prop = libhal_device_get_property_string(hal_ctx, udi, name, NULL);
DebugF(" [config/hal] getting %s on %s returned %s\n", name, udi, prop); DebugF(" [config/hal] getting %s on %s returned %s\n", name, udi, prop);
if (prop) { if (prop) {
ret = xstrdup(prop); ret = xstrdup(prop);
@ -117,13 +116,12 @@ get_prop_string(LibHalContext *hal_ctx, const char *udi, const char *name,
} }
static char * static char *
get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop, get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop)
DBusError *error)
{ {
char **props, *ret, *str; char **props, *ret, *str;
int i, len = 0; int i, len = 0;
props = libhal_device_get_property_strlist(hal_ctx, udi, prop, error); props = libhal_device_get_property_strlist(hal_ctx, udi, prop, NULL);
if (props) { if (props) {
for (i = 0; props[i]; i++) for (i = 0; props[i]; i++)
len += strlen(props[i]); len += strlen(props[i]);
@ -187,24 +185,22 @@ device_added(LibHalContext *hal_ctx, const char *udi)
if (type == TYPE_NONE) if (type == TYPE_NONE)
goto out_error; goto out_error;
driver = get_prop_string(hal_ctx, udi, "input.x11_driver", &error); driver = get_prop_string(hal_ctx, udi, "input.x11_driver");
path = get_prop_string(hal_ctx, udi, "input.device", &error); path = get_prop_string(hal_ctx, udi, "input.device");
if (!driver || !path) { if (!driver || !path) {
DebugF("[config/hal] no driver or path specified for %s\n", udi); DebugF("[config/hal] no driver or path specified for %s\n", udi);
goto unwind; goto unwind;
} }
name = get_prop_string(hal_ctx, udi, "info.product", &error); name = get_prop_string(hal_ctx, udi, "info.product");
if (!name) if (!name)
name = xstrdup("(unnamed)"); name = xstrdup("(unnamed)");
if (type & TYPE_KEYS) { if (type & TYPE_KEYS) {
xkb_rules = get_prop_string(hal_ctx, udi, "input.xkb.rules", &error); xkb_rules = get_prop_string(hal_ctx, udi, "input.xkb.rules");
xkb_model = get_prop_string(hal_ctx, udi, "input.xkb.model", &error); xkb_model = get_prop_string(hal_ctx, udi, "input.xkb.model");
xkb_layout = get_prop_string(hal_ctx, udi, "input.xkb.layout", &error); xkb_layout = get_prop_string(hal_ctx, udi, "input.xkb.layout");
xkb_variant = get_prop_string(hal_ctx, udi, "input.xkb.variant", xkb_variant = get_prop_string(hal_ctx, udi, "input.xkb.variant");
&error); xkb_options = get_prop_string_array(hal_ctx, udi, "input.xkb.options");
xkb_options = get_prop_string_array(hal_ctx, udi, "input.xkb.options",
&error);
} }
options = xcalloc(sizeof(*options), 1); options = xcalloc(sizeof(*options), 1);
@ -273,7 +269,8 @@ disconnect_hook(void *data)
if (info->hal_ctx) { if (info->hal_ctx) {
dbus_error_init(&error); dbus_error_init(&error);
if (!libhal_ctx_shutdown(info->hal_ctx, &error)) if (!libhal_ctx_shutdown(info->hal_ctx, &error))
DebugF("[config/hal] couldn't shut down context?\n"); DebugF("[config/hal] couldn't shut down context: %s (%s)\n",
error.name, error.message);
libhal_ctx_free(info->hal_ctx); libhal_ctx_free(info->hal_ctx);
dbus_error_free(&error); dbus_error_free(&error);
} }
@ -320,6 +317,7 @@ connect_hook(DBusConnection *connection, void *data)
devices = libhal_find_device_by_capability(info->hal_ctx, "input", devices = libhal_find_device_by_capability(info->hal_ctx, "input",
&num_devices, &error); &num_devices, &error);
/* FIXME: Get default devices if error is set. */
for (i = 0; i < num_devices; i++) for (i = 0; i < num_devices; i++)
device_added(info->hal_ctx, devices[i]); device_added(info->hal_ctx, devices[i]);
libhal_free_string_array(devices); libhal_free_string_array(devices);
@ -330,7 +328,8 @@ connect_hook(DBusConnection *connection, void *data)
out_ctx2: out_ctx2:
if (!libhal_ctx_shutdown(info->hal_ctx, &error)) if (!libhal_ctx_shutdown(info->hal_ctx, &error))
DebugF("[config/hal] couldn't shut down context?\n"); DebugF("[config/hal] couldn't shut down context: %s (%s)\n",
error.name, error.message);
out_ctx: out_ctx:
libhal_ctx_free(info->hal_ctx); libhal_ctx_free(info->hal_ctx);
out_err: out_err: