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

Richard Hughes hughsient at kemper.freedesktop.org
Tue Oct 23 01:58:34 PDT 2007


 Makefile.am                            |   38 ++++++++++++++++-----------------
 TODO                                   |    3 --
 backends/smart/helpers/search-name.py  |   19 ++++++++++++++++
 backends/smart/helpers/smartBackend.py |   32 +++++++++++++++++++--------
 backends/smart/pk-backend-smart.c      |   12 +++++++++-
 client/pk-console.c                    |    4 ++-
 libgbus/libgbus.c                      |   12 +++++++---
 libpackagekit/pk-connection.c          |    8 ++----
 src/pk-backend-internal.h              |    2 -
 src/pk-backend.c                       |    9 ++++++-
 src/pk-engine.c                        |    8 +++---
 src/pk-interface.xml                   |    2 -
 12 files changed, 100 insertions(+), 49 deletions(-)

New commits:
commit 8b8151f7b58a22f767d244856182e5d21c5f3c10
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 23 09:55:03 2007 +0100

    Convert finished signal to have time in milliseconds, not seconds.

diff --git a/TODO b/TODO
index 0bcedb3..b06d3ca 100644
--- a/TODO
+++ b/TODO
@@ -26,6 +26,3 @@ To do rollbacks sanely in PK we need a few things:
 resolve in pkcon has to check for installed package already - and not
 display a cryptic message when already installed
 
