summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <[email protected]>2018-10-05 17:54:47 +0200
committerAleix Pol <[email protected]>2018-10-05 17:55:54 +0200
commita2a9d9e19b82d2e54af6dd510f4977e2aa90ebbf (patch)
tree42d8dbe294dc46607a4b7133143b8ea3a2f8fb19
parent68cb2ea3f645044c6b83e7a4f2b938fc2686250c (diff)
pk: Make it possible to enable offline updates beyond the env var
Adds a setting that can be defined on kdeglobals such as: ``` [Software] UseOfflineUpdates=true ``` BUG: 399369
-rw-r--r--libdiscover/backends/PackageKitBackend/PackageKitUpdater.cpp20
-rw-r--r--libdiscover/backends/PackageKitBackend/PackageKitUpdater.h3
2 files changed, 21 insertions, 2 deletions
diff --git a/libdiscover/backends/PackageKitBackend/PackageKitUpdater.cpp b/libdiscover/backends/PackageKitBackend/PackageKitUpdater.cpp
index 3d68f2d..cac97f9 100644
--- a/libdiscover/backends/PackageKitBackend/PackageKitUpdater.cpp
+++ b/libdiscover/backends/PackageKitBackend/PackageKitUpdater.cpp
@@ -28,6 +28,8 @@
#include <QAction>
#include <QSet>
+#include <KSharedConfig>
+#include <KConfigGroup>
#include <KLocalizedString>
int percentageWithStatus(PackageKit::Transaction::Status status, uint percentage)
@@ -151,13 +153,27 @@ void PackageKitUpdater::proceed()
if (!m_proceedFunctions.isEmpty())
processProceedFunction();
#ifdef PKQT_1_0
- else if (qEnvironmentVariableIsSet("PK_OFFLINE_UPDATE"))
+ else if (useOfflineUpdates())
setupTransaction(PackageKit::Transaction::TransactionFlagOnlyTrusted | PackageKit::Transaction::TransactionFlagOnlyDownload);
#endif
else
setupTransaction(PackageKit::Transaction::TransactionFlagOnlyTrusted);
}
+bool PackageKitUpdater::useOfflineUpdates() const
+{
+ if (qEnvironmentVariableIsSet("PK_OFFLINE_UPDATE"))
+ return true;
+ KConfigGroup group(KSharedConfig::openConfig(), "Software");
+ return group.readEntry<bool>("UseOfflineUpdates", false);
+}
+
+void PackageKitUpdater::setUseOfflineUpdates(bool use)
+{
+ KConfigGroup group(KSharedConfig::openConfig(), "Software");
+ group.writeEntry<bool>("UseOfflineUpdates", use);
+}
+
void PackageKitUpdater::start()
{
Q_ASSERT(!isProgressing());
@@ -195,7 +211,7 @@ void PackageKitUpdater::finished(PackageKit::Transaction::Exit exit, uint /*time
m_backend->fetchUpdates();
fetchLastUpdateTime();
- if (qEnvironmentVariableIsSet("PK_OFFLINE_UPDATE")) {
+ if (useOfflineUpdates()) {
#ifdef PKQT_1_0
PackageKit::Daemon::global()->offline()->trigger(PackageKit::Offline::ActionReboot);
Q_EMIT passiveMessage(i18n("Please restart the computer to finish the installation"));
diff --git a/libdiscover/backends/PackageKitBackend/PackageKitUpdater.h b/libdiscover/backends/PackageKitBackend/PackageKitUpdater.h
index 179a3d7..213da70 100644
--- a/libdiscover/backends/PackageKitBackend/PackageKitUpdater.h
+++ b/libdiscover/backends/PackageKitBackend/PackageKitUpdater.h
@@ -83,6 +83,9 @@ class PackageKitUpdater : public AbstractBackendUpdater
void fetchLastUpdateTime();
void lastUpdateTimeReceived(QDBusPendingCallWatcher* w);
void setupTransaction(PackageKit::Transaction::TransactionFlags flags);
+ bool useOfflineUpdates() const;
+ void setUseOfflineUpdates(bool use);
+
QSet<QString> involvedPackages(const QSet<AbstractResource*>& packages) const;
QSet<AbstractResource*> packagesForPackageId(const QSet<QString>& packages) const;