Results 1 to 4 of 4

Thread: HAL & DBusConnection & Qt main loop integration

  1. #1
    Join Date
    Dec 2007
    Posts
    11
    Thanks
    4

    Question HAL & DBusConnection & Qt main loop integration

    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):
    Qt Code:
    1. bool libhal_ctx_set_dbus_connection (LibHalContext *ctx, DBusConnection *conn);
    To copy to clipboard, switch view to plain text mode 
    so a DBusConnection instance is needed.

    I can create one the "standard" way, by calling (from the D-Bus API):
    Qt Code:
    1. DBusConnection* dbus_bus_get(DBusBusType type, DBusError *error);
    To copy to clipboard, switch view to plain text mode 
    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
    Last edited by juannm; 14th January 2009 at 20:05. Reason: updated contents

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: HAL & DBusConnection & Qt main loop integration

    I think you can listen to HAL signals directly using DBUS without any HAL calls. HAL is a normal DBUS service.

  3. #3
    Join Date
    Dec 2007
    Posts
    11
    Thanks
    4

    Default Re: HAL & DBusConnection & Qt main loop integration

    Quote Originally Posted by wysota View Post
    I think you can listen to HAL signals directly using DBUS without any HAL calls. HAL is a normal DBUS service.
    Yes it is, in fact the original way of accessing HAL is though its DBUS interface. But it also ships with two C libraries to link the code with (namely libhal and libhal-storage). I just wanted to use those and forget about dbus stuff (except on initialization), just for the fun of learning how to use it.

    libdbus has a glib adaptor that allows to create a connection integrated with the main loop, and it seems to also have a qt3 version of the same adaptor.

    So I just wanted to know whether someone else has been using libhal (not simply HAL's d-bus interface) + Qt4 and ask him about this.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: HAL & DBusConnection & Qt main loop integration

    Qt4 itself uses the glib loop, so there is a chance it will work out of the box although having to link against a library you need only for a few calls that can be safely done without the library seems like an overkill.

Similar Threads

  1. Main Thread Event loop
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2007, 12:10
  2. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55
  3. While statement inside the main loop
    By OnionRingOfDoom in forum Qt Programming
    Replies: 4
    Last Post: 8th February 2006, 18:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.