本文整理汇总了C++中AptIntf::cancelled方法的典型用法代码示例。如果您正苦于以下问题:C++ AptIntf::cancelled方法的具体用法?C++ AptIntf::cancelled怎么用?C++ AptIntf::cancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AptIntf
的用法示例。
在下文中一共展示了AptIntf::cancelled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: backend_depends_on_or_requires_thread
static void backend_depends_on_or_requires_thread(PkBackendJob *job, GVariant *params, gpointer user_data)
{
PkRoleEnum role;
PkBitfield filters;
gchar **package_ids;
gboolean recursive;
gchar *pi;
g_variant_get(params, "(t^a&sb)",
&filters,
&package_ids,
&recursive);
role = pk_backend_job_get_role(job);
pk_backend_job_set_allow_cancel(job, true);
AptIntf *apt = static_cast<AptIntf*>(pk_backend_job_get_user_data(job));
if (!apt->init()) {
g_debug("Failed to create apt cache");
return;
}
pk_backend_job_set_status(job, PK_STATUS_ENUM_QUERY);
PkgList output;
for (uint i = 0; i < g_strv_length(package_ids); ++i) {
if (apt->cancelled()) {
break;
}
pi = package_ids[i];
if (pk_package_id_check(pi) == false) {
pk_backend_job_error_code(job,
PK_ERROR_ENUM_PACKAGE_ID_INVALID,
"%s",
pi);
return;
}
const pkgCache::VerIterator &ver = apt->aptCacheFile()->resolvePkgID(pi);
if (ver.end()) {
pk_backend_job_error_code(job,
PK_ERROR_ENUM_PACKAGE_NOT_FOUND,
"Couldn't find package %s",
pi);
return;
}
if (role == PK_ROLE_ENUM_DEPENDS_ON) {
apt->getDepends(output, ver, recursive);
} else {
apt->getRequires(output, ver, recursive);
}
}
// It's faster to emit the packages here than in the matching part
apt->emitPackages(output, filters);
}
示例2: backend_manage_packages_thread
//.........这里部分代码省略.........
&package_ids);
} else if (role == PK_ROLE_ENUM_UPDATE_PACKAGES) {
g_variant_get(params, "(t^a&s)",
&transaction_flags,
&package_ids);
}
// Check if we should only simulate the install (calculate dependencies)
bool simulate;
simulate = pk_bitfield_contain(transaction_flags, PK_TRANSACTION_FLAG_ENUM_SIMULATE);
// Check if we should only download all the required packages for this transaction
bool downloadOnly;
downloadOnly = pk_bitfield_contain(transaction_flags, PK_TRANSACTION_FLAG_ENUM_ONLY_DOWNLOAD);
// Check if we should fix broken packages
bool fixBroken = false;
if (role == PK_ROLE_ENUM_REPAIR_SYSTEM) {
// On fix broken mode no package to remove/install is allowed
fixBroken = true;
}
g_debug("FILE INSTALL: %i", fileInstall);
pk_backend_job_set_allow_cancel(job, true);
AptIntf *apt = static_cast<AptIntf*>(pk_backend_job_get_user_data(job));
if (!apt->init()) {
g_debug("Failed to create apt cache");
return;
}
pk_backend_job_set_status(job, PK_STATUS_ENUM_QUERY);
PkgList installPkgs, removePkgs;
if (fileInstall) {
// File installation EXPERIMENTAL
// GDebi can not install more than one package at time
if (g_strv_length(full_paths) > 1) {
pk_backend_job_error_code(job,
PK_ERROR_ENUM_NOT_SUPPORTED,
"The backend can only process one file at time.");
return;
}
// get the list of packages to install
if (!apt->markFileForInstall(full_paths[0], installPkgs, removePkgs)) {
return;
}
cout << "installPkgs.size: " << installPkgs.size() << endl;
cout << "removePkgs.size: " << removePkgs.size() << endl;
} else if (!fixBroken) {
// Resolve the given packages
if (role == PK_ROLE_ENUM_REMOVE_PACKAGES) {
removePkgs = apt->resolvePackageIds(package_ids);
} else {
installPkgs = apt->resolvePackageIds(package_ids);
}
if (removePkgs.size() == 0 && installPkgs.size() == 0) {
pk_backend_job_error_code(job,
PK_ERROR_ENUM_PACKAGE_NOT_FOUND,
"Could not find package(s)");
return;
}
}
// Install/Update/Remove packages, or just simulate
bool ret;
ret = apt->runTransaction(installPkgs,
removePkgs,
fileInstall, // Mark newly installed packages as auto-installed
// (they're dependencies of the new local package)
fixBroken,
transaction_flags,
autoremove);
if (!ret) {
// Print transaction errors
g_debug("AptIntf::runTransaction() failed: %i", _error->PendingError());
return;
}
if (fileInstall) {
// Now perform the installation!
gchar *path;
for (uint i = 0; i < g_strv_length(full_paths); ++i) {
if (apt->cancelled()) {
break;
}
path = full_paths[i];
if (!apt->installFile(path, simulate)) {
cout << "Installation of DEB file " << path << " failed." << endl;
return;
}
}
}
}
示例3: pk_backend_download_packages_thread
/**
* pk_backend_download_packages_thread:
*/
static void pk_backend_download_packages_thread(PkBackendJob *job, GVariant *params, gpointer user_data)
{
gchar **package_ids;
const gchar *tmpDir;
string directory;
g_variant_get(params, "(^a&ss)",
&package_ids,
&tmpDir);
directory = _config->FindDir("Dir::Cache::archives");
pk_backend_job_set_allow_cancel(job, true);
AptIntf *apt = static_cast<AptIntf*>(pk_backend_job_get_user_data(job));
if (!apt->init()) {
g_debug("Failed to create apt cache");
return;
}
PkBackend *backend = PK_BACKEND(pk_backend_job_get_backend(job));
if (pk_backend_is_online(backend)) {
pk_backend_job_set_status(job, PK_STATUS_ENUM_QUERY);
// Create the progress
AcqPackageKitStatus Stat(apt, job);
// get a fetcher
pkgAcquire fetcher(&Stat);
gchar *pi;
// TODO this might be useful when the item is in the cache
// for (pkgAcquire::ItemIterator I = fetcher.ItemsBegin(); I < fetcher.ItemsEnd();)
// {
// if ((*I)->Local == true)
// {
// I++;
// continue;
// }
//
// // Close the item and check if it was found in cache
// (*I)->Finished();
// if ((*I)->Complete == false) {
// Transient = true;
// }
//
// // Clear it out of the fetch list
// delete *I;
// I = fetcher.ItemsBegin();
// }
for (uint i = 0; i < g_strv_length(package_ids); ++i) {
pi = package_ids[i];
if (pk_package_id_check(pi) == false) {
pk_backend_job_error_code(job,
PK_ERROR_ENUM_PACKAGE_ID_INVALID,
"%s",
pi);
return;
}
if (apt->cancelled()) {
break;
}
const pkgCache::VerIterator &ver = apt->aptCacheFile()->resolvePkgID(pi);
// Ignore packages that could not be found or that exist only due to dependencies.
if (ver.end()) {
_error->Error("Can't find this package id \"%s\".", pi);
continue;
} else {
if(!ver.Downloadable()) {
_error->Error("No downloadable files for %s,"
"perhaps it is a local or obsolete" "package?",
pi);
continue;
}
string storeFileName;
if (!apt->getArchive(&fetcher,
ver,
directory,
storeFileName)) {
return;
}
gchar **files = (gchar **) g_malloc(2 * sizeof(gchar *));
files[0] = g_strdup_printf("%s/%s", directory.c_str(), flNotDir(storeFileName).c_str());
files[1] = NULL;
pk_backend_job_files(job, pi, files);
g_strfreev(files);
}
}
if (fetcher.Run() != pkgAcquire::Continue
&& apt->cancelled() == false) {
// We failed and we did not cancel
show_errors(job, PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED);
return;
}
//.........这里部分代码省略.........