-void
-ghb_hal_init()
-{
-#if !defined(_WIN32)
- DBusGConnection *gconn;
- DBusConnection *conn;
- GError *gerror = NULL;
- DBusError error;
- char **devices;
- int nr;
-
- dbus_init ();
-
- if (!(hal_ctx = libhal_ctx_new ())) {
- g_warning ("failed to create a HAL context!");
- return;
- }
-
- gconn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &gerror);
- if (gerror != NULL)
- {
- g_warning("DBUS cannot connect: %s", gerror->message);
- g_error_free(gerror);
- return;
- }
- conn = dbus_g_connection_get_connection(gconn);
- libhal_ctx_set_dbus_connection (hal_ctx, conn);
- dbus_error_init (&error);
- if (!libhal_ctx_init (hal_ctx, &error)) {
- g_warning ("libhal_ctx_init failed: %s", error.message ? error.message : "unknown");
- dbus_error_free (&error);
- libhal_ctx_free (hal_ctx);
- dbus_g_connection_unref(gconn);
- hal_ctx = NULL;
- return;
- }
-
- /*
- * Do something to ping the HAL daemon - the above functions will
- * succeed even if hald is not running, so long as DBUS is. But we
- * want to exit silently if hald is not running, to behave on
- * pre-2.6 systems.
- */
- if (!(devices = libhal_get_all_devices (hal_ctx, &nr, &error))) {
- g_warning ("seems that HAL is not running: %s", error.message ? error.message : "unknown");
- dbus_error_free (&error);
-
- libhal_ctx_shutdown (hal_ctx, NULL);
- libhal_ctx_free (hal_ctx);
- hal_ctx = NULL;
- dbus_g_connection_unref(gconn);
- return;
- }
-
- libhal_free_string_array (devices);
- dbus_g_connection_unref(gconn);
-#endif
-}
-