|
Lines 474-486
connect_and_register(DBusConnection *connection, struct config_hal_info *info)
Link Here
|
| 474 |
char **devices; |
474 |
char **devices; |
| 475 |
int num_devices, i; |
475 |
int num_devices, i; |
| 476 |
|
476 |
|
|
|
477 |
if (info->hal_ctx) |
| 478 |
return TRUE; /* already registered, pretend we did something */ |
| 479 |
|
| 477 |
info->system_bus = connection; |
480 |
info->system_bus = connection; |
| 478 |
|
481 |
|
| 479 |
dbus_error_init(&error); |
482 |
dbus_error_init(&error); |
| 480 |
|
483 |
|
| 481 |
if (info->hal_ctx) |
|
|
| 482 |
return TRUE; /* already registered, pretend we did something */ |
| 483 |
|
| 484 |
info->hal_ctx = libhal_ctx_new(); |
484 |
info->hal_ctx = libhal_ctx_new(); |
| 485 |
if (!info->hal_ctx) { |
485 |
if (!info->hal_ctx) { |
| 486 |
LogMessage(X_ERROR, "config/hal: couldn't create HAL context\n"); |
486 |
LogMessage(X_ERROR, "config/hal: couldn't create HAL context\n"); |
|
Lines 499-505
connect_and_register(DBusConnection *connection, struct config_hal_info *info)
Link Here
|
| 499 |
if (!libhal_device_property_watch_all(info->hal_ctx, &error)) { |
499 |
if (!libhal_device_property_watch_all(info->hal_ctx, &error)) { |
| 500 |
LogMessage(X_ERROR, "config/hal: couldn't watch all properties: %s (%s)\n", |
500 |
LogMessage(X_ERROR, "config/hal: couldn't watch all properties: %s (%s)\n", |
| 501 |
error.name, error.message); |
501 |
error.name, error.message); |
| 502 |
goto out_ctx2; |
502 |
goto out_ctx; |
| 503 |
} |
503 |
} |
| 504 |
libhal_ctx_set_device_added(info->hal_ctx, device_added); |
504 |
libhal_ctx_set_device_added(info->hal_ctx, device_added); |
| 505 |
libhal_ctx_set_device_removed(info->hal_ctx, device_removed); |
505 |
libhal_ctx_set_device_removed(info->hal_ctx, device_removed); |
|
Lines 507-512
connect_and_register(DBusConnection *connection, struct config_hal_info *info)
Link Here
|
| 507 |
devices = libhal_find_device_by_capability(info->hal_ctx, "input", |
507 |
devices = libhal_find_device_by_capability(info->hal_ctx, "input", |
| 508 |
&num_devices, &error); |
508 |
&num_devices, &error); |
| 509 |
/* FIXME: Get default devices if error is set. */ |
509 |
/* FIXME: Get default devices if error is set. */ |
|
|
510 |
if (dbus_error_is_set(&error)) { |
| 511 |
LogMessage(X_ERROR, "config/hal: couldn't find input device: %s (%s)\n", |
| 512 |
error.name, error.message); |
| 513 |
goto out_ctx; |
| 514 |
} |
| 510 |
for (i = 0; i < num_devices; i++) |
515 |
for (i = 0; i < num_devices; i++) |
| 511 |
device_added(info->hal_ctx, devices[i]); |
516 |
device_added(info->hal_ctx, devices[i]); |
| 512 |
libhal_free_string_array(devices); |
517 |
libhal_free_string_array(devices); |
|
Lines 515-526
connect_and_register(DBusConnection *connection, struct config_hal_info *info)
Link Here
|
| 515 |
|
520 |
|
| 516 |
return TRUE; |
521 |
return TRUE; |
| 517 |
|
522 |
|
| 518 |
out_ctx2: |
|
|
| 519 |
if (!libhal_ctx_shutdown(info->hal_ctx, &error)) |
| 520 |
LogMessage(X_WARNING, "config/hal: couldn't shut down context: %s (%s)\n", |
| 521 |
error.name, error.message); |
| 522 |
out_ctx: |
523 |
out_ctx: |
| 523 |
libhal_ctx_free(info->hal_ctx); |
524 |
dbus_error_free(&error); |
|
|
525 |
|
| 526 |
if (info->hal_ctx) { |
| 527 |
if (!libhal_ctx_shutdown(info->hal_ctx, &error)) { |
| 528 |
LogMessage(X_WARNING, "config/hal: couldn't shut down context: %s (%s)\n", |
| 529 |
error.name, error.message); |
| 530 |
dbus_error_free(&error); |
| 531 |
} |
| 532 |
libhal_ctx_free(info->hal_ctx); |
| 533 |
} |
| 534 |
|
| 524 |
out_err: |
535 |
out_err: |
| 525 |
dbus_error_free(&error); |
536 |
dbus_error_free(&error); |
| 526 |
|
537 |
|
| 527 |
- |
|
|