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

Richard Hughes hughsient at kemper.freedesktop.org
Fri Nov 9 02:48:36 PST 2007


 HACKING                                  |   10 
 backends/conary/helpers/conaryBackend.py |    2 
 backends/conary/pk-backend-conary.c      |    2 
 client/pk-console.c                      |   20 +
 docs/pk-backends.xml                     |    4 
 libpackagekit/pk-common.c                |  331 ++++++++++++++++++++++++++-----
 libpackagekit/pk-common.h                |    5 
 libpackagekit/pk-connection.c            |    3 
 libpackagekit/pk-debug.c                 |   29 --
 libpackagekit/pk-enum-list.c             |   58 +++++
 libpackagekit/pk-enum.c                  |   13 +
 libpackagekit/pk-enum.h                  |    1 
 libpackagekit/pk-network-dummy.c         |    4 
 libpackagekit/pk-network-nm.c            |    9 
 libpackagekit/pk-package-id.c            |   41 +++
 libpackagekit/pk-polkit-client.c         |   17 +
 src/pk-backend-python.c                  |    2 
 src/pk-backend.c                         |  244 ++++++++++++++++++++++
 src/pk-transaction-db.c                  |   27 +-
 src/pk-transaction-id.c                  |    7 
 20 files changed, 725 insertions(+), 104 deletions(-)

New commits:
commit 23b4c83372de78764d5647c47e138b74153e1776
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Nov 9 10:47:16 2007 +0000

    add a metric ton of gtk-doc comments in libpackagekit

diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index 40d9589..a90fe6b 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -38,6 +38,12 @@
 
 /**
  * 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)
@@ -77,6 +83,11 @@ out:
 
 /**
  * pk_strvalidate_char:
+ * @item: A single char to test
+ *
+ * Tests a char to see if it may be dangerous.
+ *
+ * Return value: %TRUE if the char is valid
  **/
 static gboolean
 pk_strvalidate_char (gchar item)
@@ -104,6 +115,13 @@ pk_strvalidate_char (gchar item)
 
 /**
  * pk_strsafe:
+ * @text: The input text to make safe
+ *
+ * Replaces chars in the text that may be dangerous, or that may print
+ * incorrectly. These chars include new lines, tabs and quotes, and are
+ * replaced by spaces.
+ *
+ * Return value: the new string with no insane chars
  **/
 gchar *
 pk_strsafe (const gchar *text)
@@ -120,6 +138,12 @@ pk_strsafe (const gchar *text)
 
 /**
  * pk_strnumber:
+ * @text: The text the validate
+ *
+ * Tests a string to see if it is a number. Both positive and negative numbers
+ * are allowed.
+ *
+ * Return value: %TRUE if the string represents a numeric value
  **/
 gboolean
 pk_strnumber (const gchar *text)
@@ -151,6 +175,12 @@ pk_strnumber (const gchar *text)
 
 /**
  * pk_strtoint:
+ * @text: The text the convert
+ * @value: The return numeric return value, or 0 if invalid.
+ *
+ * Converts a string into a signed integer value in a safe way.
+ *
+ * Return value: %TRUE if the string was converted correctly
  **/
 gboolean
 pk_strtoint (const gchar *text, gint *value)
@@ -168,6 +198,12 @@ pk_strtoint (const gchar *text, gint *value)
 
 /**
  * pk_strtouint:
+ * @text: The text the convert
+ * @value: The return numeric return value, or 0 if invalid.
+ *
+ * Converts a string into a unsigned integer value in a safe way.
+ *
+ * Return value: %TRUE if the string was converted correctly
  **/
 gboolean
 pk_strtouint (const gchar *text, guint *value)
@@ -185,11 +221,14 @@ pk_strtouint (const gchar *text, guint *value)
 
 /**
  * pk_strzero:
+ * @text: The text to check
  *
  * This function is a much safer way of doing "if (strlen (text) == 0))"
  * as it does not rely on text being NULL terminated. It's also much
  * quicker as it only checks the first byte rather than scanning the whole
  * string just to verify it's not zero length.
+ *
+ * Return value: %TRUE if the string was converted correctly
  **/
 gboolean
 pk_strzero (const gchar *text)
@@ -205,11 +244,15 @@ pk_strzero (const gchar *text)
 
 /**
  * pk_strlen:
+ * @text: The text to check
+ * @max_length: The maximum length of the string
  *
  * This function is a much safer way of doing strlen as it checks for NULL and
  * a stupidly long string.
  * This also modifies the string in place if it is over-range by inserting
  * a NULL at the max_length.
+ *
+ * Return value: the length of the string, or max_length.
  **/
 guint
 pk_strlen (gchar *text, guint max_length)
@@ -226,6 +269,11 @@ pk_strlen (gchar *text, guint max_length)
 
 /**
  * pk_strvalidate:
+ * @text: The text to check for validity
+ *
+ * Tests a string to see if it may be dangerous or invalid.
+ *
+ * Return value: %TRUE if the string is valid
  **/
 gboolean
 pk_strvalidate (const gchar *text)
@@ -250,8 +298,14 @@ pk_strvalidate (const gchar *text)
 
 /**
  * pk_strsplit:
+ * @id: the ; delimited string to split
+ * @parts: how many parts the delimted string should be split into
  *
- * You need to use g_strfreev on the returned value
+ * Splits a string into the correct number of parts, checking the correct
+ * number of delimiters are present.
+ *
+ * Return value: a char array is split correctly, %NULL if invalid
+ * Note: You need to use g_strfreev on the returned value
  **/
 gchar **
 pk_strsplit (const gchar *id, guint parts)
@@ -290,9 +344,13 @@ out:
 
 /**
  * pk_strequal:
+ * @id1: the first item of text to test
+ * @id2: the second item of text to test
  *
  * This function is a much safer way of doing strcmp as it checks for
- * stupidly long strings, and returns boolean TRUE, not zero for success
+ * NULL first, and returns boolean TRUE, not zero for success.
+ *
+ * Return value: %TRUE if the string are bot non-%NULL and the same.
  **/
 gboolean
 pk_strequal (const gchar *id1, const gchar *id2)
@@ -306,7 +364,16 @@ pk_strequal (const gchar *id1, const gchar *id2)
 
 /**
  * pk_strcmp_sections:
- * only compare first sections, not all the data
+ * @id1: the first item of text to test
+ * @id2: the second item of text to test
+ * @parts: the number of parts each id should have
+ * @compare: the leading number of parts to compare
+ *
+ * We only want to compare some first sections, not all the data when
+ * comparing package_id's and transaction_id's.
+ *
+ * Return value: %TRUE if the strings can be considered the same.
+ *
  **/
 gboolean
 pk_strcmp_sections (const gchar *id1, const gchar *id2, guint parts, guint compare)
@@ -361,6 +428,11 @@ out:
  * pk_strpad:
  * @data: the input string
  * @length: the desired length of the output string, with padding
+ *
+ * Returns the text padded to a length with spaces. If the string is
+ * longer than length then a longer string is returned.
+ *
+ * Return value: The padded string
  **/
 gchar *
 pk_strpad (const gchar *data, guint length)
