Results 1 to 2 of 2

Thread: Qt on maemo DBus

  1. #1
    Join Date
    Mar 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Qt on maemo DBus

    Hi,

    I am trying to use Qt4 on maemo 4.x. (I am an absolute beginner to linux world.)

    I am trying to capture event when the device goes in dimmed state. I understand we need to use DBus for it.
    Following is the information I get when dbus-monitor is run on the device
    signal sender=:1.5 -> dest=(null destination) path=/com/nokia/mce/signal; interface=com.nokia.mce.signal; member=display_status_ind
    string "dimmed"
    based on that I am writing following code
    Qt Code:
    1. bool success = conn.connect("com.nokia.mce.signal","/com/nokia/mce/signal","com.nokia.mce.signal", "display_status_ind",halObj, SLOT(listenInactivity(string)));
    2. qDebug() << "SUCCESS : " << success;
    To copy to clipboard, switch view to plain text mode 
    where halObj class is as follows
    class HalObj : public QObject
    {
    Q_OBJECT
    public:
    HalObj (QObject * parent = 0);
    virtual ~ HalObj() {}
    public slots:
    void listenInactivity(QString aStr);
    };

    But for some reason, my slot never gets called. Also second problem, that I am facing is that, I want to listen for this signal continuously, but it seems, I dont seem to loop by itself, I need to wrap my function call in an infinite while loop.
    Here is my main.cpp

    Qt Code:
    1. void fun()
    2. {
    3. qDebug()<<"Step1";
    4. //Step 1
    5. /* Register previously declared types with DBus */
    6. qDBusRegisterMetaType<Property>();
    7. qDBusRegisterMetaType< QList<Property> >();
    8. qDebug()<<"Step2";
    9. //Step 2
    10. /* This object is used to listen for and react to events */
    11. HalObj * halObj = new HalObj();
    12.  
    13. /* HAL stores everything on the system bus */
    14. QDBusConnection conn = QDBusConnection::systemBus();
    15.  
    16. /* Connect to the HAL Manager device to find all devices */
    17. QDBusInterface battery("com.nokia.bme.signal","/com/nokia/bme/signal","com.nokia.bme.signal",conn);
    18.  
    19. qDebug()<<"Step5";
    20. //Step 5
    21. /* Listen for any ’display_status_ind’ events from this battery
    22.   * on DBus
    23.   */
    24. bool success = conn.connect("com.nokia.mce.signal","/com/nokia/mce/signal","com.nokia.mce.signal", "display_status_ind",halObj, SLOT(listenInactivity(string)));
    25. qDebug() << "SUCCESS : " << success;
    26.  
    27. qDebug()<<"Step7";
    28. }
    29.  
    30. int main(int argc, char *argv[])
    31. {
    32. while(1)
    33. {
    34. fun();
    35. sleep(2);
    36. }
    37. QCoreApplication a(argc, argv);
    38. return a.exec();
    39. }
    To copy to clipboard, switch view to plain text mode 

    Please let me know how to go about this problem.

    Another signal I am looking for is charger connected.
    The DBus monitor shows following:
    signal sender=:1.2 -> dest=(null destination) path=/com/nokia/bme/signal; interface=com.nokia.bme.signal; member=charger_connected
    My question is
    In the above signal,
    Service is: com.nokia.bme.signal
    Path is: /com/nokia/bme/signal
    Interface is: com.nokia.bme.signal
    Method/Signal is : charger_connected
    Parameter to slot: void

    Is my assumption correct?

    any help would be highly appreciated

    Kind Regards

    Mrudul
    Last edited by mrudulpen; 14th March 2009 at 18:19. Reason: updated contents

  2. #2
    Join Date
    Mar 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Cool Re: Qt on maemo DBus

    Hi,

    Found the solution to this.

    Problem was with the path of Signal that was specified. It needs to be ""

    Also no need of Interface. One can directly connect to system or session bus.

    Regards

    Mrudul

Similar Threads

  1. DBus connection
    By Nitz in forum Qt Programming
    Replies: 2
    Last Post: 25th January 2009, 14:43
  2. DBus daemon not starting
    By Khal Drogo in forum Qt Programming
    Replies: 5
    Last Post: 7th August 2008, 15:12
  3. DBus and IPC
    By DrDonut in forum Qt Programming
    Replies: 3
    Last Post: 22nd March 2008, 23:42
  4. Can use Qt to develop app for maemo linux?
    By Teerayoot in forum Newbie
    Replies: 1
    Last Post: 7th December 2007, 20:07

Tags for this Thread

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.