Changeset View
Changeset View
Standalone View
Standalone View
libdiscover/backends/PackageKitBackend/PackageKitNotifier.cpp
Show All 32 Lines | |||||
33 | #include <QDBusInterface> | 33 | #include <QDBusInterface> | ||
34 | #include <QFile> | 34 | #include <QFile> | ||
35 | #include <QFileSystemWatcher> | 35 | #include <QFileSystemWatcher> | ||
36 | #include <KLocalizedString> | 36 | #include <KLocalizedString> | ||
37 | #include <KDesktopFile> | 37 | #include <KDesktopFile> | ||
38 | #include <KConfigGroup> | 38 | #include <KConfigGroup> | ||
39 | 39 | | |||
40 | #include "pk-offline-private.h" | 40 | #include "pk-offline-private.h" | ||
41 | #include "libdiscover_backend_debug.h" | ||||
41 | 42 | | |||
42 | PackageKitNotifier::PackageKitNotifier(QObject* parent) | 43 | PackageKitNotifier::PackageKitNotifier(QObject* parent) | ||
43 | : BackendNotifierModule(parent) | 44 | : BackendNotifierModule(parent) | ||
44 | , m_securityUpdates(0) | 45 | , m_securityUpdates(0) | ||
45 | , m_normalUpdates(0) | 46 | , m_normalUpdates(0) | ||
46 | { | 47 | { | ||
47 | connect(PackageKit::Daemon::global(), &PackageKit::Daemon::updatesChanged, this, &PackageKitNotifier::recheckSystemUpdateNeeded); | 48 | connect(PackageKit::Daemon::global(), &PackageKit::Daemon::updatesChanged, this, &PackageKitNotifier::recheckSystemUpdateNeeded); | ||
48 | connect(PackageKit::Daemon::global(), &PackageKit::Daemon::transactionListChanged, this, &PackageKitNotifier::transactionListChanged); | 49 | connect(PackageKit::Daemon::global(), &PackageKit::Daemon::transactionListChanged, this, &PackageKitNotifier::transactionListChanged); | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
99 | { | 100 | { | ||
100 | } | 101 | } | ||
101 | 102 | | |||
102 | void PackageKitNotifier::checkOfflineUpdates() | 103 | void PackageKitNotifier::checkOfflineUpdates() | ||
103 | { | 104 | { | ||
104 | if (!QFile::exists(QStringLiteral(PK_OFFLINE_RESULTS_FILENAME))) { | 105 | if (!QFile::exists(QStringLiteral(PK_OFFLINE_RESULTS_FILENAME))) { | ||
105 | return; | 106 | return; | ||
106 | } | 107 | } | ||
107 | qDebug() << "found offline update results at " << PK_OFFLINE_RESULTS_FILENAME; | 108 | qCDebug(LIBDISCOVER_BACKEND_LOG) << "found offline update results at " << PK_OFFLINE_RESULTS_FILENAME; | ||
108 | 109 | | |||
109 | KDesktopFile file(QStringLiteral(PK_OFFLINE_RESULTS_FILENAME)); | 110 | KDesktopFile file(QStringLiteral(PK_OFFLINE_RESULTS_FILENAME)); | ||
110 | KConfigGroup group(&file, PK_OFFLINE_RESULTS_GROUP); | 111 | KConfigGroup group(&file, PK_OFFLINE_RESULTS_GROUP); | ||
111 | 112 | | |||
112 | const bool success = group.readEntry("Success", false); | 113 | const bool success = group.readEntry("Success", false); | ||
113 | const QString packagesJoined = group.readEntry("Packages"); | 114 | const QString packagesJoined = group.readEntry("Packages"); | ||
114 | const auto packages = packagesJoined.splitRef(QLatin1Char(',')); | 115 | const auto packages = packagesJoined.splitRef(QLatin1Char(',')); | ||
115 | if (!success) { | 116 | if (!success) { | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
168 | { | 169 | { | ||
169 | if (PackageKit::Daemon::global()->isRunning()) { | 170 | if (PackageKit::Daemon::global()->isRunning()) { | ||
170 | PackageKit::Daemon::getUpdates(); | 171 | PackageKit::Daemon::getUpdates(); | ||
171 | } | 172 | } | ||
172 | } | 173 | } | ||
173 | 174 | | |||
174 | void PackageKitNotifier::setupGetUpdatesTransaction(PackageKit::Transaction* trans) | 175 | void PackageKitNotifier::setupGetUpdatesTransaction(PackageKit::Transaction* trans) | ||
175 | { | 176 | { | ||
176 | qDebug() << "using..." << trans << trans->tid().path(); | 177 | qCDebug(LIBDISCOVER_BACKEND_LOG) << "using..." << trans << trans->tid().path(); | ||
177 | 178 | | |||
178 | trans->setProperty("normalUpdates", 0); | 179 | trans->setProperty("normalUpdates", 0); | ||
179 | trans->setProperty("securityUpdates", 0); | 180 | trans->setProperty("securityUpdates", 0); | ||
180 | connect(trans, &PackageKit::Transaction::package, this, &PackageKitNotifier::package); | 181 | connect(trans, &PackageKit::Transaction::package, this, &PackageKitNotifier::package); | ||
181 | connect(trans, &PackageKit::Transaction::finished, this, &PackageKitNotifier::finished); | 182 | connect(trans, &PackageKit::Transaction::finished, this, &PackageKitNotifier::finished); | ||
182 | } | 183 | } | ||
183 | 184 | | |||
184 | void PackageKitNotifier::package(PackageKit::Transaction::Info info, const QString &/*packageID*/, const QString &/*summary*/) | 185 | void PackageKitNotifier::package(PackageKit::Transaction::Info info, const QString &/*packageID*/, const QString &/*summary*/) | ||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | 308 | if (!m_needsReboot) { | |||
309 | Q_EMIT needsRebootChanged(); | 310 | Q_EMIT needsRebootChanged(); | ||
310 | } | 311 | } | ||
311 | } | 312 | } | ||
312 | 313 | | |||
313 | void PackageKitNotifier::onRequireRestart(PackageKit::Transaction::Restart type, const QString &packageID) | 314 | void PackageKitNotifier::onRequireRestart(PackageKit::Transaction::Restart type, const QString &packageID) | ||
314 | { | 315 | { | ||
315 | PackageKit::Transaction* t = qobject_cast<PackageKit::Transaction*>(sender()); | 316 | PackageKit::Transaction* t = qobject_cast<PackageKit::Transaction*>(sender()); | ||
316 | t->setProperty("requireRestart", qMax<int>(t->property("requireRestart").toInt(), type)); | 317 | t->setProperty("requireRestart", qMax<int>(t->property("requireRestart").toInt(), type)); | ||
317 | qDebug() << "RESTART" << type << "is required for package" << packageID; | 318 | qCDebug(LIBDISCOVER_BACKEND_LOG) << "RESTART" << type << "is required for package" << packageID; | ||
318 | } | 319 | } |