[packagekit] packagekit: Branch 'master' - 13 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Tue Sep 18 13:27:23 PDT 2007
TODO | 12 +-
backends/conary/helpers/conaryBackend.py | 25 ++--
client/pk-console.c | 21 +++
docs/introduction.xml | 36 ++++++
libpackagekit/pk-enum.c | 11 +-
libpackagekit/pk-enum.h | 11 +-
libpackagekit/pk-task-client.c | 51 +++++++++
libpackagekit/pk-task-client.h | 4
libpackagekit/pk-task-monitor.c | 37 ++++++
src/Makefile.am | 8 -
src/pk-backend-internal.h | 8 -
src/pk-backend.c | 156 +++++++++++++++++++---------
src/pk-engine.c | 153 ++++++++++++++--------------
src/pk-job-list.h | 79 --------------
src/pk-self-test.c | 4
src/pk-transaction-list.c | 168 +++++++++++++++----------------
src/pk-transaction-list.h | 79 ++++++++++++++
17 files changed, 548 insertions(+), 315 deletions(-)
New commits:
diff-tree 618521ce3a600fadf4a3a1bc59e7d77461da1807 (from 040e8b4fafbfadd96f34c252318f09cd0b8ca381)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 19:36:45 2007 +0100
be more specific about roles so we can defer scheduling them until later
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 1f99367..58bdf20 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -58,7 +58,15 @@ static PkTaskEnumMatch task_status[] = {
static PkTaskEnumMatch task_role[] = {
{PK_ROLE_ENUM_UNKNOWN, "unknown"}, /* fall though value */
- {PK_ROLE_ENUM_QUERY, "query"},
+ {PK_ROLE_ENUM_GET_DEPENDS, "get-depends"},
+ {PK_ROLE_ENUM_GET_UPDATE_DETAIL, "get-update-detail"},
+ {PK_ROLE_ENUM_GET_DESCRIPTION, "get-description"},
+ {PK_ROLE_ENUM_GET_REQUIRES, "get-requires"},
+ {PK_ROLE_ENUM_GET_UPDATES, "get-updates"},
+ {PK_ROLE_ENUM_SEARCH_DETAILS, "search-details"},
+ {PK_ROLE_ENUM_SEARCH_FILE, "search-file"},
+ {PK_ROLE_ENUM_SEARCH_GROUP, "search-group"},
+ {PK_ROLE_ENUM_SEARCH_NAME, "search-name"},
{PK_ROLE_ENUM_REFRESH_CACHE, "refresh-cache"},
{PK_ROLE_ENUM_PACKAGE_REMOVE, "package-remove"},
{PK_ROLE_ENUM_PACKAGE_INSTALL, "package-install"},
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 41e5290..2d3a126 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -29,7 +29,15 @@ G_BEGIN_DECLS
/* what we asked to do */
typedef enum {
- PK_ROLE_ENUM_QUERY,
+ PK_ROLE_ENUM_GET_DEPENDS,
+ PK_ROLE_ENUM_GET_UPDATE_DETAIL,
+ PK_ROLE_ENUM_GET_DESCRIPTION,
+ PK_ROLE_ENUM_GET_REQUIRES,
+ PK_ROLE_ENUM_GET_UPDATES,
+ PK_ROLE_ENUM_SEARCH_DETAILS,
+ PK_ROLE_ENUM_SEARCH_FILE,
+ PK_ROLE_ENUM_SEARCH_GROUP,
+ PK_ROLE_ENUM_SEARCH_NAME,
PK_ROLE_ENUM_REFRESH_CACHE,
PK_ROLE_ENUM_SYSTEM_UPDATE,
PK_ROLE_ENUM_PACKAGE_REMOVE,
diff --git a/src/pk-backend-internal.h b/src/pk-backend-internal.h
index c6d8761..aaae739 100644
--- a/src/pk-backend-internal.h
+++ b/src/pk-backend-internal.h
@@ -61,9 +61,10 @@ PkEnumList *pk_backend_get_filters (Pk
gdouble pk_backend_get_runtime (PkBackend *backend);
gboolean pk_backend_load (PkBackend *backend,
const gchar *name);
+gboolean pk_backend_run (PkBackend *backend);
gboolean pk_backend_unload (PkBackend *backend);
const gchar *pk_backend_get_name (PkBackend *backend);
-gboolean pk_backend_cancel (PkBackend *backend);
+gboolean pk_backend_cancel (PkBackend *backend);
gboolean pk_backend_get_depends (PkBackend *backend,
const gchar *package_id);
gboolean pk_backend_get_update_detail (PkBackend *backend,
@@ -108,9 +109,8 @@ gboolean pk_backend_get_package (PkBa
gchar **package_id);
/* these are external in nature, but we shouldn't be using them in helpers */
-gboolean pk_backend_set_role (PkBackend *backend,
- PkRoleEnum role,
- const gchar *package_id);
+gboolean pk_backend_set_role (PkBackend *backend,
+ PkRoleEnum role);
gboolean pk_backend_not_implemented_yet (PkBackend *backend,
const gchar *method);
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 1a8f0bf..aad12ea 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -57,7 +57,11 @@ struct _PkBackendPrivate
gchar *name;
PkStatusEnum role; /* this never changes for the lifetime of a job */
PkStatusEnum status; /* this changes */
- gchar *package_id; /* never changes, this is linked to role */
+ gboolean xcached_force;
+ gboolean xcached_allow_deps;
+ gchar *xcached_package_id;
+ gchar *xcached_filter;
+ gchar *xcached_search;
PkExitEnum exit;
GTimer *timer;
PkSpawn *spawn;
@@ -557,7 +561,7 @@ pk_backend_change_sub_percentage (PkBack
* pk_backend_set_role:
**/
gboolean
-pk_backend_set_role (PkBackend *backend, PkRoleEnum role, const gchar *package_id)
+pk_backend_set_role (PkBackend *backend, PkRoleEnum role)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
@@ -567,9 +571,9 @@ pk_backend_set_role (PkBackend *backend,
pk_error ("cannot set role more than once, already %s",
pk_role_enum_to_text (backend->priv->role));
}
- pk_debug ("setting role to %s (string is '%s')", pk_role_enum_to_text (role), package_id);
+ pk_debug ("setting role to %s", pk_role_enum_to_text (role));
+ backend->priv->assigned = TRUE;
backend->priv->role = role;
- backend->priv->package_id = g_strdup (package_id);
backend->priv->status = PK_STATUS_ENUM_SETUP;
return TRUE;
}
@@ -770,7 +774,7 @@ pk_backend_get_role (PkBackend *backend,
*role = backend->priv->role;
}
if (package_id != NULL) {
- *package_id = g_strdup (backend->priv->package_id);
+ *package_id = g_strdup (backend->priv->xcached_package_id);
}
return TRUE;
}
@@ -880,6 +884,64 @@ pk_backend_cancel (PkBackend *backend)
}
/**
+ * pk_backend_run:
+ */
+gboolean
+pk_backend_run (PkBackend *backend)
+{
+ g_return_val_if_fail (backend != NULL, FALSE);
+ if (backend->priv->role == PK_ROLE_ENUM_GET_DEPENDS) {
+ backend->desc->get_depends (backend,
+ backend->priv->xcached_package_id);
+ } else if (backend->priv->role == PK_ROLE_ENUM_GET_UPDATE_DETAIL) {
+ backend->desc->get_update_detail (backend,
+ backend->priv->xcached_package_id);
+ } else if (backend->priv->role == PK_ROLE_ENUM_GET_DESCRIPTION) {
+ backend->desc->get_description (backend,
+ backend->priv->xcached_package_id);
+ } else if (backend->priv->role == PK_ROLE_ENUM_GET_REQUIRES) {
+ backend->desc->get_requires (backend,
+ backend->priv->xcached_package_id);
+ } else if (backend->priv->role == PK_ROLE_ENUM_GET_UPDATES) {
+ backend->desc->get_updates (backend);
+ } else if (backend->priv->role == PK_ROLE_ENUM_SEARCH_DETAILS) {
+ backend->desc->search_details (backend,
+ backend->priv->xcached_filter,
+ backend->priv->xcached_search);
+ } else if (backend->priv->role == PK_ROLE_ENUM_SEARCH_FILE) {
+ backend->desc->search_file (backend,
+ backend->priv->xcached_filter,
+ backend->priv->xcached_search);
+ } else if (backend->priv->role == PK_ROLE_ENUM_SEARCH_GROUP) {
+ backend->desc->search_group (backend,
+ backend->priv->xcached_filter,
+ backend->priv->xcached_search);
+ } else if (backend->priv->role == PK_ROLE_ENUM_SEARCH_NAME) {
+ backend->desc->search_name (backend,
+ backend->priv->xcached_filter,
+ backend->priv->xcached_search);
+ } else if (backend->priv->role == PK_ROLE_ENUM_PACKAGE_INSTALL) {
+ backend->desc->install_package (backend,
+ backend->priv->xcached_package_id);
+ } else if (backend->priv->role == PK_ROLE_ENUM_REFRESH_CACHE) {
+ backend->desc->refresh_cache (backend,
+ backend->priv->xcached_force);
+ } else if (backend->priv->role == PK_ROLE_ENUM_PACKAGE_REMOVE) {
+ backend->desc->remove_package (backend,
+ backend->priv->xcached_package_id,
+ backend->priv->xcached_allow_deps);
+ } else if (backend->priv->role == PK_ROLE_ENUM_PACKAGE_UPDATE) {
+ backend->desc->update_package (backend,
+ backend->priv->xcached_package_id);
+ } else if (backend->priv->role == PK_ROLE_ENUM_SYSTEM_UPDATE) {
+ backend->desc->update_system (backend);
+ } else {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
* pk_backend_get_depends:
*/
gboolean
@@ -890,9 +952,8 @@ pk_backend_get_depends (PkBackend *backe
pk_backend_not_implemented_yet (backend, "GetDepends");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_QUERY, package_id);
- backend->desc->get_depends (backend, package_id);
- backend->priv->assigned = TRUE;
+ backend->priv->xcached_package_id = g_strdup (package_id);
+ pk_backend_set_role (backend, PK_ROLE_ENUM_GET_DEPENDS);
return TRUE;
}
@@ -907,9 +968,8 @@ pk_backend_get_update_detail (PkBackend
pk_backend_not_implemented_yet (backend, "GetUpdateDetail");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_QUERY, package_id);
- backend->desc->get_update_detail (backend, package_id);
- backend->priv->assigned = TRUE;
+ backend->priv->xcached_package_id = g_strdup (package_id);
+ pk_backend_set_role (backend, PK_ROLE_ENUM_GET_UPDATE_DETAIL);
return TRUE;
}
@@ -924,9 +984,8 @@ pk_backend_get_description (PkBackend *b
pk_backend_not_implemented_yet (backend, "GetDescription");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_QUERY, package_id);
- backend->desc->get_description (backend, package_id);
- backend->priv->assigned = TRUE;
+ backend->priv->xcached_package_id = g_strdup (package_id);
+ pk_backend_set_role (backend, PK_ROLE_ENUM_GET_DESCRIPTION);
return TRUE;
}
@@ -941,9 +1000,8 @@ pk_backend_get_requires (PkBackend *back
pk_backend_not_implemented_yet (backend, "GetRequires");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_QUERY, package_id);
- backend->desc->get_requires (backend, package_id);
- backend->priv->assigned = TRUE;
+ backend->priv->xcached_package_id = g_strdup (package_id);
+ pk_backend_set_role (backend, PK_ROLE_ENUM_GET_REQUIRES);
return TRUE;
}
@@ -958,9 +1016,7 @@ pk_backend_get_updates (PkBackend *backe
pk_backend_not_implemented_yet (backend, "GetUpdates");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_QUERY, NULL);
- backend->desc->get_updates (backend);
- backend->priv->assigned = TRUE;
+ pk_backend_set_role (backend, PK_ROLE_ENUM_GET_UPDATES);
return TRUE;
}
@@ -975,9 +1031,8 @@ pk_backend_install_package (PkBackend *b
pk_backend_not_implemented_yet (backend, "InstallPackage");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_PACKAGE_INSTALL, package_id);
- backend->desc->install_package (backend, package_id);
- backend->priv->assigned = TRUE;
+ backend->priv->xcached_package_id = g_strdup (package_id);
+ pk_backend_set_role (backend, PK_ROLE_ENUM_PACKAGE_INSTALL);
return TRUE;
}
@@ -992,9 +1047,8 @@ pk_backend_refresh_cache (PkBackend *bac
pk_backend_not_implemented_yet (backend, "RefreshCache");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_REFRESH_CACHE, NULL);
- backend->desc->refresh_cache (backend, force);
- backend->priv->assigned = TRUE;
+ backend->priv->xcached_force = force;
+ pk_backend_set_role (backend, PK_ROLE_ENUM_REFRESH_CACHE);
return TRUE;
}
@@ -1009,9 +1063,9 @@ pk_backend_remove_package (PkBackend *ba
pk_backend_not_implemented_yet (backend, "RemovePackage");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_PACKAGE_REMOVE, package_id);
- backend->desc->remove_package (backend, package_id, allow_deps);
- backend->priv->assigned = TRUE;
+ backend->priv->xcached_allow_deps = allow_deps;
+ backend->priv->xcached_package_id = g_strdup (package_id);
+ pk_backend_set_role (backend, PK_ROLE_ENUM_PACKAGE_REMOVE);
return TRUE;
}
@@ -1026,9 +1080,9 @@ pk_backend_search_details (PkBackend *ba
pk_backend_not_implemented_yet (backend, "SearchDetails");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_QUERY, search);
- backend->desc->search_details (backend, filter, search);
- backend->priv->assigned = TRUE;
+ backend->priv->xcached_filter = g_strdup (filter);
+ backend->priv->xcached_search = g_strdup (search);
+ pk_backend_set_role (backend, PK_ROLE_ENUM_SEARCH_DETAILS);
return TRUE;
}
@@ -1043,9 +1097,9 @@ pk_backend_search_file (PkBackend *backe
pk_backend_not_implemented_yet (backend, "SearchFile");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_QUERY, search);
- backend->desc->search_file (backend, filter, search);
- backend->priv->assigned = TRUE;
+ backend->priv->xcached_filter = g_strdup (filter);
+ backend->priv->xcached_search = g_strdup (search);
+ pk_backend_set_role (backend, PK_ROLE_ENUM_SEARCH_FILE);
return TRUE;
}
@@ -1060,9 +1114,9 @@ pk_backend_search_group (PkBackend *back
pk_backend_not_implemented_yet (backend, "SearchGroup");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_QUERY, search);
- backend->desc->search_group (backend, filter, search);
- backend->priv->assigned = TRUE;
+ backend->priv->xcached_filter = g_strdup (filter);
+ backend->priv->xcached_search = g_strdup (search);
+ pk_backend_set_role (backend, PK_ROLE_ENUM_SEARCH_GROUP);
return TRUE;
}
@@ -1077,9 +1131,9 @@ pk_backend_search_name (PkBackend *backe
pk_backend_not_implemented_yet (backend, "SearchName");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_QUERY, search);
- backend->desc->search_name (backend, filter, search);
- backend->priv->assigned = TRUE;
+ backend->priv->xcached_filter = g_strdup (filter);
+ backend->priv->xcached_search = g_strdup (search);
+ pk_backend_set_role (backend, PK_ROLE_ENUM_SEARCH_NAME);
return TRUE;
}
@@ -1094,9 +1148,8 @@ pk_backend_update_package (PkBackend *ba
pk_backend_not_implemented_yet (backend, "UpdatePackage");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_PACKAGE_UPDATE, package_id);
- backend->desc->update_package (backend, package_id);
- backend->priv->assigned = TRUE;
+ backend->priv->xcached_package_id = g_strdup (package_id);
+ pk_backend_set_role (backend, PK_ROLE_ENUM_PACKAGE_UPDATE);
return TRUE;
}
@@ -1111,9 +1164,7 @@ pk_backend_update_system (PkBackend *bac
pk_backend_not_implemented_yet (backend, "UpdateSystem");
return FALSE;
}
- pk_backend_set_role (backend, PK_ROLE_ENUM_SYSTEM_UPDATE, NULL);
- backend->desc->update_system (backend);
- backend->priv->assigned = TRUE;
+ pk_backend_set_role (backend, PK_ROLE_ENUM_SYSTEM_UPDATE);
return TRUE;
}
@@ -1245,9 +1296,14 @@ pk_backend_finalize (GObject *object)
pk_debug ("freeing %s (%p)", backend->priv->name, backend);
g_free (backend->priv->name);
+ g_free (backend->priv->last_package);
pk_backend_unload (backend);
g_timer_destroy (backend->priv->timer);
- g_free (backend->priv->last_package);
+
+ g_free (backend->priv->xcached_package_id);
+ g_free (backend->priv->xcached_filter);
+ g_free (backend->priv->xcached_search);
+
if (backend->priv->spawn != NULL) {
pk_backend_spawn_helper_delete (backend);
}
@@ -1338,7 +1394,9 @@ pk_backend_init (PkBackend *backend)
backend->priv->assigned = FALSE;
backend->priv->is_killable = FALSE;
backend->priv->spawn = NULL;
- backend->priv->package_id = NULL;
+ backend->priv->xcached_package_id = NULL;
+ backend->priv->xcached_filter = NULL;
+ backend->priv->xcached_search = NULL;
backend->priv->last_percentage = PK_BACKEND_PERCENTAGE_INVALID;
backend->priv->last_subpercentage = PK_BACKEND_PERCENTAGE_INVALID;
backend->priv->last_package = NULL;
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 642e4e4..c291d84 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -501,6 +501,9 @@ 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);
diff-tree 040e8b4fafbfadd96f34c252318f09cd0b8ca381 (from 620e067898c155da88876a0ceb60c9bb6791bc2b)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 18:51:34 2007 +0100
rename PkJobList to PkTransactionList to better reflect what it's doing
diff --git a/src/Makefile.am b/src/Makefile.am
index cbedf63..1acef5e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -48,8 +48,6 @@ packagekitd_SOURCES = \
pk-backend.h \
pk-conf.c \
pk-conf.h \
- pk-job-list.c \
- pk-job-list.h \
pk-spawn.c \
pk-spawn.h \
pk-engine.h \
@@ -60,6 +58,8 @@ packagekitd_SOURCES = \
pk-thread-list.c \
pk-transaction-db.h \
pk-transaction-db.c \
+ pk-transaction-list.c \
+ pk-transaction-list.h \
$(NULL)
packagekitd_LDADD = \
@@ -118,8 +118,8 @@ pk_self_test_SOURCES = \
pk-network.c \
pk-thread-list.h \
pk-thread-list.c \
- pk-job-list.h \
- pk-job-list.c \
+ pk-transaction-list.h \
+ pk-transaction-list.c \
pk-self-test.c \
$(NULL)
diff --git a/src/pk-engine.c b/src/pk-engine.c
index e0833bc..642e4e4 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -47,7 +47,7 @@
#include "pk-backend-internal.h"
#include "pk-engine.h"
#include "pk-transaction-db.h"
-#include "pk-job-list.h"
+#include "pk-transaction-list.h"
#include "pk-marshal.h"
static void pk_engine_class_init (PkEngineClass *klass);
@@ -62,7 +62,7 @@ struct PkEnginePrivate
PolKitContext *pk_context;
DBusConnection *connection;
gchar *backend;
- PkJobList *job_list;
+ PkTransactionList *job_list;
PkTransactionDb *transaction_db;
};
@@ -161,7 +161,7 @@ pk_engine_job_list_changed (PkEngine *en
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- job_list = pk_job_list_get_array (engine->priv->job_list);
+ 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);
@@ -175,13 +175,13 @@ pk_engine_job_list_changed (PkEngine *en
static void
pk_engine_job_status_changed_cb (PkTask *task, PkStatusEnum status, PkEngine *engine)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
const gchar *status_text;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -199,12 +199,12 @@ pk_engine_job_status_changed_cb (PkTask
static void
pk_engine_percentage_changed_cb (PkTask *task, guint percentage, PkEngine *engine)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -220,12 +220,12 @@ pk_engine_percentage_changed_cb (PkTask
static void
pk_engine_sub_percentage_changed_cb (PkTask *task, guint percentage, PkEngine *engine)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -241,12 +241,12 @@ pk_engine_sub_percentage_changed_cb (PkT
static void
pk_engine_no_percentage_updates_cb (PkTask *task, PkEngine *engine)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -262,12 +262,12 @@ pk_engine_no_percentage_updates_cb (PkTa
static void
pk_engine_package_cb (PkTask *task, guint value, const gchar *package_id, const gchar *summary, PkEngine *engine)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -286,12 +286,12 @@ pk_engine_update_detail_cb (PkTask *task
const gchar *url, const gchar *restart,
const gchar *update_text, PkEngine *engine)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -309,13 +309,13 @@ pk_engine_update_detail_cb (PkTask *task
static void
pk_engine_error_code_cb (PkTask *task, PkErrorCodeEnum code, const gchar *details, PkEngine *engine)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
const gchar *code_text;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -332,13 +332,13 @@ pk_engine_error_code_cb (PkTask *task, P
static void
pk_engine_require_restart_cb (PkTask *task, PkRestartEnum restart, const gchar *details, PkEngine *engine)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
const gchar *restart_text;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -356,13 +356,13 @@ static void
pk_engine_description_cb (PkTask *task, const gchar *package_id, const gchar *licence, PkGroupEnum group,
const gchar *detail, const gchar *url, PkEngine *engine)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
const gchar *group_text;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -379,14 +379,14 @@ pk_engine_description_cb (PkTask *task,
static void
pk_engine_finished_cb (PkTask *task, PkExitEnum exit, PkEngine *engine)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
const gchar *exit_text;
gdouble time;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -403,7 +403,7 @@ pk_engine_finished_cb (PkTask *task, PkE
g_signal_emit (engine, signals [PK_ENGINE_FINISHED], 0, item->job, exit_text, (guint) time);
/* remove from array and unref */
- pk_job_list_remove (engine->priv->job_list, task);
+ pk_transaction_list_remove (engine->priv->job_list, task);
g_object_unref (task);
pk_debug ("removed task %p", task);
@@ -417,12 +417,12 @@ pk_engine_finished_cb (PkTask *task, PkE
static void
pk_engine_allow_interrupt_cb (PkTask *task, gboolean allow_kill, PkEngine *engine)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -479,7 +479,7 @@ pk_engine_new_task (PkEngine *engine)
/* initialise some stuff */
pk_engine_reset_timer (engine);
- pk_job_list_add (engine->priv->job_list, task);
+ pk_transaction_list_add (engine->priv->job_list, task);
/* we don't add to the array or do the job-list-changed yet
* as this job might fail */
@@ -493,16 +493,16 @@ static gboolean
pk_engine_add_task (PkEngine *engine, PkTask *task)
{
PkRoleEnum role;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* commit, so it appears in the JobList */
- pk_job_list_commit (engine->priv->job_list, task);
+ pk_transaction_list_commit (engine->priv->job_list, task);
/* get all the data we know */
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ 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);
@@ -529,7 +529,7 @@ pk_engine_delete_task (PkEngine *engine,
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
pk_debug ("removing task %p as it failed", task);
- pk_job_list_remove (engine->priv->job_list, task);
+ pk_transaction_list_remove (engine->priv->job_list, task);
/* we don't do g_object_unref (task) here as it is done in the
::finished handler */
@@ -603,7 +603,7 @@ pk_engine_refresh_cache (PkEngine *engin
{
gboolean ret;
PkTask *task;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -618,7 +618,7 @@ pk_engine_refresh_cache (PkEngine *engin
return FALSE;
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return FALSE;
@@ -636,7 +636,7 @@ pk_engine_get_updates (PkEngine *engine,
{
gboolean ret;
PkTask *task;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -651,7 +651,7 @@ pk_engine_get_updates (PkEngine *engine,
return FALSE;
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return FALSE;
@@ -722,7 +722,7 @@ pk_engine_search_name (PkEngine *engine,
{
gboolean ret;
PkTask *task;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -749,7 +749,7 @@ pk_engine_search_name (PkEngine *engine,
return FALSE;
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return FALSE;
@@ -768,7 +768,7 @@ pk_engine_search_details (PkEngine *engi
{
gboolean ret;
PkTask *task;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -795,7 +795,7 @@ pk_engine_search_details (PkEngine *engi
return FALSE;
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return FALSE;
@@ -814,7 +814,7 @@ pk_engine_search_group (PkEngine *engine
{
gboolean ret;
PkTask *task;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -841,7 +841,7 @@ pk_engine_search_group (PkEngine *engine
return FALSE;
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return FALSE;
@@ -860,7 +860,7 @@ pk_engine_search_file (PkEngine *engine,
{
gboolean ret;
PkTask *task;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -887,7 +887,7 @@ pk_engine_search_file (PkEngine *engine,
return FALSE;
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return FALSE;
@@ -906,7 +906,7 @@ pk_engine_get_depends (PkEngine *engine,
{
gboolean ret;
PkTask *task;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -929,7 +929,7 @@ pk_engine_get_depends (PkEngine *engine,
return FALSE;
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return FALSE;
@@ -948,7 +948,7 @@ pk_engine_get_requires (PkEngine *engine
{
gboolean ret;
PkTask *task;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -971,7 +971,7 @@ pk_engine_get_requires (PkEngine *engine
return FALSE;
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return FALSE;
@@ -990,7 +990,7 @@ pk_engine_get_update_detail (PkEngine *e
{
gboolean ret;
PkTask *task;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -1013,7 +1013,7 @@ pk_engine_get_update_detail (PkEngine *e
return FALSE;
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return FALSE;
@@ -1032,7 +1032,7 @@ pk_engine_get_description (PkEngine *eng
{
gboolean ret;
PkTask *task;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -1047,7 +1047,7 @@ pk_engine_get_description (PkEngine *eng
return FALSE;
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return FALSE;
@@ -1067,7 +1067,7 @@ pk_engine_update_system (PkEngine *engin
gboolean ret;
GError *error;
PkTask *task;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
@@ -1080,7 +1080,7 @@ pk_engine_update_system (PkEngine *engin
}
/* are we already performing an update? */
- if (pk_job_list_role_present (engine->priv->job_list, PK_ROLE_ENUM_SYSTEM_UPDATE) == TRUE) {
+ if (pk_transaction_list_role_present (engine->priv->job_list, PK_ROLE_ENUM_SYSTEM_UPDATE) == TRUE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_JOB_EXISTS_WITH_ROLE,
"Already performing system update");
dbus_g_method_return_error (context, error);
@@ -1099,7 +1099,7 @@ pk_engine_update_system (PkEngine *engin
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -1114,7 +1114,7 @@ void
pk_engine_remove_package (PkEngine *engine, const gchar *package_id, gboolean allow_deps,
DBusGMethodInvocation *context, GError **dead_error)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
gboolean ret;
PkTask *task;
GError *error;
@@ -1150,7 +1150,7 @@ pk_engine_remove_package (PkEngine *engi
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -1168,7 +1168,7 @@ pk_engine_install_package (PkEngine *eng
DBusGMethodInvocation *context, GError **dead_error)
{
gboolean ret;
- PkJobListItem *item;
+ PkTransactionItem *item;
PkTask *task;
GError *error;
@@ -1203,7 +1203,7 @@ pk_engine_install_package (PkEngine *eng
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -1221,7 +1221,7 @@ pk_engine_update_package (PkEngine *engi
DBusGMethodInvocation *context, GError **dead_error)
{
gboolean ret;
- PkJobListItem *item;
+ PkTransactionItem *item;
PkTask *task;
GError *error;
@@ -1256,7 +1256,7 @@ pk_engine_update_package (PkEngine *engi
}
pk_engine_add_task (engine, task);
- item = pk_job_list_get_item_from_task (engine->priv->job_list, task);
+ item = pk_transaction_list_get_item_from_task (engine->priv->job_list, task);
if (item == NULL) {
pk_warning ("could not find task");
return;
@@ -1273,7 +1273,7 @@ pk_engine_get_job_list (PkEngine *engine
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- *job_list = pk_job_list_get_array (engine->priv->job_list);
+ *job_list = pk_transaction_list_get_array (engine->priv->job_list);
return TRUE;
}
@@ -1286,12 +1286,12 @@ pk_engine_get_status (PkEngine *engine,
const gchar **status, GError **error)
{
PkStatusEnum status_enum;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_job_list_get_item_from_job (engine->priv->job_list, job);
+ item = pk_transaction_list_get_item_from_job (engine->priv->job_list, job);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_JOB,
"No job:%i", job);
@@ -1310,13 +1310,13 @@ gboolean
pk_engine_get_role (PkEngine *engine, guint job,
const gchar **role, const gchar **package_id, GError **error)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
PkRoleEnum role_enum;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_job_list_get_item_from_job (engine->priv->job_list, job);
+ item = pk_transaction_list_get_item_from_job (engine->priv->job_list, job);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_JOB,
"No job:%i", job);
@@ -1334,13 +1334,13 @@ pk_engine_get_role (PkEngine *engine, gu
gboolean
pk_engine_get_percentage (PkEngine *engine, guint job, guint *percentage, GError **error)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
gboolean ret;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_job_list_get_item_from_job (engine->priv->job_list, job);
+ item = pk_transaction_list_get_item_from_job (engine->priv->job_list, job);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_JOB,
"No job:%i", job);
@@ -1361,13 +1361,13 @@ pk_engine_get_percentage (PkEngine *engi
gboolean
pk_engine_get_sub_percentage (PkEngine *engine, guint job, guint *percentage, GError **error)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
gboolean ret;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_job_list_get_item_from_job (engine->priv->job_list, job);
+ item = pk_transaction_list_get_item_from_job (engine->priv->job_list, job);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_JOB,
"No job:%i", job);
@@ -1388,13 +1388,13 @@ pk_engine_get_sub_percentage (PkEngine *
gboolean
pk_engine_get_package (PkEngine *engine, guint job, gchar **package, GError **error)
{
- PkJobListItem *item;
+ PkTransactionItem *item;
gboolean ret;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_job_list_get_item_from_job (engine->priv->job_list, job);
+ item = pk_transaction_list_get_item_from_job (engine->priv->job_list, job);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_JOB,
"No job:%i", job);
@@ -1429,12 +1429,12 @@ gboolean
pk_engine_cancel (PkEngine *engine, guint job, GError **error)
{
gboolean ret;
- PkJobListItem *item;
+ PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_job_list_get_item_from_job (engine->priv->job_list, job);
+ item = pk_transaction_list_get_item_from_job (engine->priv->job_list, job);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_JOB,
"No job:%i", job);
@@ -1549,7 +1549,7 @@ pk_engine_get_seconds_idle (PkEngine *en
/* check for jobs running - a job that takes a *long* time might not
* give sufficient percentage updates to not be marked as idle */
- size = pk_job_list_get_size (engine->priv->job_list);
+ size = pk_transaction_list_get_size (engine->priv->job_list);
if (size != 0) {
pk_debug ("engine idle zero as %i jobs in progress", size);
return 0;
@@ -1654,7 +1654,7 @@ pk_engine_init (PkEngine *engine)
PolKitError *pk_error;
engine->priv = PK_ENGINE_GET_PRIVATE (engine);
- engine->priv->job_list = pk_job_list_new ();
+ engine->priv->job_list = pk_transaction_list_new ();
engine->priv->timer = g_timer_new ();
engine->priv->backend = NULL;
diff --git a/src/pk-job-list.c b/src/pk-job-list.c
deleted file mode 100644
index e7834cc..0000000
--- a/src/pk-job-list.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/* -*- 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.
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <errno.h>
-#include <signal.h>
-
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
-#include <glib/gi18n.h>
-#include "pk-debug.h"
-#include "pk-job-list.h"
-
-static void pk_job_list_class_init (PkJobListClass *klass);
-static void pk_job_list_init (PkJobList *job_list);
-static void pk_job_list_finalize (GObject *object);
-
-#define PK_JOB_LIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_JOB_LIST, PkJobListPrivate))
-#define PK_JOB_LIST_COUNT_FILE LOCALSTATEDIR "/run/PackageKit/job_count.dat"
-
-struct PkJobListPrivate
-{
- GPtrArray *array;
- guint job_count;
-};
-
-enum {
- PK_JOB_LIST_CHANGED,
- PK_JOB_LIST_LAST_SIGNAL
-};
-
-static guint signals [PK_JOB_LIST_LAST_SIGNAL] = { 0, };
-
-G_DEFINE_TYPE (PkJobList, pk_job_list, G_TYPE_OBJECT)
-
-/**
- * pk_job_list_load_job_count:
- **/
-static gboolean
-pk_job_list_load_job_count (PkJobList *job_list)
-{
- gboolean ret;
- gchar *contents;
- ret = g_file_get_contents (PK_JOB_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_job_list_save_job_count:
- **/
-static gboolean
-pk_job_list_save_job_count (PkJobList *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_JOB_LIST_COUNT_FILE, contents, -1, NULL);
- g_free (contents);
- if (ret == FALSE) {
- pk_warning ("failed to set last job");
- return FALSE;
- }
- return TRUE;
-}
-
-/**
- * pk_job_list_role_present:
- *
- * if there is a queued job with this role, useful to avoid having
- * multiple system updates queued
- **/
-gboolean
-pk_job_list_role_present (PkJobList *job_list, PkRoleEnum role)
-{
- guint i;
- guint length;
- PkRoleEnum role_temp;
- PkJobListItem *item;
-
- g_return_val_if_fail (job_list != NULL, FALSE);
- g_return_val_if_fail (PK_IS_JOB_LIST (job_list), FALSE);
-
- /* check for existing job doing an update */
- length = job_list->priv->array->len;
- for (i=0; i<length; i++) {
- item = (PkJobListItem *) g_ptr_array_index (job_list->priv->array, i);
- pk_backend_get_role (item->task, &role_temp, NULL);
- if (role_temp == role) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/**
- * pk_job_list_tid_get_random_hex_string:
- **/
-static gchar *
-pk_job_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_job_list_tid_id_generate:
- **/
-gchar *
-pk_job_list_tid_id_generate (void)
-{
- gchar *random;
- gchar *job;
- gchar *tid;
- random = pk_job_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_job_list_add:
- **/
-PkJobListItem *
-pk_job_list_add (PkJobList *job_list, PkTask *task)
-{
- PkJobListItem *item;
-
- 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 (PkJobListItem, 1);
- item->valid = FALSE;
- item->task = task;
- item->job = job_list->priv->job_count;
- item->tid = pk_job_list_tid_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_job_list_save_job_count (job_list);
- return item;
-}
-
-/**
- * pk_job_list_remove:
- **/
-gboolean
-pk_job_list_remove (PkJobList *job_list, PkTask *task)
-{
- PkJobListItem *item;
- g_return_val_if_fail (job_list != NULL, FALSE);
- g_return_val_if_fail (PK_IS_JOB_LIST (job_list), FALSE);
-
- item = pk_job_list_get_item_from_task (job_list, task);
- if (item == NULL) {
- return FALSE;
- }
- g_ptr_array_remove (job_list->priv->array, item);
- g_free (item->tid);
- g_free (item);
- return TRUE;
-}
-
-/**
- * pk_job_list_commit:
- **/
-gboolean
-pk_job_list_commit (PkJobList *job_list, PkTask *task)
-{
- PkJobListItem *item;
- g_return_val_if_fail (job_list != NULL, FALSE);
- g_return_val_if_fail (PK_IS_JOB_LIST (job_list), FALSE);
-
- item = pk_job_list_get_item_from_task (job_list, task);
- if (item == NULL) {
- return FALSE;
- }
- pk_debug ("marking job %i as valid", item->job);
- item->valid = TRUE;
- return TRUE;
-}
-
-/**
- * pk_job_list_get_array:
- **/
-GArray *
-pk_job_list_get_array (PkJobList *job_list)
-{
- guint i;
- guint length;
- GArray *array;
- PkJobListItem *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;
- for (i=0; i<length; i++) {
- item = (PkJobListItem *) 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);
- }
- }
- return array;
-}
-
-/**
- * pk_job_list_get_size:
- **/
-guint
-pk_job_list_get_size (PkJobList *job_list)
-{
- 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;
-}
-
-/**
- * pk_job_list_get_item_from_job:
- **/
-PkJobListItem *
-pk_job_list_get_item_from_job (PkJobList *job_list, guint job)
-{
- guint i;
- guint length;
- PkJobListItem *item;
-
- g_return_val_if_fail (job_list != NULL, NULL);
- g_return_val_if_fail (PK_IS_JOB_LIST (job_list), NULL);
-
- /* find the task with the job ID */
- length = job_list->priv->array->len;
- for (i=0; i<length; i++) {
- item = (PkJobListItem *) g_ptr_array_index (job_list->priv->array, i);
- if (item->job == job) {
- return item;
- }
- }
- return NULL;
-}
-
-/**
- * pk_job_list_get_item_from_task:
- **/
-PkJobListItem *
-pk_job_list_get_item_from_task (PkJobList *job_list, PkTask *task)
-{
- guint i;
- guint length;
- PkJobListItem *item;
-
- g_return_val_if_fail (job_list != NULL, NULL);
- g_return_val_if_fail (PK_IS_JOB_LIST (job_list), NULL);
-
- /* find the task with the job ID */
- length = job_list->priv->array->len;
- for (i=0; i<length; i++) {
- item = (PkJobListItem *) g_ptr_array_index (job_list->priv->array, i);
- if (item->task == task) {
- return item;
- }
- }
- return NULL;
-}
-
-/**
- * pk_job_list_class_init:
- * @klass: The PkJobListClass
- **/
-static void
-pk_job_list_class_init (PkJobListClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = pk_job_list_finalize;
-
- signals [PK_JOB_LIST_CHANGED] =
- g_signal_new ("changed",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- g_type_class_add_private (klass, sizeof (PkJobListPrivate));
-}
-
-/**
- * pk_job_list_init:
- * @job_list: This class instance
- **/
-static void
-pk_job_list_init (PkJobList *job_list)
-{
- job_list->priv = PK_JOB_LIST_GET_PRIVATE (job_list);
- job_list->priv->array = g_ptr_array_new ();
- job_list->priv->job_count = pk_job_list_load_job_count (job_list);
-}
-
-/**
- * pk_job_list_finalize:
- * @object: The object to finalize
- **/
-static void
-pk_job_list_finalize (GObject *object)
-{
- PkJobList *job_list;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (PK_IS_JOB_LIST (object));
-
- job_list = PK_JOB_LIST (object);
-
- 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_job_list_save_job_count (job_list);
-
- G_OBJECT_CLASS (pk_job_list_parent_class)->finalize (object);
-}
-
-/**
- * pk_job_list_new:
- *
- * Return value: a new PkJobList object.
- **/
-PkJobList *
-pk_job_list_new (void)
-{
- PkJobList *job_list;
- job_list = g_object_new (PK_TYPE_JOB_LIST, NULL);
- return PK_JOB_LIST (job_list);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef PK_BUILD_TESTS
-#include <libselftest.h>
-
-void
-libst_job_list (LibSelfTest *test)
-{
- PkJobList *job_list;
- gchar *tid;
-
- if (libst_start (test, "PkJobList", CLASS_AUTO) == FALSE) {
- return;
- }
-
- job_list = pk_job_list_new ();
-
- /************************************************************/
- libst_title (test, "make sure we get a valid tid");
- tid = pk_job_list_tid_id_generate ();
- if (tid != NULL) {
- libst_success (test, "got tid %s", tid);
- } else {
- libst_failed (test, "failed to get tid");
- }
- g_free (tid);
-
- g_object_unref (job_list);
-
- libst_end (test);
-}
-#endif
-
diff --git a/src/pk-job-list.h b/src/pk-job-list.h
deleted file mode 100644
index bd7a855..0000000
--- a/src/pk-job-list.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- 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_JOB_LIST_H
-#define __PK_JOB_LIST_H
-
-#include <glib-object.h>
-#include "pk-backend-internal.h"
-
-G_BEGIN_DECLS
-
-#define PK_TYPE_JOB_LIST (pk_job_list_get_type ())
-#define PK_JOB_LIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_JOB_LIST, PkJobList))
-#define PK_JOB_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_JOB_LIST, PkJobListClass))
-#define PK_IS_JOB_LIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_JOB_LIST))
-#define PK_IS_JOB_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_JOB_LIST))
-#define PK_JOB_LIST_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_JOB_LIST, PkJobListClass))
-#define PK_JOB_LIST_ERROR (pk_job_list_error_quark ())
-#define PK_JOB_LIST_TYPE_ERROR (pk_job_list_error_get_type ())
-
-typedef struct PkJobListPrivate PkJobListPrivate;
-
-typedef struct
-{
- GObject parent;
- PkJobListPrivate *priv;
-} PkJobList;
-
-typedef struct
-{
- GObjectClass parent_class;
-} PkJobListClass;
-
-typedef struct {
- guint job;
- gboolean valid;
- PkTask *task;
- gchar *tid;
-} PkJobListItem;
-
-GType pk_job_list_get_type (void);
-PkJobList *pk_job_list_new (void);
-
-PkJobListItem *pk_job_list_add (PkJobList *job_list,
- PkTask *task);
-gboolean pk_job_list_remove (PkJobList *job_list,
- PkTask *task);
-gboolean pk_job_list_commit (PkJobList *job_list,
- PkTask *task);
-gboolean pk_job_list_role_present (PkJobList *job_list,
- PkRoleEnum role);
-GArray *pk_job_list_get_array (PkJobList *job_list);
-guint pk_job_list_get_size (PkJobList *job_list);
-PkJobListItem *pk_job_list_get_item_from_job (PkJobList *job_list,
- guint job);
-PkJobListItem *pk_job_list_get_item_from_task (PkJobList *job_list,
- PkTask *task);
-
-G_END_DECLS
-
-#endif /* __PK_JOB_LIST_H */
diff --git a/src/pk-self-test.c b/src/pk-self-test.c
index 4a98a54..b807cf2 100644
--- a/src/pk-self-test.c
+++ b/src/pk-self-test.c
@@ -27,7 +27,7 @@
/* prototypes */
void libst_spawn (LibSelfTest *test);
void libst_thread_list (LibSelfTest *test);
-void libst_job_list (LibSelfTest *test);
+void libst_transaction_list (LibSelfTest *test);
int
main (int argc, char **argv)
@@ -44,7 +44,7 @@ main (int argc, char **argv)
/* tests go here */
libst_spawn (&test);
libst_thread_list (&test);
- libst_job_list (&test);
+ libst_transaction_list (&test);
return (libst_finish (&test));
}
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
new file mode 100644
index 0000000..be82075
--- /dev/null
+++ b/src/pk-transaction-list.c
@@ -0,0 +1,427 @@
+/* -*- 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.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <errno.h>
+#include <signal.h>
+
+#include <string.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <glib/gi18n.h>
+#include "pk-debug.h"
+#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_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 {
+ PK_TRANSACTION_LIST_CHANGED,
+ PK_TRANSACTION_LIST_LAST_SIGNAL
+};
+
+static guint signals [PK_TRANSACTION_LIST_LAST_SIGNAL] = { 0, };
+
+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
+ * multiple system updates queued
+ **/
+gboolean
+pk_transaction_list_role_present (PkTransactionList *job_list, 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);
+
+ /* check for existing job doing an update */
+ length = job_list->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);
+ if (role_temp == role) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
+ * 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 *
+pk_transaction_list_add (PkTransactionList *job_list, PkTask *task)
+{
+ PkTransactionItem *item;
+
+ 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 ();
+ 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;
+}
+
+/**
+ * pk_transaction_list_remove:
+ **/
+gboolean
+pk_transaction_list_remove (PkTransactionList *job_list, PkTask *task)
+{
+ PkTransactionItem *item;
+ g_return_val_if_fail (job_list != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_JOB_LIST (job_list), FALSE);
+
+ item = pk_transaction_list_get_item_from_task (job_list, task);
+ if (item == NULL) {
+ return FALSE;
+ }
+ g_ptr_array_remove (job_list->priv->array, item);
+ g_free (item->tid);
+ g_free (item);
+ return TRUE;
+}
+
+/**
+ * pk_transaction_list_commit:
+ **/
+gboolean
+pk_transaction_list_commit (PkTransactionList *job_list, PkTask *task)
+{
+ PkTransactionItem *item;
+ g_return_val_if_fail (job_list != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_JOB_LIST (job_list), FALSE);
+
+ item = pk_transaction_list_get_item_from_task (job_list, task);
+ if (item == NULL) {
+ return FALSE;
+ }
+ pk_debug ("marking job %i as valid", item->job);
+ item->valid = TRUE;
+ return TRUE;
+}
+
+/**
+ * pk_transaction_list_get_array:
+ **/
+GArray *
+pk_transaction_list_get_array (PkTransactionList *job_list)
+{
+ guint i;
+ guint length;
+ GArray *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;
+ 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);
+ }
+ }
+ return array;
+}
+
+/**
+ * pk_transaction_list_get_size:
+ **/
+guint
+pk_transaction_list_get_size (PkTransactionList *job_list)
+{
+ 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;
+}
+
+/**
+ * pk_transaction_list_get_item_from_job:
+ **/
+PkTransactionItem *
+pk_transaction_list_get_item_from_job (PkTransactionList *job_list, guint job)
+{
+ 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);
+
+ /* find the task with the job ID */
+ 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) {
+ return item;
+ }
+ }
+ return NULL;
+}
+
+/**
+ * pk_transaction_list_get_item_from_task:
+ **/
+PkTransactionItem *
+pk_transaction_list_get_item_from_task (PkTransactionList *job_list, PkTask *task)
+{
+ 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);
+
+ /* find the task with the job ID */
+ 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->task == task) {
+ return item;
+ }
+ }
+ return NULL;
+}
+
+/**
+ * pk_transaction_list_class_init:
+ * @klass: The PkTransactionListClass
+ **/
+static void
+pk_transaction_list_class_init (PkTransactionListClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = pk_transaction_list_finalize;
+
+ signals [PK_TRANSACTION_LIST_CHANGED] =
+ g_signal_new ("changed",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ g_type_class_add_private (klass, sizeof (PkTransactionListPrivate));
+}
+
+/**
+ * pk_transaction_list_init:
+ * @job_list: This class instance
+ **/
+static void
+pk_transaction_list_init (PkTransactionList *job_list)
+{
+ 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);
+}
+
+/**
+ * pk_transaction_list_finalize:
+ * @object: The object to finalize
+ **/
+static void
+pk_transaction_list_finalize (GObject *object)
+{
+ PkTransactionList *job_list;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (PK_IS_JOB_LIST (object));
+
+ job_list = PK_TRANSACTION_LIST (object);
+
+ 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);
+}
+
+/**
+ * pk_transaction_list_new:
+ *
+ * Return value: a new PkTransactionList object.
+ **/
+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);
+}
+
+/***************************************************************************
+ *** MAKE CHECK TESTS ***
+ ***************************************************************************/
+#ifdef PK_BUILD_TESTS
+#include <libselftest.h>
+
+void
+libst_transaction_list (LibSelfTest *test)
+{
+ PkTransactionList *job_list;
+ gchar *tid;
+
+ if (libst_start (test, "PkTransactionList", CLASS_AUTO) == FALSE) {
+ return;
+ }
+
+ job_list = pk_transaction_list_new ();
+
+ /************************************************************/
+ libst_title (test, "make sure we get a valid tid");
+ tid = pk_transaction_list_tid_id_generate ();
+ if (tid != NULL) {
+ libst_success (test, "got tid %s", tid);
+ } else {
+ libst_failed (test, "failed to get tid");
+ }
+ g_free (tid);
+
+ g_object_unref (job_list);
+
+ libst_end (test);
+}
+#endif
+
diff --git a/src/pk-transaction-list.h b/src/pk-transaction-list.h
new file mode 100644
index 0000000..9cacb71
--- /dev/null
+++ b/src/pk-transaction-list.h
@@ -0,0 +1,79 @@
+/* -*- 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_LIST_H
+#define __PK_TRANSACTION_LIST_H
+
+#include <glib-object.h>
+#include "pk-backend-internal.h"
+
+G_BEGIN_DECLS
+
+#define PK_TYPE_JOB_LIST (pk_transaction_list_get_type ())
+#define PK_TRANSACTION_LIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_JOB_LIST, PkTransactionList))
+#define PK_TRANSACTION_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_JOB_LIST, PkTransactionListClass))
+#define PK_IS_JOB_LIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_JOB_LIST))
+#define PK_IS_JOB_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_JOB_LIST))
+#define PK_TRANSACTION_LIST_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_JOB_LIST, PkTransactionListClass))
+#define PK_TRANSACTION_LIST_ERROR (pk_transaction_list_error_quark ())
+#define PK_TRANSACTION_LIST_TYPE_ERROR (pk_transaction_list_error_get_type ())
+
+typedef struct PkTransactionListPrivate PkTransactionListPrivate;
+
+typedef struct
+{
+ GObject parent;
+ PkTransactionListPrivate *priv;
+} PkTransactionList;
+
+typedef struct
+{
+ GObjectClass parent_class;
+} PkTransactionListClass;
+
+typedef struct {
+ guint job;
+ gboolean valid;
+ PkTask *task;
+ 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);
+GArray *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_task(PkTransactionList *job_list,
+ PkTask *task);
+
+G_END_DECLS
+
+#endif /* __PK_TRANSACTION_LIST_H */
diff-tree 620e067898c155da88876a0ceb60c9bb6791bc2b (from 8edc1e2be3940fdaec769f91269e0449f67b364d)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 18:33:37 2007 +0100
update TODO
diff --git a/TODO b/TODO
index d714cfd..ad4508b 100644
--- a/TODO
+++ b/TODO
@@ -10,6 +10,10 @@ NOTE: RELEASE BLOCKER
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-tree 8edc1e2be3940fdaec769f91269e0449f67b364d (from 5f99bba61424bed860e192635fc5d15dcd367afb)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 18:32:37 2007 +0100
add the new wait state
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index e322ada..1f99367 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -45,6 +45,7 @@ static PkTaskEnumMatch task_exit[] = {
static PkTaskEnumMatch task_status[] = {
{PK_STATUS_ENUM_UNKNOWN, "unknown"}, /* fall though value */
+ {PK_STATUS_ENUM_WAIT, "wait"},
{PK_STATUS_ENUM_SETUP, "setup"},
{PK_STATUS_ENUM_QUERY, "query"},
{PK_STATUS_ENUM_REFRESH_CACHE, "refresh-cache"},
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 5d48475..41e5290 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -41,6 +41,7 @@ typedef enum {
/* what we are actually doing */
typedef enum {
PK_STATUS_ENUM_SETUP,
+ PK_STATUS_ENUM_WAIT,
PK_STATUS_ENUM_QUERY,
PK_STATUS_ENUM_REMOVE,
PK_STATUS_ENUM_REFRESH_CACHE,
diff-tree 5f99bba61424bed860e192635fc5d15dcd367afb (from 7e7c2ffa2dd72e4db663bf52819e10c1f942fad2)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 18:27:49 2007 +0100
add options into documentation
diff --git a/docs/introduction.xml b/docs/introduction.xml
index 20052ac..2136244 100644
--- a/docs/introduction.xml
+++ b/docs/introduction.xml
@@ -528,6 +528,42 @@
<literal>45;dafeca;checkpoint32</literal>
</para>
</sect2>
+ <sect2 id="config-main">
+ <title>Daemon Config Options</title>
+ <para>
+ The config file <literal>/etc/PackageKit.conf</literal>allows to the
+ administrator to change system daemon options.
+ In normal use this file does not have to be changed, but it may be
+ useful to people debugging the daemon or developing backends.
+ </para>
+ <para>
+ The options are:
+ </para>
+ <sect3 id="config-main-logging">
+ <title>TransactionLogging</title>
+ <para>
+ This logs all transactions to a database so old transactions can be viewed.
+ </para>
+ </sect3>
+ <sect3 id="config-main-timeout">
+ <title>ShutdownTimeout</title>
+ <para>
+ This is the time that the daemon waits when idle before shutting down.
+ A smaller number will result in slower response times when running
+ many transactions in a small amount of time.
+ A longer timeout will lock the underlying packaging backend for longer,
+ although the daemon will start and stop less often.
+ </para>
+ </sect3>
+ <sect3 id="config-main-default">
+ <title>DefaultBackend</title>
+ <para>
+ The default backend that the daemon should use.
+ The default is set at compile time to the
+ <literal>--default-backend=</literal> configure setting.
+ </para>
+ </sect3>
+ </sect2>
</sect1>
<sect1 id="api-method-reference">
diff-tree 7e7c2ffa2dd72e4db663bf52819e10c1f942fad2 (from 2945bad94696dfb80b105837bdb53c90ac41e800)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 18 18:19:12 2007 +0100
update todo
diff --git a/TODO b/TODO
index 44cca22..d714cfd 100644
--- a/TODO
+++ b/TODO
@@ -13,6 +13,9 @@ 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.
+*** Add a way to locally install packages ***
+We have to be very careful with this, and not allow automatic installs.
+
*** Split up PolicyKit install into different types ***
Have different permissions for signed and unsigned repos.
diff-tree 2945bad94696dfb80b105837bdb53c90ac41e800 (from parents)
Merge: 83e0847eb3f59db574e47805d9b390f7ae3853ae 0f1902e99e453b98f1706ebced8b58a1245e6338
Author: Ken VanDine <ken at vandine.org>
Date: Tue Sep 18 10:58:24 2007 -0400
Merge branch 'master' of git+ssh://kvandine@git.packagekit.org/srv/git/PackageKit
diff-tree 83e0847eb3f59db574e47805d9b390f7ae3853ae (from 87f5323c2885bc58dcb190a6f71d9e8f34abad01)
Author: Ken VanDine <ken at vandine.org>
Date: Tue Sep 18 10:58:13 2007 -0400
Added percentages calls
diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 654964a..a603bd2 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -166,6 +166,7 @@ class PackageKitConaryBackend(PackageKit
pass
def refresh_cache(self):
+ self.percentage()
cache = Cache()
cache.populate_database()
@@ -233,6 +234,7 @@ class PackageKitConaryBackend(PackageKit
self.error(ERROR_INTERNAL_ERROR,'Package was not found')
def get_updates(self):
+ self.percentage()
updateItems = self.client.fullUpdateItemList()
applyList = [ (x[0], (None, None), x[1:], True) for x in updateItems ]
updJob = self.client.newUpdateJob()
diff-tree 0f1902e99e453b98f1706ebced8b58a1245e6338 (from parents)
Merge: 030e2398a039cc8f3ec849259e366edc0f7d98af 275ba554f42678fdfbbaf506eb953c217cec1c8a
Author: Elliot Peele <elliot at enki.rdu.rpath.com>
Date: Tue Sep 18 10:46:08 2007 -0400
Merge branch 'master' of git+ssh://git.packagekit.org/srv/git/PackageKit
diff-tree 030e2398a039cc8f3ec849259e366edc0f7d98af (from d7ea46a250e3c185657416b89bb3713238bf4401)
Author: Elliot Peele <elliot at enki.rdu.rpath.com>
Date: Tue Sep 18 10:45:55 2007 -0400
use dbstore driver instead of depending on external driver
diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 6ef0768..d2b0f8e 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -12,8 +12,8 @@ import sys
import os
from conary.deps import deps
-from conary import conarycfg, conaryclient, queryrep, versions, updatecmd
-from pysqlite2 import dbapi2 as sqlite
+from conary import conarycfg, conaryclient
+from conary import dbstore, queryrep, versions, updatecmd
from packagekit import *
@@ -329,11 +329,9 @@ class Cache(object):
if not os.path.isdir(self.dbPath):
os.makedirs(self.dbPath)
- self.conn = sqlite.connect(os.path.join(self.dbPath, self.dbName),
- isolation_level=None)
+ self.conn = dbstore.connect(os.path.join(self.dbPath, self.dbName))
self.cursor = self.conn.cursor()
self.cursor.execute("PRAGMA count_changes=0")
- self.cursor.execute("pragma synchronous=off")
if os.path.isfile(os.path.join(self.dbPath, self.dbName)):
self._validate_tables()
diff-tree d7ea46a250e3c185657416b89bb3713238bf4401 (from cc438e642f632255afddf146dbd5464bd29a91b0)
Author: Elliot Peele <elliot at enki.rdu.rpath.com>
Date: Tue Sep 18 10:37:45 2007 -0400
use updatecmd.parseTroveSpec
diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 654964a..6ef0768 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -12,7 +12,6 @@ import sys
import os
from conary.deps import deps
-from conary.conaryclient import cmdline
from conary import conarycfg, conaryclient, queryrep, versions, updatecmd
from pysqlite2 import dbapi2 as sqlite
@@ -20,7 +19,7 @@ from packagekit import *
class PackageKitConaryBackend(PackageKitBaseBackend):
def __init__(self, args):
- PackageKitBaseBackend.__init__(self,args)
+ PackageKitBaseBackend.__init__(self, args)
self.cfg = conarycfg.ConaryConfiguration(True)
self.cfg.initializeFlavors()
self.client = conaryclient.ConaryClient(self.cfg)
@@ -46,8 +45,8 @@ class PackageKitConaryBackend(PackageKit
def _do_search(self, searchlist, filters):
fltlist = filters.split(';')
- troveSpecs = [ cmdline.parseTroveSpec(searchlist,
- allowEmptyName=False) ]
+ troveSpecs = [ updatecmd.parseTroveSpec(searchlist,
+ allowEmptyName=False) ]
# get a hold of cached data
cache = Cache()
@@ -92,8 +91,8 @@ class PackageKitConaryBackend(PackageKit
affinityDb = self.client.db
fltlist = filters.split(';')
- troveSpecs = [ cmdline.parseTroveSpec(searchlist,
- allowEmptyName=False) ]
+ troveSpecs = [ updatecmd.parseTroveSpec(searchlist,
+ allowEmptyName=False) ]
try:
# Look for packages with affinity
@@ -307,12 +306,12 @@ class PackageKitConaryBackend(PackageKit
find a package based on a package id (name;version;arch;repoid)
'''
# Split up the id
- (name,version,arch,fullVersion) = self.get_package_from_id(id)
+ (name, version, arch, fullVersion) = self.get_package_from_id(id)
troveTuple = tuple([name,
versions.VersionFromString(fullVersion),
None])
installed = self.check_installed(troveTuple)
- return name,installed,version,arch,fullVersion
+ return name, installed, version, arch, fullVersion
class Cache(object):
diff-tree 275ba554f42678fdfbbaf506eb953c217cec1c8a (from 007b362ebdfbd2957a684a65901c458664f7f368)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Sep 17 23:21:53 2007 +0100
update TODO
diff --git a/TODO b/TODO
index 8353e1e..44cca22 100644
--- a/TODO
+++ b/TODO
@@ -23,8 +23,9 @@ We need a way to get the installed files
We need a way to work out how long something is going to take, and
to expose in the UI.
-*** Valgrind everything ***
-We leak memory like there is no tommorrow.
+*** Get Transactions ***
+Do we use a job number? Finished?
+Need to convert the role to an enum
*** task_client has to return GError ***
Client programs using libpackagekit should know the error, rather than just
diff-tree 007b362ebdfbd2957a684a65901c458664f7f368 (from 487bc629e85b556d3dbd74f6f2a48a5c773197d1)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Sep 17 23:20:28 2007 +0100
connect up the transactions client side bits.
diff --git a/client/pk-console.c b/client/pk-console.c
index c7866be..d21c2e7 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -96,6 +96,20 @@ pk_console_package_cb (PkTaskClient *tcl
}
/**
+ * pk_console_transaction_cb:
+ **/
+static void
+pk_console_transaction_cb (PkTaskClient *tclient, const gchar *tid, const gchar *timespec,
+ gboolean succeeded, const gchar *role, guint duration, gpointer data)
+{
+ g_print ("tid : %s\n", tid);
+ g_print (" timespec : %s\n", timespec);
+ g_print (" succeeded : %i\n", succeeded);
+ g_print (" role : %s\n", role /*pk_role_enum_to_text (role)*/);
+ g_print (" duration : %i (seconds)\n", duration);
+}
+
+/**
* pk_console_update_detail_cb:
**/
static void
@@ -147,6 +161,7 @@ pk_console_usage (const gchar *error)
g_print (" pkcon [sync] [verbose] get actions\n");
g_print (" pkcon [sync] [verbose] get groups\n");
g_print (" pkcon [sync] [verbose] get filters\n");
+ g_print (" pkcon [sync] [verbose] get transactions\n");
g_print ("\n");
g_print (" package_id is typically gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
}
@@ -302,6 +317,10 @@ pk_console_parse_multiple_commands (PkTa
pk_enum_list_print (elist);
g_object_unref (elist);
remove = 2;
+ } else if (strcmp (value, "transactions") == 0) {
+ pk_task_client_set_sync (tclient, TRUE);
+ pk_task_client_get_old_transactions (tclient, 10);
+ remove = 2;
} else {
pk_console_usage ("invalid get type");
}
@@ -429,6 +448,8 @@ main (int argc, char *argv[])
tclient = pk_task_client_new ();
g_signal_connect (tclient, "package",
G_CALLBACK (pk_console_package_cb), NULL);
+ g_signal_connect (tclient, "transaction",
+ G_CALLBACK (pk_console_transaction_cb), NULL);
g_signal_connect (tclient, "description",
G_CALLBACK (pk_console_description_cb), NULL);
g_signal_connect (tclient, "update-detail",
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
index ea3609f..74eee85 100644
--- a/libpackagekit/pk-task-client.c
+++ b/libpackagekit/pk-task-client.c
@@ -71,6 +71,7 @@ typedef enum {
PK_TASK_CLIENT_SUB_PERCENTAGE_CHANGED,
PK_TASK_CLIENT_NO_PERCENTAGE_UPDATES,
PK_TASK_CLIENT_PACKAGE,
+ PK_TASK_CLIENT_TRANSACTION,
PK_TASK_CLIENT_UPDATE_DETAIL,
PK_TASK_CLIENT_DESCRIPTION,
PK_TASK_CLIENT_ERROR_CODE,
@@ -979,6 +980,33 @@ pk_task_client_get_groups (PkTaskClient
}
/**
+ * pk_task_client_get_old_transactions:
+ **/
+gboolean
+pk_task_client_get_old_transactions (PkTaskClient *tclient, guint number)
+{
+ gboolean ret;
+ GError *error;
+
+ g_return_val_if_fail (tclient != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
+
+ error = NULL;
+ ret = dbus_g_proxy_call (tclient->priv->proxy, "GetOldTransactions", &error,
+ G_TYPE_UINT, number,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetOldTransactions failed :%s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+ pk_task_client_wait_if_sync (tclient);
+ return TRUE;
+}
+
+/**
* pk_task_client_get_filters:
**/
PkEnumList *
@@ -1125,6 +1153,22 @@ pk_task_client_package_cb (PkTaskMonitor
}
/**
+ * pk_task_client_transaction_cb:
+ */
+static void
+pk_task_client_transaction_cb (PkTaskMonitor *tmonitor,
+ const gchar *tid, const gchar *timespec,
+ gboolean succeeded, const gchar *role, guint duration,
+ PkTaskClient *tclient)
+{
+ g_return_if_fail (tclient != NULL);
+ g_return_if_fail (PK_IS_TASK_CLIENT (tclient));
+
+ pk_debug ("emitting transaction %s, %s, %i, %s, %i", tid, timespec, succeeded, role, duration);
+ g_signal_emit (tclient, signals [PK_TASK_CLIENT_TRANSACTION], 0, tid, timespec, succeeded, role, duration);
+}
+
+/**
* pk_task_client_update_detail_cb:
*/
static void
@@ -1235,6 +1279,11 @@ pk_task_client_class_init (PkTaskClientC
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);
+ signals [PK_TASK_CLIENT_TRANSACTION] =
+ g_signal_new ("transaction",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_BOOL_STRING_UINT,
+ G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT);
signals [PK_TASK_CLIENT_UPDATE_DETAIL] =
g_signal_new ("update-detail",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
@@ -1335,6 +1384,8 @@ pk_task_client_init (PkTaskClient *tclie
G_CALLBACK (pk_task_client_job_status_changed_cb), tclient);
g_signal_connect (tclient->priv->tmonitor, "package",
G_CALLBACK (pk_task_client_package_cb), tclient);
+ g_signal_connect (tclient->priv->tmonitor, "transaction",
+ G_CALLBACK (pk_task_client_transaction_cb), tclient);
g_signal_connect (tclient->priv->tmonitor, "update-detail",
G_CALLBACK (pk_task_client_update_detail_cb), tclient);
g_signal_connect (tclient->priv->tmonitor, "description",
diff --git a/libpackagekit/pk-task-client.h b/libpackagekit/pk-task-client.h
index d4fbd7a..3e6bb6c 100644
--- a/libpackagekit/pk-task-client.h
+++ b/libpackagekit/pk-task-client.h
@@ -98,11 +98,13 @@ gboolean pk_task_client_refresh_cache
gboolean force);
gboolean pk_task_client_install_package (PkTaskClient *tclient,
const gchar *package_id);
-gboolean pk_task_client_cancel (PkTaskClient *tclient);
+gboolean pk_task_client_cancel (PkTaskClient *tclient);
PkEnumList *pk_task_client_get_actions (PkTaskClient *tclient);
PkEnumList *pk_task_client_get_filters (PkTaskClient *tclient);
PkEnumList *pk_task_client_get_groups (PkTaskClient *tclient);
gboolean pk_task_client_reset (PkTaskClient *tclient);
+gboolean pk_task_client_get_old_transactions (PkTaskClient *tclient,
+ guint number);
G_END_DECLS
diff --git a/libpackagekit/pk-task-monitor.c b/libpackagekit/pk-task-monitor.c
index f642d6f..56a9705 100644
--- a/libpackagekit/pk-task-monitor.c
+++ b/libpackagekit/pk-task-monitor.c
@@ -59,6 +59,7 @@ typedef enum {
PK_TASK_MONITOR_SUB_PERCENTAGE_CHANGED,
PK_TASK_MONITOR_NO_PERCENTAGE_UPDATES,
PK_TASK_MONITOR_PACKAGE,
+ PK_TASK_MONITOR_TRANSACTION,
PK_TASK_MONITOR_UPDATE_DETAIL,
PK_TASK_MONITOR_DESCRIPTION,
PK_TASK_MONITOR_ERROR_CODE,
@@ -404,6 +405,22 @@ pk_task_monitor_package_cb (DBusGProxy
}
/**
+ * pk_task_monitor_transaction_cb:
+ */
+static void
+pk_task_monitor_transaction_cb (DBusGProxy *proxy,
+ const gchar *tid, const gchar *timespec,
+ gboolean succeeded, const gchar *role, guint duration,
+ PkTaskMonitor *tmonitor)
+{
+ g_return_if_fail (tmonitor != NULL);
+ g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
+
+ pk_debug ("emitting transaction %s, %s, %i, %s, %i", tid, timespec, succeeded, role, duration);
+ g_signal_emit (tmonitor, signals [PK_TASK_MONITOR_TRANSACTION], 0, tid, timespec, succeeded, role, duration);
+}
+
+/**
* pk_task_monitor_update_detail_cb:
*/
static void
@@ -529,6 +546,11 @@ pk_task_monitor_class_init (PkTaskMonito
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);
+ signals [PK_TASK_MONITOR_TRANSACTION] =
+ g_signal_new ("transaction",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_BOOL_STRING_UINT,
+ G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT);
signals [PK_TASK_MONITOR_UPDATE_DETAIL] =
g_signal_new ("update-detail",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
@@ -635,6 +657,10 @@ pk_task_monitor_init (PkTaskMonitor *tmo
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,
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,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN,
+ 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);
@@ -665,20 +691,29 @@ pk_task_monitor_init (PkTaskMonitor *tmo
G_TYPE_UINT, 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);
+
+ dbus_g_proxy_add_signal (proxy, "Transaction",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (proxy, "Transaction",
+ 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_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_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);
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);
dbus_g_proxy_connect_signal (proxy, "RequireRestart",
@@ -710,6 +745,8 @@ pk_task_monitor_finalize (GObject *objec
G_CALLBACK (pk_task_monitor_job_status_changed_cb), tmonitor);
dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "Package",
G_CALLBACK (pk_task_monitor_package_cb), tmonitor);
+ dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "Transaction",
+ G_CALLBACK (pk_task_monitor_transaction_cb), tmonitor);
dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "Description",
G_CALLBACK (pk_task_monitor_description_cb), tmonitor);
dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "ErrorCode",
More information about the PackageKit
mailing list