[PackageKit-commit] packagekit: Branch 'master' - 3 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Thu Apr 10 20:08:00 PDT 2008
backends/alpm/pk-backend-alpm.c | 4
backends/apt/pk-apt-search-plain.c | 40 +++----
backends/apt/pk-apt-search-sqlite.cpp | 40 +++----
backends/apt/pk-backend-apt.c | 40 +++----
backends/apt2/pk-backend-apt2.c | 40 +++----
backends/conary/pk-backend-conary.c | 42 +++-----
backends/dummy/pk-backend-dummy.c | 31 ++----
backends/opkg/pk-backend-opkg.c | 37 +++----
backends/pisi/pk-backend-pisi.c | 65 +++++-------
backends/test/pk-backend-test-fail.c | 28 ++---
backends/test/pk-backend-test-succeed.c | 30 ++---
backends/yum/pk-backend-yum.c | 66 ++++++------
backends/yum2/pk-backend-yum2.c | 64 +++++-------
backends/zypp/pk-backend-zypp.cpp | 54 ++++------
libpackagekit/pk-enum.c | 64 ++++++++++++
libpackagekit/pk-enum.h | 60 ++++++-----
src/pk-backend-internal.h | 3
src/pk-backend.c | 113 ++++++++++++++++++++++
src/pk-backend.h | 6 -
src/pk-engine.c | 163 +-------------------------------
20 files changed, 483 insertions(+), 507 deletions(-)
New commits:
commit d6c4553aa1defe78d9114a9467dd680cd59bf0fd
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Apr 11 04:07:16 2008 +0100
make the backends use bitfields for groups and filters, it's way quicker
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 7ec5e40..e10179d 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -711,8 +711,8 @@ backend_search_name (PkBackend *backend, const gchar *filter, const gchar *searc
pk_backend_finished (backend);
}
-static void
-backend_get_groups (PkBackend *backend, PkEnumList *list)
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
list = pk_enum_list_new ();
pk_enum_list_set_type (list, PK_ENUM_LIST_TYPE_GROUP);
diff --git a/backends/apt/pk-apt-search-plain.c b/backends/apt/pk-apt-search-plain.c
index 71792f5..2851057 100644
--- a/backends/apt/pk-apt-search-plain.c
+++ b/backends/apt/pk-apt-search-plain.c
@@ -30,35 +30,31 @@ extern PkBackendSpawn *spawn;
/**
* backend_get_groups:
*/
-void
-backend_get_groups (PkBackend *backend, PkEnumList *elist)
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_GROUP_ENUM_ACCESSORIES,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_GRAPHICS,
- PK_GROUP_ENUM_INTERNET,
- PK_GROUP_ENUM_OFFICE,
- PK_GROUP_ENUM_OTHER,
- PK_GROUP_ENUM_PROGRAMMING,
- PK_GROUP_ENUM_MULTIMEDIA,
- PK_GROUP_ENUM_SYSTEM,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return (PK_GROUP_ENUM_ACCESSORIES |
+ PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_GRAPHICS |
+ PK_GROUP_ENUM_INTERNET |
+ PK_GROUP_ENUM_OFFICE |
+ PK_GROUP_ENUM_OTHER |
+ PK_GROUP_ENUM_PROGRAMMING |
+ PK_GROUP_ENUM_MULTIMEDIA |
+ PK_GROUP_ENUM_SYSTEM);
}
/**
* backend_get_filters:
*/
-void
-backend_get_filters (PkBackend *backend, PkEnumList *elist)
+static PkFilterEnum
+backend_get_filters (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_FILTER_ENUM_GUI,
- PK_FILTER_ENUM_INSTALLED,
- PK_FILTER_ENUM_DEVELOPMENT,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+ return (PK_FILTER_ENUM_GUI |
+ PK_FILTER_ENUM_INSTALLED |
+ PK_FILTER_ENUM_DEVELOPMENT);
}
/**
diff --git a/backends/apt/pk-apt-search-sqlite.cpp b/backends/apt/pk-apt-search-sqlite.cpp
index 640799d..3b48f46 100644
--- a/backends/apt/pk-apt-search-sqlite.cpp
+++ b/backends/apt/pk-apt-search-sqlite.cpp
@@ -34,35 +34,31 @@ static PkBackendSpawn *spawn;
/**
* backend_get_groups:
*/
-extern "C" void
-backend_get_groups (PkBackend *backend, PkEnumList *elist)
+extern "C" PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_GROUP_ENUM_ACCESSORIES,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_GRAPHICS,
- PK_GROUP_ENUM_INTERNET,
- PK_GROUP_ENUM_OFFICE,
- PK_GROUP_ENUM_OTHER,
- PK_GROUP_ENUM_PROGRAMMING,
- PK_GROUP_ENUM_MULTIMEDIA,
- PK_GROUP_ENUM_SYSTEM,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return (PK_GROUP_ENUM_ACCESSORIES |
+ PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_GRAPHICS |
+ PK_GROUP_ENUM_INTERNET |
+ PK_GROUP_ENUM_OFFICE |
+ PK_GROUP_ENUM_OTHER |
+ PK_GROUP_ENUM_PROGRAMMING |
+ PK_GROUP_ENUM_MULTIMEDIA |
+ PK_GROUP_ENUM_SYSTEM);
}
/**
* backend_get_filters:
*/
-extern "C" void
-backend_get_filters (PkBackend *backend, PkEnumList *elist)
+extern "C" PkFilterEnum
+backend_get_filters (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_FILTER_ENUM_GUI,
- PK_FILTER_ENUM_INSTALLED,
- PK_FILTER_ENUM_DEVELOPMENT,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+ return (PK_FILTER_ENUM_GUI |
+ PK_FILTER_ENUM_INSTALLED |
+ PK_FILTER_ENUM_DEVELOPMENT);
}
/**
diff --git a/backends/apt/pk-backend-apt.c b/backends/apt/pk-backend-apt.c
index cb9170a..f695312 100644
--- a/backends/apt/pk-backend-apt.c
+++ b/backends/apt/pk-backend-apt.c
@@ -65,35 +65,31 @@ backend_destroy (PkBackend *backend)
/**
* backend_get_groups:
*/
-static void
-backend_get_groups (PkBackend *backend, PkEnumList *elist)
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_GROUP_ENUM_ACCESSORIES,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_GRAPHICS,
- PK_GROUP_ENUM_INTERNET,
- PK_GROUP_ENUM_OFFICE,
- PK_GROUP_ENUM_OTHER,
- PK_GROUP_ENUM_PROGRAMMING,
- PK_GROUP_ENUM_MULTIMEDIA,
- PK_GROUP_ENUM_SYSTEM,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return (PK_GROUP_ENUM_ACCESSORIES |
+ PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_GRAPHICS |
+ PK_GROUP_ENUM_INTERNET |
+ PK_GROUP_ENUM_OFFICE |
+ PK_GROUP_ENUM_OTHER |
+ PK_GROUP_ENUM_PROGRAMMING |
+ PK_GROUP_ENUM_MULTIMEDIA |
+ PK_GROUP_ENUM_SYSTEM);
}
/**
* backend_get_filters:
*/
-static void
-backend_get_filters (PkBackend *backend, PkEnumList *elist)
+static PkFilterEnum
+backend_get_filters (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_FILTER_ENUM_GUI,
- PK_FILTER_ENUM_INSTALLED,
- PK_FILTER_ENUM_DEVELOPMENT,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+ return (PK_FILTER_ENUM_GUI |
+ PK_FILTER_ENUM_INSTALLED |
+ PK_FILTER_ENUM_DEVELOPMENT);
}
/**
diff --git a/backends/apt2/pk-backend-apt2.c b/backends/apt2/pk-backend-apt2.c
index 0814405..2da4dc0 100644
--- a/backends/apt2/pk-backend-apt2.c
+++ b/backends/apt2/pk-backend-apt2.c
@@ -61,35 +61,31 @@ backend_destroy (PkBackend *backend)
/**
* backend_get_groups:
*/
-static void
-backend_get_groups (PkBackend *backend, PkEnumList *elist)
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_GROUP_ENUM_ACCESSORIES,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_GRAPHICS,
- PK_GROUP_ENUM_INTERNET,
- PK_GROUP_ENUM_OFFICE,
- PK_GROUP_ENUM_OTHER,
- PK_GROUP_ENUM_PROGRAMMING,
- PK_GROUP_ENUM_MULTIMEDIA,
- PK_GROUP_ENUM_SYSTEM,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return (PK_GROUP_ENUM_ACCESSORIES |
+ PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_GRAPHICS |
+ PK_GROUP_ENUM_INTERNET |
+ PK_GROUP_ENUM_OFFICE |
+ PK_GROUP_ENUM_OTHER |
+ PK_GROUP_ENUM_PROGRAMMING |
+ PK_GROUP_ENUM_MULTIMEDIA |
+ PK_GROUP_ENUM_SYSTEM);
}
/**
* backend_get_filters:
*/
-static void
-backend_get_filters (PkBackend *backend, PkEnumList *elist)
+static PkFilterEnum
+backend_get_filters (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_FILTER_ENUM_GUI,
- PK_FILTER_ENUM_INSTALLED,
- PK_FILTER_ENUM_DEVELOPMENT,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+ return (PK_FILTER_ENUM_GUI |
+ PK_FILTER_ENUM_INSTALLED |
+ PK_FILTER_ENUM_DEVELOPMENT);
}
/**
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index 4f00684..76cdaa1 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -60,37 +60,31 @@ backend_destroy (PkBackend *backend)
/**
* backend_get_groups:
*/
-static void
-backend_get_groups (PkBackend *backend, PkEnumList *elist)
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_GROUP_ENUM_ACCESSIBILITY,
- PK_GROUP_ENUM_ACCESSORIES,
- PK_GROUP_ENUM_EDUCATION,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_GRAPHICS,
- PK_GROUP_ENUM_INTERNET,
- PK_GROUP_ENUM_OFFICE,
- PK_GROUP_ENUM_OTHER,
- PK_GROUP_ENUM_PROGRAMMING,
- PK_GROUP_ENUM_MULTIMEDIA,
- PK_GROUP_ENUM_SYSTEM,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return (PK_GROUP_ENUM_ACCESSIBILITY |
+ PK_GROUP_ENUM_ACCESSORIES |
+ PK_GROUP_ENUM_EDUCATION |
+ PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_GRAPHICS |
+ PK_GROUP_ENUM_INTERNET |
+ PK_GROUP_ENUM_OFFICE |
+ PK_GROUP_ENUM_OTHER |
+ PK_GROUP_ENUM_PROGRAMMING |
+ PK_GROUP_ENUM_MULTIMEDIA |
+ PK_GROUP_ENUM_SYSTEM);
}
/**
* backend_get_filters:
*/
-static void
-backend_get_filters (PkBackend *backend, PkEnumList *elist)
+static PkFilterEnum
+backend_get_filters (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- /* PK_FILTER_ENUM_GUI, */
- PK_FILTER_ENUM_INSTALLED,
- /* PK_FILTER_ENUM_DEVELOPMENT, */
- -1);
+ g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+ return PK_FILTER_ENUM_INSTALLED;
}
/**
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index c681ff0..9335b8b 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -63,29 +63,25 @@ backend_destroy (PkBackend *backend)
/**
* backend_get_groups:
*/
-static void
-backend_get_groups (PkBackend *backend, PkEnumList *elist)
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_GROUP_ENUM_ACCESSIBILITY,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_SYSTEM,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return (PK_GROUP_ENUM_ACCESSIBILITY |
+ PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_SYSTEM);
}
/**
* backend_get_filters:
*/
-static void
-backend_get_filters (PkBackend *backend, PkEnumList *elist)
+static PkFilterEnum
+backend_get_filters (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_FILTER_ENUM_GUI,
- PK_FILTER_ENUM_INSTALLED,
- PK_FILTER_ENUM_DEVELOPMENT,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+ return (PK_FILTER_ENUM_GUI |
+ PK_FILTER_ENUM_INSTALLED |
+ PK_FILTER_ENUM_DEVELOPMENT);
}
/**
@@ -343,7 +339,8 @@ backend_install_signature (PkBackend *backend, PkSigTypeEnum type,
_has_signature = TRUE;
} else {
pk_backend_error_code (backend, PK_ERROR_ENUM_GPG_FAILURE,
- "GPG key %s not recognised for package_id %s", key_id, package_id);
+ "GPG key %s not recognised for package_id %s",
+ key_id, package_id);
}
pk_backend_finished (backend);
}
diff --git a/backends/opkg/pk-backend-opkg.c b/backends/opkg/pk-backend-opkg.c
index 78ac73d..39816c3 100644
--- a/backends/opkg/pk-backend-opkg.c
+++ b/backends/opkg/pk-backend-opkg.c
@@ -753,15 +753,13 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
/**
* backend_get_filters:
*/
-static void
-backend_get_filters (PkBackend *backend, PkEnumList *elist)
+static PkFilterEnum
+backend_get_filters (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_FILTER_ENUM_INSTALLED,
- PK_FILTER_ENUM_DEVELOPMENT,
- PK_FILTER_ENUM_GUI,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+ return (PK_FILTER_ENUM_INSTALLED |
+ PK_FILTER_ENUM_DEVELOPMENT |
+ PK_FILTER_ENUM_GUI);
}
@@ -1035,20 +1033,17 @@ backend_get_updates (PkBackend *backend, const gchar *filter)
/**
* backend_get_groups:
*/
-static void
-backend_get_groups (PkBackend *backend, PkEnumList *elist)
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_GROUP_ENUM_COMMUNICATION,
- PK_GROUP_ENUM_PROGRAMMING,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_OTHER,
- PK_GROUP_ENUM_INTERNET,
- PK_GROUP_ENUM_REPOS,
- PK_GROUP_ENUM_MAPS,
- -1
- );
+ g_return_val_if_fail (backend != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return (PK_GROUP_ENUM_COMMUNICATION |
+ PK_GROUP_ENUM_PROGRAMMING |
+ PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_OTHER |
+ PK_GROUP_ENUM_INTERNET |
+ PK_GROUP_ENUM_REPOS |
+ PK_GROUP_ENUM_MAPS);
}
diff --git a/backends/pisi/pk-backend-pisi.c b/backends/pisi/pk-backend-pisi.c
index 9fcde95..ccd38a9 100644
--- a/backends/pisi/pk-backend-pisi.c
+++ b/backends/pisi/pk-backend-pisi.c
@@ -59,50 +59,41 @@ backend_destroy (PkBackend *backend)
/**
* backend_get_groups:
*/
-static void
-backend_get_groups (PkBackend *backend, PkEnumList *elist)
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- /* PK_GROUP_ENUM_ACCESSIBILITY, */
- PK_GROUP_ENUM_ACCESSORIES,
- PK_GROUP_ENUM_EDUCATION,
- PK_GROUP_ENUM_GAMES,
- /* PK_GROUP_ENUM_GRAPHICS, */
- PK_GROUP_ENUM_INTERNET,
- /* PK_GROUP_ENUM_OFFICE, */
- PK_GROUP_ENUM_OTHER,
- PK_GROUP_ENUM_PROGRAMMING,
- PK_GROUP_ENUM_MULTIMEDIA,
- PK_GROUP_ENUM_SYSTEM,
- PK_GROUP_ENUM_DESKTOP_GNOME,
- PK_GROUP_ENUM_DESKTOP_KDE,
- PK_GROUP_ENUM_DESKTOP_OTHER,
- PK_GROUP_ENUM_PUBLISHING,
- PK_GROUP_ENUM_SERVERS,
- PK_GROUP_ENUM_FONTS,
- PK_GROUP_ENUM_ADMIN_TOOLS,
- /* PK_GROUP_ENUM_LEGACY, */
- PK_GROUP_ENUM_LOCALIZATION,
- PK_GROUP_ENUM_VIRTUALIZATION,
- PK_GROUP_ENUM_SECURITY,
- PK_GROUP_ENUM_POWER_MANAGEMENT,
- PK_GROUP_ENUM_UNKNOWN,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return (PK_GROUP_ENUM_ACCESSORIES |
+ PK_GROUP_ENUM_EDUCATION |
+ PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_INTERNET |
+ PK_GROUP_ENUM_OTHER |
+ PK_GROUP_ENUM_PROGRAMMING |
+ PK_GROUP_ENUM_MULTIMEDIA |
+ PK_GROUP_ENUM_SYSTEM |
+ PK_GROUP_ENUM_DESKTOP_GNOME |
+ PK_GROUP_ENUM_DESKTOP_KDE |
+ PK_GROUP_ENUM_DESKTOP_OTHER |
+ PK_GROUP_ENUM_PUBLISHING |
+ PK_GROUP_ENUM_SERVERS |
+ PK_GROUP_ENUM_FONTS |
+ PK_GROUP_ENUM_ADMIN_TOOLS |
+ PK_GROUP_ENUM_LOCALIZATION |
+ PK_GROUP_ENUM_VIRTUALIZATION |
+ PK_GROUP_ENUM_SECURITY |
+ PK_GROUP_ENUM_POWER_MANAGEMENT |
+ PK_GROUP_ENUM_UNKNOWN);
}
/**
* backend_get_filters:
*/
-static void
-backend_get_filters (PkBackend *backend, PkEnumList *elist)
+static PkFilterEnum
+backend_get_filters (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_FILTER_ENUM_GUI,
- PK_FILTER_ENUM_INSTALLED,
- /* PK_FILTER_ENUM_DEVELOPMENT, */
- -1);
+ g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+ return (PK_FILTER_ENUM_GUI |
+ PK_FILTER_ENUM_INSTALLED);
}
/**
diff --git a/backends/test/pk-backend-test-fail.c b/backends/test/pk-backend-test-fail.c
index 0c91c27..deb8761 100644
--- a/backends/test/pk-backend-test-fail.c
+++ b/backends/test/pk-backend-test-fail.c
@@ -49,29 +49,25 @@ backend_destroy (PkBackend *backend)
/**
* backend_get_groups:
*/
-static void
-backend_get_groups (PkBackend *backend, PkEnumList *elist)
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_GROUP_ENUM_ACCESSIBILITY,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_SYSTEM,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return (PK_GROUP_ENUM_ACCESSIBILITY |
+ PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_SYSTEM);
}
/**
* backend_get_filters:
*/
-static void
-backend_get_filters (PkBackend *backend, PkEnumList *elist)
+static PkFilterEnum
+backend_get_filters (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_FILTER_ENUM_GUI,
- PK_FILTER_ENUM_INSTALLED,
- PK_FILTER_ENUM_DEVELOPMENT,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+ return (PK_FILTER_ENUM_GUI |
+ PK_FILTER_ENUM_INSTALLED |
+ PK_FILTER_ENUM_DEVELOPMENT);
}
/**
diff --git a/backends/test/pk-backend-test-succeed.c b/backends/test/pk-backend-test-succeed.c
index df971c2..0b27b71 100644
--- a/backends/test/pk-backend-test-succeed.c
+++ b/backends/test/pk-backend-test-succeed.c
@@ -45,30 +45,26 @@ backend_destroy (PkBackend *backend)
/**
* backend_get_groups:
*/
-static void
-backend_get_groups (PkBackend *backend, PkEnumList *elist)
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_GROUP_ENUM_ACCESSIBILITY,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_SYSTEM,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return (PK_GROUP_ENUM_ACCESSIBILITY |
+ PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_SYSTEM);
}
/**
* backend_get_filters:
*/
-static void
-backend_get_filters (PkBackend *backend, PkEnumList *elist)
+static PkFilterEnum
+backend_get_filters (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_FILTER_ENUM_GUI,
- PK_FILTER_ENUM_INSTALLED,
- PK_FILTER_ENUM_DEVELOPMENT,
- PK_FILTER_ENUM_FREE,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+ return (PK_FILTER_ENUM_GUI |
+ PK_FILTER_ENUM_INSTALLED |
+ PK_FILTER_ENUM_DEVELOPMENT |
+ PK_FILTER_ENUM_FREE);
}
/**
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index aa3f853..2ef1ef6 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -58,48 +58,44 @@ backend_destroy (PkBackend *backend)
/**
* backend_get_groups:
*/
-static void
-backend_get_groups (PkBackend *backend, PkEnumList *elist)
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_GROUP_ENUM_ADMIN_TOOLS,
- PK_GROUP_ENUM_DESKTOP_GNOME,
- PK_GROUP_ENUM_DESKTOP_KDE,
- PK_GROUP_ENUM_DESKTOP_XFCE,
- PK_GROUP_ENUM_DESKTOP_OTHER,
- PK_GROUP_ENUM_EDUCATION,
- PK_GROUP_ENUM_FONTS,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_GRAPHICS,
- PK_GROUP_ENUM_INTERNET,
- PK_GROUP_ENUM_LEGACY,
- PK_GROUP_ENUM_LOCALIZATION,
- PK_GROUP_ENUM_MULTIMEDIA,
- PK_GROUP_ENUM_OFFICE,
- PK_GROUP_ENUM_OTHER,
- PK_GROUP_ENUM_PROGRAMMING,
- PK_GROUP_ENUM_PUBLISHING,
- PK_GROUP_ENUM_SERVERS,
- PK_GROUP_ENUM_SYSTEM,
- PK_GROUP_ENUM_VIRTUALIZATION,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return (PK_GROUP_ENUM_ADMIN_TOOLS |
+ PK_GROUP_ENUM_DESKTOP_GNOME |
+ PK_GROUP_ENUM_DESKTOP_KDE |
+ PK_GROUP_ENUM_DESKTOP_XFCE |
+ PK_GROUP_ENUM_DESKTOP_OTHER |
+ PK_GROUP_ENUM_EDUCATION |
+ PK_GROUP_ENUM_FONTS |
+ PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_GRAPHICS |
+ PK_GROUP_ENUM_INTERNET |
+ PK_GROUP_ENUM_LEGACY |
+ PK_GROUP_ENUM_LOCALIZATION |
+ PK_GROUP_ENUM_MULTIMEDIA |
+ PK_GROUP_ENUM_OFFICE |
+ PK_GROUP_ENUM_OTHER |
+ PK_GROUP_ENUM_PROGRAMMING |
+ PK_GROUP_ENUM_PUBLISHING |
+ PK_GROUP_ENUM_SERVERS |
+ PK_GROUP_ENUM_SYSTEM |
+ PK_GROUP_ENUM_VIRTUALIZATION);
}
/**
* backend_get_filters:
*/
-static void
-backend_get_filters (PkBackend *backend, PkEnumList *elist)
+static PkFilterEnum
+backend_get_filters (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_FILTER_ENUM_GUI,
- PK_FILTER_ENUM_INSTALLED,
- PK_FILTER_ENUM_DEVELOPMENT,
- PK_FILTER_ENUM_BASENAME,
- PK_FILTER_ENUM_FREE,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+ return (PK_FILTER_ENUM_GUI |
+ PK_FILTER_ENUM_INSTALLED |
+ PK_FILTER_ENUM_DEVELOPMENT |
+ PK_FILTER_ENUM_BASENAME |
+ PK_FILTER_ENUM_FREE);
}
/**
diff --git a/backends/yum2/pk-backend-yum2.c b/backends/yum2/pk-backend-yum2.c
index bdd4766..ac72768 100644
--- a/backends/yum2/pk-backend-yum2.c
+++ b/backends/yum2/pk-backend-yum2.c
@@ -60,47 +60,43 @@ backend_destroy (PkBackend *backend)
/**
* backend_get_groups:
*/
-static void
-backend_get_groups (PkBackend *backend, PkEnumList *elist)
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_GROUP_ENUM_ADMIN_TOOLS,
- PK_GROUP_ENUM_DESKTOP_GNOME,
- PK_GROUP_ENUM_DESKTOP_KDE,
- PK_GROUP_ENUM_DESKTOP_XFCE,
- PK_GROUP_ENUM_DESKTOP_OTHER,
- PK_GROUP_ENUM_EDUCATION,
- PK_GROUP_ENUM_FONTS,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_GRAPHICS,
- PK_GROUP_ENUM_INTERNET,
- PK_GROUP_ENUM_LEGACY,
- PK_GROUP_ENUM_LOCALIZATION,
- PK_GROUP_ENUM_MULTIMEDIA,
- PK_GROUP_ENUM_OFFICE,
- PK_GROUP_ENUM_OTHER,
- PK_GROUP_ENUM_PROGRAMMING,
- PK_GROUP_ENUM_PUBLISHING,
- PK_GROUP_ENUM_SERVERS,
- PK_GROUP_ENUM_SYSTEM,
- PK_GROUP_ENUM_VIRTUALIZATION,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return (PK_GROUP_ENUM_ADMIN_TOOLS |
+ PK_GROUP_ENUM_DESKTOP_GNOME |
+ PK_GROUP_ENUM_DESKTOP_KDE |
+ PK_GROUP_ENUM_DESKTOP_XFCE |
+ PK_GROUP_ENUM_DESKTOP_OTHER |
+ PK_GROUP_ENUM_EDUCATION |
+ PK_GROUP_ENUM_FONTS |
+ PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_GRAPHICS |
+ PK_GROUP_ENUM_INTERNET |
+ PK_GROUP_ENUM_LEGACY |
+ PK_GROUP_ENUM_LOCALIZATION |
+ PK_GROUP_ENUM_MULTIMEDIA |
+ PK_GROUP_ENUM_OFFICE |
+ PK_GROUP_ENUM_OTHER |
+ PK_GROUP_ENUM_PROGRAMMING |
+ PK_GROUP_ENUM_PUBLISHING |
+ PK_GROUP_ENUM_SERVERS |
+ PK_GROUP_ENUM_SYSTEM |
+ PK_GROUP_ENUM_VIRTUALIZATION);
}
/**
* backend_get_filters:
*/
-static void
-backend_get_filters (PkBackend *backend, PkEnumList *elist)
+static PkFilterEnum
+backend_get_filters (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_FILTER_ENUM_GUI,
- PK_FILTER_ENUM_INSTALLED,
- PK_FILTER_ENUM_DEVELOPMENT,
- PK_FILTER_ENUM_FREE,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+ return (PK_FILTER_ENUM_GUI |
+ PK_FILTER_ENUM_INSTALLED |
+ PK_FILTER_ENUM_DEVELOPMENT |
+ PK_FILTER_ENUM_FREE);
}
/**
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 1eaedf8..36e243c 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -330,42 +330,38 @@ backend_get_requires(PkBackend *backend, const gchar *filter, const gchar *packa
/**
* backend_get_groups:
*/
-static void
-backend_get_groups (PkBackend *backend, PkEnumList *elist)
+static PkGroupEnum
+backend_get_groups (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_GRAPHICS,
- PK_GROUP_ENUM_OFFICE,
- PK_GROUP_ENUM_PROGRAMMING,
- PK_GROUP_ENUM_MULTIMEDIA,
- PK_GROUP_ENUM_SYSTEM,
- PK_GROUP_ENUM_DESKTOP_GNOME,
- PK_GROUP_ENUM_DESKTOP_KDE,
- PK_GROUP_ENUM_DESKTOP_XFCE,
- PK_GROUP_ENUM_DESKTOP_OTHER,
- PK_GROUP_ENUM_PUBLISHING,
- PK_GROUP_ENUM_ADMIN_TOOLS,
- PK_GROUP_ENUM_LOCALIZATION,
- PK_GROUP_ENUM_SECURITY,
- PK_GROUP_ENUM_EDUCATION,
- PK_GROUP_ENUM_COMMUNICATION,
- PK_GROUP_ENUM_NETWORK,
- PK_GROUP_ENUM_UNKNOWN,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return (PK_GROUP_ENUM_GAMES |
+ PK_GROUP_ENUM_GRAPHICS |
+ PK_GROUP_ENUM_OFFICE |
+ PK_GROUP_ENUM_PROGRAMMING |
+ PK_GROUP_ENUM_MULTIMEDIA |
+ PK_GROUP_ENUM_SYSTEM |
+ PK_GROUP_ENUM_DESKTOP_GNOME |
+ PK_GROUP_ENUM_DESKTOP_KDE |
+ PK_GROUP_ENUM_DESKTOP_XFCE |
+ PK_GROUP_ENUM_DESKTOP_OTHER |
+ PK_GROUP_ENUM_PUBLISHING |
+ PK_GROUP_ENUM_ADMIN_TOOLS |
+ PK_GROUP_ENUM_LOCALIZATION |
+ PK_GROUP_ENUM_SECURITY |
+ PK_GROUP_ENUM_EDUCATION |
+ PK_GROUP_ENUM_COMMUNICATION |
+ PK_GROUP_ENUM_NETWORK |
+ PK_GROUP_ENUM_UNKNOWN);
}
/**
* backend_get_filters:
*/
-static void
-backend_get_filters (PkBackend *backend, PkEnumList *elist)
+static PkFilterEnum
+backend_get_filters (PkBackend *backend)
{
- g_return_if_fail (backend != NULL);
- pk_enum_list_append_multiple (elist,
- PK_FILTER_ENUM_INSTALLED,
- -1);
+ g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
+ return PK_FILTER_ENUM_INSTALLED;
}
static gboolean
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index eab463d..565f817 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -618,6 +618,38 @@ pk_role_enum_to_text (PkRoleEnum role)
}
/**
+ * pk_roles_enums_to_text:
+ * @filters: The enumerated type values
+ *
+ * Converts a enumerated type bitfield to its text representation
+ *
+ * Return value: the enumerated constant value, e.g. "install-file;update-system"
+ **/
+gchar *
+pk_role_enums_to_text (PkRoleEnum roles)
+{
+ GString *string;
+ guint i;
+
+ string = g_string_new ("");
+ for (i=1; i<PK_ROLE_ENUM_UNKNOWN; i*=2) {
+ if ((roles & i) == 0) {
+ continue;
+ }
+ g_string_append_printf (string, "%s;", pk_role_enum_to_text (i));
+ }
+ /* do we have a no enums? \n */
+ if (string->len == 0) {
+ pk_warning ("not valid!");
+ g_string_append (string, pk_role_enum_to_text (PK_ROLE_ENUM_UNKNOWN));
+ } else {
+ /* remove last \n */
+ g_string_set_size (string, string->len - 1);
+ }
+ return g_string_free (string, FALSE);
+}
+
+/**
* pk_error_enum_from_text:
* @code: Text describing the enumerated type
*
@@ -730,6 +762,38 @@ pk_group_enum_to_text (PkGroupEnum group)
}
/**
+ * pk_groups_enums_to_text:
+ * @filters: The enumerated type values
+ *
+ * Converts a enumerated type bitfield to its text representation
+ *
+ * Return value: the enumerated constant value, e.g. "gnome;kde"
+ **/
+gchar *
+pk_group_enums_to_text (PkGroupEnum groups)
+{
+ GString *string;
+ guint i;
+
+ string = g_string_new ("");
+ for (i=1; i<PK_GROUP_ENUM_UNKNOWN; i*=2) {
+ if ((groups & i) == 0) {
+ continue;
+ }
+ g_string_append_printf (string, "%s;", pk_group_enum_to_text (i));
+ }
+ /* do we have a no enums? \n */
+ if (string->len == 0) {
+ pk_warning ("not valid!");
+ g_string_append (string, pk_group_enum_to_text (PK_GROUP_ENUM_UNKNOWN));
+ } else {
+ /* remove last \n */
+ g_string_set_size (string, string->len - 1);
+ }
+ return g_string_free (string, FALSE);
+}
+
+/**
* pk_freq_enum_from_text:
* @freq: Text describing the enumerated type
*
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 4d4fbd2..9b26f47 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -489,6 +489,7 @@ const gchar *pk_status_enum_to_text (PkStatusEnum status);
PkRoleEnum pk_role_enum_from_text (const gchar *role);
const gchar *pk_role_enum_to_text (PkRoleEnum role);
+gchar *pk_role_enums_to_text (PkRoleEnum roles);
PkErrorCodeEnum pk_error_enum_from_text (const gchar *code);
const gchar *pk_error_enum_to_text (PkErrorCodeEnum code);
@@ -501,6 +502,7 @@ const gchar *pk_message_enum_to_text (PkMessageEnum message);
PkGroupEnum pk_group_enum_from_text (const gchar *group);
const gchar *pk_group_enum_to_text (PkGroupEnum group);
+gchar *pk_group_enums_to_text (PkGroupEnum groups);
PkFilterEnum pk_filter_enum_from_text (const gchar *filter);
const gchar *pk_filter_enum_to_text (PkFilterEnum filter);
diff --git a/src/pk-backend-internal.h b/src/pk-backend-internal.h
index 2bf6594..f830654 100644
--- a/src/pk-backend-internal.h
+++ b/src/pk-backend-internal.h
@@ -65,6 +65,9 @@ gchar *pk_backend_get_name (PkBackend *backend)
gboolean pk_backend_get_backend_detail (PkBackend *backend,
gchar **name,
gchar **author);
+PkGroupEnum pk_backend_get_groups (PkBackend *backend);
+PkFilterEnum pk_backend_get_filters (PkBackend *backend);
+PkRoleEnum pk_backend_get_actions (PkBackend *backend);
G_END_DECLS
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 8f736f1..7b623a6 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -123,6 +123,119 @@ enum {
static guint signals [PK_BACKEND_LAST_SIGNAL] = { 0 };
/**
+ * pk_backend_get_groups:
+ **/
+PkGroupEnum
+pk_backend_get_groups (PkBackend *backend)
+{
+ g_return_val_if_fail (PK_IS_BACKEND (backend), PK_GROUP_ENUM_UNKNOWN);
+ g_return_val_if_fail (backend->priv->locked != FALSE, PK_GROUP_ENUM_UNKNOWN);
+ g_return_val_if_fail (backend->desc->get_groups != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return backend->desc->get_groups (backend);
+}
+
+/**
+ * pk_backend_get_filters:
+ **/
+PkFilterEnum
+pk_backend_get_filters (PkBackend *backend)
+{
+ g_return_val_if_fail (PK_IS_BACKEND (backend), PK_FILTER_ENUM_UNKNOWN);
+ g_return_val_if_fail (backend->priv->locked != FALSE, PK_FILTER_ENUM_UNKNOWN);
+ g_return_val_if_fail (backend->desc->get_filters != NULL, PK_GROUP_ENUM_UNKNOWN);
+ return backend->desc->get_filters (backend);
+}
+
+/**
+ * pk_backend_get_actions:
+ **/
+PkRoleEnum
+pk_backend_get_actions (PkBackend *backend)
+{
+ PkRoleEnum roles = 0;
+ PkBackendDesc *desc;
+
+ g_return_val_if_fail (PK_IS_BACKEND (backend), PK_ROLE_ENUM_UNKNOWN);
+ g_return_val_if_fail (backend->priv->locked != FALSE, PK_ROLE_ENUM_UNKNOWN);
+
+ /* lets reduce pointer dereferences... */
+ desc = backend->desc;
+ if (desc->cancel != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_CANCEL);
+ }
+ if (desc->get_depends != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_GET_DEPENDS);
+ }
+ if (desc->get_description != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_GET_DESCRIPTION);
+ }
+ if (desc->get_files != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_GET_FILES);
+ }
+ if (desc->get_requires != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_GET_REQUIRES);
+ }
+ if (desc->get_packages != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_GET_PACKAGES);
+ }
+ if (desc->what_provides != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_WHAT_PROVIDES);
+ }
+ if (desc->get_updates != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_GET_UPDATES);
+ }
+ if (desc->get_update_detail != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_GET_UPDATE_DETAIL);
+ }
+ if (desc->install_package != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_INSTALL_PACKAGE);
+ }
+ if (desc->install_file != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_INSTALL_FILE);
+ }
+ if (desc->refresh_cache != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_REFRESH_CACHE);
+ }
+ if (desc->remove_package != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_REMOVE_PACKAGE);
+ }
+ if (desc->resolve != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_RESOLVE);
+ }
+ if (desc->rollback != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_ROLLBACK);
+ }
+ if (desc->search_details != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_SEARCH_DETAILS);
+ }
+ if (desc->search_file != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_SEARCH_FILE);
+ }
+ if (desc->search_group != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_SEARCH_GROUP);
+ }
+ if (desc->search_name != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_SEARCH_NAME);
+ }
+ if (desc->update_packages != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_UPDATE_PACKAGES);
+ }
+ if (desc->update_system != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_UPDATE_SYSTEM);
+ }
+ if (desc->get_repo_list != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_GET_REPO_LIST);
+ }
+ if (desc->repo_enable != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_REPO_ENABLE);
+ }
+ if (desc->repo_set_data != NULL) {
+ pk_enums_add (roles, PK_ROLE_ENUM_REPO_SET_DATA);
+ }
+ return roles;
+}
+
+/**
* pk_backend_set_internal:
*
* Designed for volatile internal state, such as the authentication prompt
diff --git a/src/pk-backend.h b/src/pk-backend.h
index 9f6b79f..0533033 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -132,10 +132,8 @@ typedef struct {
const char *author;
void (*initialize) (PkBackend *backend);
void (*destroy) (PkBackend *backend);
- void (*get_groups) (PkBackend *backend,
- PkEnumList *elist);
- void (*get_filters) (PkBackend *backend,
- PkEnumList *elist);
+ PkGroupEnum (*get_groups) (PkBackend *backend);
+ PkFilterEnum (*get_filters) (PkBackend *backend);
void (*cancel) (PkBackend *backend);
void (*get_depends) (PkBackend *backend,
const gchar *filter,
diff --git a/src/pk-engine.c b/src/pk-engine.c
index b252943..92cf174 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -46,7 +46,6 @@
#include <pk-network.h>
#include <pk-package-list.h>
#include <pk-enum.h>
-#include <pk-enum-list.h>
#include "pk-cache.h"
#include "pk-backend.h"
@@ -91,9 +90,9 @@ struct PkEnginePrivate
PkNetwork *network;
PkNotify *notify;
PkRestart *restart;
- PkEnumList *actions;
- PkEnumList *groups;
- PkEnumList *filters;
+ PkRoleEnum actions;
+ PkGroupEnum groups;
+ PkFilterEnum filters;
gboolean signal_state_timeout; /* don't queue StateHasChanged */
};
@@ -325,7 +324,7 @@ gboolean
pk_engine_get_actions (PkEngine *engine, gchar **actions, GError **error)
{
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- *actions = pk_enum_list_to_string (engine->priv->actions);
+ *actions = pk_role_enums_to_text (engine->priv->actions);
return TRUE;
}
@@ -336,7 +335,7 @@ gboolean
pk_engine_get_groups (PkEngine *engine, gchar **groups, GError **error)
{
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- *groups = pk_enum_list_to_string (engine->priv->groups);
+ *groups = pk_group_enums_to_text (engine->priv->groups);
return TRUE;
}
@@ -347,7 +346,7 @@ gboolean
pk_engine_get_filters (PkEngine *engine, gchar **filters, GError **error)
{
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- *filters = pk_enum_list_to_string (engine->priv->filters);
+ *filters = pk_filter_enums_to_text (engine->priv->filters);
return TRUE;
}
@@ -466,139 +465,6 @@ pk_engine_restart_schedule_cb (PkRestart *restart, PkEngine *engine)
}
/**
- * pk_engine_get_actions_internal:
- *
- * You need to g_object_unref the returned object
- */
-static PkEnumList *
-pk_engine_get_actions_internal (PkEngine *engine)
-{
- PkEnumList *elist;
- PkBackendDesc *desc;
-
- g_return_val_if_fail (engine != NULL, NULL);
-
- /* lets reduce pointer dereferences... */
- desc = engine->priv->backend->desc;
-
- elist = pk_enum_list_new ();
- pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ROLE);
- if (desc->cancel != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_CANCEL);
- }
- if (desc->get_depends != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_GET_DEPENDS);
- }
- if (desc->get_description != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_GET_DESCRIPTION);
- }
- if (desc->get_files != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_GET_FILES);
- }
- if (desc->get_requires != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_GET_REQUIRES);
- }
- if (desc->get_packages != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_GET_PACKAGES);
- }
- if (desc->what_provides != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_WHAT_PROVIDES);
- }
- if (desc->get_updates != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_GET_UPDATES);
- }
- if (desc->get_update_detail != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_GET_UPDATE_DETAIL);
- }
- if (desc->install_package != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_INSTALL_PACKAGE);
- }
- if (desc->install_file != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_INSTALL_FILE);
- }
- if (desc->refresh_cache != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_REFRESH_CACHE);
- }
- if (desc->remove_package != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_REMOVE_PACKAGE);
- }
- if (desc->resolve != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_RESOLVE);
- }
- if (desc->rollback != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_ROLLBACK);
- }
- if (desc->search_details != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_SEARCH_DETAILS);
- }
- if (desc->search_file != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_SEARCH_FILE);
- }
- if (desc->search_group != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_SEARCH_GROUP);
- }
- if (desc->search_name != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_SEARCH_NAME);
- }
- if (desc->update_packages != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_UPDATE_PACKAGES);
- }
- if (desc->update_system != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_UPDATE_SYSTEM);
- }
- if (desc->get_repo_list != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_GET_REPO_LIST);
- }
- if (desc->repo_enable != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_REPO_ENABLE);
- }
- if (desc->repo_set_data != NULL) {
- pk_enum_list_append (elist, PK_ROLE_ENUM_REPO_SET_DATA);
- }
- return elist;
-}
-
-/**
- * pk_engine_get_groups_internal:
- *
- * You need to g_object_unref the returned object
- */
-static PkEnumList *
-pk_engine_get_groups_internal (PkEngine *engine)
-{
- PkEnumList *elist;
-
- g_return_val_if_fail (engine != NULL, NULL);
-
- elist = pk_enum_list_new ();
- pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_GROUP);
- if (engine->priv->backend->desc->get_groups != NULL) {
- engine->priv->backend->desc->get_groups (engine->priv->backend, elist);
- }
- return elist;
-}
-
-/**
- * pk_engine_get_filters_internal:
- *
- * You need to g_object_unref the returned object
- */
-static PkEnumList *
-pk_engine_get_filters_internal (PkEngine *engine)
-{
- PkEnumList *elist;
-
- g_return_val_if_fail (engine != NULL, NULL);
-
- elist = pk_enum_list_new ();
- pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_FILTER);
- if (engine->priv->backend->desc->get_filters != NULL) {
- engine->priv->backend->desc->get_filters (engine->priv->backend, elist);
- }
- return elist;
-}
-
-/**
* pk_engine_init:
**/
static void
@@ -625,9 +491,9 @@ pk_engine_init (PkEngine *engine)
engine->priv->network = pk_network_new ();
/* create a new backend so we can get the static stuff */
- engine->priv->actions = pk_engine_get_actions_internal (engine);
- engine->priv->groups = pk_engine_get_groups_internal (engine);
- engine->priv->filters = pk_engine_get_filters_internal (engine);
+ engine->priv->actions = pk_backend_get_actions (engine->priv->backend);
+ engine->priv->groups = pk_backend_get_groups (engine->priv->backend);
+ engine->priv->filters = pk_backend_get_filters (engine->priv->backend);
engine->priv->timer = g_timer_new ();
@@ -710,17 +576,6 @@ pk_engine_finalize (GObject *object)
g_object_unref (engine->priv->backend);
g_object_unref (engine->priv->cache);
- /* optional gobjects */
- if (engine->priv->actions != NULL) {
- g_object_unref (engine->priv->actions);
- }
- if (engine->priv->groups != NULL) {
- g_object_unref (engine->priv->groups);
- }
- if (engine->priv->filters != NULL) {
- g_object_unref (engine->priv->filters);
- }
-
G_OBJECT_CLASS (pk_engine_parent_class)->finalize (object);
}
commit ec44a3e3c2ac83c9bb8646f6a9d28450e7560322
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Apr 11 03:53:02 2008 +0100
typo, oops
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 4502973..4d4fbd2 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -233,35 +233,35 @@ typedef enum {
* The group type
**/
typedef enum {
- PK_GROUP_ENUM_ACCESSIBILITY, = 1 << 0,
- PK_GROUP_ENUM_ACCESSORIES, = 1 << 1,
- PK_GROUP_ENUM_ADMIN_TOOLS, = 1 << 2,
- PK_GROUP_ENUM_COMMUNICATION, = 1 << 3,
- PK_GROUP_ENUM_DESKTOP_GNOME, = 1 << 4,
- PK_GROUP_ENUM_DESKTOP_KDE, = 1 << 5,
- PK_GROUP_ENUM_DESKTOP_OTHER, = 1 << 6,
- PK_GROUP_ENUM_DESKTOP_XFCE, = 1 << 7,
- PK_GROUP_ENUM_EDUCATION, = 1 << 8,
- PK_GROUP_ENUM_FONTS, = 1 << 9,
- PK_GROUP_ENUM_GAMES, = 1 << 10,
- PK_GROUP_ENUM_GRAPHICS, = 1 << 11,
- PK_GROUP_ENUM_INTERNET, = 1 << 12,
- PK_GROUP_ENUM_LEGACY, = 1 << 13,
- PK_GROUP_ENUM_LOCALIZATION, = 1 << 14,
- PK_GROUP_ENUM_MAPS, = 1 << 15,
- PK_GROUP_ENUM_MULTIMEDIA, = 1 << 16,
- PK_GROUP_ENUM_NETWORK, = 1 << 17,
- PK_GROUP_ENUM_OFFICE, = 1 << 18,
- PK_GROUP_ENUM_OTHER, = 1 << 19,
- PK_GROUP_ENUM_POWER_MANAGEMENT, = 1 << 20,
- PK_GROUP_ENUM_PROGRAMMING, = 1 << 21,
- PK_GROUP_ENUM_PUBLISHING, = 1 << 22,
- PK_GROUP_ENUM_REPOS, = 1 << 23,
- PK_GROUP_ENUM_SECURITY, = 1 << 24,
- PK_GROUP_ENUM_SERVERS, = 1 << 25,
- PK_GROUP_ENUM_SYSTEM, = 1 << 26,
- PK_GROUP_ENUM_VIRTUALIZATION, = 1 << 27,
- PK_GROUP_ENUM_UNKNOWN = 1 << 28,
+ PK_GROUP_ENUM_ACCESSIBILITY = 1 << 0,
+ PK_GROUP_ENUM_ACCESSORIES = 1 << 1,
+ PK_GROUP_ENUM_ADMIN_TOOLS = 1 << 2,
+ PK_GROUP_ENUM_COMMUNICATION = 1 << 3,
+ PK_GROUP_ENUM_DESKTOP_GNOME = 1 << 4,
+ PK_GROUP_ENUM_DESKTOP_KDE = 1 << 5,
+ PK_GROUP_ENUM_DESKTOP_OTHER = 1 << 6,
+ PK_GROUP_ENUM_DESKTOP_XFCE = 1 << 7,
+ PK_GROUP_ENUM_EDUCATION = 1 << 8,
+ PK_GROUP_ENUM_FONTS = 1 << 9,
+ PK_GROUP_ENUM_GAMES = 1 << 10,
+ PK_GROUP_ENUM_GRAPHICS = 1 << 11,
+ PK_GROUP_ENUM_INTERNET = 1 << 12,
+ PK_GROUP_ENUM_LEGACY = 1 << 13,
+ PK_GROUP_ENUM_LOCALIZATION = 1 << 14,
+ PK_GROUP_ENUM_MAPS = 1 << 15,
+ PK_GROUP_ENUM_MULTIMEDIA = 1 << 16,
+ PK_GROUP_ENUM_NETWORK = 1 << 17,
+ PK_GROUP_ENUM_OFFICE = 1 << 18,
+ PK_GROUP_ENUM_OTHER = 1 << 19,
+ PK_GROUP_ENUM_POWER_MANAGEMENT = 1 << 20,
+ PK_GROUP_ENUM_PROGRAMMING = 1 << 21,
+ PK_GROUP_ENUM_PUBLISHING = 1 << 22,
+ PK_GROUP_ENUM_REPOS = 1 << 23,
+ PK_GROUP_ENUM_SECURITY = 1 << 24,
+ PK_GROUP_ENUM_SERVERS = 1 << 25,
+ PK_GROUP_ENUM_SYSTEM = 1 << 26,
+ PK_GROUP_ENUM_VIRTUALIZATION = 1 << 27,
+ PK_GROUP_ENUM_UNKNOWN = 1 << 28
} PkGroupEnum;
/**
commit c6758148b6bd537cc2538cc92eeb54904c03d28c
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Apr 11 03:19:14 2008 +0100
make the group enum a bitfield
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index bce00df..4502973 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -233,35 +233,35 @@ typedef enum {
* The group type
**/
typedef enum {
- PK_GROUP_ENUM_ACCESSIBILITY,
- PK_GROUP_ENUM_ACCESSORIES,
- PK_GROUP_ENUM_EDUCATION,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_GRAPHICS,
- PK_GROUP_ENUM_INTERNET,
- PK_GROUP_ENUM_OFFICE,
- PK_GROUP_ENUM_OTHER,
- PK_GROUP_ENUM_PROGRAMMING,
- PK_GROUP_ENUM_MULTIMEDIA,
- PK_GROUP_ENUM_SYSTEM,
- PK_GROUP_ENUM_DESKTOP_GNOME,
- PK_GROUP_ENUM_DESKTOP_KDE,
- PK_GROUP_ENUM_DESKTOP_XFCE,
- PK_GROUP_ENUM_DESKTOP_OTHER,
- PK_GROUP_ENUM_PUBLISHING,
- PK_GROUP_ENUM_SERVERS,
- PK_GROUP_ENUM_FONTS,
- PK_GROUP_ENUM_ADMIN_TOOLS,
- PK_GROUP_ENUM_LEGACY,
- PK_GROUP_ENUM_LOCALIZATION,
- PK_GROUP_ENUM_VIRTUALIZATION,
- PK_GROUP_ENUM_SECURITY,
- PK_GROUP_ENUM_POWER_MANAGEMENT,
- PK_GROUP_ENUM_COMMUNICATION,
- PK_GROUP_ENUM_NETWORK,
- PK_GROUP_ENUM_MAPS,
- PK_GROUP_ENUM_REPOS,
- PK_GROUP_ENUM_UNKNOWN
+ PK_GROUP_ENUM_ACCESSIBILITY, = 1 << 0,
+ PK_GROUP_ENUM_ACCESSORIES, = 1 << 1,
+ PK_GROUP_ENUM_ADMIN_TOOLS, = 1 << 2,
+ PK_GROUP_ENUM_COMMUNICATION, = 1 << 3,
+ PK_GROUP_ENUM_DESKTOP_GNOME, = 1 << 4,
+ PK_GROUP_ENUM_DESKTOP_KDE, = 1 << 5,
+ PK_GROUP_ENUM_DESKTOP_OTHER, = 1 << 6,
+ PK_GROUP_ENUM_DESKTOP_XFCE, = 1 << 7,
+ PK_GROUP_ENUM_EDUCATION, = 1 << 8,
+ PK_GROUP_ENUM_FONTS, = 1 << 9,
+ PK_GROUP_ENUM_GAMES, = 1 << 10,
+ PK_GROUP_ENUM_GRAPHICS, = 1 << 11,
+ PK_GROUP_ENUM_INTERNET, = 1 << 12,
+ PK_GROUP_ENUM_LEGACY, = 1 << 13,
+ PK_GROUP_ENUM_LOCALIZATION, = 1 << 14,
+ PK_GROUP_ENUM_MAPS, = 1 << 15,
+ PK_GROUP_ENUM_MULTIMEDIA, = 1 << 16,
+ PK_GROUP_ENUM_NETWORK, = 1 << 17,
+ PK_GROUP_ENUM_OFFICE, = 1 << 18,
+ PK_GROUP_ENUM_OTHER, = 1 << 19,
+ PK_GROUP_ENUM_POWER_MANAGEMENT, = 1 << 20,
+ PK_GROUP_ENUM_PROGRAMMING, = 1 << 21,
+ PK_GROUP_ENUM_PUBLISHING, = 1 << 22,
+ PK_GROUP_ENUM_REPOS, = 1 << 23,
+ PK_GROUP_ENUM_SECURITY, = 1 << 24,
+ PK_GROUP_ENUM_SERVERS, = 1 << 25,
+ PK_GROUP_ENUM_SYSTEM, = 1 << 26,
+ PK_GROUP_ENUM_VIRTUALIZATION, = 1 << 27,
+ PK_GROUP_ENUM_UNKNOWN = 1 << 28,
} PkGroupEnum;
/**
More information about the PackageKit-commit
mailing list