@@ -390,6 +462,12 @@ pk_strpad (const gchar *data, guint length)
  * @data: the input string
  * @length: the desired length of the output string, with padding
  * @extra: if we are running with a deficit, we might have a positive offset
+ *
+ * This function pads a string, but allows a follow-on value. This is useful
+ * if the function is being used to print columns of text, and one oversize
+ * one has to be absorbed into the next where possible.
+ *
+ * Return value: The padded string
  **/
 gchar *
 pk_strpad_extra (const gchar *data, guint length, guint *extra)
@@ -420,6 +498,13 @@ pk_strpad_extra (const gchar *data, guint length, guint *extra)
 
 /**
  * pk_strbuild_va:
+ * @first_element: The first string item, or NULL
+ * @args: the va_list
+ *
+ * This function converts a va_list into a string in a safe and efficient way,
+ * e.g. pk_strbuild_va("foo","bar","baz") == "foo bar baz"
+ *
+ * Return value: the single string
  **/
 gchar *
 pk_strbuild_va (const gchar *first_element, va_list *args)
diff --git a/libpackagekit/pk-connection.c b/libpackagekit/pk-connection.c
index 0984fe7..baefb5a 100644
--- a/libpackagekit/pk-connection.c
+++ b/libpackagekit/pk-connection.c
@@ -58,6 +58,9 @@ G_DEFINE_TYPE (PkConnection, pk_connection, G_TYPE_OBJECT)
 
 /**
  * pk_connection_valid:
+ * @connection: a valid #PkConnection instance
+ *
+ * Return value: %TRUE if packagekitd is running
  **/
 gboolean
 pk_connection_valid (PkConnection *connection)
diff --git a/libpackagekit/pk-debug.c b/libpackagekit/pk-debug.c
index b7e356e..0d6accf 100644
--- a/libpackagekit/pk-debug.c
+++ b/libpackagekit/pk-debug.c
@@ -37,20 +37,16 @@ static gboolean do_verbose = FALSE;	/* if we should print out debugging */
  * pk_print_line:
  **/
 static void
-pk_print_line (const gchar *func,
-		const gchar *file,
-		const int    line,
-		const gchar *buffer)
+pk_print_line (const gchar *func, const gchar *file, const int line, const gchar *buffer)
 {
-	gchar   *str_time;
-	time_t  the_time;
+	gchar *str_time;
+	time_t the_time;
 
 	time (&the_time);
 	str_time = g_new0 (gchar, 255);
 	strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
 
-	fprintf (stderr, "[%s] %s:%d (%s):\t %s\n",
-		 func, file, line, str_time, buffer);
+	fprintf (stderr, "[%s] %s:%d (%s):\t %s\n", func, file, line, str_time, buffer);
 	g_free (str_time);
 }
 
