×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    95

    Angry How to listen to System clock changes CLOCKD_TIME_CHANGED using Qt ?

    hi there;
    I was trying to create a Qt application that can listen to System clock changes (i.e a user has adjusted the system clock). I found a DBus signal in libtime.h called CLOCKD_TIME_CHANGED , this signal -as described by the documentation - is sent when the time settings das been changed
    I used dbus-monitor --system to verfiy if it is emitted when I change system clock and i found the following :
    Code:
    signal sender=:1.28 -> dest=(null destination) serial=455 path=/com/nokia/time; interface=com.nokia.time; member=changed
       int64 403039731056640
    signal sender=:1.28 -> dest=(null destination) serial=456 path=/com/nokia/clockd; interface=com.nokia.clockd; member=time_changed
       int32 0
    signal sender=:1.28 -> dest=(null destination) serial=467 path=/com/nokia/time; interface=com.nokia.time; member=changed
       int64 0
    signal sender=:1.28 -> dest=(null destination) serial=468 path=/com/nokia/clockd; interface=com.nokia.clockd; member=time_changed
       int32 0
    signal sender=:1.28 -> dest=(null destination) serial=502 path=/com/nokia/time; interface=com.nokia.time; member=changed
       int64 503937102774272
    signal sender=:1.28 -> dest=(null destination) serial=503 path=/com/nokia/clockd; interface=com.nokia.clockd; member=time_changed
       int32 0
    signal sender=:1.28 -> dest=(null destination) serial=513 path=/com/nokia/time; interface=com.nokia.time; member=changed
       int64 1265145480
    signal sender=:1.28 -> dest=(null destination) serial=514 path=/com/nokia/clockd; interface=com.nokia.clockd; member=time_changed
       int32 1265145480
    signal sender=:1.38 -> dest=(null destination) serial=54 path=/com/nokia/alarmd; interface=com.nokia.alarmd; member=queue_status_ind
       int32 0
       int32 2147483647
       int32 2147483647
       int32 1265200040
    signal sender=:1.38 -> dest=(null destination) serial=55 path=/com/nokia/alarmd; interface=com.nokia.alarmd; member=time_change_ind
    Everything is OK so far,
    But the problem is when I try to connect to it uding QT-dbus
    the connect statement always returns false and the slot I created to handle the change is never called.
    I don't know where the problem is
    My .pro file has the following added to it:
    Code:
    INCLUDEPATH += /usr/include/clockd /usr/include/dbus-1.0 usr/lib/dbus-1.0/include
    LIBS += -ldbus-glib-1 -ldbus-1
    in my code :
    Code:
    #include "/usr/include/clockd/libtime.h"
    #include <time.h>
    #include <QDebug>
    #include <QDBusConnection>
    #include <QDBusInterface>
    #include <QObject>
    QDBusConnection m_pConnection = QDBusConnection::systemBus();
    QDBusInterface* Clock_interface = new QDBusInterface(CLOCKD_SERVICE, CLOCKD_PATH,
    			  CLOCKD_INTERFACE, m_pConnection);
    //QDBusMessage replay = clock_interface
    if(QObject::connect(Clock_interface,SIGNAL(CLOCKD_TIME_CHANGED),this,SLOT(handleTimeChanged())) )qDebug(" managed to connect to dbus signal !!!!");
        else 
    	qDebug("NOT CONNECTED!!!");
    the program compiles and when it runs, it
    tells me there are missing parantheses. So, I tried the connect signal another way
    Code:
    if(QObject::connect(Clock_interface,SIGNAL(CLOCKD_TIME_CHANGED(int)),this,SLOT(handleTimeChanged(int)))
    at runtime, it tells me
    Object::connect: No such signal com::nokia::clockd::CLOCKD_TIME_CHANGED(int)
    I don't know where I went worng. I am not sure i am doing the right thing at the first place!
    Could anybody tell me what to do to make my QT app listen to the CLOCKD_TIME_CHANGED signal???
    thanks in advance

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to listen to System clock changes CLOCKD_TIME_CHANGED using Qt ?

    The correct way to do it is to use QDBusConnection::connect() instead of QObject::connect().
    Also you don't need glib dbus and dbus includes and libs. Instead you have to add
    Code:
    QT += dbus
    to your project file.

Similar Threads

  1. kinetic scrolling
    By stalep in forum Nokia N9
    Replies: 10
    Last Post: 2009-12-08, 12:41
  2. system clock drift
    By nstamps in forum Mobile Java General
    Replies: 1
    Last Post: 2007-07-24, 10:48
  3. Hello guys!How can I code a system clock program!
    By yms541 in forum Mobile Java General
    Replies: 2
    Last Post: 2006-06-20, 18:23
  4. System Help with nokia pc connectivity SDK
    By gotka in forum PC Suite API and PC Connectivity SDK
    Replies: 4
    Last Post: 2004-07-06, 09:56
  5. How to get the time from system clock?
    By jarjak in forum Symbian
    Replies: 2
    Last Post: 2003-08-20, 13:50

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×