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
based on that I am writing following codeQuote:
signal sender=:1.5 -> dest=(null destination) path=/com/nokia/mce/signal; interface=com.nokia.mce.signal; member=display_status_ind
string "dimmed"
where halObj class is as followsCode:
bool success = conn.connect("com.nokia.mce.signal","/com/nokia/mce/signal","com.nokia.mce.signal", "display_status_ind",halObj, SLOT(listenInactivity(string))); qDebug() << "SUCCESS : " << success;
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
Code:
void fun() { qDebug()<<"Step1"; //Step 1 /* Register previously declared types with DBus */ qDBusRegisterMetaType<Property>(); qDBusRegisterMetaType< QList<Property> >(); qDebug()<<"Step2"; //Step 2 /* This object is used to listen for and react to events */ HalObj * halObj = new HalObj(); /* HAL stores everything on the system bus */ /* Connect to the HAL Manager device to find all devices */ qDebug()<<"Step5"; //Step 5 /* Listen for any ’display_status_ind’ events from this battery * on DBus */ bool success = conn.connect("com.nokia.mce.signal","/com/nokia/mce/signal","com.nokia.mce.signal", "display_status_ind",halObj, SLOT(listenInactivity(string))); qDebug() << "SUCCESS : " << success; qDebug()<<"Step7"; } int main(int argc, char *argv[]) { while(1) { fun(); sleep(2); } return a.exec(); }
Please let me know how to go about this problem.
Another signal I am looking for is charger connected.
The DBus monitor shows following:
My question isQuote:
signal sender=:1.2 -> dest=(null destination) path=/com/nokia/bme/signal; interface=com.nokia.bme.signal; member=charger_connected
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