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