[PackageKit-commit] packagekit: Branch 'master' - 4 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Fri May 2 03:24:24 PDT 2008
backends/yum/helpers/yumBackend.py | 2
client/pk-import-desktop.c | 18 +
client/pk-import-specspo.c | 2
configure.ac | 4
libpackagekit/pk-enum.c | 1
libpackagekit/pk-enum.h | 1
libpackagekit/pk-extra.c | 423 ++++++++++++++++---------------------
libpackagekit/pk-extra.h | 22 +
src/pk-network-nm-dummy.c | 2
9 files changed, 220 insertions(+), 255 deletions(-)
New commits:
commit 5a10be4c03865ed6fb9cfe0f1491c1f1b644c409
Author: Tick <tick at openmoko.com>
Date: Fri May 2 11:23:29 2008 +0100
compile fix for not NETWORK_MANAGER
diff --git a/src/pk-network-nm-dummy.c b/src/pk-network-nm-dummy.c
index e7753d1..c5b10b3 100644
--- a/src/pk-network-nm-dummy.c
+++ b/src/pk-network-nm-dummy.c
@@ -39,7 +39,7 @@
#include <glib/gi18n.h>
#include "pk-debug.h"
-#include "pk-network_nm.h"
+#include "pk-network-nm.h"
#include "pk-marshal.h"
static void pk_network_nm_class_init (PkNetworkNmClass *klass);
commit 91fc7d5e97789299eb2d740f7722d301da9ae88d
Author: Richard Hughes <richard at hughsie.com>
Date: Fri May 2 03:16:25 2008 +0100
massivly simplify PkExtra; we can keep all the data hot in memory - it's only a few tens of Kb
diff --git a/client/pk-import-desktop.c b/client/pk-import-desktop.c
index 3edebbf..f5be0a5 100644
--- a/client/pk-import-desktop.c
+++ b/client/pk-import-desktop.c
@@ -127,6 +127,16 @@ pk_desktop_process_desktop (const gchar *package_name, const gchar *filename)
gsize len;
gchar *locale_temp;
static GPtrArray *locale_array = NULL;
+ const gchar *icon_name;
+ const gchar *summary;
+
+ /* can we optimise for the common case? */
+ icon_name = pk_extra_get_icon_name (extra, package_name);
+ summary = pk_extra_get_summary (extra, package_name);
+ if (icon_name != NULL || summary != NULL) {
+ g_print ("PackageName:\t%s\t[skipping]\n", package_name);
+ return;
+ }
key = g_key_file_new ();
ret = g_key_file_load_from_file (key, filename, G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
@@ -172,11 +182,11 @@ pk_desktop_process_desktop (const gchar *package_name, const gchar *filename)
/* save in order of priority */
if (comment != NULL) {
- pk_extra_set_localised_detail (extra, package_name, comment);
+ pk_extra_set_data_locale (extra, package_name, comment);
} else if (genericname != NULL) {
- pk_extra_set_localised_detail (extra, package_name, genericname);
+ pk_extra_set_data_locale (extra, package_name, genericname);
} else {
- pk_extra_set_localised_detail (extra, package_name, name);
+ pk_extra_set_data_locale (extra, package_name, name);
}
g_free (comment);
g_free (genericname);
@@ -190,7 +200,7 @@ pk_desktop_process_desktop (const gchar *package_name, const gchar *filename)
exec = g_key_file_get_string (key, G_KEY_FILE_DESKTOP_GROUP, "Exec", NULL);
icon = g_key_file_get_string (key, G_KEY_FILE_DESKTOP_GROUP, "Icon", NULL);
pk_debug ("PackageName=%s, Exec=%s, Icon=%s", package_name, exec, icon);
- pk_extra_set_package_detail (extra, package_name, icon, exec);
+ pk_extra_set_data_package (extra, package_name, icon, exec);
g_free (icon);
g_free (exec);
diff --git a/client/pk-import-specspo.c b/client/pk-import-specspo.c
index bd37480..cf14cc2 100644
--- a/client/pk-import-specspo.c
+++ b/client/pk-import-specspo.c
@@ -122,7 +122,7 @@ pk_import_specspo_do_package (const gchar *package_name)
g_print (" %s", locale);
// g_print (" %s", trans);
pk_extra_set_locale (extra, locale);
- pk_extra_set_localised_detail (extra, package_name, trans);
+ pk_extra_set_data_locale (extra, package_name, trans);
}
}
}
diff --git a/libpackagekit/pk-extra.c b/libpackagekit/pk-extra.c
index c769645..da50127 100644
--- a/libpackagekit/pk-extra.c
+++ b/libpackagekit/pk-extra.c
@@ -61,14 +61,22 @@ struct _PkExtraPrivate
gchar *database;
gchar *locale;
gchar *locale_base;
- gchar *icon;
- gchar *exec;
- gchar *summary;
sqlite3 *db;
GHashTable *hash_locale;
GHashTable *hash_package;
};
+typedef struct
+{
+ gchar *summary;
+} PkExtraLocaleObj;
+
+typedef struct
+{
+ gchar *icon_name;
+ gchar *exec;
+} PkExtraPackageObj;
+
G_DEFINE_TYPE (PkExtra, pk_extra, G_TYPE_OBJECT)
static gpointer pk_extra_object = NULL;
@@ -79,20 +87,54 @@ static gint
pk_extra_populate_package_cache_callback (void *data, gint argc, gchar **argv, gchar **col_name)
{
PkExtra *extra = PK_EXTRA (data);
+ PkExtraPackageObj *obj;
gint i;
gchar *col;
gchar *value;
+ gchar *package = NULL;
+ gchar *icon_name = NULL;
+ gchar *exec = NULL;
g_return_val_if_fail (PK_IS_EXTRA (extra), 0);
for (i=0; i<argc; i++) {
col = col_name[i];
value = argv[i];
- /* just insert it, as we match on the package */
+ /* save the package name, and use it is the key */
if (pk_strequal (col, "package") && value != NULL) {
- g_hash_table_insert (extra->priv->hash_package, g_strdup (value), GUINT_TO_POINTER (1));
+pk_warning ("package=%s", argv[i]);
+ package = g_strdup (argv[i]);
+ } else if (pk_strequal (col, "icon") && value != NULL) {
+pk_warning ("icon_name=%s", argv[i]);
+ icon_name = g_strdup (argv[i]);
+ } else if (pk_strequal (col, "exec") && value != NULL) {
+pk_warning ("exec=%s", argv[i]);
+ exec = g_strdup (argv[i]);
}
}
+
+ /* sanity check */
+ if (package == NULL) {
+ pk_warning ("package data invalid (%s,%s,%s)", package, icon_name, exec);
+ goto out;
+ }
+
+ /* check we are not already added */
+ obj = g_hash_table_lookup (extra->priv->hash_package, package);
+ if (obj != NULL) {
+ pk_debug ("not adding duplicate %s, %s", package, icon_name);
+ g_free (exec);
+ g_free (package);
+ g_free (icon_name);
+ goto out;
+ }
+
+ obj = g_new (PkExtraPackageObj, 1);
+ obj->icon_name = icon_name;
+ obj->exec = exec;
+ g_hash_table_insert (extra->priv->hash_package, (gpointer) package, (gpointer) obj);
+ pk_debug ("adding %s, %s", package, icon_name);
+out:
return 0;
}
@@ -103,11 +145,12 @@ static gint
pk_extra_populate_locale_cache_callback (void *data, gint argc, gchar **argv, gchar **col_name)
{
PkExtra *extra = PK_EXTRA (data);
+ PkExtraLocaleObj *obj;
gint i;
gchar *col;
gchar *value;
- gchar **package = NULL;
- gchar **summary = NULL;
+ gchar *package = NULL;
+ gchar *summary = NULL;
g_return_val_if_fail (PK_IS_EXTRA (extra), 0);
@@ -116,17 +159,32 @@ pk_extra_populate_locale_cache_callback (void *data, gint argc, gchar **argv, gc
value = argv[i];
/* save the package name, and use it is the key */
if (pk_strequal (col, "package") && value != NULL) {
- package = &argv[i];
+ package = g_strdup (argv[i]);
} else if (pk_strequal (col, "summary") && value != NULL) {
- summary = &argv[i];
+ summary = g_strdup (argv[i]);
}
}
- /* only when both non-NULL */
- if (package != NULL && summary != NULL) {
- g_hash_table_insert (extra->priv->hash_locale, g_strdup (*package), GUINT_TO_POINTER (1));
+ /* sanity check */
+ if (package == NULL) {
+ pk_warning ("package data invalid (%s,%s)", package, summary);
+ goto out;
+ }
+
+ /* check we are not already added */
+ obj = g_hash_table_lookup (extra->priv->hash_locale, package);
+ if (obj != NULL) {
+ pk_debug ("not adding duplicate %s, %s", package, summary);
+ g_free (package);
+ g_free (summary);
+ goto out;
}
+ obj = g_new (PkExtraLocaleObj, 1);
+ obj->summary = summary;
+ g_hash_table_insert (extra->priv->hash_locale, (gpointer) package, (gpointer) obj);
+ pk_debug ("adding %s, %s", package, summary);
+out:
return 0;
}
@@ -139,7 +197,7 @@ pk_extra_populate_locale_cache_callback (void *data, gint argc, gchar **argv, gc
static gboolean
pk_extra_populate_locale_cache (PkExtra *extra)
{
- const gchar *statement = NULL;
+ gchar *statement = NULL;
gchar *error_msg = NULL;
gint rc;
@@ -153,8 +211,19 @@ pk_extra_populate_locale_cache (PkExtra *extra)
}
/* get summary packages */
- statement = "SELECT package, summary FROM localised";
+ statement = g_strdup_printf ("SELECT package, summary FROM localised WHERE locale = '%s'", extra->priv->locale);
+ rc = sqlite3_exec (extra->priv->db, statement, pk_extra_populate_locale_cache_callback, extra, &error_msg);
+ g_free (statement);
+ if (rc != SQLITE_OK) {
+ pk_warning ("SQL error: %s\n", error_msg);
+ sqlite3_free (error_msg);
+ return FALSE;
+ }
+
+ /* get summary packages - base */
+ statement = g_strdup_printf ("SELECT package, summary FROM localised WHERE locale = '%s'", extra->priv->locale_base);
rc = sqlite3_exec (extra->priv->db, statement, pk_extra_populate_locale_cache_callback, extra, &error_msg);
+ g_free (statement);
if (rc != SQLITE_OK) {
pk_warning ("SQL error: %s\n", error_msg);
sqlite3_free (error_msg);
@@ -185,7 +254,7 @@ pk_extra_populate_package_cache (PkExtra *extra)
}
/* get packages */
- statement = "SELECT package FROM data";
+ statement = "SELECT package, icon, exec FROM data";
rc = sqlite3_exec (extra->priv->db, statement, pk_extra_populate_package_cache_callback, extra, &error_msg);
if (rc != SQLITE_OK) {
pk_warning ("SQL error: %s\n", error_msg);
@@ -255,204 +324,81 @@ pk_extra_get_locale (PkExtra *extra)
}
/**
- * pk_extra_detail_localised_callback:
- **/
-static gint
-pk_extra_detail_localised_callback (void *data, gint argc, gchar **argv, gchar **col_name)
-{
- PkExtra *extra = PK_EXTRA (data);
- gint i;
- gchar *col;
- gchar *value;
-
- g_return_val_if_fail (PK_IS_EXTRA (extra), 0);
-
- for (i=0; i<argc; i++) {
- col = col_name[i];
- value = argv[i];
- if (pk_strequal (col, "summary")) {
- g_free (extra->priv->summary);
- extra->priv->summary = g_strdup (value);
- } else {
- pk_warning ("%s = %s\n", col, value);
- }
- }
- return 0;
-}
-
-/**
- * pk_extra_get_localised_detail_try:
+ * pk_extra_get_summary:
* @extra: a valid #PkExtra instance
*
- * TODO: This function is HOT in the profile chart
- *
- * Return value: the current locale
+ * Return value: if we managed to get data
**/
-static gboolean
-pk_extra_get_localised_detail_try (PkExtra *extra, const gchar *package, const gchar *locale)
+const gchar *
+pk_extra_get_summary (PkExtra *extra, const gchar *package)
{
- gchar *statement;
- gchar *error_msg = NULL;
- gint rc;
+ PkExtraLocaleObj *obj;
- statement = g_strdup_printf ("SELECT summary FROM localised "
- "WHERE package = '%s' AND locale = '%s'",
- package, locale);
- rc = sqlite3_exec (extra->priv->db, statement, pk_extra_detail_localised_callback, extra, &error_msg);
- g_free (statement);
- if (rc != SQLITE_OK) {
- pk_warning ("SQL error: %s\n", error_msg);
- sqlite3_free (error_msg);
+ g_return_val_if_fail (PK_IS_EXTRA (extra), NULL);
+ g_return_val_if_fail (package != NULL, NULL);
+
+ /* super quick if exists in cache */
+ obj = g_hash_table_lookup (extra->priv->hash_locale, package);
+ if (obj == NULL) {
return FALSE;
}
- return TRUE;
+ return obj->summary;
}
/**
- * pk_extra_get_localised_detail:
+ * pk_extra_get_icon_name:
* @extra: a valid #PkExtra instance
*
* Return value: if we managed to get data
**/
-gboolean
-pk_extra_get_localised_detail (PkExtra *extra, const gchar *package, gchar **summary)
+const gchar *
+pk_extra_get_icon_name (PkExtra *extra, const gchar *package)
{
- gpointer value;
+ PkExtraPackageObj *obj;
- g_return_val_if_fail (PK_IS_EXTRA (extra), FALSE);
- g_return_val_if_fail (extra->priv->locale != NULL, FALSE);
- g_return_val_if_fail (package != NULL, FALSE);
- g_return_val_if_fail (summary != NULL, FALSE);
-
- /* we failed to open */
- if (extra->priv->db == NULL) {
- pk_debug ("no database");
- return FALSE;
- }
+ g_return_val_if_fail (PK_IS_EXTRA (extra), NULL);
+ g_return_val_if_fail (package != NULL, NULL);
- /* can we optimize the call */
- value = g_hash_table_lookup (extra->priv->hash_locale, package);
- if (value == NULL) {
+ /* super quick if exists in cache */
+ obj = g_hash_table_lookup (extra->priv->hash_package, package);
+ if (obj == NULL) {
return FALSE;
}
-
- /* try with default locale */
- pk_extra_get_localised_detail_try (extra, package, extra->priv->locale);
-
- /* try harder with a base locale */
- if (extra->priv->summary == NULL && extra->priv->locale_base != NULL) {
- pk_extra_get_localised_detail_try (extra, package, extra->priv->locale_base);
- }
-
- /* don't copy and g_free, just re-assign */
- if (extra->priv->summary != NULL) {
- *summary = extra->priv->summary;
- extra->priv->summary = NULL;
- return TRUE;
- }
- return FALSE;
-}
-
-/**
- * pk_extra_detail_package_callback:
- **/
-static gint
-pk_extra_detail_package_callback (void *data, gint argc, gchar **argv, gchar **col_name)
-{
- PkExtra *extra = PK_EXTRA (data);
- gint i;
- gchar *col;
- gchar *value;
-
- g_return_val_if_fail (PK_IS_EXTRA (extra), 0);
-
- for (i=0; i<argc; i++) {
- col = col_name[i];
- value = argv[i];
- if (pk_strequal (col, "exec")) {
- g_free (extra->priv->exec);
- extra->priv->exec = g_strdup (value);
- } else if (pk_strequal (col, "icon")) {
- g_free (extra->priv->icon);
- extra->priv->icon = g_strdup (value);
- } else {
- pk_warning ("%s = %s\n", col, value);
- }
- }
- return 0;
+ return obj->icon_name;
}
/**
- * pk_extra_get_package_detail:
+ * pk_extra_get_exec:
* @extra: a valid #PkExtra instance
*
- * Return value: the current locale
+ * Return value: if we managed to get data
**/
-gboolean
-pk_extra_get_package_detail (PkExtra *extra, const gchar *package, gchar **icon, gchar **exec)
+const gchar *
+pk_extra_get_exec (PkExtra *extra, const gchar *package)
{
- gchar *statement;
- gchar *error_msg = NULL;
- gint rc;
- gpointer value;
-
- g_return_val_if_fail (PK_IS_EXTRA (extra), FALSE);
- g_return_val_if_fail (extra->priv->locale != NULL, FALSE);
+ PkExtraPackageObj *obj;
- /* we failed to open */
- if (extra->priv->db == NULL) {
- pk_debug ("no database");
- return FALSE;
- }
-
- /* can we optimize the call */
- value = g_hash_table_lookup (extra->priv->hash_package, package);
- if (value == NULL) {
- return FALSE;
- }
-
- statement = g_strdup_printf ("SELECT icon, exec FROM data WHERE package = '%s'", package);
- rc = sqlite3_exec (extra->priv->db, statement, pk_extra_detail_package_callback, extra, &error_msg);
- if (rc != SQLITE_OK) {
- pk_warning ("SQL error: %s\n", error_msg);
- sqlite3_free (error_msg);
- return FALSE;
- }
- g_free (statement);
-
- /* report back */
- if (icon != NULL) {
- *icon = extra->priv->icon;
- } else {
- g_free (extra->priv->icon);
- }
- if (exec != NULL) {
- *exec = extra->priv->exec;
- } else {
- g_free (extra->priv->exec);
- }
+ g_return_val_if_fail (PK_IS_EXTRA (extra), NULL);
+ g_return_val_if_fail (package != NULL, NULL);
- /* did we fail to get both? */
- if (extra->priv->icon == NULL &&
- extra->priv->exec == NULL) {
+ /* super quick if exists in cache */
+ obj = g_hash_table_lookup (extra->priv->hash_package, package);
+ if (obj == NULL) {
return FALSE;
}
-
- /* reset */
- extra->priv->icon = NULL;
- extra->priv->exec = NULL;
- return TRUE;
+ return obj->exec;
}
/**
- * pk_extra_set_localised_detail:
+ * pk_extra_set_data_locale:
* @extra: a valid #PkExtra instance
*
* Return value: the current locale
**/
gboolean
-pk_extra_set_localised_detail (PkExtra *extra, const gchar *package, const gchar *summary)
+pk_extra_set_data_locale (PkExtra *extra, const gchar *package, const gchar *summary)
{
+ PkExtraLocaleObj *obj;
gchar *statement;
gchar *error_msg = NULL;
sqlite3_stmt *sql_statement = NULL;
@@ -501,20 +447,23 @@ pk_extra_set_localised_detail (PkExtra *extra, const gchar *package, const gchar
/* add to cache */
pk_debug ("adding summary:%s", package);
- g_hash_table_insert (extra->priv->hash_locale, g_strdup (package), GUINT_TO_POINTER (1));
+ obj = g_new (PkExtraLocaleObj, 1);
+ obj->summary = g_strdup (summary);
+ g_hash_table_insert (extra->priv->hash_locale, g_strdup (package), (gpointer) obj);
return TRUE;
}
/**
- * pk_extra_set_package_detail:
+ * pk_extra_set_data_package:
* @extra: a valid #PkExtra instance
*
* Return value: the current locale
**/
gboolean
-pk_extra_set_package_detail (PkExtra *extra, const gchar *package, const gchar *icon, const gchar *exec)
+pk_extra_set_data_package (PkExtra *extra, const gchar *package, const gchar *icon_name, const gchar *exec)
{
+ PkExtraPackageObj *obj;
gchar *statement;
gchar *error_msg = NULL;
sqlite3_stmt *sql_statement = NULL;
@@ -522,8 +471,7 @@ pk_extra_set_package_detail (PkExtra *extra, const gchar *package, const gchar *
g_return_val_if_fail (PK_IS_EXTRA (extra), FALSE);
g_return_val_if_fail (package != NULL, FALSE);
- g_return_val_if_fail (icon != NULL || exec != NULL, FALSE);
- g_return_val_if_fail (extra->priv->locale != NULL, FALSE);
+ g_return_val_if_fail (icon_name != NULL || exec != NULL, FALSE);
/* we failed to open */
if (extra->priv->db == NULL) {
@@ -546,7 +494,7 @@ pk_extra_set_package_detail (PkExtra *extra, const gchar *package, const gchar *
/* add data */
sqlite3_bind_text (sql_statement, 1, package, -1, SQLITE_STATIC);
- sqlite3_bind_text (sql_statement, 2, icon, -1, SQLITE_STATIC);
+ sqlite3_bind_text (sql_statement, 2, icon_name, -1, SQLITE_STATIC);
sqlite3_bind_text (sql_statement, 3, exec, -1, SQLITE_STATIC);
/* save this */
@@ -560,7 +508,10 @@ pk_extra_set_package_detail (PkExtra *extra, const gchar *package, const gchar *
/* add to cache */
pk_debug ("adding package:%s", package);
- g_hash_table_insert (extra->priv->hash_package, g_strdup (package), GUINT_TO_POINTER (1));
+ obj = g_new (PkExtraPackageObj, 1);
+ obj->icon_name = g_strdup (icon_name);
+ obj->exec = g_strdup (exec);
+ g_hash_table_insert (extra->priv->hash_package, g_strdup (package), (gpointer) obj);
return TRUE;
}
@@ -637,6 +588,29 @@ pk_extra_set_database (PkExtra *extra, const gchar *filename)
}
/**
+ * pk_free_locale_obj:
+ **/
+static void
+pk_free_locale_obj (gpointer mem)
+{
+ PkExtraLocaleObj *obj = (PkExtraLocaleObj *) mem;
+ g_free (obj->summary);
+ g_free (obj);
+}
+
+/**
+ * pk_free_package_obj:
+ **/
+static void
+pk_free_package_obj (gpointer mem)
+{
+ PkExtraPackageObj *obj = (PkExtraPackageObj *) mem;
+ g_free (obj->exec);
+ g_free (obj->icon_name);
+ g_free (obj);
+}
+
+/**
* pk_extra_class_init:
**/
static void
@@ -658,11 +632,8 @@ pk_extra_init (PkExtra *extra)
extra->priv->db = NULL;
extra->priv->locale = NULL;
extra->priv->locale_base = NULL;
- extra->priv->icon = NULL;
- extra->priv->exec = NULL;
- extra->priv->summary = NULL;
- extra->priv->hash_package = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- extra->priv->hash_locale = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ extra->priv->hash_package = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, pk_free_package_obj);
+ extra->priv->hash_locale = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, pk_free_locale_obj);
}
/**
@@ -677,9 +648,6 @@ pk_extra_finalize (GObject *object)
extra = PK_EXTRA (object);
g_return_if_fail (extra->priv != NULL);
- g_free (extra->priv->icon);
- g_free (extra->priv->exec);
- g_free (extra->priv->summary);
g_free (extra->priv->locale);
g_free (extra->priv->locale_base);
sqlite3_close (extra->priv->db);
@@ -717,9 +685,9 @@ libst_extra (LibSelfTest *test)
PkExtra *extra;
const gchar *text;
gboolean ret;
- gchar *icon = NULL;
- gchar *exec = NULL;
- gchar *summary = NULL;
+ const gchar *icon = NULL;
+ const gchar *exec = NULL;
+ const gchar *summary = NULL;
guint i;
if (libst_start (test, "PkExtra", CLASS_AUTO) == FALSE) {
@@ -783,8 +751,7 @@ libst_extra (LibSelfTest *test)
/************************************************************/
libst_title (test, "insert localised data");
- ret = pk_extra_set_localised_detail (extra, "gnome-power-manager",
- "Power manager for the GNOME's desktop");
+ ret = pk_extra_set_data_locale (extra, "gnome-power-manager", "Power manager for the GNOME's desktop");
if (ret) {
libst_success (test, NULL);
} else {
@@ -793,14 +760,12 @@ libst_extra (LibSelfTest *test)
/************************************************************/
libst_title (test, "retrieve localised data");
- ret = pk_extra_get_localised_detail (extra, "gnome-power-manager", &summary);
- if (ret && summary != NULL) {
+ summary = pk_extra_get_summary (extra, "gnome-power-manager");
+ if (summary != NULL) {
libst_success (test, "%s", summary);
} else {
libst_failed (test, "failed!");
}
- g_free (summary);
- summary = NULL;
/************************************************************/
libst_title (test, "set locale implicit en_GB");
@@ -820,19 +785,17 @@ libst_extra (LibSelfTest *test)
}
/************************************************************/
- libst_title (test, "retrieve localised data");
- ret = pk_extra_get_localised_detail (extra, "gnome-power-manager", &summary);
- if (ret && summary != NULL) {
+ libst_title (test, "retrieve localised data2");
+ summary = pk_extra_get_summary (extra, "gnome-power-manager");
+ if (summary != NULL) {
libst_success (test, "%s", summary);
} else {
libst_failed (test, "failed!");
}
- g_free (summary);
- summary = NULL;
/************************************************************/
libst_title (test, "insert package data");
- ret = pk_extra_set_package_detail (extra, "gnome-power-manager", "gpm-main.png", "gnome-power-manager");
+ ret = pk_extra_set_data_package (extra, "gnome-power-manager", "gpm-main.png", "gnome-power-manager");
if (ret) {
libst_success (test, NULL);
} else {
@@ -841,22 +804,17 @@ libst_extra (LibSelfTest *test)
/************************************************************/
libst_title (test, "retrieve package data");
- ret = pk_extra_get_package_detail (extra, "gnome-power-manager", &icon, &exec);
- if (ret &&
- pk_strequal (icon, "gpm-main.png") &&
- pk_strequal (exec, "gnome-power-manager")) {
+ icon = pk_extra_get_icon_name (extra, "gnome-power-manager");
+ exec = pk_extra_get_exec (extra, "gnome-power-manager");
+ if (pk_strequal (icon, "gpm-main.png")) {
libst_success (test, "%s:%s", icon, exec);
} else {
libst_failed (test, "%s:%s", icon, exec);
}
- g_free (icon);
- g_free (exec);
- icon = NULL;
- exec = NULL;
/************************************************************/
libst_title (test, "insert new package data");
- ret = pk_extra_set_package_detail (extra, "gnome-power-manager", "gpm-prefs.png", "gnome-power-preferences");
+ ret = pk_extra_set_data_package (extra, "gnome-power-manager", "gpm-prefs.png", "gnome-power-preferences");
if (ret) {
libst_success (test, NULL);
} else {
@@ -865,23 +823,20 @@ libst_extra (LibSelfTest *test)
/************************************************************/
libst_title (test, "retrieve new package data");
- ret = pk_extra_get_package_detail (extra, "gnome-power-manager", &icon, &exec);
- if (ret &&
- pk_strequal (icon, "gpm-prefs.png") &&
+ icon = pk_extra_get_icon_name (extra, "gnome-power-manager");
+ exec = pk_extra_get_exec (extra, "gnome-power-manager");
+ if (pk_strequal (icon, "gpm-prefs.png") &&
pk_strequal (exec, "gnome-power-preferences")) {
libst_success (test, "%s:%s", icon, exec);
} else {
libst_failed (test, "%s:%s", icon, exec);
}
- g_free (icon);
- g_free (exec);
- icon = NULL;
- exec = NULL;
/************************************************************/
libst_title (test, "retrieve missing package data");
- ret = pk_extra_get_package_detail (extra, "gnome-moo-manager", &icon, &exec);
- if (!ret && icon == NULL && exec == NULL) {
+ icon = pk_extra_get_icon_name (extra, "gnome-moo-manager");
+ exec = pk_extra_get_exec (extra, "gnome-moo-manager");
+ if (icon == NULL && exec == NULL) {
libst_success (test, "passed");
} else {
libst_failed (test, "%s:%s", icon, exec);
@@ -890,30 +845,24 @@ libst_extra (LibSelfTest *test)
/************************************************************/
libst_title (test, "do lots of loops");
for (i=0;i<250;i++) {
- ret = pk_extra_get_localised_detail (extra, "gnome-power-manager", &summary);
- if (!ret || summary == NULL) {
+ summary = pk_extra_get_summary (extra, "gnome-power-manager");
+ if (summary == NULL) {
libst_failed (test, "failed to get good!");
}
- g_free (summary);
- summary = NULL;
- ret = pk_extra_get_localised_detail (extra, "gnome-moo-manager", &summary);
- if (ret || summary != NULL) {
- libst_failed (test, "failed to not get bad 1, %i, %s!", ret, summary);
- }
- ret = pk_extra_get_localised_detail (extra, "gnome-moo-manager", &summary);
- if (ret || summary != NULL) {
+ summary = pk_extra_get_summary (extra, "gnome-moo-manager");
+ if (summary != NULL) {
libst_failed (test, "failed to not get bad 2!");
}
- ret = pk_extra_get_localised_detail (extra, "gnome-moo-manager", &summary);
- if (ret || summary != NULL) {
+ summary = pk_extra_get_summary (extra, "gnome-moo-manager");
+ if (summary != NULL) {
libst_failed (test, "failed to not get bad 3!");
}
- ret = pk_extra_get_localised_detail (extra, "gnome-moo-manager", &summary);
- if (ret || summary != NULL) {
+ summary = pk_extra_get_summary (extra, "gnome-moo-manager");
+ if (summary != NULL) {
libst_failed (test, "failed to not get bad 4!");
}
}
- libst_success (test, "%i get_localised_detail loops completed in %ims", i*5, libst_elapsed (test));
+ libst_success (test, "%i get_summary loops completed in %ims", i*5, libst_elapsed (test));
g_object_unref (extra);
g_unlink ("extra.db");
diff --git a/libpackagekit/pk-extra.h b/libpackagekit/pk-extra.h
index c1c2f96..67a0f63 100644
--- a/libpackagekit/pk-extra.h
+++ b/libpackagekit/pk-extra.h
@@ -66,19 +66,21 @@ const gchar *pk_extra_get_locale (PkExtra *extra);
gboolean pk_extra_set_database (PkExtra *extra,
const gchar *filename)
G_GNUC_WARN_UNUSED_RESULT;
-gboolean pk_extra_get_localised_detail (PkExtra *extra,
- const gchar *package,
- gchar **summary);
-gboolean pk_extra_set_localised_detail (PkExtra *extra,
+
+const gchar *pk_extra_get_summary (PkExtra *extra,
+ const gchar *package);
+const gchar *pk_extra_get_icon_name (PkExtra *extra,
+ const gchar *package);
+const gchar *pk_extra_get_exec (PkExtra *extra,
+ const gchar *package);
+
+/* not individual as they require SQL access, so slow */
+gboolean pk_extra_set_data_locale (PkExtra *extra,
const gchar *package,
const gchar *summary);
-gboolean pk_extra_get_package_detail (PkExtra *extra,
- const gchar *package,
- gchar **icon,
- gchar **exec);
-gboolean pk_extra_set_package_detail (PkExtra *extra,
+gboolean pk_extra_set_data_package (PkExtra *extra,
const gchar *package,
- const gchar *icon,
+ const gchar *icon_name,
const gchar *exec);
G_END_DECLS
commit 6801dad3ae6c02801fa47323689e4b94f89f8201
Author: Richard Hughes <richard at hughsie.com>
Date: Fri May 2 01:31:56 2008 +0100
yum: catch a case where we can't load the comps list
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index da763f7..728b43b 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -434,6 +434,8 @@ class PackageKitYumBackend(PackageKitBaseBackend):
def _buildGroupDict(self):
pkgGroups= {}
cats = self.yumbase.comps.categories
+ if len(cats) == 0:
+ self.error(ERROR_GROUP_LIST_INVALID,'comps categories could not be loaded')
for cat in cats:
grps = map(lambda x: self.yumbase.comps.return_group(x),
filter(lambda x: self.yumbase.comps.has_group(x),cat.groups))
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index d3161af..af3b879 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -129,6 +129,7 @@ static PkEnumMatch enum_error[] = {
{PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED, "package-already-installed"},
{PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, "package-download-failed"},
{PK_ERROR_ENUM_GROUP_NOT_FOUND, "group-not-found"},
+ {PK_ERROR_ENUM_GROUP_LIST_INVALID, "group-list-invalid"},
{PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "dep-resolution-failed"},
{PK_ERROR_ENUM_CREATE_THREAD_FAILED, "create-thread-failed"},
{PK_ERROR_ENUM_REPO_NOT_FOUND, "repo-not-found"},
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index b4dc918..70aabfe 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -227,6 +227,7 @@ typedef enum {
PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED,
PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED,
PK_ERROR_ENUM_GROUP_NOT_FOUND,
+ PK_ERROR_ENUM_GROUP_LIST_INVALID,
PK_ERROR_ENUM_DEP_RESOLUTION_FAILED,
PK_ERROR_ENUM_FILTER_INVALID,
PK_ERROR_ENUM_CREATE_THREAD_FAILED,
commit 7e94e5267ff2d112a027f4389b2dc879aa2d5c3f
Author: Patrick Niklaus <marex at opencompositing.org>
Date: Fri May 2 01:15:36 2008 +0100
raise the PolicyKit dep to 0.8
diff --git a/configure.ac b/configure.ac
index 409fc11..82ddaf6 100755
--- a/configure.ac
+++ b/configure.ac
@@ -76,8 +76,8 @@ GIO_REQUIRED=2.16.1
DBUS_REQUIRED=1.1.1
DBUS_GLIB_REQUIRED=0.73
LIBNM_GLIB_REQUIRED=0.6.4
-POLKIT_DBUS_REQUIRED=0.7
-POLKIT_GRANT_REQUIRED=0.7
+POLKIT_DBUS_REQUIRED=0.8
+POLKIT_GRANT_REQUIRED=0.8
dnl ---------------------------------------------------------------------------
dnl - Make above strings available for packaging files (e.g. rpm spec files)
More information about the PackageKit-commit
mailing list