Skip to content

Commit

Permalink
pk-backend-cards
Browse files Browse the repository at this point in the history
add get-packages function
  • Loading branch information
tnut committed Mar 18, 2024
1 parent 3bf4a43 commit c9e298f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
15 changes: 15 additions & 0 deletions backends/cards/job.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,22 @@ PkBackendJob *Job::pkJob() const
{
return m_job;
}
void Job::resolvePackages(PkBitfield filters)
{
g_debug("resolvePackgesIds");

pk_backend_job_set_status (m_job, PK_STATUS_ENUM_QUERY);

for (auto p: m_cache->getListOfPackagesNames()) {
cards::Cache* pkg = new cards::Cache;
pkg->name(p);
pkg->description(m_cache->getDescription(p));
pkg->arch(m_cache->getArch(p));
pkg->version(m_cache->getVersion(p));
pkg->collection(m_cache->getCollection(p));
m_packageSet.insert(pkg);
}
}
void Job::resolvePackageIds(gchar **package_ids, PkBitfield filters)
{
g_debug("resolvePackgesIds");
Expand Down
6 changes: 6 additions & 0 deletions backends/cards/job.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class Job
*/
PkBackendJob *pkJob() const;

/**
* Get the list of packages
* generate m_packageSet, if the list is empty no package was found
*/
void resolvePackages(PkBitfield filters = PK_FILTER_ENUM_NONE);

/**
* Tries to find a list of packages mathing the package ids
* generate m_packageSet, if the list is empty no package was found
Expand Down
16 changes: 16 additions & 0 deletions backends/cards/pk-backend-cards.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,21 @@ pk_backend_resolve (PkBackend *backend, PkBackendJob *job, PkBitfield filters, g
{
pk_backend_job_thread_create(job, pk_backend_resolve_thread, NULL, NULL);
}

void
pk_backend_get_packages (PkBackend *backend, PkBackendJob *job, PkBitfield filters)
{
pk_backend_job_set_status (job, PK_STATUS_ENUM_REQUEST);

auto cards = static_cast<Job*>(pk_backend_job_get_user_data(job));
if (!cards->init()) {
g_debug("Failed to create cards cache");
return;
}
cards->resolvePackages(filters);
cards->emitPackages(filters,PK_INFO_ENUM_UNKNOWN, true);
pk_backend_job_finished (job);
}
void
pk_backend_install_packages (PkBackend *backend, PkBackendJob *job, PkBitfield transaction_flags, gchar **package_ids)
{
Expand All @@ -226,6 +241,7 @@ pk_backend_get_roles(PkBackend *backend)
roles = pk_bitfield_from_enums(
PK_ROLE_ENUM_CANCEL,
PK_ROLE_ENUM_GET_FILES,
PK_ROLE_ENUM_GET_PACKAGES,
PK_ROLE_ENUM_RESOLVE,
PK_ROLE_ENUM_REFRESH_CACHE,
PK_ROLE_ENUM_GET_UPDATES,
Expand Down

0 comments on commit c9e298f

Please sign in to comment.