Problem Interfacing with Hal

Marko Anastasov marko at marko.anastasov.name
Sat Feb 25 08:24:08 PST 2006


On Fri, 2006-02-24 at 18:20 -0500, Danny Budik wrote:
> What I do is initialize Hal where the callbacks 
> libhal_ctx_set_device_added and libhal_ctx_set_device_removed are 
> called. Then I have a while loop which just waits for an event (such as 
> my plugging in a device).

Are you using glib? In that case, in the initialization code
you should have something like:

dbus_conn_ = dbus_bus_get(DBUS_BUS_SYSTEM, error);
if (! (dbus_error_is_set(error)))
{
  dbus_connection_setup_with_g_main(dbus_conn_, NULL);
  libhal_ctx_set_dbus_connection(hal_ctx_, dbus_conn_);
}

for the callbacks:

libhal_ctx_set_device_added(hal_ctx_, on_hal_device_added);
libhal_ctx_set_device_removed (hal_ctx_, on_hal_device_removed);
libhal_ctx_set_device_property_modified(hal_ctx_,on_hal_property_modified);

and then:

static void
on_hal_device_added(LibHalContext* ctx, const char* udi)
{ ... }


Marko



More information about the hal mailing list