maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   QDBus and connect to com.nokia.csd.Call (https://talk.maemo.org/showthread.php?t=50718)

prklic 2010-04-22 06:45

Problem: QDBus and connect to com.nokia.csd.Call
 
Hello all,
I'm started develop one application which use Qt, QDBus for display incoming call. I try connect to com.nokia.csd.Call via QDBusConnection. This connection is OK, I receive TRUE. But if I call to my phone from other phone, incomming call isn't displayed!

See below for my code.

My class is:

class MyClass : public QObject
{
Q_OBJECT

public:
MyClass(QObject *parent = 0);
~MyClass(){}

public slots:
void receiveCall(QString path, QString callNum);
}


method "receiveCall" is implemented as:

void MyClass::receiveCall(QString path, QString callNum)
{
QLabel label;
...
label.show();
label.setText("Incoming call: " + path + " " + callNum);
}


In main.cpp:

static QDBusConnection conn = QDBusConnection::systemBus();

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QLabel label;
....

MyClass *mycall = new MyClass();
bool result = conn.connect("com.nokia.csd.Call", "/com/nokia/csd/call", "com.nokia.csd.Call", "Coming", mycall, SLOT(receiveCall(QString,QString)));

if(result)
{
label.setText("DBus connected OK!");
}
else
{
label.setText("DBus connected ERROR!");
}

return a.exec();
}


After start application I see text "DBus connected OK!". When I call to phone with application, so no label with text "Incoming call: ..." isn't see. Where is problem? Where do I error?

Thanks all

vhs 2010-04-22 12:26

Re: Problem: QDBus and connect to com.nokia.csd.Call
 
Hi,
I have used QT but not on maemo, so my answer would not be maemo specific.
Looks like the problem is that your QLabel object is created on the stack and destroyed after the slot returns. so what you should do is create the QLabel as a datamember of MyClass and create it in the MyClass contructor. Use the same QLabel in main and in the MyClass::receiveCall() slot.

hope this helps.

prklic 2010-04-22 20:55

Re: QDBus and connect to com.nokia.csd.Call
 
Hi,
I'm try it, but not help :( .

arne.anka 2010-04-22 21:01

Re: QDBus and connect to com.nokia.csd.Call
 
quick idea: your label doesn't have a parent. where is it supposed to appear?

prklic 2010-04-22 21:18

Re: QDBus and connect to com.nokia.csd.Call
 
I want display call number, but if I'm add QLabel created in main function, to MyClass, doesn't work.

vhs 2010-04-22 21:35

Re: QDBus and connect to com.nokia.csd.Call
 
Try something in these lines. I haven't compiled it, so there may be some errors.

class MyClass : public QObject
{
Q_OBJECT

private:
QLabel *label;
public:
MyClass(QObject *parent = 0)
{
label = new QLabel();
}
~MyClass(){}
void setText(QString s)
{
label->setText(s);
}


public slots:
void receiveCall(QString path, QString callNum);
}

method "receiveCall" is implemented as:

void MyClass::receiveCall(QString path, QString callNum)
{
setText("Incoming call: " + path + " " + callNum);
}

In main.cpp:

static QDBusConnection conn = QDBusConnection::systemBus();

int main(int argc, char *argv[])
{
QApplication a(argc, argv);



MyClass *mycall = new MyClass();
bool result = conn.connect("com.nokia.csd.Call", "/com/nokia/csd/call", "com.nokia.csd.Call", "Coming", mycall, SLOT(receiveCall(QString,QString)));

if(result)
{
mycall->setText("DBus connected OK!");
}
else
{
mycall->setText("DBus connected ERROR!");
}

return a.exec();
}

prklic 2010-04-22 22:14

Re: QDBus and connect to com.nokia.csd.Call
 
Does not work. I think, that the signal "Coming" is processed via maemo application and don't next.

vhs 2010-04-22 23:38

Re: QDBus and connect to com.nokia.csd.Call
 
If your conn.connect() returns true then the signal is definitely connected and if the signal is ever emitted your slot would get called.
If conn.connect returns true then the issues would be one of these:
>You are not connected to the right signal
>The signal is not getting emitted.

prklic 2010-04-23 05:31

Re: QDBus and connect to com.nokia.csd.Call
 
I want something like http://maemocentral.com/2010/02/22/h...s-on-the-n900/ in Python but in Qt. Accordingly connect to signal "Comit". I think that signal name is OK, but maybe not work in Qt.

crabsody 2010-04-25 09:23

Re: QDBus and connect to com.nokia.csd.Call
 
I don't know much about Qt or QDbus but I have a question that might help. Who sets in your slot receiveCall that its arguments are the path and the callNum? Maybe you should create a QDBusMessage and have a connection like this

bool result = conn.connect("com.nokia.csd.Call", "/com/nokia/csd/call", "com.nokia.csd.Call", "Coming", mycall, SLOT(receiveCall(const QDBusMessage&)));


All times are GMT. The time now is 15:12.

vBulletin® Version 3.8.8