Blob Blame History Raw
diff --git a/solid/solid/backends/upower/upowerdevice.cpp b/solid/solid/backends/upower/upowerdevice.cpp
index 94f59bf..7c70a31 100644
--- a/solid/solid/backends/upower/upowerdevice.cpp
+++ b/solid/solid/backends/upower/upowerdevice.cpp
@@ -1,6 +1,6 @@
 /*
     Copyright 2010 Michael Zanetti <mzanetti@kde.org>
-    Copyright 2010 Lukas Tinkl <ltinkl@redhat.com>
+    Copyright 2010-2015 Lukas Tinkl <ltinkl@redhat.com>
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public
@@ -32,6 +32,7 @@
 #include <QtCore/QStringList>
 #include <QtCore/QDebug>
 #include <QtDBus/QDBusPendingReply>
+#include <QtDBus/QDBusReply>
 
 using namespace Solid::Backends::UPower;
 
@@ -44,11 +45,16 @@ UPowerDevice::UPowerDevice(const QString &udi)
     , m_udi(udi)
 {
     if (m_device.isValid()) {
-        connect(&m_device, SIGNAL(Changed()), this, SLOT(slotChanged()));
+        if (m_device.metaObject()->indexOfSignal("Changed()") != -1) {
+            connect(&m_device, SIGNAL(Changed()), this, SLOT(slotChanged()));
+        } else {
+            // for UPower >= 0.99.0, missing Changed() signal
+            QDBusConnection::systemBus().connect(UP_DBUS_SERVICE, m_udi, "org.freedesktop.DBus.Properties", "PropertiesChanged", this,
+                                                 SLOT(onPropertiesChanged(QString,QVariantMap,QStringList)));
+        }
 
-         // for UPower >= 0.99.0, missing Changed() signal
-        QDBusConnection::systemBus().connect(UP_DBUS_SERVICE, m_udi, "org.freedesktop.DBus.Properties", "PropertiesChanged", this,
-                                             SLOT(onPropertiesChanged(QString,QVariantMap,QStringList)));
+        QDBusConnection::systemBus().connect("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "PrepareForSleep",
+                                             this, SLOT(login1Resuming(bool)));
     }
 }
 
@@ -238,3 +244,13 @@ void UPowerDevice::slotChanged()
     m_cache.clear();
     emit changed();
 }
+
+void UPowerDevice::login1Resuming(bool active)
+{
+    if (!active) {
+        QDBusReply<void> refreshCall = m_device.asyncCall("Refresh");
+        if (refreshCall.isValid()) {
+            slotChanged();
+        }
+    }
+}
diff --git a/solid/solid/backends/upower/upowerdevice.h b/solid/solid/backends/upower/upowerdevice.h
index 805b9b2..7694d05 100644
--- a/solid/solid/backends/upower/upowerdevice.h
+++ b/solid/solid/backends/upower/upowerdevice.h
@@ -64,6 +64,7 @@ Q_SIGNALS:
 private Q_SLOTS:
     void onPropertiesChanged(const QString &ifaceName, const QVariantMap &changedProps, const QStringList &invalidatedProps);
     void slotChanged();
+    void login1Resuming(bool active);
 
 private:
     QString batteryTechnology() const;