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

Richard Hughes hughsient at kemper.freedesktop.org
Wed Oct 24 15:44:02 PDT 2007


 backends/BACKENDS            |    2 -
 client/pk-console.c          |    3 +-
 docs/pk-introduction.xml     |   13 +++++++++
 html/pk-faq.html             |    2 -
 html/pk-help.html            |    2 -
 libpackagekit/pk-client.c    |   13 ++-------
 libpackagekit/pk-enum.c      |    5 ++-
 libpackagekit/pk-enum.h      |    5 ++-
 libpackagekit/pk-task-list.c |   54 --------------------------------------
 python/packagekit/backend.py |    2 +
 src/pk-backend.c             |   26 ++++++++++++++----
 src/pk-engine.c              |   61 ++++++++++++++++++++++++++++++++++++++++---
 src/pk-spawn.c               |   28 ++++++++++---------
 src/pk-spawn.h               |    8 -----
 src/pk-transaction-list.c    |   55 ++++++++++++++++++++++++++++++++------
 src/pk-transaction-list.h    |    1 
 16 files changed, 173 insertions(+), 107 deletions(-)

New commits:
commit b153b89648eb39e3418be9b3ffbb19512a92cb4c
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Oct 24 23:40:20 2007 +0100

    add two more error enums for cancellation

diff --git a/docs/pk-introduction.xml b/docs/pk-introduction.xml
index ab84f4e..d339757 100644
--- a/docs/pk-introduction.xml
+++ b/docs/pk-introduction.xml
@@ -333,6 +333,19 @@
                 stable operation of the system.
               </entry>
             </row>
+            <row>
+              <entry><literal>process-quit</literal></entry>
+              <entry>
+                The process was asked to quit, probably because it was cancelled.
+              </entry>
+            </row>
+            <row>
+              <entry><literal>process-kill</literal></entry>
+              <entry>
+                The process was forcibly killed, probably because ignored the
+                quit request. This is probably due to it being cancelled.
+              </entry>
+            </row>
           </tbody>
         </tgroup>
       </informaltable>
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 3b467d2..fcee276 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -101,6 +101,8 @@ static PkTaskEnumMatch task_error[] = {
 	{PK_ERROR_ENUM_CREATE_THREAD_FAILED,	"create-thread-failed"},
 	{PK_ERROR_ENUM_REPO_NOT_FOUND,		"repo-not-found"},
 	{PK_ERROR_ENUM_CANNOT_REMOVE_SYSTEM_PACKAGE,	"cannot-remove-system-package"},
+	{PK_ERROR_ENUM_PROCESS_QUIT,		"process-quit"},
+	{PK_ERROR_ENUM_PROCESS_KILL,		"process-kill"},
 	{0, NULL},
 };
 
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 9b48476..e3748a1 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -109,6 +109,8 @@ typedef enum {
 	PK_ERROR_ENUM_NO_CACHE,
 	PK_ERROR_ENUM_REPO_NOT_FOUND,
 	PK_ERROR_ENUM_CANNOT_REMOVE_SYSTEM_PACKAGE,
+	PK_ERROR_ENUM_PROCESS_QUIT,
+	PK_ERROR_ENUM_PROCESS_KILL,
 	PK_ERROR_ENUM_UNKNOWN
 } PkErrorCodeEnum;
 
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 99a2d54..a288a84 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -42,6 +42,8 @@ ERROR_TRANSACTION_ERROR = "transaction-error"
 ERROR_NO_CACHE = "no-cache"
 ERROR_REPO_NOT_FOUND = "repo-not-found"
 ERROR_CANNOT_REMOVE_SYSTEM_PACKAGE = "cannot-remove-system-package"
