Rhiakath Guru


Joined: 10 Feb 2006 Posts: 569 Location: Hell...
|
Posted: Tue May 01, 2012 9:03 am Post subject: Retrieving upower devices with qtdbus |
|
|
Hi there. I really really get messed up with dbus, qt and it's data types.
Now, i'm trying to enumerate devices from upower.
after the call, i get a nice answer.
| Code: |
QDBusInterface PropertyConnection ( "org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower", QDBusConnection::systemBus(), this );
QDBusMessage Reply;
Reply = PropertyConnection.call ( "EnumerateDevices" );
if (Reply.type() == QDBusMessage::ErrorMessage)
{
qDebug() << "DBus error" << Reply.errorMessage();
return;
}
else if (Reply.type() != QDBusMessage::ReplyMessage)
{
qDebug() << "Wrong message type from dbus" << Reply.type();
return;
}
qDebug() << "Reply" << endl;
qDebug() << Reply;
|
which gives me
| Code: |
Reply
QDBusMessage(type=MethodReturn, service=":1.29", signature="ao", contents=([Argument: ao {[ObjectPath: /org/freedesktop/UPower/devices/line_power_ACAD], [ObjectPath: /org/freedesktop/UPower/devices/battery_BAT0]}]) )
|
Looks good so far.
But i seem to be unable to extract the two object paths from there.
Reply.arguments().count() returns 1. So I guess it's a single argument, consisting of a qlist of qdbusobjectpath???
Nevertheless, if I do this
| Code: |
qDebug() << "Variant" << endl;
QVariant messageVariant = Reply.arguments().takeFirst();
qDebug() << messageVariant;
qDebug() << "DBusVariant" << endl;
QDBusVariant dbusvariant = qvariant_cast <QDBusVariant> (Reply.arguments().takeFirst());
qDebug() << dbusvariant.variant(); |
I already get nothing in return. So I guess i'm taking the wrong route here.
How can i access those Object Paths?
Thanks. _________________ pc-rhiakath ~ $ emerge -s happiness
Searching..
[ Results for search key : happiness ]
[ Applications found : 0 ]
-------------------------------------------
I see dead pixels... |
|