File change-refresh-logic.patch of Package plasma5-pk-updates

From 06e21dffef7286d79718bdf49590aa8d90c24991 Mon Sep 17 00:00:00 2001
From: Raymond Wooninck <tittiatcoke@gmail.com>
Date: Thu, 11 Feb 2016 10:15:41 +0100
Subject: change the refresh logic and avoid unnecessary calls to the
 PackageKit Daemon


diff -urB plasma-pk-updates-0.2/src/declarative/pkupdates.cpp new/src/declarative/pkupdates.cpp
--- plasma-pk-updates-0.2/src/declarative/pkupdates.cpp	2015-04-06 20:52:42.000000000 +0200
+++ new/src/declarative/pkupdates.cpp	2016-02-11 15:49:38.001607501 +0100
@@ -189,19 +189,20 @@
     return i18n("Last updated: never");
 }
 
-void PkUpdates::checkUpdates(bool force)
+void PkUpdates::checkUpdates()
 {
-    qDebug() << "Checking updates, forced:" << force;
+    qDebug() << "Checking updates, forced";
 
-    if (force) { // save the timestamp
-        KConfigGroup grp(KSharedConfig::openConfig("plasma-pk-updates"), "General");
-        grp.writeEntry("Timestamp", QDateTime::currentDateTime().toMSecsSinceEpoch());
-        grp.sync();
-    }
+    // save the timestamp
+    KConfigGroup grp(KSharedConfig::openConfig("plasma-pk-updates"), "General");
+    grp.writeEntry("Timestamp", QDateTime::currentDateTime().toMSecsSinceEpoch());
+    grp.sync();
 
-    m_cacheTrans = PackageKit::Daemon::refreshCache(force);
+    // ask the PackageKit daemon to refresh the cache
+    m_cacheTrans = PackageKit::Daemon::refreshCache(true);
     setActivity(CheckingUpdates);
 
+    // evaluate the result
     connect(m_cacheTrans.data(), &PackageKit::Transaction::statusChanged, this, &PkUpdates::onStatusChanged);
     connect(m_cacheTrans.data(), &PackageKit::Transaction::finished, this, &PkUpdates::onFinished);
     connect(m_cacheTrans.data(), &PackageKit::Transaction::errorCode, this, &PkUpdates::onErrorCode);
diff -urB plasma-pk-updates-0.2/src/declarative/pkupdates.h new/src/declarative/pkupdates.h
--- plasma-pk-updates-0.2/src/declarative/pkupdates.h	2015-04-06 20:52:42.000000000 +0200
+++ new/src/declarative/pkupdates.h	2016-02-11 15:47:59.129045166 +0100
@@ -162,7 +162,7 @@
       *
       * @param force whether to force the cache refresh
       */
-    Q_INVOKABLE void checkUpdates(bool force = false);
+    Q_INVOKABLE void checkUpdates();
 
     /**
       * Launch the update process
diff -urB plasma-pk-updates-0.2/src/plasma/contents/ui/Full.qml new/src/plasma/contents/ui/Full.qml
--- plasma-pk-updates-0.2/src/plasma/contents/ui/Full.qml	2015-04-06 20:52:42.000000000 +0200
+++ new/src/plasma/contents/ui/Full.qml	2016-02-11 15:47:59.129045166 +0100
@@ -170,7 +170,7 @@
             }
             text: i18n("Check For Updates")
             tooltip: i18n("Checks for any available updates")
-            onClicked: PkUpdates.checkUpdates(true) // circumvent the checks, the user knows what they're doing ;)
+            onClicked: PkUpdates.checkUpdates() // circumvent the checks, the user knows what they're doing ;)
         }
 
         Button {
diff -urB plasma-pk-updates-0.2/src/plasma/contents/ui/main.qml new/src/plasma/contents/ui/main.qml
--- plasma-pk-updates-0.2/src/plasma/contents/ui/main.qml	2015-04-06 20:52:42.000000000 +0200
+++ new/src/plasma/contents/ui/main.qml	2016-02-11 15:47:59.129045166 +0100
@@ -50,8 +50,8 @@
         triggeredOnStart: true
         interval: 1000 * 60 * 60; // 1 hour
         onTriggered: {
-            if (networkAllowed() && batteryAllowed())
-                PkUpdates.checkUpdates(needsForcedUpdate())
+            if (needsForcedUpdate() && networkAllowed() && batteryAllowed())
+                PkUpdates.checkUpdates()
         }
     }
 
openSUSE Build Service is sponsored by