-*** Not enough resoltion in finished ***
-Convert finished signal to have time in milliseconds, not seconds.
-
diff --git a/client/pk-console.c b/client/pk-console.c
index 0abe0e2..6862286 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -316,6 +316,7 @@ pk_console_finished_cb (PkClient *client, PkStatusEnum status, guint runtime, gp
 	PkRoleEnum role;
 	gchar *blanking;
 	const gchar *role_text;
+	gfloat time;
 
 	/* cancel the spinning */
 	if (timer_id != 0) {
@@ -333,7 +334,8 @@ pk_console_finished_cb (PkClient *client, PkStatusEnum status, guint runtime, gp
 
 	pk_client_get_role (client, &role, NULL);
 	role_text = pk_role_enum_to_text (role);
-	g_print ("%s runtime was %i seconds\n", role_text, runtime);
+	time = (gfloat) runtime / 1000.0;
+	g_print ("%s runtime was %.1f seconds\n", role_text, time);
 	if (loop != NULL) {
 		g_main_loop_quit (loop);
 	}
diff --git a/libgbus/libgbus.c b/libgbus/libgbus.c
index 600a5f7..d15181e 100644
--- a/libgbus/libgbus.c
+++ b/libgbus/libgbus.c
@@ -72,13 +72,11 @@ name_owner_changed_cb (DBusGProxy     *proxy,
 	if (strcmp (name, libgbus->priv->service) == 0) {
 		/* ITS4: ignore, not used for allocation */
 		if (strlen (prev) != 0 && strlen (new) == 0 && libgbus->priv->connected == TRUE) {
-			g_debug ("emitting connection-changed for %s", name);
 			g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, FALSE);
 			libgbus->priv->connected = FALSE;
 		}
 		/* ITS4: ignore, not used for allocation */
 		if (strlen (prev) == 0 && strlen (new) != 0 && libgbus->priv->connected == FALSE) {
-			g_debug ("emitting connection-changed for %s", name);
 			g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, TRUE);
 			libgbus->priv->connected = TRUE;
 		}
@@ -143,7 +141,6 @@ libgbus_assign (LibGBus      *libgbus,
 	/* coldplug */
 	libgbus->priv->connected = libgbus_is_connected (libgbus);
 	if (libgbus->priv->connected == TRUE) {
-		g_debug ("emitting connection-changed for %s", service);
 		g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, TRUE);
 	}
 	return TRUE;
diff --git a/src/pk-backend-internal.h b/src/pk-backend-internal.h
index 61d4c7f..128c87d 100644
--- a/src/pk-backend-internal.h
+++ b/src/pk-backend-internal.h
@@ -60,7 +60,7 @@ gboolean	 pk_backend_get_backend_detail		(PkBackend	*backend,
 							 gchar		**version);
 PkEnumList	*pk_backend_get_groups			(PkBackend	*backend);
 PkEnumList	*pk_backend_get_filters			(PkBackend	*backend);
-gdouble		 pk_backend_get_runtime			(PkBackend	*backend);
+guint		 pk_backend_get_runtime			(PkBackend	*backend);
 gboolean	 pk_backend_load			(PkBackend      *backend,
 							 const gchar	*name);
 gboolean	 pk_backend_run				(PkBackend      *backend);
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 171879e..dc189b4 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -1605,11 +1605,16 @@ pk_backend_get_filters (PkBackend *backend)
 
 /**
  * pk_backend_get_runtime:
+ *
+ * Returns time running in ms
  */
-gdouble
+guint
 pk_backend_get_runtime (PkBackend *backend)
 {
-	return g_timer_elapsed (backend->priv->timer, NULL);
+	gdouble time;
+	time = g_timer_elapsed (backend->priv->timer, NULL);
+	time *= 1000;
+	return (guint) time;
 }
 
 /**
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 540c89b..b912680 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -502,7 +502,7 @@ pk_engine_finished_cb (PkBackend *backend, PkExitEnum exit, PkEngine *engine)
 	PkTransactionItem *item;
 	PkRoleEnum role;
 	const gchar *exit_text;
-	gdouble time;
+	guint time;
 	gchar *packages;
 
 	g_return_if_fail (engine != NULL);
@@ -568,7 +568,7 @@ pk_engine_finished_cb (PkBackend *backend, PkExitEnum exit, PkEngine *engine)
 	}
 	g_free (packages);
 
-	pk_debug ("backend was running for %f seconds", time);
+	pk_debug ("backend was running for %i ms", time);
 	pk_transaction_db_set_finished (engine->priv->transaction_db, item->tid, TRUE, time);
 
 	/* could the update list have changed? */
@@ -579,8 +579,8 @@ pk_engine_finished_cb (PkBackend *backend, PkExitEnum exit, PkEngine *engine)
 	}
 
 	exit_text = pk_exit_enum_to_text (exit);
-	pk_debug ("emitting finished transaction:%s, '%s', %i", item->tid, exit_text, (guint) time);
-	g_signal_emit (engine, signals [PK_ENGINE_FINISHED], 0, item->tid, exit_text, (guint) time);
+	pk_debug ("emitting finished transaction:%s, '%s', %i", item->tid, exit_text, time);
+	g_signal_emit (engine, signals [PK_ENGINE_FINISHED], 0, item->tid, exit_text, time);
 
 	/* unref */
 	g_object_unref (backend);
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index a78556b..824ba7b 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -128,7 +128,7 @@
     <signal name="Finished">
       <arg type="s" name="tid" direction="out"/>
       <arg type="s" name="status" direction="out"/> <!-- success,failed,canceled -->
-      <arg type="u" name="runtime" direction="out"/> <!-- amount of time transaction has been running in seconds -->
+      <arg type="u" name="runtime" direction="out"/> <!-- amount of time transaction has been running in ms -->
     </signal>
     <signal name="AllowInterrupt">
       <arg type="s" name="tid" direction="out"/>
commit 9b68af101208c468bfcedbf943aeec8b0e747889
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 23 09:36:45 2007 +0100

    a few cosmetic changes to libgbus

diff --git a/Makefile.am b/Makefile.am
index 72d9cc3..5904601 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,22 +1,22 @@
-SUBDIRS = 			\
-	docs			\
-	html			\
-	policy			\
-	etc			\
-	man			\
-	data			\
-	libselftest		\
-	libgbus			\
-	libpackagekit		\
-	src			\
-	client			\
-	backends		\
-	$(NULL)
-
 AUTOMAKE_OPTIONS = 1.7
 
 NULL =
 
+SUBDIRS = 						\
+	docs						\
+	html						\
+	policy						\
+	etc						\
+	man						\
+	data						\
+	libselftest					\
+	libgbus						\
+	libpackagekit					\
+	src						\
+	client						\
+	backends					\
+	$(NULL)
+
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = packagekit.pc
 
@@ -24,10 +24,10 @@ dbusdir = ${SYSCONFDIR}/dbus-1/system.d
 dist_dbus_DATA = PackageKit.conf
 
 packagekitpythondir = ${PYTHON_PACKAGE_DIR}
-packagekitpython_PYTHON =             \
-	python/packagekit/__init__.py     \
-	python/packagekit/backend.py		\
-	python/packagekit/frontend.py		\
+packagekitpython_PYTHON =				\
+	python/packagekit/__init__.py			\
+	python/packagekit/backend.py			\
+	python/packagekit/frontend.py			\
 	$(NULL)
 	
 
diff --git a/libgbus/libgbus.c b/libgbus/libgbus.c
index 96bb1a1..600a5f7 100644
--- a/libgbus/libgbus.c
+++ b/libgbus/libgbus.c
@@ -72,11 +72,13 @@ name_owner_changed_cb (DBusGProxy     *proxy,
 	if (strcmp (name, libgbus->priv->service) == 0) {
 		/* ITS4: ignore, not used for allocation */
 		if (strlen (prev) != 0 && strlen (new) == 0 && libgbus->priv->connected == TRUE) {
+			g_debug ("emitting connection-changed for %s", name);
 			g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, FALSE);
 			libgbus->priv->connected = FALSE;
 		}
 		/* ITS4: ignore, not used for allocation */
 		if (strlen (prev) == 0 && strlen (new) != 0 && libgbus->priv->connected == FALSE) {
+			g_debug ("emitting connection-changed for %s", name);
 			g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, TRUE);
 			libgbus->priv->connected = TRUE;
 		}
@@ -117,8 +119,8 @@ libgbus_assign (LibGBus      *libgbus,
 	} else {
 		libgbus->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
 	}
-	if (error) {
-		g_warning ("Cannot connect to session bus: %s", error->message);
+	if (error != NULL) {
+		g_warning ("Cannot connect to bus: %s", error->message);
 		g_error_free (error);
 		return FALSE;
 	}
@@ -127,7 +129,7 @@ libgbus_assign (LibGBus      *libgbus,
 								DBUS_PATH_DBUS,
 						 		DBUS_INTERFACE_DBUS,
 								&error);
-	if (error) {
+	if (error != NULL) {
 		g_warning ("Cannot connect to DBUS: %s", error->message);
 		g_error_free (error);
 		return FALSE;
@@ -141,6 +143,7 @@ libgbus_assign (LibGBus      *libgbus,
 	/* coldplug */
 	libgbus->priv->connected = libgbus_is_connected (libgbus);
 	if (libgbus->priv->connected == TRUE) {
+		g_debug ("emitting connection-changed for %s", service);
 		g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, TRUE);
 	}
 	return TRUE;
commit db27350bd606a6d3a83da0466c93c62082e88fdb
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Oct 23 08:49:22 2007 +0100

    emit connection-changed(TRUE) at startip in libgbus if the connection is active - this allows us to easily coldplug

diff --git a/libgbus/libgbus.c b/libgbus/libgbus.c
index 9c29ff2..96bb1a1 100644
--- a/libgbus/libgbus.c
+++ b/libgbus/libgbus.c
@@ -89,6 +89,9 @@ name_owner_changed_cb (DBusGProxy     *proxy,
  * @bus_type: The bus type, either LIBGBUS_SESSION or LIBGBUS_SYSTEM
  * @service: The LIBGBUS service name
  * Return value: success
+ *
+ * Emits connection-changed(TRUE) if connection is alive - this means you
+ * have to connect up the callback before this function is called.
  **/
 gboolean
 libgbus_assign (LibGBus      *libgbus,
@@ -137,6 +140,9 @@ libgbus_assign (LibGBus      *libgbus,
 
 	/* coldplug */
 	libgbus->priv->connected = libgbus_is_connected (libgbus);
+	if (libgbus->priv->connected == TRUE) {
+		g_signal_emit (libgbus, signals [CONNECTION_CHANGED], 0, TRUE);
+	}
 	return TRUE;
 }
 
diff --git a/libpackagekit/pk-connection.c b/libpackagekit/pk-connection.c
index df16135..0984fe7 100644
--- a/libpackagekit/pk-connection.c
+++ b/libpackagekit/pk-connection.c
@@ -122,13 +122,11 @@ pk_connection_init (PkConnection *connection)
 {
 	connection->priv = PK_CONNECTION_GET_PRIVATE (connection);
 	connection->priv->libgbus = libgbus_new ();
-
-	/* hardcode to PK */
-	libgbus_assign (connection->priv->libgbus, LIBGBUS_SYSTEM, PK_DBUS_SERVICE);
-
-	/* watch for future changes */
 	g_signal_connect (connection->priv->libgbus, "connection-changed",
 			  G_CALLBACK (pk_connection_connection_changed_cb), connection);
+
+	/* hardcode to PackageKit */
+	libgbus_assign (connection->priv->libgbus, LIBGBUS_SYSTEM, PK_DBUS_SERVICE);
 }
 
 /**
commit 99fc5ad74a5a821df0c01b2f7771d21d9250a93b
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Mon Oct 22 19:56:14 2007 -0400

    smart: extract a process_search_results method

diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index 477e101..18de83c 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -35,15 +35,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
         packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
         ratio, results, suggestions = self.ctrl.search(packagestring)
 
-        packages = []
-        for obj in results:
-            if isinstance(obj, smart.cache.Package):
-                packages.append(obj)
-
-        if not packages:
-            for obj in results:
-                for pkg in obj.packages:
-                    packages.append(pkg)
+        packages = self._process_search_results(results)
 
         if len(packages) != 1:
             return
@@ -64,15 +56,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
         globbed = "*%s*" % packagename
         ratio, results, suggestions = self.ctrl.search(globbed)
 
-        packages = []
-        for obj in results:
-            if isinstance(obj, smart.cache.Package):
-                packages.append(obj)
-
-        if not packages:
-            for obj in results:
-                for pkg in obj.packages:
-                    packages.append(pkg)
+        packages = self._process_search_results(results)
 
         for package in packages:
             self._show_package(package)
@@ -85,3 +69,16 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
         version, arch = package.version.split('@')
         self.package(self.get_package_id(package.name, version, arch,
             "installed"), status, None)
+
+    def _process_search_results(self, results):
+        packages = []
+        for obj in results:
+            if isinstance(obj, smart.cache.Package):
+                packages.append(obj)
+
+        if not packages:
+            for obj in results:
+                for pkg in obj.packages:
+                    packages.append(pkg)
+
+        return packages
commit 6747155be2ce71e1cf6ac662868a46f3e306c8fe
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Mon Oct 22 11:55:08 2007 -0400

    smart: Add search-name

diff --git a/backends/smart/helpers/search-name.py b/backends/smart/helpers/search-name.py
new file mode 100755
index 0000000..2ea180c
--- /dev/null
+++ b/backends/smart/helpers/search-name.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+# Copyright (C) 2007 James Bowes <jbowes at redhat.com>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+import sys
+import smartBackend
+
+backend = smartBackend.PackageKitSmartBackend(sys.argv[2:])
+backend.search_name(sys.argv[1], sys.argv[2])
+
+sys.exit()
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index e3231c9..477e101 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -60,6 +60,23 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
         for result in results:
             self._show_package(result)
 
+    def search_name(self, filters, packagename):
+        globbed = "*%s*" % packagename
+        ratio, results, suggestions = self.ctrl.search(globbed)
+
+        packages = []
+        for obj in results:
+            if isinstance(obj, smart.cache.Package):
+                packages.append(obj)
+
+        if not packages:
+            for obj in results:
+                for pkg in obj.packages:
+                    packages.append(pkg)
+
+        for package in packages:
+            self._show_package(package)
+
     def _show_package(self, package):
         if package.installed:
             status = INFO_INSTALLED
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index 7a97e0d..53112f8 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -51,6 +51,16 @@ backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_i
 	pk_backend_spawn_helper (backend, "resolve.py", filter, package_id, NULL);
 }
 
+/**
+ * backend_search_name:
+ */
+static void
+backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_spawn_helper (backend, "search-name.py", filter, search, NULL);
+}
+
 PK_BACKEND_OPTIONS (
 	"SMART",					/* description */
 	"0.0.1",					/* version */
@@ -74,7 +84,7 @@ PK_BACKEND_OPTIONS (
 	NULL,						/* search_details */
 	NULL,						/* search_file */
 	NULL,						/* search_group */
-	NULL,						/* search_name */
+	backend_search_name,				/* search_name */
 	NULL,						/* update_package */
 	NULL,						/* update_system */
 	NULL,						/* get_repo_list */



More information about the PackageKit mailing list