juannm
14th January 2009, 20:04
Hello,
I'm playing with HAL and writing a console application in order to write a message when plugging a usb pendrive.
The problem is that libhal must be initialized with a call to the following function (from the HAL API):
bool libhal_ctx_set_dbus_connection (LibHalContext *ctx, DBusConnection *conn);
so a DBusConnection instance is needed.
I can create one the "standard" way, by calling (from the D-Bus API):
DBusConnection* dbus_bus_get(DBusBusType type, DBusError *error);
but then this DBusConnection is not integrated with the Qt main loop, so later in the code, when calling "return app.exec()" my program enters the main loop and nothing shows up in the console.
I thought about using the DBusConnection created inside QDBusConnection::systemBus(), because I expect it to be integrated with the Qt main loop (but then maybe I'm wrong), maybe using the "Unique Connection Name" of the connection (given by QDBusConnection::baseService()), but then I would need some method like "DBusConnection* dbus_bus_get_by_unique_name(char* name)", and that doesn't seem to exist in the D-Bus API.
Am I facing this issue the wrong way? Any comments or suggestions are truly appreciated :)
I'm playing with HAL and writing a console application in order to write a message when plugging a usb pendrive.
The problem is that libhal must be initialized with a call to the following function (from the HAL API):
bool libhal_ctx_set_dbus_connection (LibHalContext *ctx, DBusConnection *conn);
so a DBusConnection instance is needed.
I can create one the "standard" way, by calling (from the D-Bus API):
DBusConnection* dbus_bus_get(DBusBusType type, DBusError *error);
but then this DBusConnection is not integrated with the Qt main loop, so later in the code, when calling "return app.exec()" my program enters the main loop and nothing shows up in the console.
I thought about using the DBusConnection created inside QDBusConnection::systemBus(), because I expect it to be integrated with the Qt main loop (but then maybe I'm wrong), maybe using the "Unique Connection Name" of the connection (given by QDBusConnection::baseService()), but then I would need some method like "DBusConnection* dbus_bus_get_by_unique_name(char* name)", and that doesn't seem to exist in the D-Bus API.
Am I facing this issue the wrong way? Any comments or suggestions are truly appreciated :)