Changeset View
Changeset View
Standalone View
Standalone View
libdiscover/backends/PackageKitBackend/PackageKitBackend.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
49 | #include <PackageKit/Offline> | 49 | #include <PackageKit/Offline> | ||
50 | #include <PackageKit/Details> | 50 | #include <PackageKit/Details> | ||
51 | 51 | | |||
52 | #include <KLocalizedString> | 52 | #include <KLocalizedString> | ||
53 | #include <KProtocolManager> | 53 | #include <KProtocolManager> | ||
54 | 54 | | |||
55 | #include "utils.h" | 55 | #include "utils.h" | ||
56 | #include "config-paths.h" | 56 | #include "config-paths.h" | ||
57 | #include "libdiscover_backend_debug.h" | ||||
57 | 58 | | |||
58 | DISCOVER_BACKEND_PLUGIN(PackageKitBackend) | 59 | DISCOVER_BACKEND_PLUGIN(PackageKitBackend) | ||
59 | 60 | | |||
60 | template <typename T, typename W> | 61 | template <typename T, typename W> | ||
61 | static void setWhenAvailable(const QDBusPendingReply<T>& pending, W func, QObject* parent) | 62 | static void setWhenAvailable(const QDBusPendingReply<T>& pending, W func, QObject* parent) | ||
62 | { | 63 | { | ||
63 | QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(pending, parent); | 64 | QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(pending, parent); | ||
64 | QObject::connect(watcher, &QDBusPendingCallWatcher::finished, | 65 | QObject::connect(watcher, &QDBusPendingCallWatcher::finished, | ||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Line(s) | 200 | if (status == PackageKit::Transaction::ExitSuccess && !pkgidVal.isNull()) { | |||
203 | res->addPackageId(PackageKit::Transaction::InfoInstalled, pkgid, true); | 204 | res->addPackageId(PackageKit::Transaction::InfoInstalled, pkgid, true); | ||
204 | } | 205 | } | ||
205 | acquireFetching(false); | 206 | acquireFetching(false); | ||
206 | }); | 207 | }); | ||
207 | continue; | 208 | continue; | ||
208 | } | 209 | } | ||
209 | } | 210 | } | ||
210 | 211 | | |||
211 | qDebug() << "no packages for" << component.id(); | 212 | qCDebug(LIBDISCOVER_BACKEND_LOG) << "no packages for" << component.id(); | ||
212 | continue; | 213 | continue; | ||
213 | } | 214 | } | ||
214 | neededPackages += pkgNames; | 215 | neededPackages += pkgNames; | ||
215 | 216 | | |||
216 | addComponent(component, pkgNames); | 217 | addComponent(component, pkgNames); | ||
217 | } | 218 | } | ||
218 | 219 | | |||
219 | acquireFetching(false); | 220 | acquireFetching(false); | ||
220 | if (!neededPackages.isEmpty()) { | 221 | if (!neededPackages.isEmpty()) { | ||
221 | neededPackages.removeDuplicates(); | 222 | neededPackages.removeDuplicates(); | ||
222 | resolvePackages(neededPackages); | 223 | resolvePackages(neededPackages); | ||
223 | } else { | 224 | } else { | ||
224 | qDebug() << "empty appstream db"; | 225 | qCDebug(LIBDISCOVER_BACKEND_LOG) << "empty appstream db"; | ||
225 | if (PackageKit::Daemon::backendName() == QLatin1String("aptcc") || PackageKit::Daemon::backendName().isEmpty()) { | 226 | if (PackageKit::Daemon::backendName() == QLatin1String("aptcc") || PackageKit::Daemon::backendName().isEmpty()) { | ||
226 | checkForUpdates(); | 227 | checkForUpdates(); | ||
227 | } | 228 | } | ||
228 | } | 229 | } | ||
229 | } | 230 | } | ||
230 | 231 | | |||
231 | AppPackageKitResource* PackageKitBackend::addComponent(const AppStream::Component& component, const QStringList& pkgNames) | 232 | AppPackageKitResource* PackageKitBackend::addComponent(const AppStream::Component& component, const QStringList& pkgNames) | ||
232 | { | 233 | { | ||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Line(s) | 385 | for(const QString &name : pkgnames) { | |||
390 | } | 391 | } | ||
391 | } | 392 | } | ||
392 | return ret; | 393 | return ret; | ||
393 | } | 394 | } | ||
394 | 395 | | |||
395 | void PackageKitBackend::checkForUpdates() | 396 | void PackageKitBackend::checkForUpdates() | ||
396 | { | 397 | { | ||
397 | if (PackageKit::Daemon::global()->offline()->updateTriggered()) { | 398 | if (PackageKit::Daemon::global()->offline()->updateTriggered()) { | ||
398 | qDebug() << "Won't be checking for updates again, the system needs a reboot to apply the fetched offline updates."; | 399 | qCDebug(LIBDISCOVER_BACKEND_LOG) << "Won't be checking for updates again, the system needs a reboot to apply the fetched offline updates."; | ||
399 | return; | 400 | return; | ||
400 | } | 401 | } | ||
401 | 402 | | |||
402 | if (!m_refresher) { | 403 | if (!m_refresher) { | ||
403 | acquireFetching(true); | 404 | acquireFetching(true); | ||
404 | m_refresher = PackageKit::Daemon::refreshCache(false); | 405 | m_refresher = PackageKit::Daemon::refreshCache(false); | ||
405 | 406 | | |||
406 | connect(m_refresher.data(), &PackageKit::Transaction::errorCode, this, &PackageKitBackend::transactionError); | 407 | connect(m_refresher.data(), &PackageKit::Transaction::errorCode, this, &PackageKitBackend::transactionError); | ||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | 492 | for (auto it = m_packages.packages.constBegin(), itEnd = m_packages.packages.constEnd(); it != itEnd; ++it) { | |||
492 | if (it.key().compare(appstreamId, Qt::CaseInsensitive) == 0 | 493 | if (it.key().compare(appstreamId, Qt::CaseInsensitive) == 0 | ||
493 | || it.key().compare(deprecatedHost, Qt::CaseInsensitive) == 0 | 494 | || it.key().compare(deprecatedHost, Qt::CaseInsensitive) == 0 | ||
494 | || (appstreamId.endsWith(QLatin1String(".desktop")) && appstreamId.compare(it.key()+QLatin1String(".desktop"), Qt::CaseInsensitive) == 0)) { | 495 | || (appstreamId.endsWith(QLatin1String(".desktop")) && appstreamId.compare(it.key()+QLatin1String(".desktop"), Qt::CaseInsensitive) == 0)) { | ||
495 | pkg = it.value(); | 496 | pkg = it.value(); | ||
496 | break; | 497 | break; | ||
497 | } | 498 | } | ||
498 | } | 499 | } | ||
499 | // if (!pkg) | 500 | // if (!pkg) | ||
500 | // qDebug() << "could not find" << host << deprecatedHost; | 501 | // qCDebug(LIBDISCOVER_BACKEND_LOG) << "could not find" << host << deprecatedHost; | ||
501 | } | 502 | } | ||
502 | } | 503 | } | ||
503 | return new ResultsStream(QStringLiteral("PackageKitStream-url"), pkg ? QVector<AbstractResource*>{pkg} : QVector<AbstractResource*>{}); | 504 | return new ResultsStream(QStringLiteral("PackageKitStream-url"), pkg ? QVector<AbstractResource*>{pkg} : QVector<AbstractResource*>{}); | ||
504 | } | 505 | } | ||
505 | 506 | | |||
506 | bool PackageKitBackend::hasSecurityUpdates() const | 507 | bool PackageKitBackend::hasSecurityUpdates() const | ||
507 | { | 508 | { | ||
508 | return m_hasSecurityUpdates; | 509 | return m_hasSecurityUpdates; | ||
▲ Show 20 Lines • Show All 179 Lines • Show Last 20 Lines |