Commit 12eb9859 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

pk: also fetch details for local files

CCBUG: 400781
parent 67ac20ab
......@@ -21,6 +21,8 @@
#include "LocalFilePKResource.h"
#include <QDebug>
#include <QFileInfo>
#include <PackageKit/Daemon>
#include <PackageKit/Details>
LocalFilePKResource::LocalFilePKResource(QUrl path, PackageKitBackend* parent)
: PackageKitResource(path.toString(), path.toString(), parent)
......@@ -55,3 +57,17 @@ QString LocalFilePKResource::origin() const
{
return m_path.toLocalFile();
}
void LocalFilePKResource::fetchDetails()
{
m_details.insert(QStringLiteral("fetching"), true);//we add an entry so it's not re-fetched.
PackageKit::Transaction* transaction = PackageKit::Daemon::getDetailsLocal(m_path.toLocalFile());
connect(transaction, &PackageKit::Transaction::details, this, [this] (const PackageKit::Details &details){ setDetails(details); });
connect(transaction, &PackageKit::Transaction::errorCode, this, &PackageKitResource::failedFetchingDetails);
}
QString LocalFilePKResource::license()
{
return m_details.license();
}
......@@ -33,9 +33,11 @@ class LocalFilePKResource : public PackageKitResource
QString comment() override;
AbstractResource::State state() override { return m_state; }
QString license() override;
int size() override;
void markInstalled();
QString origin() const override;
void fetchDetails() override;
private:
AbstractResource::State m_state = AbstractResource::None;
......
......@@ -181,9 +181,9 @@ void PackageKitResource::fetchDetails()
backend()->fetchDetails(pkgid);
}
void PackageKitResource::failedFetchingDetails(PackageKit::Transaction::Error, const QString& msg)
void PackageKitResource::failedFetchingDetails(PackageKit::Transaction::Error error, const QString& msg)
{
qWarning() << "error fetching details" << msg;
qWarning() << "error fetching details" << error << msg;
}
void PackageKitResource::setDependenciesCount(int deps)
......
......@@ -98,18 +98,19 @@ class PackageKitResource : public AbstractResource
const QDateTime &issued,
const QDateTime &updated);
private Q_SLOTS:
void failedFetchingDetails(PackageKit::Transaction::Error, const QString& msg);
protected:
PackageKit::Details m_details;
private:
void fetchDependencies();
/** fetches details individually, it's better if done in batch, like for updates */
void fetchDetails();
virtual void fetchDetails();
QMap<PackageKit::Transaction::Info, QStringList> m_packages;
const QString m_summary;
const QString m_name;
PackageKit::Details m_details;
int m_dependenciesCount = -1;
static const QStringList m_objects;
};
......
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