maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Qt: dbus method call fails (https://talk.maemo.org/showthread.php?t=76380)

sakya 2011-09-07 18:36

Qt: dbus method call fails
 
Hi! :)

I have a problem with a dbus method call using Qt.

The method I'm calling is this (it works in the terminal):
Code:

dbus-send --system --print-reply --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.get_operator_name byte:0 uint32:10 uint32:222
method return sender=:1.20 -> dest=:1.4287 reply_serial=2
  string "vodafone IT"
  int32 0

When I try to call it from Qt I always get the error:
Code:

can't find method Phone.Net::get_operator_name
Here's my code
Code:

QDBusInterface device(QLatin1String("com.nokia.phone.net"),
                      QLatin1String("/com/nokia/phone/net"),
                      QLatin1String("Phone.Net"),
                      QDBusConnection::systemBus());
int opCode = 10;
int countryCode = 222;
QDBusMessage msg = device.call(QLatin1String("get_operator_name"), 0, opCode, countryCode);

I'm almost sure the device is correct (it works for calling get_registration_status) so what's the problem?

Many thanks. ;)

jstokes 2011-09-07 18:55

Re: Qt: dbus method call fails
 
It's an issue of wrong types. You're sending (I believe) three integers, when the method wants a byte and two quint32's. I would cast 0 to a uchar and make the other two quint32.

That error message is dodgy; I think it's a custom one sent by the CSD daemon

sakya 2011-09-07 19:19

Re: Qt: dbus method call fails
 
Thanks for your reply. :)
I get the same error passing one uchar and two quint32 variables.

EDIT: From Qt documentation here:
http://doc.trolltech.org/latest/qdbustypesystem.html

uchar --> BYTE
uint --> UINT32

but also using uchar and two uint I get the same error...strange.

nicolai 2011-09-07 21:21

Re: Qt: dbus method call fails
 
This one works for me:


QDBusMessage msg = device.call(QLatin1String("get_operator_name"), QVariant::fromValue(uchar(0)), opCode, countryCode);

sakya 2011-09-07 21:27

Re: Qt: dbus method call fails
 
Yes, it works using QVariant::fromValue(), many thanks. ;)


All times are GMT. The time now is 16:36.

vBulletin® Version 3.8.8