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

simplify and fix the AcPluggedJob

parent 094908f6
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
#include <QDBusMessage> #include <QDBusMessage>
#include <QDBusPendingCall> #include <QDBusPendingCall>
#include <QDBusPendingReply> #include <QDBusPendingReply>
#include <QDBusInterface> #include <QDBusInterface>
using namespace Solid; using namespace Solid;
FDAcPluggedJob::FDAcPluggedJob(QObject* parent) FDAcPluggedJob::FDAcPluggedJob(QObject* parent)
...@@ -44,19 +44,17 @@ void FDAcPluggedJob::doStart() ...@@ -44,19 +44,17 @@ void FDAcPluggedJob::doStart()
QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("org.freedesktop.DBus.Properties"),
QStringLiteral("Get")); QStringLiteral("Get"));
QList<QVariant> args; msg << QStringLiteral("org.freedesktop.UPower");
args << QStringLiteral("org.freedesktop.UPower") msg << QStringLiteral("OnBattery");
<< QStringLiteral("OnBattery");
msg.setArguments(args);
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(); emitResult();
} }
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
private Q_SLOTS: private Q_SLOTS:
virtual void doStart() Q_DECL_OVERRIDE; virtual void doStart() Q_DECL_OVERRIDE;
void slotDBusReply(const QVariant &reply); void slotDBusReply(const QDBusMessage &msg);
void slotDBusError(const QDBusError &error); void slotDBusError(const QDBusError &error);
private: 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