+ERROR_PROCESS_QUIT="process-quit"
+ERROR_PROCESS_KILL="process-kill"
 
 STATE_DOWNLOAD = "download"
 STATE_INSTALL = "install"
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 7e7512f..e719b49 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -479,15 +479,15 @@ pk_backend_spawn_finished_cb (PkSpawn *spawn, PkExitEnum exit, PkBackend *backen
 	/* if we quit the process, set an error */
 	if (exit == PK_EXIT_ENUM_QUIT) {
 		/* we just call this failed, and set an error */
-		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
+		pk_backend_error_code (backend, PK_ERROR_ENUM_PROCESS_QUIT,
 				       "Transaction was cancelled");
 	}
 
 	/* if we killed the process, set an error */
 	if (exit == PK_EXIT_ENUM_KILL) {
 		/* we just call this failed, and set an error */
-		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
-				       "Transaction was killed");
+		pk_backend_error_code (backend, PK_ERROR_ENUM_PROCESS_KILL,
+				       "Transaction was cancelled");
 	}
 
 	if (backend->priv->set_error == FALSE &&
commit 11e724b52e303494519f6dd9ad0d721d4928100c
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Oct 24 23:34:16 2007 +0100

    don't have two enum types for spawn failure

diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 7bee18e..3b467d2 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -39,7 +39,8 @@ static PkTaskEnumMatch task_exit[] = {
 	{PK_EXIT_ENUM_UNKNOWN,			"unknown"},	/* fall though value */
 	{PK_EXIT_ENUM_SUCCESS,			"success"},
 	{PK_EXIT_ENUM_FAILED,			"failed"},
-	{PK_EXIT_ENUM_CANCELED,			"canceled"},
+	{PK_EXIT_ENUM_QUIT,			"quit"},
+	{PK_EXIT_ENUM_KILL,			"kill"},
 	{0, NULL},
 };
 
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index deb3289..9b48476 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -69,7 +69,8 @@ typedef enum {
 typedef enum {
 	PK_EXIT_ENUM_SUCCESS,
 	PK_EXIT_ENUM_FAILED,
-	PK_EXIT_ENUM_CANCELED,
+	PK_EXIT_ENUM_QUIT,
+	PK_EXIT_ENUM_KILL,
 	PK_EXIT_ENUM_UNKNOWN
 } PkExitEnum;
 
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 9a40c0f..7e7512f 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -468,14 +468,30 @@ pk_backend_spawn_helper_delete (PkBackend *backend)
  * pk_backend_spawn_finished_cb:
  **/
 static void
-pk_backend_spawn_finished_cb (PkSpawn *spawn, gint exitcode, PkBackend *backend)
+pk_backend_spawn_finished_cb (PkSpawn *spawn, PkExitEnum exit, PkBackend *backend)
 {
-	pk_debug ("deleting spawn %p, exit code %i", spawn, exitcode);
+	pk_debug ("deleting spawn %p, exit %s", spawn, pk_exit_enum_to_text (exit));
 	pk_backend_spawn_helper_delete (backend);
 
-	/* check shit scripts returned an error on failure */
-	if (exitcode != 0 && backend->priv->exit != PK_EXIT_ENUM_FAILED) {
-		pk_warning ("script returned false but did not return error");
+	/* save this for the finished handler */
+	backend->priv->exit = exit;
+
+	/* if we quit the process, set an error */
+	if (exit == PK_EXIT_ENUM_QUIT) {
+		/* we just call this failed, and set an error */
+		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
+				       "Transaction was cancelled");
+	}
+
+	/* if we killed the process, set an error */
+	if (exit == PK_EXIT_ENUM_KILL) {
+		/* we just call this failed, and set an error */
+		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
+				       "Transaction was killed");
+	}
+
+	if (backend->priv->set_error == FALSE &&
+	    backend->priv->exit == PK_EXIT_ENUM_FAILED) {
 		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
 				       "Helper returned non-zero return value but did not set error");
 	}
diff --git a/src/pk-spawn.c b/src/pk-spawn.c
index e517e3b..b5ad306 100644
--- a/src/pk-spawn.c
+++ b/src/pk-spawn.c
@@ -41,6 +41,8 @@
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
+#include <pk-enum.h>
+
 #include "pk-debug.h"
 #include "pk-spawn.h"
 #include "pk-marshal.h"
@@ -61,7 +63,7 @@ struct PkSpawnPrivate
 	guint			 poll_id;
 	guint			 kill_id;
 	gboolean		 finished;
-	PkSpawnExit		 exit;
+	PkExitEnum		 exit;
 	GString			*stderr_buf;
 	GString			*stdout_buf;
 };
@@ -175,13 +177,13 @@ pk_spawn_check_child (PkSpawn *spawn)
 
 	if (WEXITSTATUS (status) > 0) {
 		pk_warning ("Running fork failed with return value %d", WEXITSTATUS (status));
-		if (spawn->priv->exit == PK_SPAWN_EXIT_UNKNOWN) {
-			spawn->priv->exit = PK_SPAWN_EXIT_FAILED;
+		if (spawn->priv->exit == PK_EXIT_ENUM_UNKNOWN) {
+			spawn->priv->exit = PK_EXIT_ENUM_FAILED;
 		}
 	} else {
 		pk_debug ("Running fork successful");
-		if (spawn->priv->exit == PK_SPAWN_EXIT_UNKNOWN) {
-			spawn->priv->exit = PK_SPAWN_EXIT_SUCCESS;
+		if (spawn->priv->exit == PK_EXIT_ENUM_UNKNOWN) {
+			spawn->priv->exit = PK_EXIT_ENUM_SUCCESS;
 		}
 	}
 
@@ -215,7 +217,7 @@ pk_spawn_sigkill_cb (PkSpawn *spawn)
 	}
 
 	/* we won't overwrite this if not unknown */
-	spawn->priv->exit = PK_SPAWN_EXIT_KILL;
+	spawn->priv->exit = PK_EXIT_ENUM_KILL;
 
 	pk_warning ("sending SIGKILL %i", spawn->priv->child_pid);
 	retval = kill (spawn->priv->child_pid, SIGKILL);
@@ -250,7 +252,7 @@ pk_spawn_kill (PkSpawn *spawn)
 	}
 
 	/* we won't overwrite this if not unknown */
