[packagekit] packagekit: Branch 'master' - 8 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Tue Sep 18 16:15:55 PDT 2007
TODO | 12 -
backends/alpm/pk-backend-alpm.c | 8
backends/apt/pk-backend-apt.cpp | 8
backends/box/pk-backend-box.c | 10
backends/conary/pk-backend-conary.c | 2
backends/dummy/pk-backend-dummy.c | 8
backends/test/pk-backend-test-fail.c | 2
backends/test/pk-backend-test-nop.c | 2
backends/test/pk-backend-test-spawn.c | 2
backends/test/pk-backend-test-succeed.c | 2
backends/test/pk-backend-test-thread.c | 2
backends/yum/pk-backend-yum.c | 2
libpackagekit/pk-enum.h | 2
libpackagekit/pk-job-list.c | 87 +++-----
libpackagekit/pk-job-list.h | 2
libpackagekit/pk-task-client.c | 60 ++---
libpackagekit/pk-task-list.c | 52 ++--
libpackagekit/pk-task-list.h | 2
libpackagekit/pk-task-monitor.c | 140 ++++++-------
libpackagekit/pk-task-monitor.h | 8
src/Makefile.am | 4
src/pk-backend.c | 21 +
src/pk-backend.h | 8
src/pk-engine.c | 239 +++++++++++-----------
src/pk-engine.h | 38 +--
src/pk-interface.xml | 66 +++---
src/pk-marshal.list | 19 -
src/pk-transaction-id.c | 165 +++++++++++++++
src/pk-transaction-id.h | 34 +++
src/pk-transaction-list.c | 340 ++++++++++++++++----------------
src/pk-transaction-list.h | 36 +--
31 files changed, 791 insertions(+), 592 deletions(-)
New commits:
diff-tree 1f0430f4f065f21d3f1674932c5a3b8aa0f6130c (from a15c34731dd0c233903d237c748e77da3abaa39e)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 23:54:34 2007 +0100
don't log a query in the sqlite database, only stuff that could break your system...
diff --git a/TODO b/TODO
index 217403f..59dbeb6 100644
--- a/TODO
+++ b/TODO
@@ -1,11 +1,5 @@
Order of no particular importance:
-*** Add a queing API ***
-Jobs need to be queued so that read only jobs can be done in parallel,
-but write jobs are done in serial. Maybe spawn each task and put it into a
-paused state?
-NOTE: RELEASE BLOCKER
-
*** API Changes ***
s/GetJobList/GetActiveTransactions
s/JobListChanged/ActiveTransactionsChanged
@@ -14,10 +8,6 @@ s/JobListChanged/ActiveTransactionsChang
For the icon to update after we've done a system upgrade
NOTE: RELEASE BLOCKER
-*** Don't log QUERY, ever ***
-There's no point...
-NOTE: RELEASE BLOCKER
-
*** Add a way to import GPG keys ***
In fedora, if you add a signed repo you have to agree to the GPG key.
diff --git a/src/pk-engine.c b/src/pk-engine.c
index bfc2e99..063a62c 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -499,12 +499,19 @@ pk_engine_add_task (PkEngine *engine, Pk
/* get all the data we know */
item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
- /* add to database */
- pk_transaction_db_add (engine->priv->transaction_db, item->tid);
-
- /* save role in the database */
+ /* only save into the database for useful stuff */
pk_backend_get_role (task, &role, NULL);
- pk_transaction_db_set_role (engine->priv->transaction_db, item->tid, role);
+ if (role == PK_ROLE_ENUM_REFRESH_CACHE ||
+ role == PK_ROLE_ENUM_SYSTEM_UPDATE ||
+ role == PK_ROLE_ENUM_PACKAGE_REMOVE ||
+ role == PK_ROLE_ENUM_PACKAGE_INSTALL ||
+ role == PK_ROLE_ENUM_PACKAGE_UPDATE) {
+ /* add to database */
+ pk_transaction_db_add (engine->priv->transaction_db, item->tid);
+
+ /* save role in the database */
+ pk_transaction_db_set_role (engine->priv->transaction_db, item->tid, role);
+ }
return TRUE;
}
diff-tree a15c34731dd0c233903d237c748e77da3abaa39e (from e8eaf601901a78ee532eaacaa7e3db4a13a46719)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 23:50:07 2007 +0100
only allow parallel queries when we are not refreshing the cache
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index 3cc49d0..1e0df43 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -199,6 +199,7 @@ gboolean
pk_transaction_list_commit (PkTransactionList *tlist, PkBackend *backend)
{
PkRoleEnum role;
+ gboolean search_okay = TRUE;
PkTransactionItem *item;
g_return_val_if_fail (tlist != NULL, FALSE);
g_return_val_if_fail (PK_IS_JOB_LIST (tlist), FALSE);
@@ -218,16 +219,24 @@ pk_transaction_list_commit (PkTransactio
g_signal_connect (backend, "finished",
G_CALLBACK (pk_transaction_list_backend_finished_cb), tlist);
- /* if it's a query then just do the action (it's always safe) */
- pk_backend_get_role (backend, &role, NULL);
- if (role == PK_ROLE_ENUM_SEARCH_NAME ||
- role == PK_ROLE_ENUM_SEARCH_FILE ||
- role == PK_ROLE_ENUM_SEARCH_GROUP ||
- role == PK_ROLE_ENUM_SEARCH_DETAILS) {
- pk_debug ("running %s", item->tid);
- item->running = TRUE;
- pk_backend_run (backend);
- return TRUE;
+ /* if we are refreshing the cache then nothing is sacred */
+ if (pk_transaction_list_role_present (tlist, PK_ROLE_ENUM_REFRESH_CACHE) == TRUE) {
+ search_okay = FALSE;
+ /* TODO: other backends might be different, need to abstract */
+ }
+
+ /* if it's a query then just do the action (if safe) */
+ if (search_okay == TRUE) {
+ pk_backend_get_role (backend, &role, NULL);
+ if (role == PK_ROLE_ENUM_SEARCH_NAME ||
+ role == PK_ROLE_ENUM_SEARCH_FILE ||
+ role == PK_ROLE_ENUM_SEARCH_GROUP ||
+ role == PK_ROLE_ENUM_SEARCH_DETAILS) {
+ pk_debug ("running %s", item->tid);
+ item->running = TRUE;
+ pk_backend_run (backend);
+ return TRUE;
+ }
}
/* do the transaction now if we have no other in progress */
diff-tree e8eaf601901a78ee532eaacaa7e3db4a13a46719 (from 3707b859eb2c0ab209788aacd3eb264699022d77)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 23:44:59 2007 +0100
only run a task if it's not been run and committed. should fix queing
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index 6917435..3cc49d0 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -102,6 +102,7 @@ pk_transaction_list_add (PkTransactionLi
/* add to the array */
item = g_new0 (PkTransactionItem, 1);
item->committed = FALSE;
+ item->running = FALSE;
item->backend = backend;
item->tid = pk_transaction_id_generate ();
g_ptr_array_add (tlist->priv->array, item);
@@ -157,7 +158,9 @@ pk_transaction_list_backend_finished_cb
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) {
+ if (item->committed == TRUE && item->running == FALSE) {
+ pk_debug ("running %s", item->tid);
+ item->running = TRUE;
pk_backend_run (item->backend);
break;
}
@@ -165,10 +168,10 @@ pk_transaction_list_backend_finished_cb
}
/**
- * pk_transaction_list_number_committed:
+ * pk_transaction_list_number_running:
**/
static guint
-pk_transaction_list_number_committed (PkTransactionList *tlist)
+pk_transaction_list_number_running (PkTransactionList *tlist)
{
guint i;
guint count = 0;
@@ -182,7 +185,7 @@ pk_transaction_list_number_committed (Pk
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) {
+ if (item->committed == TRUE && item->running == TRUE) {
count++;
}
}
@@ -221,12 +224,16 @@ pk_transaction_list_commit (PkTransactio
role == PK_ROLE_ENUM_SEARCH_FILE ||
role == PK_ROLE_ENUM_SEARCH_GROUP ||
role == PK_ROLE_ENUM_SEARCH_DETAILS) {
+ pk_debug ("running %s", item->tid);
+ item->running = TRUE;
pk_backend_run (backend);
return TRUE;
}
/* do the transaction now if we have no other in progress */
- if (pk_transaction_list_number_committed (tlist) == 0) {
+ if (pk_transaction_list_number_running (tlist) == 0) {
+ pk_debug ("running %s", item->tid);
+ item->running = TRUE;
pk_backend_run (backend);
}
diff --git a/src/pk-transaction-list.h b/src/pk-transaction-list.h
index d486fb6..93159ca 100644
--- a/src/pk-transaction-list.h
+++ b/src/pk-transaction-list.h
@@ -51,6 +51,7 @@ typedef struct
typedef struct {
gboolean committed;
+ gboolean running;
PkBackend *backend;
gchar *tid;
} PkTransactionItem;
diff-tree 3707b859eb2c0ab209788aacd3eb264699022d77 (from 7778e0e3d3193f7aeec3d6c307f304346794a018)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 23:30:28 2007 +0100
do the queuing. there's a bug somewhere but the basics are in place
diff --git a/src/pk-backend.c b/src/pk-backend.c
index c047a6a..b4c81e7 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -574,7 +574,7 @@ pk_backend_set_role (PkBackend *backend,
pk_debug ("setting role to %s", pk_role_enum_to_text (role));
backend->priv->assigned = TRUE;
backend->priv->role = role;
- backend->priv->status = PK_STATUS_ENUM_SETUP;
+ backend->priv->status = PK_STATUS_ENUM_WAIT;
return TRUE;
}
@@ -890,6 +890,11 @@ gboolean
pk_backend_run (PkBackend *backend)
{
g_return_val_if_fail (backend != NULL, FALSE);
+
+ /* we are no longer waiting, we are setting up */
+ backend->priv->status = PK_STATUS_ENUM_SETUP;
+
+ /* do the correct action with the cached parameters */
if (backend->priv->role == PK_ROLE_ENUM_GET_DEPENDS) {
backend->desc->get_depends (backend,
backend->priv->xcached_package_id);
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 15d096e..bfc2e99 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -151,22 +151,21 @@ pk_engine_reset_timer (PkEngine *engine)
}
/**
- * pk_engine_job_list_changed:
+ * pk_engine_transaction_list_changed_cb:
**/
-static gboolean
-pk_engine_job_list_changed (PkEngine *engine)
+static void
+pk_engine_transaction_list_changed_cb (PkTransactionList *tlist, PkEngine *engine)
{
gchar **job_list;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
job_list = pk_transaction_list_get_array (engine->priv->job_list);
pk_debug ("emitting job-list-changed");
g_signal_emit (engine, signals [PK_ENGINE_JOB_LIST_CHANGED], 0, job_list);
pk_engine_reset_timer (engine);
- return TRUE;
}
/**
@@ -402,12 +401,8 @@ pk_engine_finished_cb (PkTask *task, PkE
pk_debug ("emitting finished job:%s, '%s', %i", item->tid, exit_text, (guint) time);
g_signal_emit (engine, signals [PK_ENGINE_FINISHED], 0, item->tid, exit_text, (guint) time);
- /* remove from array and unref */
- pk_transaction_list_remove (engine->priv->job_list, task);
-
+ /* unref */
g_object_unref (task);
- pk_debug ("removed task %p", task);
- pk_engine_job_list_changed (engine);
pk_engine_reset_timer (engine);
}
@@ -501,9 +496,6 @@ pk_engine_add_task (PkEngine *engine, Pk
/* commit, so it appears in the JobList */
pk_transaction_list_commit (engine->priv->job_list, task);
- /* do the transaction now. TODO: schedule!!! */
- pk_backend_run (task);
-
/* get all the data we know */
item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
@@ -513,9 +505,6 @@ pk_engine_add_task (PkEngine *engine, Pk
/* save role in the database */
pk_backend_get_role (task, &role, NULL);
pk_transaction_db_set_role (engine->priv->transaction_db, item->tid, role);
-
- /* emit a signal */
- pk_engine_job_list_changed (engine);
return TRUE;
}
@@ -1659,10 +1648,13 @@ pk_engine_init (PkEngine *engine)
PolKitError *pk_error;
engine->priv = PK_ENGINE_GET_PRIVATE (engine);
- engine->priv->job_list = pk_transaction_list_new ();
engine->priv->timer = g_timer_new ();
engine->priv->backend = NULL;
+ engine->priv->job_list = pk_transaction_list_new ();
+ g_signal_connect (engine->priv->job_list, "changed",
+ G_CALLBACK (pk_engine_transaction_list_changed_cb), engine);
+
/* we use a trasaction db to store old transactions and to do rollbacks */
engine->priv->transaction_db = pk_transaction_db_new ();
g_signal_connect (engine->priv->transaction_db, "transaction",
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index 9b8f5ac..6917435 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -101,7 +101,7 @@ pk_transaction_list_add (PkTransactionLi
/* add to the array */
item = g_new0 (PkTransactionItem, 1);
- item->valid = FALSE;
+ item->committed = FALSE;
item->backend = backend;
item->tid = pk_transaction_id_generate ();
g_ptr_array_add (tlist->priv->array, item);
@@ -125,15 +125,77 @@ pk_transaction_list_remove (PkTransactio
g_ptr_array_remove (tlist->priv->array, 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;
}
/**
+ * pk_transaction_list_backend_finished_cb:
+ **/
+static void
+pk_transaction_list_backend_finished_cb (PkBackend *backend, PkExitEnum exit, PkTransactionList *tlist)
+{
+ guint i;
+ guint length;
+ PkTransactionItem *item;
+
+ g_return_if_fail (tlist != NULL);
+ g_return_if_fail (PK_IS_JOB_LIST (tlist));
+
+ item = pk_transaction_list_get_item_from_task (tlist, backend);
+ if (item == NULL) {
+ pk_error ("moo!");
+ }
+ pk_debug ("job %s completed, removing", item->tid);
+ pk_transaction_list_remove (tlist, backend);
+
+ /* 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) {
+ pk_backend_run (item->backend);
+ break;
+ }
+ }
+}
+
+/**
+ * pk_transaction_list_number_committed:
+ **/
+static guint
+pk_transaction_list_number_committed (PkTransactionList *tlist)
+{
+ guint i;
+ guint count = 0;
+ guint length;
+ PkTransactionItem *item;
+
+ g_return_val_if_fail (tlist != NULL, 0);
+ g_return_val_if_fail (PK_IS_JOB_LIST (tlist), 0);
+
+ /* find all the jobs in progress */
+ 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) {
+ count++;
+ }
+ }
+ return count;
+}
+
+/**
* pk_transaction_list_commit:
**/
gboolean
pk_transaction_list_commit (PkTransactionList *tlist, PkBackend *backend)
{
+ PkRoleEnum role;
PkTransactionItem *item;
g_return_val_if_fail (tlist != NULL, FALSE);
g_return_val_if_fail (PK_IS_JOB_LIST (tlist), FALSE);
@@ -142,8 +204,32 @@ pk_transaction_list_commit (PkTransactio
if (item == NULL) {
return FALSE;
}
- pk_debug ("marking job %s as valid", item->tid);
- item->valid = TRUE;
+ pk_debug ("marking job %s as committed", item->tid);
+ item->committed = TRUE;
+
+ /* we will changed what is running */
+ pk_debug ("emmitting ::changed");
+ g_signal_emit (tlist, signals [PK_TRANSACTION_LIST_CHANGED], 0);
+
+ /* connect up finished so we can start the next task */
+ g_signal_connect (backend, "finished",
+ G_CALLBACK (pk_transaction_list_backend_finished_cb), tlist);
+
+ /* if it's a query then just do the action (it's always safe) */
+ pk_backend_get_role (backend, &role, NULL);
+ if (role == PK_ROLE_ENUM_SEARCH_NAME ||
+ role == PK_ROLE_ENUM_SEARCH_FILE ||
+ role == PK_ROLE_ENUM_SEARCH_GROUP ||
+ role == PK_ROLE_ENUM_SEARCH_DETAILS) {
+ pk_backend_run (backend);
+ return TRUE;
+ }
+
+ /* do the transaction now if we have no other in progress */
+ if (pk_transaction_list_number_committed (tlist) == 0) {
+ pk_backend_run (backend);
+ }
+
return TRUE;
}
@@ -172,7 +258,7 @@ pk_transaction_list_get_array (PkTransac
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->valid == TRUE) {
+ if (item->committed == TRUE) {
array[count] = g_strdup (item->tid);
count++;
}
diff --git a/src/pk-transaction-list.h b/src/pk-transaction-list.h
index 6fb2bd6..d486fb6 100644
--- a/src/pk-transaction-list.h
+++ b/src/pk-transaction-list.h
@@ -50,7 +50,7 @@ typedef struct
} PkTransactionListClass;
typedef struct {
- gboolean valid;
+ gboolean committed;
PkBackend *backend;
gchar *tid;
} PkTransactionItem;
diff-tree 7778e0e3d3193f7aeec3d6c307f304346794a018 (from 0350660a5b04e1f5c499bea670d75a9e1f0ccd6c)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 22:36:51 2007 +0100
make some of the internal names more sane
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 37160d1..15d096e 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -1301,7 +1301,7 @@ pk_engine_get_status (PkEngine *engine,
"No tid:%s", tid);
return FALSE;
}
- pk_backend_get_status (item->task, &status_enum);
+ pk_backend_get_status (item->backend, &status_enum);
*status = g_strdup (pk_status_enum_to_text (status_enum));
return TRUE;
@@ -1326,7 +1326,7 @@ pk_engine_get_role (PkEngine *engine, co
"No tid:%s", tid);
return FALSE;
}
- pk_backend_get_role (item->task, &role_enum, package_id);
+ pk_backend_get_role (item->backend, &role_enum, package_id);
*role = g_strdup (pk_role_enum_to_text (role_enum));
return TRUE;
@@ -1350,7 +1350,7 @@ pk_engine_get_percentage (PkEngine *engi
"No tid:%s", tid);
return FALSE;
}
- ret = pk_backend_get_percentage (item->task, percentage);
+ ret = pk_backend_get_percentage (item->backend, percentage);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INVALID_STATE,
"No percentage data available");
@@ -1377,7 +1377,7 @@ pk_engine_get_sub_percentage (PkEngine *
"No tid:%s", tid);
return FALSE;
}
- ret = pk_backend_get_sub_percentage (item->task, percentage);
+ ret = pk_backend_get_sub_percentage (item->backend, percentage);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INVALID_STATE,
"No sub-percentage data available");
@@ -1404,7 +1404,7 @@ pk_engine_get_package (PkEngine *engine,
"No tid:%s", tid);
return FALSE;
}
- ret = pk_backend_get_package (item->task, package);
+ ret = pk_backend_get_package (item->backend, package);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INVALID_STATE,
"No package data available");
@@ -1445,7 +1445,7 @@ pk_engine_cancel (PkEngine *engine, cons
return FALSE;
}
- ret = pk_backend_cancel (item->task);
+ ret = pk_backend_cancel (item->backend);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index 196227b..9b8f5ac 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -40,7 +40,7 @@
#include "pk-transaction-list.h"
static void pk_transaction_list_class_init (PkTransactionListClass *klass);
-static void pk_transaction_list_init (PkTransactionList *job_list);
+static void pk_transaction_list_init (PkTransactionList *tlist);
static void pk_transaction_list_finalize (GObject *object);
#define PK_TRANSACTION_LIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_JOB_LIST, PkTransactionListPrivate))
@@ -66,21 +66,21 @@ G_DEFINE_TYPE (PkTransactionList, pk_tra
* multiple system updates queued
**/
gboolean
-pk_transaction_list_role_present (PkTransactionList *job_list, PkRoleEnum role)
+pk_transaction_list_role_present (PkTransactionList *tlist, PkRoleEnum role)
{
guint i;
guint length;
PkRoleEnum role_temp;
PkTransactionItem *item;
- g_return_val_if_fail (job_list != NULL, FALSE);
- g_return_val_if_fail (PK_IS_JOB_LIST (job_list), FALSE);
+ g_return_val_if_fail (tlist != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_JOB_LIST (tlist), FALSE);
/* check for existing job doing an update */
- length = job_list->priv->array->len;
+ length = tlist->priv->array->len;
for (i=0; i<length; i++) {
- item = (PkTransactionItem *) g_ptr_array_index (job_list->priv->array, i);
- pk_backend_get_role (item->task, &role_temp, NULL);
+ item = (PkTransactionItem *) g_ptr_array_index (tlist->priv->array, i);
+ pk_backend_get_role (item->backend, &role_temp, NULL);
if (role_temp == role) {
return TRUE;
}
@@ -92,19 +92,19 @@ pk_transaction_list_role_present (PkTran
* pk_transaction_list_add:
**/
PkTransactionItem *
-pk_transaction_list_add (PkTransactionList *job_list, PkTask *task)
+pk_transaction_list_add (PkTransactionList *tlist, PkBackend *backend)
{
PkTransactionItem *item;
- g_return_val_if_fail (job_list != NULL, NULL);
- g_return_val_if_fail (PK_IS_JOB_LIST (job_list), NULL);
+ g_return_val_if_fail (tlist != NULL, NULL);
+ g_return_val_if_fail (PK_IS_JOB_LIST (tlist), NULL);
/* add to the array */
item = g_new0 (PkTransactionItem, 1);
item->valid = FALSE;
- item->task = task;
+ item->backend = backend;
item->tid = pk_transaction_id_generate ();
- g_ptr_array_add (job_list->priv->array, item);
+ g_ptr_array_add (tlist->priv->array, item);
return item;
}
@@ -112,17 +112,17 @@ pk_transaction_list_add (PkTransactionLi
* pk_transaction_list_remove:
**/
gboolean
-pk_transaction_list_remove (PkTransactionList *job_list, PkTask *task)
+pk_transaction_list_remove (PkTransactionList *tlist, PkBackend *backend)
{
PkTransactionItem *item;
- g_return_val_if_fail (job_list != NULL, FALSE);
- g_return_val_if_fail (PK_IS_JOB_LIST (job_list), FALSE);
+ g_return_val_if_fail (tlist != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_JOB_LIST (tlist), FALSE);
- item = pk_transaction_list_get_item_from_task (job_list, task);
+ item = pk_transaction_list_get_item_from_task (tlist, backend);
if (item == NULL) {
return FALSE;
}
- g_ptr_array_remove (job_list->priv->array, item);
+ g_ptr_array_remove (tlist->priv->array, item);
g_free (item->tid);
g_free (item);
return TRUE;
@@ -132,13 +132,13 @@ pk_transaction_list_remove (PkTransactio
* pk_transaction_list_commit:
**/
gboolean
-pk_transaction_list_commit (PkTransactionList *job_list, PkTask *task)
+pk_transaction_list_commit (PkTransactionList *tlist, PkBackend *backend)
{
PkTransactionItem *item;
- g_return_val_if_fail (job_list != NULL, FALSE);
- g_return_val_if_fail (PK_IS_JOB_LIST (job_list), FALSE);
+ g_return_val_if_fail (tlist != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_JOB_LIST (tlist), FALSE);
- item = pk_transaction_list_get_item_from_task (job_list, task);
+ item = pk_transaction_list_get_item_from_task (tlist, backend);
if (item == NULL) {
return FALSE;
}
@@ -151,7 +151,7 @@ pk_transaction_list_commit (PkTransactio
* pk_transaction_list_get_array:
**/
gchar **
-pk_transaction_list_get_array (PkTransactionList *job_list)
+pk_transaction_list_get_array (PkTransactionList *tlist)
{
guint i;
guint count = 0;
@@ -159,18 +159,18 @@ pk_transaction_list_get_array (PkTransac
gchar **array;
PkTransactionItem *item;
- g_return_val_if_fail (job_list != NULL, NULL);
- g_return_val_if_fail (PK_IS_JOB_LIST (job_list), NULL);
+ g_return_val_if_fail (tlist != NULL, NULL);
+ g_return_val_if_fail (PK_IS_JOB_LIST (tlist), NULL);
/* find all the jobs in progress */
- length = job_list->priv->array->len;
+ length = tlist->priv->array->len;
/* create new strv list */
array = g_new0 (gchar *, length);
pk_debug ("%i active jobs", length);
for (i=0; i<length; i++) {
- item = (PkTransactionItem *) g_ptr_array_index (job_list->priv->array, i);
+ item = (PkTransactionItem *) g_ptr_array_index (tlist->priv->array, i);
/* only return in the list if it worked */
if (item->valid == TRUE) {
array[count] = g_strdup (item->tid);
@@ -184,30 +184,30 @@ pk_transaction_list_get_array (PkTransac
* pk_transaction_list_get_size:
**/
guint
-pk_transaction_list_get_size (PkTransactionList *job_list)
+pk_transaction_list_get_size (PkTransactionList *tlist)
{
- g_return_val_if_fail (job_list != NULL, 0);
- g_return_val_if_fail (PK_IS_JOB_LIST (job_list), 0);
- return job_list->priv->array->len;
+ g_return_val_if_fail (tlist != NULL, 0);
+ g_return_val_if_fail (PK_IS_JOB_LIST (tlist), 0);
+ return tlist->priv->array->len;
}
/**
* pk_transaction_list_get_item_from_tid:
**/
PkTransactionItem *
-pk_transaction_list_get_item_from_tid (PkTransactionList *job_list, const gchar *tid)
+pk_transaction_list_get_item_from_tid (PkTransactionList *tlist, const gchar *tid)
{
guint i;
guint length;
PkTransactionItem *item;
- g_return_val_if_fail (job_list != NULL, NULL);
- g_return_val_if_fail (PK_IS_JOB_LIST (job_list), NULL);
+ g_return_val_if_fail (tlist != NULL, NULL);
+ g_return_val_if_fail (PK_IS_JOB_LIST (tlist), NULL);
- /* find the task with the job ID */
- length = job_list->priv->array->len;
+ /* find the backend with the job ID */
+ length = tlist->priv->array->len;
for (i=0; i<length; i++) {
- item = (PkTransactionItem *) g_ptr_array_index (job_list->priv->array, i);
+ item = (PkTransactionItem *) g_ptr_array_index (tlist->priv->array, i);
if (pk_transaction_id_equal (item->tid, tid)) {
return item;
}
@@ -219,20 +219,20 @@ pk_transaction_list_get_item_from_tid (P
* pk_transaction_list_get_item_from_task:
**/
PkTransactionItem *
-pk_transaction_list_get_item_from_task (PkTransactionList *job_list, PkTask *task)
+pk_transaction_list_get_item_from_task (PkTransactionList *tlist, PkBackend *backend)
{
guint i;
guint length;
PkTransactionItem *item;
- g_return_val_if_fail (job_list != NULL, NULL);
- g_return_val_if_fail (PK_IS_JOB_LIST (job_list), NULL);
+ g_return_val_if_fail (tlist != NULL, NULL);
+ g_return_val_if_fail (PK_IS_JOB_LIST (tlist), NULL);
- /* find the task with the job ID */
- length = job_list->priv->array->len;
+ /* find the backend with the job ID */
+ length = tlist->priv->array->len;
for (i=0; i<length; i++) {
- item = (PkTransactionItem *) g_ptr_array_index (job_list->priv->array, i);
- if (item->task == task) {
+ item = (PkTransactionItem *) g_ptr_array_index (tlist->priv->array, i);
+ if (item->backend == backend) {
return item;
}
}
@@ -261,13 +261,13 @@ pk_transaction_list_class_init (PkTransa
/**
* pk_transaction_list_init:
- * @job_list: This class instance
+ * @tlist: This class instance
**/
static void
-pk_transaction_list_init (PkTransactionList *job_list)
+pk_transaction_list_init (PkTransactionList *tlist)
{
- job_list->priv = PK_TRANSACTION_LIST_GET_PRIVATE (job_list);
- job_list->priv->array = g_ptr_array_new ();
+ tlist->priv = PK_TRANSACTION_LIST_GET_PRIVATE (tlist);
+ tlist->priv->array = g_ptr_array_new ();
}
/**
@@ -277,16 +277,16 @@ pk_transaction_list_init (PkTransactionL
static void
pk_transaction_list_finalize (GObject *object)
{
- PkTransactionList *job_list;
+ PkTransactionList *tlist;
g_return_if_fail (object != NULL);
g_return_if_fail (PK_IS_JOB_LIST (object));
- job_list = PK_TRANSACTION_LIST (object);
+ tlist = PK_TRANSACTION_LIST (object);
- g_return_if_fail (job_list->priv != NULL);
+ g_return_if_fail (tlist->priv != NULL);
- g_ptr_array_free (job_list->priv->array, TRUE);
+ g_ptr_array_free (tlist->priv->array, TRUE);
G_OBJECT_CLASS (pk_transaction_list_parent_class)->finalize (object);
}
@@ -298,9 +298,9 @@ pk_transaction_list_finalize (GObject *o
PkTransactionList *
pk_transaction_list_new (void)
{
- PkTransactionList *job_list;
- job_list = g_object_new (PK_TYPE_JOB_LIST, NULL);
- return PK_TRANSACTION_LIST (job_list);
+ PkTransactionList *tlist;
+ tlist = g_object_new (PK_TYPE_JOB_LIST, NULL);
+ return PK_TRANSACTION_LIST (tlist);
}
/***************************************************************************
@@ -312,14 +312,14 @@ pk_transaction_list_new (void)
void
libst_transaction_list (LibSelfTest *test)
{
- PkTransactionList *job_list;
+ PkTransactionList *tlist;
gchar *tid;
if (libst_start (test, "PkTransactionList", CLASS_AUTO) == FALSE) {
return;
}
- job_list = pk_transaction_list_new ();
+ tlist = pk_transaction_list_new ();
/************************************************************/
libst_title (test, "make sure we get a valid tid");
@@ -331,7 +331,7 @@ libst_transaction_list (LibSelfTest *tes
}
g_free (tid);
- g_object_unref (job_list);
+ g_object_unref (tlist);
libst_end (test);
}
diff --git a/src/pk-transaction-list.h b/src/pk-transaction-list.h
index 83c69d5..6fb2bd6 100644
--- a/src/pk-transaction-list.h
+++ b/src/pk-transaction-list.h
@@ -50,28 +50,28 @@ typedef struct
} PkTransactionListClass;
typedef struct {
- gboolean valid;
- PkTask *task;
- gchar *tid;
+ gboolean valid;
+ PkBackend *backend;
+ gchar *tid;
} PkTransactionItem;
GType pk_transaction_list_get_type (void);
PkTransactionList *pk_transaction_list_new (void);
-PkTransactionItem *pk_transaction_list_add (PkTransactionList *job_list,
- PkTask *task);
-gboolean pk_transaction_list_remove (PkTransactionList *job_list,
- PkTask *task);
-gboolean pk_transaction_list_commit (PkTransactionList *job_list,
- PkTask *task);
-gboolean pk_transaction_list_role_present (PkTransactionList *job_list,
- PkRoleEnum role);
-gchar **pk_transaction_list_get_array (PkTransactionList *job_list);
-guint pk_transaction_list_get_size (PkTransactionList *job_list);
-PkTransactionItem *pk_transaction_list_get_item_from_tid(PkTransactionList *job_list,
- const gchar *tid);
-PkTransactionItem *pk_transaction_list_get_item_from_task(PkTransactionList *job_list,
- PkTask *task);
+PkTransactionItem *pk_transaction_list_add (PkTransactionList *tlist,
+ PkBackend *backend);
+gboolean pk_transaction_list_remove (PkTransactionList *tlist,
+ PkBackend *backend);
+gboolean pk_transaction_list_commit (PkTransactionList *tlist,
+ PkBackend *backend);
+gboolean pk_transaction_list_role_present (PkTransactionList *tlist,
+ PkRoleEnum role);
+gchar **pk_transaction_list_get_array (PkTransactionList *tlist);
+guint pk_transaction_list_get_size (PkTransactionList *tlist);
+PkTransactionItem *pk_transaction_list_get_item_from_tid(PkTransactionList *tlist,
+ const gchar *tid);
+PkTransactionItem *pk_transaction_list_get_item_from_task(PkTransactionList *tlist,
+ PkBackend *backend);
G_END_DECLS
diff-tree 0350660a5b04e1f5c499bea670d75a9e1f0ccd6c (from e05e83e82bbb206f9274554df563062241c2501b)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 22:29:54 2007 +0100
abstract out the transaction_id stuff better
diff --git a/src/Makefile.am b/src/Makefile.am
index 1acef5e..e1c00b4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -58,6 +58,8 @@ packagekitd_SOURCES = \
pk-thread-list.c \
pk-transaction-db.h \
pk-transaction-db.c \
+ pk-transaction-id.h \
+ pk-transaction-id.c \
pk-transaction-list.c \
pk-transaction-list.h \
$(NULL)
@@ -118,6 +120,8 @@ pk_self_test_SOURCES = \
pk-network.c \
pk-thread-list.h \
pk-thread-list.c \
+ pk-transaction-id.h \
+ pk-transaction-id.c \
pk-transaction-list.h \
pk-transaction-list.c \
pk-self-test.c \
diff --git a/src/pk-transaction-id.c b/src/pk-transaction-id.c
new file mode 100644
index 0000000..ee20b4e
--- /dev/null
+++ b/src/pk-transaction-id.c
@@ -0,0 +1,165 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.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 identifier 2 of the License, or
+ * (at your option) any later identifier.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <glib/gi18n.h>
+
+#include "pk-debug.h"
+#include "pk-transaction-id.h"
+#define PK_TRANSACTION_ID_COUNT_FILE LOCALSTATEDIR "/run/PackageKit/job_count.dat"
+
+/**
+ * pk_transaction_id_get_random_hex_string:
+ **/
+static gchar *
+pk_transaction_id_get_random_hex_string (guint length)
+{
+ GRand *rand;
+ gint32 num;
+ gchar *string;
+ guint i;
+
+ rand = g_rand_new ();
+
+ /* allocate a string with the correct size */
+ string = g_strnfill (length, 'x');
+ for (i=0; i<length; i++) {
+ num = g_rand_int_range (rand, (gint32) 'a', (gint32) 'f');
+ /* assign a random number as a char */
+ string[i] = (gchar) num;
+ }
+ g_rand_free (rand);
+ return string;
+}
+
+/**
+ * pk_transaction_id_load_job_count:
+ **/
+static guint
+pk_transaction_id_load_job_count (void)
+{
+ gboolean ret;
+ gchar *contents;
+ guint job_count;
+ ret = g_file_get_contents (PK_TRANSACTION_ID_COUNT_FILE, &contents, NULL, NULL);
+ if (ret == FALSE) {
+ pk_warning ("failed to get last job");
+ return FALSE;
+ }
+ job_count = atoi (contents);
+ pk_debug ("job=%i", job_count);
+ g_free (contents);
+ return job_count;
+}
+
+/**
+ * pk_transaction_id_save_job_count:
+ **/
+static gboolean
+pk_transaction_id_save_job_count (guint job_count)
+{
+ gboolean ret;
+ gchar *contents;
+
+ pk_debug ("saving %i", job_count);
+ contents = g_strdup_printf ("%i", job_count);
+ ret = g_file_set_contents (PK_TRANSACTION_ID_COUNT_FILE, contents, -1, NULL);
+ g_free (contents);
+ if (ret == FALSE) {
+ pk_warning ("failed to set last job");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * pk_transaction_id_equal:
+ * TODO: only compare first two sections...
+ **/
+gboolean
+pk_transaction_id_equal (const gchar *tid1, const gchar *tid2)
+{
+ return (strcmp (tid1, tid2) == 0);
+}
+
+/**
+ * pk_transaction_id_generate:
+ **/
+gchar *
+pk_transaction_id_generate (void)
+{
+ gchar *random;
+ gchar *job;
+ gchar *tid;
+ guint job_count;
+
+ /* load from file */
+ job_count = pk_transaction_id_load_job_count ();
+ random = pk_transaction_id_get_random_hex_string (8);
+ job = g_strdup_printf ("%i", job_count++);
+
+ /* save the new value */
+ pk_transaction_id_save_job_count (job_count);
+
+ /* make the tid */
+ tid = g_strjoin (";", job, random, "data", NULL);
+
+ g_free (random);
+ g_free (job);
+ return tid;
+}
+
+/***************************************************************************
+ *** MAKE CHECK TESTS ***
+ ***************************************************************************/
+#ifdef PK_BUILD_TESTS
+#include <libselftest.h>
+
+void
+libst_transaction_id (LibSelfTest *test)
+{
+ gchar *tid;
+
+ if (libst_start (test, "PkTransactionId", CLASS_AUTO) == FALSE) {
+ return;
+ }
+
+ /************************************************************
+ **************** IDENT ******************
+ ************************************************************/
+ libst_title (test, "get an tid object");
+ tid = pk_transaction_id_generate ();
+ if (tid != NULL) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, NULL);
+ }
+ g_free (tid);
+
+ libst_end (test);
+}
+#endif
+
diff --git a/src/pk-transaction-id.h b/src/pk-transaction-id.h
new file mode 100644
index 0000000..5e83d44
--- /dev/null
+++ b/src/pk-transaction-id.h
@@ -0,0 +1,34 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __PK_TRANSACTION_ID_H
+#define __PK_TRANSACTION_ID_H
+
+G_BEGIN_DECLS
+
+gchar *pk_transaction_id_generate (void);
+gboolean pk_transaction_id_check (const gchar *tid);
+gboolean pk_transaction_id_equal (const gchar *tid1,
+ const gchar *tid2);
+
+G_END_DECLS
+
+#endif /* __PK_TRANSACTION_ID_H */
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index 49d6a5a..196227b 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -36,6 +36,7 @@
#include <glib/gi18n.h>
#include "pk-debug.h"
+#include "pk-transaction-id.h"
#include "pk-transaction-list.h"
static void pk_transaction_list_class_init (PkTransactionListClass *klass);
@@ -43,12 +44,10 @@ static void pk_transaction_list_init
static void pk_transaction_list_finalize (GObject *object);
#define PK_TRANSACTION_LIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_JOB_LIST, PkTransactionListPrivate))
-#define PK_TRANSACTION_LIST_COUNT_FILE LOCALSTATEDIR "/run/PackageKit/job_count.dat"
struct PkTransactionListPrivate
{
GPtrArray *array;
- guint job_count;
};
enum {
@@ -61,45 +60,6 @@ static guint signals [PK_TRANSACTION_LIS
G_DEFINE_TYPE (PkTransactionList, pk_transaction_list, G_TYPE_OBJECT)
/**
- * pk_transaction_list_load_job_count:
- **/
-static gboolean
-pk_transaction_list_load_job_count (PkTransactionList *job_list)
-{
- gboolean ret;
- gchar *contents;
- ret = g_file_get_contents (PK_TRANSACTION_LIST_COUNT_FILE, &contents, NULL, NULL);
- if (ret == FALSE) {
- pk_warning ("failed to get last job");
- return FALSE;
- }
- job_list->priv->job_count = atoi (contents);
- pk_debug ("job=%i", job_list->priv->job_count);
- g_free (contents);
- return TRUE;
-}
-
-/**
- * pk_transaction_list_save_job_count:
- **/
-static gboolean
-pk_transaction_list_save_job_count (PkTransactionList *job_list)
-{
- gboolean ret;
- gchar *contents;
-
- pk_debug ("saving %i", job_list->priv->job_count);
- contents = g_strdup_printf ("%i", job_list->priv->job_count);
- ret = g_file_set_contents (PK_TRANSACTION_LIST_COUNT_FILE, contents, -1, NULL);
- g_free (contents);
- if (ret == FALSE) {
- pk_warning ("failed to set last job");
- return FALSE;
- }
- return TRUE;
-}
-
-/**
* pk_transaction_list_role_present:
*
* if there is a queued job with this role, useful to avoid having
@@ -129,47 +89,6 @@ pk_transaction_list_role_present (PkTran
}
/**
- * pk_transaction_list_tid_get_random_hex_string:
- **/
-static gchar *
-pk_transaction_list_tid_get_random_hex_string (guint length)
-{
- GRand *rand;
- gint32 num;
- gchar *string;
- guint i;
-
- rand = g_rand_new ();
-
- /* allocate a string with the correct size */
- string = g_strnfill (length, 'x');
- for (i=0; i<length; i++) {
- num = g_rand_int_range (rand, (gint32) 'a', (gint32) 'f');
- /* assign a random number as a char */
- string[i] = (gchar) num;
- }
- g_rand_free (rand);
- return string;
-}
-
-/**
- * pk_transaction_list_tid_id_generate:
- **/
-gchar *
-pk_transaction_list_tid_id_generate (void)
-{
- gchar *random;
- gchar *job;
- gchar *tid;
- random = pk_transaction_list_tid_get_random_hex_string (8);
- job = g_strdup_printf ("%i", 0);
- tid = g_strjoin (";", job, random, "data", NULL);
- g_free (random);
- g_free (job);
- return tid;
-}
-
-/**
* pk_transaction_list_add:
**/
PkTransactionItem *
@@ -180,19 +99,12 @@ pk_transaction_list_add (PkTransactionLi
g_return_val_if_fail (job_list != NULL, NULL);
g_return_val_if_fail (PK_IS_JOB_LIST (job_list), NULL);
- /* increment the job number - we never repeat an id */
- job_list->priv->job_count++;
-
/* add to the array */
item = g_new0 (PkTransactionItem, 1);
item->valid = FALSE;
item->task = task;
- item->job = job_list->priv->job_count;
- item->tid = pk_transaction_list_tid_id_generate ();
+ item->tid = pk_transaction_id_generate ();
g_ptr_array_add (job_list->priv->array, item);
-
- /* in an ideal world we don't need this, but do it in case the daemon is ctrl-c;d */
- pk_transaction_list_save_job_count (job_list);
return item;
}
@@ -280,16 +192,6 @@ pk_transaction_list_get_size (PkTransact
}
/**
- * pk_tid_equal:
- * TODO: only compare first two sections...
- **/
-static gboolean
-pk_tid_equal (const gchar *tid1, const gchar *tid2)
-{
- return (strcmp (tid1, tid2) == 0);
-}
-
-/**
* pk_transaction_list_get_item_from_tid:
**/
PkTransactionItem *
@@ -306,7 +208,7 @@ pk_transaction_list_get_item_from_tid (P
length = job_list->priv->array->len;
for (i=0; i<length; i++) {
item = (PkTransactionItem *) g_ptr_array_index (job_list->priv->array, i);
- if (pk_tid_equal (item->tid, tid)) {
+ if (pk_transaction_id_equal (item->tid, tid)) {
return item;
}
}
@@ -366,7 +268,6 @@ pk_transaction_list_init (PkTransactionL
{
job_list->priv = PK_TRANSACTION_LIST_GET_PRIVATE (job_list);
job_list->priv->array = g_ptr_array_new ();
- job_list->priv->job_count = pk_transaction_list_load_job_count (job_list);
}
/**
@@ -386,9 +287,6 @@ pk_transaction_list_finalize (GObject *o
g_return_if_fail (job_list->priv != NULL);
g_ptr_array_free (job_list->priv->array, TRUE);
- /* save last job id so we don't ever repeat */
- pk_transaction_list_save_job_count (job_list);
-
G_OBJECT_CLASS (pk_transaction_list_parent_class)->finalize (object);
}
@@ -425,7 +323,7 @@ libst_transaction_list (LibSelfTest *tes
/************************************************************/
libst_title (test, "make sure we get a valid tid");
- tid = pk_transaction_list_tid_id_generate ();
+ tid = pk_transaction_id_generate ();
if (tid != NULL) {
libst_success (test, "got tid %s", tid);
} else {
diff --git a/src/pk-transaction-list.h b/src/pk-transaction-list.h
index 056d8ea..83c69d5 100644
--- a/src/pk-transaction-list.h
+++ b/src/pk-transaction-list.h
@@ -50,7 +50,6 @@ typedef struct
} PkTransactionListClass;
typedef struct {
- guint job;
gboolean valid;
PkTask *task;
gchar *tid;
diff-tree e05e83e82bbb206f9274554df563062241c2501b (from 4fc2c59114eaa95c5c82f2fc48e47c1cea3502da)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 22:07:16 2007 +0100
make the api more consistent
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index e5ea7fc..95e6d30 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -551,7 +551,7 @@ backend_refresh_cache (PkBackend *backen
}*/
alpm_list_t *i = NULL;
- pk_backend_change_job_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
g_timeout_add (PROGRESS_UPDATE_INTERVAL, update_subprogress, backend);
for (i = dbs; i; i = alpm_list_next (i))
{
@@ -779,7 +779,7 @@ backend_update_system_timeout (gpointer
pk_backend_finished (backend);
return FALSE;
}
- pk_backend_change_job_status (backend, PK_STATUS_ENUM_UPDATE);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_UPDATE);
progress_percentage += 10;
pk_backend_change_percentage (backend, progress_percentage);
return TRUE;
@@ -792,7 +792,7 @@ static void
backend_update_system (PkBackend *backend)
{
g_return_if_fail (backend != NULL);
- pk_backend_change_job_status (backend, PK_STATUS_ENUM_DOWNLOAD);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_DOWNLOAD);
progress_percentage = 0;
pk_backend_require_restart (backend, PK_RESTART_ENUM_SYSTEM, NULL);
g_timeout_add (1000, backend_update_system_timeout, backend);
@@ -806,7 +806,7 @@ PK_BACKEND_OPTIONS (
backend_destroy, /* destroy */
NULL, /* get_groups */
NULL, /* get_filters */
- NULL, /* cancel_job_try */
+ NULL, /* cancel */
backend_get_depends, /* get_depends */
backend_get_description, /* get_description */
backend_get_requires, /* get_requires */
diff --git a/backends/apt/pk-backend-apt.cpp b/backends/apt/pk-backend-apt.cpp
index 0e65678..76d4b31 100644
--- a/backends/apt/pk-backend-apt.cpp
+++ b/backends/apt/pk-backend-apt.cpp
@@ -154,7 +154,7 @@ static gboolean backend_refresh_cache_th
OpTextProgress Prog;
/* easy as that */
- pk_backend_change_job_status(backend, PK_STATUS_ENUM_REFRESH_CACHE);
+ pk_backend_change_status(backend, PK_STATUS_ENUM_REFRESH_CACHE);
Cache = getCache();
@@ -362,7 +362,7 @@ static gboolean backend_search_packages_
search_task *st = (search_task *) data;
ExDescFile *DFList = NULL;
- pk_backend_change_job_status(backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_change_status(backend, PK_STATUS_ENUM_QUERY);
pk_backend_no_percentage_updates(backend);
pk_debug("finding %s", st->search);
@@ -544,7 +544,7 @@ static gboolean backend_get_description_
{
desc_task *dt = (desc_task *) data;
- pk_backend_change_job_status(backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_change_status(backend, PK_STATUS_ENUM_QUERY);
pk_backend_no_percentage_updates(backend);
pk_debug("finding %s", dt->pi->name);
@@ -654,7 +654,7 @@ extern "C" PK_BACKEND_OPTIONS (
NULL, /* destroy */
backend_get_groups, /* get_groups */
backend_get_filters, /* get_filters */
- NULL, /* cancel_job_try */
+ NULL, /* cancel */
NULL, /* get_depends */
backend_get_description, /* get_description */
NULL, /* get_requires */
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 7787eb9..59adc21 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -135,7 +135,7 @@ find_packages_real (PkBackend *backend,
g_return_if_fail (backend != NULL);
- pk_backend_change_job_status (backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
parse_filter (filter, &installed, &available, &devel, &nondevel, &gui, &text);
@@ -243,7 +243,7 @@ backend_get_updates_thread (PkBackend *b
GList *list = NULL;
sqlite3 *db = NULL;
- pk_backend_change_job_status (backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
db = db_open ();
@@ -269,7 +269,7 @@ backend_get_description_thread (PkBacken
return FALSE;
}
- pk_backend_change_job_status (backend, PK_STATUS_ENUM_QUERY);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
list = find_package_by_id (pi);
ps = (PackageSearch*) list->data;
if (list == NULL) {
@@ -395,7 +395,7 @@ backend_refresh_cache (PkBackend *backen
pk_backend_finished (backend);
return;
}
- pk_backend_change_job_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
pk_backend_spawn_helper (backend, "refresh-cache.sh", NULL);
}
@@ -471,7 +471,7 @@ PK_BACKEND_OPTIONS (
backend_destroy, /* destroy */
backend_get_groups, /* get_groups */
backend_get_filters, /* get_filters */
- NULL, /* cancel_job_try */
+ NULL, /* cancel */
NULL, /* get_depends */
backend_get_description, /* get_description */
NULL, /* get_requires */
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index 3fee64f..d1b42c9 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -153,7 +153,7 @@ PK_BACKEND_OPTIONS (
NULL, /* destroy */
backend_get_groups, /* get_groups */
backend_get_filters, /* get_filters */
- NULL, /* cancel_job_try */
+ NULL, /* cancel */
NULL, /* get_depends */
backend_get_description, /* get_description */
NULL, /* get_requires */
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index a3af3c5..1090f38 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -167,7 +167,7 @@ backend_install_timeout (gpointer data)
return FALSE;
}
if (progress_percentage == 50) {
- pk_backend_change_job_status (backend, PK_STATUS_ENUM_INSTALL);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_INSTALL);
}
progress_percentage += 10;
pk_backend_change_percentage (backend, progress_percentage);
@@ -291,7 +291,7 @@ backend_update_system_timeout (gpointer
pk_backend_finished (backend);
return FALSE;
}
- pk_backend_change_job_status (backend, PK_STATUS_ENUM_UPDATE);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_UPDATE);
progress_percentage += 10;
pk_backend_change_percentage (backend, progress_percentage);
return TRUE;
@@ -304,7 +304,7 @@ static void
backend_update_system (PkBackend *backend)
{
g_return_if_fail (backend != NULL);
- pk_backend_change_job_status (backend, PK_STATUS_ENUM_DOWNLOAD);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_DOWNLOAD);
progress_percentage = 0;
pk_backend_require_restart (backend, PK_RESTART_ENUM_SYSTEM, NULL);
g_timeout_add (1000, backend_update_system_timeout, backend);
@@ -318,7 +318,7 @@ PK_BACKEND_OPTIONS (
backend_destroy, /* destroy */
backend_get_groups, /* get_groups */
backend_get_filters, /* get_filters */
- backend_cancel, /* cancel_job_try */
+ backend_cancel, /* cancel */
backend_get_depends, /* get_depends */
backend_get_description, /* get_description */
backend_get_requires, /* get_requires */
diff --git a/backends/test/pk-backend-test-fail.c b/backends/test/pk-backend-test-fail.c
index 219ea92..063e8af 100644
--- a/backends/test/pk-backend-test-fail.c
+++ b/backends/test/pk-backend-test-fail.c
@@ -210,7 +210,7 @@ PK_BACKEND_OPTIONS (
NULL, /* destroy */
backend_get_groups, /* get_groups */
backend_get_filters, /* get_filters */
- backend_cancel, /* cancel_job_try */
+ backend_cancel, /* cancel */
backend_get_depends, /* get_depends */
backend_get_description, /* get_description */
backend_get_requires, /* get_requires */
diff --git a/backends/test/pk-backend-test-nop.c b/backends/test/pk-backend-test-nop.c
index 315592b..6774698 100644
--- a/backends/test/pk-backend-test-nop.c
+++ b/backends/test/pk-backend-test-nop.c
@@ -31,7 +31,7 @@ PK_BACKEND_OPTIONS (
NULL, /* destroy */
NULL, /* get_groups */
NULL, /* get_filters */
- NULL, /* cancel_job_try */
+ NULL, /* cancel */
NULL, /* get_depends */
NULL, /* get_description */
NULL, /* get_requires */
diff --git a/backends/test/pk-backend-test-spawn.c b/backends/test/pk-backend-test-spawn.c
index 3d852d1..4a9c098 100644
--- a/backends/test/pk-backend-test-spawn.c
+++ b/backends/test/pk-backend-test-spawn.c
@@ -44,7 +44,7 @@ PK_BACKEND_OPTIONS (
NULL, /* destroy */
NULL, /* get_groups */
NULL, /* get_filters */
- NULL, /* cancel_job_try */
+ NULL, /* cancel */
NULL, /* get_depends */
NULL, /* get_description */
NULL, /* get_requires */
diff --git a/backends/test/pk-backend-test-succeed.c b/backends/test/pk-backend-test-succeed.c
index 590da00..34904d6 100644
--- a/backends/test/pk-backend-test-succeed.c
+++ b/backends/test/pk-backend-test-succeed.c
@@ -242,7 +242,7 @@ PK_BACKEND_OPTIONS (
backend_destroy, /* destroy */
backend_get_groups, /* get_groups */
backend_get_filters, /* get_filters */
- backend_cancel, /* cancel_job_try */
+ backend_cancel, /* cancel */
backend_get_depends, /* get_depends */
backend_get_description, /* get_description */
backend_get_requires, /* get_requires */
diff --git a/backends/test/pk-backend-test-thread.c b/backends/test/pk-backend-test-thread.c
index b34cc58..2c4488f 100644
--- a/backends/test/pk-backend-test-thread.c
+++ b/backends/test/pk-backend-test-thread.c
@@ -91,7 +91,7 @@ PK_BACKEND_OPTIONS (
NULL, /* destroy */
NULL, /* get_groups */
NULL, /* get_filters */
- NULL, /* cancel_job_try */
+ NULL, /* cancel */
NULL, /* get_depends */
NULL, /* get_description */
NULL, /* get_requires */
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 6d13146..8e1a664 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -233,7 +233,7 @@ PK_BACKEND_OPTIONS (
NULL, /* destroy */
backend_get_groups, /* get_groups */
backend_get_filters, /* get_filters */
- backend_cancel, /* cancel_job_try */
+ backend_cancel, /* cancel */
backend_get_depends, /* get_depends */
backend_get_description, /* get_description */
backend_get_requires, /* get_requires */
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 2d3a126..3d1bca7 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -117,7 +117,7 @@ typedef enum {
PK_ACTION_ENUM_REMOVE,
PK_ACTION_ENUM_UPDATE,
PK_ACTION_ENUM_GET_UPDATES,
- PK_ACTION_ENUM_CANCEL_JOB,
+ PK_ACTION_ENUM_CANCEL,
PK_ACTION_ENUM_REFRESH_CACHE,
PK_ACTION_ENUM_UPDATE_SYSTEM,
PK_ACTION_ENUM_SEARCH_NAME,
diff --git a/src/pk-backend.c b/src/pk-backend.c
index aad12ea..c047a6a 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -331,7 +331,7 @@ pk_backend_parse_common_error (PkBackend
goto out;
}
status_enum = pk_status_enum_from_text (sections[1]);
- pk_backend_change_job_status (backend, status_enum);
+ pk_backend_change_status (backend, status_enum);
} else if (strcmp (command, "allow-interrupt") == 0) {
if (size != 2) {
g_error ("invalid command '%s'", command);
@@ -579,10 +579,10 @@ pk_backend_set_role (PkBackend *backend,
}
/**
- * pk_backend_change_job_status:
+ * pk_backend_change_status:
**/
gboolean
-pk_backend_change_job_status (PkBackend *backend, PkStatusEnum status)
+pk_backend_change_status (PkBackend *backend, PkStatusEnum status)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
@@ -861,7 +861,7 @@ gboolean
pk_backend_cancel (PkBackend *backend)
{
g_return_val_if_fail (backend != NULL, FALSE);
- if (backend->desc->cancel_job_try == NULL) {
+ if (backend->desc->cancel == NULL) {
pk_backend_not_implemented_yet (backend, "Cancel");
return FALSE;
}
@@ -879,7 +879,7 @@ pk_backend_cancel (PkBackend *backend)
pk_warning ("tried to kill a process that does not exist");
return FALSE;
}
- backend->desc->cancel_job_try (backend);
+ backend->desc->cancel (backend);
return TRUE;
}
@@ -1179,8 +1179,8 @@ pk_backend_get_actions (PkBackend *backe
PkEnumList *elist;
elist = pk_enum_list_new ();
pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
- if (backend->desc->cancel_job_try != NULL) {
- pk_enum_list_append (elist, PK_ACTION_ENUM_CANCEL_JOB);
+ if (backend->desc->cancel != NULL) {
+ pk_enum_list_append (elist, PK_ACTION_ENUM_CANCEL);
}
if (backend->desc->get_depends != NULL) {
pk_enum_list_append (elist, PK_ACTION_ENUM_GET_DEPENDS);
diff --git a/src/pk-backend.h b/src/pk-backend.h
index b449ce3..2b711d9 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -38,7 +38,7 @@ gboolean pk_backend_change_percentage
guint percentage);
gboolean pk_backend_change_sub_percentage (PkBackend *backend,
guint percentage);
-gboolean pk_backend_change_job_status (PkBackend *backend,
+gboolean pk_backend_change_status (PkBackend *backend,
PkStatusEnum status);
gboolean pk_backend_no_percentage_updates (PkBackend *backend);
gboolean pk_backend_finished (PkBackend *backend);
@@ -92,7 +92,7 @@ struct _PkBackendDesc {
void (*destroy) (PkBackend *backend);
void (*get_groups) (PkBackend *backend, PkEnumList *elist);
void (*get_filters) (PkBackend *backend, PkEnumList *elist);
- void (*cancel_job_try) (PkBackend *backend);
+ void (*cancel) (PkBackend *backend);
void (*get_depends) (PkBackend *backend, const gchar *package_id);
void (*get_description) (PkBackend *backend, const gchar *package_id);
void (*get_requires) (PkBackend *backend, const gchar *package_id);
@@ -112,7 +112,7 @@ struct _PkBackendDesc {
#define PK_BACKEND_OPTIONS(description, version, author, initialize, destroy, \
get_groups, get_filters, \
- cancel_job_try, get_depends, get_description, \
+ cancel, get_depends, get_description, \
get_requires, get_update_detail, get_updates, install_package, \
refresh_cache, remove_package, search_details, \
search_file, search_group, search_name, \
@@ -125,7 +125,7 @@ struct _PkBackendDesc {
destroy, \
get_groups, \
get_filters, \
- cancel_job_try, \
+ cancel, \
get_depends, \
get_description, \
get_requires, \
diff-tree 4fc2c59114eaa95c5c82f2fc48e47c1cea3502da (from 618521ce3a600fadf4a3a1bc59e7d77461da1807)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 21:35:32 2007 +0100
convert the job number to a transaction string. A big change, but it allows us to do some cool stuff. expect the daemon to leak and to crash for a few days. heh.
diff --git a/TODO b/TODO
index ad4508b..217403f 100644
--- a/TODO
+++ b/TODO
@@ -6,6 +6,10 @@ but write jobs are done in serial. Maybe
paused state?
NOTE: RELEASE BLOCKER
+*** API Changes ***
+s/GetJobList/GetActiveTransactions
+s/JobListChanged/ActiveTransactionsChanged
+
*** Have to have an UpdatesChanged signal ***
For the icon to update after we've done a system upgrade
NOTE: RELEASE BLOCKER
diff --git a/libpackagekit/pk-job-list.c b/libpackagekit/pk-job-list.c
index 27e4e8a..1fc2361 100644
--- a/libpackagekit/pk-job-list.c
+++ b/libpackagekit/pk-job-list.c
@@ -49,7 +49,7 @@ struct PkJobListPrivate
{
DBusGConnection *connection;
DBusGProxy *proxy;
- GArray *job_list;
+ gchar **array;
PkConnection *pconnection;
};
@@ -63,54 +63,28 @@ static guint signals [PK_JOB_LIST_LAST_S
G_DEFINE_TYPE (PkJobList, pk_job_list, G_TYPE_OBJECT)
/**
- * pk_job_list_refresh_array_with_data:
- **/
-gboolean
-pk_job_list_refresh_array_with_data (PkJobList *jlist, GPtrArray *ptrarray)
-{
- guint i;
- guint job;
-
- g_return_val_if_fail (jlist != NULL, FALSE);
- g_return_val_if_fail (PK_IS_JOB_LIST (jlist), FALSE);
-
- pk_debug ("ptrarray->len=%i", ptrarray->len);
-
- /* reset the array */
- g_array_set_size (jlist->priv->job_list, 0);
-
- for (i=0; i< ptrarray->len; i++) {
- job = GPOINTER_TO_UINT (g_ptr_array_index (ptrarray, i));
- pk_debug ("job[%i]=%i", i, job);
- g_array_append_val (jlist->priv->job_list, job);
- }
- return TRUE;
-}
-
-/**
* pk_job_list_print:
**/
gboolean
pk_job_list_print (PkJobList *jlist)
{
guint i;
- guint job;
+ gchar *tid;
guint length;
g_return_val_if_fail (jlist != NULL, FALSE);
g_return_val_if_fail (PK_IS_JOB_LIST (jlist), FALSE);
- length = jlist->priv->job_list->len;
+ length = g_strv_length (jlist->priv->array);
if (length == 0) {
g_print ("no jobs...\n");
return TRUE;
}
g_print ("jobs: ");
for (i=0; i<length; i++) {
- job = g_array_index (jlist->priv->job_list, guint, i);
- g_print ("%i, ", job);
+ tid = jlist->priv->array[i];
+ g_print ("%s\n", tid);
}
- g_print ("\n");
return TRUE;
}
@@ -124,17 +98,20 @@ pk_job_list_refresh (PkJobList *jlist)
{
gboolean ret;
GError *error;
- GPtrArray *ptrarray = NULL;
- GType g_type_ptrarray;
+ gchar **array;
g_return_val_if_fail (jlist != NULL, FALSE);
g_return_val_if_fail (PK_IS_JOB_LIST (jlist), FALSE);
+ /* clear old data */
+ if (jlist->priv->array != NULL) {
+ g_strfreev (jlist->priv->array);
+ jlist->priv->array = NULL;
+ }
error = NULL;
- g_type_ptrarray = dbus_g_type_get_collection ("GPtrArray", G_TYPE_UINT);
ret = dbus_g_proxy_call (jlist->priv->proxy, "GetJobList", &error,
G_TYPE_INVALID,
- g_type_ptrarray, &ptrarray,
+ G_TYPE_STRV, &array,
G_TYPE_INVALID);
if (error) {
pk_debug ("ERROR: %s", error->message);
@@ -143,24 +120,22 @@ pk_job_list_refresh (PkJobList *jlist)
if (ret == FALSE) {
/* abort as the DBUS method failed */
pk_warning ("GetJobList failed!");
+ jlist->priv->array = NULL;
return FALSE;
}
- pk_job_list_refresh_array_with_data (jlist, ptrarray);
- g_ptr_array_free (ptrarray, TRUE);
+ jlist->priv->array = g_strdupv (array);
return TRUE;
}
/**
* pk_job_list_get_latest:
- *
- * DO NOT FREE THIS.
**/
-GArray *
+const gchar **
pk_job_list_get_latest (PkJobList *jlist)
{
g_return_val_if_fail (jlist != NULL, FALSE);
g_return_val_if_fail (PK_IS_JOB_LIST (jlist), FALSE);
- return jlist->priv->job_list;
+ return (const gchar **) jlist->priv->array;
}
/**
@@ -168,13 +143,17 @@ pk_job_list_get_latest (PkJobList *jlist
*/
static void
pk_job_list_changed_cb (DBusGProxy *proxy,
- GPtrArray *job_list,
- PkJobList *jlist)
+ gchar **array,
+ PkJobList *jlist)
{
g_return_if_fail (jlist != NULL);
g_return_if_fail (PK_IS_JOB_LIST (jlist));
- pk_job_list_refresh_array_with_data (jlist, job_list);
+ /* clear old data */
+ if (jlist->priv->array != NULL) {
+ g_strfreev (jlist->priv->array);
+ }
+ jlist->priv->array = g_strdupv (array);
pk_debug ("emit job-list-changed");
g_signal_emit (jlist , signals [PK_JOB_LIST_CHANGED], 0);
}
@@ -214,11 +193,12 @@ static void
pk_connection_changed_cb (PkConnection *pconnection, gboolean connected, PkJobList *jlist)
{
pk_debug ("connected=%i", connected);
- /* clear job array */
- g_array_set_size (jlist->priv->job_list, 0);
+ /* force a refresh so we have valid data*/
+ if (connected == TRUE) {
+ pk_job_list_refresh (jlist);
+ }
}
-
/**
* pk_job_list_init:
**/
@@ -227,7 +207,6 @@ pk_job_list_init (PkJobList *jlist)
{
GError *error = NULL;
DBusGProxy *proxy = NULL;
- GType struct_array_type;
jlist->priv = PK_JOB_LIST_GET_PRIVATE (jlist);
jlist->priv->proxy = NULL;
@@ -241,7 +220,7 @@ pk_job_list_init (PkJobList *jlist)
}
/* we maintain a local copy */
- jlist->priv->job_list = g_array_new (FALSE, FALSE, sizeof (guint));
+ jlist->priv->array = NULL;
/* watch for PackageKit on the bus, and try to connect up at start */
jlist->priv->pconnection = pk_connection_new ();
@@ -261,12 +240,8 @@ pk_job_list_init (PkJobList *jlist)
}
jlist->priv->proxy = proxy;
- struct_array_type = dbus_g_type_get_collection ("GArray", G_TYPE_UINT);
-
- dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE, struct_array_type, G_TYPE_INVALID);
dbus_g_proxy_add_signal (proxy, "JobListChanged",
- struct_array_type, G_TYPE_INVALID);
+ G_TYPE_STRV, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "JobListChanged",
G_CALLBACK(pk_job_list_changed_cb), jlist, NULL);
@@ -289,7 +264,9 @@ pk_job_list_finalize (GObject *object)
/* free the proxy */
g_object_unref (G_OBJECT (jlist->priv->proxy));
g_object_unref (jlist->priv->pconnection);
- g_array_free (jlist->priv->job_list, TRUE);
+ if (jlist->priv->array != NULL) {
+ g_strfreev (jlist->priv->array);
+ }
G_OBJECT_CLASS (pk_job_list_parent_class)->finalize (object);
}
diff --git a/libpackagekit/pk-job-list.h b/libpackagekit/pk-job-list.h
index 6990578..f0b0eeb 100644
--- a/libpackagekit/pk-job-list.h
+++ b/libpackagekit/pk-job-list.h
@@ -51,7 +51,7 @@ PkJobList *pk_job_list_new (void);
gboolean pk_job_list_refresh (PkJobList *jlist);
gboolean pk_job_list_print (PkJobList *jlist);
-GArray *pk_job_list_get_latest (PkJobList *jlist);
+const gchar **pk_job_list_get_latest (PkJobList *jlist);
G_END_DECLS
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
index 74eee85..f1c8441 100644
--- a/libpackagekit/pk-task-client.c
+++ b/libpackagekit/pk-task-client.c
@@ -54,7 +54,7 @@ struct PkTaskClientPrivate
gboolean assigned;
gboolean is_sync;
gboolean use_buffer;
- guint job;
+ gchar *tid;
GMainLoop *loop;
PkStatusEnum last_status;
PkTaskMonitor *tmonitor;
@@ -206,7 +206,7 @@ pk_task_client_reset (PkTaskClient *tcli
tclient->priv->assigned = FALSE;
tclient->priv->is_sync = FALSE;
tclient->priv->use_buffer = FALSE;
- tclient->priv->job = 0;
+ tclient->priv->tid = NULL;
tclient->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
tclient->priv->is_finished = FALSE;
pk_task_client_remove_package_items (tclient);
@@ -251,7 +251,7 @@ pk_task_client_get_updates (PkTaskClient
error = NULL;
ret = dbus_g_proxy_call (tclient->priv->proxy, "GetUpdates", &error,
G_TYPE_INVALID,
- G_TYPE_UINT, &tclient->priv->job,
+ G_TYPE_STRING, &tclient->priv->tid,
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
@@ -265,7 +265,7 @@ pk_task_client_get_updates (PkTaskClient
return FALSE;
}
- pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
+ pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
pk_task_client_wait_if_sync (tclient);
return TRUE;
@@ -285,7 +285,7 @@ pk_task_client_update_system_action (PkT
*error = NULL;
ret = dbus_g_proxy_call (tclient->priv->proxy, "UpdateSystem", error,
G_TYPE_INVALID,
- G_TYPE_UINT, &tclient->priv->job,
+ G_TYPE_STRING, &tclient->priv->tid,
G_TYPE_INVALID);
if (ret == FALSE) {
/* abort as the DBUS method failed */
@@ -334,7 +334,7 @@ pk_task_client_update_system (PkTaskClie
}
}
- pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
+ pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
if (ret == TRUE) {
pk_task_client_wait_if_sync (tclient);
}
@@ -366,7 +366,7 @@ pk_task_client_search_name (PkTaskClient
G_TYPE_STRING, filter,
G_TYPE_STRING, search,
G_TYPE_INVALID,
- G_TYPE_UINT, &tclient->priv->job,
+ G_TYPE_STRING, &tclient->priv->tid,
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
@@ -379,7 +379,7 @@ pk_task_client_search_name (PkTaskClient
pk_warning ("SearchName failed!");
return FALSE;
}
- pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
+ pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
pk_task_client_wait_if_sync (tclient);
return TRUE;
@@ -408,7 +408,7 @@ pk_task_client_search_details (PkTaskCli
G_TYPE_STRING, filter,
G_TYPE_STRING, search,
G_TYPE_INVALID,
- G_TYPE_UINT, &tclient->priv->job,
+ G_TYPE_STRING, &tclient->priv->tid,
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
@@ -421,7 +421,7 @@ pk_task_client_search_details (PkTaskCli
pk_warning ("SearchDetails failed!");
return FALSE;
}
- pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
+ pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
pk_task_client_wait_if_sync (tclient);
return TRUE;
@@ -450,7 +450,7 @@ pk_task_client_search_group (PkTaskClien
G_TYPE_STRING, filter,
G_TYPE_STRING, search,
G_TYPE_INVALID,
- G_TYPE_UINT, &tclient->priv->job,
+ G_TYPE_STRING, &tclient->priv->tid,
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
@@ -465,7 +465,7 @@ pk_task_client_search_group (PkTaskClien
}
/* only assign on success */
tclient->priv->assigned = TRUE;
- pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
+ pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
pk_task_client_wait_if_sync (tclient);
return TRUE;
@@ -494,7 +494,7 @@ pk_task_client_search_file (PkTaskClient
G_TYPE_STRING, filter,
G_TYPE_STRING, search,
G_TYPE_INVALID,
- G_TYPE_UINT, &tclient->priv->job,
+ G_TYPE_STRING, &tclient->priv->tid,
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
@@ -509,7 +509,7 @@ pk_task_client_search_file (PkTaskClient
}
/* only assign on success */
tclient->priv->assigned = TRUE;
- pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
+ pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
pk_task_client_wait_if_sync (tclient);
return TRUE;
@@ -537,7 +537,7 @@ pk_task_client_get_depends (PkTaskClient
ret = dbus_g_proxy_call (tclient->priv->proxy, "GetDepends", &error,
G_TYPE_STRING, package,
G_TYPE_INVALID,
- G_TYPE_UINT, &tclient->priv->job,
+ G_TYPE_STRING, &tclient->priv->tid,
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
@@ -552,7 +552,7 @@ pk_task_client_get_depends (PkTaskClient
}
/* only assign on success */
tclient->priv->assigned = TRUE;
- pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
+ pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
pk_task_client_wait_if_sync (tclient);
return TRUE;
@@ -580,7 +580,7 @@ pk_task_client_get_requires (PkTaskClien
ret = dbus_g_proxy_call (tclient->priv->proxy, "GetRequires", &error,
G_TYPE_STRING, package,
G_TYPE_INVALID,
- G_TYPE_UINT, &tclient->priv->job,
+ G_TYPE_STRING, &tclient->priv->tid,
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
@@ -595,7 +595,7 @@ pk_task_client_get_requires (PkTaskClien
}
/* only assign on success */
tclient->priv->assigned = TRUE;
- pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
+ pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
pk_task_client_wait_if_sync (tclient);
return TRUE;
@@ -623,7 +623,7 @@ pk_task_client_get_update_detail (PkTask
ret = dbus_g_proxy_call (tclient->priv->proxy, "GetUpdateDetail", &error,
G_TYPE_STRING, package,
G_TYPE_INVALID,
- G_TYPE_UINT, &tclient->priv->job,
+ G_TYPE_STRING, &tclient->priv->tid,
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
@@ -638,7 +638,7 @@ pk_task_client_get_update_detail (PkTask
}
/* only assign on success */
tclient->priv->assigned = TRUE;
- pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
+ pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
pk_task_client_wait_if_sync (tclient);
return TRUE;
@@ -666,7 +666,7 @@ pk_task_client_get_description (PkTaskCl
ret = dbus_g_proxy_call (tclient->priv->proxy, "GetDescription", &error,
G_TYPE_STRING, package,
G_TYPE_INVALID,
- G_TYPE_UINT, &tclient->priv->job,
+ G_TYPE_STRING, &tclient->priv->tid,
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
@@ -681,7 +681,7 @@ pk_task_client_get_description (PkTaskCl
}
/* only assign on success */
tclient->priv->assigned = TRUE;
- pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
+ pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
pk_task_client_wait_if_sync (tclient);
return TRUE;
@@ -704,7 +704,7 @@ pk_task_client_remove_package_action (Pk
G_TYPE_STRING, package,
G_TYPE_BOOLEAN, allow_deps,
G_TYPE_INVALID,
- G_TYPE_UINT, &tclient->priv->job,
+ G_TYPE_STRING, &tclient->priv->tid,
G_TYPE_INVALID);
if (ret == FALSE) {
/* abort as the DBUS method failed */
@@ -753,7 +753,7 @@ pk_task_client_remove_package (PkTaskCli
}
}
- pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
+ pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
if (ret == TRUE) {
pk_task_client_wait_if_sync (tclient);
}
@@ -783,7 +783,7 @@ pk_task_client_refresh_cache (PkTaskClie
ret = dbus_g_proxy_call (tclient->priv->proxy, "RefreshCache", &error,
G_TYPE_BOOLEAN, force,
G_TYPE_INVALID,
- G_TYPE_UINT, &tclient->priv->job,
+ G_TYPE_STRING, &tclient->priv->tid,
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
@@ -798,7 +798,7 @@ pk_task_client_refresh_cache (PkTaskClie
}
/* only assign on success */
tclient->priv->assigned = TRUE;
- pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
+ pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
pk_task_client_wait_if_sync (tclient);
return TRUE;
@@ -819,7 +819,7 @@ pk_task_client_install_package_action (P
ret = dbus_g_proxy_call (tclient->priv->proxy, "InstallPackage", error,
G_TYPE_STRING, package,
G_TYPE_INVALID,
- G_TYPE_UINT, &tclient->priv->job,
+ G_TYPE_STRING, &tclient->priv->tid,
G_TYPE_INVALID);
if (ret == FALSE) {
/* abort as the DBUS method failed */
@@ -868,7 +868,7 @@ pk_task_client_install_package (PkTaskCl
}
}
- pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
+ pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
/* only wait if the command succeeded. False is usually due to PolicyKit auth failure */
if (ret == TRUE) {
@@ -898,7 +898,7 @@ pk_task_client_cancel (PkTaskClient *tcl
error = NULL;
ret = dbus_g_proxy_call (tclient->priv->proxy, "Cancel", &error,
- G_TYPE_UINT, tclient->priv->job,
+ G_TYPE_STRING, tclient->priv->tid,
G_TYPE_INVALID,
G_TYPE_INVALID);
if (ret == FALSE) {
@@ -1341,7 +1341,7 @@ pk_task_client_init (PkTaskClient *tclie
tclient->priv->assigned = FALSE;
tclient->priv->is_sync = FALSE;
tclient->priv->use_buffer = FALSE;
- tclient->priv->job = 0;
+ tclient->priv->tid = NULL;
tclient->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
tclient->priv->require_restart = PK_RESTART_ENUM_NONE;
tclient->priv->is_finished = FALSE;
diff --git a/libpackagekit/pk-task-list.c b/libpackagekit/pk-task-list.c
index 5e43433..266f02b 100644
--- a/libpackagekit/pk-task-list.c
+++ b/libpackagekit/pk-task-list.c
@@ -85,17 +85,16 @@ pk_task_list_print (PkTaskList *tlist)
}
for (i=0; i<length; i++) {
item = g_ptr_array_index (tlist->priv->task_list, i);
- g_print ("%i %s %s\n", item->job, pk_role_enum_to_text (item->role), item->package_id);
+ g_print ("%s %s %s\n", item->tid, pk_role_enum_to_text (item->role), item->package_id);
}
- g_print ("\n");
return TRUE;
}
/**
- * pk_task_list_find_existing_job:
+ * pk_task_list_find_existing_tid:
**/
static PkTaskListItem *
-pk_task_list_find_existing_job (PkTaskList *tlist, guint job)
+pk_task_list_find_existing_tid (PkTaskList *tlist, const gchar *tid)
{
guint i;
guint length;
@@ -105,7 +104,7 @@ pk_task_list_find_existing_job (PkTaskLi
/* mark previous tasks as non-valid */
for (i=0; i<length; i++) {
item = g_ptr_array_index (tlist->priv->task_list, i);
- if (item->job == job) {
+ if (strcmp (item->tid, tid) == 0) {
return item;
}
}
@@ -118,18 +117,19 @@ pk_task_list_find_existing_job (PkTaskLi
static void
pk_task_list_job_status_changed_cb (PkTaskMonitor *tmonitor, PkStatusEnum status, PkTaskList *tlist)
{
- guint job;
+ gchar *tid;
PkTaskListItem *item;
g_return_if_fail (tlist != NULL);
g_return_if_fail (PK_IS_TASK_LIST (tlist));
- job = pk_task_monitor_get_job (tmonitor);
- pk_debug ("job %i is now %i", job, status);
+ tid = pk_task_monitor_get_tid (tmonitor);
+ pk_debug ("tid %s is now %i", tid, status);
/* get correct item */
- item = pk_task_list_find_existing_job (tlist, job);
+ item = pk_task_list_find_existing_tid (tlist, tid);
item->status = status;
+ g_free (tid);
pk_debug ("emit task-list-changed");
g_signal_emit (tlist , signals [PK_TASK_LIST_CHANGED], 0);
@@ -141,20 +141,21 @@ pk_task_list_job_status_changed_cb (PkTa
static void
pk_task_list_job_finished_cb (PkTaskMonitor *tmonitor, PkExitEnum exit, guint runtime, PkTaskList *tlist)
{
- guint job;
+ gchar *tid;
PkTaskListItem *item;
g_return_if_fail (tlist != NULL);
g_return_if_fail (PK_IS_TASK_LIST (tlist));
- job = pk_task_monitor_get_job (tmonitor);
- pk_debug ("job %i exited with %i", job, exit);
+ tid = pk_task_monitor_get_tid (tmonitor);
+ pk_debug ("tid %s exited with %i", tid, exit);
/* get correct item */
- item = pk_task_list_find_existing_job (tlist, job);
+ 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);
+ g_signal_emit (tlist, signals [PK_TASK_LIST_FINISHED], 0, item->role, item->package_id, runtime);
}
/**
@@ -180,9 +181,9 @@ pk_task_list_refresh (PkTaskList *tlist)
{
guint i;
PkTaskListItem *item;
- guint job;
guint length;
- GArray *array;
+ const gchar *tid;
+ const gchar **array;
g_return_val_if_fail (tlist != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK_LIST (tlist), FALSE);
@@ -198,15 +199,15 @@ pk_task_list_refresh (PkTaskList *tlist)
}
/* copy tasks */
- length = array->len;
+ length = g_strv_length ((gchar **) array);
for (i=0; i<length; i++) {
- job = g_array_index (array, guint, i);
+ tid = array[i];
- item = pk_task_list_find_existing_job (tlist, job);
+ item = pk_task_list_find_existing_tid (tlist, tid);
if (item == NULL) {
- pk_debug ("new job, have to create %i", job);
+ pk_debug ("new job, have to create %s", tid);
item = g_new0 (PkTaskListItem, 1);
- item->job = job;
+ item->tid = g_strdup (tid);
item->monitor = pk_task_monitor_new ();
g_signal_connect (item->monitor, "job-status-changed",
G_CALLBACK (pk_task_list_job_status_changed_cb), tlist);
@@ -214,7 +215,7 @@ pk_task_list_refresh (PkTaskList *tlist)
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_task_monitor_set_job (item->monitor, job);
+ pk_task_monitor_set_tid (item->monitor, tid);
pk_task_monitor_get_role (item->monitor, &item->role, &item->package_id);
pk_task_monitor_get_status (item->monitor, &item->status);
@@ -230,10 +231,11 @@ pk_task_list_refresh (PkTaskList *tlist)
for (i=0; i<tlist->priv->task_list->len; i++) {
item = g_ptr_array_index (tlist->priv->task_list, i);
if (item->valid == FALSE) {
- pk_debug ("remove %i", item->job);
+ pk_debug ("remove %s", item->tid);
g_object_unref (item->monitor);
- g_free (item->package_id);
g_ptr_array_remove (tlist->priv->task_list, item);
+ g_free (item->tid);
+ g_free (item->package_id);
g_free (item);
}
}
@@ -333,7 +335,7 @@ pk_task_list_finalize (GObject *object)
/* remove all watches */
for (i=0; i<tlist->priv->task_list->len; i++) {
item = g_ptr_array_index (tlist->priv->task_list, i);
- pk_debug ("remove %i", item->job);
+ pk_debug ("remove %s", item->tid);
g_object_unref (item->monitor);
g_free (item->package_id);
g_ptr_array_remove (tlist->priv->task_list, item);
diff --git a/libpackagekit/pk-task-list.h b/libpackagekit/pk-task-list.h
index c78783d..1ff6bb4 100644
--- a/libpackagekit/pk-task-list.h
+++ b/libpackagekit/pk-task-list.h
@@ -39,7 +39,7 @@ typedef struct PkTaskListPrivate PkTaskL
typedef struct
{
- guint job;
+ gchar *tid;
PkStatusEnum status;
PkRoleEnum role;
gchar *package_id;
diff --git a/libpackagekit/pk-task-monitor.c b/libpackagekit/pk-task-monitor.c
index 56a9705..9dd87c3 100644
--- a/libpackagekit/pk-task-monitor.c
+++ b/libpackagekit/pk-task-monitor.c
@@ -49,7 +49,7 @@ struct PkTaskMonitorPrivate
{
DBusGConnection *connection;
DBusGProxy *proxy;
- guint job;
+ gchar *tid;
PkConnection *pconnection;
};
@@ -73,22 +73,22 @@ static guint signals [PK_TASK_MONITOR_LA
G_DEFINE_TYPE (PkTaskMonitor, pk_task_monitor, G_TYPE_OBJECT)
/**
- * pk_task_monitor_set_job:
+ * pk_task_monitor_set_tid:
**/
gboolean
-pk_task_monitor_set_job (PkTaskMonitor *tmonitor, guint job)
+pk_task_monitor_set_tid (PkTaskMonitor *tmonitor, const gchar *tid)
{
- tmonitor->priv->job = job;
+ tmonitor->priv->tid = g_strdup (tid);
return TRUE;
}
/**
- * pk_task_monitor_get_job:
+ * pk_task_monitor_get_tid:
**/
-guint
-pk_task_monitor_get_job (PkTaskMonitor *tmonitor)
+gchar *
+pk_task_monitor_get_tid (PkTaskMonitor *tmonitor)
{
- return tmonitor->priv->job;
+ return g_strdup (tmonitor->priv->tid);
}
/**
@@ -104,11 +104,11 @@ pk_task_monitor_get_status (PkTaskMonito
g_return_val_if_fail (tmonitor != NULL, FALSE);
g_return_val_if_fail (status != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK_MONITOR (tmonitor), FALSE);
- g_return_val_if_fail (tmonitor->priv->job != 0, FALSE);
+ g_return_val_if_fail (tmonitor->priv->tid != NULL, FALSE);
error = NULL;
ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetStatus", &error,
- G_TYPE_UINT, tmonitor->priv->job,
+ G_TYPE_STRING, tmonitor->priv->tid,
G_TYPE_INVALID,
G_TYPE_STRING, &status_text,
G_TYPE_INVALID);
@@ -137,11 +137,11 @@ pk_task_monitor_get_package (PkTaskMonit
g_return_val_if_fail (tmonitor != NULL, FALSE);
g_return_val_if_fail (package != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK_MONITOR (tmonitor), FALSE);
- g_return_val_if_fail (tmonitor->priv->job != 0, FALSE);
+ g_return_val_if_fail (tmonitor->priv->tid != NULL, FALSE);
error = NULL;
ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetPackage", &error,
- G_TYPE_UINT, tmonitor->priv->job,
+ G_TYPE_STRING, tmonitor->priv->tid,
G_TYPE_INVALID,
G_TYPE_STRING, package,
G_TYPE_INVALID);
@@ -168,11 +168,11 @@ pk_task_monitor_cancel (PkTaskMonitor *t
g_return_val_if_fail (tmonitor != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK_MONITOR (tmonitor), FALSE);
- g_return_val_if_fail (tmonitor->priv->job != 0, FALSE);
+ g_return_val_if_fail (tmonitor->priv->tid != NULL, FALSE);
error = NULL;
ret = dbus_g_proxy_call (tmonitor->priv->proxy, "Cancel", &error,
- G_TYPE_UINT, tmonitor->priv->job,
+ G_TYPE_STRING, tmonitor->priv->tid,
G_TYPE_INVALID,
G_TYPE_INVALID);
if (error) {
@@ -199,11 +199,11 @@ pk_task_monitor_get_percentage (PkTaskMo
g_return_val_if_fail (tmonitor != NULL, FALSE);
g_return_val_if_fail (percentage != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK_MONITOR (tmonitor), FALSE);
- g_return_val_if_fail (tmonitor->priv->job != 0, FALSE);
+ g_return_val_if_fail (tmonitor->priv->tid != NULL, FALSE);
error = NULL;
ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetPercentage", &error,
- G_TYPE_UINT, tmonitor->priv->job,
+ G_TYPE_STRING, tmonitor->priv->tid,
G_TYPE_INVALID,
G_TYPE_UINT, percentage,
G_TYPE_INVALID);
@@ -231,11 +231,11 @@ pk_task_monitor_get_sub_percentage (PkTa
g_return_val_if_fail (tmonitor != NULL, FALSE);
g_return_val_if_fail (percentage != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK_MONITOR (tmonitor), FALSE);
- g_return_val_if_fail (tmonitor->priv->job != 0, FALSE);
+ g_return_val_if_fail (tmonitor->priv->tid != NULL, FALSE);
error = NULL;
ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetSubPercentage", &error,
- G_TYPE_UINT, tmonitor->priv->job,
+ G_TYPE_STRING, tmonitor->priv->tid,
G_TYPE_INVALID,
G_TYPE_UINT, percentage,
G_TYPE_INVALID);
@@ -265,11 +265,11 @@ pk_task_monitor_get_role (PkTaskMonitor
g_return_val_if_fail (tmonitor != NULL, FALSE);
g_return_val_if_fail (role != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK_MONITOR (tmonitor), FALSE);
- g_return_val_if_fail (tmonitor->priv->job != 0, FALSE);
+ g_return_val_if_fail (tmonitor->priv->tid != NULL, FALSE);
error = NULL;
ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetRole", &error,
- G_TYPE_UINT, tmonitor->priv->job,
+ G_TYPE_STRING, tmonitor->priv->tid,
G_TYPE_INVALID,
G_TYPE_STRING, &role_text,
G_TYPE_STRING, &package_id_temp,
@@ -292,7 +292,7 @@ pk_task_monitor_get_role (PkTaskMonitor
*/
static void
pk_task_monitor_finished_cb (DBusGProxy *proxy,
- guint job,
+ gchar *tid,
const gchar *exit_text,
guint runtime,
PkTaskMonitor *tmonitor)
@@ -302,7 +302,7 @@ pk_task_monitor_finished_cb (DBusGProxy
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
- if (job == tmonitor->priv->job) {
+ if (strcmp (tid, tmonitor->priv->tid) == 0) {
exit = pk_exit_enum_from_text (exit_text);
pk_debug ("emit finished %i, %i", exit, runtime);
g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_FINISHED], 0, exit, runtime);
@@ -314,14 +314,14 @@ pk_task_monitor_finished_cb (DBusGProxy
*/
static void
pk_task_monitor_percentage_changed_cb (DBusGProxy *proxy,
- guint job,
+ const gchar *tid,
guint percentage,
PkTaskMonitor *tmonitor)
{
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
- if (job == tmonitor->priv->job) {
+ if (strcmp (tid, tmonitor->priv->tid) == 0) {
pk_debug ("emit percentage-changed %i", percentage);
g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_PERCENTAGE_CHANGED], 0, percentage);
}
@@ -332,14 +332,14 @@ pk_task_monitor_percentage_changed_cb (D
*/
static void
pk_task_monitor_sub_percentage_changed_cb (DBusGProxy *proxy,
- guint job,
+ const gchar *tid,
guint percentage,
PkTaskMonitor *tmonitor)
{
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
- if (job == tmonitor->priv->job) {
+ if (strcmp (tid, tmonitor->priv->tid) == 0) {
pk_debug ("emit sub-percentage-changed %i", percentage);
g_signal_emit (tmonitor, signals [PK_TASK_MONITOR_SUB_PERCENTAGE_CHANGED], 0, percentage);
}
@@ -350,13 +350,13 @@ pk_task_monitor_sub_percentage_changed_c
*/
static void
pk_task_monitor_no_percentage_updates_cb (DBusGProxy *proxy,
- guint job,
+ const gchar *tid,
PkTaskMonitor *tmonitor)
{
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
- if (job == tmonitor->priv->job) {
+ if (strcmp (tid, tmonitor->priv->tid) == 0) {
pk_debug ("emit no-percentage-updates");
g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_NO_PERCENTAGE_UPDATES], 0);
}
@@ -367,7 +367,7 @@ pk_task_monitor_no_percentage_updates_cb
*/
static void
pk_task_monitor_job_status_changed_cb (DBusGProxy *proxy,
- guint job,
+ const gchar *tid,
const gchar *status_text,
PkTaskMonitor *tmonitor)
{
@@ -378,7 +378,7 @@ pk_task_monitor_job_status_changed_cb (D
status = pk_status_enum_from_text (status_text);
- if (job == tmonitor->priv->job) {
+ if (strcmp (tid, tmonitor->priv->tid) == 0) {
pk_debug ("emit job-status-changed %i", status);
g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_JOB_STATUS_CHANGED], 0, status);
}
@@ -389,7 +389,7 @@ pk_task_monitor_job_status_changed_cb (D
*/
static void
pk_task_monitor_package_cb (DBusGProxy *proxy,
- guint job,
+ const gchar *tid,
guint value,
const gchar *package,
const gchar *summary,
@@ -398,7 +398,7 @@ pk_task_monitor_package_cb (DBusGProxy
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
- if (job == tmonitor->priv->job) {
+ if (strcmp (tid, tmonitor->priv->tid) == 0) {
pk_debug ("emit package %i, %s, %s", value, package, summary);
g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_PACKAGE], 0, value, package, summary);
}
@@ -425,7 +425,7 @@ pk_task_monitor_transaction_cb (DBusGPro
*/
static void
pk_task_monitor_update_detail_cb (DBusGProxy *proxy,
- guint job,
+ const gchar *tid,
const gchar *package_id,
const gchar *updates,
const gchar *obsoletes,
@@ -437,7 +437,7 @@ pk_task_monitor_update_detail_cb (DBusGP
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
- if (job == tmonitor->priv->job) {
+ if (strcmp (tid, tmonitor->priv->tid) == 0) {
pk_debug ("emit update-detail %s, %s, %s, %s, %s, %s",
package_id, updates, obsoletes, url, restart, update_text);
g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_UPDATE_DETAIL], 0,
@@ -450,7 +450,7 @@ pk_task_monitor_update_detail_cb (DBusGP
*/
static void
pk_task_monitor_description_cb (DBusGProxy *proxy,
- guint job,
+ const gchar *tid,
const gchar *package_id,
const gchar *licence,
const gchar *group_text,
@@ -462,7 +462,7 @@ pk_task_monitor_description_cb (DBusGPro
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
- if (job == tmonitor->priv->job) {
+ if (strcmp (tid, tmonitor->priv->tid) == 0) {
group = pk_group_enum_from_text (group_text);
pk_debug ("emit description %s, %s, %i, %s, %s", package_id, licence, group, description, url);
g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_DESCRIPTION], 0, package_id, licence, group, description, url);
@@ -474,7 +474,7 @@ pk_task_monitor_description_cb (DBusGPro
*/
static void
pk_task_monitor_error_code_cb (DBusGProxy *proxy,
- guint job,
+ const gchar *tid,
const gchar *code_text,
const gchar *details,
PkTaskMonitor *tmonitor)
@@ -483,7 +483,7 @@ pk_task_monitor_error_code_cb (DBusGProx
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
- if (job == tmonitor->priv->job) {
+ if (strcmp (tid, tmonitor->priv->tid) == 0) {
code = pk_error_enum_from_text (code_text);
pk_debug ("emit error-code %i, %s", code, details);
g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_ERROR_CODE], 0, code, details);
@@ -495,7 +495,7 @@ pk_task_monitor_error_code_cb (DBusGProx
*/
static void
pk_task_monitor_require_restart_cb (DBusGProxy *proxy,
- guint job,
+ const gchar *tid,
const gchar *restart_text,
const gchar *details,
PkTaskMonitor *tmonitor)
@@ -504,7 +504,7 @@ pk_task_monitor_require_restart_cb (DBus
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
- if (job == tmonitor->priv->job) {
+ if (strcmp (tid, tmonitor->priv->tid) == 0) {
restart = pk_restart_enum_from_text (restart_text);
pk_debug ("emit require-restart %i, %s", restart, details);
g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_REQUIRE_RESTART], 0, restart, details);
@@ -611,7 +611,7 @@ pk_task_monitor_init (PkTaskMonitor *tmo
DBusGProxy *proxy = NULL;
tmonitor->priv = PK_TASK_MONITOR_GET_PRIVATE (tmonitor);
- tmonitor->priv->job = 0;
+ tmonitor->priv->tid = NULL;
/* check dbus connections, exit if not valid */
tmonitor->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
@@ -636,26 +636,28 @@ pk_task_monitor_init (PkTaskMonitor *tmo
g_error ("Cannot connect to PackageKit.");
}
tmonitor->priv->proxy = proxy;
- dbus_g_object_register_marshaller (pk_marshal_VOID__UINT_UINT,
- G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__UINT_UINT,
- G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__UINT_STRING_UINT,
- G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__UINT_STRING_STRING,
- G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__UINT_STRING_STRING_STRING_STRING_STRING,
- G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING,
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_UINT,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_UINT,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ /* Finished */
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_UINT,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
+
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__UINT_STRING_STRING_STRING,
- G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__UINT_STRING_STRING_STRING_STRING,
- G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING,
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__UINT_UINT_STRING_STRING,
- G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__UINT_STRING_STRING_STRING_STRING_STRING_STRING,
- G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING,
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_UINT_STRING_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
/* transaction */
dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_BOOL_STRING_UINT,
@@ -663,32 +665,32 @@ pk_task_monitor_init (PkTaskMonitor *tmo
G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
dbus_g_proxy_add_signal (proxy, "Finished",
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "Finished",
G_CALLBACK (pk_task_monitor_finished_cb), tmonitor, NULL);
dbus_g_proxy_add_signal (proxy, "PercentageChanged",
- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
+ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "PercentageChanged",
G_CALLBACK (pk_task_monitor_percentage_changed_cb), tmonitor, NULL);
dbus_g_proxy_add_signal (proxy, "SubPercentageChanged",
- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID);
+ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "SubPercentageChanged",
G_CALLBACK (pk_task_monitor_sub_percentage_changed_cb), tmonitor, NULL);
dbus_g_proxy_add_signal (proxy, "NoPercentageUpdates",
- G_TYPE_UINT, G_TYPE_INVALID);
+ G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "NoPercentageUpdates",
G_CALLBACK (pk_task_monitor_no_percentage_updates_cb), tmonitor, NULL);
dbus_g_proxy_add_signal (proxy, "JobStatusChanged",
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "JobStatusChanged",
G_CALLBACK (pk_task_monitor_job_status_changed_cb), tmonitor, NULL);
dbus_g_proxy_add_signal (proxy, "Package",
- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "Package",
G_CALLBACK (pk_task_monitor_package_cb), tmonitor, NULL);
@@ -698,24 +700,24 @@ pk_task_monitor_init (PkTaskMonitor *tmo
G_CALLBACK (pk_task_monitor_transaction_cb), tmonitor, NULL);
dbus_g_proxy_add_signal (proxy, "UpdateDetail",
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "UpdateDetail",
G_CALLBACK (pk_task_monitor_update_detail_cb), tmonitor, NULL);
dbus_g_proxy_add_signal (proxy, "Description",
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "Description",
G_CALLBACK (pk_task_monitor_description_cb), tmonitor, NULL);
dbus_g_proxy_add_signal (proxy, "ErrorCode",
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "ErrorCode",
G_CALLBACK (pk_task_monitor_error_code_cb), tmonitor, NULL);
dbus_g_proxy_add_signal (proxy, "RequireRestart",
- G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "RequireRestart",
G_CALLBACK (pk_task_monitor_require_restart_cb), tmonitor, NULL);
}
diff --git a/libpackagekit/pk-task-monitor.h b/libpackagekit/pk-task-monitor.h
index 23e8a0c..1151641 100644
--- a/libpackagekit/pk-task-monitor.h
+++ b/libpackagekit/pk-task-monitor.h
@@ -29,7 +29,7 @@ G_BEGIN_DECLS
#define PK_TYPE_TASK_MONITOR (pk_task_monitor_get_type ())
#define PK_TASK_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_TASK_MONITOR, PkTaskMonitor))
-#define PK_TASK_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_TASK_MONITOR, PkTaskMonitorClass))
+#define PK_TASK_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_TASK_MONITOR, PkTaskMonitorClass))
#define PK_IS_TASK_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_TASK_MONITOR))
#define PK_IS_TASK_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_TASK_MONITOR))
#define PK_TASK_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_TASK_MONITOR, PkTaskMonitorClass))
@@ -50,9 +50,9 @@ typedef struct
GType pk_task_monitor_get_type (void);
PkTaskMonitor *pk_task_monitor_new (void);
-gboolean pk_task_monitor_set_job (PkTaskMonitor *tmonitor,
- guint job);
-guint pk_task_monitor_get_job (PkTaskMonitor *tmonitor);
+gboolean pk_task_monitor_set_tid (PkTaskMonitor *tmonitor,
+ const gchar *tid);
+gchar *pk_task_monitor_get_tid (PkTaskMonitor *tmonitor);
gboolean pk_task_monitor_get_status (PkTaskMonitor *tmonitor,
PkStatusEnum *status);
gboolean pk_task_monitor_get_role (PkTaskMonitor *tmonitor,
diff --git a/src/pk-engine.c b/src/pk-engine.c
index c291d84..37160d1 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -156,7 +156,7 @@ pk_engine_reset_timer (PkEngine *engine)
static gboolean
pk_engine_job_list_changed (PkEngine *engine)
{
- GArray *job_list;
+ gchar **job_list;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -188,8 +188,8 @@ pk_engine_job_status_changed_cb (PkTask
}
status_text = pk_status_enum_to_text (status);
- pk_debug ("emitting job-status-changed job:%i, '%s'", item->job, status_text);
- g_signal_emit (engine, signals [PK_ENGINE_JOB_STATUS_CHANGED], 0, item->job, status_text);
+ pk_debug ("emitting job-status-changed tid:%s, '%s'", item->tid, status_text);
+ g_signal_emit (engine, signals [PK_ENGINE_JOB_STATUS_CHANGED], 0, item->tid, status_text);
pk_engine_reset_timer (engine);
}
@@ -209,8 +209,8 @@ pk_engine_percentage_changed_cb (PkTask
pk_warning ("could not find task");
return;
}
- pk_debug ("emitting percentage-changed job:%i %i", item->job, percentage);
- g_signal_emit (engine, signals [PK_ENGINE_PERCENTAGE_CHANGED], 0, item->job, percentage);
+ pk_debug ("emitting percentage-changed tid:%s %i", item->tid, percentage);
+ g_signal_emit (engine, signals [PK_ENGINE_PERCENTAGE_CHANGED], 0, item->tid, percentage);
pk_engine_reset_timer (engine);
}
@@ -230,8 +230,8 @@ pk_engine_sub_percentage_changed_cb (PkT
pk_warning ("could not find task");
return;
}
- pk_debug ("emitting sub-percentage-changed job:%i %i", item->job, percentage);
- g_signal_emit (engine, signals [PK_ENGINE_SUB_PERCENTAGE_CHANGED], 0, item->job, percentage);
+ pk_debug ("emitting sub-percentage-changed tid:%s %i", item->tid, percentage);
+ g_signal_emit (engine, signals [PK_ENGINE_SUB_PERCENTAGE_CHANGED], 0, item->tid, percentage);
pk_engine_reset_timer (engine);
}
@@ -251,8 +251,8 @@ pk_engine_no_percentage_updates_cb (PkTa
pk_warning ("could not find task");
return;
}
- pk_debug ("emitting no-percentage-updates job:%i", item->job);
- g_signal_emit (engine, signals [PK_ENGINE_NO_PERCENTAGE_UPDATES], 0, item->job);
+ pk_debug ("emitting no-percentage-updates tid:%s", item->tid);
+ g_signal_emit (engine, signals [PK_ENGINE_NO_PERCENTAGE_UPDATES], 0, item->tid);
pk_engine_reset_timer (engine);
}
@@ -272,8 +272,8 @@ pk_engine_package_cb (PkTask *task, guin
pk_warning ("could not find task");
return;
}
- pk_debug ("emitting package job:%i value=%i %s, %s", item->job, value, package_id, summary);
- g_signal_emit (engine, signals [PK_ENGINE_PACKAGE], 0, item->job, value, package_id, summary);
+ pk_debug ("emitting package tid:%s value=%i %s, %s", item->tid, value, package_id, summary);
+ g_signal_emit (engine, signals [PK_ENGINE_PACKAGE], 0, item->tid, value, package_id, summary);
pk_engine_reset_timer (engine);
}
@@ -296,9 +296,9 @@ pk_engine_update_detail_cb (PkTask *task
pk_warning ("could not find task");
return;
}
- pk_debug ("emitting package job:%i value=%s, %s, %s, %s, %s, %s", item->job,
+ pk_debug ("emitting package tid:%s value=%s, %s, %s, %s, %s, %s", item->tid,
package_id, updates, obsoletes, url, restart, update_text);
- g_signal_emit (engine, signals [PK_ENGINE_UPDATE_DETAIL], 0, item->job,
+ g_signal_emit (engine, signals [PK_ENGINE_UPDATE_DETAIL], 0, item->tid,
package_id, updates, obsoletes, url, restart, update_text);
pk_engine_reset_timer (engine);
}
@@ -321,8 +321,8 @@ pk_engine_error_code_cb (PkTask *task, P
return;
}
code_text = pk_error_enum_to_text (code);
- pk_debug ("emitting error-code job:%i %s, '%s'", item->job, code_text, details);
- g_signal_emit (engine, signals [PK_ENGINE_ERROR_CODE], 0, item->job, code_text, details);
+ pk_debug ("emitting error-code tid:%s %s, '%s'", item->tid, code_text, details);
+ g_signal_emit (engine, signals [PK_ENGINE_ERROR_CODE], 0, item->tid, code_text, details);
pk_engine_reset_timer (engine);
}
@@ -344,8 +344,8 @@ pk_engine_require_restart_cb (PkTask *ta
return;
}
restart_text = pk_restart_enum_to_text (restart);
- pk_debug ("emitting error-code job:%i %s, '%s'", item->job, restart_text, details);
- g_signal_emit (engine, signals [PK_ENGINE_REQUIRE_RESTART], 0, item->job, restart_text, details);
+ pk_debug ("emitting error-code tid:%s %s, '%s'", item->tid, restart_text, details);
+ g_signal_emit (engine, signals [PK_ENGINE_REQUIRE_RESTART], 0, item->tid, restart_text, details);
pk_engine_reset_timer (engine);
}
@@ -369,8 +369,8 @@ pk_engine_description_cb (PkTask *task,
}
group_text = pk_group_enum_to_text (group);
- pk_debug ("emitting description job:%i, %s, %s, %s, %s, %s", item->job, package_id, licence, group_text, detail, url);
- g_signal_emit (engine, signals [PK_ENGINE_DESCRIPTION], 0, item->job, package_id, licence, group_text, detail, url);
+ pk_debug ("emitting description tid:%s, %s, %s, %s, %s, %s", item->tid, package_id, licence, group_text, detail, url);
+ g_signal_emit (engine, signals [PK_ENGINE_DESCRIPTION], 0, item->tid, package_id, licence, group_text, detail, url);
}
/**
@@ -399,8 +399,8 @@ pk_engine_finished_cb (PkTask *task, PkE
pk_debug ("task was running for %f seconds", time);
pk_transaction_db_set_finished (engine->priv->transaction_db, item->tid, TRUE, time);
- pk_debug ("emitting finished job: %i, '%s', %i", item->job, exit_text, (guint) time);
- g_signal_emit (engine, signals [PK_ENGINE_FINISHED], 0, item->job, exit_text, (guint) time);
+ pk_debug ("emitting finished job:%s, '%s', %i", item->tid, exit_text, (guint) time);
+ g_signal_emit (engine, signals [PK_ENGINE_FINISHED], 0, item->tid, exit_text, (guint) time);
/* remove from array and unref */
pk_transaction_list_remove (engine->priv->job_list, task);
@@ -428,8 +428,8 @@ pk_engine_allow_interrupt_cb (PkTask *ta
return;
}
- pk_debug ("emitting allow-interrpt job:%i, %i", item->job, allow_kill);
- g_signal_emit (engine, signals [PK_ENGINE_ALLOW_INTERRUPT], 0, item->job, allow_kill);
+ pk_debug ("emitting allow-interrpt tid:%s, %i", item->tid, allow_kill);
+ g_signal_emit (engine, signals [PK_ENGINE_ALLOW_INTERRUPT], 0, item->tid, allow_kill);
}
/**
@@ -602,7 +602,7 @@ pk_engine_action_is_allowed (PkEngine *e
* pk_engine_refresh_cache:
**/
gboolean
-pk_engine_refresh_cache (PkEngine *engine, gboolean force, guint *job, GError **error)
+pk_engine_refresh_cache (PkEngine *engine, gboolean force, gchar **tid, GError **error)
{
gboolean ret;
PkTask *task;
@@ -626,7 +626,7 @@ pk_engine_refresh_cache (PkEngine *engin
pk_warning ("could not find task");
return FALSE;
}
- *job = item->job;
+ *tid = g_strdup (item->tid);
return TRUE;
}
@@ -635,7 +635,7 @@ pk_engine_refresh_cache (PkEngine *engin
* pk_engine_get_updates:
**/
gboolean
-pk_engine_get_updates (PkEngine *engine, guint *job, GError **error)
+pk_engine_get_updates (PkEngine *engine, gchar **tid, GError **error)
{
gboolean ret;
PkTask *task;
@@ -659,7 +659,7 @@ pk_engine_get_updates (PkEngine *engine,
pk_warning ("could not find task");
return FALSE;
}
- *job = item->job;
+ *tid = g_strdup (item->tid);
return TRUE;
}
@@ -721,7 +721,7 @@ pk_engine_filter_check (const gchar *fil
**/
gboolean
pk_engine_search_name (PkEngine *engine, const gchar *filter, const gchar *search,
- guint *job, GError **error)
+ gchar **tid, GError **error)
{
gboolean ret;
PkTask *task;
@@ -757,7 +757,7 @@ pk_engine_search_name (PkEngine *engine,
pk_warning ("could not find task");
return FALSE;
}
- *job = item->job;
+ *tid = g_strdup (item->tid);
return TRUE;
}
@@ -767,7 +767,7 @@ pk_engine_search_name (PkEngine *engine,
**/
gboolean
pk_engine_search_details (PkEngine *engine, const gchar *filter, const gchar *search,
- guint *job, GError **error)
+ gchar **tid, GError **error)
{
gboolean ret;
PkTask *task;
@@ -803,7 +803,7 @@ pk_engine_search_details (PkEngine *engi
pk_warning ("could not find task");
return FALSE;
}
- *job = item->job;
+ *tid = g_strdup (item->tid);
return TRUE;
}
@@ -813,7 +813,7 @@ pk_engine_search_details (PkEngine *engi
**/
gboolean
pk_engine_search_group (PkEngine *engine, const gchar *filter, const gchar *search,
- guint *job, GError **error)
+ gchar **tid, GError **error)
{
gboolean ret;
PkTask *task;
@@ -849,7 +849,7 @@ pk_engine_search_group (PkEngine *engine
pk_warning ("could not find task");
return FALSE;
}
- *job = item->job;
+ *tid = g_strdup (item->tid);
return TRUE;
}
@@ -859,7 +859,7 @@ pk_engine_search_group (PkEngine *engine
**/
gboolean
pk_engine_search_file (PkEngine *engine, const gchar *filter, const gchar *search,
- guint *job, GError **error)
+ gchar **tid, GError **error)
{
gboolean ret;
PkTask *task;
@@ -895,7 +895,7 @@ pk_engine_search_file (PkEngine *engine,
pk_warning ("could not find task");
return FALSE;
}
- *job = item->job;
+ *tid = g_strdup (item->tid);
return TRUE;
}
@@ -905,7 +905,7 @@ pk_engine_search_file (PkEngine *engine,
**/
gboolean
pk_engine_get_depends (PkEngine *engine, const gchar *package_id,
- guint *job, GError **error)
+ gchar **tid, GError **error)
{
gboolean ret;
PkTask *task;
@@ -937,7 +937,7 @@ pk_engine_get_depends (PkEngine *engine,
pk_warning ("could not find task");
return FALSE;
}
- *job = item->job;
+ *tid = g_strdup (item->tid);
return TRUE;
}
@@ -947,7 +947,7 @@ pk_engine_get_depends (PkEngine *engine,
**/
gboolean
pk_engine_get_requires (PkEngine *engine, const gchar *package_id,
- guint *job, GError **error)
+ gchar **tid, GError **error)
{
gboolean ret;
PkTask *task;
@@ -979,7 +979,7 @@ pk_engine_get_requires (PkEngine *engine
pk_warning ("could not find task");
return FALSE;
}
- *job = item->job;
+ *tid = g_strdup (item->tid);
return TRUE;
}
@@ -989,7 +989,7 @@ pk_engine_get_requires (PkEngine *engine
**/
gboolean
pk_engine_get_update_detail (PkEngine *engine, const gchar *package_id,
- guint *job, GError **error)
+ gchar **tid, GError **error)
{
gboolean ret;
PkTask *task;
@@ -1021,7 +1021,7 @@ pk_engine_get_update_detail (PkEngine *e
pk_warning ("could not find task");
return FALSE;
}
- *job = item->job;
+ *tid = g_strdup (item->tid);
return TRUE;
}
@@ -1031,7 +1031,7 @@ pk_engine_get_update_detail (PkEngine *e
**/
gboolean
pk_engine_get_description (PkEngine *engine, const gchar *package_id,
- guint *job, GError **error)
+ gchar **tid, GError **error)
{
gboolean ret;
PkTask *task;
@@ -1055,7 +1055,7 @@ pk_engine_get_description (PkEngine *eng
pk_warning ("could not find task");
return FALSE;
}
- *job = item->job;
+ *tid = g_strdup (item->tid);
return TRUE;
}
@@ -1107,7 +1107,7 @@ pk_engine_update_system (PkEngine *engin
pk_warning ("could not find task");
return;
}
- dbus_g_method_return (context, item->job);
+ dbus_g_method_return (context, item->tid);
}
/**
@@ -1158,7 +1158,7 @@ pk_engine_remove_package (PkEngine *engi
pk_warning ("could not find task");
return;
}
- dbus_g_method_return (context, item->job);
+ dbus_g_method_return (context, item->tid);
}
/**
@@ -1211,7 +1211,7 @@ pk_engine_install_package (PkEngine *eng
pk_warning ("could not find task");
return;
}
- dbus_g_method_return (context, item->job);
+ dbus_g_method_return (context, item->tid);
}
/**
@@ -1264,18 +1264,19 @@ pk_engine_update_package (PkEngine *engi
pk_warning ("could not find task");
return;
}
- dbus_g_method_return (context, item->job);
+ dbus_g_method_return (context, item->tid);
}
/**
* pk_engine_get_job_list:
**/
gboolean
-pk_engine_get_job_list (PkEngine *engine, GArray **job_list, GError **error)
+pk_engine_get_job_list (PkEngine *engine, gchar ***job_list, GError **error)
{
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ pk_debug ("getting job list");
*job_list = pk_transaction_list_get_array (engine->priv->job_list);
return TRUE;
@@ -1285,8 +1286,8 @@ pk_engine_get_job_list (PkEngine *engine
* pk_engine_get_status:
**/
gboolean
-pk_engine_get_status (PkEngine *engine, guint job,
- const gchar **status, GError **error)
+pk_engine_get_status (PkEngine *engine, const gchar *tid,
+ const gchar **status, GError **error)
{
PkStatusEnum status_enum;
PkTransactionItem *item;
@@ -1294,10 +1295,10 @@ pk_engine_get_status (PkEngine *engine,
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_transaction_list_get_item_from_job (engine->priv->job_list, job);
+ item = pk_transaction_list_get_item_from_tid (engine->priv->job_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_JOB,
- "No job:%i", job);
+ "No tid:%s", tid);
return FALSE;
}
pk_backend_get_status (item->task, &status_enum);
@@ -1310,8 +1311,8 @@ pk_engine_get_status (PkEngine *engine,
* pk_engine_get_role:
**/
gboolean
-pk_engine_get_role (PkEngine *engine, guint job,
- const gchar **role, const gchar **package_id, GError **error)
+pk_engine_get_role (PkEngine *engine, const gchar *tid,
+ const gchar **role, const gchar **package_id, GError **error)
{
PkTransactionItem *item;
PkRoleEnum role_enum;
@@ -1319,10 +1320,10 @@ pk_engine_get_role (PkEngine *engine, gu
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_transaction_list_get_item_from_job (engine->priv->job_list, job);
+ item = pk_transaction_list_get_item_from_tid (engine->priv->job_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_JOB,
- "No job:%i", job);
+ "No tid:%s", tid);
return FALSE;
}
pk_backend_get_role (item->task, &role_enum, package_id);
@@ -1335,7 +1336,7 @@ pk_engine_get_role (PkEngine *engine, gu
* pk_engine_get_percentage:
**/
gboolean
-pk_engine_get_percentage (PkEngine *engine, guint job, guint *percentage, GError **error)
+pk_engine_get_percentage (PkEngine *engine, const gchar *tid, guint *percentage, GError **error)
{
PkTransactionItem *item;
gboolean ret;
@@ -1343,10 +1344,10 @@ pk_engine_get_percentage (PkEngine *engi
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_transaction_list_get_item_from_job (engine->priv->job_list, job);
+ item = pk_transaction_list_get_item_from_tid (engine->priv->job_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_JOB,
- "No job:%i", job);
+ "No tid:%s", tid);
return FALSE;
}
ret = pk_backend_get_percentage (item->task, percentage);
@@ -1362,7 +1363,7 @@ pk_engine_get_percentage (PkEngine *engi
* pk_engine_get_sub_percentage:
**/
gboolean
-pk_engine_get_sub_percentage (PkEngine *engine, guint job, guint *percentage, GError **error)
+pk_engine_get_sub_percentage (PkEngine *engine, const gchar *tid, guint *percentage, GError **error)
{
PkTransactionItem *item;
gboolean ret;
@@ -1370,10 +1371,10 @@ pk_engine_get_sub_percentage (PkEngine *
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_transaction_list_get_item_from_job (engine->priv->job_list, job);
+ item = pk_transaction_list_get_item_from_tid (engine->priv->job_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_JOB,
- "No job:%i", job);
+ "No tid:%s", tid);
return FALSE;
}
ret = pk_backend_get_sub_percentage (item->task, percentage);
@@ -1389,7 +1390,7 @@ pk_engine_get_sub_percentage (PkEngine *
* pk_engine_get_package:
**/
gboolean
-pk_engine_get_package (PkEngine *engine, guint job, gchar **package, GError **error)
+pk_engine_get_package (PkEngine *engine, const gchar *tid, gchar **package, GError **error)
{
PkTransactionItem *item;
gboolean ret;
@@ -1397,10 +1398,10 @@ pk_engine_get_package (PkEngine *engine,
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_transaction_list_get_item_from_job (engine->priv->job_list, job);
+ item = pk_transaction_list_get_item_from_tid (engine->priv->job_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_JOB,
- "No job:%i", job);
+ "No tid:%s", tid);
return FALSE;
}
ret = pk_backend_get_package (item->task, package);
@@ -1429,7 +1430,7 @@ pk_engine_get_old_transactions (PkEngine
* pk_engine_cancel:
**/
gboolean
-pk_engine_cancel (PkEngine *engine, guint job, GError **error)
+pk_engine_cancel (PkEngine *engine, const gchar *tid, GError **error)
{
gboolean ret;
PkTransactionItem *item;
@@ -1437,10 +1438,10 @@ pk_engine_cancel (PkEngine *engine, guin
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_transaction_list_get_item_from_job (engine->priv->job_list, job);
+ item = pk_transaction_list_get_item_from_tid (engine->priv->job_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_JOB,
- "No job:%i", job);
+ "No tid:%s", tid);
return FALSE;
}
@@ -1579,63 +1580,64 @@ pk_engine_class_init (PkEngineClass *kla
g_signal_new ("job-list-changed",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
0, NULL, NULL, g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE, 1, dbus_g_type_get_collection ("GArray", G_TYPE_UINT));
+ G_TYPE_NONE, 1, G_TYPE_STRV);
signals [PK_ENGINE_JOB_STATUS_CHANGED] =
g_signal_new ("job-status-changed",
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);
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
signals [PK_ENGINE_PERCENTAGE_CHANGED] =
g_signal_new ("percentage-changed",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__UINT_UINT,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+ 0, NULL, NULL, pk_marshal_VOID__STRING_UINT,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_UINT);
signals [PK_ENGINE_SUB_PERCENTAGE_CHANGED] =
g_signal_new ("sub-percentage-changed",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__UINT_UINT,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+ 0, NULL, NULL, pk_marshal_VOID__STRING_UINT,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_UINT);
signals [PK_ENGINE_NO_PERCENTAGE_UPDATES] =
g_signal_new ("no-percentage-updates",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, 1, G_TYPE_UINT);
+ 0, NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
signals [PK_ENGINE_PACKAGE] =
g_signal_new ("package",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__UINT_UINT_STRING_STRING,
- G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
+ 0, NULL, NULL, pk_marshal_VOID__STRING_UINT_STRING_STRING,
+ G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
signals [PK_ENGINE_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_STRING,
- G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING,
+ G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
signals [PK_ENGINE_REQUIRE_RESTART] =
g_signal_new ("require-restart",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__UINT_STRING_STRING,
- G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING,
+ G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
signals [PK_ENGINE_DESCRIPTION] =
g_signal_new ("description",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__UINT_STRING_STRING_STRING_STRING_STRING,
- G_TYPE_NONE, 6, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, 6, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
signals [PK_ENGINE_FINISHED] =
g_signal_new ("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);
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_UINT,
+ G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT);
signals [PK_ENGINE_UPDATE_DETAIL] =
g_signal_new ("update-detail",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__UINT_STRING_STRING_STRING_STRING_STRING_STRING,
- G_TYPE_NONE, 7, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, 7, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
signals [PK_ENGINE_ALLOW_INTERRUPT] =
g_signal_new ("allow-interrupt",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__UINT_BOOL,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_BOOLEAN);
+ 0, NULL, NULL, pk_marshal_VOID__STRING_BOOL,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
signals [PK_ENGINE_TRANSACTION] =
g_signal_new ("transaction",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/src/pk-engine.h b/src/pk-engine.h
index 9dec041..37f21fd 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -75,47 +75,47 @@ gboolean pk_engine_use_backend (PkEng
const gchar *backend);
gboolean pk_engine_get_updates (PkEngine *engine,
- guint *job,
+ gchar **tid,
GError **error);
gboolean pk_engine_search_name (PkEngine *engine,
const gchar *filter,
const gchar *search,
- guint *job,
+ gchar **tid,
GError **error);
gboolean pk_engine_search_details (PkEngine *engine,
const gchar *filter,
const gchar *search,
- guint *job,
+ gchar **tid,
GError **error);
gboolean pk_engine_search_group (PkEngine *engine,
const gchar *filter,
const gchar *search,
- guint *job,
+ gchar **tid,
GError **error);
gboolean pk_engine_search_file (PkEngine *engine,
const gchar *filter,
const gchar *search,
- guint *job,
+ gchar **tid,
GError **error);
gboolean pk_engine_get_depends (PkEngine *engine,
const gchar *package_id,
- guint *job,
+ gchar **tid,
GError **error);
gboolean pk_engine_get_update_detail (PkEngine *engine,
const gchar *package_id,
- guint *job,
+ gchar **tid,
GError **error);
gboolean pk_engine_get_requires (PkEngine *engine,
const gchar *package_id,
- guint *job,
+ gchar **tid,
GError **error);
gboolean pk_engine_get_description (PkEngine *engine,
const gchar *package_id,
- guint *job,
+ gchar **tid,
GError **error);
gboolean pk_engine_refresh_cache (PkEngine *engine,
gboolean force,
- guint *job,
+ gchar **tid,
GError **error);
void pk_engine_update_system (PkEngine *engine,
DBusGMethodInvocation *context,
@@ -134,19 +134,19 @@ void pk_engine_update_package (PkEngi
DBusGMethodInvocation *context,
GError **error);
gboolean pk_engine_get_job_list (PkEngine *engine,
- GArray **job_list,
+ gchar ***job_list,
GError **error);
-gboolean pk_engine_get_status (PkEngine *engine,
- guint job,
+gboolean pk_engine_get_status (PkEngine *engine,
+ const gchar *tid,
const gchar **status,
GError **error);
gboolean pk_engine_get_role (PkEngine *engine,
- guint job,
+ const gchar *tid,
const gchar **status,
const gchar **package_id,
GError **error);
-gboolean pk_engine_cancel (PkEngine *engine,
- guint job,
+gboolean pk_engine_cancel (PkEngine *engine,
+ const gchar *tid,
GError **error);
gboolean pk_engine_get_actions (PkEngine *engine,
gchar **actions,
@@ -160,15 +160,15 @@ gboolean pk_engine_get_filters (PkEng
guint pk_engine_get_seconds_idle (PkEngine *engine);
gboolean pk_engine_get_percentage (PkEngine *engine,
- guint job,
+ const gchar *tid,
guint *percentage,
GError **error);
gboolean pk_engine_get_sub_percentage (PkEngine *engine,
- guint job,
+ const gchar *tid,
guint *percentage,
GError **error);
gboolean pk_engine_get_package (PkEngine *engine,
- guint job,
+ const gchar *tid,
gchar **package,
GError **error);
gboolean pk_engine_get_old_transactions (PkEngine *engine,
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index c69894e..4bc92c8 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -4,93 +4,93 @@
<!-- Schedule new jobs -->
<method name="GetUpdates">
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<method name="RefreshCache">
<arg type="b" name="force" direction="in"/>
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<method name="UpdateSystem">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<method name="SearchName">
<arg type="s" name="filter" direction="in"/>
<arg type="s" name="search" direction="in"/>
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<method name="SearchDetails">
<arg type="s" name="filter" direction="in"/>
<arg type="s" name="search" direction="in"/>
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<method name="SearchGroup">
<arg type="s" name="filter" direction="in"/>
<arg type="s" name="search" direction="in"/>
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<method name="SearchFile">
<arg type="s" name="filter" direction="in"/>
<arg type="s" name="search" direction="in"/>
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<method name="GetDepends">
<arg type="s" name="package_id" direction="in"/>
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<method name="GetRequires">
<arg type="s" name="package_id" direction="in"/>
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<method name="GetUpdateDetail">
<arg type="s" name="package_id" direction="in"/>
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<method name="GetDescription"> <!-- orders Description signals for the package -->
<arg type="s" name="package_id" direction="in"/>
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<method name="RemovePackage">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="package_id" direction="in"/>
<arg type="b" name="allow_deps" direction="in"/>
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<method name="InstallPackage">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="package_id" direction="in"/>
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<method name="UpdatePackage">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="package_id" direction="in"/>
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</method>
<!-- signals emitted from any job -->
<signal name="JobStatusChanged">
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
<arg type="s" name="status" direction="out"/> <!-- invalid,setup,download,install,update,exit -->
</signal>
<signal name="PercentageChanged"> <!-- progress of the whole job -->
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
<arg type="u" name="percentage" direction="out"/>
</signal>
<signal name="SubPercentageChanged"> <!-- progress of the intervidual transaction -->
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
<arg type="u" name="percentage" direction="out"/>
</signal>
<signal name="NoPercentageUpdates"> <!-- if we are not emmitting PercentageChanged, the UI has to spin -->
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
</signal>
<signal name="Package">
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
<arg type="u" name="value" direction="out"/> <!-- installed=1, not-installed=0 | security=1, normal=0 -->
<arg type="s" name="package_id" direction="out"/>
<arg type="s" name="summary" direction="out"/>
</signal>
<signal name="Description">
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
<arg type="s" name="package_id" direction="out"/>
<arg type="s" name="licence" direction="out"/>
<arg type="s" name="group" direction="out"/>
@@ -98,7 +98,7 @@
<arg type="s" name="url" direction="out"/>
</signal>
<signal name="UpdateDetail">
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
<arg type="s" name="package_id" direction="out"/>
<arg type="s" name="updates" direction="out"/>
<arg type="s" name="obsoletes" direction="out"/>
@@ -107,21 +107,21 @@
<arg type="s" name="update_text" direction="out"/>
</signal>
<signal name="Finished">
- <arg type="u" name="job" direction="out"/>
+ <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 job has been running in seconds -->
</signal>
<signal name="AllowInterrupt">
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
<arg type="b" name="allow_kill" direction="out"/> <!-- if the job can be SIGKILL'd -->
</signal>
<signal name="ErrorCode">
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
<arg type="s" name="code" direction="out"/> <!-- enumerated type, see helpers/README -->
<arg type="s" name="details" direction="out"/> <!-- non-localized detail -->
</signal>
<signal name="RequireRestart">
- <arg type="u" name="job" direction="out"/>
+ <arg type="s" name="tid" direction="out"/>
<arg type="s" name="type" direction="out"/> <!-- system,application,session -->
<arg type="s" name="details" direction="out"/> <!-- non-localized detail -->
</signal>
@@ -129,41 +129,41 @@
<!-- Do things or query jobs -->
<method name="Cancel"> <!-- might not succeed for all manner or reasons -->
<!-- throws NoSuchJob -->
- <arg type="u" name="job" direction="in"/>
+ <arg type="s" name="tid" direction="in"/>
</method>
<method name="GetStatus"> <!-- this is what the job is currrently doing, and might change -->
<!-- throws NoSuchJob -->
- <arg type="u" name="job" direction="in"/>
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="status" direction="out"/> <!-- query,download,install,exit -->
</method>
<method name="GetRole"> <!-- this is the master role, i.e. won't change for the lifetime of the job -->
<!-- throws NoSuchJob -->
- <arg type="u" name="job" direction="in"/>
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="status" direction="out"/> <!-- query,download,install,exit -->
<arg type="s" name="package_id" direction="out"/> <!-- what we are doing the action to, or NULL -->
</method>
<method name="GetPercentage">
<!-- throws NoSuchJob -->
- <arg type="u" name="job" direction="in"/>
+ <arg type="s" name="tid" direction="in"/>
<arg type="u" name="percentage" direction="out"/>
</method>
<method name="GetSubPercentage">
<!-- throws NoSuchJob -->
- <arg type="u" name="job" direction="in"/>
+ <arg type="s" name="tid" direction="in"/>
<arg type="u" name="percentage" direction="out"/>
</method>
<method name="GetPackage">
<!-- throws NoSuchJob -->
- <arg type="u" name="job" direction="in"/>
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="package" direction="out"/>
</method>
<!-- Job list -->
<method name="GetJobList">
- <arg type="au" name="jobs" direction="out"/>
+ <arg type="as" name="transactions" direction="out"/>
</method>
<signal name="JobListChanged">
- <arg type="au" name="jobs" direction="out"/>
+ <arg type="as" name="transactions" direction="out"/>
</signal>
<!-- Transaction methods -->
diff --git a/src/pk-marshal.list b/src/pk-marshal.list
index f91dd23..72a0ca8 100644
--- a/src/pk-marshal.list
+++ b/src/pk-marshal.list
@@ -1,16 +1,17 @@
-VOID:UINT,BOOL
-VOID:UINT,UINT
-VOID:UINT,STRING,UINT
-VOID:UINT,UINT,STRING,STRING
-VOID:UINT,STRING
VOID:UINT,STRING,STRING
-VOID:UINT,STRING,STRING,STRING
-VOID:UINT,STRING,STRING,STRING,STRING
-VOID:UINT,STRING,STRING,STRING,STRING,STRING
-VOID:UINT,STRING,STRING,STRING,STRING,STRING,STRING
+VOID:UINT,STRING
+VOID:UINT,STRING,UINT
+VOID:UINT,UINT
+VOID:STRING,BOOL
+VOID:STRING,UINT
+VOID:STRING,STRING,UINT
+VOID:STRING,UINT,STRING,STRING
VOID:STRING,STRING
+VOID:STRING,STRING,STRING
VOID:STRING,STRING,STRING,STRING
+VOID:STRING,STRING,STRING,STRING,STRING
VOID:STRING,STRING,STRING,STRING,STRING,STRING
+VOID:STRING,STRING,STRING,STRING,STRING,STRING,STRING
VOID:STRING,STRING,UINT,STRING,STRING
VOID:STRING,UINT,STRING,STRING
VOID:STRING,STRING,UINT,UINT,UINT
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index be82075..49d6a5a 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -230,7 +230,7 @@ pk_transaction_list_commit (PkTransactio
if (item == NULL) {
return FALSE;
}
- pk_debug ("marking job %i as valid", item->job);
+ pk_debug ("marking job %s as valid", item->tid);
item->valid = TRUE;
return TRUE;
}
@@ -238,27 +238,31 @@ pk_transaction_list_commit (PkTransactio
/**
* pk_transaction_list_get_array:
**/
-GArray *
+gchar **
pk_transaction_list_get_array (PkTransactionList *job_list)
{
guint i;
+ guint count = 0;
guint length;
- GArray *array;
+ gchar **array;
PkTransactionItem *item;
g_return_val_if_fail (job_list != NULL, NULL);
g_return_val_if_fail (PK_IS_JOB_LIST (job_list), NULL);
- /* create new list */
- array = g_array_new (FALSE, FALSE, sizeof (guint));
-
/* find all the jobs in progress */
length = job_list->priv->array->len;
+
+ /* create new strv list */
+ array = g_new0 (gchar *, length);
+
+ pk_debug ("%i active jobs", length);
for (i=0; i<length; i++) {
item = (PkTransactionItem *) g_ptr_array_index (job_list->priv->array, i);
/* only return in the list if it worked */
if (item->valid == TRUE) {
- array = g_array_append_val (array, item->job);
+ array[count] = g_strdup (item->tid);
+ count++;
}
}
return array;
@@ -276,10 +280,20 @@ pk_transaction_list_get_size (PkTransact
}
/**
- * pk_transaction_list_get_item_from_job:
+ * pk_tid_equal:
+ * TODO: only compare first two sections...
+ **/
+static gboolean
+pk_tid_equal (const gchar *tid1, const gchar *tid2)
+{
+ return (strcmp (tid1, tid2) == 0);
+}
+
+/**
+ * pk_transaction_list_get_item_from_tid:
**/
PkTransactionItem *
-pk_transaction_list_get_item_from_job (PkTransactionList *job_list, guint job)
+pk_transaction_list_get_item_from_tid (PkTransactionList *job_list, const gchar *tid)
{
guint i;
guint length;
@@ -292,7 +306,7 @@ pk_transaction_list_get_item_from_job (P
length = job_list->priv->array->len;
for (i=0; i<length; i++) {
item = (PkTransactionItem *) g_ptr_array_index (job_list->priv->array, i);
- if (item->job == job) {
+ if (pk_tid_equal (item->tid, tid)) {
return item;
}
}
diff --git a/src/pk-transaction-list.h b/src/pk-transaction-list.h
index 9cacb71..056d8ea 100644
--- a/src/pk-transaction-list.h
+++ b/src/pk-transaction-list.h
@@ -67,10 +67,10 @@ gboolean pk_transaction_list_commit (P
PkTask *task);
gboolean pk_transaction_list_role_present (PkTransactionList *job_list,
PkRoleEnum role);
-GArray *pk_transaction_list_get_array (PkTransactionList *job_list);
+gchar **pk_transaction_list_get_array (PkTransactionList *job_list);
guint pk_transaction_list_get_size (PkTransactionList *job_list);
-PkTransactionItem *pk_transaction_list_get_item_from_job(PkTransactionList *job_list,
- guint job);
+PkTransactionItem *pk_transaction_list_get_item_from_tid(PkTransactionList *job_list,
+ const gchar *tid);
PkTransactionItem *pk_transaction_list_get_item_from_task(PkTransactionList *job_list,
PkTask *task);
More information about the PackageKit
mailing list