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

Require an update when the offline-update-action is enabled

Upon /var/lib/PackageKit/offline-update-action modification

CCMAIL: sitter@kde.org
parent 2f80d7ce
......@@ -31,6 +31,7 @@
#include <PackageKit/Daemon>
#include <QDBusInterface>
#include <QFile>
#include <QFileSystemWatcher>
#include <KLocalizedString>
#include <KDesktopFile>
#include <KConfigGroup>
......@@ -77,6 +78,10 @@ PackageKitNotifier::PackageKitNotifier(QObject* parent)
m_recheckTimer->setInterval(200);
m_recheckTimer->setSingleShot(true);
connect(m_recheckTimer, &QTimer::timeout, this, &PackageKitNotifier::recheckSystemUpdate);
QFileSystemWatcher* watcher = new QFileSystemWatcher(this);
watcher->addPath(QStringLiteral(PK_OFFLINE_ACTION_FILENAME));
connect(watcher, &QFileSystemWatcher::fileChanged, this, &PackageKitNotifier::nowNeedsReboot);
}
PackageKitNotifier::~PackageKitNotifier()
......@@ -276,8 +281,7 @@ void PackageKitNotifier::transactionListChanged(const QStringList& tids)
if (!restart.isNull()) {
auto restartEvent = PackageKit::Transaction::Restart(restart.toInt());
if (restartEvent >= PackageKit::Transaction::RestartSession) {
m_needsReboot = true;
Q_EMIT needsRebootChanged();
nowNeedsReboot();
}
}
m_transactions.remove(t->tid().path());
......@@ -287,6 +291,14 @@ void PackageKitNotifier::transactionListChanged(const QStringList& tids)
}
}
void PackageKitNotifier::nowNeedsReboot()
{
if (!m_needsReboot) {
m_needsReboot = true;
Q_EMIT needsRebootChanged();
}
}
void PackageKitNotifier::onRequireRestart(PackageKit::Transaction::Restart type, const QString &packageID)
{
PackageKit::Transaction* t = qobject_cast<PackageKit::Transaction*>(sender());
......
......@@ -52,9 +52,9 @@ private Q_SLOTS:
void onDistroUpgrade(PackageKit::Transaction::DistroUpgrade type, const QString &name, const QString &description);
private:
void nowNeedsReboot();
void recheckSystemUpdate();
void checkOfflineUpdates();
void requireRestartNotification(PackageKit::Transaction::Restart type);
void setupGetUpdatesTransaction(PackageKit::Transaction* transaction);
QProcess* checkAptVariable(const QString &aptconfig, const QLatin1String& varname, std::function<void(const QStringRef& val)> func);
......
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