@@ -58,10 +54,7 @@ pk_print_line (const gchar *func,
  * pk_debug_real:
  **/
 void
-pk_debug_real (const gchar *func,
-		const gchar *file,
-		const int    line,
-		const gchar *format, ...)
+pk_debug_real (const gchar *func, const gchar *file, const int line, const gchar *format, ...)
 {
 	va_list args;
 	gchar *buffer = NULL;
@@ -83,10 +76,7 @@ pk_debug_real (const gchar *func,
  * pk_warning_real:
  **/
 void
-pk_warning_real (const gchar *func,
-		  const gchar *file,
-		  const int    line,
-		  const gchar *format, ...)
+pk_warning_real (const gchar *func, const gchar *file, const int line, const gchar *format, ...)
 {
 	va_list args;
 	gchar *buffer = NULL;
@@ -110,10 +100,7 @@ pk_warning_real (const gchar *func,
  * pk_error_real:
  **/
 void
-pk_error_real (const gchar *func,
-		const gchar *file,
-		const int    line,
-		const gchar *format, ...)
+pk_error_real (const gchar *func, const gchar *file, const int line, const gchar *format, ...)
 {
 	va_list args;
 	gchar *buffer = NULL;
diff --git a/libpackagekit/pk-enum-list.c b/libpackagekit/pk-enum-list.c
index d091600..a2e27db 100644
--- a/libpackagekit/pk-enum-list.c
+++ b/libpackagekit/pk-enum-list.c
@@ -53,6 +53,14 @@ G_DEFINE_TYPE (PkEnumList, pk_enum_list, G_TYPE_OBJECT)
 
 /**
  * pk_enum_list_set_type:
+ * @elist: a valid #PkEnumList instance
+ * @type: the type of list this should be
+ *
+ * This function sets the type of list. You don't /need/ to use this function,
+ * but is required if you print or get the list as we need to know what
+ * pk_xxxx_enum_to_text function to use for each part.
+ *
+ * Return value: %TRUE if we set the list type
  **/
 gboolean
 pk_enum_list_set_type (PkEnumList *elist, PkEnumListType type)
@@ -65,6 +73,13 @@ pk_enum_list_set_type (PkEnumList *elist, PkEnumListType type)
 
 /**
  * pk_enum_list_append_multiple:
+ * @elist: a valid #PkEnumList instance
+ * @value: the initial value
+ *
+ * Set a many items into a list in one method. Always terminate the enum
+ * list with the value -1
+ *
+ * Return value: %TRUE if we set the data
  **/
 gboolean
 pk_enum_list_append_multiple (PkEnumList *elist, gint value, ...)
@@ -94,6 +109,13 @@ pk_enum_list_append_multiple (PkEnumList *elist, gint value, ...)
 
 /**
  * pk_enum_list_from_string:
+ * @elist: a valid #PkEnumList instance
+ * @enums: a text representation of the list, e.g. "search-name;search-details"
+ *
+ * Set the list with a seed string. Converting the seed string once allows us
+ * to deal with raw enumerated integers, which is often much faster.
+ *
+ * Return value: %TRUE if we appended the data
  **/
 gboolean
 pk_enum_list_from_string (PkEnumList *elist, const gchar *enums)
@@ -159,6 +181,12 @@ pk_enum_list_get_item_text (PkEnumList *elist, guint value)
 
 /**
  * pk_enum_list_to_string:
+ * @elist: a valid #PkEnumList instance
+ *
+ * Converts the enumerated list back to a string.
+ *
+ * Return value: A string representing the enumerated list,
+ *  e.g. "search-name;search-details"
  **/
 gchar *
 pk_enum_list_to_string (PkEnumList *elist)
@@ -193,6 +221,11 @@ pk_enum_list_to_string (PkEnumList *elist)
 
 /**
  * pk_enum_list_print:
+ * @elist: a valid #PkEnumList instance
+ *
+ * Prints the enumerated list. This is most useful for debugging.
+ *
+ * Return value: %TRUE for success.
  **/
 gboolean
 pk_enum_list_print (PkEnumList *elist)
@@ -222,6 +255,9 @@ pk_enum_list_print (PkEnumList *elist)
 
 /**
  * pk_enum_list_size:
+ * @elist: a valid #PkEnumList instance
+ *
+ * Return value: the size of the enumerated list.
  **/
 guint
 pk_enum_list_size (PkEnumList *elist)
@@ -233,6 +269,10 @@ pk_enum_list_size (PkEnumList *elist)
 
 /**
  * pk_enum_list_get_item:
+ * @elist: a valid #PkEnumList instance
+ * @item: the item number of the list
+ *
+ * Return value: the enum value for this position, or zero if error.
  **/
 guint
 pk_enum_list_get_item (PkEnumList *elist, guint item)
@@ -248,6 +288,12 @@ pk_enum_list_get_item (PkEnumList *elist, guint item)
 
 /**
  * pk_enum_list_append:
+ * @elist: a valid #PkEnumList instance
+ * @value: the value to add
+ *
+ * Set a single item into a list.
+ *
+ * Return value: %TRUE if we set the data, %FALSE if it already existed
  **/
 gboolean
 pk_enum_list_append (PkEnumList *elist, guint value)
@@ -269,6 +315,12 @@ pk_enum_list_append (PkEnumList *elist, guint value)
 
 /**
  * pk_enum_list_remove:
+ * @elist: a valid #PkEnumList instance
+ * @value: the value to add
+ *
+ * Removes a single item from a list.
+ *
+ * Return value: %TRUE if we set the data, %FALSE if it did not exist
  **/
 gboolean
 pk_enum_list_remove (PkEnumList *elist, guint value)
@@ -290,6 +342,12 @@ pk_enum_list_remove (PkEnumList *elist, guint value)
 
 /**
  * pk_enum_list_contains:
+ * @elist: a valid #PkEnumList instance
+ * @value: the value to search for
+ *
+ * Searches the list looking for a specific value.
+ *
+ * Return value: %TRUE if we found the data in the list
  **/
 gboolean
 pk_enum_list_contains (PkEnumList *elist, guint value)
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 9d8e0ca..4339c30 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -202,6 +202,12 @@ static PkEnumMatch enum_sig_type[] = {
 
 /**
  * pk_enum_find_value:
+ * @table: A #PkEnumMatch enum table of values
+ * @string: the string constant to search for, e.g. "desktop-gnome"
+ *
+ * Search for a string value in a table of constants.
+ *
+ * Return value: the enumerated constant value, e.g. PK_SIGTYPE_ENUM_GPG
  */
 guint
 pk_enum_find_value (PkEnumMatch *table, const gchar *string)
@@ -228,6 +234,12 @@ pk_enum_find_value (PkEnumMatch *table, const gchar *string)
 
 /**
  * pk_enum_find_string:
+ * @table: A #PkEnumMatch enum table of values
+ * @value: the enumerated constant value, e.g. PK_SIGTYPE_ENUM_GPG
+ *
+ * Search for a enum value in a table of constants.
+ *
+ * Return value: the string constant, e.g. "desktop-gnome"
  */
 const gchar *
 pk_enum_find_string (PkEnumMatch *table, guint value)
diff --git a/libpackagekit/pk-network-dummy.c b/libpackagekit/pk-network-dummy.c
index 8567070..bf7a9f8 100644
--- a/libpackagekit/pk-network-dummy.c
+++ b/libpackagekit/pk-network-dummy.c
@@ -62,6 +62,10 @@ G_DEFINE_TYPE (PkNetwork, pk_network, G_TYPE_OBJECT)
 
 /**
  * pk_network_is_online:
+ * @network: a valid #PkNetwork instance
+ *
+ * Return value: %TRUE if the network is online
+ * Note: This is a dummy file and no checks are done
  **/
 gboolean
 pk_network_is_online (PkNetwork *network)
diff --git a/libpackagekit/pk-network-nm.c b/libpackagekit/pk-network-nm.c
index cb12231..2f2a9eb 100644
--- a/libpackagekit/pk-network-nm.c
+++ b/libpackagekit/pk-network-nm.c
@@ -52,7 +52,7 @@ static void     pk_network_finalize	(GObject        *object);
 struct PkNetworkPrivate
 {
 	libnm_glib_ctx		*ctx;
-	guint			 callbackid;
+	guint			 callback_id;
 };
 
 enum {
@@ -67,6 +67,9 @@ G_DEFINE_TYPE (PkNetwork, pk_network, G_TYPE_OBJECT)
 
 /**
  * pk_network_is_online:
+ * @network: a valid #PkNetwork instance
+ *
+ * Return value: %TRUE if the network is online
  **/
 gboolean
 pk_network_is_online (PkNetwork *network)
@@ -125,7 +128,7 @@ pk_network_init (PkNetwork *network)
 	network->priv = PK_NETWORK_GET_PRIVATE (network);
 	context = g_main_context_default ();
 	network->priv->ctx = libnm_glib_init ();
-	network->priv->callbackid =
+	network->priv->callback_id =
 		libnm_glib_register_callback (network->priv->ctx,
 					      pk_network_nm_changed_cb,
 					      network, context);
@@ -144,7 +147,7 @@ pk_network_finalize (GObject *object)
 	network = PK_NETWORK (object);
 
 	g_return_if_fail (network->priv != NULL);
-	libnm_glib_unregister_callback (network->priv->ctx, network->priv->callbackid);
+	libnm_glib_unregister_callback (network->priv->ctx, network->priv->callback_id);
 	libnm_glib_shutdown (network->priv->ctx);
 
 	G_OBJECT_CLASS (pk_network_parent_class)->finalize (object);
diff --git a/libpackagekit/pk-package-id.c b/libpackagekit/pk-package-id.c
index 746fd94..d5ce38f 100644
--- a/libpackagekit/pk-package-id.c
+++ b/libpackagekit/pk-package-id.c
@@ -33,6 +33,10 @@
 
 /**
  * pk_package_id_new:
+ *
+ * Creates a new #PkPackageId object with default values
+ *
+ * Return value: a new #PkPackageId object
  **/
 PkPackageId *
 pk_package_id_new (void)
@@ -48,6 +52,9 @@ pk_package_id_new (void)
 
 /**
  * pk_package_id_check:
+ * @package_id: the text the check
+ *
+ * Return value: %TRUE if the package_id was well formed.
  **/
 gboolean
 pk_package_id_check (const gchar *package_id)
@@ -63,6 +70,11 @@ pk_package_id_check (const gchar *package_id)
 
 /**
  * pk_package_id_new_from_string:
+ * @package_id: the text to pre-fill the object
+ *
+ * Creates a new #PkPackageId object with values taken from the supplied id.
+ *
+ * Return value: a new #PkPackageId object
  **/
 PkPackageId *
 pk_package_id_new_from_string (const gchar *package_id)
@@ -99,10 +111,17 @@ pk_package_id_new_from_string (const gchar *package_id)
 
 /**
  * pk_package_id_new_from_list:
+ * @name: the package name
+ * @version: the package version
+ * @arch: the package architecture
+ * @data: the package extra data
+ *
+ * Creates a new #PkPackageId object with values.
+ *
+ * Return value: a new #PkPackageId object
  **/
 PkPackageId *
-pk_package_id_new_from_list (const gchar *name, const gchar *version,
-		     const gchar *arch, const gchar *data)
+pk_package_id_new_from_list (const gchar *name, const gchar *version, const gchar *arch, const gchar *data)
 {
 	PkPackageId *ident = NULL;
 
@@ -117,6 +136,9 @@ pk_package_id_new_from_list (const gchar *name, const gchar *version,
 
 /**
  * pk_package_id_to_string:
+ * @indent: A #PkPackageId object
+ *
+ * Return value: returns a string representation of #PkPackageId.
  **/
 gchar *
 pk_package_id_to_string (PkPackageId *ident)
@@ -128,6 +150,12 @@ pk_package_id_to_string (PkPackageId *ident)
 
 /**
  * pk_package_id_build:
+ * @name: the package name
+ * @version: the package version
+ * @arch: the package architecture
+ * @data: the package extra data
+ *
+ * Return value: returns a string putting together the data.
  **/
 gchar *
 pk_package_id_build (const gchar *name, const gchar *version,
@@ -138,6 +166,9 @@ pk_package_id_build (const gchar *name, const gchar *version,
 
 /**
  * pk_package_id_free:
+ * @ident: the #PkPackageId object
+ *
+ * Return value: %TRUE is the #PkPackageId object was freed.
  **/
 gboolean
 pk_package_id_free (PkPackageId *ident)
@@ -155,6 +186,12 @@ pk_package_id_free (PkPackageId *ident)
 
 /**
  * pk_package_id_equal:
+ * @pid1: the first package_id
+ * @pid2: the second package_id
+ *
+ * Only compare the first three sections, data is not part of the match
+ *
+ * Return value: %TRUE if the package_id's can be considered equal.
  **/
 gboolean
 pk_package_id_equal (const gchar *pid1, const gchar *pid2)
diff --git a/libpackagekit/pk-polkit-client.c b/libpackagekit/pk-polkit-client.c
index 3e30df4..5e34244 100644
--- a/libpackagekit/pk-polkit-client.c
+++ b/libpackagekit/pk-polkit-client.c
@@ -57,6 +57,13 @@ G_DEFINE_TYPE (PkPolkitClient, pk_polkit_client, G_TYPE_OBJECT)
 
 /**
  * pk_polkit_client_gain_privilege:
+ * @pclient; a valid #PkPolkitClient instance
+ * @pk_action: a PolicyKit action description, e.g. "org.freedesktop.packagekit.installfile"
+ *
+ * This function is indented to be used by client tools to gain extra privileges
+ * needed to do extra functionality.
+ *
+ * Return value: if we gained the privilege we asked for
  **/
 gboolean
 pk_polkit_client_gain_privilege (PkPolkitClient *pclient, const gchar *pk_action)
@@ -91,6 +98,13 @@ pk_polkit_client_gain_privilege (PkPolkitClient *pclient, const gchar *pk_action
 
 /**
  * pk_polkit_client_gain_privilege_str:
+ * @pclient; a valid #PkPolkitClient instance
+ * @error_str: the raw output error, e.g. "org.freedesktop.packagekit.installfile no"
+ *
+ * This function is indented to be passed failure messages from dbus methods
+ * so that extra auth can be requested.
+ *
+ * Return value: if we gained the privilege we asked for
  **/
 gboolean
 pk_polkit_client_gain_privilege_str (PkPolkitClient *pclient, const gchar *error_str)
@@ -122,6 +136,9 @@ pk_polkit_client_gain_privilege_str (PkPolkitClient *pclient, const gchar *error
 
 /**
  * pk_polkit_client_error_denied_by_policy:
+ * @error: a valid #GError
+ *
+ * Return value: %TRUE if the error is the PolicyKit "RefusedByPolicy"
  **/
 gboolean
 pk_polkit_client_error_denied_by_policy (GError *error)
commit 54bb49898ee08f1e4881b4749f5b2bc3d973e540
Author: Ken VanDine <ken at vandine.org>
Date:   Thu Nov 8 23:27:26 2007 -0500

    enable get_description again

diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index db07f2b..0558e24 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -69,7 +69,7 @@ PK_BACKEND_OPTIONS (
 	backend_get_filters,			/* get_filters */
 	NULL,					/* cancel */
 	NULL,					/* get_depends */
-	NULL,					/* get_description */
+	pk_backend_python_get_description,	/* get_description */
 	NULL,					/* get_files */
 	NULL,					/* get_requires */
 	NULL,					/* get_update_detail */
commit cb3c358babcf69d353e2f833bf181a9e1eb54181
Author: Ken VanDine <ken at vandine.org>
Date:   Thu Nov 8 23:15:50 2007 -0500

    Don't be so forgiving, return an error if you can't find the package for install

diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 0dd7343..69bae50 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -191,7 +191,7 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
                 self.status(STATUS_INSTALL)
                 self._do_package_update(name, version, flavor, apply=True)
             except:
-                pass
+                self.error(ERROR_PACKAGE_NOT_FOUND, 'Package was not found')
         else:
             self.error(ERROR_PACKAGE_ALREADY_INSTALLED,
                 'Package was not found')
commit 06ef70e965b1711507ee510471e89435e779d5c4
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 8 23:11:12 2007 +0000

    add some data to HACKING

diff --git a/HACKING b/HACKING
index 5e037e5..2c54f3c 100644
--- a/HACKING
+++ b/HACKING
@@ -65,8 +65,14 @@ Remember:
 * Never allocate a buffer on user input
 * Output from backends is trusted, they are run from standard locations
 
-Use flawfinder to find obvious security problems. Use "ITS4: ignore" if you are
-totally 100% sure that it's not a problem.
+Use 'make security-check' to find obvious security problems.
+Use "ITS4: ignore" if you are totally 100% sure that it's not a problem.
+
+If you compile with --enable-gcov you can use 'make gcov' to get coverage
+reports for the unit test code.
+If you compile with --enable-gprof you can use 'make gprof' to get profiling
+data - but you probably don't want to be building packages with these options
+turned on for obvious reasons.
 
 Submitting Patches
 ------------------
commit 6ea1e16cb24eb9752f4dcc445ddcfee925353b4f
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 8 22:53:16 2007 +0000

    use pk_strtouint rather than atoi

diff --git a/src/pk-transaction-db.c b/src/pk-transaction-db.c
index 51e6a46..aeb8902 100644
--- a/src/pk-transaction-db.c
+++ b/src/pk-transaction-db.c
@@ -109,6 +109,8 @@ pk_transaction_sqlite_callback (void *data, gint argc, gchar **argv, gchar **col
 	gint i;
 	gchar *col;
 	gchar *value;
+	guint temp;
+	gboolean ret;
 
 	g_return_val_if_fail (tdb != NULL, 0);
 	g_return_val_if_fail (PK_IS_TRANSACTION_DB (tdb), 0);
@@ -119,8 +121,15 @@ pk_transaction_sqlite_callback (void *data, gint argc, gchar **argv, gchar **col
 		col = col_name[i];
 		value = argv[i];
 		if (pk_strequal (col, "succeeded") == TRUE) {
-			/* ITS4: ignore, checked for sanity */
-			item.succeeded = atoi (value);
+			ret = pk_strtouint (value, &temp);
+			if (ret == FALSE) {
+				pk_warning ("failed to convert");
+			}
+			if (temp == 1) {
+				item.succeeded = TRUE;
+			} else {
+				item.succeeded = FALSE;
+			}
 			if (item.succeeded > 1) {
 				pk_warning ("item.succeeded %i! Resetting to 1", item.succeeded);
 				item.succeeded = 1;
@@ -142,13 +151,13 @@ pk_transaction_sqlite_callback (void *data, gint argc, gchar **argv, gchar **col
 				item.data = g_strdup (value);
 			}
 		} else if (pk_strequal (col, "duration") == TRUE) {
-			if (value != NULL) {
-				/* ITS4: ignore, checked for sanity */
-				item.duration = atoi (value);
-				if (item.duration > 60*60*12) {
-					pk_warning ("insane duartion %i", item.duration);
-					item.duration = 0;
-				}
+			ret = pk_strtouint (value, &item.duration);
+			if (ret == FALSE) {
+				pk_warning ("failed to convert");
+			}
+			if (item.duration > 60*60*12) {
+				pk_warning ("insane duartion %i", item.duration);
+				item.duration = 0;
 			}
 		} else {
 			pk_warning ("%s = %s\n", col, value);
diff --git a/src/pk-transaction-id.c b/src/pk-transaction-id.c
index 00ec6f1..625f854 100644
--- a/src/pk-transaction-id.c
+++ b/src/pk-transaction-id.c
@@ -71,8 +71,11 @@ pk_transaction_id_load_job_count (void)
 		return FALSE;
 	}
 
-	/* ITS4: ignore, not used for allocation */
-	job_count = atoi (contents);
+	/* convert */
+	ret = pk_strtouint (contents, &job_count);
+	if (ret == FALSE) {
+		pk_warning ("failed to convert");
+	}
 
 	/* check we got a sane number */
 	if (job_count > 10240) {
commit b219248a0dd256abf214b8edfcd6e345f4c4a6b5
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 8 22:52:30 2007 +0000

    add pk_strtouint to the library API

diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index ce5cfab..40d9589 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -161,11 +161,29 @@ pk_strtoint (const gchar *text, gint *value)
 		*value = 0;
 		return FALSE;
 	}
+	/* ITS4: ignore, we've already checked for validity */
 	*value = atoi (text);
 	return TRUE;
 }
 
 /**
+ * pk_strtouint:
+ **/
+gboolean
+pk_strtouint (const gchar *text, guint *value)
+{
+	gboolean ret;
+	gint temp;
+	ret = pk_strtoint (text, &temp);
+	if (ret == FALSE || temp < 0) {
+		*value = 0;
+		return FALSE;
+	}
+	*value = (guint) temp;
+	return TRUE;
+}
+
+/**
  * pk_strzero:
  *
  * This function is a much safer way of doing "if (strlen (text) == 0))"
@@ -471,6 +489,7 @@ libst_common (LibSelfTest *test)
 	const gchar *temp;
 	guint length;
 	gint value;
+	guint uvalue;
 
 	if (libst_start (test, "PkCommon", CLASS_AUTO) == FALSE) {
 		return;
@@ -1158,6 +1177,22 @@ libst_common (LibSelfTest *test)
 	}
 
 	/************************************************************/
+	libst_title (test, "convert valid uint number");
+	ret = pk_strtouint ("234", &uvalue);
+	if (ret == TRUE && uvalue == 234) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "value is %i", uvalue);
+	}
+
+	/************************************************************/
+	libst_title (test, "convert invalid uint number");
+	ret = pk_strtouint ("-234", &uvalue);
+	if (ret == FALSE && uvalue == 0) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "value is %i", uvalue);
+	}
 
 	libst_end (test);
 }
diff --git a/libpackagekit/pk-common.h b/libpackagekit/pk-common.h
index 734655e..9302a10 100644
--- a/libpackagekit/pk-common.h
+++ b/libpackagekit/pk-common.h
@@ -39,6 +39,8 @@ gboolean	 pk_strequal				(const gchar	*id1,
 gboolean	 pk_strnumber				(const gchar	*text);
 gboolean	 pk_strtoint				(const gchar	*text,
 							 gint		*value);
+gboolean	 pk_strtouint				(const gchar	*text,
+							 guint		*value);
 gchar		*pk_strpad				(const gchar	*data,
 							 guint		 length);
 gchar		*pk_strpad_extra			(const gchar	*data,
commit d7f822d71e76594d06b6787378587444bb1a6f3a
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 8 22:35:02 2007 +0000

    add some more unit tests

diff --git a/src/pk-backend.c b/src/pk-backend.c
index 067880d..e5817bd 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -363,7 +363,7 @@ pk_backend_parse_common_error (PkBackend *backend, const gchar *line)
 {
 	gchar **sections;
 	guint size;
-	guint percentage;
+	gint percentage;
 	gchar *command;
 	PkErrorCodeEnum error_enum;
 	PkStatusEnum status_enum;
@@ -387,10 +387,12 @@ pk_backend_parse_common_error (PkBackend *backend, const gchar *line)
 			ret = FALSE;
 			goto out;
 		}
-		/* ITS4: ignore, checked for sanity */
-		percentage = atoi (sections[1]);
-		if (percentage > 100) {
+		ret = pk_strtoint (sections[1], &percentage);
+		if (ret == FALSE) {
+			pk_warning ("invalid percentage value %s", sections[1]);
+		} else if (percentage < 0 || percentage > 100) {
 			pk_warning ("invalid percentage value %i", percentage);
+			ret = FALSE;
 		} else {
 			pk_backend_change_percentage (backend, percentage);
 		}
@@ -400,10 +402,12 @@ pk_backend_parse_common_error (PkBackend *backend, const gchar *line)
 			ret = FALSE;
 			goto out;
 		}
-		/* ITS4: ignore, checked for sanity */
-		percentage = atoi (sections[1]);
-		if (percentage > 100) {
+		ret = pk_strtoint (sections[1], &percentage);
+		if (ret == FALSE) {
+			pk_warning ("invalid subpercentage value %s", sections[1]);
+		} else if (percentage < 0 || percentage > 100) {
 			pk_warning ("invalid subpercentage value %i", percentage);
+			ret = FALSE;
 		} else {
 			pk_backend_change_sub_percentage (backend, percentage);
 		}
@@ -1956,12 +1960,36 @@ pk_backend_new (void)
 #ifdef PK_BUILD_TESTS
 #include <libselftest.h>
 
+static gboolean
+pk_backend_test_func_true (PkBackend *backend, gpointer data)
+{
+	g_usleep (1000*1000);
+	return TRUE;
+}
+
+static gboolean
+pk_backend_test_func_false (PkBackend *backend, gpointer data)
+{
+	g_usleep (1000*1000);
+	return FALSE;
+}
+
+static gboolean
+pk_backend_test_func_immediate_false (PkBackend *backend, gpointer data)
+{
+	return FALSE;
+}
+
 void
 libst_backend (LibSelfTest *test)
 {
 	PkBackend *backend;
 	const gchar *text;
 	gboolean ret;
+	gdouble elapsed;
+	GTimer *timer;
+
+	timer = g_timer_new ();
 
 	if (libst_start (test, "PkBackend", CLASS_AUTO) == FALSE) {
 		return;
@@ -2029,7 +2057,6 @@ libst_backend (LibSelfTest *test)
 		libst_failed (test, "invalid name %s", text);
 	}
 
-/*************/
 	/************************************************************/
 	libst_title (test, "unload an valid backend");
 	ret = pk_backend_unload (backend);
@@ -2057,6 +2084,207 @@ libst_backend (LibSelfTest *test)
 		libst_failed (test, "invalid name %s", text);
 	}
 
+	/************************************************************/
+	libst_title (test, "check we are not finished");
+	if (backend->priv->finished == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "we did not clear finish!");
+	}
+
+	/************************************************************/
+	libst_title (test, "wait for a thread to return true");
+	g_timer_start (timer);
+	ret = pk_backend_thread_helper (backend, pk_backend_test_func_true, NULL);
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "wait for a thread failed");
+	}
+
+	/************************************************************/
+	libst_title (test, "did we wait the correct time?");
+	elapsed = g_timer_elapsed (timer, NULL);
+	if (elapsed < 1.1 && elapsed > 0.9) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not wait for thread timeout");
+	}
+
+	/************************************************************/
+	libst_title (test, "check we finished");
+	if (backend->priv->finished == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "we did not finish!");
+	}
+
+	/* reset the backend */
+	g_object_unref (backend);
+	backend = pk_backend_new ();
+
+	/************************************************************/
+	libst_title (test, "wait for a thread to return false");
+	g_timer_start (timer);
+	ret = pk_backend_thread_helper (backend, pk_backend_test_func_false, NULL);
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "wait for a thread failed");
+	}
+
+	/************************************************************/
+	libst_title (test, "did we wait the correct time2?");
+	elapsed = g_timer_elapsed (timer, NULL);
+	if (elapsed < 1.1 && elapsed > 0.9) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not wait for thread timeout");
+	}
+
+	/* reset the backend */
+	g_object_unref (backend);
+	backend = pk_backend_new ();
+
+	/************************************************************/
+	libst_title (test, "wait for a thread to return false (straight away)");
+	g_timer_start (timer);
+	ret = pk_backend_thread_helper (backend, pk_backend_test_func_immediate_false, NULL);
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "returned false!");
+	}
+
+	/************************************************************/
+	libst_title (test, "did we wait the correct time2?");
+	elapsed = g_timer_elapsed (timer, NULL);
+	if (elapsed < 0.1) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not wait for thread timeout2");
+	}
+
+	/************************************************************
+	 **********       Check parsing common error      ***********
+	 ************************************************************/
+	libst_title (test, "test pk_backend_parse_common_error Percentage1");
+	ret = pk_backend_parse_common_error (backend, "percentage\t0");
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not validate correctly");
+	}
+
+	/************************************************************/
+	libst_title (test, "test pk_backend_parse_common_error Percentage2");
+	ret = pk_backend_parse_common_error (backend, "percentage\tbrian");
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not validate correctly");
+	}
+
+	/************************************************************/
+	libst_title (test, "test pk_backend_parse_common_error Percentage3");
+	ret = pk_backend_parse_common_error (backend, "percentage\t12345");
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not validate correctly");
+	}
+
+	/************************************************************/
+	libst_title (test, "test pk_backend_parse_common_error Percentage4");
+	ret = pk_backend_parse_common_error (backend, "percentage\t");
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not validate correctly");
+	}
+
+	/************************************************************/
+	libst_title (test, "test pk_backend_parse_common_error Percentage5");
+	ret = pk_backend_parse_common_error (backend, "percentage");
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not validate correctly");
+	}
+
+	/************************************************************/
+	libst_title (test, "test pk_backend_parse_common_error Subpercentage");
+	ret = pk_backend_parse_common_error (backend, "subpercentage\t17");
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not validate correctly");
+	}
+
+	/************************************************************/
+	libst_title (test, "test pk_backend_parse_common_error NoPercentageUpdates");
+	ret = pk_backend_parse_common_error (backend, "no-percentage-updates");
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not validate correctly");
+	}
+
+	/************************************************************/
+	libst_title (test, "test pk_backend_parse_common_error Error1");
+	ret = pk_backend_parse_common_error (backend, "error\ttransaction-error\tdescription text");
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not validate correctly");
+	}
+
+	/************************************************************/
+	libst_title (test, "test pk_backend_parse_common_error Error2");
+	ret = pk_backend_parse_common_error (backend, "error\tnot-present-woohoo\tdescription text");
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not validate correctly");
+	}
+
+	/************************************************************/
+	libst_title (test, "test pk_backend_parse_common_error Status");
+	ret = pk_backend_parse_common_error (backend, "status\tquery");
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not validate correctly");
+	}
+
+	/************************************************************/
+	libst_title (test, "test pk_backend_parse_common_error RequireRestart");
+	ret = pk_backend_parse_common_error (backend, "requirerestart\tsystem\tdetails about the restart");
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not validate correctly");
+	}
+
+	/************************************************************/
+	libst_title (test, "test pk_backend_parse_common_error AllowUpdate1");
+	ret = pk_backend_parse_common_error (backend, "allow-interrupt\ttrue");
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not validate correctly");
+	}
+
+	/************************************************************/
+	libst_title (test, "test pk_backend_parse_common_error AllowUpdate2");
+	ret = pk_backend_parse_common_error (backend, "allow-interrupt\tbrian");
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "did not validate correctly");
+	}
+
+	g_timer_destroy (timer);
 	g_object_unref (backend);
 
 	libst_end (test);
