Permalink
Browse files

Use completion and cancellation for actions that can block for some time

  • Loading branch information...
1 parent fc63678 commit 8a8aed4b22494721136b19dfeff8c18c1f5efd60 @hughsie committed Apr 17, 2010
View
2 libzif/zif-md-filelists-sql.c
@@ -513,7 +513,7 @@ zif_md_filelists_sql_test (EggTest *test)
/************************************************************/
egg_test_title (test, "search for files");
- array = zif_md_filelists_sql_search_file (md, data, cancellable, completion, &error);
+ array = zif_md_filelists_sql_search_file (ZIF_MD (md), (gchar**)data, cancellable, completion, &error);
if (array != NULL)
egg_test_success (test, NULL);
else
View
28 libzif/zif-md-filelists-xml.c
@@ -337,6 +337,7 @@ zif_md_filelists_xml_get_files (ZifMd *md, ZifPackage *package,
const gchar *pkgid_tmp;
GError *error_local = NULL;
ZifCompletion *completion_local;
+ ZifCompletion *completion_loop;
ZifMdFilelistsXml *md_filelists = ZIF_MD_FILELISTS_XML (md);
g_return_val_if_fail (ZIF_IS_MD_FILELISTS_XML (md), NULL);
@@ -363,16 +364,24 @@ zif_md_filelists_xml_get_files (ZifMd *md, ZifPackage *package,
zif_completion_done (completion);
}
+ /* setup steps */
+ completion_local = zif_completion_get_child (completion);
+ zif_completion_set_number_steps (completion_local, md_filelists->priv->array->len);
+
/* search array */
pkgid = zif_package_remote_get_pkgid (ZIF_PACKAGE_REMOTE (package));
packages = md_filelists->priv->array;
for (i=0; i<packages->len; i++) {
package_tmp = g_ptr_array_index (packages, i);
pkgid_tmp = zif_package_remote_get_pkgid (ZIF_PACKAGE_REMOTE (package_tmp));
if (g_strcmp0 (pkgid, pkgid_tmp) == 0) {
- array = zif_package_get_files (package_tmp, NULL);
+ completion_loop = zif_completion_get_child (completion_local);
+ array = zif_package_get_files (package_tmp, cancellable, completion_loop, NULL);
break;
}
+
+ /* this section done */
+ zif_completion_done (completion_local);
}
/* this section done */
@@ -398,6 +407,7 @@ zif_md_filelists_xml_search_file (ZifMd *md, gchar **search,
const gchar *pkgid;
GError *error_local = NULL;
ZifCompletion *completion_local;
+ ZifCompletion *completion_loop;
ZifMdFilelistsXml *md_filelists = ZIF_MD_FILELISTS_XML (md);
g_return_val_if_fail (ZIF_IS_MD_FILELISTS_XML (md), NULL);
@@ -424,13 +434,18 @@ zif_md_filelists_xml_search_file (ZifMd *md, gchar **search,
zif_completion_done (completion);
}
+ /* setup steps */
+ completion_local = zif_completion_get_child (completion);
+ zif_completion_set_number_steps (completion_local, md_filelists->priv->array->len);
+
/* search array */
array = g_ptr_array_new_with_free_func (g_free);
packages = md_filelists->priv->array;
for (i=0; i<packages->len; i++) {
package = g_ptr_array_index (packages, i);
- pkgid = g_object_get_data (G_OBJECT (package), "pkgid");
- files = zif_package_get_files (package, NULL);
+ pkgid = zif_package_remote_get_pkgid (ZIF_PACKAGE_REMOTE (package));
+ completion_loop = zif_completion_get_child (completion_local);
+ files = zif_package_get_files (package, cancellable, completion_loop, NULL);
for (k=0; k<files->len; k++) {
filename = g_ptr_array_index (files, k);
for (j=0; search[j] != NULL; j++) {
@@ -440,6 +455,9 @@ zif_md_filelists_xml_search_file (ZifMd *md, gchar **search,
}
}
}
+
+ /* this section done */
+ zif_completion_done (completion_local);
}
/* this section done */
@@ -631,7 +649,9 @@ zif_md_filelists_xml_test (EggTest *test)
/************************************************************/
egg_test_title (test, "correct value");
pkgid = g_ptr_array_index (array, 0);
- if (pkgid[0] != '\0' && strlen (pkgid) == 64)
+ if (pkgid == NULL)
+ egg_test_failed (test, "failed to get a pkgId");
+ else if (pkgid[0] != '\0' && strlen (pkgid) == 64)
egg_test_success (test, NULL);
else
egg_test_failed (test, "failed to get a correct pkgId '%s' (%i)", pkgid, strlen (pkgid));
View
2 libzif/zif-md-other-sql.c
@@ -467,7 +467,7 @@ zif_md_other_sql_test (EggTest *test)
/************************************************************/
egg_test_title (test, "search for files");
zif_completion_reset (completion);
- array = zif_md_other_sql_get_changelog (ZIF_MD_OTHER_SQL (md),
+ array = zif_md_other_sql_get_changelog (ZIF_MD (md),
"42b8d71b303b19c2fcc2b06bb9c764f2902dd72b9376525025ee9ba4a41c38e9",
cancellable, completion, &error);
if (array != NULL)
View
5 libzif/zif-md-primary-sql.c
@@ -690,7 +690,7 @@ zif_md_primary_sql_test (EggTest *test)
/************************************************************/
egg_test_title (test, "resolve");
- array = zif_md_primary_sql_resolve (md, data, cancellable, completion, &error);
+ array = zif_md_primary_sql_resolve (ZIF_MD (md), data, cancellable, completion, &error);
if (array != NULL)
egg_test_success (test, NULL);
else
@@ -703,7 +703,8 @@ zif_md_primary_sql_test (EggTest *test)
/************************************************************/
egg_test_title (test, "correct value");
package = g_ptr_array_index (array, 0);
- summary = zif_package_get_summary (package, NULL);
+ zif_completion_reset (completion);
+ summary = zif_package_get_summary (package, NULL, completion, NULL);
if (g_strcmp0 (zif_string_get_value (summary), "GNOME Power Manager") == 0)
egg_test_success (test, NULL);
else
View
24 libzif/zif-md-primary-xml.c
@@ -566,11 +566,13 @@ zif_md_primary_xml_search_details_cb (ZifPackage *package, gpointer user_data)
const gchar *name;
ZifString *summary;
ZifString *description;
+ ZifCompletion *completion_tmp;
gchar **search = (gchar **) user_data;
+ completion_tmp = zif_completion_new ();
name = zif_package_get_name (package);
- summary = zif_package_get_summary (package, NULL);
- description = zif_package_get_description (package, NULL);
+ summary = zif_package_get_summary (package, NULL, completion_tmp, NULL);
+ description = zif_package_get_description (package, NULL, completion_tmp, NULL);
for (i=0; search[i] != NULL; i++) {
if (g_strstr_len (name, -1, search[i]) != NULL) {
ret = TRUE;
@@ -587,6 +589,7 @@ zif_md_primary_xml_search_details_cb (ZifPackage *package, gpointer user_data)
}
zif_string_unref (summary);
zif_string_unref (description);
+ g_object_unref (completion_tmp);
return ret;
}
@@ -609,14 +612,18 @@ zif_md_primary_xml_search_group_cb (ZifPackage *package, gpointer user_data)
guint i;
gboolean ret;
ZifString *value;
+ ZifCompletion *completion_tmp;
gchar **search = (gchar **) user_data;
- value = zif_package_get_category (package, NULL);
+
+ completion_tmp = zif_completion_new ();
+ value = zif_package_get_category (package, NULL, completion_tmp, NULL);
for (i=0; search[i] != NULL; i++) {
if (g_strstr_len (zif_string_get_value (value), -1, search[i]) != NULL) {
ret = TRUE;
break;
}
}
+ g_object_unref (completion_tmp);
zif_string_unref (value);
return ret;
}
@@ -667,10 +674,14 @@ zif_md_primary_xml_what_provides_cb (ZifPackage *package, gpointer user_data)
// guint i;
gboolean ret;
GPtrArray *array;
+ ZifCompletion *completion_tmp;
// gchar **search = (gchar **) user_data;
- array = zif_package_get_provides (package, NULL);
+
+ completion_tmp = zif_completion_new ();
+ array = zif_package_get_provides (package, NULL, completion_tmp, NULL);
/* TODO: do something with the ZifDepend objects */
ret = FALSE;
+ g_object_unref (completion_tmp);
g_ptr_array_unref (array);
return ret;
}
@@ -887,7 +898,7 @@ zif_md_primary_xml_test (EggTest *test)
/************************************************************/
egg_test_title (test, "search for files");
zif_completion_reset (completion);
- array = zif_md_primary_xml_resolve (md, data, cancellable, completion, &error);
+ array = zif_md_primary_xml_resolve (ZIF_MD (md), data, cancellable, completion, &error);
if (array != NULL)
egg_test_success (test, NULL);
else
@@ -900,7 +911,8 @@ zif_md_primary_xml_test (EggTest *test)
/************************************************************/
egg_test_title (test, "correct value");
package = g_ptr_array_index (array, 0);
- summary = zif_package_get_summary (package, NULL);
+ zif_completion_reset (completion);
+ summary = zif_package_get_summary (package, NULL, completion, NULL);
if (g_strcmp0 (zif_string_get_value (summary), "GNOME power management service") == 0)
egg_test_success (test, NULL);
else
View
4 libzif/zif-package-local.c
@@ -253,7 +253,7 @@ zif_package_local_get_depends_from_name_flags_version (GPtrArray *names, GPtrArr
* zif_package_local_ensure_data:
*/
static gboolean
-zif_package_local_ensure_data (ZifPackage *pkg, ZifPackageEnsureType type, GError **error)
+zif_package_local_ensure_data (ZifPackage *pkg, ZifPackageEnsureType type, GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
GPtrArray *files;
GPtrArray *dirnames;
@@ -374,7 +374,7 @@ zif_package_local_ensure_data (ZifPackage *pkg, ZifPackageEnsureType type, GErro
} else if (type == ZIF_PACKAGE_ENSURE_TYPE_GROUP) {
/* group */
- tmp = zif_package_get_category (pkg, error);
+ tmp = zif_package_get_category (pkg, cancellable, completion, error);
if (tmp == NULL)
goto out;
group = zif_groups_get_group_for_cat (ZIF_PACKAGE_LOCAL (pkg)->priv->groups, zif_string_get_value (tmp), NULL);
View
4 libzif/zif-package-remote.c
@@ -207,7 +207,7 @@ zif_package_remote_set_store_remote (ZifPackageRemote *pkg, ZifStoreRemote *stor
* zif_package_remote_ensure_data:
*/
static gboolean
-zif_package_remote_ensure_data (ZifPackage *pkg, ZifPackageEnsureType type, GError **error)
+zif_package_remote_ensure_data (ZifPackage *pkg, ZifPackageEnsureType type, GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
gboolean ret = TRUE;
GPtrArray *array = NULL;
@@ -216,7 +216,7 @@ zif_package_remote_ensure_data (ZifPackage *pkg, ZifPackageEnsureType type, GErr
if (type == ZIF_PACKAGE_ENSURE_TYPE_FILES) {
/* get the file list for this package */
- array = zif_store_remote_get_files (pkg_remote->priv->store_remote, pkg, NULL, NULL, error);
+ array = zif_store_remote_get_files (pkg_remote->priv->store_remote, pkg, cancellable, completion, error);
if (array == NULL) {
ret = FALSE;
goto out;
View
64 libzif/zif-package.c
@@ -466,27 +466,32 @@ zif_package_is_devel (ZifPackage *package)
gboolean
zif_package_is_gui (ZifPackage *package)
{
+ gboolean ret = FALSE;
guint i;
const ZifDepend *depend;
GPtrArray *array;
+ ZifCompletion *completion_tmp;
g_return_val_if_fail (ZIF_IS_PACKAGE (package), FALSE);
g_return_val_if_fail (package->priv->package_id_split != NULL, FALSE);
/* get list of requires */
- array = zif_package_get_requires (package, NULL);
+ completion_tmp = zif_completion_new ();
+ array = zif_package_get_requires (package, NULL, completion_tmp, NULL);
if (array == NULL)
goto out;
for (i=0; i<array->len; i++) {
depend = g_ptr_array_index (array, i);
- if (g_strstr_len (depend->name, -1, "gtk") != NULL)
- return TRUE;
- if (g_strstr_len (depend->name, -1, "kde") != NULL)
- return TRUE;
+ if (g_strstr_len (depend->name, -1, "gtk") != NULL ||
+ g_strstr_len (depend->name, -1, "kde") != NULL) {
+ ret = TRUE;
+ break;
+ }
}
g_ptr_array_unref (array);
out:
- return FALSE;
+ g_object_unref (completion_tmp);
+ return ret;
}
/**
@@ -718,7 +723,8 @@ zif_package_ensure_type_to_string (ZifPackageEnsureType type)
* zif_package_ensure_data:
**/
static gboolean
-zif_package_ensure_data (ZifPackage *package, ZifPackageEnsureType type, GError **error)
+zif_package_ensure_data (ZifPackage *package, ZifPackageEnsureType type,
+ GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
gboolean ret = FALSE;
ZifPackageClass *klass = ZIF_PACKAGE_GET_CLASS (package);
@@ -733,7 +739,7 @@ zif_package_ensure_data (ZifPackage *package, ZifPackageEnsureType type, GError
goto out;
}
- ret = klass->ensure_data (package, type, error);
+ ret = klass->ensure_data (package, type, cancellable, completion, error);
out:
return ret;
}
@@ -750,7 +756,7 @@ zif_package_ensure_data (ZifPackage *package, ZifPackageEnsureType type, GError
* Since: 0.0.1
**/
ZifString *
-zif_package_get_summary (ZifPackage *package, GError **error)
+zif_package_get_summary (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
gboolean ret;
@@ -760,7 +766,7 @@ zif_package_get_summary (ZifPackage *package, GError **error)
/* not exists */
if (package->priv->summary == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_SUMMARY, error);
+ ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_SUMMARY, cancellable, completion, error);
if (!ret)
return NULL;
}
@@ -781,7 +787,7 @@ zif_package_get_summary (ZifPackage *package, GError **error)
* Since: 0.0.1
**/
ZifString *
-zif_package_get_description (ZifPackage *package, GError **error)
+zif_package_get_description (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
gboolean ret;
@@ -791,7 +797,7 @@ zif_package_get_description (ZifPackage *package, GError **error)
/* not exists */
if (package->priv->description == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_DESCRIPTION, error);
+ ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_DESCRIPTION, cancellable, completion, error);
if (!ret)
return NULL;
}
@@ -812,7 +818,7 @@ zif_package_get_description (ZifPackage *package, GError **error)
* Since: 0.0.1
**/
ZifString *
-zif_package_get_license (ZifPackage *package, GError **error)
+zif_package_get_license (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
gboolean ret;
@@ -822,7 +828,7 @@ zif_package_get_license (ZifPackage *package, GError **error)
/* not exists */
if (package->priv->license == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_LICENCE, error);
+ ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_LICENCE, cancellable, completion, error);
if (!ret)
return NULL;
}
@@ -843,7 +849,7 @@ zif_package_get_license (ZifPackage *package, GError **error)
* Since: 0.0.1
**/
ZifString *
-zif_package_get_url (ZifPackage *package, GError **error)
+zif_package_get_url (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
gboolean ret;
@@ -853,7 +859,7 @@ zif_package_get_url (ZifPackage *package, GError **error)
/* not exists */
if (package->priv->url == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_URL, error);
+ ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_URL, cancellable, completion, error);
if (!ret)
return NULL;
}
@@ -874,7 +880,7 @@ zif_package_get_url (ZifPackage *package, GError **error)
* Since: 0.0.1
**/
ZifString *
-zif_package_get_filename (ZifPackage *package, GError **error)
+zif_package_get_filename (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
g_return_val_if_fail (ZIF_IS_PACKAGE (package), NULL);
g_return_val_if_fail (package->priv->package_id_split != NULL, NULL);
@@ -910,7 +916,7 @@ zif_package_get_filename (ZifPackage *package, GError **error)
* Since: 0.0.1
**/
ZifString *
-zif_package_get_category (ZifPackage *package, GError **error)
+zif_package_get_category (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
gboolean ret;
@@ -920,7 +926,7 @@ zif_package_get_category (ZifPackage *package, GError **error)
/* not exists */
if (package->priv->category == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_CATEGORY, error);
+ ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_CATEGORY, cancellable, completion, error);
if (!ret)
return NULL;
}
@@ -941,7 +947,7 @@ zif_package_get_category (ZifPackage *package, GError **error)
* Since: 0.0.1
**/
PkGroupEnum
-zif_package_get_group (ZifPackage *package, GError **error)
+zif_package_get_group (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
gboolean ret;
@@ -950,7 +956,7 @@ zif_package_get_group (ZifPackage *package, GError **error)
/* not exists */
if (package->priv->group == PK_GROUP_ENUM_UNKNOWN) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_GROUP, error);
+ ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_GROUP, cancellable, completion, error);
if (!ret)
return PK_GROUP_ENUM_UNKNOWN;
}
@@ -974,15 +980,15 @@ zif_package_get_group (ZifPackage *package, GError **error)
* Since: 0.0.1
**/
guint64
-zif_package_get_size (ZifPackage *package, GError **error)
+zif_package_get_size (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
gboolean ret;
g_return_val_if_fail (ZIF_IS_PACKAGE (package), 0);
g_return_val_if_fail (error == NULL || *error == NULL, 0);
if (package->priv->size == 0) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_SIZE, error);
+ ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_SIZE, cancellable, completion, error);
if (!ret)
return 0;
}
@@ -1004,7 +1010,7 @@ zif_package_get_size (ZifPackage *package, GError **error)
* Since: 0.0.1
**/
GPtrArray *
-zif_package_get_files (ZifPackage *package, GError **error)
+zif_package_get_files (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
gboolean ret;
@@ -1013,7 +1019,7 @@ zif_package_get_files (ZifPackage *package, GError **error)
/* not exists */
if (package->priv->files == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_FILES, error);
+ ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_FILES, cancellable, completion, error);
if (!ret)
return NULL;
}
@@ -1034,7 +1040,7 @@ zif_package_get_files (ZifPackage *package, GError **error)
* Since: 0.0.1
**/
GPtrArray *
-zif_package_get_requires (ZifPackage *package, GError **error)
+zif_package_get_requires (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
gboolean ret;
@@ -1044,7 +1050,7 @@ zif_package_get_requires (ZifPackage *package, GError **error)
/* not exists */
if (package->priv->requires == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_REQUIRES, error);
+ ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_REQUIRES, cancellable, completion, error);
if (!ret)
return NULL;
}
@@ -1065,7 +1071,7 @@ zif_package_get_requires (ZifPackage *package, GError **error)
* Since: 0.0.1
**/
GPtrArray *
-zif_package_get_provides (ZifPackage *package, GError **error)
+zif_package_get_provides (ZifPackage *package, GCancellable *cancellable, ZifCompletion *completion, GError **error)
{
gboolean ret;
@@ -1075,7 +1081,7 @@ zif_package_get_provides (ZifPackage *package, GError **error)
/* not exists */
if (package->priv->provides == NULL) {
- ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_PROVIDES, error);
+ ret = zif_package_ensure_data (package, ZIF_PACKAGE_ENSURE_TYPE_PROVIDES, cancellable, completion, error);
if (!ret)
return NULL;
}
View
24 libzif/zif-package.h
@@ -78,6 +78,8 @@ struct _ZifPackageClass
/* vtable */
gboolean (*ensure_data) (ZifPackage *package,
ZifPackageEnsureType type,
+ GCancellable *cancellable,
+ ZifCompletion *completion,
GError **error);
};
@@ -94,26 +96,48 @@ ZifPackage *zif_package_new (void);
const gchar *zif_package_get_id (ZifPackage *package);
const gchar *zif_package_get_name (ZifPackage *package);
ZifString *zif_package_get_summary (ZifPackage *package,
+ GCancellable *cancellable,
+ ZifCompletion *completion,
GError **error);
ZifString *zif_package_get_description (ZifPackage *package,
+ GCancellable *cancellable,
+ ZifCompletion *completion,
GError **error);
ZifString *zif_package_get_license (ZifPackage *package,
+ GCancellable *cancellable,
+ ZifCompletion *completion,
GError **error);
ZifString *zif_package_get_url (ZifPackage *package,
+ GCancellable *cancellable,
+ ZifCompletion *completion,
GError **error);
ZifString *zif_package_get_filename (ZifPackage *package,
+ GCancellable *cancellable,
+ ZifCompletion *completion,
GError **error);
ZifString *zif_package_get_category (ZifPackage *package,
+ GCancellable *cancellable,
+ ZifCompletion *completion,
GError **error);
PkGroupEnum zif_package_get_group (ZifPackage *package,
+ GCancellable *cancellable,
+ ZifCompletion *completion,
GError **error);
guint64 zif_package_get_size (ZifPackage *package,
+ GCancellable *cancellable,
+ ZifCompletion *completion,
GError **error);
GPtrArray *zif_package_get_files (ZifPackage *package,
+ GCancellable *cancellable,
+ ZifCompletion *completion,
GError **error);
GPtrArray *zif_package_get_requires (ZifPackage *package,
+ GCancellable *cancellable,
+ ZifCompletion *completion,
GError **error);
GPtrArray *zif_package_get_provides (ZifPackage *package,
+ GCancellable *cancellable,
+ ZifCompletion *completion,
GError **error);
/* internal setters: TODO, in seporate -internal header file */
View
44 libzif/zif-store-local.c
@@ -288,6 +288,7 @@ zif_store_local_search_category (ZifStore *store, gchar **search, GCancellable *
GError *error_local = NULL;
gboolean ret;
ZifCompletion *completion_local = NULL;
+ ZifCompletion *completion_loop = NULL;
ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
@@ -338,7 +339,8 @@ zif_store_local_search_category (ZifStore *store, gchar **search, GCancellable *
array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
for (i=0;i<local->priv->packages->len;i++) {
package = g_ptr_array_index (local->priv->packages, i);
- category = zif_package_get_category (package, NULL);
+ completion_loop = zif_completion_get_child (completion_local);
+ category = zif_package_get_category (package, cancellable, completion_loop, NULL);
for (j=0; search[j] != NULL; j++) {
if (g_strcmp0 (zif_string_get_value (category), search[j]) == 0) {
g_ptr_array_add (array, g_object_ref (package));
@@ -372,6 +374,7 @@ zif_store_local_search_details (ZifStore *store, gchar **search, GCancellable *c
GError *error_local = NULL;
gboolean ret;
ZifCompletion *completion_local = NULL;
+ ZifCompletion *completion_loop = NULL;
ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
@@ -423,7 +426,8 @@ zif_store_local_search_details (ZifStore *store, gchar **search, GCancellable *c
for (i=0;i<local->priv->packages->len;i++) {
package = g_ptr_array_index (local->priv->packages, i);
package_id = zif_package_get_id (package);
- description = zif_package_get_description (package, NULL);
+ completion_loop = zif_completion_get_child (completion_local);
+ description = zif_package_get_description (package, cancellable, completion_loop, NULL);
split = pk_package_id_split (package_id);
for (j=0; search[j] != NULL; j++) {
if (strcasestr (split[PK_PACKAGE_ID_NAME], search[j]) != NULL) {
@@ -461,6 +465,7 @@ zif_store_local_search_group (ZifStore *store, gchar **search, GCancellable *can
gboolean ret;
PkGroupEnum group;
ZifCompletion *completion_local = NULL;
+ ZifCompletion *completion_loop = NULL;
ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
@@ -512,7 +517,8 @@ zif_store_local_search_group (ZifStore *store, gchar **search, GCancellable *can
package = g_ptr_array_index (local->priv->packages, i);
for (j=0; search[j] != NULL; j++) {
group = pk_group_enum_from_text (search[j]);
- group_tmp = zif_package_get_group (package, NULL);
+ completion_loop = zif_completion_get_child (completion_local);
+ group_tmp = zif_package_get_group (package, cancellable, completion_loop, NULL);
if (group == group_tmp) {
g_ptr_array_add (array, g_object_ref (package));
break;
@@ -543,6 +549,7 @@ zif_store_local_search_file (ZifStore *store, gchar **search, GCancellable *canc
const gchar *filename;
gboolean ret;
ZifCompletion *completion_local = NULL;
+ ZifCompletion *completion_loop = NULL;
ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
@@ -592,7 +599,8 @@ zif_store_local_search_file (ZifStore *store, gchar **search, GCancellable *canc
array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
for (i=0;i<local->priv->packages->len;i++) {
package = g_ptr_array_index (local->priv->packages, i);
- files = zif_package_get_files (package, &error_local);
+ completion_loop = zif_completion_get_child (completion_local);
+ files = zif_package_get_files (package, cancellable, completion_loop, &error_local);
if (files == NULL) {
g_set_error (error, ZIF_STORE_ERROR, ZIF_STORE_ERROR_FAILED,
"failed to get file lists: %s", error_local->message);
@@ -718,6 +726,7 @@ zif_store_local_what_provides (ZifStore *store, gchar **search, GCancellable *ca
gboolean ret;
const ZifDepend *provide;
ZifCompletion *completion_local = NULL;
+ ZifCompletion *completion_loop = NULL;
ZifStoreLocal *local = ZIF_STORE_LOCAL (store);
g_return_val_if_fail (ZIF_IS_STORE_LOCAL (store), NULL);
@@ -768,7 +777,8 @@ zif_store_local_what_provides (ZifStore *store, gchar **search, GCancellable *ca
array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
for (i=0;i<local->priv->packages->len;i++) {
package = g_ptr_array_index (local->priv->packages, i);
- provides = zif_package_get_provides (package, NULL);
+ completion_loop = zif_completion_get_child (completion_local);
+ provides = zif_package_get_provides (package, cancellable, completion_loop, NULL);
for (j=0; j<provides->len; j++) {
provide = g_ptr_array_index (provides, j);
for (k=0; search[k] != NULL; k++) {
@@ -1114,6 +1124,7 @@ zif_store_local_test (EggTest *test)
ZifString *string;
const gchar *package_id;
gchar **split;
+ const gchar *to_array[] = { NULL, NULL };
if (!egg_test_start (test, "ZifStoreLocal"))
return;
@@ -1190,7 +1201,8 @@ zif_store_local_test (EggTest *test)
/************************************************************/
egg_test_title (test, "resolve");
zif_completion_reset (completion);
- array = zif_store_local_resolve (ZIF_STORE (store), "kernel", NULL, completion, NULL);
+ to_array[0] = "kernel";
+ array = zif_store_local_resolve (ZIF_STORE (store), (gchar**)to_array, NULL, completion, NULL);
elapsed = egg_test_elapsed (test);
if (array->len >= 1)
egg_test_success (test, NULL);
@@ -1208,7 +1220,8 @@ zif_store_local_test (EggTest *test)
/************************************************************/
egg_test_title (test, "search name");
zif_completion_reset (completion);
- array = zif_store_local_search_name (ZIF_STORE (store), "gnome-p", NULL, completion, NULL);
+ to_array[0] = "gnome-p";
+ array = zif_store_local_search_name (ZIF_STORE (store), (gchar**)to_array, NULL, completion, NULL);
if (array->len > 10)
egg_test_success (test, NULL);
else
@@ -1218,7 +1231,8 @@ zif_store_local_test (EggTest *test)
/************************************************************/
egg_test_title (test, "search details");
zif_completion_reset (completion);
- array = zif_store_local_search_details (ZIF_STORE (store), "manage packages", NULL, completion, NULL);
+ to_array[0] = "manage packages";
+ array = zif_store_local_search_details (ZIF_STORE (store), (gchar**)to_array, NULL, completion, NULL);
if (array->len == 1)
egg_test_success (test, NULL);
else
@@ -1228,7 +1242,8 @@ zif_store_local_test (EggTest *test)
/************************************************************/
egg_test_title (test, "what-provides");
zif_completion_reset (completion);
- array = zif_store_local_what_provides (ZIF_STORE (store), "config(PackageKit)", NULL, completion, NULL);
+ to_array[0] = "config(PackageKit)";
+ array = zif_store_local_what_provides (ZIF_STORE (store), (gchar**)to_array, NULL, completion, NULL);
if (array->len == 1)
egg_test_success (test, NULL);
else
@@ -1257,7 +1272,8 @@ zif_store_local_test (EggTest *test)
/************************************************************/
egg_test_title (test, "get summary");
- string = zif_package_get_summary (package, NULL);
+ zif_completion_reset (completion);
+ string = zif_package_get_summary (package, NULL, completion, NULL);
if (g_strcmp0 (zif_string_get_value(string), "Package management service") == 0)
egg_test_success (test, NULL);
else
@@ -1266,7 +1282,8 @@ zif_store_local_test (EggTest *test)
/************************************************************/
egg_test_title (test, "get license");
- string = zif_package_get_license (package, NULL);
+ zif_completion_reset (completion);
+ string = zif_package_get_license (package, NULL, completion, NULL);
if (g_strcmp0 (zif_string_get_value(string), "GPLv2+") == 0)
egg_test_success (test, NULL);
else
@@ -1275,7 +1292,8 @@ zif_store_local_test (EggTest *test)
/************************************************************/
egg_test_title (test, "get category");
- string = zif_package_get_category (package, NULL);
+ zif_completion_reset (completion);
+ string = zif_package_get_category (package, NULL, completion, NULL);
if (g_strcmp0 (zif_string_get_value(string), "System Environment/Libraries") == 0)
egg_test_success (test, NULL);
else
@@ -1290,7 +1308,7 @@ zif_store_local_test (EggTest *test)
/************************************************************/
egg_test_title (test, "is gui");
ret = zif_package_is_gui (package);
- egg_test_assert (test, ret);
+ egg_test_assert (test, !ret);
/************************************************************/
egg_test_title (test, "is installed");
View
3 libzif/zif-store-remote.c
@@ -3195,7 +3195,8 @@ zif_store_remote_test (EggTest *test)
/************************************************************/
egg_test_title (test, "search category");
zif_completion_reset (completion);
- array = zif_store_remote_search_category (ZIF_STORE (store), "admin-tools", NULL, completion, &error);
+ in_array[0] = "admin-tools";
+ array = zif_store_remote_search_category (ZIF_STORE (store), (gchar**)in_array, NULL, completion, &error);
if (array == NULL)
egg_test_failed (test, "no data: %s", error->message);
else if (array->len > 0)
View
27 tools/zif-main.c
@@ -45,11 +45,13 @@ zif_print_package (ZifPackage *package)
{
const gchar *package_id;
ZifString *summary;
+ ZifCompletion *completion_tmp;
gchar **split;
package_id = zif_package_get_id (package);
split = pk_package_id_split (package_id);
- summary = zif_package_get_summary (package, NULL);
+ completion_tmp = zif_completion_new ();
+ summary = zif_package_get_summary (package, NULL, completion_tmp, NULL);
g_print ("%s-%s.%s (%s)\t%s\n",
split[PK_PACKAGE_ID_NAME],
split[PK_PACKAGE_ID_VERSION],
@@ -58,6 +60,7 @@ zif_print_package (ZifPackage *package)
zif_string_get_value (summary));
g_strfreev (split);
zif_string_unref (summary);
+ g_object_unref (completion_tmp);
}
/**
@@ -184,7 +187,7 @@ zif_cmd_get_depends (const gchar *package_name, ZifCompletion *completion)
const gchar *to_array[] = { NULL, NULL };
/* setup completion */
- zif_completion_set_number_steps (completion, 2);
+ zif_completion_set_number_steps (completion, 3);
/* add all stores */
store_array = zif_store_array_new ();
@@ -226,13 +229,17 @@ zif_cmd_get_depends (const gchar *package_name, ZifCompletion *completion)
zif_completion_done (completion);
/* get requires */
- requires = zif_package_get_requires (package, &error);
+ completion_local = zif_completion_get_child (completion);
+ requires = zif_package_get_requires (package, NULL, completion_local, &error);
if (requires == NULL) {
g_print ("failed to get requires: %s\n", error->message);
g_error_free (error);
goto out;
}
+ /* this section done */
+ zif_completion_done (completion);
+
/* match a package to each require */
completion_local = zif_completion_get_child (completion);
zif_completion_set_number_steps (completion_local, requires->len);
@@ -1032,7 +1039,8 @@ main (int argc, char *argv[])
/* at least one result */
if (array->len > 0) {
package = g_ptr_array_index (array, 0);
- files = zif_package_get_files (package, &error);
+ completion_local = zif_completion_get_child (completion);
+ files = zif_package_get_files (package, NULL, completion_local, &error);
if (files == NULL) {
g_print ("failed to get files: %s\n", error->message);
g_error_free (error);
@@ -1133,11 +1141,12 @@ main (int argc, char *argv[])
package_id = zif_package_get_id (package);
split = pk_package_id_split (package_id);
- summary = zif_package_get_summary (package, NULL);
- description = zif_package_get_description (package, NULL);
- license = zif_package_get_license (package, NULL);
- url = zif_package_get_url (package, NULL);
- size = zif_package_get_size (package, NULL);
+ completion_local = zif_completion_get_child (completion);
+ summary = zif_package_get_summary (package, NULL, completion_local, NULL);
+ description = zif_package_get_description (package, NULL, completion_local, NULL);
+ license = zif_package_get_license (package, NULL, completion_local, NULL);
+ url = zif_package_get_url (package, NULL, completion_local, NULL);
+ size = zif_package_get_size (package, NULL, completion_local, NULL);
g_print ("Name\t : %s\n", split[PK_PACKAGE_ID_NAME]);
g_print ("Version\t : %s\n", split[PK_PACKAGE_ID_VERSION]);

0 comments on commit 8a8aed4

Please sign in to comment.