Commit 51181d4c authored by Lukáš Tinkl's avatar Lukáš Tinkl

simplify and fix the AcPluggedJob

parent 094908f6
......@@ -26,8 +26,8 @@
#include <QDBusMessage>
#include <QDBusPendingCall>
#include <QDBusPendingReply>
#include <QDBusInterface>
using namespace Solid;
FDAcPluggedJob::FDAcPluggedJob(QObject* parent)
......@@ -44,19 +44,17 @@ void FDAcPluggedJob::doStart()
QStringLiteral("org.freedesktop.DBus.Properties"),
QStringLiteral("Get"));
QList<QVariant> args;
args << QStringLiteral("org.freedesktop.UPower")
<< QStringLiteral("OnBattery");
msg.setArguments(args);
msg << QStringLiteral("org.freedesktop.UPower");
msg << QStringLiteral("OnBattery");
QDBusConnection::systemBus().callWithCallback(msg, this, SLOT(slotDBusReply(QVariant)), SLOT(slotDBusError(QDBusError)));
QDBusConnection::systemBus().callWithCallback(msg, this, SLOT(slotDBusReply(QDBusMessage)), SLOT(slotDBusError(QDBusError)));
}
void FDAcPluggedJob::slotDBusReply(const QVariant & reply)
void FDAcPluggedJob::slotDBusReply(const QDBusMessage & msg)
{
Q_ASSERT(reply.isValid());
Q_ASSERT(!msg.arguments().isEmpty());
m_isPlugged = !reply.toBool();
m_isPlugged = !msg.arguments().first().value<QDBusVariant>().variant().toBool();
emitResult();
}
......
......@@ -38,7 +38,7 @@ public:
private Q_SLOTS:
virtual void doStart() Q_DECL_OVERRIDE;
void slotDBusReply(const QVariant &reply);
void slotDBusReply(const QDBusMessage &msg);
void slotDBusError(const QDBusError &error);
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment