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

Richard Hughes hughsient at kemper.freedesktop.org
Sat Feb 2 01:01:20 PST 2008


 libpackagekit/.gitignore  |    1 
 libpackagekit/pk-client.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++
 libpackagekit/pk-client.h |    2 +
 src/pk-backend.c          |    4 +++
 tools/.gitignore          |    2 +
 5 files changed, 58 insertions(+)

New commits:
commit 1b1d2ba9c2c24ce4e57d54fb44e363c93923d610
Author: Richard Hughes <richard at hughsie.com>
Date:   Sat Feb 2 08:58:26 2008 +0000

    update gitignore

diff --git a/libpackagekit/.gitignore b/libpackagekit/.gitignore
index ec55faa..c9d3c55 100644
--- a/libpackagekit/.gitignore
+++ b/libpackagekit/.gitignore
@@ -12,4 +12,5 @@ pk-self-test
 *.gcno
 *.txt
 *.out
+*.db
 
diff --git a/tools/.gitignore b/tools/.gitignore
new file mode 100644
index 0000000..d6ec1da
--- /dev/null
+++ b/tools/.gitignore
@@ -0,0 +1,2 @@
+allApplications
+
commit 279dbaa471d6db8a43212b5516a29b24bfe6123d
Author: Richard Hughes <richard at hughsie.com>
Date:   Sat Feb 2 08:53:11 2008 +0000

    add client side filtering support so we can trivially stip out the correct package when we have it installed and available in multiple repos

diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 0890bd4..3a00a13 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -43,6 +43,7 @@
 #include "pk-enum.h"
 #include "pk-client.h"
 #include "pk-connection.h"
+#include "pk-package-id.h"
 #include "pk-package-list.h"
 #include "pk-debug.h"
 #include "pk-marshal.h"
@@ -65,9 +66,11 @@ struct PkClientPrivate
 	DBusGConnection		*connection;
 	DBusGProxy		*proxy;
 	GMainLoop		*loop;
+	GHashTable		*hash;
 	gboolean		 is_finished;
 	gboolean		 use_buffer;
 	gboolean		 synchronous;
+	gboolean		 name_filter;
 	gboolean		 promiscuous;
 	gchar			*tid;
 	PkPackageList		*package_list;
@@ -240,6 +243,23 @@ pk_client_set_synchronous (PkClient *client, gboolean synchronous)
 }
 
 /**
+ * pk_client_set_name_filter:
+ * @client: a valid #PkClient instance
+ * @name_filter: if we should check for previous packages before we emit
+ *
+ * Return value: %TRUE if the name_filter mode was enabled
+ **/
+gboolean
+pk_client_set_name_filter (PkClient *client, gboolean name_filter)
+{
+	g_return_val_if_fail (client != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+	client->priv->name_filter = name_filter;
+	return TRUE;
+}
+
+/**
  * pk_client_get_use_buffer:
  * @client: a valid #PkClient instance
  *
@@ -335,6 +355,7 @@ pk_client_reset (PkClient *client)
 	client->priv->tid = NULL;
 	client->priv->use_buffer = FALSE;
 	client->priv->synchronous = FALSE;
+	client->priv->name_filter = FALSE;
 	client->priv->tid = NULL;
 	client->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
 	client->priv->role = PK_ROLE_ENUM_UNKNOWN;
@@ -483,6 +504,9 @@ pk_client_package_cb (DBusGProxy   *proxy,
 		      PkClient     *client)
 {
 	PkInfoEnum info;
+	PkPackageId *pid;
+	const gchar *data;
+
 	g_return_if_fail (client != NULL);
 	g_return_if_fail (PK_IS_CLIENT (client));
 
@@ -491,6 +515,27 @@ pk_client_package_cb (DBusGProxy   *proxy,
 		return;
 	}
 
+	/* filter repeat names */
+	if (client->priv->name_filter == TRUE) {
+		/* get the package name */
+		pid = pk_package_id_new_from_string (package_id);
+		pk_debug ("searching hash for %s", pid->name);
+
+		/* is already in the cache? */
+		data = (const gchar *) g_hash_table_lookup (client->priv->hash, pid->name);
+		if (data != NULL) {
+			pk_package_id_free (pid);
+			pk_debug ("ignoring as name filter is on, and previous found; %s", data);
+			return;
+		}
+
+		/* add to the cache */
+		pk_debug ("adding %s into the hash", pid->name);
+		g_hash_table_insert (client->priv->hash, g_strdup (pid->name), g_strdup (pid->name));
+		pk_package_id_free (pid);
+	}
+
+
 	pk_debug ("emit package %s, %s, %s", info_text, package_id, summary);
 	info = pk_info_enum_from_text (info_text);
 	g_signal_emit (client , signals [PK_CLIENT_PACKAGE], 0, info, package_id, summary);
@@ -2781,6 +2826,7 @@ pk_client_init (PkClient *client)
 
 	client->priv = PK_CLIENT_GET_PRIVATE (client);
 	client->priv->tid = NULL;
+	client->priv->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 	client->priv->loop = g_main_loop_new (NULL, FALSE);
 	client->priv->use_buffer = FALSE;
 	client->priv->promiscuous = FALSE;
@@ -2999,6 +3045,9 @@ pk_client_finalize (GObject *object)
 	/* clear the loop, if we were using it */
 	g_main_loop_unref (client->priv->loop);
 
+	/* free the hash table */
+	g_hash_table_destroy (client->priv->hash);
+
 	/* disconnect signal handlers */
 	dbus_g_proxy_disconnect_signal (client->priv->proxy, "Finished",
 				        G_CALLBACK (pk_client_finished_cb), client);
diff --git a/libpackagekit/pk-client.h b/libpackagekit/pk-client.h
index 04b707a..5a8c725 100644
--- a/libpackagekit/pk-client.h
+++ b/libpackagekit/pk-client.h
@@ -69,6 +69,8 @@ gboolean	 pk_client_set_use_buffer		(PkClient	*client,
 							 gboolean	 use_buffer);
 gboolean	 pk_client_set_synchronous		(PkClient	*client,
 							 gboolean	 synchronous);
+gboolean	 pk_client_set_name_filter		(PkClient	*client,
+							 gboolean	 name_filter);
 gboolean	 pk_client_get_use_buffer		(PkClient	*client);
 gboolean	 pk_client_get_allow_cancel		(PkClient	*client);
 
commit e2e8149bd3a62878204d9770e650a59ab76b5659
Author: Richard Hughes <richard at hughsie.com>
Date:   Sat Feb 2 07:56:37 2008 +0000

    reset the time when we do pk_backend_set_role else we get invalid runtimes

diff --git a/src/pk-backend.c b/src/pk-backend.c
index 5124c75..465507e 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -644,6 +644,10 @@ pk_backend_set_role (PkBackend *backend, PkRoleEnum role)
 			    pk_role_enum_to_text (backend->priv->role));
 		return FALSE;
 	}
+
+	/* reset the timer */
+	pk_time_reset (backend->priv->time);
+
 	pk_debug ("setting role to %s", pk_role_enum_to_text (role));
 	backend->priv->role = role;
 	backend->priv->status = PK_STATUS_ENUM_WAIT;



More information about the PackageKit mailing list