commit 7cf61592b634c1c194cee23f4ee73ae227d2433a
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 8 22:32:18 2007 +0000

    correct some devel docs

diff --git a/docs/pk-backends.xml b/docs/pk-backends.xml
index 5182653..deaf25b 100644
--- a/docs/pk-backends.xml
+++ b/docs/pk-backends.xml
@@ -182,12 +182,12 @@
           </row>
           <row>
             <entry>Package</entry>
-            <entry><literal>package_id[tab]status[tab]package_id[tab]summary</literal></entry>
+            <entry><literal>package_id[tab]status[tab]summary</literal></entry>
             <entry><literal>stdout</literal></entry>
           </row>
           <row>
             <entry>Description</entry>
-            <entry><literal>description[tab]package_id[tab]group[tab]detail[tab]url[tab]size_in_bytes[tab]file_list</literal></entry>
+            <entry><literal>description[tab]package_id[tab]group[tab]detail[tab]url[tab]size_in_bytes</literal></entry>
             <entry><literal>stdout</literal></entry>
           </row>
           <row>
commit e586cd14bf030e423ecbe4c752f2d6383737c498
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 8 22:15:57 2007 +0000

    add a safe version of pk_strtoint for the conversion code

diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index 1ac6860..ce5cfab 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -139,7 +139,9 @@ pk_strnumber (const gchar *text)
 			pk_debug ("input too long!");
 			return FALSE;
 		}
-		if (g_ascii_isdigit (text[i]) == FALSE) {
+		if (i == 0 && text[i] == '-') {
+			/* negative sign */
+		} else if (g_ascii_isdigit (text[i]) == FALSE) {
 			pk_debug ("not a number '%c' in text!", text[i]);
 			return FALSE;
 		}
@@ -148,6 +150,22 @@ pk_strnumber (const gchar *text)
 }
 
 /**
+ * pk_strtoint:
+ **/
+gboolean
+pk_strtoint (const gchar *text, gint *value)
+{
+	gboolean ret;
+	ret = pk_strnumber (text);
+	if (ret == FALSE) {
+		*value = 0;
+		return FALSE;
+	}
+	*value = atoi (text);
+	return TRUE;
+}
+
+/**
  * pk_strzero:
  *
  * This function is a much safer way of doing "if (strlen (text) == 0))"
@@ -452,6 +470,7 @@ libst_common (LibSelfTest *test)
 	gchar *text_safe;
 	const gchar *temp;
 	guint length;
+	gint value;
 
 	if (libst_start (test, "PkCommon", CLASS_AUTO) == FALSE) {
 		return;
@@ -1038,6 +1057,15 @@ libst_common (LibSelfTest *test)
 	}
 
 	/************************************************************/
+	libst_title (test, "check number valid");
+	ret = pk_strnumber ("-123");
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, NULL);
+	}
+
+	/************************************************************/
 	libst_title (test, "check number zero");
 	ret = pk_strnumber ("0");
 	if (ret == TRUE) {
@@ -1074,6 +1102,24 @@ libst_common (LibSelfTest *test)
 	}
 
 	/************************************************************/
+	libst_title (test, "check number not negative");
+	ret = pk_strnumber ("503-");
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, NULL);
+	}
+
+	/************************************************************/
+	libst_title (test, "check number positive");
+	ret = pk_strnumber ("+503");
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, NULL);
+	}
+
+	/************************************************************/
 	libst_title (test, "check number random chars");
 	ret = pk_strnumber ("dave");
 	if (ret == FALSE) {
@@ -1082,6 +1128,37 @@ libst_common (LibSelfTest *test)
 		libst_failed (test, NULL);
 	}
 
+	/************************************************************
+	 **************        Convert numbers       ****************
+	 ************************************************************/
+	libst_title (test, "convert valid number");
+	ret = pk_strtoint ("234", &value);
+	if (ret == TRUE && value == 234) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "value is %i", value);
+	}
+
+	/************************************************************/
+	libst_title (test, "convert negative valid number");
+	ret = pk_strtoint ("-234", &value);
+	if (ret == TRUE && value == -234) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "value is %i", value);
+	}
+
+	/************************************************************/
+	libst_title (test, "don't convert invalid number");
+	ret = pk_strtoint ("dave", &value);
+	if (ret == FALSE && value == 0) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "value is %i", value);
+	}
+
+	/************************************************************/
+
 	libst_end (test);
 }
 #endif
