[packagekit] packagekit: Branch 'master' - 7 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Fri Aug 31 04:00:52 PDT 2007
TODO | 4 +
helpers/packagekit.py | 11 ++++
helpers/yumBackend.py | 22 +++++++-
libpackagekit/pk-debug.c | 22 +++++---
libpackagekit/pk-task-client.c | 111 +++++++++++++++++++++++++++++++++--------
libpackagekit/pk-task-client.h | 11 ++--
src/pk-engine.c | 33 +++++++++---
src/pk-engine.h | 5 +
src/pk-interface.xml | 35 +++++++-----
src/pk-task-apt.cpp | 2
src/pk-task-common.c | 74 +++++++++++++++++++--------
src/pk-task-common.h | 18 ++++--
src/pk-task-conary.c | 20 ++++---
src/pk-task-dummy.c | 42 +++++----------
src/pk-task-yum.c | 32 ++++-------
src/pk-task.h | 5 +
16 files changed, 309 insertions(+), 138 deletions(-)
New commits:
diff-tree 6ff2e5ce91ed8eed5aa45d5eb313d9182dee2ed1 (from de5caa610609a19d03425b67385effc2341d4124)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Aug 31 11:58:55 2007 +0100
get two types of information, the status (what we are doing now) and the role (what we were asked to do) to allow the libnotify dialogs to be a little more sane.
diff --git a/TODO b/TODO
index bcf30dc..df558d5 100644
--- a/TODO
+++ b/TODO
@@ -11,16 +11,8 @@ Core:
* Add a Launch() method to startup when pk-application is launched
* task_client has to return GError
-Add:
- <method name="GetJobTask"> <!-- throws NoSuchJob -->
- <arg type="u" name="job" direction="in"/> <!-- this is the master role, i.e. won't change for the lifetime of the job -->
- <arg type="s" name="status" direction="out"/> <!-- query,download,install,exit -->
- <arg type="s" name="package_id" direction="out"/> <!-- what we are doing the action to, or NULL -->
- </method>
-
-
Backends:
-* Add conary backend
+* Complete conary backend
* Dummy backend should use subpercent and install deps
* Add enough new error enums for all the backends
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
index b423d64..f5a51a5 100644
--- a/libpackagekit/pk-task-client.c
+++ b/libpackagekit/pk-task-client.c
@@ -849,6 +849,63 @@ 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 73a5e8b..77196ab 100644
--- a/libpackagekit/pk-task-client.h
+++ b/libpackagekit/pk-task-client.h
@@ -83,18 +83,23 @@ gboolean pk_task_client_search_file (P
const gchar *filter,
const gchar *search);
gboolean pk_task_client_get_deps (PkTaskClient *tclient,
- const gchar *package);
+ const gchar *package_id);
gboolean pk_task_client_get_description (PkTaskClient *tclient,
- const gchar *package);
+ const gchar *package_id);
gboolean pk_task_client_remove_package (PkTaskClient *tclient,
const gchar *package,
gboolean allow_deps);
gboolean pk_task_client_refresh_cache (PkTaskClient *tclient,
gboolean force);
gboolean pk_task_client_install_package (PkTaskClient *tclient,
- const gchar *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/src/pk-engine.c b/src/pk-engine.c
index 92d5623..b0d1928 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -375,7 +375,7 @@ pk_engine_finished_cb (PkTask *task, PkT
/* remove from array and unref */
g_ptr_array_remove (engine->priv->array, task);
- g_timer_destroy (task->timer);
+ pk_task_common_free (task);
g_object_unref (task);
pk_debug ("removed task %p", task);
pk_engine_job_list_changed (engine);
@@ -437,12 +437,8 @@ pk_engine_new_task (PkEngine *engine)
g_signal_connect (task, "allow-interrupt",
G_CALLBACK (pk_engine_allow_interrupt_cb), engine);
- /* track how long the job has been running for */
- task->timer = g_timer_new ();
-
/* initialise some stuff */
- task->spawn = NULL;
- task->is_killable = FALSE;
+ pk_task_common_init (task);
/* set the job ID */
pk_task_set_job (task, job);
@@ -1096,6 +1092,31 @@ pk_engine_get_job_status (PkEngine *engi
}
/**
+ * pk_engine_get_job_role:
+ **/
+gboolean
+pk_engine_get_job_role (PkEngine *engine, guint job,
+ const gchar **status, const gchar **package_id, GError **error)
+{
+ PkTask *task;
+ PkTaskStatus status_enum;
+
+ g_return_val_if_fail (engine != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+
+ task = pk_get_task_from_job (engine, job);
+ if (task == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_JOB,
+ "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));
+
+ return TRUE;
+}
+
+/**
* pk_engine_cancel_job_try:
**/
gboolean
diff --git a/src/pk-engine.h b/src/pk-engine.h
index 93072ac..cf78637 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -128,6 +128,11 @@ gboolean pk_engine_get_job_status (PkE
guint job,
const gchar **status,
GError **error);
+gboolean pk_engine_get_job_role (PkEngine *engine,
+ guint job,
+ const gchar **status,
+ const gchar **package_id,
+ GError **error);
gboolean pk_engine_cancel_job_try (PkEngine *engine,
guint job,
GError **error);
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index 4dbe990..31a56a0 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -109,13 +109,21 @@
</signal>
<!-- Do things or query jobs -->
- <method name="CancelJobTry"> <!-- throws NoSuchJob -->
+ <method name="CancelJobTry"> <!-- might not succeed for all manner or reasons -->
+ <!-- throws NoSuchJob -->
<arg type="u" name="job" direction="in"/>
</method>
- <method name="GetJobStatus"> <!-- throws NoSuchJob -->
+ <method name="GetJobStatus"> <!-- this is what the job is currrently doing, and might change -->
+ <!-- throws NoSuchJob -->
<arg type="u" name="job" direction="in"/>
<arg type="s" name="status" direction="out"/> <!-- query,download,install,exit -->
</method>
+ <method name="GetJobRole"> <!-- this is the master role, i.e. won't change for the lifetime of the job -->
+ <!-- throws NoSuchJob -->
+ <arg type="u" name="job" direction="in"/>
+ <arg type="s" name="status" direction="out"/> <!-- query,download,install,exit -->
+ <arg type="s" name="package_id" direction="out"/> <!-- what we are doing the action to, or NULL -->
+ </method>
<!-- Job list -->
<method name="GetJobList">
diff --git a/src/pk-task-apt.cpp b/src/pk-task-apt.cpp
index 1d3e86d..91afeab 100644
--- a/src/pk-task-apt.cpp
+++ b/src/pk-task-apt.cpp
@@ -724,7 +724,7 @@ static void pk_task_init(PkTask * task)
task->priv = PK_TASK_GET_PRIVATE(task);
task->priv->network = pk_network_new();
task->signals = signals;
- pk_task_clear(task);
+ pk_task_common_init(task);
}
/**
diff --git a/src/pk-task-common.c b/src/pk-task-common.c
index dbf6f66..54d52e7 100644
--- a/src/pk-task-common.c
+++ b/src/pk-task-common.c
@@ -385,6 +385,26 @@ 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)
+{
+ 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) {
+ 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;
+ task->package_id = g_strdup (package_id);
+ return TRUE;
+}
+
+/**
* pk_task_change_job_status:
**/
gboolean
@@ -485,6 +505,25 @@ 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)
+{
+ g_return_val_if_fail (task != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_TASK (task), FALSE);
+
+ /* check to see if we have an action */
+ if (task->assigned == FALSE) {
+ pk_warning ("Not assigned");
+ return FALSE;
+ }
+ *status = task->role;
+ *package_id = g_strdup (task->package_id);
+ return TRUE;
+}
+
+/**
* pk_task_finished_idle:
**/
static gboolean
@@ -585,44 +624,37 @@ pk_task_set_job (PkTask *task, guint job
}
/**
- * pk_task_clear:
+ * pk_task_common_init:
**/
gboolean
-pk_task_clear (PkTask *task)
+pk_task_common_init (PkTask *task)
{
g_return_val_if_fail (task != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK (task), FALSE);
+ /* track how long the job has been running for */
+ task->timer = g_timer_new ();
+ task->job = 1;
task->assigned = FALSE;
+ task->is_killable = FALSE;
+ task->spawn = NULL;
+ task->package_id = NULL;
+ task->role = PK_TASK_STATUS_UNKNOWN;
task->status = PK_TASK_STATUS_UNKNOWN;
task->exit = PK_TASK_EXIT_UNKNOWN;
- task->job = 1;
- task->package = NULL;
return TRUE;
}
/**
- * pk_task_get_data:
- *
- * Need to g_free
- **/
-gchar *
-pk_task_get_data (PkTask *task)
-{
- return g_strdup (task->package);
-}
-
-/**
- * pk_task_set_data:
- *
- * Need to g_free
+ * pk_task_common_init:
**/
gboolean
-pk_task_set_data (PkTask *task, const gchar *data)
+pk_task_common_free (PkTask *task)
{
- g_free (task->package);
- task->package = g_strdup (data);
+ g_return_val_if_fail (task != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_TASK (task), FALSE);
+ g_timer_destroy (task->timer);
return TRUE;
}
diff --git a/src/pk-task-common.h b/src/pk-task-common.h
index d0632e1..c4687ba 100644
--- a/src/pk-task-common.h
+++ b/src/pk-task-common.h
@@ -27,6 +27,8 @@
G_BEGIN_DECLS
+gboolean pk_task_common_init (PkTask *task);
+gboolean pk_task_common_free (PkTask *task);
guint pk_task_get_job (PkTask *task);
gboolean pk_task_set_job (PkTask *task,
guint job);
@@ -36,12 +38,20 @@ gboolean pk_task_change_sub_percentage
guint percentage);
gboolean pk_task_change_job_status (PkTask *task,
PkTaskStatus status);
+gboolean pk_task_get_job_status (PkTask *task,
+ PkTaskStatus *status);
+gboolean pk_task_set_job_role (PkTask *task,
+ PkTaskStatus status,
+ const gchar *package_id);
+gboolean pk_task_get_job_role (PkTask *task,
+ PkTaskStatus *status,
+ const gchar **package_id);
gboolean pk_task_no_percentage_updates (PkTask *task);
gboolean pk_task_finished (PkTask *task,
PkTaskExit exit);
gboolean pk_task_package (PkTask *task,
guint value,
- const gchar *package,
+ const gchar *package_id,
const gchar *summary);
gboolean pk_task_require_restart (PkTask *task,
PkTaskRestart restart,
@@ -55,14 +65,8 @@ gboolean pk_task_error_code (PkTask
guint code,
const gchar *details, ...);
gboolean pk_task_assign (PkTask *task);
-gboolean pk_task_get_job_status (PkTask *task,
- PkTaskStatus *status);
-gboolean pk_task_clear (PkTask *task);
gboolean pk_task_setup_signals (GObjectClass *object_class,
guint *signals);
-gchar *pk_task_get_data (PkTask *task);
-gboolean pk_task_set_data (PkTask *task,
- const gchar *data);
gboolean pk_task_spawn_helper (PkTask *task,
const gchar *script, ...);
gboolean pk_task_not_implemented_yet (PkTask *task,
diff --git a/src/pk-task-conary.c b/src/pk-task-conary.c
index 448335a..fd56c09 100644
--- a/src/pk-task-conary.c
+++ b/src/pk-task-conary.c
@@ -94,8 +94,8 @@ pk_task_get_updates (PkTask *task)
return FALSE;
}
- pk_task_change_job_status (task, PK_TASK_STATUS_QUERY);
- pk_task_spawn_helper (task, "get-updates.py", NULL);
+ pk_task_set_job_role (task, PK_TASK_STATUS_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_change_job_status (task, PK_TASK_STATUS_REFRESH_CACHE);
+ pk_task_set_job_role (task, PK_TASK_STATUS_REFRESH_CACHE, NULL);
pk_task_spawn_helper (task, "refresh-cache.py", NULL);
return TRUE;
@@ -139,6 +139,7 @@ pk_task_update_system (PkTask *task)
return FALSE;
}
+ pk_task_set_job_role (task, PK_TASK_STATUS_UPDATE, NULL);
pk_task_not_implemented_yet (task, "UpdateSystem");
return TRUE;
}
@@ -187,8 +188,8 @@ pk_task_search_details (PkTask *task, co
return TRUE;
}
- pk_task_change_job_status (task, PK_TASK_STATUS_UPDATE);
- pk_task_spawn_helper (task, "search-details.py", filter, search);
+ pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
+ pk_task_spawn_helper (task, "search-details.py", filter, search, NULL);
return TRUE;
}
@@ -198,6 +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_not_implemented_yet (task, "SearchGroup");
return TRUE;
}
@@ -208,6 +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_not_implemented_yet (task, "SearchFile");
return TRUE;
}
@@ -225,6 +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_not_implemented_yet (task, "GetDeps");
return TRUE;
}
@@ -242,6 +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_not_implemented_yet (task, "GetDescription");
return TRUE;
}
@@ -259,6 +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_not_implemented_yet (task, "RemovePackage");
return TRUE;
}
@@ -283,6 +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_not_implemented_yet (task, "InstallPackage");
return TRUE;
}
@@ -307,6 +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_not_implemented_yet (task, "UpdatePackage");
return TRUE;
}
@@ -352,7 +360,6 @@ pk_task_init (PkTask *task)
task->priv = PK_TASK_GET_PRIVATE (task);
task->signals = signals;
task->priv->network = pk_network_new ();
- pk_task_clear (task);
}
/**
@@ -366,7 +373,6 @@ pk_task_finalize (GObject *object)
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);
}
diff --git a/src/pk-task-dummy.c b/src/pk-task-dummy.c
index 755827f..a7a2bfe 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_change_job_status (task, PK_TASK_STATUS_QUERY);
+ pk_task_set_job_role (task, PK_TASK_STATUS_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_change_job_status (task, PK_TASK_STATUS_REFRESH_CACHE);
+ pk_task_set_job_role (task, PK_TASK_STATUS_REFRESH_CACHE, NULL);
pk_task_finished (task, PK_TASK_EXIT_SUCCESS);
return TRUE;
}
@@ -144,7 +144,7 @@ pk_task_update_system (PkTask *task)
return FALSE;
}
- pk_task_change_job_status (task, PK_TASK_STATUS_UPDATE);
+ pk_task_set_job_role (task, PK_TASK_STATUS_UPDATE, NULL);
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);
@@ -184,8 +184,7 @@ pk_task_search_name (PkTask *task, const
return FALSE;
}
- task->package = strdup (search);
- pk_task_change_job_status (task, PK_TASK_STATUS_QUERY);
+ pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
pk_task_no_percentage_updates (task);
g_timeout_add (2000, pk_task_search_name_timeout, task);
@@ -198,6 +197,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_package (task, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
"The vips documentation package.");
pk_task_finished (task, PK_TASK_EXIT_SUCCESS);
@@ -210,6 +210,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_package (task, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
"The vips documentation package.");
pk_task_finished (task, PK_TASK_EXIT_SUCCESS);
@@ -222,6 +223,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_package (task, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
"The vips documentation package.");
pk_task_finished (task, PK_TASK_EXIT_SUCCESS);
@@ -232,7 +234,7 @@ pk_task_search_file (PkTask *task, const
* pk_task_get_deps:
**/
gboolean
-pk_task_get_deps (PkTask *task, const gchar *package)
+pk_task_get_deps (PkTask *task, const gchar *package_id)
{
g_return_val_if_fail (task != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK (task), FALSE);
@@ -241,8 +243,7 @@ pk_task_get_deps (PkTask *task, const gc
return FALSE;
}
- task->package = strdup (package);
- pk_task_change_job_status (task, PK_TASK_STATUS_QUERY);
+ pk_task_set_job_role (task, PK_TASK_STATUS_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",
@@ -256,7 +257,7 @@ pk_task_get_deps (PkTask *task, const gc
* pk_task_get_description:
**/
gboolean
-pk_task_get_description (PkTask *task, const gchar *package)
+pk_task_get_description (PkTask *task, const gchar *package_id)
{
g_return_val_if_fail (task != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK (task), FALSE);
@@ -265,7 +266,7 @@ pk_task_get_description (PkTask *task, c
return FALSE;
}
- pk_task_change_job_status (task, PK_TASK_STATUS_QUERY);
+ pk_task_set_job_role (task, PK_TASK_STATUS_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 "
@@ -284,7 +285,7 @@ pk_task_get_description (PkTask *task, c
* pk_task_remove_package:
**/
gboolean
-pk_task_remove_package (PkTask *task, const gchar *package, gboolean allow_deps)
+pk_task_remove_package (PkTask *task, const gchar *package_id, gboolean allow_deps)
{
g_return_val_if_fail (task != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK (task), FALSE);
@@ -293,8 +294,7 @@ pk_task_remove_package (PkTask *task, co
return FALSE;
}
- task->package = strdup (package);
- pk_task_change_job_status (task, PK_TASK_STATUS_REMOVE);
+ pk_task_set_job_role (task, PK_TASK_STATUS_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);
@@ -321,7 +321,7 @@ pk_task_install_timeout (gpointer data)
* pk_task_install_package:
**/
gboolean
-pk_task_install_package (PkTask *task, const gchar *package)
+pk_task_install_package (PkTask *task, const gchar *package_id)
{
g_return_val_if_fail (task != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK (task), FALSE);
@@ -330,8 +330,7 @@ pk_task_install_package (PkTask *task, c
return FALSE;
}
- task->package = strdup (package);
- pk_task_change_job_status (task, PK_TASK_STATUS_DOWNLOAD);
+ pk_task_set_job_role (task, PK_TASK_STATUS_INSTALL, package_id);
task->priv->progress_percentage = 0;
g_timeout_add (1000, pk_task_install_timeout, task);
return TRUE;
@@ -350,8 +349,7 @@ pk_task_update_package (PkTask *task, co
return FALSE;
}
- task->package = strdup (package_id);
- pk_task_change_job_status (task, PK_TASK_STATUS_QUERY);
+ pk_task_set_job_role (task, PK_TASK_STATUS_UPDATE, package_id);
pk_task_package (task, 1, package_id, "The same thing");
pk_task_finished (task, PK_TASK_EXIT_SUCCESS);
return TRUE;
@@ -371,12 +369,6 @@ pk_task_cancel_job_try (PkTask *task)
pk_warning ("Not assigned");
return FALSE;
}
- /* try to cancel action */
- if (task->status != PK_TASK_STATUS_QUERY) {
- pk_warning ("cannot cancel as not query");
- return FALSE;
- }
-
return TRUE;
}
@@ -401,7 +393,6 @@ pk_task_init (PkTask *task)
{
task->priv = PK_TASK_GET_PRIVATE (task);
task->signals = signals;
- pk_task_clear (task);
}
/**
@@ -415,7 +406,6 @@ pk_task_finalize (GObject *object)
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_CLASS (pk_task_parent_class)->finalize (object);
}
diff --git a/src/pk-task-yum.c b/src/pk-task-yum.c
index dc536dc..40e4dde 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_change_job_status (task, PK_TASK_STATUS_QUERY);
+ pk_task_set_job_role (task, PK_TASK_STATUS_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_change_job_status (task, PK_TASK_STATUS_REFRESH_CACHE);
+ pk_task_set_job_role (task, PK_TASK_STATUS_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_change_job_status (task, PK_TASK_STATUS_UPDATE);
+ pk_task_set_job_role (task, PK_TASK_STATUS_UPDATE, NULL);
pk_task_spawn_helper (task, "update-system.py", NULL);
return TRUE;
}
@@ -156,17 +156,11 @@ pk_task_search_name (PkTask *task, const
return FALSE;
}
- if (pk_task_filter_check (filter) == FALSE) {
- pk_task_error_code (task, PK_TASK_ERROR_CODE_FILTER_INVALID, "filter '%s' not valid", filter);
- pk_task_finished (task, PK_TASK_EXIT_FAILED);
- return TRUE;
- }
-
/* only copy this code if you can kill the process with no ill effect */
pk_task_allow_interrupt (task, TRUE);
pk_task_no_percentage_updates (task);
- pk_task_change_job_status (task, PK_TASK_STATUS_QUERY);
+ pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
pk_task_spawn_helper (task, "search-name.py", filter, search, NULL);
return TRUE;
}
@@ -193,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_change_job_status (task, PK_TASK_STATUS_QUERY);
+ pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
pk_task_spawn_helper (task, "search-details.py", filter, search, NULL);
return TRUE;
}
@@ -220,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_change_job_status (task, PK_TASK_STATUS_QUERY);
+ pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, search);
pk_task_spawn_helper (task, "search-group.py", filter, search, NULL);
return TRUE;
}
@@ -246,6 +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_not_implemented_yet (task, "SearchFile");
return TRUE;
@@ -267,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_change_job_status (task, PK_TASK_STATUS_QUERY);
+ pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, package_id);
pk_task_spawn_helper (task, "get-deps.py", package_id, NULL);
return TRUE;
}
@@ -288,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_change_job_status (task, PK_TASK_STATUS_QUERY);
+ pk_task_set_job_role (task, PK_TASK_STATUS_QUERY, package_id);
pk_task_spawn_helper (task, "get-description.py", package_id, NULL);
return TRUE;
}
@@ -313,7 +308,7 @@ pk_task_remove_package (PkTask *task, co
deps = "no";
}
- pk_task_change_job_status (task, PK_TASK_STATUS_REMOVE);
+ pk_task_set_job_role (task, PK_TASK_STATUS_REMOVE, package_id);
pk_task_spawn_helper (task, "remove.py", deps, package_id, NULL);
return TRUE;
}
@@ -338,7 +333,7 @@ pk_task_install_package (PkTask *task, c
return TRUE;
}
- pk_task_change_job_status (task, PK_TASK_STATUS_INSTALL);
+ pk_task_set_job_role (task, PK_TASK_STATUS_INSTALL, package_id);
pk_task_spawn_helper (task, "install.py", package_id, NULL);
return TRUE;
}
@@ -363,7 +358,7 @@ pk_task_update_package (PkTask *task, co
return TRUE;
}
- pk_task_change_job_status (task, PK_TASK_STATUS_UPDATE);
+ pk_task_set_job_role (task, PK_TASK_STATUS_UPDATE, package_id);
pk_task_spawn_helper (task, "update.py", package_id, NULL);
return TRUE;
}
@@ -422,7 +417,6 @@ pk_task_init (PkTask *task)
task->priv = PK_TASK_GET_PRIVATE (task);
task->signals = signals;
task->priv->network = pk_network_new ();
- pk_task_clear (task);
}
/**
@@ -436,8 +430,6 @@ pk_task_finalize (GObject *object)
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);
}
diff --git a/src/pk-task.h b/src/pk-task.h
index e1629d2..a7c77cf 100644
--- a/src/pk-task.h
+++ b/src/pk-task.h
@@ -57,10 +57,11 @@ typedef struct
PkTaskPrivate *priv;
gboolean assigned;
guint job;
- PkTaskStatus status;
+ PkTaskStatus role; /* this never changes for the lifetime of a job */
+ PkTaskStatus status; /* this changes */
+ gchar *package_id; /* never changes, this is linked to role */
PkTaskExit exit;
GTimer *timer;
- gchar *package;
guint *signals;
PkSpawn *spawn;
gboolean is_killable;
diff-tree de5caa610609a19d03425b67385effc2341d4124 (from abd81b6fa6e72144a41135857e33d0bceb1ebb6b)
Author: Tim Lauridsen <tla at rasmil.dk>
Date: Fri Aug 31 12:41:30 2007 +0200
implemented allow-interupt in packagekit.py and in YumBackend
diff --git a/helpers/packagekit.py b/helpers/packagekit.py
index 92beb43..7824dab 100644
--- a/helpers/packagekit.py
+++ b/helpers/packagekit.py
@@ -118,6 +118,17 @@ class PackageKitBaseBackend:
'''
print >> sys.stderr,"requirerestart\t%s\t%s" % (restart_type,details)
+ def allow_interrupt(self,allow):
+ '''
+ send 'allow-interrupt' signal:
+ @param allow: Allow the current process to be aborted.
+ '''
+ if allow:
+ data = 'true'
+ else:
+ data = 'false'
+ print >> sys.stderr,"allow-interrupt\t%s" % (data)
+
def get_package_id(self,name,version,arch,data):
return "%s;%s;%s;%s" % (name,version,arch,data)
diff --git a/helpers/yumBackend.py b/helpers/yumBackend.py
index 1975ff1..9140ae5 100644
--- a/helpers/yumBackend.py
+++ b/helpers/yumBackend.py
@@ -548,6 +548,7 @@ class ProcessTransPackageKitCallback:
def event(self,state,data=None):
if state == PT_DOWNLOAD: # Start Downloading
+ self.base.allow_interrupt(True)
self.base.percentage(10)
self.base.status(STATE_DOWNLOAD)
if state == PT_DOWNLOAD_PKGS: # Packages to download
@@ -556,8 +557,10 @@ class ProcessTransPackageKitCallback:
self.base.percentage(40)
pass
elif state == PT_TEST_TRANS:
+ self.base.allow_interrupt(False)
self.base.percentage(45)
pass
elif state == PT_TRANSACTION:
+ self.base.allow_interrupt(False)
self.base.percentage(50)
pass
diff-tree abd81b6fa6e72144a41135857e33d0bceb1ebb6b (from af90ec525b08bcb741b11a7e09804a754fb36d73)
Author: Tim Lauridsen <tla at rasmil.dk>
Date: Fri Aug 31 12:28:43 2007 +0200
Make the yumBackend show package in both download & install/update/remove
diff --git a/helpers/yumBackend.py b/helpers/yumBackend.py
index 10847a7..1975ff1 100644
--- a/helpers/yumBackend.py
+++ b/helpers/yumBackend.py
@@ -354,8 +354,11 @@ class PackageKitYumBackend(PackageKitBas
pkg,inst = self._findPackage(package)
if pkg:
id = self.get_package_id(pkg.name, pkg.version,pkg.arch, pkg.repo)
+ desc = pkg.description
+ desc = desc.replace('\n\n',';')
+ desc = desc.replace('\n',' ')
self.description(id, "%s-%s" % (pkg.version, pkg.release),
- repr(pkg.description), pkg.url)
+ desc, pkg.url)
else:
self.error(ERROR_INTERNAL_ERROR,'Package was not found')
@@ -425,6 +428,7 @@ class DownloadCallback( BaseMeter ):
self.totalPct = startPct
def _getPackage(self,name):
+ name = name.split('-')[0]
if self.pkgs:
for pkg in self.pkgs:
if pkg.name == name:
@@ -494,7 +498,11 @@ class DownloadCallback( BaseMeter ):
if self.showNames:
pkg = self._getPackage(name)
if pkg: # show package to download
- self.base._show_package(pkgs,1)
+ self.base._show_package(pkg,1)
+ else:
+ id = self.base.get_package_id(name, '', '', '')
+ self.base.package(id,1, "Repository MetaData")
+
class PackageKitCallback(RPMBaseCallback):
def __init__(self,base):
@@ -509,15 +517,20 @@ class PackageKitCallback(RPMBaseCallback
bump = float(self.numPct)/ts_total
pct = int(self.startPct + (ts_current * bump))
return pct
+
+ def _showName(self):
+ id = self.base.get_package_id(self.curpkg, '', '', '')
+ self.base.package(id,1, "")
+
def event(self, package, action, te_current, te_total, ts_current, ts_total):
if str(package) != self.curpkg:
self.curpkg = str(package)
- self.base.data(self.curpkg)
if action in TS_INSTALL_STATES:
self.base.status(STATE_INSTALL)
elif action in TS_REMOVE_STATES:
self.base.status(STATE_REMOVE)
+ self._showName()
pct = self._calcTotalPct(ts_current, ts_total)
self.base.percentage(pct)
val = (ts_current*100L)/ts_total
diff-tree af90ec525b08bcb741b11a7e09804a754fb36d73 (from 3197f7bf234b4af432510f89e27f06fac5d9edf0)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Aug 31 10:50:33 2007 +0100
move around sections inthe xml spec and better document
diff --git a/TODO b/TODO
index d4dacb7..bcf30dc 100644
--- a/TODO
+++ b/TODO
@@ -11,6 +11,14 @@ Core:
* Add a Launch() method to startup when pk-application is launched
* task_client has to return GError
+Add:
+ <method name="GetJobTask"> <!-- throws NoSuchJob -->
+ <arg type="u" name="job" direction="in"/> <!-- this is the master role, i.e. won't change for the lifetime of the job -->
+ <arg type="s" name="status" direction="out"/> <!-- query,download,install,exit -->
+ <arg type="s" name="package_id" direction="out"/> <!-- what we are doing the action to, or NULL -->
+ </method>
+
+
Backends:
* Add conary backend
* Dummy backend should use subpercent and install deps
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index 1039521..4dbe990 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -2,8 +2,6 @@
<node name="/">
<interface name="org.freedesktop.PackageKit">
- <!-- ASYNCHRONOUS -->
-
<!-- Schedule new jobs -->
<method name="GetUpdates">
<arg type="u" name="job" direction="out"/>
@@ -61,7 +59,7 @@
<arg type="u" name="job" direction="out"/>
</method>
- <!-- state has changed, we want to broadcast this to all jobs -->
+ <!-- signals emitted from any job -->
<signal name="JobStatusChanged">
<arg type="u" name="job" direction="out"/>
<arg type="s" name="status" direction="out"/> <!-- invalid,setup,download,install,update,exit -->
@@ -110,25 +108,26 @@
<arg type="s" name="details" direction="out"/> <!-- non-localized detail -->
</signal>
+ <!-- Do things or query jobs -->
+ <method name="CancelJobTry"> <!-- throws NoSuchJob -->
+ <arg type="u" name="job" direction="in"/>
+ </method>
+ <method name="GetJobStatus"> <!-- throws NoSuchJob -->
+ <arg type="u" name="job" direction="in"/>
+ <arg type="s" name="status" direction="out"/> <!-- query,download,install,exit -->
+ </method>
- <!-- SYNCHRONOUS -->
-
- <!-- Job management -->
+ <!-- Job list -->
<method name="GetJobList">
<arg type="au" name="jobs" direction="out"/>
</method>
<signal name="JobListChanged">
<arg type="au" name="jobs" direction="out"/>
</signal>
- <method name="GetJobStatus"> <!-- throws NoSuchJob -->
- <arg type="u" name="job" direction="in"/>
- <arg type="s" name="status" direction="out"/> <!-- query,download,install,exit -->
- </method>
- <method name="CancelJobTry"> <!-- throws NoSuchJob -->
- <arg type="u" name="job" direction="in"/>
- </method>
+
+ <!-- General methods -->
<method name="GetActions">
- <arg type="s" name="actions" direction="out"/> <!-- list of supported actions "groups;install;remove" etc. TODO: Document -->
+ <arg type="s" name="actions" direction="out"/> <!-- list of supported actions "groups;install;remove" etc -->
</method>
</interface>
diff-tree 3197f7bf234b4af432510f89e27f06fac5d9edf0 (from cd9da2040cbd92a48ec7e0f0b1eb7741488bbb9f)
Author: Tom Parker <palfrey at tevp.net>
Date: Thu Aug 30 20:10:49 2007 +0200
Convert debug to using g_vasprintf for long debug
pk_{debug,warning,error} used g_vsnprintf with a fixed 1024 byte
buffer. Admittedly, using pk_debug with things exceeding that
is a bit silly, but still. This patch converts the debug
functions to using g_vasprintf, which means we can throw away
the fixed buffer entirely and get >1024 character messages.
diff --git a/libpackagekit/pk-debug.c b/libpackagekit/pk-debug.c
index c2b2725..25098a9 100644
--- a/libpackagekit/pk-debug.c
+++ b/libpackagekit/pk-debug.c
@@ -21,6 +21,7 @@
#include <glib.h>
#include <glib/gi18n.h>
+#include <glib/gprintf.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
@@ -31,7 +32,6 @@
#include "pk-debug.h"
static gboolean do_verbose = FALSE; /* if we should print out debugging */
-static gchar va_args_buffer [1025];
/**
* pk_print_line:
@@ -64,16 +64,19 @@ pk_debug_real (const gchar *func,
const gchar *format, ...)
{
va_list args;
+ gchar *buffer = NULL;
if (do_verbose == FALSE) {
return;
}
va_start (args, format);
- g_vsnprintf (va_args_buffer, 1024, format, args);
+ g_vasprintf (&buffer, format, args);
va_end (args);
- pk_print_line (func, file, line, va_args_buffer);
+ pk_print_line (func, file, line, buffer);
+
+ g_free(buffer);
}
/**
@@ -86,18 +89,21 @@ pk_warning_real (const gchar *func,
const gchar *format, ...)
{
va_list args;
+ gchar *buffer = NULL;
if (do_verbose == FALSE) {
return;
}
va_start (args, format);
- g_vsnprintf (va_args_buffer, 1024, format, args);
+ g_vasprintf (&buffer, format, args);
va_end (args);
/* do extra stuff for a warning */
fprintf (stderr, "*** WARNING ***\n");
- pk_print_line (func, file, line, va_args_buffer);
+ pk_print_line (func, file, line, buffer);
+
+ g_free(buffer);
}
/**
@@ -110,14 +116,16 @@ pk_error_real (const gchar *func,
const gchar *format, ...)
{
va_list args;
+ gchar *buffer = NULL;
va_start (args, format);
- g_vsnprintf (va_args_buffer, 1024, format, args);
+ g_vasprintf (&buffer, format, args);
va_end (args);
/* do extra stuff for a warning */
fprintf (stderr, "*** ERROR ***\n");
- pk_print_line (func, file, line, va_args_buffer);
+ pk_print_line (func, file, line, buffer);
+ g_free(buffer);
exit (0);
}
diff-tree cd9da2040cbd92a48ec7e0f0b1eb7741488bbb9f (from 0f5094d0c882295bf17ec836987c1952c103f99e)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Aug 31 04:02:04 2007 +0100
only assign on success - a failed method is fair game to be reused straight away
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
index a1b2363..b423d64 100644
--- a/libpackagekit/pk-task-client.c
+++ b/libpackagekit/pk-task-client.c
@@ -400,7 +400,6 @@ pk_task_client_search_details (PkTaskCli
pk_warning ("Already assigned");
return FALSE;
}
- tclient->priv->assigned = TRUE;
error = NULL;
ret = dbus_g_proxy_call (tclient->priv->proxy, "SearchDetails", &error,
@@ -443,7 +442,6 @@ pk_task_client_search_group (PkTaskClien
pk_warning ("Already assigned");
return FALSE;
}
- tclient->priv->assigned = TRUE;
error = NULL;
ret = dbus_g_proxy_call (tclient->priv->proxy, "SearchGroup", &error,
@@ -463,6 +461,8 @@ pk_task_client_search_group (PkTaskClien
pk_warning ("SearchGroup failed!");
return FALSE;
}
+ /* only assign on success */
+ tclient->priv->assigned = TRUE;
pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
pk_task_client_wait_if_sync (tclient);
@@ -486,7 +486,6 @@ pk_task_client_search_file (PkTaskClient
pk_warning ("Already assigned");
return FALSE;
}
- tclient->priv->assigned = TRUE;
error = NULL;
ret = dbus_g_proxy_call (tclient->priv->proxy, "SearchFile", &error,
@@ -506,6 +505,8 @@ pk_task_client_search_file (PkTaskClient
pk_warning ("SearchFile failed!");
return FALSE;
}
+ /* only assign on success */
+ tclient->priv->assigned = TRUE;
pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
pk_task_client_wait_if_sync (tclient);
@@ -529,7 +530,6 @@ pk_task_client_get_deps (PkTaskClient *t
pk_warning ("Already assigned");
return FALSE;
}
- tclient->priv->assigned = TRUE;
error = NULL;
ret = dbus_g_proxy_call (tclient->priv->proxy, "GetDeps", &error,
@@ -548,6 +548,8 @@ pk_task_client_get_deps (PkTaskClient *t
pk_warning ("GetDeps failed!");
return FALSE;
}
+ /* only assign on success */
+ tclient->priv->assigned = TRUE;
pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
pk_task_client_wait_if_sync (tclient);
@@ -571,7 +573,6 @@ pk_task_client_get_description (PkTaskCl
pk_warning ("Already assigned");
return FALSE;
}
- tclient->priv->assigned = TRUE;
error = NULL;
ret = dbus_g_proxy_call (tclient->priv->proxy, "GetDescription", &error,
@@ -590,6 +591,8 @@ pk_task_client_get_description (PkTaskCl
pk_warning ("GetDescription failed!");
return FALSE;
}
+ /* only assign on success */
+ tclient->priv->assigned = TRUE;
pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
pk_task_client_wait_if_sync (tclient);
@@ -687,7 +690,6 @@ pk_task_client_refresh_cache (PkTaskClie
pk_warning ("Already assigned");
return FALSE;
}
- tclient->priv->assigned = TRUE;
error = NULL;
ret = dbus_g_proxy_call (tclient->priv->proxy, "RefreshCache", &error,
@@ -706,6 +708,8 @@ pk_task_client_refresh_cache (PkTaskClie
pk_warning ("RefreshCache failed!");
return FALSE;
}
+ /* only assign on success */
+ tclient->priv->assigned = TRUE;
pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job);
pk_task_client_wait_if_sync (tclient);
diff-tree 0f5094d0c882295bf17ec836987c1952c103f99e (from c70412f1408a1f70fec835e27e0828c143363721)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Aug 31 03:58:41 2007 +0100
use g_quark_to_string for local GErrors for all methods
diff --git a/TODO b/TODO
index 681b1e6..d4dacb7 100644
--- a/TODO
+++ b/TODO
@@ -8,6 +8,8 @@ Core:
* Add package size into description signal
* Valgrind everything
* Add GetPercentage and GetSubPercentage for coldplugging
+* Add a Launch() method to startup when pk-application is launched
+* task_client has to return GError
Backends:
* Add conary backend
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
index 2803699..a1b2363 100644
--- a/libpackagekit/pk-task-client.c
+++ b/libpackagekit/pk-task-client.c
@@ -212,6 +212,22 @@ pk_task_client_reset (PkTaskClient *tcli
}
/**
+ * pk_task_client_get_error_name:
+ **/
+static const gchar *
+pk_task_client_get_error_name (GError *error)
+{
+ const gchar *name;
+ if (error->domain == DBUS_GERROR &&
+ error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
+ name = dbus_g_error_get_name (error);
+ } else {
+ name = g_quark_to_string (error->domain);
+ }
+ return name;
+}
+
+/**
* pk_task_client_get_updates:
**/
gboolean
@@ -237,7 +253,7 @@ pk_task_client_get_updates (PkTaskClient
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
- error_name = dbus_g_error_get_name (error);
+ error_name = pk_task_client_get_error_name (error);
pk_debug ("ERROR: %s: %s", error_name, error->message);
g_error_free (error);
}
@@ -352,13 +368,7 @@ pk_task_client_search_name (PkTaskClient
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
- if (error->domain == DBUS_GERROR &&
- error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
- error_name = dbus_g_error_get_name (error);
- }
- else {
- error_name = g_quark_to_string(error->domain);
- }
+ error_name = pk_task_client_get_error_name (error);
pk_debug ("ERROR: %s: %s", error_name, error->message);
g_error_free (error);
}
@@ -401,7 +411,7 @@ pk_task_client_search_details (PkTaskCli
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
- error_name = dbus_g_error_get_name (error);
+ error_name = pk_task_client_get_error_name (error);
pk_debug ("ERROR: %s: %s", error_name, error->message);
g_error_free (error);
}
@@ -444,7 +454,7 @@ pk_task_client_search_group (PkTaskClien
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
- error_name = dbus_g_error_get_name (error);
+ error_name = pk_task_client_get_error_name (error);
pk_debug ("ERROR: %s: %s", error_name, error->message);
g_error_free (error);
}
@@ -487,7 +497,7 @@ pk_task_client_search_file (PkTaskClient
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
- error_name = dbus_g_error_get_name (error);
+ error_name = pk_task_client_get_error_name (error);
pk_debug ("ERROR: %s: %s", error_name, error->message);
g_error_free (error);
}
@@ -529,7 +539,7 @@ pk_task_client_get_deps (PkTaskClient *t
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
- error_name = dbus_g_error_get_name (error);
+ error_name = pk_task_client_get_error_name (error);
pk_debug ("ERROR: %s: %s", error_name, error->message);
g_error_free (error);
}
@@ -571,7 +581,7 @@ pk_task_client_get_description (PkTaskCl
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
- error_name = dbus_g_error_get_name (error);
+ error_name = pk_task_client_get_error_name (error);
pk_debug ("ERROR: %s: %s", error_name, error->message);
g_error_free (error);
}
@@ -687,7 +697,7 @@ pk_task_client_refresh_cache (PkTaskClie
G_TYPE_INVALID);
if (error) {
const gchar *error_name;
- error_name = dbus_g_error_get_name (error);
+ error_name = pk_task_client_get_error_name (error);
pk_debug ("ERROR: %s: %s", error_name, error->message);
g_error_free (error);
}
More information about the PackageKit
mailing list