diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-03-21 14:24:15 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-03-21 14:24:15 +0000 |
commit | 833ce8edc2b4cde819a2aa7efb8e562958c48acd (patch) | |
tree | e48df90df6d0e8cb059036e65c908b9de53f93ed /common | |
parent | ad5740f56965f3fc003b704fe41e80fe1e53434d (diff) |
Implement generic HAL device helpers
Diffstat (limited to 'common')
-rw-r--r-- | common/hal-dummy.c | 5 | ||||
-rw-r--r-- | common/hal-libhal.c | 49 | ||||
-rw-r--r-- | common/hal.h | 7 |
3 files changed, 47 insertions, 14 deletions
diff --git a/common/hal-dummy.c b/common/hal-dummy.c index e16a6b67..8d6be05f 100644 --- a/common/hal-dummy.c +++ b/common/hal-dummy.c @@ -35,3 +35,8 @@ int hal_init(DBusConnection *conn) void hal_cleanup(void) { } + +int hal_add_device(struct hal_device *device) +{ + return 0; +} diff --git a/common/hal-libhal.c b/common/hal-libhal.c index d3fe9717..4ae97098 100644 --- a/common/hal-libhal.c +++ b/common/hal-libhal.c @@ -40,8 +40,6 @@ static LibHalContext *hal_ctx = NULL; int hal_init(DBusConnection *conn) { - char str[64], *udi; - hal_ctx = libhal_ctx_new(); if (!hal_ctx) return -ENOMEM; @@ -62,18 +60,6 @@ int hal_init(DBusConnection *conn) return -EIO; } - udi = libhal_new_device(hal_ctx, NULL); - - if (libhal_device_add_capability(hal_ctx, udi, "net", NULL) == FALSE) { - error("Failed to add device capability"); - } - - sprintf(str, "/org/freedesktop/Hal/devices/bluetooth_pan"); - - if (libhal_device_commit_to_gdl(hal_ctx, udi, str, NULL) == FALSE) { - error("Failed to add new HAL device"); - } - return 0; } @@ -88,3 +74,38 @@ void hal_cleanup(void) hal_ctx = NULL; } + +int hal_add_device(struct hal_device *device) +{ + char udi[128], *dev; + char *str = "00000000-0000-1000-8000-00805f9b34fb"; + + dev = libhal_new_device(hal_ctx, NULL); + + if (libhal_device_add_capability(hal_ctx, dev, + "bluetooth", NULL) == FALSE) { + error("Failed to add device capability"); + } + + if (libhal_device_set_property_string(hal_ctx, dev, + "bluetooth.uuid", str, NULL) == FALSE) { + error("Failed to add UUID property"); + } + + if (libhal_device_set_property_bool(hal_ctx, dev, + "bluetooth.is_connected", FALSE, NULL) == FALSE) { + error("Failed to add connected state property"); + } + + sprintf(udi, "/org/freedesktop/Hal/devices/bluetooth_network_connection_aabbccddeeff"); + + if (libhal_remove_device(hal_ctx, udi, NULL) == FALSE) { + error("Can't remove old HAL device"); + } + + if (libhal_device_commit_to_gdl(hal_ctx, dev, udi, NULL) == FALSE) { + error("Failed to add new HAL device"); + } + + return 0; +} diff --git a/common/hal.h b/common/hal.h index 5ff86a8a..f2afacad 100644 --- a/common/hal.h +++ b/common/hal.h @@ -25,3 +25,10 @@ int hal_init(DBusConnection *conn); void hal_cleanup(void); + +struct hal_device { + char *udi; + char uuid[37]; +}; + +int hal_add_device(struct hal_device *); |