[packagekit] packagekit: Branch 'master' - 6 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Fri Aug 31 07:10:25 PDT 2007
TODO | 3 ++
libpackagekit/pk-task-client.c | 57 ----------------------------------------
libpackagekit/pk-task-client.h | 5 ---
libpackagekit/pk-task-list.c | 23 ++++++++++++----
libpackagekit/pk-task-list.h | 3 +-
libpackagekit/pk-task-monitor.c | 37 +++++++++++++++++++++++++
libpackagekit/pk-task-monitor.h | 3 ++
libpackagekit/pk-task-utils.c | 29 ++++++++++++++++++++
libpackagekit/pk-task-utils.h | 15 ++++++++++
libselftest/libselftest.c | 16 +++++++----
src/pk-engine.c | 14 ++++-----
src/pk-task-apt.cpp | 5 +--
src/pk-task-common.c | 15 ++++------
src/pk-task-common.h | 4 +-
src/pk-task-conary.c | 22 +++++++--------
src/pk-task-dummy.c | 26 +++++++++---------
src/pk-task-yum.c | 24 ++++++++--------
17 files changed, 172 insertions(+), 129 deletions(-)
New commits:
diff-tree b7dd1651e72d6327922b55c2d8d72c14c087e91b (from a3626e52e1a5a4e2e4d19bcdb2489dd1e7063969)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Aug 31 14:40:18 2007 +0100
role and status are very different things, don't try to piggyback the enums
diff --git a/TODO b/TODO
index df558d5..0b231d9 100644
--- a/TODO
+++ b/TODO
@@ -10,6 +10,9 @@ Core:
* Add GetPercentage and GetSubPercentage for coldplugging
* Add a Launch() method to startup when pk-application is launched
* task_client has to return GError
+* Add logging so we can see what was installed/removed and when
+* Add "when installed" data into description
+* Add "installed by 'Richard Hughes'" data into description
Backends:
* Complete conary backend
diff --git a/libpackagekit/pk-task-list.h b/libpackagekit/pk-task-list.h
index a677293..3fc2250 100644
--- a/libpackagekit/pk-task-list.h
+++ b/libpackagekit/pk-task-list.h
@@ -41,7 +41,7 @@ typedef struct
{
guint job;
PkTaskStatus status;
- PkTaskStatus role;
+ PkTaskRole role;
gchar *package_id;
PkTaskMonitor *monitor;
gboolean valid;
diff --git a/libpackagekit/pk-task-monitor.c b/libpackagekit/pk-task-monitor.c
index 1fb2045..ed14568 100644
--- a/libpackagekit/pk-task-monitor.c
+++ b/libpackagekit/pk-task-monitor.c
@@ -127,15 +127,15 @@ pk_task_monitor_get_status (PkTaskMonito
* pk_task_monitor_get_role:
**/
gboolean
-pk_task_monitor_get_role (PkTaskMonitor *tmonitor, PkTaskStatus *status, gchar **package_id)
+pk_task_monitor_get_role (PkTaskMonitor *tmonitor, PkTaskRole *role, gchar **package_id)
{
gboolean ret;
GError *error;
- gchar *status_text;
+ gchar *role_text;
gchar *package_id_temp;
g_return_val_if_fail (tmonitor != NULL, FALSE);
- g_return_val_if_fail (status != 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);
@@ -143,7 +143,7 @@ pk_task_monitor_get_role (PkTaskMonitor
ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetJobRole", &error,
G_TYPE_UINT, tmonitor->priv->job,
G_TYPE_INVALID,
- G_TYPE_STRING, &status_text,
+ G_TYPE_STRING, &role_text,
G_TYPE_STRING, &package_id_temp,
G_TYPE_INVALID);
if (ret == FALSE) {
@@ -152,7 +152,7 @@ pk_task_monitor_get_role (PkTaskMonitor
g_error_free (error);
return FALSE;
}
- *status = pk_task_status_from_text (status_text);
+ *role = pk_task_role_from_text (role_text);
if (package_id != NULL) {
*package_id = g_strdup (package_id_temp);
}
diff --git a/libpackagekit/pk-task-monitor.h b/libpackagekit/pk-task-monitor.h
index 4aaeed1..c8109f9 100644
--- a/libpackagekit/pk-task-monitor.h
+++ b/libpackagekit/pk-task-monitor.h
@@ -56,7 +56,7 @@ guint pk_task_monitor_get_job (PkTask
gboolean pk_task_monitor_get_status (PkTaskMonitor *tmonitor,
PkTaskStatus *status);
gboolean pk_task_monitor_get_role (PkTaskMonitor *tmonitor,
- PkTaskStatus *status,
+ PkTaskRole *role,
gchar **package_id);
G_END_DECLS
diff --git a/libpackagekit/pk-task-utils.c b/libpackagekit/pk-task-utils.c
index b547e56..d7b6ea4 100644
--- a/libpackagekit/pk-task-utils.c
+++ b/libpackagekit/pk-task-utils.c
@@ -55,6 +55,17 @@ static PkTaskEnumMatch task_status[] = {
{0, NULL},
};
+static PkTaskEnumMatch task_role[] = {
+ {PK_TASK_ROLE_UNKNOWN, "unknown"}, /* fall though value */
+ {PK_TASK_ROLE_QUERY, "query"},
+ {PK_TASK_ROLE_REFRESH_CACHE, "refresh-cache"},
+ {PK_TASK_ROLE_PACKAGE_REMOVE, "package-remove"},
+ {PK_TASK_ROLE_PACKAGE_INSTALL, "package-install"},
+ {PK_TASK_ROLE_PACKAGE_UPDATE, "package-update"},
+ {PK_TASK_ROLE_SYSTEM_UPDATE, "system-update"},
+ {0, NULL},
+};
+
static PkTaskEnumMatch task_error[] = {
{PK_TASK_ERROR_CODE_UNKNOWN, "unknown"}, /* fall though value */
{PK_TASK_ERROR_CODE_NO_NETWORK, "no-network"},
@@ -194,6 +205,24 @@ pk_task_status_to_text (PkTaskStatus sta
}
/**
+ * pk_task_role_from_text:
+ **/
+PkTaskRole
+pk_task_role_from_text (const gchar *role)
+{
+ return pk_task_enum_find_value (task_role, role);
+}
+
+/**
+ * pk_task_role_to_text:
+ **/
+const gchar *
+pk_task_role_to_text (PkTaskRole role)
+{
+ return pk_task_enum_find_string (task_role, role);
+}
+
+/**
* pk_task_error_code_from_text:
**/
PkTaskErrorCode
diff --git a/libpackagekit/pk-task-utils.h b/libpackagekit/pk-task-utils.h
index f932901..6ae3864 100644
--- a/libpackagekit/pk-task-utils.h
+++ b/libpackagekit/pk-task-utils.h
@@ -26,6 +26,18 @@
G_BEGIN_DECLS
+/* what we asked to do */
+typedef enum {
+ PK_TASK_ROLE_QUERY,
+ PK_TASK_ROLE_REFRESH_CACHE,
+ PK_TASK_ROLE_SYSTEM_UPDATE,
+ PK_TASK_ROLE_PACKAGE_REMOVE,
+ PK_TASK_ROLE_PACKAGE_INSTALL,
+ PK_TASK_ROLE_PACKAGE_UPDATE,
+ PK_TASK_ROLE_UNKNOWN
+} PkTaskRole;
+
+/* what we are actually doing */
typedef enum {
PK_TASK_STATUS_SETUP,
PK_TASK_STATUS_QUERY,
@@ -102,6 +114,9 @@ const gchar *pk_task_exit_to_text (PkT
PkTaskStatus pk_task_status_from_text (const gchar *status);
const gchar *pk_task_status_to_text (PkTaskStatus status);
+PkTaskRole pk_task_role_from_text (const gchar *role);
+const gchar *pk_task_role_to_text (PkTaskRole role);
+
PkTaskErrorCode pk_task_error_code_from_text (const gchar *code);
const gchar *pk_task_error_code_to_text (PkTaskErrorCode code);
diff --git a/src/pk-engine.c b/src/pk-engine.c
index b0d1928..1491747 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -863,7 +863,7 @@ pk_engine_update_system (PkEngine *engin
guint i;
guint job;
guint length;
- PkTaskStatus status;
+ PkTaskRole role;
PkTask *task;
gboolean ret;
GError *error;
@@ -882,8 +882,8 @@ pk_engine_update_system (PkEngine *engin
length = engine->priv->array->len;
for (i=0; i<length; i++) {
task = (PkTask *) g_ptr_array_index (engine->priv->array, i);
- ret = pk_task_get_job_status (task, &status);
- if (ret == TRUE && status == PK_TASK_STATUS_UPDATE) {
+ ret = pk_task_get_job_role (task, &role, NULL);
+ if (ret == TRUE && role == PK_TASK_ROLE_SYSTEM_UPDATE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_DENIED,
"operation not yet supported by backend");
dbus_g_method_return_error (context, error);
@@ -1096,10 +1096,10 @@ pk_engine_get_job_status (PkEngine *engi
**/
gboolean
pk_engine_get_job_role (PkEngine *engine, guint job,
- const gchar **status, const gchar **package_id, GError **error)
+ const gchar **role, const gchar **package_id, GError **error)
{
PkTask *task;
- PkTaskStatus status_enum;
+ PkTaskRole role_enum;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -1110,8 +1110,8 @@ pk_engine_get_job_role (PkEngine *engine
"No job:%i", job);
return FALSE;
}
- pk_task_get_job_role (task, &status_enum, package_id);
- *status = g_strdup (pk_task_status_to_text (status_enum));
+ pk_task_get_job_role (task, &role_enum, package_id);
+ *role = g_strdup (pk_task_role_to_text (role_enum));
return TRUE;
}
diff --git a/src/pk-task-common.c b/src/pk-task-common.c
index 54d52e7..193ba2d 100644
--- a/src/pk-task-common.c
+++ b/src/pk-task-common.c
@@ -388,18 +388,17 @@ pk_task_change_sub_percentage (PkTask *t
* pk_task_set_job_role:
**/
gboolean
-pk_task_set_job_role (PkTask *task, PkTaskStatus status, const gchar *package_id)
+pk_task_set_job_role (PkTask *task, PkTaskRole role, const gchar *package_id)
{
g_return_val_if_fail (task != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK (task), FALSE);
/* Should only be called once... */
- if (task->role != PK_TASK_STATUS_UNKNOWN) {
+ if (task->role != PK_TASK_ROLE_UNKNOWN) {
pk_error ("cannot set role more than once, already %i", task->role);
}
- pk_debug ("setting role to %i %s", status, package_id);
- task->role = status;
- task->status = status;
+ pk_debug ("setting role to %i (%s)", role, package_id);
+ task->role = role;
task->package_id = g_strdup (package_id);
return TRUE;
}
@@ -508,7 +507,7 @@ pk_task_get_job_status (PkTask *task, Pk
* pk_task_get_job_role:
**/
gboolean
-pk_task_get_job_role (PkTask *task, PkTaskStatus *status, const gchar **package_id)
+pk_task_get_job_role (PkTask *task, PkTaskRole *role, const gchar **package_id)
{
g_return_val_if_fail (task != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK (task), FALSE);
@@ -518,7 +517,7 @@ pk_task_get_job_role (PkTask *task, PkTa
pk_warning ("Not assigned");
return FALSE;
}
- *status = task->role;
+ *role = task->role;
*package_id = g_strdup (task->package_id);
return TRUE;
}
@@ -639,7 +638,7 @@ pk_task_common_init (PkTask *task)
task->is_killable = FALSE;
task->spawn = NULL;
task->package_id = NULL;
- task->role = PK_TASK_STATUS_UNKNOWN;
+ task->role = PK_TASK_ROLE_UNKNOWN;
task->status = PK_TASK_STATUS_UNKNOWN;
task->exit = PK_TASK_EXIT_UNKNOWN;
diff --git a/src/pk-task-common.h b/src/pk-task-common.h
index c4687ba..43388de 100644
--- a/src/pk-task-common.h
+++ b/src/pk-task-common.h
@@ -41,10 +41,10 @@ gboolean pk_task_change_job_status (Pk
gboolean pk_task_get_job_status (PkTask *task,
PkTaskStatus *status);
gboolean pk_task_set_job_role (PkTask *task,
- PkTaskStatus status,
+ PkTaskRole role,
const gchar *package_id);
gboolean pk_task_get_job_role (PkTask *task,
- PkTaskStatus *status,
+ PkTaskRole *role,
const gchar **package_id);
gboolean pk_task_no_percentage_updates (PkTask *task);
gboolean pk_task_finished (PkTask *task,
diff --git a/src/pk-task-conary.c b/src/pk-task-conary.c
index fd56c09..cbd73c3 100644
--- a/src/pk-task-conary.c
+++ b/src/pk-task-conary.c
@@ -94,7 +94,7 @@ pk_task_get_updates (PkTask *task)
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, NULL);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, NULL);
pk_task_spawn_helper (task, "get-updates.py", NULL);
return TRUE;
}
@@ -120,7 +120,7 @@ pk_task_refresh_cache (PkTask *task, gbo
}
/* easy as that */
- pk_task_set_job_role (task, PK_TASK_STATUS_REFRESH_CACHE, NULL);
+ pk_task_set_job_role (task, PK_TASK_ROLE_REFRESH_CACHE, NULL);
pk_task_spawn_helper (task, "refresh-cache.py", NULL);
return TRUE;
@@ -139,7 +139,7 @@ pk_task_update_system (PkTask *task)
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_UPDATE, NULL);
+ pk_task_set_job_role (task, PK_TASK_ROLE_SYSTEM_UPDATE, NULL);
pk_task_not_implemented_yet (task, "UpdateSystem");
return TRUE;
}
@@ -188,7 +188,7 @@ pk_task_search_details (PkTask *task, co
return TRUE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, search);
pk_task_spawn_helper (task, "search-details.py", filter, search, NULL);
return TRUE;
}
@@ -199,7 +199,7 @@ pk_task_search_details (PkTask *task, co
gboolean
pk_task_search_group (PkTask *task, const gchar *filter, const gchar *search)
{
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, search);
pk_task_not_implemented_yet (task, "SearchGroup");
return TRUE;
}
@@ -210,7 +210,7 @@ pk_task_search_group (PkTask *task, cons
gboolean
pk_task_search_file (PkTask *task, const gchar *filter, const gchar *search)
{
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, search);
pk_task_not_implemented_yet (task, "SearchFile");
return TRUE;
}
@@ -228,7 +228,7 @@ pk_task_get_deps (PkTask *task, const gc
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, package_id);
pk_task_not_implemented_yet (task, "GetDeps");
return TRUE;
}
@@ -246,7 +246,7 @@ pk_task_get_description (PkTask *task, c
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, package_id);
pk_task_not_implemented_yet (task, "GetDescription");
return TRUE;
}
@@ -264,7 +264,7 @@ pk_task_remove_package (PkTask *task, co
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_REMOVE, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_PACKAGE_REMOVE, package_id);
pk_task_not_implemented_yet (task, "RemovePackage");
return TRUE;
}
@@ -289,7 +289,7 @@ pk_task_install_package (PkTask *task, c
return TRUE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_INSTALL, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_PACKAGE_INSTALL, package_id);
pk_task_not_implemented_yet (task, "InstallPackage");
return TRUE;
}
@@ -314,7 +314,7 @@ pk_task_update_package (PkTask *task, co
return TRUE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_UPDATE, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_PACKAGE_UPDATE, package_id);
pk_task_not_implemented_yet (task, "UpdatePackage");
return TRUE;
}
diff --git a/src/pk-task-dummy.c b/src/pk-task-dummy.c
index a3cb3fb..7c15606 100644
--- a/src/pk-task-dummy.c
+++ b/src/pk-task-dummy.c
@@ -89,7 +89,7 @@ pk_task_get_updates (PkTask *task)
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, NULL);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, NULL);
pk_task_package (task, 0, "powertop;1.8-1.fc8;i386;fedora",
"Power consumption monitor");
pk_task_package (task, 1, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
@@ -112,7 +112,7 @@ pk_task_refresh_cache (PkTask *task, gbo
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_REFRESH_CACHE, NULL);
+ pk_task_set_job_role (task, PK_TASK_ROLE_REFRESH_CACHE, NULL);
pk_task_finished (task, PK_TASK_EXIT_SUCCESS);
return TRUE;
}
@@ -145,7 +145,7 @@ pk_task_update_system (PkTask *task)
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_UPDATE, NULL);
+ pk_task_set_job_role (task, PK_TASK_ROLE_SYSTEM_UPDATE, NULL);
pk_task_change_job_status (task, PK_TASK_STATUS_DOWNLOAD);
task->priv->progress_percentage = 0;
pk_task_require_restart (task, PK_TASK_RESTART_SYSTEM, NULL);
@@ -186,7 +186,7 @@ pk_task_search_name (PkTask *task, const
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, search);
pk_task_no_percentage_updates (task);
g_timeout_add (2000, pk_task_search_name_timeout, task);
@@ -199,7 +199,7 @@ pk_task_search_name (PkTask *task, const
gboolean
pk_task_search_details (PkTask *task, const gchar *filter, const gchar *search)
{
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, search);
pk_task_package (task, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
"The vips documentation package.");
pk_task_finished (task, PK_TASK_EXIT_SUCCESS);
@@ -212,7 +212,7 @@ pk_task_search_details (PkTask *task, co
gboolean
pk_task_search_group (PkTask *task, const gchar *filter, const gchar *search)
{
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, search);
pk_task_package (task, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
"The vips documentation package.");
pk_task_finished (task, PK_TASK_EXIT_SUCCESS);
@@ -225,7 +225,7 @@ pk_task_search_group (PkTask *task, cons
gboolean
pk_task_search_file (PkTask *task, const gchar *filter, const gchar *search)
{
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, search);
pk_task_package (task, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
"The vips documentation package.");
pk_task_finished (task, PK_TASK_EXIT_SUCCESS);
@@ -245,7 +245,7 @@ pk_task_get_deps (PkTask *task, const gc
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, package_id);
pk_task_package (task, 1, "glib2;2.14.0;i386;fedora",
"The GLib library");
pk_task_package (task, 1, "gtk2;gtk2-2.11.6-6.fc8;i386;fedora",
@@ -268,7 +268,7 @@ pk_task_get_description (PkTask *task, c
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, package_id);
pk_task_description (task, "gnome-power-manager;2.6.19;i386;fedora", PK_TASK_GROUP_PROGRAMMING,
"Scribus is an desktop open source page layout program with "
"the aim of producing commercial grade output in PDF and "
@@ -296,7 +296,7 @@ pk_task_remove_package (PkTask *task, co
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_REMOVE, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_PACKAGE_REMOVE, package_id);
pk_task_error_code (task, PK_TASK_ERROR_CODE_NO_NETWORK, "No network connection available");
pk_task_finished (task, PK_TASK_EXIT_FAILED);
@@ -332,7 +332,7 @@ pk_task_install_package (PkTask *task, c
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_INSTALL, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_PACKAGE_INSTALL, package_id);
task->priv->progress_percentage = 0;
g_timeout_add (1000, pk_task_install_timeout, task);
return TRUE;
@@ -351,7 +351,7 @@ pk_task_update_package (PkTask *task, co
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_UPDATE, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_PACKAGE_UPDATE, package_id);
pk_task_package (task, 1, package_id, "The same thing");
pk_task_finished (task, PK_TASK_EXIT_SUCCESS);
return TRUE;
diff --git a/src/pk-task-yum.c b/src/pk-task-yum.c
index 40e4dde..6328d4b 100644
--- a/src/pk-task-yum.c
+++ b/src/pk-task-yum.c
@@ -93,7 +93,7 @@ pk_task_get_updates (PkTask *task)
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, NULL);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, NULL);
pk_task_spawn_helper (task, "get-updates.py", NULL);
return TRUE;
}
@@ -119,7 +119,7 @@ pk_task_refresh_cache (PkTask *task, gbo
}
/* easy as that */
- pk_task_set_job_role (task, PK_TASK_STATUS_REFRESH_CACHE, NULL);
+ pk_task_set_job_role (task, PK_TASK_ROLE_REFRESH_CACHE, NULL);
pk_task_spawn_helper (task, "refresh-cache.py", NULL);
return TRUE;
@@ -138,7 +138,7 @@ pk_task_update_system (PkTask *task)
return FALSE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_UPDATE, NULL);
+ pk_task_set_job_role (task, PK_TASK_ROLE_SYSTEM_UPDATE, NULL);
pk_task_spawn_helper (task, "update-system.py", NULL);
return TRUE;
}
@@ -160,7 +160,7 @@ pk_task_search_name (PkTask *task, const
pk_task_allow_interrupt (task, TRUE);
pk_task_no_percentage_updates (task);
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, search);
pk_task_spawn_helper (task, "search-name.py", filter, search, NULL);
return TRUE;
}
@@ -187,7 +187,7 @@ pk_task_search_details (PkTask *task, co
/* only copy this code if you can kill the process with no ill effect */
pk_task_allow_interrupt (task, TRUE);
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, search);
pk_task_spawn_helper (task, "search-details.py", filter, search, NULL);
return TRUE;
}
@@ -214,7 +214,7 @@ pk_task_search_group (PkTask *task, cons
/* only copy this code if you can kill the process with no ill effect */
pk_task_allow_interrupt (task, TRUE);
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, search);
pk_task_spawn_helper (task, "search-group.py", filter, search, NULL);
return TRUE;
}
@@ -240,7 +240,7 @@ pk_task_search_file (PkTask *task, const
/* only copy this code if you can kill the process with no ill effect */
pk_task_allow_interrupt (task, TRUE);
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, search);
pk_task_not_implemented_yet (task, "SearchFile");
return TRUE;
@@ -262,7 +262,7 @@ pk_task_get_deps (PkTask *task, const gc
/* only copy this code if you can kill the process with no ill effect */
pk_task_allow_interrupt (task, TRUE);
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, package_id);
pk_task_spawn_helper (task, "get-deps.py", package_id, NULL);
return TRUE;
}
@@ -283,7 +283,7 @@ pk_task_get_description (PkTask *task, c
/* only copy this code if you can kill the process with no ill effect */
pk_task_allow_interrupt (task, TRUE);
- pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, package_id);
pk_task_spawn_helper (task, "get-description.py", package_id, NULL);
return TRUE;
}
@@ -308,7 +308,7 @@ pk_task_remove_package (PkTask *task, co
deps = "no";
}
- pk_task_set_job_role (task, PK_TASK_STATUS_REMOVE, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_PACKAGE_REMOVE, package_id);
pk_task_spawn_helper (task, "remove.py", deps, package_id, NULL);
return TRUE;
}
@@ -333,7 +333,7 @@ pk_task_install_package (PkTask *task, c
return TRUE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_INSTALL, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_PACKAGE_INSTALL, package_id);
pk_task_spawn_helper (task, "install.py", package_id, NULL);
return TRUE;
}
@@ -358,7 +358,7 @@ pk_task_update_package (PkTask *task, co
return TRUE;
}
- pk_task_set_job_role (task, PK_TASK_STATUS_UPDATE, package_id);
+ pk_task_set_job_role (task, PK_TASK_ROLE_PACKAGE_UPDATE, package_id);
pk_task_spawn_helper (task, "update.py", package_id, NULL);
return TRUE;
}
diff-tree a3626e52e1a5a4e2e4d19bcdb2489dd1e7063969 (from b6d857de562e32ac89b6c7a4e6aeb1a486e74945)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Aug 31 14:13:19 2007 +0100
fix GetJobRole and make dummy backend do something interesting
diff --git a/libpackagekit/pk-task-monitor.c b/libpackagekit/pk-task-monitor.c
index 17b0848..1fb2045 100644
--- a/libpackagekit/pk-task-monitor.c
+++ b/libpackagekit/pk-task-monitor.c
@@ -141,13 +141,14 @@ pk_task_monitor_get_role (PkTaskMonitor
error = NULL;
ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetJobRole", &error,
+ G_TYPE_UINT, tmonitor->priv->job,
G_TYPE_INVALID,
G_TYPE_STRING, &status_text,
G_TYPE_STRING, &package_id_temp,
G_TYPE_INVALID);
if (ret == FALSE) {
/* abort as the DBUS method failed */
- pk_warning ("GetJobStatus failed :%s", error->message);
+ pk_warning ("GetJobRole failed :%s", error->message);
g_error_free (error);
return FALSE;
}
diff --git a/src/pk-task-dummy.c b/src/pk-task-dummy.c
index a7a2bfe..a3cb3fb 100644
--- a/src/pk-task-dummy.c
+++ b/src/pk-task-dummy.c
@@ -125,6 +125,7 @@ pk_task_update_system_timeout (gpointer
pk_task_finished (task, PK_TASK_EXIT_SUCCESS);
return FALSE;
}
+ pk_task_change_job_status (task, PK_TASK_STATUS_UPDATE);
task->priv->progress_percentage += 10;
pk_task_change_percentage (task, task->priv->progress_percentage);
return TRUE;
@@ -145,6 +146,7 @@ pk_task_update_system (PkTask *task)
}
pk_task_set_job_role (task, PK_TASK_STATUS_UPDATE, NULL);
+ pk_task_change_job_status (task, PK_TASK_STATUS_DOWNLOAD);
task->priv->progress_percentage = 0;
pk_task_require_restart (task, PK_TASK_RESTART_SYSTEM, NULL);
g_timeout_add (1000, pk_task_update_system_timeout, task);
diff-tree b6d857de562e32ac89b6c7a4e6aeb1a486e74945 (from aa98d658186814fe5eee606ab2f8521eb8fe624a)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Aug 31 13:58:00 2007 +0100
make the PkTaskList aware of role
diff --git a/libpackagekit/pk-task-list.c b/libpackagekit/pk-task-list.c
index 9e8fd3e..be9d58d 100644
--- a/libpackagekit/pk-task-list.c
+++ b/libpackagekit/pk-task-list.c
@@ -85,7 +85,7 @@ pk_task_list_print (PkTaskList *tlist)
}
for (i=0; i<length; i++) {
item = g_ptr_array_index (tlist->priv->task_list, i);
- g_print ("%i %s %s", item->job, pk_task_status_to_text (item->status), item->package);
+ g_print ("%i %s %s", item->job, pk_task_status_to_text (item->role), item->package_id);
}
g_print ("\n");
return TRUE;
@@ -153,8 +153,8 @@ pk_task_list_job_finished_cb (PkTaskMoni
/* get correct item */
item = pk_task_list_find_existing_job (tlist, job);
- pk_debug ("emit task-list-finished %i, %s, %i", item->status, item->package, runtime);
- g_signal_emit (tlist , signals [PK_TASK_LIST_FINISHED], 0, item->status, item->package, runtime);
+ pk_debug ("emit task-list-finished %i, %s, %i", item->status, item->package_id, runtime);
+ g_signal_emit (tlist , signals [PK_TASK_LIST_FINISHED], 0, item->status, item->package_id, runtime);
}
/**
@@ -215,8 +215,8 @@ pk_task_list_refresh (PkTaskList *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_get_role (item->monitor, &item->role, &item->package_id);
pk_task_monitor_get_status (item->monitor, &item->status);
- item->package = NULL;
/* add to watched array */
g_ptr_array_add (tlist->priv->task_list, item);
@@ -232,7 +232,7 @@ pk_task_list_refresh (PkTaskList *tlist)
if (item->valid == FALSE) {
pk_debug ("remove %i", item->job);
g_object_unref (item->monitor);
- g_free (item->package);
+ g_free (item->package_id);
g_ptr_array_remove (tlist->priv->task_list, item);
g_free (item);
}
@@ -321,12 +321,25 @@ pk_task_list_init (PkTaskList *tlist)
static void
pk_task_list_finalize (GObject *object)
{
+ guint i;
+ PkTaskListItem *item;
PkTaskList *tlist;
+
g_return_if_fail (object != NULL);
g_return_if_fail (PK_IS_TASK_LIST (object));
tlist = PK_TASK_LIST (object);
g_return_if_fail (tlist->priv != NULL);
+ /* 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);
+ g_object_unref (item->monitor);
+ g_free (item->package_id);
+ g_ptr_array_remove (tlist->priv->task_list, item);
+ g_free (item);
+ }
+
g_ptr_array_free (tlist->priv->task_list, TRUE);
g_object_unref (tlist->priv->job_list);
diff --git a/libpackagekit/pk-task-list.h b/libpackagekit/pk-task-list.h
index a55398e..a677293 100644
--- a/libpackagekit/pk-task-list.h
+++ b/libpackagekit/pk-task-list.h
@@ -41,7 +41,8 @@ typedef struct
{
guint job;
PkTaskStatus status;
- gchar *package;
+ PkTaskStatus role;
+ gchar *package_id;
PkTaskMonitor *monitor;
gboolean valid;
} PkTaskListItem;
diff --git a/libpackagekit/pk-task-monitor.c b/libpackagekit/pk-task-monitor.c
index 7114259..17b0848 100644
--- a/libpackagekit/pk-task-monitor.c
+++ b/libpackagekit/pk-task-monitor.c
@@ -100,6 +100,7 @@ pk_task_monitor_get_status (PkTaskMonito
GError *error;
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);
@@ -126,13 +127,15 @@ pk_task_monitor_get_status (PkTaskMonito
* pk_task_monitor_get_role:
**/
gboolean
-pk_task_monitor_get_role (PkTaskMonitor *tmonitor, PkTaskStatus *status, const gchar **package_id)
+pk_task_monitor_get_role (PkTaskMonitor *tmonitor, PkTaskStatus *status, gchar **package_id)
{
gboolean ret;
GError *error;
gchar *status_text;
+ gchar *package_id_temp;
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);
@@ -140,7 +143,7 @@ pk_task_monitor_get_role (PkTaskMonitor
ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetJobRole", &error,
G_TYPE_INVALID,
G_TYPE_STRING, &status_text,
- G_TYPE_STRING, package_id,
+ G_TYPE_STRING, &package_id_temp,
G_TYPE_INVALID);
if (ret == FALSE) {
/* abort as the DBUS method failed */
@@ -149,6 +152,9 @@ pk_task_monitor_get_role (PkTaskMonitor
return FALSE;
}
*status = pk_task_status_from_text (status_text);
+ if (package_id != NULL) {
+ *package_id = g_strdup (package_id_temp);
+ }
return TRUE;
}
diff --git a/libpackagekit/pk-task-monitor.h b/libpackagekit/pk-task-monitor.h
index c1eb68d..4aaeed1 100644
--- a/libpackagekit/pk-task-monitor.h
+++ b/libpackagekit/pk-task-monitor.h
@@ -57,7 +57,7 @@ gboolean pk_task_monitor_get_status (P
PkTaskStatus *status);
gboolean pk_task_monitor_get_role (PkTaskMonitor *tmonitor,
PkTaskStatus *status,
- const gchar **package_id);
+ gchar **package_id);
G_END_DECLS
diff-tree aa98d658186814fe5eee606ab2f8521eb8fe624a (from 97cfe95b7a3dfa5e3281db590de9cd0eb76c01ce)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Aug 31 13:49:21 2007 +0100
move the get_role to PkTaskMonitor as we don't need the client
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
index f5a51a5..b423d64 100644
--- a/libpackagekit/pk-task-client.c
+++ b/libpackagekit/pk-task-client.c
@@ -849,63 +849,6 @@ pk_task_client_get_actions (PkTaskClient
}
/**
- * pk_task_client_get_job_role:
- **/
-gboolean
-pk_task_client_get_job_role (PkTaskClient *tclient, PkTaskStatus *status, const gchar **package_id)
-{
- gboolean ret;
- GError *error;
- gchar *status_text;
-
- 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, "GetJobRole", &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &status_text,
- G_TYPE_STRING, package_id,
- G_TYPE_INVALID);
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("GetJobStatus failed :%s", error->message);
- g_error_free (error);
- return FALSE;
- }
- *status = pk_task_status_from_text (status_text);
- return TRUE;
-}
-
-/**
- * pk_task_client_get_job_status:
- **/
-gboolean
-pk_task_client_get_job_status (PkTaskClient *tclient, PkTaskStatus *status)
-{
- gboolean ret;
- GError *error;
- gchar *status_text;
-
- 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, "GetJobStatus", &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &status_text,
- G_TYPE_INVALID);
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("GetJobStatus failed :%s", error->message);
- g_error_free (error);
- return FALSE;
- }
- *status = pk_task_status_from_text (status_text);
- return TRUE;
-}
-
-/**
* pk_task_client_finished_cb:
*/
static void
diff --git a/libpackagekit/pk-task-client.h b/libpackagekit/pk-task-client.h
index 77196ab..b588db0 100644
--- a/libpackagekit/pk-task-client.h
+++ b/libpackagekit/pk-task-client.h
@@ -95,11 +95,6 @@ gboolean pk_task_client_install_package
const gchar *package_id);
gboolean pk_task_client_cancel_job_try (PkTaskClient *tclient);
gchar *pk_task_client_get_actions (PkTaskClient *tclient);
-gboolean pk_task_client_get_job_role (PkTaskClient *tclient,
- PkTaskStatus *status,
- const gchar **package_id);
-gboolean pk_task_client_get_job_status (PkTaskClient *tclient,
- PkTaskStatus *status);
gboolean pk_task_client_reset (PkTaskClient *tclient);
G_END_DECLS
diff --git a/libpackagekit/pk-task-monitor.c b/libpackagekit/pk-task-monitor.c
index 66cc39b..7114259 100644
--- a/libpackagekit/pk-task-monitor.c
+++ b/libpackagekit/pk-task-monitor.c
@@ -123,6 +123,36 @@ pk_task_monitor_get_status (PkTaskMonito
}
/**
+ * pk_task_monitor_get_role:
+ **/
+gboolean
+pk_task_monitor_get_role (PkTaskMonitor *tmonitor, PkTaskStatus *status, const gchar **package_id)
+{
+ gboolean ret;
+ GError *error;
+ gchar *status_text;
+
+ 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);
+
+ error = NULL;
+ ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetJobRole", &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &status_text,
+ G_TYPE_STRING, package_id,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetJobStatus failed :%s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+ *status = pk_task_status_from_text (status_text);
+ return TRUE;
+}
+
+/**
* pk_task_monitor_finished_cb:
*/
static void
diff --git a/libpackagekit/pk-task-monitor.h b/libpackagekit/pk-task-monitor.h
index aa22439..c1eb68d 100644
--- a/libpackagekit/pk-task-monitor.h
+++ b/libpackagekit/pk-task-monitor.h
@@ -55,6 +55,9 @@ gboolean pk_task_monitor_set_job (PkTa
guint pk_task_monitor_get_job (PkTaskMonitor *tmonitor);
gboolean pk_task_monitor_get_status (PkTaskMonitor *tmonitor,
PkTaskStatus *status);
+gboolean pk_task_monitor_get_role (PkTaskMonitor *tmonitor,
+ PkTaskStatus *status,
+ const gchar **package_id);
G_END_DECLS
diff-tree 97cfe95b7a3dfa5e3281db590de9cd0eb76c01ce (from c5e6f5bca88890042a47a92c1b2ba16c5753ad14)
Author: Tom Parker <palfrey at tevp.net>
Date: Fri Aug 31 13:41:04 2007 +0200
Do the v_snprintf->v_asprintf fix in libselftest
diff --git a/libselftest/libselftest.c b/libselftest/libselftest.c
index 270eb80..d67eae0 100644
--- a/libselftest/libselftest.c
+++ b/libselftest/libselftest.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <glib/gi18n.h>
#include <glib-object.h>
+#include <glib/gprintf.h>
#include "libselftest.h"
@@ -92,12 +93,13 @@ void
libst_title (LibSelfTest *test, const gchar *format, ...)
{
va_list args;
- gchar va_args_buffer [1025];
+ gchar *va_args_buffer = NULL;
if (test->level == LEVEL_ALL) {
va_start (args, format);
- g_vsnprintf (va_args_buffer, 1024, format, args);
+ g_vasprintf (&va_args_buffer, format, args);
va_end (args);
g_print ("> check #%u\t%s: \t%s...", test->total+1, test->type, va_args_buffer);
+ g_free(va_args_buffer);
}
test->total++;
}
@@ -106,16 +108,17 @@ void
libst_success (LibSelfTest *test, const gchar *format, ...)
{
va_list args;
- gchar va_args_buffer [1025];
+ gchar *va_args_buffer = NULL;
if (test->level == LEVEL_ALL) {
if (format == NULL) {
g_print ("...OK\n");
goto finish;
}
va_start (args, format);
- g_vsnprintf (va_args_buffer, 1024, format, args);
+ g_vasprintf (&va_args_buffer, format, args);
va_end (args);
g_print ("...OK [%s]\n", va_args_buffer);
+ g_free(va_args_buffer);
}
finish:
test->succeeded++;
@@ -125,16 +128,17 @@ void
libst_failed (LibSelfTest *test, const gchar *format, ...)
{
va_list args;
- gchar va_args_buffer [1025];
+ gchar *va_args_buffer = NULL;
if (test->level == LEVEL_ALL || test->level == LEVEL_NORMAL) {
if (format == NULL) {
g_print ("FAILED\n");
goto failed;
}
va_start (args, format);
- g_vsnprintf (va_args_buffer, 1024, format, args);
+ g_vasprintf (&va_args_buffer, format, args);
va_end (args);
g_print ("FAILED [%s]\n", va_args_buffer);
+ g_free(va_args_buffer);
}
failed:
exit (1);
diff-tree c5e6f5bca88890042a47a92c1b2ba16c5753ad14 (from 6ff2e5ce91ed8eed5aa45d5eb313d9182dee2ed1)
Author: Tom Parker <palfrey at tevp.net>
Date: Fri Aug 31 13:27:25 2007 +0200
Update pk-task-apt to new interfaces
diff --git a/src/pk-task-apt.cpp b/src/pk-task-apt.cpp
index 91afeab..81ee1d6 100644
--- a/src/pk-task-apt.cpp
+++ b/src/pk-task-apt.cpp
@@ -41,6 +41,7 @@
#include "pk-task-common.h"
#include "config.h"
#include "pk-network.h"
+#include "pk-package-id.h"
static void pk_task_class_init(PkTaskClass * klass);
static void pk_task_init(PkTask * task);
@@ -502,7 +503,7 @@ static void *do_search_task(gpointer dat
if (Match == true)// && pk_task_filter_package_name(st->task,P.Name().c_str()))
{
- gchar *pid = pk_task_package_ident_build(P.Name().c_str(),J->verstr,J->arch,J->repo);
+ gchar *pid = pk_package_id_build(P.Name().c_str(),J->verstr,J->arch,J->repo);
pk_task_package(st->task, J->installed, pid, P.ShortDesc().c_str());
g_free(pid);
}
@@ -737,8 +738,6 @@ static void pk_task_finalize(GObject * o
g_return_if_fail(PK_IS_TASK(object));
task = PK_TASK(object);
g_return_if_fail(task->priv != NULL);
- g_free(task->package);
- g_object_unref(task->priv->network);
G_OBJECT_CLASS(pk_task_parent_class)->finalize(object);
}
More information about the PackageKit
mailing list