Commit 51bcad41 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Merge remote-tracking branch 'origin/Plasma/5.13'

parents dee02d69 92e65b13
...@@ -748,6 +748,11 @@ void FlatpakBackend::loadRemoteUpdates(FlatpakInstallation* installation) ...@@ -748,6 +748,11 @@ void FlatpakBackend::loadRemoteUpdates(FlatpakInstallation* installation)
void FlatpakBackend::onFetchUpdatesFinished(FlatpakInstallation *flatpakInstallation, GPtrArray *updates) void FlatpakBackend::onFetchUpdatesFinished(FlatpakInstallation *flatpakInstallation, GPtrArray *updates)
{ {
if (!updates) {
qWarning() << "could not get updates for" << flatpakInstallation;
return;
}
g_autoptr(GPtrArray) fetchedUpdates = updates; g_autoptr(GPtrArray) fetchedUpdates = updates;
for (uint i = 0; i < fetchedUpdates->len; i++) { for (uint i = 0; i < fetchedUpdates->len; i++) {
......
...@@ -72,6 +72,7 @@ QString PackageKitBackend::locateService(const QString &filename) ...@@ -72,6 +72,7 @@ QString PackageKitBackend::locateService(const QString &filename)
PackageKitBackend::PackageKitBackend(QObject* parent) PackageKitBackend::PackageKitBackend(QObject* parent)
: AbstractResourcesBackend(parent) : AbstractResourcesBackend(parent)
, m_appdata(new AppStream::Pool)
, m_updater(new PackageKitUpdater(this)) , m_updater(new PackageKitUpdater(this))
, m_refresher(nullptr) , m_refresher(nullptr)
, m_isFetching(0) , m_isFetching(0)
...@@ -93,20 +94,9 @@ PackageKitBackend::PackageKitBackend(QObject* parent) ...@@ -93,20 +94,9 @@ PackageKitBackend::PackageKitBackend(QObject* parent)
SourcesModel::global()->addSourcesBackend(new PackageKitSourcesBackend(this)); SourcesModel::global()->addSourcesBackend(new PackageKitSourcesBackend(this));
QString error;
const bool b = m_appdata.load(&error);
reloadPackageList(); reloadPackageList();
if (!b && m_packages.packages.isEmpty()) { setWhenAvailable(PackageKit::Daemon::getTimeSinceAction(PackageKit::Transaction::RoleRefreshCache), [this](uint timeSince) {
qWarning() << "Could not open the AppStream metadata pool" << error;
QTimer::singleShot(0, this, [this]() {
Q_EMIT passiveMessage(i18n("Please make sure that Appstream is properly set up on your system"));
});
}
setWhenAvailable(PackageKit::Daemon::getTimeSinceAction(PackageKit::Transaction::RoleRefreshCache), [this, error](uint timeSince) {
if (timeSince > 3600) if (timeSince > 3600)
checkForUpdates(); checkForUpdates();
}, this); }, this);
...@@ -139,7 +129,18 @@ void PackageKitBackend::reloadPackageList() ...@@ -139,7 +129,18 @@ void PackageKitBackend::reloadPackageList()
disconnect(m_refresher.data(), &PackageKit::Transaction::finished, this, &PackageKitBackend::reloadPackageList); disconnect(m_refresher.data(), &PackageKit::Transaction::finished, this, &PackageKitBackend::reloadPackageList);
} }
const auto components = m_appdata.components(); QString error;
m_appdata.reset(new AppStream::Pool);
const bool b = m_appdata->load(&error);
if (!b && m_packages.packages.isEmpty()) {
qWarning() << "Could not open the AppStream metadata pool" << error;
QTimer::singleShot(0, this, [this]() {
Q_EMIT passiveMessage(i18n("Please make sure that Appstream is properly set up on your system"));
});
}
const auto components = m_appdata->components();
QStringList neededPackages; QStringList neededPackages;
neededPackages.reserve(components.size()); neededPackages.reserve(components.size());
foreach(const AppStream::Component& component, components) { foreach(const AppStream::Component& component, components) {
...@@ -148,8 +149,9 @@ void PackageKitBackend::reloadPackageList() ...@@ -148,8 +149,9 @@ void PackageKitBackend::reloadPackageList()
const auto pkgNames = component.packageNames(); const auto pkgNames = component.packageNames();
if (pkgNames.isEmpty()) { if (pkgNames.isEmpty()) {
if (component.kind() == AppStream::Component::KindDesktopApp) { auto launchable = component.launchable(AppStream::Launchable::KindDesktopId);
const QString file = locateService(component.desktopId()); if (component.kind() == AppStream::Component::KindDesktopApp && !launchable.entries().isEmpty()) {
const QString file = locateService(launchable.entries().constFirst());
if (!file.isEmpty()) { if (!file.isEmpty()) {
auto trans = PackageKit::Daemon::searchFiles(file); auto trans = PackageKit::Daemon::searchFiles(file);
connect(trans, &PackageKit::Transaction::package, this, [trans](PackageKit::Transaction::Info info, const QString &packageID){ connect(trans, &PackageKit::Transaction::package, this, [trans](PackageKit::Transaction::Info info, const QString &packageID){
...@@ -180,8 +182,15 @@ void PackageKitBackend::reloadPackageList() ...@@ -180,8 +182,15 @@ void PackageKitBackend::reloadPackageList()
} }
acquireFetching(false); acquireFetching(false);
neededPackages.removeDuplicates(); if (!neededPackages.isEmpty()) {
resolvePackages(neededPackages); neededPackages.removeDuplicates();
resolvePackages(neededPackages);
} else {
qDebug() << "empty appstream db";
if (PackageKit::Daemon::backendName() == QLatin1String("aptcc") || PackageKit::Daemon::backendName().isEmpty()) {
checkForUpdates();
}
}
} }
AppPackageKitResource* PackageKitBackend::addComponent(const AppStream::Component& component, const QStringList& pkgNames) AppPackageKitResource* PackageKitBackend::addComponent(const AppStream::Component& component, const QStringList& pkgNames)
...@@ -354,6 +363,7 @@ void PackageKitBackend::checkForUpdates() ...@@ -354,6 +363,7 @@ void PackageKitBackend::checkForUpdates()
m_refresher = PackageKit::Daemon::refreshCache(false); m_refresher = PackageKit::Daemon::refreshCache(false);
connect(m_refresher.data(), &PackageKit::Transaction::errorCode, this, &PackageKitBackend::transactionError); connect(m_refresher.data(), &PackageKit::Transaction::errorCode, this, &PackageKitBackend::transactionError);
connect(m_refresher.data(), &PackageKit::Transaction::finished, this, [this]() { connect(m_refresher.data(), &PackageKit::Transaction::finished, this, [this]() {
m_refresher = nullptr;
reloadPackageList(); reloadPackageList();
acquireFetching(false); acquireFetching(false);
}); });
...@@ -364,7 +374,7 @@ void PackageKitBackend::checkForUpdates() ...@@ -364,7 +374,7 @@ void PackageKitBackend::checkForUpdates()
QList<AppStream::Component> PackageKitBackend::componentsById(const QString& id) const QList<AppStream::Component> PackageKitBackend::componentsById(const QString& id) const
{ {
return m_appdata.componentsById(id); return m_appdata->componentsById(id);
} }
ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters& filter) ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters& filter)
...@@ -377,7 +387,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters ...@@ -377,7 +387,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters
} else if (filter.search.isEmpty()) { } else if (filter.search.isEmpty()) {
return new ResultsStream(QStringLiteral("PackageKitStream-all"), kFilter<QVector<AbstractResource*>>(m_packages.packages, [](AbstractResource* res) { return !res->isTechnical(); })); return new ResultsStream(QStringLiteral("PackageKitStream-all"), kFilter<QVector<AbstractResource*>>(m_packages.packages, [](AbstractResource* res) { return !res->isTechnical(); }));
} else { } else {
const QList<AppStream::Component> components = m_appdata.search(filter.search); const QList<AppStream::Component> components = m_appdata->search(filter.search);
const QStringList ids = kTransform<QStringList>(components, [](const AppStream::Component& comp) { return comp.id(); }); const QStringList ids = kTransform<QStringList>(components, [](const AppStream::Component& comp) { return comp.id(); });
auto stream = new ResultsStream(QStringLiteral("PackageKitStream-search")); auto stream = new ResultsStream(QStringLiteral("PackageKitStream-search"));
if (!ids.isEmpty()) { if (!ids.isEmpty()) {
......
...@@ -101,7 +101,7 @@ class DISCOVERCOMMON_EXPORT PackageKitBackend : public AbstractResourcesBackend ...@@ -101,7 +101,7 @@ class DISCOVERCOMMON_EXPORT PackageKitBackend : public AbstractResourcesBackend
void performDetailsFetch(); void performDetailsFetch();
AppPackageKitResource* addComponent(const AppStream::Component& component, const QStringList& pkgNames); AppPackageKitResource* addComponent(const AppStream::Component& component, const QStringList& pkgNames);
AppStream::Pool m_appdata; QScopedPointer<AppStream::Pool> m_appdata;
PackageKitUpdater* m_updater; PackageKitUpdater* m_updater;
QPointer<PackageKit::Transaction> m_refresher; QPointer<PackageKit::Transaction> m_refresher;
int m_isFetching; int m_isFetching;
......
...@@ -26,9 +26,8 @@ Button ...@@ -26,9 +26,8 @@ Button
id: root id: root
text: i18n("Configure permissions...") text: i18n("Configure permissions...")
visible: resource.isInstalled
onClicked: overlay.open() onClicked: overlay.open()
visible: view.count > 0 visible: resource.isInstalled && view.count > 0
DiscoverPopup { DiscoverPopup {
id: overlay id: overlay
......
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