-	spawn->priv->exit = PK_SPAWN_EXIT_QUIT;
+	spawn->priv->exit = PK_EXIT_ENUM_QUIT;
 
 	pk_warning ("sending SIGQUIT %i", spawn->priv->child_pid);
 	retval = kill (spawn->priv->child_pid, SIGQUIT);
@@ -362,7 +364,7 @@ pk_spawn_init (PkSpawn *spawn)
 	spawn->priv->poll_id = 0;
 	spawn->priv->kill_id = 0;
 	spawn->priv->finished = FALSE;
-	spawn->priv->exit = PK_SPAWN_EXIT_UNKNOWN;
+	spawn->priv->exit = PK_EXIT_ENUM_UNKNOWN;
 
 	spawn->priv->stderr_buf = g_string_new ("");
 	spawn->priv->stdout_buf = g_string_new ("");
@@ -422,7 +424,7 @@ pk_spawn_new (void)
 #define BAD_EXIT 999
 
 static GMainLoop *loop;
-PkSpawnExit mexit = BAD_EXIT;
+PkExitEnum mexit = BAD_EXIT;
 guint stdout_count = 0;
 guint stderr_count = 0;
 guint finished_count = 0;
@@ -458,7 +460,7 @@ pk_test_get_data (const gchar *filename)
  * pk_test_finished_cb:
  **/
 static void
-pk_test_finished_cb (PkSpawn *spawn, PkSpawnExit exit, LibSelfTest *test)
+pk_test_finished_cb (PkSpawn *spawn, PkExitEnum exit, LibSelfTest *test)
 {
 	pk_debug ("spawn exit=%i", exit);
 	mexit = exit;
@@ -558,7 +560,7 @@ libst_spawn (LibSelfTest *test)
 
 	/************************************************************/
 	libst_title (test, "make sure finished okay");
-	if (mexit == PK_SPAWN_EXIT_SUCCESS) {
+	if (mexit == PK_EXIT_ENUM_SUCCESS) {
 		libst_success (test, NULL);
 	} else {
 		libst_failed (test, "finish was okay!");
@@ -608,7 +610,7 @@ libst_spawn (LibSelfTest *test)
 
 	/************************************************************/
 	libst_title (test, "make sure finished in SIGKILL");
-	if (mexit == PK_SPAWN_EXIT_KILL) {
+	if (mexit == PK_EXIT_ENUM_KILL) {
 		libst_success (test, NULL);
 	} else {
 		libst_failed (test, "finish %i!", mexit);
@@ -636,7 +638,7 @@ libst_spawn (LibSelfTest *test)
 
 	/************************************************************/
 	libst_title (test, "make sure finished in SIGQUIT");
-	if (mexit == PK_SPAWN_EXIT_QUIT) {
+	if (mexit == PK_EXIT_ENUM_QUIT) {
 		libst_success (test, NULL);
 	} else {
 		libst_failed (test, "finish %i!", mexit);
diff --git a/src/pk-spawn.h b/src/pk-spawn.h
index a13d9b9..f2770e0 100644
--- a/src/pk-spawn.h
+++ b/src/pk-spawn.h
@@ -48,14 +48,6 @@ typedef struct
 	GObjectClass	parent_class;
 } PkSpawnClass;
 
-typedef enum {
-	PK_SPAWN_EXIT_SUCCESS,
-	PK_SPAWN_EXIT_FAILED,
-	PK_SPAWN_EXIT_QUIT,
-	PK_SPAWN_EXIT_KILL,
-	PK_SPAWN_EXIT_UNKNOWN
-} PkSpawnExit;
-
 GType		 pk_spawn_get_type		  	(void);
 PkSpawn		*pk_spawn_new				(void);
 
commit 0acac7b2158eb5e1627adbffd7d4c96b33086e18
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Wed Oct 24 18:18:26 2007 -0400

    Link to static faq page in pk-help.

diff --git a/html/pk-help.html b/html/pk-help.html
index 5337d46..943a8c8 100644
--- a/html/pk-help.html
+++ b/html/pk-help.html
@@ -42,7 +42,7 @@ bugs.freedesktop.org</a>
 If you want to write a backend, you can see the <a
 href="pk-reference.html">developer information</a>, or you can checkout
 the source and see the docbook files in doc. Use the <a
-href="wiki/FAQ">FAQ</a> and mailing list for questions, and try to use
+href="pk-faq.html">FAQ</a> and mailing list for questions, and try to use
 existing backends as a template for what you are trying to do.
 </p>
 
commit 3d720a6cac7dd1534bb4645ffac589ef3c531571
Merge: 1064e4e... be285ff...
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Oct 24 23:03:34 2007 +0100

    Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit

commit 1064e4e911958fe9eb4d4323166d48f4e6c70139
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Oct 24 23:03:15 2007 +0100

    fix the lines wrapping when there are multiple resolve matches

diff --git a/client/pk-console.c b/client/pk-console.c
index c799bfc..53b1db9 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -413,9 +413,10 @@ pk_console_perhaps_resolve (PkClient *client, PkFilterEnum filter, const gchar *
 	}
 
 	/* 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 ("option is %s", item->package_id);
+		g_print ("%i. %s\n", i+1, item->package_id);
 	}
 	return NULL;
 }
commit be285ffbd4c6088b9c31372f58abf93035cd8597
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Wed Oct 24 16:47:26 2007 -0400

    Update backend status for yum's update-package.

diff --git a/backends/BACKENDS b/backends/BACKENDS
index 145b8c3..88e40c7 100644
--- a/backends/BACKENDS
+++ b/backends/BACKENDS
@@ -13,7 +13,7 @@ search-group      |        |     |     |     |      |       |      |
 install-package   |   X    |  X  |     |  X  |  X   |   X   |   X  |
 install-file      |        |  X  |     |  X  |      |       |      |
 remove-package    |   X    |  X  |     |  X  |  X   |   X   |   X  |
-update-package    |        |     |     |  X  |      |       |   X  |
+update-package    |        |  X  |     |  X  |      |       |   X  |
 get-depends       |        |  X  |     |  X  |      |       |   X  |
 get-requires      |   X    |     |     |  X  |      |       |   X  |
 get-description   |   X    |  X  |  X  |  X  |      |       |   X  |
diff --git a/html/pk-faq.html b/html/pk-faq.html
index f746a39..4913e08 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -36,7 +36,7 @@ search-group      |        |     |     |     |      |       |      |
 install-package   |   X    |  X  |     |  X  |  X   |   X   |   X  |
 install-file      |        |  X  |     |  X  |      |       |      |
 remove-package    |   X    |  X  |     |  X  |  X   |   X   |   X  |
-update-package    |        |     |     |  X  |      |       |   X  |
+update-package    |        |  X  |     |  X  |      |       |   X  |
 get-depends       |        |  X  |     |  X  |      |       |   X  |
 get-requires      |   X    |     |     |  X  |      |       |   X  |
 get-description   |   X    |  X  |  X  |  X  |      |       |   X  |
commit b469464a5dfa19f35ae63f14adf843ccfaebd3f2
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Oct 24 22:54:07 2007 +0100

    don't use a seporate tid_promiscuous in PkClient as we can't get use this in the methods

diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 05db45d..1ee48a6 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -56,7 +56,6 @@ struct PkClientPrivate
 	gboolean		 use_buffer;
 	gboolean		 promiscuous;
 	gchar			*tid;
-	gchar			*tid_promiscuous;
 	PkPackageList		*package_list;
 	PkConnection		*pconnection;
 	PkPolkitClient		*polkit;
@@ -131,10 +130,6 @@ pk_client_set_promiscuous (PkClient *client, gboolean enabled)
 gchar *
 pk_client_get_tid (PkClient *client)
 {
-	/* return the last thing */
-	if (client->priv->promiscuous == TRUE) {
-		return g_strdup (client->priv->tid_promiscuous);
-	}
 	return g_strdup (client->priv->tid);
 }
 
@@ -268,8 +263,8 @@ pk_client_should_proxy (PkClient *client, const gchar *tid)
 {
 	/* are we promiscuous? */
 	if (client->priv->promiscuous == TRUE) {
-		g_free (client->priv->tid_promiscuous);
-		client->priv->tid_promiscuous = g_strdup (tid);
+		g_free (client->priv->tid);
+		client->priv->tid = g_strdup (tid);
 		return TRUE;
 	}
 
@@ -741,7 +736,7 @@ pk_client_get_role (PkClient *client, PkRoleEnum *role, gchar **package_id)
 	}
 
 	/* we can avoid a trip to the daemon */
-	if (package_id == NULL) {
+	if (client->priv->promiscuous == FALSE && package_id == NULL) {
 		*role = client->priv->role;
 		return TRUE;
 	}
@@ -2276,7 +2271,6 @@ pk_client_init (PkClient *client)
 
 	client->priv = PK_CLIENT_GET_PRIVATE (client);
 	client->priv->tid = NULL;
-	client->priv->tid_promiscuous = NULL;
 	client->priv->use_buffer = FALSE;
 	client->priv->promiscuous = FALSE;
 	client->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
@@ -2455,7 +2449,6 @@ pk_client_finalize (GObject *object)
 	g_free (client->priv->xcached_filter);
 	g_free (client->priv->xcached_search);
 	g_free (client->priv->tid);
-	g_free (client->priv->tid_promiscuous);
 
 	/* disconnect signal handlers */
 	dbus_g_proxy_disconnect_signal (client->priv->proxy, "Finished",
commit 5d888bf81f2a835f50fd65b78d6e4ce0019ffd91
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Oct 24 22:52:54 2007 +0100

    remove task-list-finished and error-code from PkTaskList as there are no users now. A bit of background - the task list didn't give us all the details, and was essentially a non-discrimiate proxy of PkClient. This was bad. Now PkClient can do the other 'bolted on' stuff, there's no need for this functionality

diff --git a/libpackagekit/pk-task-list.c b/libpackagekit/pk-task-list.c
index 352f415..9544338 100644
--- a/libpackagekit/pk-task-list.c
+++ b/libpackagekit/pk-task-list.c
@@ -54,8 +54,6 @@ struct PkTaskListPrivate
 
 typedef enum {
 	PK_TASK_LIST_CHANGED,
-	PK_TASK_LIST_FINISHED,
-	PK_TASK_LIST_ERROR_CODE,
 	PK_TASK_LIST_LAST_SIGNAL
 } PkSignals;
 
@@ -84,7 +82,7 @@ pk_task_list_print (PkTaskList *tlist)
 	}
 	for (i=0; i<length; i++) {
 		item = g_ptr_array_index (tlist->priv->task_list, i);
-		g_print ("%s %s %s\n", item->tid, pk_role_enum_to_text (item->role), item->package_id);
+		g_print ("%s\t%s %s\n", item->tid, pk_role_enum_to_text (item->role), item->package_id);
 	}
 	return TRUE;
 }
@@ -158,42 +156,6 @@ pk_task_list_job_status_changed_cb (PkClient *client, PkStatusEnum status, PkTas
 }
 
 /**
- * pk_task_list_job_finished_cb:
- **/
-static void
-pk_task_list_job_finished_cb (PkClient *client, PkExitEnum exit, guint runtime, PkTaskList *tlist)
-{
-	gchar *tid;
-	PkTaskListItem *item;
-
-	g_return_if_fail (tlist != NULL);
-	g_return_if_fail (PK_IS_TASK_LIST (tlist));
-
-	tid = pk_client_get_tid (client);
-	pk_debug ("tid %s exited with %i", tid, exit);
-
-	/* get correct item */
-	item = pk_task_list_find_existing_tid (tlist, tid);
-	g_free (tid);
-
-	pk_debug ("emit task-list-finished %i, %s, %i", item->role, item->package_id, runtime);
-	g_signal_emit (tlist, signals [PK_TASK_LIST_FINISHED], 0, item->role, item->package_id, runtime);
-}
-
-/**
- * pk_task_list_error_code_cb:
- **/
-static void
-pk_task_list_error_code_cb (PkClient *client, PkErrorCodeEnum error_code, const gchar *details, PkTaskList *tlist)
-{
-	g_return_if_fail (tlist != NULL);
-	g_return_if_fail (PK_IS_TASK_LIST (tlist));
-
-	pk_debug ("emit error-code %i, %s", error_code, details);
-	g_signal_emit (tlist , signals [PK_TASK_LIST_ERROR_CODE], 0, error_code, details);
-}
-
-/**
  * pk_task_list_refresh:
  *
  * Not normally required, but force a refresh
@@ -233,10 +195,6 @@ pk_task_list_refresh (PkTaskList *tlist)
 			item->monitor = pk_client_new ();
 			g_signal_connect (item->monitor, "transaction-status-changed",
 					  G_CALLBACK (pk_task_list_job_status_changed_cb), tlist);
-			g_signal_connect (item->monitor, "finished",
-					  G_CALLBACK (pk_task_list_job_finished_cb), tlist);
-			g_signal_connect (item->monitor, "error-code",
-					  G_CALLBACK (pk_task_list_error_code_cb), tlist);
 			pk_client_set_tid (item->monitor, tid);
 			pk_client_get_role (item->monitor, &item->role, &item->package_id);
 			pk_client_get_status (item->monitor, &item->status);
@@ -318,16 +276,6 @@ pk_task_list_class_init (PkTaskListClass *klass)
 			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
 			      0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
 			      G_TYPE_NONE, 0);
-	signals [PK_TASK_LIST_FINISHED] =
-		g_signal_new ("task-list-finished",
-			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
-			      0, NULL, NULL, pk_marshal_VOID__UINT_STRING_UINT,
-			      G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT);
-	signals [PK_TASK_LIST_ERROR_CODE] =
-		g_signal_new ("error-code",
-			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
-			      0, NULL, NULL, pk_marshal_VOID__UINT_STRING,
-			      G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
 
 	g_type_class_add_private (klass, sizeof (PkTaskListPrivate));
 }
commit 079d0aed55fcc5e5a941aa7e52276cd74aacfe94
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Oct 24 22:48:01 2007 +0100

    defer destroying the backend for 5 seconds so we can query it in finished_cb in clients

diff --git a/src/pk-engine.c b/src/pk-engine.c
index c5ed870..7e0f051 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -542,8 +542,7 @@ pk_engine_finished_cb (PkBackend *backend, PkExitEnum exit, PkEngine *engine)
 	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);
+	/* daemon is busy */
 	pk_engine_reset_timer (engine);
 }
 
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index 0dfca07..c58bda3 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -134,13 +134,30 @@ pk_transaction_list_remove (PkTransactionList *tlist, PkTransactionItem *item)
 	g_free (item->tid);
 	g_free (item);
 
-	/* we have changed what is running */
-	pk_debug ("emmitting ::changed");
-	g_signal_emit (tlist, signals [PK_TRANSACTION_LIST_CHANGED], 0);
-
 	return TRUE;
 }
 
+/* we need this for the finished data */
+typedef struct {
+	PkTransactionList *tlist;
+	PkTransactionItem *item;
+} PkTransactionFinished;
+
+/**
+ * pk_transaction_list_remove_item_timeout:
+ **/
+static gboolean
+pk_transaction_list_remove_item_timeout (gpointer data)
+{
+	PkTransactionFinished *finished = (PkTransactionFinished *) data;
+
+	pk_debug ("transaction %s completed, removing", finished->item->tid);
+	g_object_unref (finished->item->backend);
+	pk_transaction_list_remove (finished->tlist, finished->item);
+	g_free (finished);
+	return FALSE;
+}
+
 /**
  * pk_transaction_list_backend_finished_cb:
  **/
@@ -150,6 +167,7 @@ pk_transaction_list_backend_finished_cb (PkBackend *backend, PkExitEnum exit, Pk
 	guint i;
 	guint length;
 	PkTransactionItem *item;
+	PkTransactionFinished *finished;
 
 	g_return_if_fail (tlist != NULL);
 	g_return_if_fail (PK_IS_TRANSACTION_LIST (tlist));
@@ -160,7 +178,16 @@ pk_transaction_list_backend_finished_cb (PkBackend *backend, PkExitEnum exit, Pk
 	}
 	pk_debug ("transaction %s completed, marking finished", item->tid);
 	item->finished = TRUE;
-	pk_transaction_list_remove (tlist, item);
+
+	/* we have changed what is running */
+	pk_debug ("emmitting ::changed");
+	g_signal_emit (tlist, signals [PK_TRANSACTION_LIST_CHANGED], 0);
+
+	/* give the client a few seconds to still query the backend */
+	finished = g_new0 (PkTransactionFinished, 1);
+	finished->tlist = tlist;
+	finished->item = item;
+	g_timeout_add_seconds (5, pk_transaction_list_remove_item_timeout, finished);
 
 	/* do the next transaction now if we have another queued */
 	length = tlist->priv->array->len;
commit 26c02474fc4e23ef9dc17dd9ecdf48ff8b97be19
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Oct 24 22:14:35 2007 +0100

    mark the transactions as finished when the backend is finished - no functional change - but allows us to do some kool stuff later

diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index 0343fa4..0dfca07 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -80,6 +80,10 @@ pk_transaction_list_role_present (PkTransactionList *tlist, PkRoleEnum role)
 	length = tlist->priv->array->len;
 	for (i=0; i<length; i++) {
 		item = (PkTransactionItem *) g_ptr_array_index (tlist->priv->array, i);
+		/* we might have recently finished this, but not removed it */
+		if (item->finished == TRUE) {
+			continue;
+		}
 		/* we might not have this set yet */
 		if (item->backend == NULL) {
 			continue;
@@ -107,6 +111,7 @@ pk_transaction_list_create (PkTransactionList *tlist)
 	item = g_new0 (PkTransactionItem, 1);
 	item->committed = FALSE;
 	item->running = FALSE;
+	item->finished = FALSE;
 	item->backend = NULL;
 	item->package_list = pk_package_list_new ();
 	item->tid = pk_transaction_id_generate ();
@@ -153,14 +158,17 @@ pk_transaction_list_backend_finished_cb (PkBackend *backend, PkExitEnum exit, Pk
 	if (item == NULL) {
 		pk_error ("no transaction list found!");
 	}
-	pk_debug ("transaction %s completed, removing", item->tid);
+	pk_debug ("transaction %s completed, marking finished", item->tid);
+	item->finished = TRUE;
 	pk_transaction_list_remove (tlist, item);
 
 	/* do the next transaction now if we have another queued */
 	length = tlist->priv->array->len;
 	for (i=0; i<length; i++) {
 		item = (PkTransactionItem *) g_ptr_array_index (tlist->priv->array, i);
-		if (item->committed == TRUE && item->running == FALSE) {
+		if (item->committed == TRUE &&
+		    item->running == FALSE &&
+		    item->finished == FALSE) {
 			pk_debug ("running %s", item->tid);
 			item->running = TRUE;
 			pk_backend_run (item->backend);
@@ -187,7 +195,9 @@ pk_transaction_list_number_running (PkTransactionList *tlist)
 	length = tlist->priv->array->len;
 	for (i=0; i<length; i++) {
 		item = (PkTransactionItem *) g_ptr_array_index (tlist->priv->array, i);
-		if (item->committed == TRUE && item->running == TRUE) {
+		if (item->committed == TRUE &&
+		    item->running == TRUE &&
+		    item->finished == FALSE) {
 			count++;
 		}
 	}
@@ -272,7 +282,7 @@ pk_transaction_list_get_array (PkTransactionList *tlist)
 	for (i=0; i<length; i++) {
 		item = (PkTransactionItem *) g_ptr_array_index (tlist->priv->array, i);
 		/* only return in the list if it worked */
-		if (item->committed == TRUE) {
+		if (item->committed == TRUE && item->finished == FALSE) {
 			array[count] = g_strdup (item->tid);
 			count++;
 		}
diff --git a/src/pk-transaction-list.h b/src/pk-transaction-list.h
index 2add6d6..a677706 100644
--- a/src/pk-transaction-list.h
+++ b/src/pk-transaction-list.h
@@ -53,6 +53,7 @@ typedef struct
 typedef struct {
 	gboolean		 committed;
 	gboolean		 running;
+	gboolean		 finished;
 	PkBackend		*backend;
 	gchar			*tid;
 	PkPackageList		*package_list;
commit 264599834621094f8198e45434ff4de688c4663a
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Oct 24 21:10:29 2007 +0100

    add some debugging text to the daemon

diff --git a/src/pk-engine.c b/src/pk-engine.c
index f11a823..c5ed870 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -733,6 +733,8 @@ pk_engine_get_tid (PkEngine *engine, gchar **tid, GError **error)
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("GetTid method called");
+
 	item = pk_transaction_list_create (engine->priv->transaction_list);
 	pk_debug ("sending tid: '%s'", item->tid);
 	*tid =  g_strdup (item->tid);
@@ -781,6 +783,8 @@ pk_engine_refresh_cache (PkEngine *engine, const gchar *tid, gboolean force, GEr
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("RefreshCache method called: %s, %i", tid, force);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -827,6 +831,8 @@ pk_engine_get_updates (PkEngine *engine, const gchar *tid, GError **error)
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("GetUpdates method called: %s", tid);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -958,6 +964,8 @@ pk_engine_search_name (PkEngine *engine, const gchar *tid, const gchar *filter,
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("SearchName method called: %s, %s, %s", tid, filter, search);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1009,6 +1017,8 @@ pk_engine_search_details (PkEngine *engine, const gchar *tid, const gchar *filte
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("SearchDetails method called: %s, %s, %s", tid, filter, search);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1060,6 +1070,8 @@ pk_engine_search_group (PkEngine *engine, const gchar *tid, const gchar *filter,
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("SearchGroup method called: %s, %s, %s", tid, filter, search);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1111,6 +1123,8 @@ pk_engine_search_file (PkEngine *engine, const gchar *tid, const gchar *filter,
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("SearchFile method called: %s, %s, %s", tid, filter, search);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1162,6 +1176,8 @@ pk_engine_resolve (PkEngine *engine, const gchar *tid, const gchar *filter, cons
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("Resolve method called: %s, %s, %s", tid, filter, package);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1215,6 +1231,8 @@ pk_engine_get_depends (PkEngine *engine, const gchar *tid, const gchar *package_
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("GetDepends method called: %s, %s", tid, package_id);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1270,6 +1288,8 @@ pk_engine_get_requires (PkEngine *engine, const gchar *tid, const gchar *package
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("GetRequires method called: %s, %s", tid, package_id);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1325,6 +1345,8 @@ pk_engine_get_update_detail (PkEngine *engine, const gchar *tid, const gchar *pa
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("GetUpdateDetail method called: %s, %s", tid, package_id);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1380,6 +1402,8 @@ pk_engine_get_description (PkEngine *engine, const gchar *tid, const gchar *pack
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("GetDescription method called: %s, %s", tid, package_id);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1436,6 +1460,8 @@ pk_engine_update_system (PkEngine *engine, const gchar *tid, DBusGMethodInvocati
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
 
+	pk_debug ("UpdateSystem method called: %s", tid);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1495,6 +1521,8 @@ pk_engine_remove_package (PkEngine *engine, const gchar *tid, const gchar *packa
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
 
+	pk_debug ("RemovePackage method called: %s, %s, %i", tid, package_id, allow_deps);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1566,6 +1594,8 @@ pk_engine_install_package (PkEngine *engine, const gchar *tid, const gchar *pack
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
 
+	pk_debug ("method called: %s, %s", tid, package_id);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1637,6 +1667,8 @@ pk_engine_install_file (PkEngine *engine, const gchar *tid, const gchar *full_pa
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
 
+	pk_debug ("InstallFile method called: %s, %s", tid, full_path);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1699,6 +1731,8 @@ pk_engine_rollback (PkEngine *engine, const gchar *tid, const gchar *transaction
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
 
+	pk_debug ("Rollback method called: %s, %s", tid, transaction_id);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1761,6 +1795,8 @@ pk_engine_update_package (PkEngine *engine, const gchar *tid, const gchar *packa
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
 
+	pk_debug ("UpdatePackage method called: %s, %s", tid, package_id);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1828,6 +1864,8 @@ pk_engine_get_repo_list (PkEngine *engine, const gchar *tid, GError **error)
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("GetRepoList method called: %s", tid);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1871,6 +1909,8 @@ pk_engine_repo_enable (PkEngine *engine, const gchar *tid, const gchar *repo_id,
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
 
+	pk_debug ("RepoEnable method called: %s, %s, %i", tid, repo_id, enabled);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1934,6 +1974,8 @@ pk_engine_repo_set_data (PkEngine *engine, const gchar *tid, const gchar *repo_i
 	g_return_if_fail (engine != NULL);
 	g_return_if_fail (PK_IS_ENGINE (engine));
 
+	pk_debug ("RepoSetData method called: %s, %s, %s, %s", tid, repo_id, parameter, value);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -1989,7 +2031,7 @@ pk_engine_get_transaction_list (PkEngine *engine, gchar ***transaction_list, GEr
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
-	pk_debug ("getting transaction list");
+	pk_debug ("GetTransactionList method called");
 	*transaction_list = pk_transaction_list_get_array (engine->priv->transaction_list);
 
 	return TRUE;
@@ -2008,6 +2050,8 @@ pk_engine_get_status (PkEngine *engine, const gchar *tid,
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("GetStatus method called: %s", tid);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -2034,6 +2078,8 @@ pk_engine_get_role (PkEngine *engine, const gchar *tid,
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("GetRole method called: %s", tid);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -2068,6 +2114,8 @@ pk_engine_get_progress (PkEngine *engine, const gchar *tid,
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("GetProgress method called: %s", tid);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -2096,6 +2144,8 @@ pk_engine_get_package (PkEngine *engine, const gchar *tid, gchar **package, GErr
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("GetPackage method called: %s", tid);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -2123,6 +2173,8 @@ pk_engine_get_old_transactions (PkEngine *engine, const gchar *tid, guint number
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("GetOldTransactions method called: %s", tid);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -2151,6 +2203,8 @@ pk_engine_cancel (PkEngine *engine, const gchar *tid, GError **error)
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("Cancel method called: %s", tid);
+
 	/* find pre-requested transaction id */
 	item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
 	if (item == NULL) {
@@ -2223,6 +2277,8 @@ pk_engine_get_backend_detail (PkEngine *engine, gchar **name, gchar **author, gc
 	g_return_val_if_fail (engine != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
+	pk_debug ("GetBackendDetail method called");
+
 	/* create a new backend */
 	backend = pk_engine_backend_new (engine);
 	if (backend == NULL) {



More information about the PackageKit mailing list