summaryrefslogtreecommitdiffstats
path: root/common/hal-libhal.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-03-21 14:24:15 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-03-21 14:24:15 +0000
commit833ce8edc2b4cde819a2aa7efb8e562958c48acd (patch)
treee48df90df6d0e8cb059036e65c908b9de53f93ed /common/hal-libhal.c
parentad5740f56965f3fc003b704fe41e80fe1e53434d (diff)
Implement generic HAL device helpers
Diffstat (limited to 'common/hal-libhal.c')
-rw-r--r--common/hal-libhal.c49
1 files changed, 35 insertions, 14 deletions
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;
+}