本文整理汇总了C++中pk_backend_set_status函数的典型用法代码示例。如果您正苦于以下问题:C++ pk_backend_set_status函数的具体用法?C++ pk_backend_set_status怎么用?C++ pk_backend_set_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pk_backend_set_status函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: backend_download_packages
/**
* backend_download_packages:
*/
static void
backend_download_packages (PkBackend *backend, gchar **package_ids, const gchar *directory)
{
guint i;
guint len;
const gchar *package_id;
const gchar *files;
const char *error;
slapt_pkg_list_t *installed;
slapt_pkg_list_t *available;
slapt_pkg_info_t *pkg;
const char *summary;
const char *note = NULL;
char *filename;
pk_backend_set_status (backend, PK_STATUS_ENUM_LOADING_CACHE);
installed = slapt_get_installed_pkgs();
available = slapt_get_available_pkgs();
pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD);
pk_backend_set_percentage (backend, 0);
len = g_strv_length (package_ids);
for (i=0; i<len; i++) {
package_id = package_ids[i];
pkg = _get_pkg_from_string(package_id, available, installed);
if (pkg == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found");
continue;
}
summary = _get_pkg_summary(pkg);
pk_backend_package (backend, PK_INFO_ENUM_DOWNLOADING, package_id, summary);
g_free((gpointer) summary);
error = slapt_download_pkg(_config, pkg, note);
if (error == NULL) {
filename = slapt_gen_pkg_file_name(_config, pkg);
files = g_strdup(filename);
pk_backend_files (backend, package_id, files);
g_free((gpointer) files);
free(filename);
} else {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, error);
}
}
slapt_free_pkg_list(available);
slapt_free_pkg_list(installed);
pk_backend_set_percentage (backend, 100);
pk_backend_finished (backend);
}
示例2: pk_backend_transaction_sig_check
static void
pk_backend_transaction_sig_check (PkBackend *self)
{
g_return_if_fail (self != NULL);
pk_backend_set_status (self, PK_STATUS_ENUM_SIG_CHECK);
}
示例3: backend_get_requires
/**
* backend_get_requires:
*/
static void
backend_get_requires (PkBackend *backend, PkBitfield filters, gchar **package_ids, gboolean recursive)
{
guint i;
guint len;
const gchar *package_id;
PkPackageId *pi;
slapt_pkg_info_t *pkg;
slapt_pkg_list_t *installed;
slapt_pkg_list_t *available;
slapt_pkg_list_t *requires;
PkInfoEnum state;
const char *summary;
installed = slapt_get_installed_pkgs();
available = slapt_get_available_pkgs();
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
len = g_strv_length (package_ids);
for (i=0; i<len; i++) {
package_id = package_ids[i];
pi = pk_package_id_new_from_string (package_id);
if (pi == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
pk_backend_finished (backend);
return;
}
pkg = _get_pkg_from_id(pi, available, installed);
pk_package_id_free (pi);
if (pkg == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found");
continue;
}
requires = slapt_is_required_by(_config, available, pkg);
for (i = 0; i < requires->pkg_count; i++) {
pkg = requires->pkgs[i];
state = pkg->installed ? PK_INFO_ENUM_INSTALLED : PK_INFO_ENUM_AVAILABLE;
package_id = _get_string_from_pkg(pkg);
summary = _get_pkg_summary(pkg);
pk_backend_package (backend, state, package_id, summary);
g_free((gpointer) summary);
g_free((gpointer) package_id);
}
slapt_free_pkg_list(requires);
}
slapt_free_pkg_list(available);
slapt_free_pkg_list(installed);
pk_backend_finished (backend);
}
示例4: pk_backend_transaction_upgrade_start
static void
pk_backend_transaction_upgrade_start (PkBackend *self, alpm_pkg_t *pkg,
alpm_pkg_t *old)
{
PkRoleEnum role;
PkStatusEnum state;
PkInfoEnum info;
g_return_if_fail (self != NULL);
g_return_if_fail (pkg != NULL);
role = pk_backend_get_role (self);
if (role == PK_ROLE_ENUM_INSTALL_FILES ||
role == PK_ROLE_ENUM_SIMULATE_INSTALL_FILES) {
state = PK_STATUS_ENUM_INSTALL;
info = PK_INFO_ENUM_INSTALLING;
} else {
state = PK_STATUS_ENUM_UPDATE;
info = PK_INFO_ENUM_UPDATING;
}
pk_backend_set_status (self, state);
pk_backend_pkg (self, pkg, info);
pk_backend_output_start (self, pkg);
}
示例5: backend_get_depends_requires_thread
static gboolean
backend_get_depends_requires_thread (PkBackend *backend)
{
GList *list = NULL;
sqlite3 *db;
gchar **package_ids;
int deps_type;
gchar **package_id_data;
db = db_open ();
package_ids = pk_backend_get_strv (backend, "package_ids");
deps_type = pk_backend_get_uint (backend, "type");
/* FIXME: support multiple packages */
package_id_data = pk_package_id_split (package_ids[0]);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
if (deps_type == DEPS_TYPE_DEPENDS)
list = box_db_repos_get_depends (db, package_id_data[PK_PACKAGE_ID_NAME]);
else if (deps_type == DEPS_TYPE_REQUIRES)
list = box_db_repos_get_requires (db, package_id_data[PK_PACKAGE_ID_NAME]);
add_packages_from_list (backend, list, FALSE);
box_db_repos_package_list_free (list);
db_close (db);
pk_backend_finished (backend);
return TRUE;
}
示例6: backend_update_packages
/**
* backend_update_packages:
*/
static void
backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids)
{
guint i;
guint len;
const gchar *package_id;
int ret;
slapt_pkg_list_t *installed;
slapt_pkg_list_t *available;
const gchar *search;
slapt_pkg_list_t *results = NULL;
slapt_transaction_t *transaction;
slapt_pkg_info_t *pkg;
slapt_pkg_info_t *oldpkg;
/* FIXME: support only_trusted */
pk_backend_set_status (backend, PK_STATUS_ENUM_UPDATE);
pk_backend_set_percentage (backend, 0);
installed = slapt_get_installed_pkgs();
available = slapt_get_available_pkgs();
transaction = slapt_init_transaction();
len = g_strv_length (package_ids);
for (i=0; i<len; i++) {
package_id = package_ids[i];
pkg = _get_pkg_from_string(package_id, available, installed);
if (pkg == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found");
continue;
}
oldpkg = NULL;
search = g_strdup_printf("^%s$", pkg->name);
results = slapt_search_pkg_list(installed, search);
g_free((gpointer) search);
if (results->pkg_count > 0) {
oldpkg = results->pkgs[0];
} else {
continue;
}
slapt_add_upgrade_to_transaction(transaction, oldpkg, pkg);
}
ret = slapt_handle_transaction(_config, transaction);
if (ret != 0) {
pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, "install failed");
}
slapt_free_transaction(transaction);
slapt_free_pkg_list(available);
slapt_free_pkg_list(installed);
pk_backend_set_percentage (backend, 100);
pk_backend_finished (backend);
}
示例7: pk_backend_transaction_test_commit
static void
pk_backend_transaction_test_commit (PkBackend *self)
{
g_return_if_fail (self != NULL);
pk_backend_set_status (self, PK_STATUS_ENUM_TEST_COMMIT);
}
示例8: backend_get_packages_thread
static gboolean
backend_get_packages_thread (PkBackend *backend)
{
PkBitfield filters;
GList *list = NULL;
sqlite3 *db = NULL;
filters = pk_backend_get_uint (backend, "filters");
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
db = db_open();
if ((pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED) &&
pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED)) ||
(!pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED) &&
!pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED))) {
list = box_db_repos_packages_search_all (db, NULL, 0);
} else if (pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED)) {
list = box_db_repos_packages_search_installed (db, NULL, 0);
} else if (pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
list = box_db_repos_packages_search_available (db, NULL, 0);
}
add_packages_from_list (backend, list, FALSE);
box_db_repos_package_list_free (list);
db_close(db);
pk_backend_finished (backend);
return TRUE;
}
示例9: pk_backend_transaction_setup
static void
pk_backend_transaction_setup (PkBackend *self)
{
g_return_if_fail (self != NULL);
pk_backend_set_status (self, PK_STATUS_ENUM_SETUP);
}
示例10: pk_backend_transaction_download
static void
pk_backend_transaction_download (PkBackend *self)
{
g_return_if_fail (self != NULL);
pk_backend_set_status (self, PK_STATUS_ENUM_DOWNLOAD);
}
示例11: pk_backend_transaction_dep_resolve
static void
pk_backend_transaction_dep_resolve (PkBackend *self)
{
g_return_if_fail (self != NULL);
pk_backend_set_status (self, PK_STATUS_ENUM_DEP_RESOLVE);
}
示例12: pk_backend_transaction_repackaging
static void
pk_backend_transaction_repackaging (PkBackend *self)
{
g_return_if_fail (self != NULL);
pk_backend_set_status (self, PK_STATUS_ENUM_REPACKAGING);
}
示例13: backend_remove_packages
/**
* backend_remove_packages:
*/
static void
backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove)
{
guint i;
guint len;
gchar *pi;
int ret;
slapt_pkg_list_t *installed;
slapt_pkg_list_t *available;
slapt_transaction_t *transaction;
slapt_pkg_info_t *pkg;
/* FIXME: support only_trusted */
pk_backend_set_status (backend, PK_STATUS_ENUM_REMOVE);
pk_backend_set_percentage (backend, 0);
installed = slapt_get_installed_pkgs();
available = slapt_get_available_pkgs();
transaction = slapt_init_transaction();
len = g_strv_length (package_ids);
for (i=0; i<len; i++) {
pi = package_ids[i];
if (pi == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
pk_backend_finished (backend);
return;
}
pkg = _get_pkg_from_id(pi, installed, NULL);
if (pkg == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found");
continue;
}
if (!pkg->installed) {
char *pkgname = slapt_stringify_pkg(pkg);
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, "package %s not installed", pkgname);
free(pkgname);
continue;
}
slapt_add_remove_to_transaction(transaction, pkg);
}
ret = slapt_handle_transaction(_config, transaction);
if (ret != 0) {
pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, "remove failed");
}
slapt_free_transaction(transaction);
slapt_free_pkg_list(available);
slapt_free_pkg_list(installed);
pk_backend_set_percentage (backend, 100);
pk_backend_finished (backend);
}
示例14: backend_get_details_thread
static gboolean
backend_get_details_thread (PkBackend *backend)
{
PackageSearch *ps;
GList *list;
sqlite3 *db;
gchar **package_ids;
gchar **package_id_data;
package_ids = pk_backend_get_strv (backend, "package_ids");
/* FIXME: support multiple packages */
package_id_data = pk_package_id_split (package_ids[0]);
db = db_open ();
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
/* only one element is returned */
list = box_db_repos_packages_search_by_data (db, package_id_data[PK_PACKAGE_ID_NAME], package_id_data[PK_PACKAGE_ID_VERSION]);
if (list == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "cannot find package by id");
db_close (db);
return FALSE;
}
ps = (PackageSearch*) list->data;
pk_backend_details (backend, package_ids[0], "unknown", PK_GROUP_ENUM_OTHER, ps->description, "", 0);
box_db_repos_package_list_free (list);
db_close (db);
pk_backend_finished (backend);
return TRUE;
}
示例15: backend_refresh_cache
/**
* backend_refresh_cache:
*/
static void
backend_refresh_cache (PkBackend *backend, gboolean force)
{
pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID);
pk_backend_thread_create (backend, backend_refresh_cache_thread);
}