I'm trying to get a property value from the dbus. I'm getting no error, but I'm also not getting the right value. In other words, the value returned is not the same value as returned by qdbus. Here is my code:
const QString service = "org.freedesktop.UPower";
const QString path = "/org/freedesktop/UPower/devices/line_power_ADP1";
const QString interface = "org.freedesktop.UPower.Device";
const QString property = "Online";
QDBusConnection bus = QDBusConnection::systemBus();
QList<QVariant> args;
args.append(QVariant(interface));
args.append(QVariant(property));
QDBusMessage mesg = QDBusMessage::createMethodCall(service, path, "org.freedesktop.DBus.Properties", "Get");
mesg.setArguments(args);
QDBusMessage ret = bus.call(mesg);
if (ret.type() == QDBusMessage::ErrorMessage)
{
qDebug() << "Error getting property value. " << ret.errorName() << ": " << ret.errorMessage();
}
bool value = ret.arguments()[0].value<bool>(); //incorrect value!
As far as I can tell, this should get the "Online" property corresponding to the path "/org/freedesktop/UPower/devices/line_power_ADP1" of the service "org.freedesktop.UPower" on the system bus. But in reality, all it's getting is junk -- no error, only junk.