diff --git a/libpackagekit/pk-common.h b/libpackagekit/pk-common.h
index 835a46d..734655e 100644
--- a/libpackagekit/pk-common.h
+++ b/libpackagekit/pk-common.h
@@ -37,6 +37,8 @@ gboolean	 pk_strvalidate				(const gchar	*text);
 gboolean	 pk_strequal				(const gchar	*id1,
 							 const gchar	*id2);
 gboolean	 pk_strnumber				(const gchar	*text);
+gboolean	 pk_strtoint				(const gchar	*text,
+							 gint		*value);
 gchar		*pk_strpad				(const gchar	*data,
 							 guint		 length);
 gchar		*pk_strpad_extra			(const gchar	*data,
commit 0d6c6d41b168728e08a35131ee1b153b8c02dbd4
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 8 21:53:12 2007 +0000

    add pk_strnumber to validate if something is a number

diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index 4184892..1ac6860 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -119,6 +119,35 @@ pk_strsafe (const gchar *text)
 }
 
 /**
+ * pk_strnumber:
+ **/
+gboolean
+pk_strnumber (const gchar *text)
+{
+	guint i;
+	guint length;
+
+	/* check explicitly */
+	if (pk_strzero (text) == TRUE) {
+		return FALSE;
+	}
+
+	/* ITS4: ignore, not used for allocation and checked for oversize */
+	length = strlen (text);
+	for (i=0; i<length; i++) {
+		if (i > 10) {
+			pk_debug ("input too long!");
+			return FALSE;
+		}
+		if (g_ascii_isdigit (text[i]) == FALSE) {
+			pk_debug ("not a number '%c' in text!", text[i]);
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+
+/**
  * pk_strzero:
  *
  * This function is a much safer way of doing "if (strlen (text) == 0))"
@@ -997,6 +1026,62 @@ libst_common (LibSelfTest *test)
 	}
 	g_free (text_safe);
 
+	/************************************************************
+	 **************       Check for numbers      ****************
+	 ************************************************************/
+	libst_title (test, "check number valid");
+	ret = pk_strnumber ("123");
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, NULL);
+	}
+
+	/************************************************************/
+	libst_title (test, "check number zero");
+	ret = pk_strnumber ("0");
+	if (ret == TRUE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, NULL);
+	}
+
+	/************************************************************/
+	libst_title (test, "check number oversize");
+	ret = pk_strnumber ("123456891234");
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, NULL);
+	}
+
+	/************************************************************/
+	libst_title (test, "check number NULL");
+	ret = pk_strnumber (NULL);
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, NULL);
+	}
+
+	/************************************************************/
+	libst_title (test, "check number blank");
+	ret = pk_strnumber ("");
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, NULL);
+	}
+
+	/************************************************************/
+	libst_title (test, "check number random chars");
+	ret = pk_strnumber ("dave");
+	if (ret == FALSE) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, NULL);
+	}
+
 	libst_end (test);
 }
 #endif
diff --git a/libpackagekit/pk-common.h b/libpackagekit/pk-common.h
index 098c096..835a46d 100644
--- a/libpackagekit/pk-common.h
+++ b/libpackagekit/pk-common.h
@@ -36,6 +36,7 @@ gboolean	 pk_strzero				(const gchar	*text);
 gboolean	 pk_strvalidate				(const gchar	*text);
 gboolean	 pk_strequal				(const gchar	*id1,
 							 const gchar	*id2);
