[packagekit] packagekit: Branch 'master' - 3 commits

Richard Hughes hughsient at kemper.freedesktop.org
Tue Oct 9 12:20:59 PDT 2007


 TODO                         |    4 --
 libpackagekit/pk-enum-list.c |   74 +++++++++++++++++++++++++++++++++++++++++++
 libpackagekit/pk-enum-list.h |    3 +
 libpackagekit/pk-enum.c      |    7 ++++
 libpackagekit/pk-enum.h      |    7 ++--
 5 files changed, 89 insertions(+), 6 deletions(-)

New commits:
diff-tree 14d81c195462c0b22fe6eeffac3b1694247e384a (from 070442c71c110f5184b0d566ecd07c73bc11e953)
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 9 20:15:42 2007 +0100

    make sure enum types return UNKNOWN when the enum type is not known

diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 40f5313..4775d70 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -98,6 +98,7 @@ static PkTaskEnumMatch task_error[] = {
 };
 
 static PkTaskEnumMatch task_restart[] = {
+	{PK_RESTART_ENUM_UNKNOWN,		"unknown"},	/* fall though value */
 	{PK_RESTART_ENUM_NONE,			"none"},
 	{PK_RESTART_ENUM_SYSTEM,		"system"},
 	{PK_RESTART_ENUM_SESSION,		"session"},
@@ -106,6 +107,7 @@ static PkTaskEnumMatch task_restart[] = 
 };
 
 static PkTaskEnumMatch task_filter[] = {
+	{PK_FILTER_ENUM_UNKNOWN,		"unknown"},	/* fall though value */
 	{PK_FILTER_ENUM_DEVELOPMENT,		"devel"},
 	{PK_FILTER_ENUM_INSTALLED,		"installed"},
 	{PK_FILTER_ENUM_GUI,			"gui"},
@@ -113,6 +115,7 @@ static PkTaskEnumMatch task_filter[] = {
 };
 
 static PkTaskEnumMatch task_group[] = {
+	{PK_GROUP_ENUM_UNKNOWN,			"unknown"},	/* fall though value */
 	{PK_GROUP_ENUM_ACCESSIBILITY,		"accessibility"},
 	{PK_GROUP_ENUM_ACCESSORIES,		"accessories"},
 	{PK_GROUP_ENUM_EDUCATION,		"education"},
@@ -128,6 +131,7 @@ static PkTaskEnumMatch task_group[] = {
 };
 
 static PkTaskEnumMatch task_freq[] = {
+	{PK_FREQ_ENUM_UNKNOWN,			"unknown"},	/* fall though value */
 	{PK_FREQ_ENUM_HOURLY,			"hourly"},
 	{PK_FREQ_ENUM_DAILY,			"daily"},
 	{PK_FREQ_ENUM_WEEKLY,			"weekly"},
@@ -136,6 +140,7 @@ static PkTaskEnumMatch task_freq[] = {
 };
 
 static PkTaskEnumMatch task_update[] = {
+	{PK_UPDATE_ENUM_UNKNOWN,		"unknown"},	/* fall though value */
 	{PK_UPDATE_ENUM_ALL,			"all"},
 	{PK_UPDATE_ENUM_SECURITY,		"security"},
 	{PK_UPDATE_ENUM_NONE,			"none"},
@@ -143,6 +148,7 @@ static PkTaskEnumMatch task_update[] = {
 };
 
 static PkTaskEnumMatch task_info[] = {
+	{PK_INFO_ENUM_UNKNOWN,			"unknown"},	/* fall though value */
 	{PK_INFO_ENUM_INSTALLED,		"installed"},
 	{PK_INFO_ENUM_AVAILABLE,		"available"},
 	{PK_INFO_ENUM_LOW,			"low"},
@@ -157,6 +163,7 @@ static PkTaskEnumMatch task_info[] = {
 };
 
 static PkTaskEnumMatch task_sig_type[] = {
+	{PK_SIGTYPE_ENUM_UNKNOWN,		"unknown"},	/* fall though value */
 	{PK_SIGTYPE_ENUM_GPG,                   "gpg"},
 };
 
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index ae5d1bd..ec5f9a7 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -81,7 +81,8 @@ typedef enum {
 	PK_RESTART_ENUM_NONE,
 	PK_RESTART_ENUM_APPLICATION,
 	PK_RESTART_ENUM_SESSION,
-	PK_RESTART_ENUM_SYSTEM
+	PK_RESTART_ENUM_SYSTEM,
+	PK_RESTART_ENUM_UNKNOWN
 } PkRestartEnum;
 
 typedef enum {
@@ -128,6 +129,7 @@ typedef enum {
 	PK_UPDATE_ENUM_ALL,
 	PK_UPDATE_ENUM_SECURITY,
 	PK_UPDATE_ENUM_NONE,
+	PK_UPDATE_ENUM_UNKNOWN,
 } PkUpdateEnum;
 
 typedef enum {
@@ -145,7 +147,8 @@ typedef enum {
 } PkInfoEnum;
 
 typedef enum {
-	PK_SIGTYPE_ENUM_GPG
+	PK_SIGTYPE_ENUM_GPG,
+	PK_SIGTYPE_ENUM_UNKNOWN
 } PkSigTypeEnum;
 
 PkSigTypeEnum    pk_sig_type_enum_from_text             (const gchar    *sig_type);
diff-tree 070442c71c110f5184b0d566ecd07c73bc11e953 (from cd922965851e3c3757dae20290471d7c473a90b5)
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 9 18:59:59 2007 +0100

    update TODO

diff --git a/TODO b/TODO
index 067ec70..9e3b906 100644
--- a/TODO
+++ b/TODO
@@ -4,10 +4,6 @@ Order of no particular importance:
 Do automatic updates at login time when system has gone idle
 NOTE: RELEASE BLOCKER
 
-*** pk-application (client) ***
-Don't hardcode the group list in PkApplication
-NOTE: RELEASE BLOCKER
-
 *** pk-update-icon (client) ***
 * Don't re-run get-updates when selecting "Show updates" from the update icon, just populate it with the previous results.
 NOTE: RELEASE BLOCKER
diff-tree cd922965851e3c3757dae20290471d7c473a90b5 (from 0e332d143c1547d4c29d81c0f0debc40378c2767)
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 9 18:55:10 2007 +0100

    add pk_enum_list_size and pk_enum_list_get_item into the library

diff --git a/libpackagekit/pk-enum-list.c b/libpackagekit/pk-enum-list.c
index 028a1dc..529040e 100644
--- a/libpackagekit/pk-enum-list.c
+++ b/libpackagekit/pk-enum-list.c
@@ -56,6 +56,8 @@ G_DEFINE_TYPE (PkEnumList, pk_enum_list,
 gboolean
 pk_enum_list_set_type (PkEnumList *elist, PkEnumListType type)
 {
+	g_return_val_if_fail (elist != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_ENUM_LIST (elist), FALSE);
 	elist->priv->type = type;
 	return TRUE;
 }
@@ -70,6 +72,9 @@ pk_enum_list_append_multiple (PkEnumList
 	guint i;
 	guint value_temp;
 
+	g_return_val_if_fail (elist != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_ENUM_LIST (elist), FALSE);
+
 	/* create a new list. A list must have at least one entry */
 	g_ptr_array_add (elist->priv->data, GINT_TO_POINTER(value));
 
@@ -96,6 +101,9 @@ pk_enum_list_from_string (PkEnumList *el
 	guint i;
 	guint value_temp = 0;
 
+	g_return_val_if_fail (elist != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_ENUM_LIST (elist), FALSE);
+
 	if (enums == NULL) {
 		pk_warning ("enums null");
 		return FALSE;
@@ -137,6 +145,9 @@ pk_enum_list_to_string (PkEnumList *elis
 	guint length;
 	const gchar *text = NULL;
 
+	g_return_val_if_fail (elist != NULL, NULL);
+	g_return_val_if_fail (PK_IS_ENUM_LIST (elist), NULL);
+
 	length = elist->priv->data->len;
 	if (length == 0) {
 		return g_strdup ("none");
@@ -174,6 +185,9 @@ pk_enum_list_print (PkEnumList *elist)
 	guint value;
 	const gchar *text = NULL;
 
+	g_return_val_if_fail (elist != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_ENUM_LIST (elist), FALSE);
+
 	if (elist->priv->type == PK_ENUM_LIST_TYPE_ROLE) {
 		g_print ("Printing actions:\n");
 	} else if (elist->priv->type == PK_ENUM_LIST_TYPE_GROUP) {
@@ -199,11 +213,39 @@ pk_enum_list_print (PkEnumList *elist)
 }
 
 /**
+ * pk_enum_list_size:
+ **/
+guint
+pk_enum_list_size (PkEnumList *elist)
+{
+	g_return_val_if_fail (elist != NULL, 0);
+	g_return_val_if_fail (PK_IS_ENUM_LIST (elist), 0);
+	return elist->priv->data->len;
+}
+
+/**
+ * pk_enum_list_get_item:
+ **/
+guint
+pk_enum_list_get_item (PkEnumList *elist, guint item)
+{
+	g_return_val_if_fail (elist != NULL, 0);
+	g_return_val_if_fail (PK_IS_ENUM_LIST (elist), 0);
+	if (item >= elist->priv->data->len) {
+		pk_warning ("getting item over length");
+		return 0;
+	}
+	return GPOINTER_TO_UINT (g_ptr_array_index (elist->priv->data, item));
+}
+
+/**
  * pk_enum_list_append:
  **/
 gboolean
 pk_enum_list_append (PkEnumList *elist, guint value)
 {
+	g_return_val_if_fail (elist != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_ENUM_LIST (elist), FALSE);
 	g_ptr_array_add (elist->priv->data, GUINT_TO_POINTER(value));
 	return TRUE;
 }
@@ -215,6 +257,10 @@ gboolean
 pk_enum_list_contains (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) {
 			return TRUE;
@@ -289,6 +335,7 @@ libst_enum_list (LibSelfTest *test)
 	PkEnumList *elist;
 	gboolean ret;
 	gchar *text;
+	guint value;
 
 	/************************************************************
 	 ****************          ENUM         ******************
@@ -321,6 +368,15 @@ libst_enum_list (LibSelfTest *test)
 	g_free (text);
 
 	/************************************************************/
+	libst_title (test, "get empty size");
+	value = pk_enum_list_size (elist);
+	if (value == 0) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "invalid size %i, should be 0", value);
+	}
+
+	/************************************************************/
 	libst_title (test, "append single");
 	ret = pk_enum_list_append (elist, PK_ROLE_ENUM_SEARCH_NAME);
 	if (ret == TRUE) {
@@ -330,6 +386,24 @@ libst_enum_list (LibSelfTest *test)
 	}
 
 	/************************************************************/
+	libst_title (test, "get single size");
+	value = pk_enum_list_size (elist);
+	if (value == 1) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "invalid size %i, should be 1", value);
+	}
+
+	/************************************************************/
+	libst_title (test, "check item");
+	value = pk_enum_list_get_item (elist, 0);
+	if (value == PK_ROLE_ENUM_SEARCH_NAME) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "invalid item %i, should be PK_ROLE_ENUM_SEARCH_NAME", value);
+	}
+
+	/************************************************************/
 	libst_title (test, "get single list");
 	text = pk_enum_list_to_string (elist);
 	if (strcmp (text, "search-name") == 0) {
diff --git a/libpackagekit/pk-enum-list.h b/libpackagekit/pk-enum-list.h
index 4305851..936b6a2 100644
--- a/libpackagekit/pk-enum-list.h
+++ b/libpackagekit/pk-enum-list.h
@@ -61,6 +61,9 @@ gboolean	 pk_enum_list_set_type			(PkEnu
 gboolean	 pk_enum_list_from_string		(PkEnumList	*elist,
 							 const gchar	*enums);
 gchar		*pk_enum_list_to_string			(PkEnumList	*elist);
+guint		 pk_enum_list_size			(PkEnumList	*elist);
+guint		 pk_enum_list_get_item			(PkEnumList	*elist,
+							 guint		 item);
 gboolean	 pk_enum_list_contains			(PkEnumList	*elist,
 							 guint		 value);
 gboolean	 pk_enum_list_append			(PkEnumList	*elist,



More information about the PackageKit mailing list