[PackageKit-commit] packagekit: Branch 'master' - 4 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Fri Apr 11 09:11:39 PDT 2008
Makefile.am | 2
backends/alpm/pk-backend-alpm.c | 28 -
backends/apt/pk-apt-search-plain.c | 30 +
backends/apt/pk-backend-apt.c | 28 +
backends/apt2/pk-backend-apt2.c | 35 --
backends/box/pk-backend-box.c | 93 ++---
backends/conary/pk-backend-conary.c | 129 --------
backends/dummy/pk-backend-dummy.c | 22 -
backends/opkg/pk-backend-opkg.c | 78 +---
backends/pisi/pk-backend-pisi.c | 63 ++-
backends/poldek/pk-backend-poldek.c | 78 ++--
backends/smart/pk-backend-smart.c | 40 +-
backends/test/pk-backend-test-dbus.c | 4
backends/test/pk-backend-test-fail.c | 16
backends/test/pk-backend-test-spawn.c | 7
backends/test/pk-backend-test-succeed.c | 22 -
backends/test/pk-backend-test-thread.c | 4
backends/yum/pk-backend-yum.c | 70 +++-
backends/yum2/pk-backend-yum2.c | 40 +-
backends/zypp/pk-backend-zypp.cpp | 162 +++++-----
libpackagekit/Makefile.am | 3
libpackagekit/pk-filter.c | 515 --------------------------------
libpackagekit/pk-filter.h | 65 ----
libpackagekit/pk-self-test.c | 2
src/pk-backend-dbus.c | 97 ++++--
src/pk-backend-dbus.h | 22 -
src/pk-backend-spawn.c | 6
src/pk-backend.h | 22 -
src/pk-engine.c | 7
src/pk-self-test.c | 4
src/pk-transaction-db.c | 6
src/pk-transaction.c | 207 ++++++++++--
tools/add-method.sh | 2
33 files changed, 711 insertions(+), 1198 deletions(-)
New commits:
commit afe944b573465572ed2611ffdeeb657182add9bb
Author: Stefan Haas <shaas at suse.de>
Date: Fri Apr 11 17:51:21 2008 +0200
fixed GetPackages
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 5c24607..42de58d 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -1515,13 +1515,13 @@ backend_get_packages_thread (PkBackendThread *thread, gpointer data) {
/*get current backend */
backend = pk_backend_thread_get_backend (thread);
- gchar *filter = (gchar*) data;
+ PkFilterEnum* filter = (PkFilterEnum*) data;
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
PkInfoEnum info = PK_INFO_ENUM_AVAILABLE;
- if (g_ascii_strcasecmp (filter, "installed")) {
+ if (*filter == PK_FILTER_ENUM_INSTALLED) {
zypp_build_local_pool ();
}else{
zypp_build_pool (TRUE);
@@ -1532,7 +1532,7 @@ backend_get_packages_thread (PkBackendThread *thread, gpointer data) {
for (zypp::ResPool::byKind_iterator it = pool.byKindBegin (zypp::ResKind::package); it != pool.byKindEnd (zypp::ResKind::package); it++) {
if ((*it)->isSystem ()) {
info = PK_INFO_ENUM_INSTALLED;
- if (g_ascii_strcasecmp (filter, "not_installed"))
+ if (*filter == PK_FILTER_ENUM_NOT_INSTALLED)
continue;
}
@@ -1554,13 +1554,12 @@ backend_get_packages_thread (PkBackendThread *thread, gpointer data) {
* backend_get_packages:
*/
static void
-backend_get_packages (PkBackend *backend, const gchar *filter)
+backend_get_packages (PkBackend *backend, PkFilterEnum filter)
{
- g_return_if_fail (backend != NULL);
+ g_return_if_fail (backend != NULL);
+ PkFilterEnum *data = g_new0(PkFilterEnum, 1);
- gchar *data = g_new0(gchar, 1);
- data = g_strdup(filter);
- pk_backend_thread_create (thread, backend_get_packages_thread, data);
+ pk_backend_thread_create (thread, backend_get_packages_thread, data);
}
static gboolean
commit e47a195230f8c226815fabb8ef3a4f6ae2173867
Merge: 8b35ca5... 0214a25...
Author: Stefan Haas <shaas at suse.de>
Date: Fri Apr 11 17:25:50 2008 +0200
Merge branch 'master' of git+ssh://shaas@git.packagekit.org/srv/git/PackageKit
commit 8b35ca515577c6b6b28e0c1db52e9cd925c8b227
Author: Stefan Haas <shaas at suse.de>
Date: Fri Apr 11 17:25:25 2008 +0200
added GetPackages to zypp-Backend
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index f12a1a3..674d7b0 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -361,7 +361,8 @@ static PkFilterEnum
backend_get_filters (PkBackend *backend)
{
g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
- return PK_FILTER_ENUM_INSTALLED;
+ return (PkFilterEnum) (PK_FILTER_ENUM_INSTALLED |
+ PK_FILTER_ENUM_NOT_INSTALLED);
}
static gboolean
@@ -1554,6 +1555,60 @@ backend_get_files(PkBackend *backend, const gchar *package_id)
}
static gboolean
+backend_get_packages_thread (PkBackendThread *thread, gpointer data) {
+ PkBackend *backend;
+
+ /*get current backend */
+ backend = pk_backend_thread_get_backend (thread);
+ gchar *filter = (gchar*) data;
+
+ pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
+
+ PkInfoEnum info = PK_INFO_ENUM_AVAILABLE;
+
+ if (g_ascii_strcasecmp (filter, "installed")) {
+ zypp_build_local_pool ();
+ }else{
+ zypp_build_pool (TRUE);
+ }
+
+ zypp::ResPool pool = zypp::ResPool::instance ();
+
+ for (zypp::ResPool::byKind_iterator it = pool.byKindBegin (zypp::ResKind::package); it != pool.byKindEnd (zypp::ResKind::package); it++) {
+ if ((*it)->isSystem ()) {
+ info = PK_INFO_ENUM_INSTALLED;
+ if (g_ascii_strcasecmp (filter, "not_installed"))
+ continue;
+ }
+
+ gchar *package_id = zypp_build_package_id_from_resolvable (it->satSolvable ());
+ pk_backend_package (backend,
+ info,
+ package_id,
+ (*it)->description ().c_str ());
+ g_free (package_id);
+ }
+
+
+ g_free (filter);
+ pk_backend_finished (backend);
+
+ return TRUE;
+}
+/**
+ * backend_get_packages:
+ */
+static void
+backend_get_packages (PkBackend *backend, const gchar *filter)
+{
+ g_return_if_fail (backend != NULL);
+
+ gchar *data = g_new0(gchar, 1);
+ data = g_strdup(filter);
+ pk_backend_thread_create (thread, backend_get_packages_thread, data);
+}
+
+static gboolean
backend_update_packages_thread (PkBackendThread *thread, gpointer data) {
PkBackend *backend;
@@ -1774,7 +1829,7 @@ extern "C" PK_BACKEND_OPTIONS (
backend_get_depends, /* get_depends */
backend_get_description, /* get_description */
backend_get_files, /* get_files */
- NULL, /* get_packages */
+ backend_get_packages, /* get_packages */
backend_get_repo_list, /* get_repo_list */
backend_get_requires, /* get_requires */
backend_get_update_detail, /* get_update_detail */
commit 0214a250f5e7bda2895f23d1746185bce6c16d8e
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Apr 11 15:55:14 2008 +0100
remove PkFilter now we can manipulate enum lists - I don't think I've broken anything, but it's best to be sure and check
diff --git a/Makefile.am b/Makefile.am
index 87cfa32..3d00bbd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -93,5 +93,5 @@ EXTRA_DIST = \
intltool-update.in \
$(NULL)
-DISTCHECK_CONFIGURE_FLAGS = --disable-gcov --enable-gtk-doc --with-security-framework=dummy
+DISTCHECK_CONFIGURE_FLAGS = --disable-gcov --enable-gtk-doc --with-security-framework=dummy --disable-developer
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 9e42182..889ad30 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -21,8 +21,6 @@
#define ALPM_CONFIG_PATH "/etc/pacman.conf"
#define ALPM_PROGRESS_UPDATE_INTERVAL 400
-#define ALPM_FILTER_INSTALLED "installed"
-#define ALPM_FILTER_NINSTALLED "~installed"
#include <gmodule.h>
#include <glib.h>
@@ -644,31 +642,15 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
* backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
alpm_list_t *result = NULL;
alpm_list_t *localresult = NULL;
alpm_list_t *dbs = NULL;
- gchar **sections = NULL;
- gboolean installed = TRUE, ninstalled = TRUE;
-
-
- sections = g_strsplit (filter, ";", 0);
- int i = 0;
- while (sections[i]) {
- if (strcmp(sections[i], ALPM_FILTER_INSTALLED) == 0)
- {
- installed = FALSE;
- }
- if (strcmp(sections[i], ALPM_FILTER_NINSTALLED) == 0)
- {
- ninstalled = FALSE;
- }
-
- i++;
- }
- g_strfreev (sections);
+
+ installed = pk_enums_contain (filters, PK_FILTER_ENUM_INSTALLED);
+ ninstalled = pk_enums_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED);
pk_debug ("alpm: searching for \"%s\" - searching in installed: %i, ~installed: %i",
search, installed, ninstalled);
@@ -761,7 +743,7 @@ backend_install_file (PkBackend *backend, const gchar *path)
}
void
-backend_get_repo_list (PkBackend *backend, const gchar *filter)
+backend_get_repo_list (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
backend_initialize (backend);
diff --git a/backends/apt/pk-apt-search-plain.c b/backends/apt/pk-apt-search-plain.c
index 2851057..139a012 100644
--- a/backends/apt/pk-apt-search-plain.c
+++ b/backends/apt/pk-apt-search-plain.c
@@ -64,8 +64,8 @@ backend_get_filters (PkBackend *backend)
void
backend_get_description (PkBackend *backend, const gchar *package_id)
{
- g_return_if_fail (backend != NULL);
- pk_backend_spawn_helper (spawn, "get-description.py", package_id, NULL);
+ g_return_if_fail (backend != NULL);
+ pk_backend_spawn_helper (spawn, "get-description.py", package_id, NULL);
}
/**
@@ -73,30 +73,38 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
*/
void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
- g_return_if_fail (backend != NULL);
- pk_backend_spawn_helper (spawn, "search-details.py", filter, search, NULL);
+ gchar *filters_text;
+ g_return_if_fail (backend != NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-details.py", filters_texts_text, search, NULL);
+ g_free (filters_text);
}
/**
* backend_search_name:
*/
void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
- g_return_if_fail (backend != NULL);
- pk_backend_spawn_helper (spawn, "search-name.py", filter, search, NULL);
+ gchar *filters_text;
+ g_return_if_fail (backend != NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-name.py", filters_text, search, NULL);
+ g_free (filters_text);
}
/**
* backend_search_group:
*/
void
-backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
- g_return_if_fail (backend != NULL);
- pk_backend_spawn_helper (spawn, "search-group.py", filter, search, NULL);
+ gchar *filters_text;
+ g_return_if_fail (backend != NULL);
+ pk_backend_spawn_helper (spawn, "search-group.py", filters_text, search, NULL);
+ g_free (filters_text);
}
/* don't need to do any setup/finalize in the plain search mode */
diff --git a/backends/apt/pk-backend-apt.c b/backends/apt/pk-backend-apt.c
index f695312..2732b01 100644
--- a/backends/apt/pk-backend-apt.c
+++ b/backends/apt/pk-backend-apt.c
@@ -108,22 +108,28 @@ pk_backend_bool_to_text (gboolean value)
* backend_get_depends:
*/
static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_depends (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-depends.py", filter, package_id, pk_backend_bool_to_text (recursive), NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-depends.py", filters_text, package_id, pk_backend_bool_to_text (recursive), NULL);
+ g_free (filters_text);
}
/**
* backend_get_updates:
*/
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-updates.py", filter, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-updates.py", filters_text, NULL);
+ g_free (filters_text);
}
/**
@@ -220,22 +226,28 @@ backend_update_system (PkBackend *backend)
* pk_backend_resolve:
*/
static void
-backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
+backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package_id)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "resolve.py", filter, package_id, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "resolve.py", filters_text, package_id, NULL);
+ g_free (filters_text);
}
/**
* pk_backend_get_repo_list:
*/
static void
-backend_get_repo_list (PkBackend *backend, const gchar *filter)
+backend_get_repo_list (PkBackend *backend, PkFilterEnum filters)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-repo-list.py", filter, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-repo-list.py", filters_text, NULL);
+ g_free (filters_text);
}
PK_BACKEND_OPTIONS (
diff --git a/backends/apt2/pk-backend-apt2.c b/backends/apt2/pk-backend-apt2.c
index 2da4dc0..a411c3f 100644
--- a/backends/apt2/pk-backend-apt2.c
+++ b/backends/apt2/pk-backend-apt2.c
@@ -89,37 +89,14 @@ backend_get_filters (PkBackend *backend)
}
/**
- * pk_backend_bool_to_text:
- *
-static const gchar *
-pk_backend_bool_to_text (gboolean value)
-{
- if (value == TRUE) {
- return "yes";
- }
- return "no";
-} */
-
-/**
- * backend_get_depends:
- *
-static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
-{
- g_return_if_fail (backend != NULL);
- g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-depends.py", package_id, pk_backend_bool_to_text (recursive), NULL);
-} */
-
-/**
* backend_get_updates:
*/
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (dbus != NULL);
- pk_backend_dbus_get_updates (dbus, filter);
+ pk_backend_dbus_get_updates (dbus, filters);
}
/**
@@ -189,22 +166,22 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
* * pk_backend_search_details:
* */
static void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (dbus != NULL);
- pk_backend_dbus_search_details (dbus, filter, search);
+ pk_backend_dbus_search_details (dbus, filters, search);
}
/**
* * pk_backend_search_name:
* */
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (dbus != NULL);
- pk_backend_dbus_search_name (dbus, filter, search);
+ pk_backend_dbus_search_name (dbus, filters, search);
}
/**
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 305f47f..726d881 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -27,7 +27,6 @@
#include <pk-backend-thread.h>
#include <pk-debug.h>
#include <pk-network.h>
-#include <pk-filter.h>
#include <sqlite3.h>
#include <libbox/libbox-db.h>
@@ -60,7 +59,7 @@ enum DepsBehaviour {
typedef struct {
gchar *search;
- gchar *filter;
+ PkFilterEnum filters;
gint mode;
} FindData;
@@ -121,43 +120,36 @@ add_packages_from_list (PkBackend *backend, GList *list, gboolean updates)
}
static void
-find_packages_real (PkBackend *backend, const gchar *search, const gchar *filter_text, gint mode)
+find_packages_real (PkBackend *backend, const gchar *search, PkFilterEnum filters, gint mode)
{
GList *list = NULL;
sqlite3 *db = NULL;
- gint search_filter = 0;
- PkFilter *filter;
+ gint filter_box = 0;
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
- /* parse */
- filter = pk_filter_new_from_string (filter_text);
- if (filter == NULL) {
- pk_error ("filter invalid, daemon broken");
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_INSTALLED)) {
+ filter_box = filter_box | PKG_INSTALLED;
}
-
- if (filter->installed == TRUE) {
- search_filter = search_filter | PKG_INSTALLED;
- }
- if (filter->not_installed == TRUE) {
- search_filter = search_filter | PKG_AVAILABLE;
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
+ filter_box = filter_box | PKG_AVAILABLE;
}
- if (filter->devel == TRUE) {
- search_filter = search_filter | PKG_DEVEL;
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_DEVEL)) {
+ filter_box = filter_box | PKG_DEVEL;
}
- if (filter->not_devel == TRUE) {
- search_filter = search_filter | PKG_NON_DEVEL;
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_NOT_DEVEL)) {
+ filter_box = filter_box | PKG_NON_DEVEL;
}
- if (filter->gui == TRUE) {
- search_filter = search_filter | PKG_GUI;
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_GUI)) {
+ filter_box = filter_box | PKG_GUI;
}
- if (filter->not_gui == TRUE) {
- search_filter = search_filter | PKG_TEXT;
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_NOT_GUI)) {
+ filter_box = filter_box | PKG_TEXT;
}
if (mode == SEARCH_TYPE_DETAILS) {
- search_filter = search_filter | PKG_SEARCH_DETAILS;
+ filter_box = filter_box | PKG_SEARCH_DETAILS;
}
pk_backend_no_percentage_updates (backend);
@@ -165,10 +157,11 @@ find_packages_real (PkBackend *backend, const gchar *search, const gchar *filter
db = db_open();
if (mode == SEARCH_TYPE_FILE) {
- if (filter->installed == FALSE && filter->not_installed == FALSE) {
+ if (!pk_enums_contain (filters, PK_FILTER_ENUM_INSTALLED) &&
+ !pk_enums_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
pk_backend_error_code (backend, PK_ERROR_ENUM_UNKNOWN, "invalid search mode");
} else {
- list = box_db_repos_search_file_with_filter (db, search, search_filter);
+ list = box_db_repos_search_file_with_filter (db, search, filter_box);
add_packages_from_list (backend, list, FALSE);
box_db_repos_package_list_free (list);
}
@@ -177,22 +170,23 @@ find_packages_real (PkBackend *backend, const gchar *search, const gchar *filter
add_packages_from_list (backend, list, FALSE);
box_db_repos_package_list_free (list);
} else {
- if (filter->installed == FALSE && filter->not_installed == FALSE) {
+ if (!pk_enums_contain (filters, PK_FILTER_ENUM_INSTALLED) &&
+ !pk_enums_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
pk_backend_error_code (backend, PK_ERROR_ENUM_UNKNOWN, "invalid search mode");
} else {
- if (filter->installed == TRUE && filter->not_installed == TRUE) {
- list = box_db_repos_packages_search_all(db, (gchar *)search, search_filter);
- } else if (filter->installed == TRUE) {
- list = box_db_repos_packages_search_installed(db, (gchar *)search, search_filter);
- } else if (filter->not_installed == TRUE) {
- list = box_db_repos_packages_search_available(db, (gchar *)search, search_filter);
+ if (pk_enums_contain (filters, PK_FILTER_ENUM_INSTALLED) &&
+ pk_enums_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
+ list = box_db_repos_packages_search_all(db, (gchar *)search, filter_box);
+ } else if (pk_enums_contain (filters, PK_FILTER_ENUM_INSTALLED)) {
+ list = box_db_repos_packages_search_installed(db, (gchar *)search, filter_box);
+ } else if (pk_enums_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
+ list = box_db_repos_packages_search_available(db, (gchar *)search, filter_box);
}
add_packages_from_list (backend, list, FALSE);
box_db_repos_package_list_free (list);
}
}
- pk_filter_free (filter);
db_close(db);
}
@@ -205,10 +199,9 @@ backend_find_packages_thread (PkBackendThread *thread, gpointer data)
/* get current backend */
backend = pk_backend_thread_get_backend (thread);
- find_packages_real (backend, d->search, d->filter, d->mode);
+ find_packages_real (backend, d->search, d->filters, d->mode);
g_free(d->search);
- g_free(d->filter);
g_free(d);
pk_backend_finished (backend);
@@ -217,14 +210,14 @@ backend_find_packages_thread (PkBackendThread *thread, gpointer data)
static void
-find_packages (PkBackend *backend, const gchar *search, const gchar *filter, gint mode)
+find_packages (PkBackend *backend, const gchar *search, PkFilterEnum filters, gint mode)
{
FindData *data = g_new0(FindData, 1);
g_return_if_fail (backend != NULL);
data->search = g_strdup(search);
- data->filter = g_strdup(filter);
+ data->filters = filters;
data->mode = mode;
pk_backend_thread_create (thread, backend_find_packages_thread, data);
}
@@ -584,7 +577,7 @@ backend_get_filters (PkBackend *backend)
* backend_get_depends:
*/
static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_depends (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
ThreadData *data = g_new0(ThreadData, 1);
@@ -627,7 +620,7 @@ backend_get_files (PkBackend *backend, const gchar *package_id)
* backend_get_requires:
*/
static void
-backend_get_requires (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_requires (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
ThreadData *data = g_new0(ThreadData, 1);
@@ -642,7 +635,7 @@ backend_get_requires (PkBackend *backend, const gchar *filter, const gchar *pack
* backend_get_updates:
*/
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
pk_backend_thread_create (thread, backend_get_updates_thread, NULL);
@@ -723,40 +716,40 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
* backend_resolve:
*/
static void
-backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package)
+backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package)
{
g_return_if_fail (backend != NULL);
- find_packages (backend, package, filter, SEARCH_TYPE_RESOLVE);
+ find_packages (backend, package, filters, SEARCH_TYPE_RESOLVE);
}
/**
* backend_search_details:
*/
static void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
- find_packages (backend, search, filter, SEARCH_TYPE_DETAILS);
+ find_packages (backend, search, filters, SEARCH_TYPE_DETAILS);
}
/**
* backend_search_file:
*/
static void
-backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_file (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
- find_packages (backend, search, filter, SEARCH_TYPE_FILE);
+ find_packages (backend, search, filters, SEARCH_TYPE_FILE);
}
/**
* backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
- find_packages (backend, search, filter, SEARCH_TYPE_NAME);
+ find_packages (backend, search, filters, SEARCH_TYPE_NAME);
}
/**
@@ -793,7 +786,7 @@ backend_update_system (PkBackend *backend)
* backend_get_repo_list:
*/
static void
-backend_get_repo_list (PkBackend *backend, const gchar *filter)
+backend_get_repo_list (PkBackend *backend, PkFilterEnum filters)
{
GList *list;
GList *li;
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index 76cdaa1..0797aec 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -112,19 +112,6 @@ backend_cancel (PkBackend *backend)
}
/**
- * backend_get_depends:
- */
-/**
-static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
-{
- g_return_if_fail (backend != NULL);
- g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-depends.py", filter, package_id, pk_backend_bool_to_text (recursive), NULL);
-}
- */
-
-/**
* backend_get_description:
*/
static void
@@ -147,27 +134,17 @@ backend_get_files (PkBackend *backend, const gchar *package_id)
}
/**
- * backend_get_requires:
- */
-/**
-static void
-backend_get_requires (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
-{
- g_return_if_fail (backend != NULL);
- g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-requires.py", filter, package_id, pk_backend_bool_to_text (recursive), NULL);
-}
- */
-
-/**
* backend_get_updates:
*/
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-updates.py", filter, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-updates.py", filters_text, NULL);
+ g_free (filters_text);
}
/**
@@ -244,53 +221,17 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
}
/**
- * pk_backend_search_details:
- */
-/**
-static void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
-{
- g_return_if_fail (backend != NULL);
- g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-details.py", filter, search, NULL);
-}
- */
-
-/**
- * pk_backend_search_file:
- */
-/**
-static void
-backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
-{
- g_return_if_fail (backend != NULL);
- g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-file.py", filter, search, NULL);
-}
- */
-
-/**
- * pk_backend_search_group:
- */
-/**
-static void
-backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
-{
- g_return_if_fail (backend != NULL);
- g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-group.py", filter, search, NULL);
-}
- */
-
-/**
* pk_backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-name.py", filter, search, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-name.py", filters_text, search, NULL);
+ g_free (filters_text);
}
/**
@@ -332,55 +273,15 @@ backend_update_system (PkBackend *backend)
* pk_backend_resolve:
*/
static void
-backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
-{
- g_return_if_fail (backend != NULL);
- g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "resolve.py", filter, package_id, NULL);
-}
-
-/**
- * pk_backend_get_repo_list:
- */
-/**
-static void
-backend_get_repo_list (PkBackend *backend, const gchar *filter)
-{
- g_return_if_fail (backend != NULL);
- g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-repo-list.py", filter, NULL);
-}
- */
-
-/**
- * pk_backend_repo_enable:
- */
-/**
-static void
-backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled)
-{
- g_return_if_fail (backend != NULL);
- g_return_if_fail (spawn != NULL);
- if (enabled == TRUE) {
- pk_backend_spawn_helper (spawn, "repo-enable.py", rid, "true", NULL);
- } else {
- pk_backend_spawn_helper (spawn, "repo-enable.py", rid, "false", NULL);
- }
-}
- */
-
-/**
- * pk_backend_repo_set_data:
- */
-/**
-static void
-backend_repo_set_data (PkBackend *backend, const gchar *rid, const gchar *parameter, const gchar *value)
+backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package_id)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "repo-set-data.py", rid, parameter, value, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "resolve.py", filters_text, package_id, NULL);
+ g_free (filters_text);
}
- */
PK_BACKEND_OPTIONS (
"Conary", /* description */
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index 9335b8b..71649f1 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -122,7 +122,7 @@ backend_cancel (PkBackend *backend)
* backend_get_depends:
*/
static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_depends (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
@@ -169,7 +169,7 @@ backend_get_files (PkBackend *backend, const gchar *package_id)
* backend_get_requires:
*/
static void
-backend_get_requires (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_requires (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
@@ -261,7 +261,7 @@ backend_get_updates_timeout (gpointer data)
* backend_get_updates:
*/
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
@@ -393,7 +393,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
* backend_resolve:
*/
static void
-backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package)
+backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package)
{
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
@@ -434,7 +434,7 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
* backend_search_details:
*/
static void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
@@ -449,7 +449,7 @@ backend_search_details (PkBackend *backend, const gchar *filter, const gchar *se
* backend_search_file:
*/
static void
-backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_file (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
@@ -464,7 +464,7 @@ backend_search_file (PkBackend *backend, const gchar *filter, const gchar *searc
* backend_search_group:
*/
static void
-backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
@@ -505,7 +505,7 @@ backend_search_name_timeout (gpointer data)
* backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_no_percentage_updates (backend);
@@ -657,7 +657,7 @@ backend_update_system (PkBackend *backend)
* backend_get_repo_list:
*/
static void
-backend_get_repo_list (PkBackend *backend, const gchar *filter)
+backend_get_repo_list (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
@@ -736,7 +736,7 @@ backend_service_pack (PkBackend *backend, const gchar *location, gboolean enable
* backend_what_provides:
*/
static void
-backend_what_provides (PkBackend *backend, const gchar *filter, PkProvidesEnum provides, const gchar *search)
+backend_what_provides (PkBackend *backend, PkFilterEnum filters, PkProvidesEnum provides, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_REQUEST);
@@ -750,7 +750,7 @@ backend_what_provides (PkBackend *backend, const gchar *filter, PkProvidesEnum p
* backend_get_packages:
*/
static void
-backend_get_packages (PkBackend *backend, const gchar *filter)
+backend_get_packages (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_REQUEST);
diff --git a/backends/opkg/pk-backend-opkg.c b/backends/opkg/pk-backend-opkg.c
index 39816c3..2f94bc3 100644
--- a/backends/opkg/pk-backend-opkg.c
+++ b/backends/opkg/pk-backend-opkg.c
@@ -28,7 +28,6 @@
#include <pk-debug.h>
#include <pk-package-ids.h>
-
#define OPKG_LIB
#include <libopkg.h>
@@ -37,16 +36,6 @@ static PkBackendThread *thread;
/* this is implemented in libopkg.a */
int opkg_upgrade_pkg(opkg_conf_t *conf, pkg_t *old);
-
-enum filters {
- PKG_INSTALLED = 1,
- PKG_NOT_INSTALLED = 2,
- PKG_DEVEL = 4,
- PKG_NOT_DEVEL = 8,
- PKG_GUI = 16,
- PKG_NOT_GUI = 32
-};
-
enum {
SEARCH_NAME,
SEARCH_DESCRIPTION,
@@ -57,7 +46,7 @@ enum {
typedef struct {
gint search_type;
gchar *needle;
- gint filter;
+ PkFilterEnum filters;
} SearchParams;
/* global config structures */
@@ -236,39 +225,6 @@ opkg_check_tag (pkg_t *pkg, gchar *tag)
}
/**
- * parse_filter:
- */
-static int
-parse_filter (const gchar *filter)
-{
- gchar **sections = NULL;
- gint i = 0;
- gint retval = 0;
-
- sections = g_strsplit (filter, ";", 0);
- while (sections[i]) {
- if (strcmp(sections[i], "installed") == 0)
- retval = retval | PKG_INSTALLED;
- if (strcmp(sections[i], "~installed") == 0)
- retval = retval | PKG_NOT_INSTALLED;
- if (strcmp(sections[i], "devel") == 0)
- retval = retval | PKG_DEVEL;
- if (strcmp(sections[i], "~devel") == 0)
- retval = retval | PKG_NOT_DEVEL;
- if (strcmp(sections[i], "gui") == 0)
- retval = retval | PKG_GUI;
- if (strcmp(sections[i], "~gui") == 0)
- retval = retval | PKG_NOT_GUI;
- i++;
- }
- g_strfreev (sections);
-
- return retval;
-}
-
-
-
-/**
* backend_initialize:
*/
static void
@@ -493,7 +449,7 @@ backend_search_thread (PkBackendThread *thread, SearchParams *params)
pkg_vec_t *available;
pkg_t *pkg;
gchar *search;
- gint filter;
+ PkFilterEnum filters;
PkBackend *backend;
if (!params->needle)
@@ -506,7 +462,7 @@ backend_search_thread (PkBackendThread *thread, SearchParams *params)
backend = pk_backend_thread_get_backend (thread);
search = params->needle;
- filter = params->filter;
+ filters = params->filters;
available = pkg_vec_alloc();
pkg_hash_fetch_available (&global_conf.pkg_hash, available);
@@ -547,17 +503,17 @@ backend_search_thread (PkBackendThread *thread, SearchParams *params)
(!pkg->tags || !g_strrstr (pkg->tags, search)))
continue;
- if ((filter & PKG_DEVEL) && !opkg_is_devel_pkg (pkg))
+ if ((filters & PK_FILTER_ENUM_DEVEL) && !opkg_is_devel_pkg (pkg))
continue;
- if ((filter & PKG_NOT_DEVEL) && opkg_is_devel_pkg (pkg))
+ if ((filters & PK_FILTER_ENUM_NOT_DEVEL) && opkg_is_devel_pkg (pkg))
continue;
- if ((filter & PKG_GUI) && !opkg_is_gui_pkg (pkg))
+ if ((filters & PK_FILTER_ENUM_GUI) && !opkg_is_gui_pkg (pkg))
continue;
- if ((filter & PKG_NOT_GUI) && opkg_is_gui_pkg (pkg))
+ if ((filters & PK_FILTER_ENUM_NOT_GUI) && opkg_is_gui_pkg (pkg))
continue;
- if ((filter & PKG_INSTALLED) && (pkg->state_status == SS_NOT_INSTALLED))
+ if ((filters & PK_FILTER_ENUM_INSTALLED) && (pkg->state_status == SS_NOT_INSTALLED))
continue;
- if ((filter & PKG_NOT_INSTALLED) && (pkg->state_status != SS_NOT_INSTALLED))
+ if ((filters & PK_FILTER_ENUM_NOT_INSTALLED) && (pkg->state_status != SS_NOT_INSTALLED))
continue;
version = pkg_version_str_alloc (pkg);
@@ -582,7 +538,7 @@ backend_search_thread (PkBackendThread *thread, SearchParams *params)
}
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
SearchParams *params;
@@ -592,7 +548,7 @@ backend_search_name (PkBackend *backend, const gchar *filter, const gchar *searc
pk_backend_no_percentage_updates (backend);
params = g_new0 (SearchParams, 1);
- params->filter = parse_filter (filter);
+ params->filters = filters;
params->search_type = SEARCH_NAME;
params->needle = g_strdup (search);
@@ -603,7 +559,7 @@ backend_search_name (PkBackend *backend, const gchar *filter, const gchar *searc
* backend_search_description:
*/
static void
-backend_search_description (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_description (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
SearchParams *params;
@@ -613,7 +569,7 @@ backend_search_description (PkBackend *backend, const gchar *filter, const gchar
pk_backend_no_percentage_updates (backend);
params = g_new0 (SearchParams, 1);
- params->filter = parse_filter (filter);
+ params->filters = filters;
params->search_type = SEARCH_DESCRIPTION;
params->needle = g_strdup (search);
@@ -621,7 +577,7 @@ backend_search_description (PkBackend *backend, const gchar *filter, const gchar
}
static void
-backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
SearchParams *params;
@@ -631,7 +587,7 @@ backend_search_group (PkBackend *backend, const gchar *filter, const gchar *sear
pk_backend_no_percentage_updates (backend);
params = g_new0 (SearchParams, 1);
- params->filter = parse_filter (filter);
+ params->filters = filters;
params->search_type = SEARCH_TAG;
params->needle = g_strdup_printf ("group::%s", search);
@@ -894,7 +850,7 @@ backend_get_depends_thread (PkBackendThread *thread, gchar *package_id)
}
static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_depends (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
/* TODO: revursive is ignored */
g_return_if_fail (backend != NULL);
@@ -1018,7 +974,7 @@ backend_get_updates_thread (PkBackendThread *thread, gpointer data)
}
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
diff --git a/backends/pisi/pk-backend-pisi.c b/backends/pisi/pk-backend-pisi.c
index ccd38a9..d9fb100 100644
--- a/backends/pisi/pk-backend-pisi.c
+++ b/backends/pisi/pk-backend-pisi.c
@@ -124,11 +124,14 @@ backend_cancel (PkBackend *backend)
* backend_get_depends:
*/
static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_depends (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-depends.py", filter, package_id, pk_backend_bool_to_text (recursive), NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-depends.py", filters_text, package_id, pk_backend_bool_to_text (recursive), NULL);
+ g_free (filters_text);
}
/**
@@ -157,22 +160,28 @@ backend_get_files (PkBackend *backend, const gchar *package_id)
* backend_get_requires:
*/
static void
-backend_get_requires (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_requires (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-requires.py", filter, package_id, pk_backend_bool_to_text (recursive), NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-requires.py", filters_text, package_id, pk_backend_bool_to_text (recursive), NULL);
+ g_free (filters_text);
}
/**
* backend_get_updates:
*/
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-updates.py", filter, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-updates.py", filters_text, NULL);
+ g_free (filters_text);
}
/**
@@ -239,44 +248,56 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
* pk_backend_search_details:
*/
static void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-details.py", filter, search, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-details.py", filters_text, search, NULL);
+ g_free (filters_text);
}
/**
* pk_backend_search_file:
*/
static void
-backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_file (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-file.py", filter, search, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-file.py", filters_text, search, NULL);
+ g_free (filters_text);
}
/**
* pk_backend_search_group:
*/
static void
-backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-group.py", filter, search, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-group.py", filters_text, search, NULL);
+ g_free (filters_text);
}
/**
* pk_backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-name.py", filter, search, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-name.py", filters_text, search, NULL);
+ g_free (filters_text);
}
/**
@@ -318,22 +339,28 @@ backend_update_system (PkBackend *backend)
* pk_backend_resolve:
*/
static void
-backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
+backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package_id)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "resolve.py", filter, package_id, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "resolve.py", filters_text, package_id, NULL);
+ g_free (filters_text);
}
/**
* pk_backend_get_repo_list:
*/
static void
-backend_get_repo_list (PkBackend *backend, const gchar *filter)
+backend_get_repo_list (PkBackend *backend, PkFilterEnum filters)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-repo-list.py", filter, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-repo-list.py", filters_text, NULL);
+ g_free (filters_text);
}
/**
diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index b7823d8..f139134 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -21,7 +21,6 @@
#include <pk-backend.h>
#include <pk-backend-thread.h>
-#include <pk-filter.h>
#include <pk-network.h>
#include <pk-package-ids.h>
@@ -57,14 +56,14 @@ enum {
typedef struct {
gint mode;
- PkFilter *filter;
+ PkFilterEnum filters;
gchar *search;
} SearchData;
/* used by GetDepends and GetRequires */
typedef struct {
gchar *package_id;
- PkFilter *filter;
+ PkFilterEnum filters;
gboolean recursive;
} DepsData;
@@ -597,7 +596,7 @@ do_requires (tn_array *installed, tn_array *available, tn_array *requires, struc
tmp = n_array_new (2, NULL, NULL);
- if (data->filter->installed) {
+ if (pk_enums_contain (data->filters, PK_FILTER_ENUM_INSTALLED)) {
for (i = 0; i < n_array_size (installed); i++) {
struct pkg *ipkg = n_array_nth (installed, i);
int j;
@@ -630,7 +629,7 @@ do_requires (tn_array *installed, tn_array *available, tn_array *requires, struc
}
}
}
- if (data->filter->not_installed) {
+ if (pk_enums_contain (data->filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
for (i = 0; i < n_array_size (available); i++) {
struct pkg *apkg = n_array_nth (available, i);
int j;
@@ -664,7 +663,7 @@ do_requires (tn_array *installed, tn_array *available, tn_array *requires, struc
}
/* FIXME: recursive takes too much time for available packages, so don't use it */
- if (!data->filter->not_installed) {
+ if (!pk_enums_contain (data->filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
if (data->recursive && tmp && n_array_size (tmp) > 0) {
for (i = 0; i < n_array_size (tmp); i++) {
struct pkg *p = n_array_nth (tmp, i);
@@ -727,7 +726,7 @@ do_depends (tn_array *installed, tn_array *available, tn_array *depends, struct
continue;
/* first check in installed packages */
- if (data->filter->installed) {
+ if (pk_enums_contain (data->filters, PK_FILTER_ENUM_INSTALLED)) {
for (j = 0; j < n_array_size (installed); j++) {
struct pkg *p = n_array_nth (installed, j);
@@ -744,7 +743,7 @@ do_depends (tn_array *installed, tn_array *available, tn_array *depends, struct
continue;
/* ... now available */
- if (data->filter->not_installed) {
+ if (pk_enums_contain (data->filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
for (j = 0; j < n_array_size (available); j++) {
struct pkg *p = n_array_nth (available, j);
@@ -925,7 +924,7 @@ search_package (PkBackendThread *thread, gpointer data)
gchar *command = NULL;
tn_array *pkgs = NULL, *installed = NULL, *available = NULL;
- if (d->filter->installed)
+ if (pk_enums_contain (d->filters, PK_FILTER_ENUM_INSTALLED))
{
command = g_strdup_printf ("cd /installed; %s *%s*", search_inst, d->search);
if (poclidek_rcmd_execline (cmd, command)) {
@@ -943,7 +942,7 @@ search_package (PkBackendThread *thread, gpointer data)
g_free (command);
}
- if (d->filter->not_installed)
+ if (pk_enums_contain (d->filters, PK_FILTER_ENUM_NOT_INSTALLED))
{
command = g_strdup_printf ("cd /all-avail; %s *%s*", search_inst, d->search);
if (poclidek_rcmd_execline (cmd, command))
@@ -952,7 +951,9 @@ search_package (PkBackendThread *thread, gpointer data)
g_free (command);
}
- if (d->filter->installed && d->filter->not_installed && installed && available) {
+ if (pk_enums_contain (d->filters, PK_FILTER_ENUM_INSTALLED) &&
+ pk_enums_contain (d->filters, PK_FILTER_ENUM_NOT_INSTALLED) &&
+ installed && available) {
gint i;
pkgs = installed;
@@ -972,7 +973,7 @@ search_package (PkBackendThread *thread, gpointer data)
n_array_sort_ex(pkgs, (tn_fn_cmp)pkg_cmp_name_evr_rev_recno);
n_array_free (available);
- } else if (!d->filter->installed || available) {
+ } else if (!pk_enums_contain (d->filters, PK_FILTER_ENUM_INSTALLED) || available) {
gint i;
pkgs = available;
@@ -982,37 +983,39 @@ search_package (PkBackendThread *thread, gpointer data)
poldek_pkg_set_installed (pkg, FALSE);
}
- } else if (!d->filter->not_installed || installed)
+ } else if (!pk_enums_contain (d->filters, PK_FILTER_ENUM_NOT_INSTALLED) || installed)
pkgs = installed;
if (pkgs) {
gint i;
- if (d->filter->not_newest == FALSE)
+ if (pk_enums_contain (d->filters, PK_FILTER_ENUM_NOT_NEWEST) == FALSE)
do_newest (pkgs);
for (i = 0; i < n_array_size (pkgs); i++) {
struct pkg *pkg = n_array_nth (pkgs, i);
/* development filter */
- if (!d->filter->devel || !d->filter->not_devel) {
+ if (!pk_enums_contain (d->filters, PK_FILTER_ENUM_DEVELOPMENT) ||
+ !pk_enums_contain (d->filters, PK_FILTER_ENUM_NOT_DEVELOPMENT)) {
/* devel in filter */
- if (d->filter->devel && !poldek_pkg_is_devel (pkg))
+ if (pk_enums_contain (d->filters, PK_FILTER_ENUM_DEVELOPMENT) && !poldek_pkg_is_devel (pkg))
continue;
/* ~devel in filter */
- if (d->filter->not_devel && poldek_pkg_is_devel (pkg))
+ if (pk_enums_contain (d->filters, PK_FILTER_ENUM_NOT_DEVELOPMENT) && poldek_pkg_is_devel (pkg))
continue;
}
/* gui filter */
- if (!d->filter->gui || !d->filter->not_gui) {
+ if (!pk_enums_contain (d->filters, PK_FILTER_ENUM_GUI) ||
+ !pk_enums_contain (d->filters, PK_FILTER_ENUM_NOT_GUI)) {
/* gui in filter */
- if (d->filter->gui && !poldek_pkg_is_gui (pkg))
+ if (pk_enums_contain (d->filters, PK_FILTER_ENUM_GUI) && !poldek_pkg_is_gui (pkg))
continue;
/* ~gui in filter */
- if (d->filter->not_gui && poldek_pkg_is_gui (pkg))
+ if (pk_enums_contain (d->filters, PK_FILTER_ENUM_NOT_GUI) && poldek_pkg_is_gui (pkg))
continue;
}
@@ -1028,7 +1031,6 @@ search_package (PkBackendThread *thread, gpointer data)
poclidek_rcmd_free (cmd);
}
- pk_filter_free (d->filter);
g_free (d->search);
g_free (d);
@@ -1182,7 +1184,6 @@ backend_get_depends_thread (PkBackendThread *thread, gpointer data)
n_array_free (installed);
g_free (d->package_id);
- pk_filter_free (d->filter);
g_free (d);
pk_backend_finished (backend);
@@ -1191,7 +1192,7 @@ backend_get_depends_thread (PkBackendThread *thread, gpointer data)
}
static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_depends (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
DepsData *data = g_new0 (DepsData, 1);
@@ -1200,7 +1201,7 @@ backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *packa
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
data->package_id = g_strdup (package_id);
- data->filter = pk_filter_new_from_string (filter);
+ data->filters = filters;
data->recursive = recursive;
pk_backend_thread_create (thread, backend_get_depends_thread, data);
}
@@ -1383,7 +1384,6 @@ backend_get_requires_thread (PkBackendThread *thread, gpointer data)
n_array_free (available);
g_free (d->package_id);
- pk_filter_free (d->filter);
g_free (d);
pk_backend_finished (backend);
@@ -1392,7 +1392,7 @@ backend_get_requires_thread (PkBackendThread *thread, gpointer data)
}
static void
-backend_get_requires (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_requires (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
DepsData *data = g_new0 (DepsData, 1);
@@ -1401,7 +1401,7 @@ backend_get_requires (PkBackend *backend, const gchar *filter, const gchar *pack
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
data->package_id = g_strdup (package_id);
- data->filter = pk_filter_new_from_string (filter);
+ data->filters = filters;
data->recursive = recursive;
pk_backend_thread_create (thread, backend_get_requires_thread, data);
}
@@ -1539,7 +1539,7 @@ backend_get_updates_thread (PkBackendThread *thread, gpointer data)
}
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
@@ -1765,7 +1765,7 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
* backend_resolve:
*/
static void
-backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package)
+backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package)
{
SearchData *data = g_new0 (SearchData, 1);
@@ -1774,7 +1774,7 @@ backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package)
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
data->mode = SEARCH_ENUM_NAME;
- data->filter = pk_filter_new_from_string (filter);
+ data->filters = filters;
data->search = g_strdup (package);
pk_backend_thread_create (thread, search_package, data);
}
@@ -1783,7 +1783,7 @@ backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package)
* backend_search_details:
*/
static void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
SearchData *data = g_new0 (SearchData, 1);
@@ -1792,7 +1792,7 @@ backend_search_details (PkBackend *backend, const gchar *filter, const gchar *se
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
data->mode = SEARCH_ENUM_DETAILS;
- data->filter = pk_filter_new_from_string (filter);
+ data->filters = filters;
data->search = g_strdup (search);
pk_backend_thread_create (thread, search_package, data);
}
@@ -1801,7 +1801,7 @@ backend_search_details (PkBackend *backend, const gchar *filter, const gchar *se
* backend_search_file:
*/
static void
-backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_file (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
SearchData *data = g_new0 (SearchData, 1);
@@ -1810,7 +1810,7 @@ backend_search_file (PkBackend *backend, const gchar *filter, const gchar *searc
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
data->mode = SEARCH_ENUM_FILE;
- data->filter = pk_filter_new_from_string (filter);
+ data->filters = filters;
data->search = g_strdup (search);
pk_backend_thread_create (thread, search_package, data);
}
@@ -1819,7 +1819,7 @@ backend_search_file (PkBackend *backend, const gchar *filter, const gchar *searc
* backend_search_group:
*/
static void
-backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
SearchData *data = g_new0 (SearchData, 1);
@@ -1828,7 +1828,7 @@ backend_search_group (PkBackend *backend, const gchar *filter, const gchar *sear
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
data->mode = SEARCH_ENUM_GROUP;
- data->filter = pk_filter_new_from_string (filter);
+ data->filters = filters;
data->search = g_strdup (search);
pk_backend_thread_create (thread, search_package, data);
}
@@ -1837,7 +1837,7 @@ backend_search_group (PkBackend *backend, const gchar *filter, const gchar *sear
* backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
SearchData *data = g_new0 (SearchData, 1);
@@ -1846,7 +1846,7 @@ backend_search_name (PkBackend *backend, const gchar *filter, const gchar *searc
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
data->mode = SEARCH_ENUM_NAME;
- data->filter = pk_filter_new_from_string (filter);
+ data->filters = filters;
data->search = g_strdup (search);
pk_backend_thread_create (thread, search_package, data);
}
@@ -1963,7 +1963,7 @@ backend_update_packages (PkBackend *backend, gchar **package_ids)
* backend_get_repo_list:
*/
static void
-backend_get_repo_list (PkBackend *backend, const gchar *filter)
+backend_get_repo_list (PkBackend *backend, PkFilterEnum filters)
{
tn_array *sources = NULL;
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index af0a83a..87981d5 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -61,12 +61,15 @@ backend_destroy (PkBackend *backend)
* backend_get_depends:
*/
static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_depends (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
/* FIXME: Use recursive and filter here */
+ filters_text = pk_filter_enums_to_text (filters);
pk_backend_spawn_helper (spawn, "get-depends.py", package_id, NULL);
+ g_free (filters_text);
}
/**
@@ -95,11 +98,14 @@ backend_get_files (PkBackend *backend, const gchar *package_id)
* backend_get_updates:
*/
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-updates.py", filter, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-updates.py", filters_text, NULL);
+ g_free (filters_text);
}
/**
@@ -167,33 +173,42 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
* pk_backend_resolve:
*/
static void
-backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
+backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package_id)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "resolve.py", filter, package_id, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "resolve.py", filters_text, package_id, NULL);
+ g_free (filters_text);
}
/**
* pk_backend_search_details:
*/
static void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-details.py", filter, search, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-details.py", filters_text, search, NULL);
+ g_free (filters_text);
}
/**
* pk_backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-name.py", filter, search, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-name.py", filters_text, search, NULL);
+ g_free (filters_text);
}
/**
@@ -235,11 +250,14 @@ backend_update_system (PkBackend *backend)
* pk_backend_get_repo_list:
*/
static void
-backend_get_repo_list (PkBackend *backend, const gchar *filter)
+backend_get_repo_list (PkBackend *backend, PkFilterEnum filters)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-repo-list.py", filter, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-repo-list.py", filters_text, NULL);
+ g_free (filters_text);
}
/**
diff --git a/backends/test/pk-backend-test-dbus.c b/backends/test/pk-backend-test-dbus.c
index a1e1a53..2005d29 100644
--- a/backends/test/pk-backend-test-dbus.c
+++ b/backends/test/pk-backend-test-dbus.c
@@ -33,12 +33,12 @@ static PkBackendDbus *dbus;
* backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_set_allow_cancel (backend, TRUE);
pk_backend_no_percentage_updates (backend);
- pk_backend_dbus_search_name (dbus, filter, search);
+ pk_backend_dbus_search_name (dbus, filters, search);
}
/**
diff --git a/backends/test/pk-backend-test-fail.c b/backends/test/pk-backend-test-fail.c
index deb8761..18b8fb4 100644
--- a/backends/test/pk-backend-test-fail.c
+++ b/backends/test/pk-backend-test-fail.c
@@ -84,7 +84,7 @@ backend_cancel (PkBackend *backend)
* backend_get_depends:
*/
static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_depends (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -114,7 +114,7 @@ backend_get_files (PkBackend *backend, const gchar *package_id)
* backend_get_requires:
*/
static void
-backend_get_requires (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_requires (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -134,7 +134,7 @@ backend_get_update_detail (PkBackend *backend, const gchar *package_id)
* backend_get_updates:
*/
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -184,7 +184,7 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
* backend_resolve:
*/
static void
-backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
+backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -204,7 +204,7 @@ backend_rollback (PkBackend *backend, const gchar *package_id)
* backend_search_details:
*/
static void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -214,7 +214,7 @@ backend_search_details (PkBackend *backend, const gchar *filter, const gchar *se
* backend_search_file:
*/
static void
-backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_file (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
@@ -228,7 +228,7 @@ backend_search_file (PkBackend *backend, const gchar *filter, const gchar *searc
* backend_search_group:
*/
static void
-backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -238,7 +238,7 @@ backend_search_group (PkBackend *backend, const gchar *filter, const gchar *sear
* backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
diff --git a/backends/test/pk-backend-test-spawn.c b/backends/test/pk-backend-test-spawn.c
index 5dc8f66..e69b4c9 100644
--- a/backends/test/pk-backend-test-spawn.c
+++ b/backends/test/pk-backend-test-spawn.c
@@ -31,12 +31,15 @@ static PkBackendSpawn *spawn;
* backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
pk_backend_set_allow_cancel (backend, TRUE);
pk_backend_no_percentage_updates (backend);
- pk_backend_spawn_helper (spawn, "search-name.sh", filter, search, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-name.sh", filters_text, search, NULL);
+ g_free (filters_text);
}
/**
diff --git a/backends/test/pk-backend-test-succeed.c b/backends/test/pk-backend-test-succeed.c
index 0b27b71..0097ffb 100644
--- a/backends/test/pk-backend-test-succeed.c
+++ b/backends/test/pk-backend-test-succeed.c
@@ -81,7 +81,7 @@ backend_cancel (PkBackend *backend)
* backend_get_depends:
*/
static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_depends (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -111,7 +111,7 @@ backend_get_files (PkBackend *backend, const gchar *package_id)
* backend_get_requires:
*/
static void
-backend_get_requires (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_requires (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -131,7 +131,7 @@ backend_get_update_detail (PkBackend *backend, const gchar *package_id)
* backend_get_updates:
*/
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -192,7 +192,7 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
* backend_resolve:
*/
static void
-backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
+backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -212,7 +212,7 @@ backend_rollback (PkBackend *backend, const gchar *transaction_id)
* backend_search_details:
*/
static void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -222,7 +222,7 @@ backend_search_details (PkBackend *backend, const gchar *filter, const gchar *se
* backend_search_file:
*/
static void
-backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_file (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -232,7 +232,7 @@ backend_search_file (PkBackend *backend, const gchar *filter, const gchar *searc
* backend_search_group:
*/
static void
-backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -255,7 +255,7 @@ backend_search_name_timeout (gpointer data)
* A really long wait........
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_no_percentage_updates (backend);
@@ -286,7 +286,7 @@ backend_update_system (PkBackend *backend)
* backend_get_repo_list:
*/
static void
-backend_get_repo_list (PkBackend *backend, const gchar *filter)
+backend_get_repo_list (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -326,7 +326,7 @@ backend_service_pack (PkBackend *backend, const gchar *location, gboolean enable
* backend_what_provides:
*/
static void
-backend_what_provides (PkBackend *backend, const gchar *filter, PkProvidesEnum provides, const gchar *search)
+backend_what_provides (PkBackend *backend, PkFilterEnum filters, PkProvidesEnum provides, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
@@ -336,7 +336,7 @@ backend_what_provides (PkBackend *backend, const gchar *filter, PkProvidesEnum p
* backend_get_packages:
*/
static void
-backend_get_packages (PkBackend *backend, const gchar *filter)
+backend_get_packages (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
pk_backend_finished (backend);
diff --git a/backends/test/pk-backend-test-thread.c b/backends/test/pk-backend-test-thread.c
index 0a8b4c1..a74afe1 100644
--- a/backends/test/pk-backend-test-thread.c
+++ b/backends/test/pk-backend-test-thread.c
@@ -78,7 +78,7 @@ backend_search_group_thread (PkBackendThread *thread, gpointer data)
* backend_search_group:
*/
static void
-backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_thread_create (thread, backend_search_group_thread, NULL);
@@ -125,7 +125,7 @@ backend_search_name_thread (PkBackendThread *thread, gpointer data)
* backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
pk_backend_thread_create (thread, backend_search_name_thread, NULL);
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 2ef1ef6..511485f 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -126,11 +126,14 @@ backend_cancel (PkBackend *backend)
* backend_get_depends:
*/
static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_depends (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-depends.py", filter, package_id, pk_backend_bool_to_text (recursive), NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-depends.py", filters_text, package_id, pk_backend_bool_to_text (recursive), NULL);
+ g_free (filters_text);
}
/**
@@ -159,22 +162,28 @@ backend_get_files (PkBackend *backend, const gchar *package_id)
* backend_get_requires:
*/
static void
-backend_get_requires (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_requires (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-requires.py", filter, package_id, pk_backend_bool_to_text (recursive), NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-requires.py", filters_text, package_id, pk_backend_bool_to_text (recursive), NULL);
+ g_free (filters_text);
}
/**
* backend_get_updates:
*/
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-updates.py", filter, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-updates.py", filters_text, NULL);
+ g_free (filters_text);
}
/**
@@ -267,44 +276,56 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
* pk_backend_search_details:
*/
static void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-details.py", filter, search, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-details.py", filters_text, search, NULL);
+ g_free (filters_text);
}
/**
* pk_backend_search_file:
*/
static void
-backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_file (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-file.py", filter, search, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-file.py", filters_text, search, NULL);
+ g_free (filters_text);
}
/**
* pk_backend_search_group:
*/
static void
-backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-group.py", filter, search, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-group.py", filters_text, search, NULL);
+ g_free (filters_text);
}
/**
* pk_backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "search-name.py", filter, search, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "search-name.py", filters_text, search, NULL);
+ g_free (filters_text);
}
/**
@@ -346,22 +367,28 @@ backend_update_system (PkBackend *backend)
* pk_backend_resolve:
*/
static void
-backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
+backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package_id)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "resolve.py", filter, package_id, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "resolve.py", filters_text, package_id, NULL);
+ g_free (filters_text);
}
/**
* pk_backend_get_repo_list:
*/
static void
-backend_get_repo_list (PkBackend *backend, const gchar *filter)
+backend_get_repo_list (PkBackend *backend, PkFilterEnum filters)
{
+ gchar *filters_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
- pk_backend_spawn_helper (spawn, "get-repo-list.py", filter, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "get-repo-list.py", filters_text, NULL);
+ g_free (filters_text);
}
/**
@@ -394,13 +421,16 @@ backend_repo_set_data (PkBackend *backend, const gchar *rid, const gchar *parame
* backend_what_provides:
*/
static void
-backend_what_provides (PkBackend *backend, const gchar *filter, PkProvidesEnum provides, const gchar *search)
+backend_what_provides (PkBackend *backend, PkFilterEnum filters, PkProvidesEnum provides, const gchar *search)
{
+ gchar *filters_text;
const gchar *provides_text;
g_return_if_fail (backend != NULL);
g_return_if_fail (spawn != NULL);
provides_text = pk_provides_enum_to_text (provides);
- pk_backend_spawn_helper (spawn, "what-provides.py", filter, provides_text, search, NULL);
+ filters_text = pk_filter_enums_to_text (filters);
+ pk_backend_spawn_helper (spawn, "what-provides.py", filters_text, provides_text, search, NULL);
+ g_free (filters_text);
}
PK_BACKEND_OPTIONS (
diff --git a/backends/yum2/pk-backend-yum2.c b/backends/yum2/pk-backend-yum2.c
index ac72768..f5358ea 100644
--- a/backends/yum2/pk-backend-yum2.c
+++ b/backends/yum2/pk-backend-yum2.c
@@ -114,11 +114,11 @@ backend_cancel (PkBackend *backend)
* backend_get_depends:
*/
static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_depends (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (dbus != NULL);
- pk_backend_dbus_get_depends (dbus, filter, package_id, recursive);
+ pk_backend_dbus_get_depends (dbus, filters, package_id, recursive);
}
/**
@@ -147,22 +147,22 @@ backend_get_files (PkBackend *backend, const gchar *package_id)
* backend_get_requires:
*/
static void
-backend_get_requires (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_requires (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (dbus != NULL);
- pk_backend_dbus_get_requires (dbus, filter, package_id, recursive);
+ pk_backend_dbus_get_requires (dbus, filters, package_id, recursive);
}
/**
* backend_get_updates:
*/
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (dbus != NULL);
- pk_backend_dbus_get_updates (dbus, filter);
+ pk_backend_dbus_get_updates (dbus, filters);
}
/**
@@ -240,44 +240,44 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
* pk_backend_search_details:
*/
static void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (dbus != NULL);
- pk_backend_dbus_search_details (dbus, filter, search);
+ pk_backend_dbus_search_details (dbus, filters, search);
}
/**
* pk_backend_search_file:
*/
static void
-backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_file (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (dbus != NULL);
- pk_backend_dbus_search_file (dbus, filter, search);
+ pk_backend_dbus_search_file (dbus, filters, search);
}
/**
* pk_backend_search_group:
*/
static void
-backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (dbus != NULL);
- pk_backend_dbus_search_group (dbus, filter, search);
+ pk_backend_dbus_search_group (dbus, filters, search);
}
/**
* pk_backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (dbus != NULL);
- pk_backend_dbus_search_name (dbus, filter, search);
+ pk_backend_dbus_search_name (dbus, filters, search);
}
/**
@@ -314,22 +314,22 @@ backend_update_system (PkBackend *backend)
* pk_backend_resolve:
*/
static void
-backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
+backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (dbus != NULL);
- pk_backend_dbus_resolve (dbus, filter, package_id);
+ pk_backend_dbus_resolve (dbus, filters, package_id);
}
/**
* pk_backend_get_repo_list:
*/
static void
-backend_get_repo_list (PkBackend *backend, const gchar *filter)
+backend_get_repo_list (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (dbus != NULL);
- pk_backend_dbus_get_repo_list (dbus, filter);
+ pk_backend_dbus_get_repo_list (dbus, filters);
}
/**
@@ -358,11 +358,11 @@ backend_repo_set_data (PkBackend *backend, const gchar *rid, const gchar *parame
* pk_backend_what_provides:
*/
static void
-backend_what_provides (PkBackend *backend, const gchar *filter, PkProvidesEnum provides, const gchar *search)
+backend_what_provides (PkBackend *backend, PkFilterEnum filters, PkProvidesEnum provides, const gchar *search)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (dbus != NULL);
- pk_backend_dbus_what_provides (dbus, filter, provides, search);
+ pk_backend_dbus_what_provides (dbus, filters, provides, search);
}
PK_BACKEND_OPTIONS (
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index f12a1a3..66a59fc 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -25,7 +25,6 @@
#include <pk-backend-thread.h>
#include <unistd.h>
#include <pk-debug.h>
-#include <pk-filter.h>
#include <string>
#include <set>
@@ -78,18 +77,18 @@ enum DepsBehavior {
typedef struct {
gchar *search;
- gchar *filter;
+ PkFilterEnum filters;
gint mode;
} FindData;
typedef struct {
gchar *pkGroup;
- gchar *filter;
+ PkFilterEnum filters;
} GroupData;
typedef struct {
gchar *name;
- gchar *filter;
+ PkFilterEnum filters;
} ResolveData;
typedef struct {
@@ -99,7 +98,7 @@ typedef struct {
typedef struct {
gchar *package_id;
- gchar *filter;
+ PkFilterEnum filters;
gint type;
} FilterData;
@@ -182,8 +181,7 @@ backend_get_requires_thread (PkBackendThread *thread, gpointer data) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
pk_package_id_free (pi);
g_free (d->package_id);
- g_free (d->filter);
- g_free (d);
+ g_free (d);
pk_backend_finished (backend);
return FALSE;
}
@@ -210,8 +208,7 @@ backend_get_requires_thread (PkBackendThread *thread, gpointer data) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, "Package is not installed");
pk_package_id_free (pi);
g_free (d->package_id);
- g_free (d->filter);
- g_free (d);
+ g_free (d);
pk_backend_finished (backend);
return FALSE;
}
@@ -225,8 +222,7 @@ backend_get_requires_thread (PkBackendThread *thread, gpointer data) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "Package couldn't be found");
pk_package_id_free (pi);
g_free (d->package_id);
- g_free (d->filter);
- g_free (d);
+ g_free (d);
pk_backend_finished (backend);
return FALSE;
}
@@ -317,13 +313,14 @@ backend_get_requires_thread (PkBackendThread *thread, gpointer data) {
* backend_get_requires:
*/
static void
-backend_get_requires(PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive) {
+backend_get_requires(PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
+{
g_return_if_fail (backend != NULL);
FilterData *data = g_new0(FilterData, 1);
data->package_id = g_strdup(package_id);
data->type = recursive;
- data->filter = g_strdup(filter);
+ data->filters = filters;
pk_backend_thread_create (thread, backend_get_requires_thread, data);
}
@@ -530,7 +527,7 @@ backend_get_depends_thread (PkBackendThread *thread, gpointer data)
* backend_get_depends:
*/
static void
-backend_get_depends (PkBackend *backend, const gchar *filter, const gchar *package_id, gboolean recursive)
+backend_get_depends (PkBackend *backend, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
g_return_if_fail (backend != NULL);
ThreadData *data = g_new0(ThreadData, 1);
@@ -696,7 +693,7 @@ backend_get_updates_thread (PkBackendThread *thread, gpointer data)
* backend_get_updates
*/
static void
-backend_get_updates (PkBackend *backend, const gchar *filter)
+backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
g_return_if_fail (backend != NULL);
pk_backend_thread_create (thread, backend_get_updates_thread, NULL);
@@ -1166,7 +1163,6 @@ backend_resolve_thread (PkBackendThread *thread, gpointer data)
if (package == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "couldn't find package");
g_free (rdata->name);
- g_free (rdata->filter);
g_free (rdata);
pk_backend_finished (backend);
return FALSE;
@@ -1180,7 +1176,6 @@ backend_resolve_thread (PkBackendThread *thread, gpointer data)
package.lookupStrAttribute (zypp::sat::SolvAttr::description).c_str ());
g_free (rdata->name);
- g_free (rdata->filter);
g_free (rdata);
g_free (package_id);
pk_backend_finished (backend);
@@ -1191,32 +1186,25 @@ backend_resolve_thread (PkBackendThread *thread, gpointer data)
* backend_resolve:
*/
static void
-backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
+backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
//printf("Enter backend_resolve - filter:%s, package_id:%s\n", filter, package_id);
ResolveData *data = g_new0(ResolveData, 1);
data->name = g_strdup (package_id);
- data->filter = g_strdup (filter);
+ data->filters = filters;
pk_backend_thread_create (thread, backend_resolve_thread, data);
}
static void
-find_packages_real (PkBackend *backend, const gchar *search, const gchar *filter_text, gint mode)
+find_packages_real (PkBackend *backend, const gchar *search, PkFilterEnum filters, gint mode)
{
//GList *list = NULL;
- PkFilter *filter;
g_return_if_fail (backend != NULL);
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
- /* parse */
- filter = pk_filter_new_from_string (filter_text);
- if (filter == NULL) {
- pk_error ("filter invalid, daemon broken");
- }
-
pk_backend_no_percentage_updates (backend);
std::vector<zypp::sat::Solvable> *v = new std::vector<zypp::sat::Solvable>;
@@ -1236,36 +1224,6 @@ find_packages_real (PkBackend *backend, const gchar *search, const gchar *filter
zypp_emit_packages_in_list (backend, v);
delete (v);
-/*
- if (mode == SEARCH_TYPE_FILE) {
- if (filter->installed == FALSE && filter->not_installed == FALSE) {
- pk_backend_error_code (backend, PK_ERROR_ENUM_UNKNOWN, "invalid search mode");
- } else {
- list = box_db_repos_search_file_with_filter (db, search, search_filter);
- add_packages_from_list (backend, list, FALSE);
- box_db_repos_package_list_free (list);
- }
- } else if (mode == SEARCH_TYPE_RESOLVE) {
- list = box_db_repos_packages_search_one (db, (gchar *)search);
- add_packages_from_list (backend, list, FALSE);
- box_db_repos_package_list_free (list);
- } else {
- if (filter->installed == FALSE && filter->not_installed == FALSE) {
- pk_backend_error_code (backend, PK_ERROR_ENUM_UNKNOWN, "invalid search mode");
- } else {
- if (filter->installed == TRUE && filter->not_installed == TRUE) {
- list = box_db_repos_packages_search_all(db, (gchar *)search, search_filter);
- } else if (filter->installed == TRUE) {
- list = box_db_repos_packages_search_installed(db, (gchar *)search, search_filter);
- } else if (filter->not_installed == TRUE) {
- list = box_db_repos_packages_search_available(db, (gchar *)search, search_filter);
- }
- add_packages_from_list (backend, list, FALSE);
- box_db_repos_package_list_free (list);
- }
- }
-*/
- pk_filter_free (filter);
}
static gboolean
@@ -1277,10 +1235,9 @@ backend_find_packages_thread (PkBackendThread *thread, gpointer data)
backend = pk_backend_thread_get_backend (thread);
g_return_val_if_fail (backend != NULL, FALSE);
- find_packages_real (backend, d->search, d->filter, d->mode);
+ find_packages_real (backend, d->search, d->filters, d->mode);
g_free(d->search);
- g_free(d->filter);
g_free(d);
pk_backend_finished (backend);
@@ -1288,14 +1245,14 @@ backend_find_packages_thread (PkBackendThread *thread, gpointer data)
}
static void
-find_packages (PkBackend *backend, const gchar *search, const gchar *filter, gint mode)
+find_packages (PkBackend *backend, const gchar *search, PkFilterEnum filters, gint mode)
{
FindData *data = g_new0(FindData, 1);
g_return_if_fail (backend != NULL);
data->search = g_strdup(search);
- data->filter = g_strdup(filter);
+ data->filters = filters;
data->mode = mode;
pk_backend_thread_create (thread, backend_find_packages_thread, data);
}
@@ -1304,20 +1261,20 @@ find_packages (PkBackend *backend, const gchar *search, const gchar *filter, gin
* backend_search_name:
*/
static void
-backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
- find_packages (backend, search, filter, SEARCH_TYPE_NAME);
+ find_packages (backend, search, filters, SEARCH_TYPE_NAME);
}
/**
* backend_search_details:
*/
static void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
- find_packages (backend, search, filter, SEARCH_TYPE_DETAILS);
+ find_packages (backend, search, filters, SEARCH_TYPE_DETAILS);
}
static gboolean
@@ -1330,7 +1287,6 @@ backend_search_group_thread (PkBackendThread *thread, gpointer data)
if (d->pkGroup == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_GROUP_NOT_FOUND, "Group is invalid.");
- g_free (d->filter);
g_free (d->pkGroup);
g_free (d);
pk_backend_finished (backend);
@@ -1363,7 +1319,6 @@ backend_search_group_thread (PkBackendThread *thread, gpointer data)
pk_backend_set_percentage (backend, 100);
- g_free (d->filter);
g_free (d->pkGroup);
g_free (d);
pk_backend_finished (backend);
@@ -1375,13 +1330,13 @@ backend_search_group_thread (PkBackendThread *thread, gpointer data)
* backend_search_group:
*/
static void
-backend_search_group (PkBackend *backend, const gchar *filter, const gchar *pkGroup)
+backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *pkGroup)
{
g_return_if_fail (backend != NULL);
GroupData *data = g_new0(GroupData, 1);
data->pkGroup = g_strdup(pkGroup);
- data->filter = g_strdup(filter);
+ data->filters = filters;
pk_backend_thread_create (thread, backend_search_group_thread, data);
}
@@ -1389,17 +1344,17 @@ backend_search_group (PkBackend *backend, const gchar *filter, const gchar *pkGr
* backend_search_file:
*/
static void
-backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+backend_search_file (PkBackend *backend, PkFilterEnum filters, const gchar *search)
{
g_return_if_fail (backend != NULL);
- find_packages (backend, search, filter, SEARCH_TYPE_FILE);
+ find_packages (backend, search, filters, SEARCH_TYPE_FILE);
}
/**
* backend_get_repo_list:
*/
static void
-backend_get_repo_list (PkBackend *backend, const gchar *filter)
+backend_get_repo_list (PkBackend *backend, PkFilterEnum filters)
{
//Fixme - use the new param - filter
@@ -1741,7 +1696,6 @@ backend_what_provides_thread (PkBackendThread *thread, gpointer data) {
pk_backend_package (backend, info, package_id, it->lookupStrAttribute (zypp::sat::SolvAttr::summary).c_str ());
}
- g_free (d->filter);
g_free (d->name);
g_free (d);
pk_backend_finished (backend);
@@ -1753,13 +1707,13 @@ backend_what_provides_thread (PkBackendThread *thread, gpointer data) {
* backend_what_provides
*/
static void
-backend_what_provides(PkBackend *backend, const gchar *filter, PkProvidesEnum provide, const gchar *search)
+backend_what_provides(PkBackend *backend, PkFilterEnum filters, PkProvidesEnum provide, const gchar *search)
{
g_return_if_fail (backend != NULL);
ResolveData *data = g_new0(ResolveData, 1);
data->name = g_strdup(search);
- data->filter = g_strdup(filter);
+ data->filters = filters;
pk_backend_thread_create (thread, backend_what_provides_thread, data);
}
diff --git a/libpackagekit/Makefile.am b/libpackagekit/Makefile.am
index b3859bf..ad28599 100644
--- a/libpackagekit/Makefile.am
+++ b/libpackagekit/Makefile.am
@@ -43,7 +43,6 @@ libpackagekit_include_HEADERS = \
pk-package-list.h \
pk-enum.h \
pk-common.h \
- pk-filter.h \
pk-client.h \
pk-control.h \
pk-task-list.h \
@@ -72,8 +71,6 @@ libpackagekit_la_SOURCES = \
pk-enum.c \
pk-common.c \
pk-common.h \
- pk-filter.c \
- pk-filter.h \
pk-client.c \
pk-client.h \
pk-control.c \
diff --git a/libpackagekit/pk-filter.c b/libpackagekit/pk-filter.c
deleted file mode 100644
index 37dabd5..0000000
--- a/libpackagekit/pk-filter.c
+++ /dev/null
@@ -1,515 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007-2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:pk-filter
- * @short_description: Common filter functions for PackageKit
- *
- * This file contains functions that may be useful.
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <string.h>
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
-#include <glib/gi18n.h>
-
-#include "pk-debug.h"
-#include "pk-filter.h"
-#include "pk-common.h"
-#include "pk-enum.h"
-
-/**
- * pk_filter_check:
- * @filter: A text failter to test
- *
- * Tests a compound filter to see if every element is correct and if it well
- * formed.
- *
- * Return value: %TRUE if the filter is valid
- **/
-gboolean
-pk_filter_check (const gchar *filter)
-{
- gchar **sections;
- guint i;
- guint length;
- gboolean ret;
-
- if (filter == NULL) {
- pk_warning ("filter null");
- return FALSE;
- }
- if (pk_strzero (filter)) {
- pk_warning ("filter zero length");
- return FALSE;
- }
-
- /* split by delimeter ';' */
- sections = g_strsplit (filter, ";", 0);
- length = g_strv_length (sections);
- ret = FALSE;
- for (i=0; i<length; i++) {
- /* only one wrong part is enough to fail the filter */
- if (pk_strzero (sections[i])) {
- goto out;
- }
- if (pk_filter_enum_from_text (sections[i]) == PK_FILTER_ENUM_UNKNOWN) {
- goto out;
- }
- }
- ret = TRUE;
-out:
- g_strfreev (sections);
- return ret;
-}
-
-/**
- * pk_filter_set_all:
- * @filter: the #PkFilter object
- *
- * Return value: %TRUE if the #PkFilter object was reset.
- **/
-gboolean
-pk_filter_set_all (PkFilter *filter, gboolean value)
-{
- if (filter == NULL) {
- pk_warning ("no filter");
- return FALSE;
- }
- filter->installed = value;
- filter->not_installed = value;
- filter->devel = value;
- filter->not_devel = value;
- filter->gui = value;
- filter->not_gui = value;
- filter->supported = value;
- filter->not_supported = value;
- filter->visible = value;
- filter->not_visible = value;
- filter->basename = value;
- filter->not_basename = value;
- filter->newest = value;
- filter->not_newest = value;
- return TRUE;
-}
-
-/**
- * pk_filter_new:
- *
- * Creates a new #PkFilter object with default values
- *
- * Return value: a new #PkFilter object
- **/
-PkFilter *
-pk_filter_new (void)
-{
- PkFilter *filter;
- filter = g_new0 (PkFilter, 1);
- pk_filter_set_all (filter, FALSE);
- return filter;
-}
-
-/**
- * pk_filter_new_from_string:
- * @filter: the text to pre-fill the object
- *
- * Creates a new #PkFilter object with values taken from the supplied id.
- *
- * Return value: a new #PkFilter object, or NULL in event of an error
- **/
-PkFilter *
-pk_filter_new_from_string (const gchar *filter_text)
-{
- gchar **sections;
- PkFilter *filter = NULL;
- gboolean ret = TRUE;
- guint i = 0;
-
- /* check for nothing */
- if (pk_strzero (filter_text)) {
- pk_warning ("invalid blank filter (do you mean 'none'?)");
- return NULL;
- }
-
- /* check for nothing */
- if (pk_strequal (filter_text, "none")) {
- pk_debug ("shortcut for speed");
- filter = pk_filter_new ();
- /* 'none' is a really bad name, it should really be 'all' */
- pk_filter_set_all (filter, TRUE);
- return filter;
- }
-
- sections = g_strsplit (filter_text, ";", -1);
- if (sections == NULL) {
- pk_warning ("failed to split");
- return NULL;
- }
-
- /* create new object, all set FALSE */
- filter = pk_filter_new ();
-
- /* by default we pass something, unless it's present in the negative */
- pk_filter_set_all (filter, TRUE);
-
- while (sections[i]) {
- if (pk_strequal (sections[i], "installed")) {
- filter->not_installed = FALSE;
- } else if (pk_strequal (sections[i], "~installed")) {
- filter->installed = FALSE;
- } else if (pk_strequal (sections[i], "devel")) {
- filter->not_devel = FALSE;
- } else if (pk_strequal (sections[i], "~devel")) {
- filter->devel = FALSE;
- } else if (pk_strequal (sections[i], "gui")) {
- filter->not_gui = FALSE;
- } else if (pk_strequal (sections[i], "~gui")) {
- filter->gui = FALSE;
- } else if (pk_strequal (sections[i], "supported")) {
- filter->not_supported = FALSE;
- } else if (pk_strequal (sections[i], "~supported")) {
- filter->supported = FALSE;
- } else if (pk_strequal (sections[i], "visible")) {
- filter->not_visible = FALSE;
- } else if (pk_strequal (sections[i], "~visible")) {
- filter->visible = FALSE;
- } else if (pk_strequal (sections[i], "basename")) {
- filter->not_basename = FALSE;
- } else if (pk_strequal (sections[i], "~basename")) {
- filter->basename = FALSE;
- } else if (pk_strequal (sections[i], "newest")) {
- filter->not_newest = FALSE;
- } else if (pk_strequal (sections[i], "~newest")) {
- filter->newest = FALSE;
- } else {
- pk_warning ("element '%s' not recognised", sections[i]);
- ret = FALSE;
- }
- i++;
- }
-
- /* failed parsing */
- if (!ret) {
- pk_warning ("invalid filter '%s'", filter_text);
- pk_filter_free (filter);
- filter = NULL;
- goto out;
- }
-
- /* all OK */
-out:
- g_strfreev (sections);
- return filter;
-}
-
-/**
- * pk_filter_to_string:
- * @filter: A #PkFilter object
- *
- * Return value: returns a string representation of #PkFilter.
- **/
-gchar *
-pk_filter_to_string (PkFilter *filter)
-{
- GString *string;
- gchar *filter_text;
-
- if (filter == NULL) {
- pk_warning ("no filter");
- return NULL;
- }
-
- string = g_string_new ("");
- if (filter->installed && !filter->not_installed) {
- g_string_append (string, "installed;");
- }
- if (filter->not_installed && !filter->installed) {
- g_string_append (string, "~installed;");
- }
- if (filter->devel && !filter->not_devel) {
- g_string_append (string, "devel;");
- }
- if (filter->not_devel && !filter->devel) {
- g_string_append (string, "~devel;");
- }
- if (filter->gui && !filter->not_gui) {
- g_string_append (string, "gui;");
- }
- if (filter->not_gui && !filter->gui) {
- g_string_append (string, "~gui;");
- }
- if (filter->supported && !filter->not_supported) {
- g_string_append (string, "supported;");
- }
- if (filter->not_supported && !filter->supported) {
- g_string_append (string, "~supported;");
- }
- if (filter->visible && !filter->not_visible) {
- g_string_append (string, "visible;");
- }
- if (filter->not_visible && !filter->visible) {
- g_string_append (string, "~visible;");
- }
- if (filter->basename && !filter->not_basename) {
- g_string_append (string, "basename;");
- }
- if (filter->not_basename && !filter->basename) {
- g_string_append (string, "~basename;");
- }
- if (filter->newest && !filter->not_newest) {
- g_string_append (string, "newest;");
- }
- if (filter->not_newest && !filter->newest) {
- g_string_append (string, "~newest;");
- }
-
- /* remove trailing ; */
- if (string->len > 0) {
- g_string_set_size (string, string->len-1);
- } else {
- /* this is blank filter */
- g_string_append (string, "none");
- }
-
- filter_text = g_string_free (string, FALSE);
- return filter_text;
-}
-
-/**
- * pk_filter_free:
- * @filter: the #PkFilter object
- *
- * Return value: %TRUE if the #PkFilter object was freed.
- **/
-gboolean
-pk_filter_free (PkFilter *filter)
-{
- if (filter == NULL) {
- pk_warning ("no filter");
- return FALSE;
- }
- g_free (filter);
- return TRUE;
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef PK_BUILD_TESTS
-#include <libselftest.h>
-
-void
-libst_filter (LibSelfTest *test)
-{
- gboolean ret;
- PkFilter *filter;
- const gchar *temp;
-
- if (libst_start (test, "PkFilter", CLASS_AUTO) == FALSE) {
- return;
- }
-
- /************************************************************
- **************** FILTER OBJECT ******************
- ************************************************************/
-
- /************************************************************/
- libst_title (test, "create a blank filter");
- filter = pk_filter_new ();
- if (filter != NULL && filter->installed == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, NULL);
- }
-
- /************************************************************/
- libst_title (test, "free a blank filter");
- ret = pk_filter_free (filter);
- if (ret) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, NULL);
- }
-
- /************************************************************/
- libst_title (test, "create a filter from a string (blank)");
- filter = pk_filter_new_from_string ("none");
- if (filter != NULL && filter->installed && filter->gui &&
- filter->gui && filter->not_basename && filter->basename) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, NULL);
- }
-
- /************************************************************/
- libst_title (test, "create a string from a filter (blank)");
- temp = pk_filter_to_string (filter);
- if (pk_strequal (temp, "none")) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "filter '%s'", temp);
- }
- pk_filter_free (filter);
-
- /************************************************************/
- libst_title (test, "create a filter from a string (composite)");
- filter = pk_filter_new_from_string ("gui;~basename");
- if (filter != NULL && filter->gui && !filter->not_gui && filter->not_basename && !filter->basename) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, NULL);
- }
-
- /************************************************************/
- libst_title (test, "create a string from a filter (composite)");
- temp = pk_filter_to_string (filter);
- if (pk_strequal (temp, "gui;~basename")) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, NULL, "filter '%s'", filter);
- }
-
- /************************************************************/
- libst_title (test, "reset a filter");
- pk_filter_set_all (filter, FALSE);
- temp = pk_filter_to_string (filter);
- if (pk_strequal (temp, "none")) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, NULL);
- }
-
- pk_filter_free (filter);
-
- /************************************************************
- **************** FILTERS ******************
- ************************************************************/
- temp = NULL;
- libst_title (test, "test a fail filter (null)");
- ret = pk_filter_check (temp);
- if (ret == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "passed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "";
- libst_title (test, "test a fail filter ()");
- ret = pk_filter_check (temp);
- if (ret == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "passed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = ";";
- libst_title (test, "test a fail filter (;)");
- ret = pk_filter_check (temp);
- if (ret == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "passed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "moo";
- libst_title (test, "test a fail filter (invalid)");
- ret = pk_filter_check (temp);
- if (ret == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "passed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "moo;foo";
- libst_title (test, "test a fail filter (invalid, multiple)");
- ret = pk_filter_check (temp);
- if (ret == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "passed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "gui;;";
- libst_title (test, "test a fail filter (valid then zero length)");
- ret = pk_filter_check (temp);
- if (ret == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "passed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "none";
- libst_title (test, "test a pass filter (none)");
- ret = pk_filter_check (temp);
- if (ret) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "failed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "gui";
- libst_title (test, "test a pass filter (single)");
- ret = pk_filter_check (temp);
- if (ret) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "failed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "devel;~gui";
- libst_title (test, "test a pass filter (multiple)");
- ret = pk_filter_check (temp);
- if (ret) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "failed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "~gui;~installed";
- libst_title (test, "test a pass filter (multiple2)");
- ret = pk_filter_check (temp);
- if (ret) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "failed the filter '%s'", temp);
- }
-
- libst_end (test);
-}
-#endif
-
diff --git a/libpackagekit/pk-filter.h b/libpackagekit/pk-filter.h
deleted file mode 100644
index e3e5262..0000000
--- a/libpackagekit/pk-filter.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007-2008 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __PK_FILTER_H
-#define __PK_FILTER_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/**
- * PkFilter:
- *
- * Convenience object that is unwrapped.
- **/
-typedef struct {
- gboolean installed;
- gboolean not_installed;
- gboolean devel;
- gboolean not_devel;
- gboolean gui;
- gboolean not_gui;
- gboolean supported;
- gboolean not_supported;
- gboolean visible;
- gboolean not_visible;
- gboolean basename;
- gboolean not_basename;
- gboolean newest;
- gboolean not_newest;
-} PkFilter;
-
-gboolean pk_filter_check (const gchar *filter)
- G_GNUC_WARN_UNUSED_RESULT;
-PkFilter *pk_filter_new (void)
- G_GNUC_WARN_UNUSED_RESULT;
-PkFilter *pk_filter_new_from_string (const gchar *filter)
- G_GNUC_WARN_UNUSED_RESULT;
-gchar *pk_filter_to_string (PkFilter *filter)
- G_GNUC_WARN_UNUSED_RESULT;
-gboolean pk_filter_free (PkFilter *filter);
-gboolean pk_filter_set_all (PkFilter *filter,
- gboolean value);
-
-G_END_DECLS
-
-#endif /* __PK_FILTER_H */
diff --git a/libpackagekit/pk-self-test.c b/libpackagekit/pk-self-test.c
index 1e94065..dff6ecd 100644
--- a/libpackagekit/pk-self-test.c
+++ b/libpackagekit/pk-self-test.c
@@ -32,7 +32,6 @@ void libst_package_ids (LibSelfTest *test);
void libst_package_list (LibSelfTest *test);
void libst_enum (LibSelfTest *test);
void libst_common (LibSelfTest *test);
-void libst_filter (LibSelfTest *test);
void libst_enum_list (LibSelfTest *test);
void libst_extra (LibSelfTest *test);
void libst_extra_obj (LibSelfTest *test);
@@ -51,7 +50,6 @@ main (int argc, char **argv)
/* tests go here */
libst_common (&test);
- libst_filter (&test);
libst_package_id (&test);
libst_package_ids (&test);
libst_package_list (&test);
diff --git a/src/pk-backend-dbus.c b/src/pk-backend-dbus.c
index 1a6885f..cae34bd 100644
--- a/src/pk-backend-dbus.c
+++ b/src/pk-backend-dbus.c
@@ -511,18 +511,20 @@ pk_backend_dbus_cancel (PkBackendDbus *backend_dbus)
* pk_backend_dbus_get_updates:
**/
gboolean
-pk_backend_dbus_get_updates (PkBackendDbus *backend_dbus, const gchar *filter)
+pk_backend_dbus_get_updates (PkBackendDbus *backend_dbus, PkFilterEnum filters)
{
gboolean ret;
GError *error = NULL;
+ gchar *filters_text;
g_return_val_if_fail (PK_IS_BACKEND_DBUS (backend_dbus), FALSE);
g_return_val_if_fail (backend_dbus->priv->proxy != NULL, FALSE);
/* new sync method call */
pk_backend_dbus_time_reset (backend_dbus);
+ filters_text = pk_filter_enums_to_text (filters);
ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "GetUpdates", &error,
- G_TYPE_STRING, filter,
+ G_TYPE_STRING, filters_text,
G_TYPE_INVALID, G_TYPE_INVALID);
if (error != NULL) {
pk_warning ("%s", error->message);
@@ -533,6 +535,7 @@ pk_backend_dbus_get_updates (PkBackendDbus *backend_dbus, const gchar *filter)
if (ret) {
pk_backend_dbus_time_check (backend_dbus);
}
+ g_free (filters_text);
return ret;
}
@@ -540,18 +543,20 @@ pk_backend_dbus_get_updates (PkBackendDbus *backend_dbus, const gchar *filter)
* pk_backend_dbus_get_repo_list:
**/
gboolean
-pk_backend_dbus_get_repo_list (PkBackendDbus *backend_dbus, const gchar *filter)
+pk_backend_dbus_get_repo_list (PkBackendDbus *backend_dbus, PkFilterEnum filters)
{
gboolean ret;
GError *error = NULL;
+ gchar *filters_text;
g_return_val_if_fail (PK_IS_BACKEND_DBUS (backend_dbus), FALSE);
g_return_val_if_fail (backend_dbus->priv->proxy != NULL, FALSE);
/* new sync method call */
pk_backend_dbus_time_reset (backend_dbus);
+ filters_text = pk_filter_enums_to_text (filters);
ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "GetRepoList", &error,
- G_TYPE_STRING, filter,
+ G_TYPE_STRING, filters_text,
G_TYPE_INVALID, G_TYPE_INVALID);
if (error != NULL) {
pk_warning ("%s", error->message);
@@ -562,6 +567,7 @@ pk_backend_dbus_get_repo_list (PkBackendDbus *backend_dbus, const gchar *filter)
if (ret) {
pk_backend_dbus_time_check (backend_dbus);
}
+ g_free (filters_text);
return ret;
}
@@ -692,20 +698,21 @@ pk_backend_dbus_repo_set_data (PkBackendDbus *backend_dbus, const gchar *rid,
* pk_backend_dbus_resolve:
**/
gboolean
-pk_backend_dbus_resolve (PkBackendDbus *backend_dbus, const gchar *filter, const gchar *package)
+pk_backend_dbus_resolve (PkBackendDbus *backend_dbus, PkFilterEnum filters, const gchar *package)
{
gboolean ret;
GError *error = NULL;
+ gchar *filters_text;
g_return_val_if_fail (PK_IS_BACKEND_DBUS (backend_dbus), FALSE);
g_return_val_if_fail (backend_dbus->priv->proxy != NULL, FALSE);
- g_return_val_if_fail (filter != NULL, FALSE);
g_return_val_if_fail (package != NULL, FALSE);
/* new sync method call */
pk_backend_dbus_time_reset (backend_dbus);
+ filters_text = pk_filter_enums_to_text (filters);
ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "Resolve", &error,
- G_TYPE_STRING, filter,
+ G_TYPE_STRING, filters_text,
G_TYPE_STRING, package,
G_TYPE_INVALID, G_TYPE_INVALID);
if (error != NULL) {
@@ -717,6 +724,7 @@ pk_backend_dbus_resolve (PkBackendDbus *backend_dbus, const gchar *filter, const
if (ret) {
pk_backend_dbus_time_check (backend_dbus);
}
+ g_free (filters_text);
return ret;
}
@@ -754,20 +762,21 @@ pk_backend_dbus_rollback (PkBackendDbus *backend_dbus, const gchar *transaction_
* pk_backend_dbus_search_name:
**/
gboolean
-pk_backend_dbus_search_name (PkBackendDbus *backend_dbus, const gchar *filter, const gchar *search)
+pk_backend_dbus_search_name (PkBackendDbus *backend_dbus, PkFilterEnum filters, const gchar *search)
{
gboolean ret;
GError *error = NULL;
+ gchar *filters_text;
g_return_val_if_fail (PK_IS_BACKEND_DBUS (backend_dbus), FALSE);
g_return_val_if_fail (backend_dbus->priv->proxy != NULL, FALSE);
- g_return_val_if_fail (filter != NULL, FALSE);
g_return_val_if_fail (search != NULL, FALSE);
/* new sync method call */
pk_backend_dbus_time_reset (backend_dbus);
+ filters_text = pk_filter_enums_to_text (filters);
ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "SearchName", &error,
- G_TYPE_STRING, filter,
+ G_TYPE_STRING, filters_text,
G_TYPE_STRING, search,
G_TYPE_INVALID, G_TYPE_INVALID);
if (error != NULL) {
@@ -779,6 +788,7 @@ pk_backend_dbus_search_name (PkBackendDbus *backend_dbus, const gchar *filter, c
if (ret) {
pk_backend_dbus_time_check (backend_dbus);
}
+ g_free (filters_text);
return ret;
}
@@ -786,20 +796,21 @@ pk_backend_dbus_search_name (PkBackendDbus *backend_dbus, const gchar *filter, c
* pk_backend_dbus_search_details:
**/
gboolean
-pk_backend_dbus_search_details (PkBackendDbus *backend_dbus, const gchar *filter, const gchar *search)
+pk_backend_dbus_search_details (PkBackendDbus *backend_dbus, PkFilterEnum filters, const gchar *search)
{
gboolean ret;
GError *error = NULL;
+ gchar *filters_text;
g_return_val_if_fail (PK_IS_BACKEND_DBUS (backend_dbus), FALSE);
g_return_val_if_fail (backend_dbus->priv->proxy != NULL, FALSE);
- g_return_val_if_fail (filter != NULL, FALSE);
g_return_val_if_fail (search != NULL, FALSE);
/* new sync method call */
pk_backend_dbus_time_reset (backend_dbus);
+ filters_text = pk_filter_enums_to_text (filters);
ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "SearchDetails", &error,
- G_TYPE_STRING, filter,
+ G_TYPE_STRING, filters_text,
G_TYPE_STRING, search,
G_TYPE_INVALID, G_TYPE_INVALID);
if (error != NULL) {
@@ -811,6 +822,7 @@ pk_backend_dbus_search_details (PkBackendDbus *backend_dbus, const gchar *filter
if (ret) {
pk_backend_dbus_time_check (backend_dbus);
}
+ g_free (filters_text);
return ret;
}
@@ -818,20 +830,21 @@ pk_backend_dbus_search_details (PkBackendDbus *backend_dbus, const gchar *filter
* pk_backend_dbus_search_group:
**/
gboolean
-pk_backend_dbus_search_group (PkBackendDbus *backend_dbus, const gchar *filter, const gchar *search)
+pk_backend_dbus_search_group (PkBackendDbus *backend_dbus, PkFilterEnum filters, const gchar *search)
{
gboolean ret;
GError *error = NULL;
+ gchar *filters_text;
g_return_val_if_fail (PK_IS_BACKEND_DBUS (backend_dbus), FALSE);
g_return_val_if_fail (backend_dbus->priv->proxy != NULL, FALSE);
- g_return_val_if_fail (filter != NULL, FALSE);
g_return_val_if_fail (search != NULL, FALSE);
/* new sync method call */
pk_backend_dbus_time_reset (backend_dbus);
+ filters_text = pk_filter_enums_to_text (filters);
ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "SearchGroup", &error,
- G_TYPE_STRING, filter,
+ G_TYPE_STRING, filters_text,
G_TYPE_STRING, search,
G_TYPE_INVALID, G_TYPE_INVALID);
if (error != NULL) {
@@ -843,6 +856,7 @@ pk_backend_dbus_search_group (PkBackendDbus *backend_dbus, const gchar *filter,
if (ret) {
pk_backend_dbus_time_check (backend_dbus);
}
+ g_free (filters_text);
return ret;
}
@@ -850,20 +864,21 @@ pk_backend_dbus_search_group (PkBackendDbus *backend_dbus, const gchar *filter,
* pk_backend_dbus_search_file:
**/
gboolean
-pk_backend_dbus_search_file (PkBackendDbus *backend_dbus, const gchar *filter, const gchar *search)
+pk_backend_dbus_search_file (PkBackendDbus *backend_dbus, PkFilterEnum filters, const gchar *search)
{
gboolean ret;
GError *error = NULL;
+ gchar *filters_text;
g_return_val_if_fail (PK_IS_BACKEND_DBUS (backend_dbus), FALSE);
g_return_val_if_fail (backend_dbus->priv->proxy != NULL, FALSE);
- g_return_val_if_fail (filter != NULL, FALSE);
g_return_val_if_fail (search != NULL, FALSE);
/* new sync method call */
pk_backend_dbus_time_reset (backend_dbus);
+ filters_text = pk_filter_enums_to_text (filters);
ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "SearchFile", &error,
- G_TYPE_STRING, filter,
+ G_TYPE_STRING, filters_text,
G_TYPE_STRING, search,
G_TYPE_INVALID, G_TYPE_INVALID);
if (error != NULL) {
@@ -875,6 +890,7 @@ pk_backend_dbus_search_file (PkBackendDbus *backend_dbus, const gchar *filter, c
if (ret) {
pk_backend_dbus_time_check (backend_dbus);
}
+ g_free (filters_text);
return ret;
}
@@ -882,10 +898,11 @@ pk_backend_dbus_search_file (PkBackendDbus *backend_dbus, const gchar *filter, c
* pk_backend_dbus_get_depends:
**/
gboolean
-pk_backend_dbus_get_depends (PkBackendDbus *backend_dbus, const gchar *filter, const gchar *package_id, gboolean recursive)
+pk_backend_dbus_get_depends (PkBackendDbus *backend_dbus, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
gboolean ret;
GError *error = NULL;
+ gchar *filters_text;
g_return_val_if_fail (PK_IS_BACKEND_DBUS (backend_dbus), FALSE);
g_return_val_if_fail (backend_dbus->priv->proxy != NULL, FALSE);
@@ -893,8 +910,9 @@ pk_backend_dbus_get_depends (PkBackendDbus *backend_dbus, const gchar *filter, c
/* new sync method call */
pk_backend_dbus_time_reset (backend_dbus);
+ filters_text = pk_filter_enums_to_text (filters);
ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "GetDepends", &error,
- G_TYPE_STRING, filter,
+ G_TYPE_STRING, filters_text,
G_TYPE_STRING, package_id,
G_TYPE_BOOLEAN, recursive,
G_TYPE_INVALID, G_TYPE_INVALID);
@@ -907,6 +925,7 @@ pk_backend_dbus_get_depends (PkBackendDbus *backend_dbus, const gchar *filter, c
if (ret) {
pk_backend_dbus_time_check (backend_dbus);
}
+ g_free (filters_text);
return ret;
}
@@ -914,10 +933,11 @@ pk_backend_dbus_get_depends (PkBackendDbus *backend_dbus, const gchar *filter, c
* pk_backend_dbus_get_requires:
**/
gboolean
-pk_backend_dbus_get_requires (PkBackendDbus *backend_dbus, const gchar *filter, const gchar *package_id, gboolean recursive)
+pk_backend_dbus_get_requires (PkBackendDbus *backend_dbus, PkFilterEnum filters, const gchar *package_id, gboolean recursive)
{
gboolean ret;
GError *error = NULL;
+ gchar *filters_text;
g_return_val_if_fail (PK_IS_BACKEND_DBUS (backend_dbus), FALSE);
g_return_val_if_fail (backend_dbus->priv->proxy != NULL, FALSE);
@@ -925,8 +945,9 @@ pk_backend_dbus_get_requires (PkBackendDbus *backend_dbus, const gchar *filter,
/* new sync method call */
pk_backend_dbus_time_reset (backend_dbus);
+ filters_text = pk_filter_enums_to_text (filters);
ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "GetRequires", &error,
- G_TYPE_STRING, filter,
+ G_TYPE_STRING, filters_text,
G_TYPE_STRING, package_id,
G_TYPE_BOOLEAN, recursive,
G_TYPE_INVALID, G_TYPE_INVALID);
@@ -939,6 +960,7 @@ pk_backend_dbus_get_requires (PkBackendDbus *backend_dbus, const gchar *filter,
if (ret) {
pk_backend_dbus_time_check (backend_dbus);
}
+ g_free (filters_text);
return ret;
}
@@ -946,18 +968,20 @@ pk_backend_dbus_get_requires (PkBackendDbus *backend_dbus, const gchar *filter,
* pk_backend_dbus_get_packages:
**/
gboolean
-pk_backend_dbus_get_packages (PkBackendDbus *backend_dbus, const gchar *filter)
+pk_backend_dbus_get_packages (PkBackendDbus *backend_dbus, PkFilterEnum filters)
{
gboolean ret;
GError *error = NULL;
+ gchar *filters_text;
g_return_val_if_fail (PK_IS_BACKEND_DBUS (backend_dbus), FALSE);
g_return_val_if_fail (backend_dbus->priv->proxy != NULL, FALSE);
/* new sync method call */
pk_backend_dbus_time_reset (backend_dbus);
+ filters_text = pk_filter_enums_to_text (filters);
ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "GetPackages", &error,
- G_TYPE_STRING, filter,
+ G_TYPE_STRING, filters_text,
G_TYPE_INVALID, G_TYPE_INVALID);
if (error != NULL) {
pk_warning ("%s", error->message);
@@ -968,6 +992,7 @@ pk_backend_dbus_get_packages (PkBackendDbus *backend_dbus, const gchar *filter)
if (ret) {
pk_backend_dbus_time_check (backend_dbus);
}
+ g_free (filters_text);
return ret;
}
@@ -1218,24 +1243,25 @@ pk_backend_dbus_service_pack (PkBackendDbus *backend_dbus, const gchar *location
* pk_backend_dbus_what_provides:
**/
gboolean
-pk_backend_dbus_what_provides (PkBackendDbus *backend_dbus, const gchar *filter,
- PkProvidesEnum provides, const gchar *search)
+pk_backend_dbus_what_provides (PkBackendDbus *backend_dbus, PkFilterEnum filters,
+ PkProvidesEnum provides, const gchar *search)
{
gboolean ret;
GError *error = NULL;
const gchar *provides_text;
+ gchar *filters_text;
g_return_val_if_fail (PK_IS_BACKEND_DBUS (backend_dbus), FALSE);
g_return_val_if_fail (backend_dbus->priv->proxy != NULL, FALSE);
- g_return_val_if_fail (filter != NULL, FALSE);
g_return_val_if_fail (search != NULL, FALSE);
g_return_val_if_fail (provides != PK_PROVIDES_ENUM_UNKNOWN, FALSE);
/* new sync method call */
pk_backend_dbus_time_reset (backend_dbus);
provides_text = pk_provides_enum_to_text (provides);
+ filters_text = pk_filter_enums_to_text (filters);
ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "WhatProvides", &error,
- G_TYPE_STRING, filter,
+ G_TYPE_STRING, filters_text,
G_TYPE_STRING, provides_text,
G_TYPE_STRING, search,
G_TYPE_INVALID, G_TYPE_INVALID);
@@ -1248,6 +1274,7 @@ pk_backend_dbus_what_provides (PkBackendDbus *backend_dbus, const gchar *filter,
if (ret) {
pk_backend_dbus_time_check (backend_dbus);
}
+ g_free (filters_text);
return ret;
}
@@ -1446,6 +1473,12 @@ libst_backend_dbus (LibSelfTest *test)
return;
}
+ /* don't do these when doing make distcheck */
+#ifndef PK_IS_DEVELOPER
+ libst_end (test);
+ return;
+#endif
+
/************************************************************/
libst_title (test, "get an backend_dbus");
backend_dbus = pk_backend_dbus_new ();
@@ -1486,7 +1519,7 @@ libst_backend_dbus (LibSelfTest *test)
/************************************************************/
libst_title (test, "search by name");
- ret = pk_backend_dbus_search_name (backend_dbus, "none", "power");
+ ret = pk_backend_dbus_search_name (backend_dbus, PK_FILTER_ENUM_NONE, "power");
elapsed = libst_elapsed (test);
if (ret) {
libst_success (test, NULL);
@@ -1520,7 +1553,7 @@ libst_backend_dbus (LibSelfTest *test)
/************************************************************/
libst_title (test, "search by name again");
- ret = pk_backend_dbus_search_name (backend_dbus, "none", "power");
+ ret = pk_backend_dbus_search_name (backend_dbus, PK_FILTER_ENUM_NONE, "power");
if (ret) {
libst_success (test, NULL);
} else {
@@ -1545,7 +1578,7 @@ libst_backend_dbus (LibSelfTest *test)
/************************************************************/
libst_title (test, "search by name");
- ret = pk_backend_dbus_search_name (backend_dbus, "none", "power");
+ ret = pk_backend_dbus_search_name (backend_dbus, PK_FILTER_ENUM_NONE, "power");
if (ret) {
libst_success (test, NULL);
} else {
diff --git a/src/pk-backend-dbus.h b/src/pk-backend-dbus.h
index 4e0eff3..88d946c 100644
--- a/src/pk-backend-dbus.h
+++ b/src/pk-backend-dbus.h
@@ -67,30 +67,30 @@ gboolean pk_backend_dbus_refresh_cache (PkBackendDbus *backend_dbus,
gboolean force);
gboolean pk_backend_dbus_update_system (PkBackendDbus *backend_dbus);
gboolean pk_backend_dbus_resolve (PkBackendDbus *backend_dbus,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *package);
gboolean pk_backend_dbus_rollback (PkBackendDbus *backend_dbus,
const gchar *transaction_id);
gboolean pk_backend_dbus_search_name (PkBackendDbus *backend_dbus,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *search);
gboolean pk_backend_dbus_search_details (PkBackendDbus *backend_dbus,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *search);
gboolean pk_backend_dbus_search_group (PkBackendDbus *backend_dbus,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *search);
gboolean pk_backend_dbus_search_file (PkBackendDbus *backend_dbus,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *search);
gboolean pk_backend_dbus_get_packages (PkBackendDbus *backend_dbus,
- const gchar *filter);
+ PkFilterEnum filters);
gboolean pk_backend_dbus_get_depends (PkBackendDbus *backend_dbus,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *package_id,
gboolean recursive);
gboolean pk_backend_dbus_get_requires (PkBackendDbus *backend_dbus,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *package_id,
gboolean recursive);
gboolean pk_backend_dbus_get_update_detail (PkBackendDbus *backend_dbus,
@@ -113,7 +113,7 @@ gboolean pk_backend_dbus_service_pack (PkBackendDbus *backend_dbus,
const gchar *location,
gboolean enabled);
gboolean pk_backend_dbus_what_provides (PkBackendDbus *backend_dbus,
- const gchar *filter,
+ PkFilterEnum filters,
PkProvidesEnum provides,
const gchar *search);
gboolean pk_backend_dbus_kill (PkBackendDbus *backend_dbus);
@@ -125,10 +125,10 @@ gboolean pk_backend_dbus_repo_set_data (PkBackendDbus *backend_dbus,
const gchar *parameter,
const gchar *value);
gboolean pk_backend_dbus_get_repo_list (PkBackendDbus *backend_dbus,
- const gchar *filter);
+ PkFilterEnum filters);
gboolean pk_backend_dbus_cancel (PkBackendDbus *backend_dbus);
gboolean pk_backend_dbus_get_updates (PkBackendDbus *backend_dbus,
- const gchar *filter);
+ PkFilterEnum filters);
gboolean pk_backend_dbus_set_name (PkBackendDbus *backend_dbus,
const gchar *service);
diff --git a/src/pk-backend-spawn.c b/src/pk-backend-spawn.c
index 497c281..7031178 100644
--- a/src/pk-backend-spawn.c
+++ b/src/pk-backend-spawn.c
@@ -644,6 +644,12 @@ libst_backend_spawn (LibSelfTest *test)
return;
}
+ /* don't do these when doing make distcheck */
+#ifndef PK_IS_DEVELOPER
+ libst_end (test);
+ return;
+#endif
+
/************************************************************/
libst_title (test, "get an backend_spawn");
backend_spawn = pk_backend_spawn_new ();
diff --git a/src/pk-backend.h b/src/pk-backend.h
index a51614a..1c9eab4 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -135,7 +135,7 @@ typedef struct {
PkFilterEnum (*get_filters) (PkBackend *backend);
void (*cancel) (PkBackend *backend);
void (*get_depends) (PkBackend *backend,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *package_id,
gboolean recursive);
void (*get_description) (PkBackend *backend,
@@ -143,17 +143,17 @@ typedef struct {
void (*get_files) (PkBackend *backend,
const gchar *package_id);
void (*get_packages) (PkBackend *backend,
- const gchar *filter);
+ PkFilterEnum filters);
void (*get_repo_list) (PkBackend *backend,
- const gchar *filter);
+ PkFilterEnum filters);
void (*get_requires) (PkBackend *backend,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *package_id,
gboolean recursive);
void (*get_update_detail) (PkBackend *backend,
const gchar *package_id);
void (*get_updates) (PkBackend *backend,
- const gchar *filter);
+ PkFilterEnum filters);
void (*install_file) (PkBackend *backend,
const gchar *full_path);
void (*install_package) (PkBackend *backend,
@@ -176,21 +176,21 @@ typedef struct {
const gchar *parameter,
const gchar *value);
void (*resolve) (PkBackend *backend,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *package);
void (*rollback) (PkBackend *backend,
const gchar *transaction_id);
void (*search_details) (PkBackend *backend,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *search);
void (*search_file) (PkBackend *backend,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *search);
void (*search_group) (PkBackend *backend,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *search);
void (*search_name) (PkBackend *backend,
- const gchar *filter,
+ PkFilterEnum filters,
const gchar *search);
void (*service_pack) (PkBackend *backend,
const gchar *location,
@@ -199,7 +199,7 @@ typedef struct {
gchar **package_ids);
void (*update_system) (PkBackend *backend);
void (*what_provides) (PkBackend *backend,
- const gchar *filter,
+ PkFilterEnum filters,
PkProvidesEnum provide,
const gchar *search);
gpointer padding[10];
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 92cf174..c9b273f 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -42,7 +42,6 @@
#include <pk-debug.h>
#include <pk-common.h>
-#include <pk-filter.h>
#include <pk-network.h>
#include <pk-package-list.h>
#include <pk-enum.h>
@@ -609,6 +608,12 @@ libst_engine (LibSelfTest *test)
return;
}
+ /* don't do these when doing make distcheck */
+#ifndef PK_IS_DEVELOPER
+ libst_end (test);
+ return;
+#endif
+
/************************************************************/
libst_title (test, "get a backend instance");
backend = pk_backend_new ();
diff --git a/src/pk-self-test.c b/src/pk-self-test.c
index 08eea18..d0aace7 100644
--- a/src/pk-self-test.c
+++ b/src/pk-self-test.c
@@ -53,15 +53,12 @@ main (int argc, char **argv)
pk_debug_init (TRUE);
/* components */
-#if 0
libst_restart (&test);
libst_security (&test);
libst_time (&test);
libst_conf (&test);
libst_inhibit (&test);
-#endif
libst_spawn (&test);
-#if 0
libst_thread_list (&test);
libst_transaction_list (&test);
libst_transaction_db (&test);
@@ -74,7 +71,6 @@ main (int argc, char **argv)
/* system */
libst_engine (&test);
-#endif
return (libst_finish (&test));
}
diff --git a/src/pk-transaction-db.c b/src/pk-transaction-db.c
index c90bf86..228d180 100644
--- a/src/pk-transaction-db.c
+++ b/src/pk-transaction-db.c
@@ -567,6 +567,12 @@ libst_transaction_db (LibSelfTest *test)
return;
}
+ /* don't do these when doing make distcheck */
+#ifndef PK_IS_DEVELOPER
+ libst_end (test);
+ return;
+#endif
+
db = pk_transaction_db_new ();
/************************************************************/
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 05c4889..4515556 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -54,7 +54,6 @@
#include "pk-backend.h"
#include "pk-backend-internal.h"
#include "pk-inhibit.h"
-#include "pk-filter.h"
#include "pk-cache.h"
#include "pk-notify.h"
#include "pk-security.h"
@@ -98,7 +97,7 @@ struct PkTransactionPrivate
gchar **cached_package_ids;
gchar *cached_transaction_id;
gchar *cached_full_path;
- gchar *cached_filter;
+ PkFilterEnum cached_filters;
gchar *cached_search;
gchar *cached_repo_id;
gchar *cached_key_id;
@@ -222,11 +221,11 @@ pk_transaction_set_running (PkTransaction *transaction)
/* do the correct action with the cached parameters */
if (priv->role == PK_ROLE_ENUM_GET_DEPENDS) {
- desc->get_depends (priv->backend, priv->cached_filter, priv->cached_package_id, priv->cached_force);
+ desc->get_depends (priv->backend, priv->cached_filters, priv->cached_package_id, priv->cached_force);
} else if (priv->role == PK_ROLE_ENUM_GET_UPDATE_DETAIL) {
desc->get_update_detail (priv->backend, priv->cached_package_id);
} else if (priv->role == PK_ROLE_ENUM_RESOLVE) {
- desc->resolve (priv->backend, priv->cached_filter, priv->cached_package_id);
+ desc->resolve (priv->backend, priv->cached_filters, priv->cached_package_id);
} else if (priv->role == PK_ROLE_ENUM_ROLLBACK) {
desc->rollback (priv->backend, priv->cached_transaction_id);
} else if (priv->role == PK_ROLE_ENUM_GET_DESCRIPTION) {
@@ -234,21 +233,21 @@ pk_transaction_set_running (PkTransaction *transaction)
} else if (priv->role == PK_ROLE_ENUM_GET_FILES) {
desc->get_files (priv->backend, priv->cached_package_id);
} else if (priv->role == PK_ROLE_ENUM_GET_REQUIRES) {
- desc->get_requires (priv->backend, priv->cached_filter, priv->cached_package_id, priv->cached_force);
+ desc->get_requires (priv->backend, priv->cached_filters, priv->cached_package_id, priv->cached_force);
} else if (priv->role == PK_ROLE_ENUM_WHAT_PROVIDES) {
- desc->what_provides (priv->backend, priv->cached_filter, priv->cached_provides, priv->cached_search);
+ desc->what_provides (priv->backend, priv->cached_filters, priv->cached_provides, priv->cached_search);
} else if (priv->role == PK_ROLE_ENUM_GET_UPDATES) {
- desc->get_updates (priv->backend, priv->cached_filter);
+ desc->get_updates (priv->backend, priv->cached_filters);
} else if (priv->role == PK_ROLE_ENUM_GET_PACKAGES) {
- desc->get_packages (priv->backend, priv->cached_filter);
+ desc->get_packages (priv->backend, priv->cached_filters);
} else if (priv->role == PK_ROLE_ENUM_SEARCH_DETAILS) {
- desc->search_details (priv->backend, priv->cached_filter, priv->cached_search);
+ desc->search_details (priv->backend, priv->cached_filters, priv->cached_search);
} else if (priv->role == PK_ROLE_ENUM_SEARCH_FILE) {
- desc->search_file (priv->backend,priv->cached_filter,priv->cached_search);
+ desc->search_file (priv->backend,priv->cached_filters,priv->cached_search);
} else if (priv->role == PK_ROLE_ENUM_SEARCH_GROUP) {
- desc->search_group (priv->backend, priv->cached_filter, priv->cached_search);
+ desc->search_group (priv->backend, priv->cached_filters, priv->cached_search);
} else if (priv->role == PK_ROLE_ENUM_SEARCH_NAME) {
- desc->search_name (priv->backend,priv->cached_filter,priv->cached_search);
+ desc->search_name (priv->backend,priv->cached_filters,priv->cached_search);
} else if (priv->role == PK_ROLE_ENUM_INSTALL_PACKAGE) {
desc->install_package (priv->backend, priv->cached_package_id);
} else if (priv->role == PK_ROLE_ENUM_INSTALL_FILE) {
@@ -266,7 +265,7 @@ pk_transaction_set_running (PkTransaction *transaction)
} else if (priv->role == PK_ROLE_ENUM_UPDATE_SYSTEM) {
desc->update_system (priv->backend);
} else if (priv->role == PK_ROLE_ENUM_GET_REPO_LIST) {
- desc->get_repo_list (priv->backend, priv->cached_filter);
+ desc->get_repo_list (priv->backend, priv->cached_filters);
} else if (priv->role == PK_ROLE_ENUM_REPO_ENABLE) {
desc->repo_enable (priv->backend, priv->cached_repo_id, priv->cached_enabled);
} else if (priv->role == PK_ROLE_ENUM_REPO_SET_DATA) {
@@ -926,24 +925,48 @@ pk_transaction_search_check (const gchar *search, GError **error)
gboolean
pk_transaction_filter_check (const gchar *filter, GError **error)
{
- gboolean ret;
+ gchar **sections;
+ guint i;
+ guint length;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (error != NULL, FALSE);
+
+ /* is zero? */
+ if (pk_strzero (filter)) {
+ *error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_INPUT_INVALID,
+ "filter zero length");
+ return FALSE;
+ }
/* check for invalid input */
ret = pk_strvalidate (filter);
if (!ret) {
*error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_INPUT_INVALID,
- "Invalid filter term");
+ "Invalid filter term: %s", filter);
return FALSE;
}
- /* check for invalid filter */
- ret = pk_filter_check (filter);
- if (!ret) {
- *error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_FILTER_INVALID,
- "Filter '%s' is invalid", filter);
- return FALSE;
+ /* split by delimeter ';' */
+ sections = g_strsplit (filter, ";", 0);
+ length = g_strv_length (sections);
+ for (i=0; i<length; i++) {
+ /* only one wrong part is enough to fail the filter */
+ if (pk_strzero (sections[i])) {
+ *error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_INPUT_INVALID,
+ "Single empty section of filter: %s", filter);
+ goto out;
+ }
+ if (pk_filter_enum_from_text (sections[i]) == PK_FILTER_ENUM_UNKNOWN) {
+ *error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_INPUT_INVALID,
+ "Unknown filter part: %s", sections[i]);
+ goto out;
+ }
}
- return TRUE;
+ ret = TRUE;
+out:
+ g_strfreev (sections);
+ return ret;
}
/**
@@ -1101,7 +1124,7 @@ pk_transaction_get_depends (PkTransaction *transaction, const gchar *filter, con
pk_transaction_set_dbus_name (transaction, dbus_g_method_get_sender (context));
/* save so we can run later */
- transaction->priv->cached_filter = g_strdup (filter);
+ transaction->priv->cached_filters = pk_filter_enums_from_text (filter);
transaction->priv->cached_package_id = g_strdup (package_id);
transaction->priv->cached_force = recursive;
transaction->priv->status = PK_STATUS_ENUM_WAIT;
@@ -1280,7 +1303,7 @@ pk_transaction_get_packages (PkTransaction *transaction, const gchar *filter, DB
pk_transaction_set_dbus_name (transaction, dbus_g_method_get_sender (context));
/* save so we can run later */
- transaction->priv->cached_filter = g_strdup (filter);
+ transaction->priv->cached_filters = pk_filter_enums_from_text (filter);
transaction->priv->status = PK_STATUS_ENUM_WAIT;
pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_PACKAGES);
@@ -1397,7 +1420,7 @@ pk_transaction_get_repo_list (PkTransaction *transaction, const gchar *filter, D
pk_transaction_set_dbus_name (transaction, dbus_g_method_get_sender (context));
/* save so we can run later */
- transaction->priv->cached_filter = g_strdup (filter);
+ transaction->priv->cached_filters = pk_filter_enums_from_text (filter);
transaction->priv->status = PK_STATUS_ENUM_WAIT;
pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_REPO_LIST);
@@ -1467,7 +1490,7 @@ pk_transaction_get_requires (PkTransaction *transaction, const gchar *filter, co
pk_transaction_set_dbus_name (transaction, dbus_g_method_get_sender (context));
/* save so we can run later */
- transaction->priv->cached_filter = g_strdup (filter);
+ transaction->priv->cached_filters = pk_filter_enums_from_text (filter);
transaction->priv->cached_package_id = g_strdup (package_id);
transaction->priv->cached_force = recursive;
transaction->priv->status = PK_STATUS_ENUM_WAIT;
@@ -1655,7 +1678,7 @@ pk_transaction_get_updates (PkTransaction *transaction, const gchar *filter, DBu
}
/* save so we can run later */
- transaction->priv->cached_filter = g_strdup (filter);
+ transaction->priv->cached_filters = pk_filter_enums_from_text (filter);
transaction->priv->status = PK_STATUS_ENUM_WAIT;
pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_UPDATES);
@@ -2209,7 +2232,7 @@ pk_transaction_resolve (PkTransaction *transaction, const gchar *filter,
/* save so we can run later */
transaction->priv->cached_package_id = g_strdup (package);
- transaction->priv->cached_filter = g_strdup (filter);
+ transaction->priv->cached_filters = pk_filter_enums_from_text (filter);
transaction->priv->status = PK_STATUS_ENUM_WAIT;
pk_transaction_set_role (transaction, PK_ROLE_ENUM_RESOLVE);
@@ -2332,7 +2355,7 @@ pk_transaction_search_details (PkTransaction *transaction, const gchar *filter,
pk_transaction_set_dbus_name (transaction, dbus_g_method_get_sender (context));
/* save so we can run later */
- transaction->priv->cached_filter = g_strdup (filter);
+ transaction->priv->cached_filters = pk_filter_enums_from_text (filter);
transaction->priv->cached_search = g_strdup (search);
transaction->priv->status = PK_STATUS_ENUM_WAIT;
pk_transaction_set_role (transaction, PK_ROLE_ENUM_SEARCH_DETAILS);
@@ -2392,7 +2415,7 @@ pk_transaction_search_file (PkTransaction *transaction, const gchar *filter,
pk_transaction_set_dbus_name (transaction, dbus_g_method_get_sender (context));
/* save so we can run later */
- transaction->priv->cached_filter = g_strdup (filter);
+ transaction->priv->cached_filters = pk_filter_enums_from_text (filter);
transaction->priv->cached_search = g_strdup (search);
transaction->priv->status = PK_STATUS_ENUM_WAIT;
pk_transaction_set_role (transaction, PK_ROLE_ENUM_SEARCH_FILE);
@@ -2452,7 +2475,7 @@ pk_transaction_search_group (PkTransaction *transaction, const gchar *filter,
pk_transaction_set_dbus_name (transaction, dbus_g_method_get_sender (context));
/* save so we can run later */
- transaction->priv->cached_filter = g_strdup (filter);
+ transaction->priv->cached_filters = pk_filter_enums_from_text (filter);
transaction->priv->cached_search = g_strdup (search);
transaction->priv->status = PK_STATUS_ENUM_WAIT;
pk_transaction_set_role (transaction, PK_ROLE_ENUM_SEARCH_GROUP);
@@ -2512,7 +2535,7 @@ pk_transaction_search_name (PkTransaction *transaction, const gchar *filter,
pk_transaction_set_dbus_name (transaction, dbus_g_method_get_sender (context));
/* save so we can run later */
- transaction->priv->cached_filter = g_strdup (filter);
+ transaction->priv->cached_filters = pk_filter_enums_from_text (filter);
transaction->priv->cached_search = g_strdup (search);
transaction->priv->status = PK_STATUS_ENUM_WAIT;
pk_transaction_set_role (transaction, PK_ROLE_ENUM_SEARCH_NAME);
@@ -2722,7 +2745,7 @@ pk_transaction_what_provides (PkTransaction *transaction, const gchar *filter, c
pk_transaction_set_dbus_name (transaction, dbus_g_method_get_sender (context));
/* save so we can run later */
- transaction->priv->cached_filter = g_strdup (filter);
+ transaction->priv->cached_filters = pk_filter_enums_from_text (filter);
transaction->priv->cached_search = g_strdup (search);
transaction->priv->cached_provides = provides;
transaction->priv->status = PK_STATUS_ENUM_WAIT;
@@ -2854,7 +2877,7 @@ pk_transaction_init (PkTransaction *transaction)
transaction->priv->cached_package_ids = NULL;
transaction->priv->cached_transaction_id = NULL;
transaction->priv->cached_full_path = NULL;
- transaction->priv->cached_filter = NULL;
+ transaction->priv->cached_filters = PK_FILTER_ENUM_NONE;
transaction->priv->cached_search = NULL;
transaction->priv->cached_repo_id = NULL;
transaction->priv->cached_parameter = NULL;
@@ -2939,7 +2962,6 @@ pk_transaction_finalize (GObject *object)
g_free (transaction->priv->cached_key_id);
g_strfreev (transaction->priv->cached_package_ids);
g_free (transaction->priv->cached_transaction_id);
- g_free (transaction->priv->cached_filter);
g_free (transaction->priv->cached_search);
g_free (transaction->priv->cached_repo_id);
g_free (transaction->priv->cached_parameter);
@@ -2984,6 +3006,9 @@ void
libst_transaction (LibSelfTest *test)
{
PkTransaction *transaction = NULL;
+ gboolean ret;
+ const gchar *temp;
+ GError *error = NULL;
if (libst_start (test, "PkTransaction", CLASS_AUTO) == FALSE) {
return;
@@ -2998,6 +3023,118 @@ libst_transaction (LibSelfTest *test)
libst_failed (test, NULL);
}
+ /************************************************************
+ **************** FILTERS ******************
+ ************************************************************/
+ temp = NULL;
+ libst_title (test, "test a fail filter (null)");
+ ret = pk_transaction_filter_check (temp, &error);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "passed the filter '%s'", temp);
+ }
+ g_clear_error (&error);
+
+ /************************************************************/
+ temp = "";
+ libst_title (test, "test a fail filter ()");
+ ret = pk_transaction_filter_check (temp, &error);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "passed the filter '%s'", temp);
+ }
+ g_clear_error (&error);
+
+ /************************************************************/
+ temp = ";";
+ libst_title (test, "test a fail filter (;)");
+ ret = pk_transaction_filter_check (temp, &error);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "passed the filter '%s'", temp);
+ }
+ g_clear_error (&error);
+
+ /************************************************************/
+ temp = "moo";
+ libst_title (test, "test a fail filter (invalid)");
+ ret = pk_transaction_filter_check (temp, &error);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "passed the filter '%s'", temp);
+ }
+ g_clear_error (&error);
+
+ /************************************************************/
+ temp = "moo;foo";
+ libst_title (test, "test a fail filter (invalid, multiple)");
+ ret = pk_transaction_filter_check (temp, &error);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "passed the filter '%s'", temp);
+ }
+ g_clear_error (&error);
+
+ /************************************************************/
+ temp = "gui;;";
+ libst_title (test, "test a fail filter (valid then zero length)");
+ ret = pk_transaction_filter_check (temp, &error);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "passed the filter '%s'", temp);
+ }
+ g_clear_error (&error);
+
+ /************************************************************/
+ temp = "none";
+ libst_title (test, "test a pass filter (none)");
+ ret = pk_transaction_filter_check (temp, &error);
+ if (ret) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed the filter '%s'", temp);
+ }
+ g_clear_error (&error);
+
+ /************************************************************/
+ temp = "gui";
+ libst_title (test, "test a pass filter (single)");
+ ret = pk_transaction_filter_check (temp, &error);
+ if (ret) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed the filter '%s'", temp);
+ }
+ g_clear_error (&error);
+
+ /************************************************************/
+ temp = "devel;~gui";
+ libst_title (test, "test a pass filter (multiple)");
+ ret = pk_transaction_filter_check (temp, &error);
+ if (ret) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed the filter '%s'", temp);
+ }
+ g_clear_error (&error);
+
+ /************************************************************/
+ temp = "~gui;~installed";
+ libst_title (test, "test a pass filter (multiple2)");
+ ret = pk_transaction_filter_check (temp, &error);
+ if (ret) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed the filter '%s'", temp);
+ }
+ g_clear_error (&error);
+
g_object_unref (transaction);
libst_end (test);
diff --git a/tools/add-method.sh b/tools/add-method.sh
index 4f89a9d..2f95d34 100755
--- a/tools/add-method.sh
+++ b/tools/add-method.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-$EDITOR docs/spec/pk-methods.xml src/pk-interface-transaction.xml src/pk-transaction.h src/pk-transaction.c python/packagekit/backend.py python/packagekit/daemonBackend.py libpackagekit/pk-client.h libpackagekit/pk-client.c libpackagekit/pk-enum.h libpackagekit/pk-enum.c client/pk-console.c backends/*/pk-*.c src/pk-backend-dbus.c src/pk-backend-dbus.h contrib/*.bash src/pk-engine.c src/pk-backend.h docs/html/pk-faq.html ../gnome-packagekit/src/gpk-common.c
+$EDITOR docs/spec/pk-methods.xml src/pk-interface-transaction.xml src/pk-transaction.h src/pk-transaction.c python/packagekit/backend.py python/packagekit/daemonBackend.py libpackagekit/pk-client.h libpackagekit/pk-client.c libpackagekit/pk-enum.h libpackagekit/pk-enum.c client/pk-console.c backends/*/pk-*.c* src/pk-backend-dbus.c src/pk-backend-dbus.h contrib/*.bash src/pk-engine.c src/pk-backend.h docs/html/pk-faq.html ../gnome-packagekit/src/gpk-common.c
More information about the PackageKit-commit
mailing list