+gboolean	 pk_strnumber				(const gchar	*text);
 gchar		*pk_strpad				(const gchar	*data,
 							 guint		 length);
 gchar		*pk_strpad_extra			(const gchar	*data,
commit ab4330c911d92fb67a0cf98f5ab6c4e0c1583d0a
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 8 21:14:20 2007 +0000

    don't return 0 when we do pk_error, or the make check passes when we error out

diff --git a/libpackagekit/pk-debug.c b/libpackagekit/pk-debug.c
index 25098a9..b7e356e 100644
--- a/libpackagekit/pk-debug.c
+++ b/libpackagekit/pk-debug.c
@@ -126,7 +126,7 @@ pk_error_real (const gchar *func,
 	fprintf (stderr, "*** ERROR ***\n");
 	pk_print_line (func, file, line, buffer);
 	g_free(buffer);
-	exit (0);
+	exit (1);
 }
 
 /**
commit 740efd3edd1fc37e3fa4b58618294911c5e328a9
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Nov 8 18:41:22 2007 +0000

    remove the at symbol from the char blacklist

diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index 8db860b..4184892 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -92,7 +92,6 @@ pk_strvalidate_char (gchar item)
 	case ']':
 	case '{':
 	case '}':
-	case '@':
 	case '#':
 	case '\\':
 	case '<':
@@ -177,7 +176,7 @@ pk_strvalidate (const gchar *text)
 			return FALSE;
 		}
 		if (pk_strvalidate_char (text[i]) == FALSE) {
-			pk_debug ("invalid char in text!");
+			pk_debug ("invalid char '%c' in text!", text[i]);
 			return FALSE;
 		}
 	}
commit ac5a5dd9a5e33fbf5784f19d6acec6d86a40c68b
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Thu Nov 8 18:19:11 2007 +0000

    fixed typo in a comment

diff --git a/src/pk-backend-python.c b/src/pk-backend-python.c
index 0de1c6c..fbcf221 100644
--- a/src/pk-backend-python.c
+++ b/src/pk-backend-python.c
@@ -22,7 +22,7 @@
 #include <pk-backend-python.h>
 
 /**
- * pk_backend_python_cancel:
+ * pk_backend_bool_to_text:
  */
 static const gchar *
 pk_backend_bool_to_text (gboolean value)
commit 6cbb6b20a2ba6ce3666290e97f78c52127cfffb9
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Wed Nov 7 18:02:09 2007 -0500

    pkcon: If no matches found in perhaps_resolve, don't print that multiple matches were found.

diff --git a/client/pk-console.c b/client/pk-console.c
index b9e4f99..20e9eb2 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -430,11 +430,13 @@ pk_console_perhaps_resolve (PkClient *client, PkFilterEnum filter, const gchar *
 		return item->package_id;
 	}
 
-	/* else list the options */
-	g_print ("There are multiple matches\n");
-	for (i=0; i<length; i++) {
-		item = pk_client_package_buffer_get_item (client_resolve, i);
-		g_print ("%i. %s\n", i+1, item->package_id);
+	/* else list the options if multiple matches found */
+	if (length != 0) {
+		g_print ("There are multiple matches\n");
+		for (i=0; i<length; i++) {
+			item = pk_client_package_buffer_get_item (client_resolve, i);
+			g_print ("%i. %s\n", i+1, item->package_id);
+		}
 	}
 	return NULL;
 }
commit 12a0e4eba0d4ab2d967a5890a35cef1c1862d5d1
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Wed Nov 7 17:54:44 2007 -0500

    pkcon: Use the NONE filter where appropriate for resolving.

diff --git a/client/pk-console.c b/client/pk-console.c
index 745d4da..b9e4f99 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -501,7 +501,7 @@ pk_console_get_requires (PkClient *client, const gchar *package)
 {
 	gboolean ret;
 	gchar *package_id;
-	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_INSTALLED, package);
+	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_NONE, package);
 	if (package_id == NULL) {
 		g_print ("Could not find a package with that name to get requires\n");
 		return FALSE;
@@ -519,7 +519,7 @@ pk_console_get_depends (PkClient *client, const gchar *package)
 {
 	gboolean ret;
 	gchar *package_id;
-	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_INSTALLED, package);
+	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_NONE, package);
 	if (package_id == NULL) {
 		g_print ("Could not find a package with that name to get depends\n");
 		return FALSE;
@@ -537,7 +537,7 @@ pk_console_get_description (PkClient *client, const gchar *package)
 {
 	gboolean ret;
 	gchar *package_id;
-	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_INSTALLED, package);
+	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_NONE, package);
 	if (package_id == NULL) {
 		g_print ("Could not find a package with that name to get description\n");
 		return FALSE;
@@ -555,7 +555,7 @@ pk_console_get_files (PkClient *client, const gchar *package)
 {
 	gboolean ret;
 	gchar *package_id;
-	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_INSTALLED, package);
+	package_id = pk_console_perhaps_resolve (client, PK_FILTER_ENUM_NONE, package);
 	if (package_id == NULL) {
 		g_print ("Could not find a package with that name to get files\n");
 		return FALSE;
commit b7fbcbe44ffcf72629e41a943447de3900ecbf06
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Wed Nov 7 09:18:09 2007 -0500

    Add a 'none' filter enum entry.

diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index b44ed0c..9d8e0ca 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -121,6 +121,7 @@ static PkEnumMatch enum_restart[] = {
 
 static PkEnumMatch enum_filter[] = {
 	{PK_FILTER_ENUM_UNKNOWN,		"unknown"},	/* fall though value */
+	{PK_FILTER_ENUM_NONE,			"none"},
 	{PK_FILTER_ENUM_DEVELOPMENT,		"devel"},
 	{PK_FILTER_ENUM_INSTALLED,		"installed"},
 	{PK_FILTER_ENUM_GUI,			"gui"},
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 76fc5fc..ccd3f3a 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -89,6 +89,7 @@ typedef enum {
 	PK_FILTER_ENUM_NOT_DEVELOPMENT,
 	PK_FILTER_ENUM_NOT_INSTALLED,
 	PK_FILTER_ENUM_NOT_GUI,
+	PK_FILTER_ENUM_NONE,
 	PK_FILTER_ENUM_UNKNOWN
 } PkFilterEnum;
 
commit f8462230552d86991032a09c8df6390f2825a0b1
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Wed Nov 7 17:45:45 2007 -0500

    pk-common: Use pk_filter_enum_from_text instead of pk_filter_check_part.

diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index 9b1061c..8db860b 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -34,43 +34,7 @@
 
 #include "pk-debug.h"
 #include "pk-common.h"
-
-/**
- * pk_filter_check_part:
- **/
-gboolean
-pk_filter_check_part (const gchar *filter)
-{
-	if (filter == NULL) {
-		return FALSE;
-	}
-	if (pk_strzero (filter) == TRUE) {
-		return FALSE;
-	}
-	/* keep strcmp for speed */
-	if (strcmp (filter, "none") == 0) {
-		return TRUE;
-	}
-	if (strcmp (filter, "installed") == 0) {
-		return TRUE;
-	}
-	if (strcmp (filter, "~installed") == 0) {
-		return TRUE;
-	}
-	if (strcmp (filter, "devel") == 0) {
-		return TRUE;
-	}
-	if (strcmp (filter, "~devel") == 0) {
-		return TRUE;
-	}
-	if (strcmp (filter, "gui") == 0) {
-		return TRUE;
-	}
-	if (strcmp (filter, "~gui") == 0) {
-		return TRUE;
-	}
-	return FALSE;
-}
+#include "pk-enum.h"
 
 /**
  * pk_filter_check:
@@ -101,7 +65,7 @@ pk_filter_check (const gchar *filter)
 		if (pk_strzero (sections[i]) == TRUE) {
 			goto out;
 		}
-		if (pk_filter_check_part (sections[i]) == FALSE) {
+		if (pk_filter_enum_from_text (sections[i]) == PK_FILTER_ENUM_UNKNOWN) {
 			goto out;
 		}
 	}



More information about the PackageKit mailing list