PDA

View Full Version : QDBusMessage problem



nrabara
23rd November 2009, 13:09
Hi,

I am using Qt binding to speak with DBus, I have created interface with system bus.




//Now when I call QDbusMessage msg = interface.call(“ListDevices”);
//It gives me the following,

qDebu() << “ msg :” << msg;

msg: QDBusMessage = (type=MethodReturn, service”:1:0”, signature=”ao”, contents=((Arguments: ao{[objectPath: /org/bluez/780/hci0/dev_00_1C_EF_44_D6_1D], [ObjectPath: /org/bluez/780/hci0/dev_00_OD_18_D1_OF_1A]) )

//Now when I try to get string from the message by using following, code got to infinite loop.

QList <QVariant> devices = msg.arguments();

QVariant (name,devices)
{
QString dName =name.toStringList()[0]; // code gets hang here
qDebug << “Debug” << dName;
}



Can Anybody help me, how to iterate this msg and find the List of devices from the message(last arguments[contents])

Your suggestion would be a great help for me…

Thanks in advance,
Nirav

waiter
10th November 2012, 09:17
QDBusMessage msg = interface->call("EnumerateDevices");

QList<QVariant> jj = msg.arguments();
QVariant varr = jj.at(0);

if(varr.canConvert<QDBusArgument>())
{
QDBusArgument arg = varr.value<QDBusArgument>();

if(arg.currentType() == QDBusArgument::ArrayType)
{
QList<QDBusObjectPath> pathsLst = qdbus_cast<QList<QDBusObjectPath> >(arg);
qDebug()<<"devices count"<<pathsLst.count();
foreach(QDBusObjectPath,pathsLst)
{}
}
}