From e867e1dc937eedbaa3ac7f678f4703fab78d2d4e Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 19 Mar 2007 19:46:43 +0000 Subject: Try to init the HAL context --- network/hal.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'network/hal.c') 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 #endif +#include + +#include +#include + +#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; } -- cgit