Blame SOURCES/solid-upower-0.99.patch

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