Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Retrieving upower devices with qtdbus
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Rhiakath
Guru
Guru


Joined: 10 Feb 2006
Posts: 569
Location: Hell...

PostPosted: Tue May 01, 2012 9:03 am    Post subject: Retrieving upower devices with qtdbus Reply with quote

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...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum