summaryrefslogtreecommitdiffstats
path: root/network/hal.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-03-19 19:46:43 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-03-19 19:46:43 +0000
commite867e1dc937eedbaa3ac7f678f4703fab78d2d4e (patch)
treef4c6f92695969e089f0259bba3b0f607ef825d4b /network/hal.c
parent37ca3ab5974892ba7a4a87420a70bafa070db812 (diff)
Try to init the HAL context
Diffstat (limited to 'network/hal.c')
-rw-r--r--network/hal.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/network/hal.c b/network/hal.c
index f024282e..79e2b6e5 100644
--- a/network/hal.c
+++ b/network/hal.c
@@ -25,13 +25,47 @@
#include <config.h>
#endif
+#include <errno.h>
+
+#include <dbus/dbus.h>
+#include <hal/libhal.h>
+
+#include "logging.h"
+
#include "hal.h"
-int hal_init(void)
+static LibHalContext *hal_ctx = NULL;
+
+int hal_init(DBusConnection *conn)
{
+ hal_ctx = libhal_ctx_new();
+ if (!hal_ctx)
+ return -ENOMEM;
+
+ if (libhal_ctx_set_dbus_connection(hal_ctx, conn) == FALSE) {
+ libhal_ctx_free(hal_ctx);
+ hal_ctx = NULL;
+ return -EIO;
+ }
+
+ if (libhal_ctx_init(hal_ctx, NULL) == FALSE) {
+ error("Unable to init HAL context");
+ libhal_ctx_free(hal_ctx);
+ hal_ctx = NULL;
+ return -EIO;
+ }
+
return 0;
}
void hal_cleanup(void)
{
+ if (!hal_ctx)
+ return;
+
+ libhal_ctx_shutdown(hal_ctx, NULL);
+
+ libhal_ctx_free(hal_ctx);
+
+ hal_ctx = NULL;
}