Commit a2a9d9e1 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

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
parent 68cb2ea3
......@@ -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"));
......
......@@ -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;
......
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