[packagekit] packagekit: Branch 'master' - 3 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Fri Oct 12 09:41:15 PDT 2007
libpackagekit/pk-enum-list.c | 76 +++++++++++++++++++++++++++++++++++++++++++
libpackagekit/pk-enum-list.h | 2 +
libpackagekit/pk-enum.c | 3 +
libpackagekit/pk-enum.h | 3 +
4 files changed, 84 insertions(+)
New commits:
diff-tree 192becd7e3899ba4ea6c0ace7dcdd2bee2ac8559 (from 50e4ee0eac39b520630db1e14f380a89df1f1479)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Oct 12 15:43:58 2007 +0100
add the negative filter states to the enumerated list
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 4775d70..ecb5778 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -111,6 +111,9 @@ static PkTaskEnumMatch task_filter[] = {
{PK_FILTER_ENUM_DEVELOPMENT, "devel"},
{PK_FILTER_ENUM_INSTALLED, "installed"},
{PK_FILTER_ENUM_GUI, "gui"},
+ {PK_FILTER_ENUM_NORMAL, "~devel"},
+ {PK_FILTER_ENUM_AVAILABLE, "~installed"},
+ {PK_FILTER_ENUM_TEXT, "~gui"},
{0, NULL},
};
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index ec5f9a7..bcdc934 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -74,6 +74,9 @@ typedef enum {
PK_FILTER_ENUM_DEVELOPMENT,
PK_FILTER_ENUM_INSTALLED,
PK_FILTER_ENUM_GUI,
+ PK_FILTER_ENUM_NORMAL, /* not DEVELOPMENT */
+ PK_FILTER_ENUM_AVAILABLE, /* not INSTALLED */
+ PK_FILTER_ENUM_TEXT, /* not GUI */
PK_FILTER_ENUM_UNKNOWN
} PkFilterEnum;
diff-tree 50e4ee0eac39b520630db1e14f380a89df1f1479 (from 94d00900d223c7474d04d0521fbf60090f5fbab1)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Oct 12 15:29:51 2007 +0100
add pk_enum_list_remove to libpackagekit
diff --git a/libpackagekit/pk-enum-list.c b/libpackagekit/pk-enum-list.c
index 46090cb..2319e87 100644
--- a/libpackagekit/pk-enum-list.c
+++ b/libpackagekit/pk-enum-list.c
@@ -260,6 +260,27 @@ pk_enum_list_append (PkEnumList *elist,
}
/**
+ * pk_enum_list_remove:
+ **/
+gboolean
+pk_enum_list_remove (PkEnumList *elist, guint value)
+{
+ guint i;
+
+ g_return_val_if_fail (elist != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_ENUM_LIST (elist), FALSE);
+
+ for (i=0; i<elist->priv->data->len; i++) {
+ if (GPOINTER_TO_UINT (g_ptr_array_index (elist->priv->data, i)) == value) {
+ g_ptr_array_remove_index (elist->priv->data, i);
+ return TRUE;
+ }
+ }
+ pk_debug ("cannot find item %i", value);
+ return FALSE;
+}
+
+/**
* pk_enum_list_contains:
**/
gboolean
@@ -441,6 +462,15 @@ libst_enum_list (LibSelfTest *test)
}
/************************************************************/
+ libst_title (test, "get multiple size");
+ value = pk_enum_list_size (elist);
+ if (value == 3) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "invalid size %i, should be 3", value);
+ }
+
+ /************************************************************/
libst_title (test, "get multiple list");
text = pk_enum_list_to_string (elist);
if (strcmp (text, "search-name;search-details;search-group") == 0) {
@@ -449,6 +479,34 @@ libst_enum_list (LibSelfTest *test)
libst_failed (test, "invalid '%s', should be 'search-name;search-details;search-group'", text);
}
g_free (text);
+
+ /************************************************************/
+ libst_title (test, "remove single");
+ ret = pk_enum_list_remove (elist, PK_ROLE_ENUM_SEARCH_DETAILS);
+ if (ret == TRUE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, NULL);
+ }
+
+ /************************************************************/
+ libst_title (test, "remove duplicate single");
+ ret = pk_enum_list_remove (elist, PK_ROLE_ENUM_SEARCH_DETAILS);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, NULL);
+ }
+
+ /************************************************************/
+ libst_title (test, "get size after remove");
+ value = pk_enum_list_size (elist);
+ if (value == 2) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "invalid size %i, should be 2", value);
+ }
+
g_object_unref (elist);
/************************************************************/
diff --git a/libpackagekit/pk-enum-list.h b/libpackagekit/pk-enum-list.h
index 936b6a2..5320c21 100644
--- a/libpackagekit/pk-enum-list.h
+++ b/libpackagekit/pk-enum-list.h
@@ -68,6 +68,8 @@ gboolean pk_enum_list_contains (PkEnu
guint value);
gboolean pk_enum_list_append (PkEnumList *elist,
guint value);
+gboolean pk_enum_list_remove (PkEnumList *elist,
+ guint value);
gboolean pk_enum_list_print (PkEnumList *elist);
gboolean pk_enum_list_append_multiple (PkEnumList *elist,
gint value, ...);
diff-tree 94d00900d223c7474d04d0521fbf60090f5fbab1 (from 40a58a9dd4d22459defb445b63e073cdb45e5b49)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Oct 12 15:22:44 2007 +0100
don't allow calling pk_enum_list_append when the item is already in the list
diff --git a/libpackagekit/pk-enum-list.c b/libpackagekit/pk-enum-list.c
index 529040e..46090cb 100644
--- a/libpackagekit/pk-enum-list.c
+++ b/libpackagekit/pk-enum-list.c
@@ -244,8 +244,17 @@ pk_enum_list_get_item (PkEnumList *elist
gboolean
pk_enum_list_append (PkEnumList *elist, guint value)
{
+ guint i;
+
g_return_val_if_fail (elist != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENUM_LIST (elist), FALSE);
+
+ for (i=0; i<elist->priv->data->len; i++) {
+ if (GPOINTER_TO_UINT (g_ptr_array_index (elist->priv->data, i)) == value) {
+ pk_debug ("trying to append item already in list");
+ return FALSE;
+ }
+ }
g_ptr_array_add (elist->priv->data, GUINT_TO_POINTER(value));
return TRUE;
}
@@ -386,6 +395,15 @@ libst_enum_list (LibSelfTest *test)
}
/************************************************************/
+ libst_title (test, "append duplicate");
+ ret = pk_enum_list_append (elist, PK_ROLE_ENUM_SEARCH_NAME);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, NULL);
+ }
+
+ /************************************************************/
libst_title (test, "get single size");
value = pk_enum_list_size (elist);
if (value == 1) {
More information about the PackageKit
mailing list