[packagekit] packagekit: Branch 'master' - 14 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Sun Sep 9 10:32:06 PDT 2007
TODO | 6
backends/apt/pk-backend-apt.cpp | 30 +++
backends/box/pk-backend-box.c | 140 ++++++++++----
backends/conary/pk-backend-conary.c | 30 +++
backends/dummy/pk-backend-dummy.c | 30 +++
backends/test/pk-backend-test.c | 30 +++
backends/yum/pk-backend-yum.c | 30 +++
client/pk-console.c | 21 +-
client/pk-monitor.c | 2
configure.ac | 18 -
libpackagekit/Makefile.am | 8
libpackagekit/pk-action-list.c | 205 --------------------
libpackagekit/pk-action-list.h | 42 ----
libpackagekit/pk-enum-list.c | 359 ++++++++++++++++++++++++++++++++++++
libpackagekit/pk-enum-list.h | 74 +++++++
libpackagekit/pk-enum.c | 57 ++++-
libpackagekit/pk-enum.h | 52 +++--
libpackagekit/pk-self-test.c | 6
libpackagekit/pk-task-client.c | 100 ++++++++--
libpackagekit/pk-task-client.h | 7
libpackagekit/pk-task-list.c | 6
libpackagekit/pk-task-list.h | 4
libpackagekit/pk-task-monitor.c | 14 -
libpackagekit/pk-task-monitor.h | 4
python/.gitignore | 1
python/packagekit.py | 147 ++++++++++++++
python/pkt | 83 ++++++++
src/pk-backend-internal.h | 12 -
src/pk-backend.c | 106 +++++++---
src/pk-backend.h | 14 +
src/pk-conf.c | 1
src/pk-engine.c | 72 ++++++-
src/pk-engine.h | 6
src/pk-interface.xml | 8
tools/pkt | 109 ----------
35 files changed, 1298 insertions(+), 536 deletions(-)
New commits:
diff-tree cd1005349652d909ea5c227c3081e638a520f951 (from 17470c54c3f4fc7fbef4ba31a55119196df0973f)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 9 18:29:50 2007 +0100
set the status to setup when setting the role
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 53f5789..d591b84 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -480,6 +480,7 @@ pk_backend_set_job_role (PkBackend *back
pk_debug ("setting role to %s (string is '%s')", pk_role_enum_to_text (role), package_id);
backend->priv->role = role;
backend->priv->package_id = g_strdup (package_id);
+ backend->priv->status = PK_STATUS_ENUM_SETUP;
return TRUE;
}
diff-tree 17470c54c3f4fc7fbef4ba31a55119196df0973f (from edaeb012a561244ca9f51bcb9b2016dfc60605a6)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 9 18:24:09 2007 +0100
make the enum types more sane
diff --git a/client/pk-console.c b/client/pk-console.c
index a461994..73c8201 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -329,7 +329,7 @@ pk_console_tidy_up_sync (PkTaskClient *t
* pk_console_finished_cb:
**/
static void
-pk_console_finished_cb (PkTaskClient *tclient, PkTaskStatus status, guint runtime, gpointer data)
+pk_console_finished_cb (PkTaskClient *tclient, PkStatusEnum status, guint runtime, gpointer data)
{
g_print ("Runtime was %i seconds\n", runtime);
}
@@ -338,7 +338,7 @@ pk_console_finished_cb (PkTaskClient *tc
* pk_console_error_code_cb:
**/
static void
-pk_console_error_code_cb (PkTaskClient *tclient, PkTaskErrorCode error_code, const gchar *details, gpointer data)
+pk_console_error_code_cb (PkTaskClient *tclient, PkErrorCodeEnum error_code, const gchar *details, gpointer data)
{
g_print ("Error: %s : %s\n", pk_error_enum_to_text (error_code), details);
}
diff --git a/client/pk-monitor.c b/client/pk-monitor.c
index d59f9d4..05178fd 100644
--- a/client/pk-monitor.c
+++ b/client/pk-monitor.c
@@ -46,7 +46,7 @@ pk_monitor_task_list_changed_cb (PkTaskL
* pk_monitor_error_code_cb:
**/
static void
-pk_monitor_error_code_cb (PkTaskList *tlist, PkTaskErrorCode error_code, const gchar *details, gpointer data)
+pk_monitor_error_code_cb (PkTaskList *tlist, PkErrorCodeEnum error_code, const gchar *details, gpointer data)
{
g_print ("Error: %s : %s\n", pk_error_enum_to_text (error_code), details);
}
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index b014caa..e322ada 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -182,7 +182,7 @@ pk_task_enum_find_string (PkTaskEnumMatc
/**
* pk_exit_enum_from_text:
*/
-PkTaskExit
+PkExitEnum
pk_exit_enum_from_text (const gchar *exit)
{
return pk_task_enum_find_value (task_exit, exit);
@@ -192,7 +192,7 @@ pk_exit_enum_from_text (const gchar *exi
* pk_exit_enum_to_text:
**/
const gchar *
-pk_exit_enum_to_text (PkTaskExit exit)
+pk_exit_enum_to_text (PkExitEnum exit)
{
return pk_task_enum_find_string (task_exit, exit);
}
@@ -200,7 +200,7 @@ pk_exit_enum_to_text (PkTaskExit exit)
/**
* pk_status_enum_from_text:
**/
-PkTaskStatus
+PkStatusEnum
pk_status_enum_from_text (const gchar *status)
{
return pk_task_enum_find_value (task_status, status);
@@ -210,7 +210,7 @@ pk_status_enum_from_text (const gchar *s
* pk_status_enum_to_text:
**/
const gchar *
-pk_status_enum_to_text (PkTaskStatus status)
+pk_status_enum_to_text (PkStatusEnum status)
{
return pk_task_enum_find_string (task_status, status);
}
@@ -218,7 +218,7 @@ pk_status_enum_to_text (PkTaskStatus sta
/**
* pk_role_enum_from_text:
**/
-PkTaskRole
+PkRoleEnum
pk_role_enum_from_text (const gchar *role)
{
return pk_task_enum_find_value (task_role, role);
@@ -228,7 +228,7 @@ pk_role_enum_from_text (const gchar *rol
* pk_role_enum_to_text:
**/
const gchar *
-pk_role_enum_to_text (PkTaskRole role)
+pk_role_enum_to_text (PkRoleEnum role)
{
return pk_task_enum_find_string (task_role, role);
}
@@ -236,7 +236,7 @@ pk_role_enum_to_text (PkTaskRole role)
/**
* pk_error_enum_from_text:
**/
-PkTaskErrorCode
+PkErrorCodeEnum
pk_error_enum_from_text (const gchar *code)
{
return pk_task_enum_find_value (task_error, code);
@@ -246,7 +246,7 @@ pk_error_enum_from_text (const gchar *co
* pk_error_enum_to_text:
**/
const gchar *
-pk_error_enum_to_text (PkTaskErrorCode code)
+pk_error_enum_to_text (PkErrorCodeEnum code)
{
return pk_task_enum_find_string (task_error, code);
}
@@ -254,7 +254,7 @@ pk_error_enum_to_text (PkTaskErrorCode c
/**
* pk_restart_enum_from_text:
**/
-PkTaskRestart
+PkRestartEnum
pk_restart_enum_from_text (const gchar *restart)
{
return pk_task_enum_find_value (task_restart, restart);
@@ -264,7 +264,7 @@ pk_restart_enum_from_text (const gchar *
* pk_restart_enum_to_text:
**/
const gchar *
-pk_restart_enum_to_text (PkTaskRestart restart)
+pk_restart_enum_to_text (PkRestartEnum restart)
{
return pk_task_enum_find_string (task_restart, restart);
}
@@ -272,7 +272,7 @@ pk_restart_enum_to_text (PkTaskRestart r
/**
* pk_group_enum_from_text:
**/
-PkTaskGroup
+PkGroupEnum
pk_group_enum_from_text (const gchar *group)
{
return pk_task_enum_find_value (task_group, group);
@@ -282,7 +282,7 @@ pk_group_enum_from_text (const gchar *gr
* pk_group_enum_to_text:
**/
const gchar *
-pk_group_enum_to_text (PkTaskGroup group)
+pk_group_enum_to_text (PkGroupEnum group)
{
return pk_task_enum_find_string (task_group, group);
}
@@ -290,7 +290,7 @@ pk_group_enum_to_text (PkTaskGroup group
/**
* pk_filter_enum_from_text:
**/
-PkTaskFilter
+PkFilterEnum
pk_filter_enum_from_text (const gchar *filter)
{
return pk_task_enum_find_value (task_filter, filter);
@@ -300,7 +300,7 @@ pk_filter_enum_from_text (const gchar *f
* pk_filter_enum_to_text:
**/
const gchar *
-pk_filter_enum_to_text (PkTaskFilter filter)
+pk_filter_enum_to_text (PkFilterEnum filter)
{
return pk_task_enum_find_string (task_filter, filter);
}
@@ -308,7 +308,7 @@ pk_filter_enum_to_text (PkTaskFilter fil
/**
* pk_action_enum_from_text:
**/
-PkTaskAction
+PkActionEnum
pk_action_enum_from_text (const gchar *action)
{
return pk_task_enum_find_value (task_action, action);
@@ -318,7 +318,7 @@ pk_action_enum_from_text (const gchar *a
* pk_action_enum_to_text:
**/
const gchar *
-pk_action_enum_to_text (PkTaskAction action)
+pk_action_enum_to_text (PkActionEnum action)
{
return pk_task_enum_find_string (task_action, action);
}
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 981f365..5d48475 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -36,7 +36,7 @@ typedef enum {
PK_ROLE_ENUM_PACKAGE_INSTALL,
PK_ROLE_ENUM_PACKAGE_UPDATE,
PK_ROLE_ENUM_UNKNOWN
-} PkTaskRole;
+} PkRoleEnum;
/* what we are actually doing */
typedef enum {
@@ -48,28 +48,28 @@ typedef enum {
PK_STATUS_ENUM_INSTALL,
PK_STATUS_ENUM_UPDATE,
PK_STATUS_ENUM_UNKNOWN
-} PkTaskStatus;
+} PkStatusEnum;
typedef enum {
PK_EXIT_ENUM_SUCCESS,
PK_EXIT_ENUM_FAILED,
PK_EXIT_ENUM_CANCELED,
PK_EXIT_ENUM_UNKNOWN
-} PkTaskExit;
+} PkExitEnum;
typedef enum {
PK_FILTER_ENUM_DEVELOPMENT,
PK_FILTER_ENUM_INSTALLED,
PK_FILTER_ENUM_GUI,
PK_FILTER_ENUM_UNKNOWN
-} PkTaskFilter;
+} PkFilterEnum;
typedef enum {
PK_RESTART_ENUM_NONE,
PK_RESTART_ENUM_APPLICATION,
PK_RESTART_ENUM_SESSION,
PK_RESTART_ENUM_SYSTEM
-} PkTaskRestart;
+} PkRestartEnum;
typedef enum {
PK_ERROR_ENUM_OOM,
@@ -86,7 +86,7 @@ typedef enum {
PK_ERROR_ENUM_CREATE_THREAD_FAILED,
PK_ERROR_ENUM_TRANSACTION_ERROR,
PK_ERROR_ENUM_UNKNOWN
-} PkTaskErrorCode;
+} PkErrorCodeEnum;
typedef enum {
PK_GROUP_ENUM_ACCESSIBILITY,
@@ -101,7 +101,7 @@ typedef enum {
PK_GROUP_ENUM_MULTIMEDIA,
PK_GROUP_ENUM_SYSTEM,
PK_GROUP_ENUM_UNKNOWN
-} PkTaskGroup;
+} PkGroupEnum;
typedef enum {
PK_ACTION_ENUM_INSTALL = 1,
@@ -122,31 +122,31 @@ typedef enum {
PK_ACTION_ENUM_REMOVE_PACKAGE,
PK_ACTION_ENUM_UPDATE_PACKAGE,
PK_ACTION_ENUM_UNKNOWN
-} PkTaskAction;
+} PkActionEnum;
-PkTaskExit pk_exit_enum_from_text (const gchar *exit);
-const gchar *pk_exit_enum_to_text (PkTaskExit exit);
+PkExitEnum pk_exit_enum_from_text (const gchar *exit);
+const gchar *pk_exit_enum_to_text (PkExitEnum exit);
-PkTaskStatus pk_status_enum_from_text (const gchar *status);
-const gchar *pk_status_enum_to_text (PkTaskStatus status);
+PkStatusEnum pk_status_enum_from_text (const gchar *status);
+const gchar *pk_status_enum_to_text (PkStatusEnum status);
-PkTaskRole pk_role_enum_from_text (const gchar *role);
-const gchar *pk_role_enum_to_text (PkTaskRole role);
+PkRoleEnum pk_role_enum_from_text (const gchar *role);
+const gchar *pk_role_enum_to_text (PkRoleEnum role);
-PkTaskErrorCode pk_error_enum_from_text (const gchar *code);
-const gchar *pk_error_enum_to_text (PkTaskErrorCode code);
+PkErrorCodeEnum pk_error_enum_from_text (const gchar *code);
+const gchar *pk_error_enum_to_text (PkErrorCodeEnum code);
-PkTaskRestart pk_restart_enum_from_text (const gchar *restart);
-const gchar *pk_restart_enum_to_text (PkTaskRestart restart);
+PkRestartEnum pk_restart_enum_from_text (const gchar *restart);
+const gchar *pk_restart_enum_to_text (PkRestartEnum restart);
-PkTaskGroup pk_group_enum_from_text (const gchar *group);
-const gchar *pk_group_enum_to_text (PkTaskGroup group);
+PkGroupEnum pk_group_enum_from_text (const gchar *group);
+const gchar *pk_group_enum_to_text (PkGroupEnum group);
-PkTaskFilter pk_filter_enum_from_text (const gchar *filter);
-const gchar *pk_filter_enum_to_text (PkTaskFilter filter);
+PkFilterEnum pk_filter_enum_from_text (const gchar *filter);
+const gchar *pk_filter_enum_to_text (PkFilterEnum filter);
-PkTaskAction pk_action_enum_from_text (const gchar *action);
-const gchar *pk_action_enum_to_text (PkTaskAction action);
+PkActionEnum pk_action_enum_from_text (const gchar *action);
+const gchar *pk_action_enum_to_text (PkActionEnum action);
G_END_DECLS
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
index 6a694e6..a4f6ce2 100644
--- a/libpackagekit/pk-task-client.c
+++ b/libpackagekit/pk-task-client.c
@@ -56,11 +56,11 @@ struct PkTaskClientPrivate
gboolean use_buffer;
guint job;
GMainLoop *loop;
- PkTaskStatus last_status;
+ PkStatusEnum last_status;
PkTaskMonitor *tmonitor;
PkConnection *pconnection;
PkPolkitClient *polkit;
- PkTaskRestart require_restart;
+ PkRestartEnum require_restart;
gboolean is_finished;
GPtrArray *package_items;
};
@@ -109,7 +109,7 @@ pk_task_client_get_use_buffer (PkTaskCli
/**
* pk_task_client_get_use_buffer:
**/
-PkTaskRestart
+PkRestartEnum
pk_task_client_get_require_restart (PkTaskClient *tclient)
{
g_return_val_if_fail (tclient != NULL, FALSE);
@@ -974,7 +974,7 @@ pk_task_client_get_filters (PkTaskClient
*/
static void
pk_task_client_finished_cb (PkTaskMonitor *tmonitor,
- PkTaskExit exit,
+ PkExitEnum exit,
guint runtime,
PkTaskClient *tclient)
{
@@ -1040,7 +1040,7 @@ pk_task_client_no_percentage_updates_cb
*/
static void
pk_task_client_job_status_changed_cb (PkTaskMonitor *tmonitor,
- PkTaskStatus status,
+ PkStatusEnum status,
PkTaskClient *tclient)
{
g_return_if_fail (tclient != NULL);
@@ -1086,7 +1086,7 @@ pk_task_client_package_cb (PkTaskMonitor
static void
pk_task_client_description_cb (PkTaskMonitor *tmonitor,
const gchar *package_id,
- PkTaskGroup group,
+ PkGroupEnum group,
const gchar *detail,
const gchar *url,
PkTaskClient *tclient)
@@ -1103,7 +1103,7 @@ pk_task_client_description_cb (PkTaskMon
*/
static void
pk_task_client_error_code_cb (PkTaskMonitor *tmonitor,
- PkTaskErrorCode code,
+ PkErrorCodeEnum code,
const gchar *details,
PkTaskClient *tclient)
{
@@ -1119,7 +1119,7 @@ pk_task_client_error_code_cb (PkTaskMoni
*/
static void
pk_task_client_require_restart_cb (PkTaskMonitor *tmonitor,
- PkTaskRestart restart,
+ PkRestartEnum restart,
const gchar *details,
PkTaskClient *tclient)
{
diff --git a/libpackagekit/pk-task-client.h b/libpackagekit/pk-task-client.h
index 67ce0b7..f5269f4 100644
--- a/libpackagekit/pk-task-client.h
+++ b/libpackagekit/pk-task-client.h
@@ -68,7 +68,7 @@ gboolean pk_task_client_set_use_buffer
gboolean pk_task_client_get_use_buffer (PkTaskClient *tclient);
GPtrArray *pk_task_client_get_package_buffer (PkTaskClient *tclient);
-PkTaskRestart pk_task_client_get_require_restart (PkTaskClient *tclient);
+PkRestartEnum pk_task_client_get_require_restart (PkTaskClient *tclient);
gboolean pk_task_client_get_updates (PkTaskClient *tclient);
gboolean pk_task_client_update_system (PkTaskClient *tclient);
gboolean pk_task_client_search_name (PkTaskClient *tclient,
diff --git a/libpackagekit/pk-task-list.c b/libpackagekit/pk-task-list.c
index 98f7b3b..90afdc2 100644
--- a/libpackagekit/pk-task-list.c
+++ b/libpackagekit/pk-task-list.c
@@ -116,7 +116,7 @@ pk_task_list_find_existing_job (PkTaskLi
* pk_task_list_job_status_changed_cb:
**/
static void
-pk_task_list_job_status_changed_cb (PkTaskMonitor *tmonitor, PkTaskStatus status, PkTaskList *tlist)
+pk_task_list_job_status_changed_cb (PkTaskMonitor *tmonitor, PkStatusEnum status, PkTaskList *tlist)
{
guint job;
PkTaskListItem *item;
@@ -139,7 +139,7 @@ pk_task_list_job_status_changed_cb (PkTa
* pk_task_list_job_finished_cb:
**/
static void
-pk_task_list_job_finished_cb (PkTaskMonitor *tmonitor, PkTaskExit exit, guint runtime, PkTaskList *tlist)
+pk_task_list_job_finished_cb (PkTaskMonitor *tmonitor, PkExitEnum exit, guint runtime, PkTaskList *tlist)
{
guint job;
PkTaskListItem *item;
@@ -161,7 +161,7 @@ pk_task_list_job_finished_cb (PkTaskMoni
* pk_task_list_error_code_cb:
**/
static void
-pk_task_list_error_code_cb (PkTaskMonitor *tmonitor, PkTaskErrorCode error_code, const gchar *details, PkTaskList *tlist)
+pk_task_list_error_code_cb (PkTaskMonitor *tmonitor, PkErrorCodeEnum error_code, const gchar *details, PkTaskList *tlist)
{
g_return_if_fail (tlist != NULL);
g_return_if_fail (PK_IS_TASK_LIST (tlist));
diff --git a/libpackagekit/pk-task-list.h b/libpackagekit/pk-task-list.h
index d0f7717..c78783d 100644
--- a/libpackagekit/pk-task-list.h
+++ b/libpackagekit/pk-task-list.h
@@ -40,8 +40,8 @@ typedef struct PkTaskListPrivate PkTaskL
typedef struct
{
guint job;
- PkTaskStatus status;
- PkTaskRole role;
+ PkStatusEnum status;
+ PkRoleEnum role;
gchar *package_id;
PkTaskMonitor *monitor;
gboolean valid;
diff --git a/libpackagekit/pk-task-monitor.c b/libpackagekit/pk-task-monitor.c
index 300aa0a..322c043 100644
--- a/libpackagekit/pk-task-monitor.c
+++ b/libpackagekit/pk-task-monitor.c
@@ -93,7 +93,7 @@ pk_task_monitor_get_job (PkTaskMonitor *
* pk_task_monitor_get_status:
**/
gboolean
-pk_task_monitor_get_status (PkTaskMonitor *tmonitor, PkTaskStatus *status)
+pk_task_monitor_get_status (PkTaskMonitor *tmonitor, PkStatusEnum *status)
{
gboolean ret;
gchar *status_text;
@@ -127,7 +127,7 @@ pk_task_monitor_get_status (PkTaskMonito
* pk_task_monitor_get_role:
**/
gboolean
-pk_task_monitor_get_role (PkTaskMonitor *tmonitor, PkTaskRole *role, gchar **package_id)
+pk_task_monitor_get_role (PkTaskMonitor *tmonitor, PkRoleEnum *role, gchar **package_id)
{
gboolean ret;
GError *error;
@@ -169,7 +169,7 @@ pk_task_monitor_finished_cb (DBusGProxy
guint runtime,
PkTaskMonitor *tmonitor)
{
- PkTaskExit exit;
+ PkExitEnum exit;
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
@@ -243,7 +243,7 @@ pk_task_monitor_job_status_changed_cb (D
const gchar *status_text,
PkTaskMonitor *tmonitor)
{
- PkTaskStatus status;
+ PkStatusEnum status;
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
@@ -288,7 +288,7 @@ pk_task_monitor_description_cb (DBusGPro
const gchar *url,
PkTaskMonitor *tmonitor)
{
- PkTaskGroup group;
+ PkGroupEnum group;
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
@@ -309,7 +309,7 @@ pk_task_monitor_error_code_cb (DBusGProx
const gchar *details,
PkTaskMonitor *tmonitor)
{
- PkTaskErrorCode code;
+ PkErrorCodeEnum code;
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
@@ -330,7 +330,7 @@ pk_task_monitor_require_restart_cb (DBus
const gchar *details,
PkTaskMonitor *tmonitor)
{
- PkTaskRestart restart;
+ PkRestartEnum restart;
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
diff --git a/libpackagekit/pk-task-monitor.h b/libpackagekit/pk-task-monitor.h
index 405bbec..3141839 100644
--- a/libpackagekit/pk-task-monitor.h
+++ b/libpackagekit/pk-task-monitor.h
@@ -54,9 +54,9 @@ gboolean pk_task_monitor_set_job (PkTa
guint job);
guint pk_task_monitor_get_job (PkTaskMonitor *tmonitor);
gboolean pk_task_monitor_get_status (PkTaskMonitor *tmonitor,
- PkTaskStatus *status);
+ PkStatusEnum *status);
gboolean pk_task_monitor_get_role (PkTaskMonitor *tmonitor,
- PkTaskRole *role,
+ PkRoleEnum *role,
gchar **package_id);
G_END_DECLS
diff --git a/src/pk-backend-internal.h b/src/pk-backend-internal.h
index 36225dd..7e0129f 100644
--- a/src/pk-backend-internal.h
+++ b/src/pk-backend-internal.h
@@ -94,14 +94,14 @@ gboolean pk_backend_update_package (Pk
const gchar *package_id);
gboolean pk_backend_update_system (PkBackend *backend);
gboolean pk_backend_get_job_status (PkBackend *backend,
- PkTaskStatus *status);
+ PkStatusEnum *status);
gboolean pk_backend_get_job_role (PkBackend *backend,
- PkTaskRole *role,
+ PkRoleEnum *role,
const gchar **package_id);
/* these are external in nature, but we shouldn't be using them in helpers */
gboolean pk_backend_set_job_role (PkBackend *backend,
- PkTaskRole role,
+ PkRoleEnum role,
const gchar *package_id);
gboolean pk_backend_not_implemented_yet (PkBackend *backend,
const gchar *method);
diff --git a/src/pk-backend.c b/src/pk-backend.c
index a48a15f..53f5789 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -53,10 +53,10 @@ struct _PkBackendPrivate
{
GModule *handle;
gchar *name;
- PkTaskStatus role; /* this never changes for the lifetime of a job */
- PkTaskStatus status; /* this changes */
+ 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 */
- PkTaskExit exit;
+ PkExitEnum exit;
GTimer *timer;
PkSpawn *spawn;
gboolean is_killable;
@@ -175,7 +175,7 @@ pk_backend_parse_common_output (PkBacken
guint value = 0;
gchar *command;
gboolean ret = TRUE;
- PkTaskGroup group;
+ PkGroupEnum group;
/* check if output line */
if (line == NULL || strstr (line, "\t") == NULL)
@@ -230,9 +230,9 @@ pk_backend_parse_common_error (PkBackend
guint size;
guint percentage;
gchar *command;
- PkTaskErrorCode error_enum;
- PkTaskStatus status_enum;
- PkTaskRestart restart_enum;
+ PkErrorCodeEnum error_enum;
+ PkStatusEnum status_enum;
+ PkRestartEnum restart_enum;
gboolean ret = TRUE;
/* check if output line */
@@ -322,7 +322,7 @@ out:
static void
pk_backend_spawn_finished_cb (PkSpawn *spawn, gint exitcode, PkBackend *backend)
{
- PkTaskExit exit;
+ PkExitEnum exit;
pk_debug ("unref'ing spawn %p, exit code %i", spawn, exitcode);
g_object_unref (spawn);
@@ -467,7 +467,7 @@ pk_backend_change_sub_percentage (PkBack
* pk_backend_set_job_role:
**/
gboolean
-pk_backend_set_job_role (PkBackend *backend, PkTaskRole role, const gchar *package_id)
+pk_backend_set_job_role (PkBackend *backend, PkRoleEnum role, const gchar *package_id)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
@@ -487,7 +487,7 @@ pk_backend_set_job_role (PkBackend *back
* pk_backend_change_job_status:
**/
gboolean
-pk_backend_change_job_status (PkBackend *backend, PkTaskStatus status)
+pk_backend_change_job_status (PkBackend *backend, PkStatusEnum status)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
@@ -516,7 +516,7 @@ pk_backend_package (PkBackend *backend,
* pk_backend_require_restart:
**/
gboolean
-pk_backend_require_restart (PkBackend *backend, PkTaskRestart restart, const gchar *details)
+pk_backend_require_restart (PkBackend *backend, PkRestartEnum restart, const gchar *details)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
@@ -531,7 +531,7 @@ pk_backend_require_restart (PkBackend *b
* pk_backend_description:
**/
gboolean
-pk_backend_description (PkBackend *backend, const gchar *package, PkTaskGroup group,
+pk_backend_description (PkBackend *backend, const gchar *package, PkGroupEnum group,
const gchar *description, const gchar *url)
{
g_return_val_if_fail (backend != NULL, FALSE);
@@ -547,7 +547,7 @@ pk_backend_description (PkBackend *backe
* pk_backend_error_code:
**/
gboolean
-pk_backend_error_code (PkBackend *backend, PkTaskErrorCode code, const gchar *format, ...)
+pk_backend_error_code (PkBackend *backend, PkErrorCodeEnum code, const gchar *format, ...)
{
va_list args;
gchar buffer[1025];
@@ -569,7 +569,7 @@ pk_backend_error_code (PkBackend *backen
* pk_backend_get_job_status:
**/
gboolean
-pk_backend_get_job_status (PkBackend *backend, PkTaskStatus *status)
+pk_backend_get_job_status (PkBackend *backend, PkStatusEnum *status)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
@@ -587,7 +587,7 @@ pk_backend_get_job_status (PkBackend *ba
* pk_backend_get_job_role:
**/
gboolean
-pk_backend_get_job_role (PkBackend *backend, PkTaskRole *role, const gchar **package_id)
+pk_backend_get_job_role (PkBackend *backend, PkRoleEnum *role, const gchar **package_id)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
@@ -618,7 +618,7 @@ pk_backend_finished_idle (gpointer data)
* pk_backend_finished:
**/
gboolean
-pk_backend_finished (PkBackend *backend, PkTaskExit exit)
+pk_backend_finished (PkBackend *backend, PkExitEnum exit)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
diff --git a/src/pk-backend.h b/src/pk-backend.h
index 7c3db69..ef7701f 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -38,20 +38,20 @@ gboolean pk_backend_change_percentage
gboolean pk_backend_change_sub_percentage (PkBackend *backend,
guint percentage);
gboolean pk_backend_change_job_status (PkBackend *backend,
- PkTaskStatus status);
+ PkStatusEnum status);
gboolean pk_backend_no_percentage_updates (PkBackend *backend);
gboolean pk_backend_finished (PkBackend *backend,
- PkTaskExit exit);
+ PkExitEnum exit);
gboolean pk_backend_package (PkBackend *backend,
guint value,
const gchar *package_id,
const gchar *summary);
gboolean pk_backend_require_restart (PkBackend *backend,
- PkTaskRestart restart,
+ PkRestartEnum restart,
const gchar *details);
gboolean pk_backend_description (PkBackend *backend,
const gchar *package,
- PkTaskGroup group,
+ PkGroupEnum group,
const gchar *description,
const gchar *url);
gboolean pk_backend_error_code (PkBackend *backend,
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 0fff6ea..4a0a04e 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -247,7 +247,7 @@ pk_engine_job_list_changed (PkEngine *en
* pk_engine_job_status_changed_cb:
**/
static void
-pk_engine_job_status_changed_cb (PkTask *task, PkTaskStatus status, PkEngine *engine)
+pk_engine_job_status_changed_cb (PkTask *task, PkStatusEnum status, PkEngine *engine)
{
PkEngineMap *map;
const gchar *status_text;
@@ -355,7 +355,7 @@ pk_engine_package_cb (PkTask *task, guin
* pk_engine_error_code_cb:
**/
static void
-pk_engine_error_code_cb (PkTask *task, PkTaskErrorCode code, const gchar *details, PkEngine *engine)
+pk_engine_error_code_cb (PkTask *task, PkErrorCodeEnum code, const gchar *details, PkEngine *engine)
{
PkEngineMap *map;
const gchar *code_text;
@@ -378,7 +378,7 @@ pk_engine_error_code_cb (PkTask *task, P
* pk_engine_require_restart_cb:
**/
static void
-pk_engine_require_restart_cb (PkTask *task, PkTaskRestart restart, const gchar *details, PkEngine *engine)
+pk_engine_require_restart_cb (PkTask *task, PkRestartEnum restart, const gchar *details, PkEngine *engine)
{
PkEngineMap *map;
const gchar *restart_text;
@@ -401,7 +401,7 @@ pk_engine_require_restart_cb (PkTask *ta
* pk_engine_description_cb:
**/
static void
-pk_engine_description_cb (PkTask *task, const gchar *package_id, PkTaskGroup group,
+pk_engine_description_cb (PkTask *task, const gchar *package_id, PkGroupEnum group,
const gchar *detail, const gchar *url, PkEngine *engine)
{
PkEngineMap *map;
@@ -425,7 +425,7 @@ pk_engine_description_cb (PkTask *task,
* pk_engine_finished_cb:
**/
static void
-pk_engine_finished_cb (PkTask *task, PkTaskExit exit, PkEngine *engine)
+pk_engine_finished_cb (PkTask *task, PkExitEnum exit, PkEngine *engine)
{
PkEngineMap *map;
const gchar *exit_text;
@@ -1080,7 +1080,7 @@ pk_engine_update_system (PkEngine *engin
{
guint i;
guint length;
- PkTaskRole role;
+ PkRoleEnum role;
gboolean ret;
GError *error;
PkTask *task;
@@ -1307,7 +1307,7 @@ gboolean
pk_engine_get_job_status (PkEngine *engine, guint job,
const gchar **status, GError **error)
{
- PkTaskStatus status_enum;
+ PkStatusEnum status_enum;
PkEngineMap *map;
g_return_val_if_fail (engine != NULL, FALSE);
@@ -1333,7 +1333,7 @@ pk_engine_get_job_role (PkEngine *engine
const gchar **role, const gchar **package_id, GError **error)
{
PkEngineMap *map;
- PkTaskRole role_enum;
+ PkRoleEnum role_enum;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
diff-tree edaeb012a561244ca9f51bcb9b2016dfc60605a6 (from e449078f9f26c8f012421e2a3ee399548b8727b6)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 9 18:13:30 2007 +0100
use PkEnumList when getting capabilities
diff --git a/client/pk-console.c b/client/pk-console.c
index d344105..a461994 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -140,7 +140,6 @@ pk_console_parse_multiple_commands (PkTa
const gchar *details = NULL;
guint remove;
PkEnumList *elist;
- gchar *text;
mode = g_ptr_array_index (array, 0);
if (array->len > 1) {
@@ -257,45 +256,18 @@ pk_console_parse_multiple_commands (PkTa
pk_task_client_get_updates (tclient);
remove = 2;
} else if (strcmp (value, "actions") == 0) {
- /* get backend actions */
- text = pk_task_client_get_actions (tclient);
-
- /* push into a PkEnumList */
- elist = pk_enum_list_new ();
- pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
- pk_enum_list_from_string (elist, text);
+ elist = pk_task_client_get_actions (tclient);
pk_enum_list_print (elist);
-
- /* don't leak */
- g_free (text);
g_object_unref (elist);
remove = 2;
} else if (strcmp (value, "filters") == 0) {
- /* get backend filters */
- text = pk_task_client_get_filters (tclient);
-
- /* push into a PkEnumList */
- elist = pk_enum_list_new ();
- pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
- pk_enum_list_from_string (elist, text);
+ elist = pk_task_client_get_filters (tclient);
pk_enum_list_print (elist);
-
- /* don't leak */
- g_free (text);
g_object_unref (elist);
remove = 2;
} else if (strcmp (value, "groups") == 0) {
- /* get backend groups */
- text = pk_task_client_get_groups (tclient);
-
- /* push into a PkEnumList */
- elist = pk_enum_list_new ();
- pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
- pk_enum_list_from_string (elist, text);
+ elist = pk_task_client_get_groups (tclient);
pk_enum_list_print (elist);
-
- /* don't leak */
- g_free (text);
g_object_unref (elist);
remove = 2;
} else {
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
index ee1da70..6a694e6 100644
--- a/libpackagekit/pk-task-client.c
+++ b/libpackagekit/pk-task-client.c
@@ -867,16 +867,20 @@ pk_task_client_cancel_job_try (PkTaskCli
/**
* pk_task_client_get_actions:
**/
-gchar *
+PkEnumList *
pk_task_client_get_actions (PkTaskClient *tclient)
{
gboolean ret;
GError *error;
gchar *actions;
+ PkEnumList *elist;
g_return_val_if_fail (tclient != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
+ elist = pk_enum_list_new ();
+ pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
+
error = NULL;
ret = dbus_g_proxy_call (tclient->priv->proxy, "GetActions", &error,
G_TYPE_INVALID,
@@ -886,24 +890,32 @@ pk_task_client_get_actions (PkTaskClient
/* abort as the DBUS method failed */
pk_warning ("GetActions failed :%s", error->message);
g_error_free (error);
- return NULL;
+ return elist;
}
- return actions;
+
+ /* convert to enumerated types */
+ pk_enum_list_from_string (elist, actions);
+ g_free (actions);
+ return elist;
}
/**
* pk_task_client_get_groups:
**/
-gchar *
+PkEnumList *
pk_task_client_get_groups (PkTaskClient *tclient)
{
gboolean ret;
GError *error;
gchar *groups;
+ PkEnumList *elist;
g_return_val_if_fail (tclient != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
+ elist = pk_enum_list_new ();
+ pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_GROUP);
+
error = NULL;
ret = dbus_g_proxy_call (tclient->priv->proxy, "GetGroups", &error,
G_TYPE_INVALID,
@@ -913,25 +925,32 @@ pk_task_client_get_groups (PkTaskClient
/* abort as the DBUS method failed */
pk_warning ("GetGroups failed :%s", error->message);
g_error_free (error);
- return NULL;
+ return elist;
}
- return groups;
+
+ /* convert to enumerated types */
+ pk_enum_list_from_string (elist, groups);
+ g_free (groups);
+ return elist;
}
/**
* pk_task_client_get_filters:
- * TODO: convert to enumerated types here...
**/
-gchar *
+PkEnumList *
pk_task_client_get_filters (PkTaskClient *tclient)
{
gboolean ret;
GError *error;
gchar *filters;
+ PkEnumList *elist;
g_return_val_if_fail (tclient != NULL, FALSE);
g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
+ elist = pk_enum_list_new ();
+ pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_FILTER);
+
error = NULL;
ret = dbus_g_proxy_call (tclient->priv->proxy, "GetFilters", &error,
G_TYPE_INVALID,
@@ -941,9 +960,13 @@ pk_task_client_get_filters (PkTaskClient
/* abort as the DBUS method failed */
pk_warning ("GetFilters failed :%s", error->message);
g_error_free (error);
- return NULL;
+ return elist;
}
- return filters;
+
+ /* convert to enumerated types */
+ pk_enum_list_from_string (elist, filters);
+ g_free (filters);
+ return elist;
}
/**
diff --git a/libpackagekit/pk-task-client.h b/libpackagekit/pk-task-client.h
index 3bc1569..67ce0b7 100644
--- a/libpackagekit/pk-task-client.h
+++ b/libpackagekit/pk-task-client.h
@@ -24,6 +24,7 @@
#include <glib-object.h>
#include "pk-enum.h"
+#include "pk-enum-list.h"
G_BEGIN_DECLS
@@ -96,9 +97,9 @@ gboolean pk_task_client_refresh_cache
gboolean pk_task_client_install_package (PkTaskClient *tclient,
const gchar *package_id);
gboolean pk_task_client_cancel_job_try (PkTaskClient *tclient);
-gchar *pk_task_client_get_actions (PkTaskClient *tclient);
-gchar *pk_task_client_get_filters (PkTaskClient *tclient);
-gchar *pk_task_client_get_groups (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);
G_END_DECLS
diff-tree e449078f9f26c8f012421e2a3ee399548b8727b6 (from 1a11ba52cc89bc344a62a750e09e5a72d9d366f0)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 9 18:00:23 2007 +0100
remove two unused files
diff --git a/libpackagekit/pk-action-list.c b/libpackagekit/pk-action-list.c
deleted file mode 100644
index e0c5b60..0000000
--- a/libpackagekit/pk-action-list.c
+++ /dev/null
@@ -1,205 +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 <string.h>
-#include <sys/types.h>
-#include <glib/gi18n.h>
-
-#include "pk-debug.h"
-#include "pk-action-list.h"
-
-/**
- * pk_action_list_new:
- **/
-PkActionList *
-pk_action_list_new (PkTaskAction action, ...)
-{
- va_list args;
- guint i;
- PkActionList *alist;
- PkTaskAction action_temp;
-
- /* create a new list. A list must have at least one entry */
- alist = g_ptr_array_new ();
- g_ptr_array_add (alist, GUINT_TO_POINTER(action));
-
- /* process the valist */
- va_start (args, action);
- for (i=0;; i++) {
- action_temp = va_arg (args, PkTaskAction);
- if (action_temp == 0) break;
- g_ptr_array_add (alist, GUINT_TO_POINTER(action_temp));
- }
- va_end (args);
-
- return alist;
-}
-
-
-/**
- * pk_action_list_new_from_string:
- **/
-PkActionList *
-pk_action_list_new_from_string (const gchar *actions)
-{
- PkActionList *alist;
- gchar **sections;
- guint i;
- PkTaskAction action_temp;
-
- if (actions == NULL) {
- pk_warning ("actions null");
- return FALSE;
- }
-
- /* split by delimeter ';' */
- sections = g_strsplit (actions, ";", 0);
-
- /* create a new list. A list must have at least one entry */
- alist = g_ptr_array_new ();
-
- for (i=0; sections[i]; i++) {
- action_temp = pk_action_enum_from_text (sections[i]);
- g_ptr_array_add (alist, GUINT_TO_POINTER(action_temp));
- }
- g_strfreev (sections);
- return alist;
-}
-
-/**
- * pk_action_list_free:
- **/
-gboolean
-pk_action_list_free (PkActionList *alist)
-{
- g_ptr_array_free (alist, TRUE);
- return TRUE;
-}
-
-/**
- * pk_action_list_to_string:
- **/
-gchar *
-pk_action_list_to_string (PkActionList *alist)
-{
- guint i;
- GString *string;
- PkTaskAction action;
-
- string = g_string_new ("");
- for (i=0; i<alist->len; i++) {
- action = GPOINTER_TO_UINT (g_ptr_array_index (alist, i));
- g_string_append (string, pk_action_enum_to_text (action));
- g_string_append (string, ";");
- }
-
- /* remove last ';' */
- g_string_set_size (string, string->len - 1);
-
- return g_string_free (string, FALSE);
-}
-
-/**
- * pk_action_list_append:
- **/
-gboolean
-pk_action_list_append (PkActionList *alist, PkTaskAction action)
-{
- g_ptr_array_add (alist, GUINT_TO_POINTER(action));
- return TRUE;
-}
-
-/**
- * pk_action_list_contains:
- **/
-gboolean
-pk_action_list_contains (PkActionList *alist, PkTaskAction action)
-{
- guint i;
- for (i=0; i<alist->len; i++) {
- if (GPOINTER_TO_UINT (g_ptr_array_index (alist, i)) == action) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef PK_BUILD_TESTS
-#include <libselftest.h>
-
-void
-libst_action_list (LibSelfTest *test)
-{
- if (libst_start (test, "PkActionList", CLASS_AUTO) == FALSE) {
- return;
- }
-#if 0
- /************************************************************
- **************** ACTIONS ******************
- ************************************************************/
- libst_title (test, "test the action building (single)");
- text = pk_action_enum_build (PK_ACTION_ENUM_INSTALL, 0);
- if (strcmp (text, "install") == 0) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "incorrect single argument '%s'", text);
- }
- g_free (text);
-
- /************************************************************/
- libst_title (test, "test the action building (multiple)");
- text = pk_action_enum_build (PK_ACTION_ENUM_INSTALL, PK_ACTION_ENUM_SEARCH_NAME, PK_ACTION_ENUM_GET_DEPENDS, 0);
- if (strcmp (text, "install;search-name;get-depends") == 0) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "incorrect multiple argument '%s'", text);
- }
-
- /************************************************************/
- libst_title (test, "test the action checking (present)");
- ret = pk_action_enum_contains (text, PK_ACTION_ENUM_INSTALL);
- if (ret == TRUE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "not found present");
- }
-
- /************************************************************/
- libst_title (test, "test the action checking (not-present)");
- ret = pk_action_enum_contains (text, PK_ACTION_ENUM_REMOVE);
- if (ret == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "found present");
- }
- g_free (text);
-#endif
- libst_end (test);
-}
-#endif
-
diff --git a/libpackagekit/pk-action-list.h b/libpackagekit/pk-action-list.h
deleted file mode 100644
index 08a1f47..0000000
--- a/libpackagekit/pk-action-list.h
+++ /dev/null
@@ -1,42 +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_ACTION_LIST_H
-#define __PK_ACTION_LIST_H
-
-#include <glib-object.h>
-#include <pk-enum.h>
-
-G_BEGIN_DECLS
-
-typedef GPtrArray PkActionList;
-PkActionList *pk_action_list_new (PkTaskAction action, ...);
-PkActionList *pk_action_list_new_from_string (const gchar *actions);
-gchar *pk_action_list_to_string (PkActionList *alist);
-gboolean pk_action_list_contains (PkActionList *alist,
- PkTaskAction action);
-gboolean pk_action_list_append (PkActionList *alist,
- PkTaskAction action);
-gboolean pk_action_list_free (PkActionList *alist);
-
-G_END_DECLS
-
-#endif /* __PK_ACTION_LIST_H */
diff-tree 1a11ba52cc89bc344a62a750e09e5a72d9d366f0 (from 2d30206e8d6b5312641f8970a7be9ae1a2583695)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 9 18:00:00 2007 +0100
allow the backend to specify what groups and filters it supports
diff --git a/TODO b/TODO
index c8d9fb9..f0413eb 100644
--- a/TODO
+++ b/TODO
@@ -9,9 +9,6 @@ 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 methods so backends can advertise filters and groups ***
-Add GetFilters and GetGroups into the API and command line tools
-
*** Split up PolicyKit install into different types ***
Have different permissions for signed and unsigned repos.
diff --git a/backends/apt/pk-backend-apt.cpp b/backends/apt/pk-backend-apt.cpp
index ce45293..5e24588 100644
--- a/backends/apt/pk-backend-apt.cpp
+++ b/backends/apt/pk-backend-apt.cpp
@@ -261,6 +261,34 @@ void *do_update_thread(gpointer data)
}
/**
+ * backend_get_groups:
+ */
+static void
+backend_get_groups (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_GROUP_ENUM_ACCESSIBILITY,
+ PK_GROUP_ENUM_GAMES,
+ PK_GROUP_ENUM_SYSTEM,
+ 0);
+}
+
+/**
+ * backend_get_filters:
+ */
+static void
+backend_get_filters (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_FILTER_ENUM_GUI,
+ PK_FILTER_ENUM_INSTALLED,
+ PK_FILTER_ENUM_DEVELOPMENT,
+ 0);
+}
+
+/**
* backend_refresh_cache:
**/
static void backend_refresh_cache(PkBackend * backend, gboolean force)
@@ -631,6 +659,8 @@ extern "C" PK_BACKEND_OPTIONS (
"Richard Hughes <richard at hughsie.com>", /* author */
NULL, /* initalize */
NULL, /* destroy */
+ backend_get_groups, /* get_groups */
+ backend_get_filters, /* get_filters */
NULL, /* cancel_job_try */
NULL, /* get_depends */
backend_get_description, /* get_description */
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index f0a9ab3..c03c727 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -321,6 +321,34 @@ backend_destroy (PkBackend *backend)
}
/**
+ * backend_get_groups:
+ */
+static void
+backend_get_groups (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_GROUP_ENUM_ACCESSIBILITY,
+ PK_GROUP_ENUM_GAMES,
+ PK_GROUP_ENUM_SYSTEM,
+ 0);
+}
+
+/**
+ * backend_get_filters:
+ */
+static void
+backend_get_filters (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_FILTER_ENUM_GUI,
+ PK_FILTER_ENUM_INSTALLED,
+ PK_FILTER_ENUM_DEVELOPMENT,
+ 0);
+}
+
+/**
* backend_get_description:
*/
static void
@@ -412,6 +440,8 @@ PK_BACKEND_OPTIONS (
"Grzegorz DÄ
browski <gdx at o2.pl>", /* author */
backend_initalize, /* initalize */
backend_destroy, /* destroy */
+ backend_get_groups, /* get_groups */
+ backend_get_filters, /* get_filters */
NULL, /* cancel_job_try */
NULL, /* get_depends */
backend_get_description, /* get_description */
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index f1bac73..c9e62e7 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -26,6 +26,34 @@
#include <pk-backend.h>
/**
+ * backend_get_groups:
+ */
+static void
+backend_get_groups (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_GROUP_ENUM_ACCESSIBILITY,
+ PK_GROUP_ENUM_GAMES,
+ PK_GROUP_ENUM_SYSTEM,
+ 0);
+}
+
+/**
+ * backend_get_filters:
+ */
+static void
+backend_get_filters (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_FILTER_ENUM_GUI,
+ PK_FILTER_ENUM_INSTALLED,
+ PK_FILTER_ENUM_DEVELOPMENT,
+ 0);
+}
+
+/**
* backend_get_description:
*/
static void
@@ -123,6 +151,8 @@ PK_BACKEND_OPTIONS (
"Ken VanDine <ken at vandine.org>", /* author */
NULL, /* initalize */
NULL, /* destroy */
+ backend_get_groups, /* get_groups */
+ backend_get_filters, /* get_filters */
NULL, /* cancel_job_try */
NULL, /* get_depends */
backend_get_description, /* get_description */
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index 007567f..1075ec6 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -46,6 +46,34 @@ backend_destroy (PkBackend *backend)
}
/**
+ * backend_get_groups:
+ */
+static void
+backend_get_groups (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_GROUP_ENUM_ACCESSIBILITY,
+ PK_GROUP_ENUM_GAMES,
+ PK_GROUP_ENUM_SYSTEM,
+ 0);
+}
+
+/**
+ * backend_get_filters:
+ */
+static void
+backend_get_filters (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_FILTER_ENUM_GUI,
+ PK_FILTER_ENUM_INSTALLED,
+ PK_FILTER_ENUM_DEVELOPMENT,
+ 0);
+}
+
+/**
* backend_cancel_job_try:
*/
static void
@@ -274,6 +302,8 @@ PK_BACKEND_OPTIONS (
"Richard Hughes <richard at hughsie.com>", /* author */
backend_initalize, /* initalize */
backend_destroy, /* destroy */
+ backend_get_groups, /* get_groups */
+ backend_get_filters, /* get_filters */
backend_cancel_job_try, /* cancel_job_try */
backend_get_depends, /* get_depends */
backend_get_description, /* get_description */
diff --git a/backends/test/pk-backend-test.c b/backends/test/pk-backend-test.c
index c7c1698..333de71 100644
--- a/backends/test/pk-backend-test.c
+++ b/backends/test/pk-backend-test.c
@@ -43,6 +43,34 @@ backend_destroy (PkBackend *backend)
}
/**
+ * backend_get_groups:
+ */
+static void
+backend_get_groups (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_GROUP_ENUM_ACCESSIBILITY,
+ PK_GROUP_ENUM_GAMES,
+ PK_GROUP_ENUM_SYSTEM,
+ 0);
+}
+
+/**
+ * backend_get_filters:
+ */
+static void
+backend_get_filters (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_FILTER_ENUM_GUI,
+ PK_FILTER_ENUM_INSTALLED,
+ PK_FILTER_ENUM_DEVELOPMENT,
+ 0);
+}
+
+/**
* backend_cancel_job_try:
*/
static void
@@ -188,6 +216,8 @@ PK_BACKEND_OPTIONS (
"Richard Hughes <richard at hughsie.com>", /* author */
backend_initalize, /* initalize */
backend_destroy, /* destroy */
+ backend_get_groups, /* get_groups */
+ backend_get_filters, /* get_filters */
backend_cancel_job_try, /* cancel_job_try */
backend_get_depends, /* get_depends */
backend_get_description, /* get_description */
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 8a97a30..8aa7b84 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -25,6 +25,34 @@
#include <pk-backend.h>
/**
+ * backend_get_groups:
+ */
+static void
+backend_get_groups (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_GROUP_ENUM_ACCESSIBILITY,
+ PK_GROUP_ENUM_GAMES,
+ PK_GROUP_ENUM_SYSTEM,
+ 0);
+}
+
+/**
+ * backend_get_filters:
+ */
+static void
+backend_get_filters (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_FILTER_ENUM_GUI,
+ PK_FILTER_ENUM_INSTALLED,
+ PK_FILTER_ENUM_DEVELOPMENT,
+ 0);
+}
+
+/**
* backend_cancel_job_try:
*/
static void
@@ -192,6 +220,8 @@ PK_BACKEND_OPTIONS (
"Richard Hughes <richard at hughsie.com>", /* author */
NULL, /* initalize */
NULL, /* destroy */
+ backend_get_groups, /* get_groups */
+ backend_get_filters, /* get_filters */
backend_cancel_job_try, /* cancel_job_try */
backend_get_depends, /* get_depends */
backend_get_description, /* get_description */
diff --git a/client/pk-console.c b/client/pk-console.c
index 9c73e4b..d344105 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -270,6 +270,34 @@ pk_console_parse_multiple_commands (PkTa
g_free (text);
g_object_unref (elist);
remove = 2;
+ } else if (strcmp (value, "filters") == 0) {
+ /* get backend filters */
+ text = pk_task_client_get_filters (tclient);
+
+ /* push into a PkEnumList */
+ elist = pk_enum_list_new ();
+ pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
+ pk_enum_list_from_string (elist, text);
+ pk_enum_list_print (elist);
+
+ /* don't leak */
+ g_free (text);
+ g_object_unref (elist);
+ remove = 2;
+ } else if (strcmp (value, "groups") == 0) {
+ /* get backend groups */
+ text = pk_task_client_get_groups (tclient);
+
+ /* push into a PkEnumList */
+ elist = pk_enum_list_new ();
+ pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
+ pk_enum_list_from_string (elist, text);
+ pk_enum_list_print (elist);
+
+ /* don't leak */
+ g_free (text);
+ g_object_unref (elist);
+ remove = 2;
} else {
pk_console_usage ("invalid get type");
}
diff --git a/libpackagekit/pk-enum-list.c b/libpackagekit/pk-enum-list.c
index f652d46..03bf318 100644
--- a/libpackagekit/pk-enum-list.c
+++ b/libpackagekit/pk-enum-list.c
@@ -106,6 +106,10 @@ pk_enum_list_from_string (PkEnumList *el
for (i=0; sections[i]; i++) {
if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
value_temp = pk_action_enum_from_text (sections[i]);
+ } else if (elist->priv->type == PK_ENUM_LIST_TYPE_GROUP) {
+ value_temp = pk_group_enum_from_text (sections[i]);
+ } else if (elist->priv->type == PK_ENUM_LIST_TYPE_FILTER) {
+ value_temp = pk_filter_enum_from_text (sections[i]);
} else {
pk_error ("unknown type %i (did you use pk_enum_list_set_type?)", elist->priv->type);
}
@@ -137,6 +141,10 @@ pk_enum_list_to_string (PkEnumList *elis
value = GPOINTER_TO_UINT (g_ptr_array_index (elist->priv->data, i));
if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
text = pk_action_enum_to_text (value);
+ } else if (elist->priv->type == PK_ENUM_LIST_TYPE_GROUP) {
+ text = pk_group_enum_to_text (value);
+ } else if (elist->priv->type == PK_ENUM_LIST_TYPE_FILTER) {
+ text = pk_filter_enum_to_text (value);
} else {
pk_error ("unknown type %i (did you use pk_enum_list_set_type?)", elist->priv->type);
}
@@ -162,11 +170,19 @@ pk_enum_list_print (PkEnumList *elist)
if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
g_print ("Printing actions:\n");
+ } else if (elist->priv->type == PK_ENUM_LIST_TYPE_GROUP) {
+ g_print ("Printing groups:\n");
+ } else if (elist->priv->type == PK_ENUM_LIST_TYPE_FILTER) {
+ g_print ("Printing filters:\n");
}
for (i=0; i<elist->priv->data->len; i++) {
value = GPOINTER_TO_UINT (g_ptr_array_index (elist->priv->data, i));
if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
text = pk_action_enum_to_text (value);
+ } else if (elist->priv->type == PK_ENUM_LIST_TYPE_GROUP) {
+ text = pk_group_enum_to_text (value);
+ } else if (elist->priv->type == PK_ENUM_LIST_TYPE_FILTER) {
+ text = pk_filter_enum_to_text (value);
} else {
pk_error ("unknown type %i (did you use pk_enum_list_set_type?)", elist->priv->type);
}
diff --git a/libpackagekit/pk-enum-list.h b/libpackagekit/pk-enum-list.h
index 58efa14..a65d120 100644
--- a/libpackagekit/pk-enum-list.h
+++ b/libpackagekit/pk-enum-list.h
@@ -48,6 +48,8 @@ typedef struct
typedef enum {
PK_ENUM_LIST_TYPE_ACTION,
+ PK_ENUM_LIST_TYPE_GROUP,
+ PK_ENUM_LIST_TYPE_FILTER,
PK_ENUM_LIST_TYPE_UNKNOWN
} PkEnumListType;
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 7cca080..b014caa 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -92,6 +92,13 @@ static PkTaskEnumMatch task_restart[] =
{0, NULL},
};
+static PkTaskEnumMatch task_filter[] = {
+ {PK_FILTER_ENUM_DEVELOPMENT, "devel"},
+ {PK_FILTER_ENUM_INSTALLED, "installed"},
+ {PK_FILTER_ENUM_GUI, "gui"},
+ {0, NULL},
+};
+
static PkTaskEnumMatch task_group[] = {
{PK_GROUP_ENUM_ACCESSIBILITY, "accessibility"},
{PK_GROUP_ENUM_ACCESSORIES, "accessories"},
@@ -281,6 +288,24 @@ pk_group_enum_to_text (PkTaskGroup group
}
/**
+ * pk_filter_enum_from_text:
+ **/
+PkTaskFilter
+pk_filter_enum_from_text (const gchar *filter)
+{
+ return pk_task_enum_find_value (task_filter, filter);
+}
+
+/**
+ * pk_filter_enum_to_text:
+ **/
+const gchar *
+pk_filter_enum_to_text (PkTaskFilter filter)
+{
+ return pk_task_enum_find_string (task_filter, filter);
+}
+
+/**
* pk_action_enum_from_text:
**/
PkTaskAction
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 63580e3..981f365 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -58,6 +58,13 @@ typedef enum {
} PkTaskExit;
typedef enum {
+ PK_FILTER_ENUM_DEVELOPMENT,
+ PK_FILTER_ENUM_INSTALLED,
+ PK_FILTER_ENUM_GUI,
+ PK_FILTER_ENUM_UNKNOWN
+} PkTaskFilter;
+
+typedef enum {
PK_RESTART_ENUM_NONE,
PK_RESTART_ENUM_APPLICATION,
PK_RESTART_ENUM_SESSION,
@@ -135,6 +142,9 @@ const gchar *pk_restart_enum_to_text (P
PkTaskGroup pk_group_enum_from_text (const gchar *group);
const gchar *pk_group_enum_to_text (PkTaskGroup group);
+PkTaskFilter pk_filter_enum_from_text (const gchar *filter);
+const gchar *pk_filter_enum_to_text (PkTaskFilter filter);
+
PkTaskAction pk_action_enum_from_text (const gchar *action);
const gchar *pk_action_enum_to_text (PkTaskAction action);
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
index ae03767..ee1da70 100644
--- a/libpackagekit/pk-task-client.c
+++ b/libpackagekit/pk-task-client.c
@@ -892,6 +892,61 @@ pk_task_client_get_actions (PkTaskClient
}
/**
+ * pk_task_client_get_groups:
+ **/
+gchar *
+pk_task_client_get_groups (PkTaskClient *tclient)
+{
+ gboolean ret;
+ GError *error;
+ gchar *groups;
+
+ 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, "GetGroups", &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &groups,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetGroups failed :%s", error->message);
+ g_error_free (error);
+ return NULL;
+ }
+ return groups;
+}
+
+/**
+ * pk_task_client_get_filters:
+ * TODO: convert to enumerated types here...
+ **/
+gchar *
+pk_task_client_get_filters (PkTaskClient *tclient)
+{
+ gboolean ret;
+ GError *error;
+ gchar *filters;
+
+ 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, "GetFilters", &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &filters,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetFilters failed :%s", error->message);
+ g_error_free (error);
+ return NULL;
+ }
+ return filters;
+}
+
+/**
* pk_task_client_finished_cb:
*/
static void
diff --git a/libpackagekit/pk-task-client.h b/libpackagekit/pk-task-client.h
index b119034..3bc1569 100644
--- a/libpackagekit/pk-task-client.h
+++ b/libpackagekit/pk-task-client.h
@@ -97,6 +97,8 @@ 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);
+gchar *pk_task_client_get_filters (PkTaskClient *tclient);
+gchar *pk_task_client_get_groups (PkTaskClient *tclient);
gboolean pk_task_client_reset (PkTaskClient *tclient);
G_END_DECLS
diff --git a/src/pk-backend-internal.h b/src/pk-backend-internal.h
index d33d18a..36225dd 100644
--- a/src/pk-backend-internal.h
+++ b/src/pk-backend-internal.h
@@ -56,6 +56,8 @@ typedef PkBackend PkTask;
GType pk_backend_get_type (void);
PkBackend *pk_backend_new (void);
PkEnumList *pk_backend_get_actions (PkBackend *backend);
+PkEnumList *pk_backend_get_groups (PkBackend *backend);
+PkEnumList *pk_backend_get_filters (PkBackend *backend);
gdouble pk_backend_get_runtime (PkBackend *backend);
gboolean pk_backend_load (PkBackend *backend,
const gchar *name);
diff --git a/src/pk-backend.c b/src/pk-backend.c
index a45b369..a48a15f 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -968,6 +968,40 @@ pk_backend_get_actions (PkBackend *backe
}
/**
+ * pk_backend_get_groups:
+ *
+ * You need to g_object_unref the returned object
+ */
+PkEnumList *
+pk_backend_get_groups (PkBackend *backend)
+{
+ PkEnumList *elist;
+ elist = pk_enum_list_new ();
+ pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_GROUP);
+ if (backend->desc->get_groups != NULL) {
+ backend->desc->get_groups (backend, elist);
+ }
+ return elist;
+}
+
+/**
+ * pk_backend_get_filters:
+ *
+ * You need to g_object_unref the returned object
+ */
+PkEnumList *
+pk_backend_get_filters (PkBackend *backend)
+{
+ PkEnumList *elist;
+ elist = pk_enum_list_new ();
+ pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_FILTER);
+ if (backend->desc->get_filters != NULL) {
+ backend->desc->get_filters (backend, elist);
+ }
+ return elist;
+}
+
+/**
* pk_backend_get_runtime:
*/
gdouble
diff --git a/src/pk-backend.h b/src/pk-backend.h
index 47f513e..7c3db69 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -24,6 +24,7 @@
#include <glib.h>
#include <pk-enum.h>
+#include <pk-enum-list.h>
#include <pk-package-id.h>
G_BEGIN_DECLS
@@ -72,6 +73,8 @@ struct _PkBackendDesc {
const char *author;
void (*initialize) (PkBackend *backend);
void (*destroy) (PkBackend *backend);
+ void (*get_groups) (PkBackend *backend, PkEnumList *elist);
+ void (*get_filters) (PkBackend *backend, PkEnumList *elist);
void (*cancel_job_try) (PkBackend *backend);
void (*get_depends) (PkBackend *backend, const gchar *package_id);
void (*get_description) (PkBackend *backend, const gchar *package_id);
@@ -90,6 +93,7 @@ struct _PkBackendDesc {
};
#define PK_BACKEND_OPTIONS(description, version, author, initialize, destroy, \
+ get_groups, get_filters, \
cancel_job_try, get_depends, get_description, \
get_requires, get_updates, install_package, \
refresh_cache, remove_package, search_details, \
@@ -101,6 +105,8 @@ struct _PkBackendDesc {
author, \
initialize, \
destroy, \
+ get_groups, \
+ get_filters, \
cancel_job_try, \
get_depends, \
get_description, \
diff --git a/src/pk-engine.c b/src/pk-engine.c
index ab2183e..0fff6ea 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -1379,7 +1379,6 @@ pk_engine_cancel_job_try (PkEngine *engi
return TRUE;
}
-
/**
* pk_engine_get_actions:
* @engine: This class instance
@@ -1405,6 +1404,54 @@ pk_engine_get_actions (PkEngine *engine,
}
/**
+ * pk_engine_get_groups:
+ * @engine: This class instance
+ **/
+gboolean
+pk_engine_get_groups (PkEngine *engine, gchar **groups, GError **error)
+{
+ PkTask *task;
+ PkEnumList *elist;
+
+ g_return_val_if_fail (engine != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+
+ /* create a new task and start it */
+ task = pk_engine_new_task (engine);
+ pk_backend_load (task, engine->priv->backend);
+ elist = pk_backend_get_groups (task);
+ *groups = pk_enum_list_to_string (elist);
+ g_object_unref (task);
+ g_object_unref (elist);
+
+ return TRUE;
+}
+
+/**
+ * pk_engine_get_filters:
+ * @engine: This class instance
+ **/
+gboolean
+pk_engine_get_filters (PkEngine *engine, gchar **filters, GError **error)
+{
+ PkTask *task;
+ PkEnumList *elist;
+
+ g_return_val_if_fail (engine != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+
+ /* create a new task and start it */
+ task = pk_engine_new_task (engine);
+ pk_backend_load (task, engine->priv->backend);
+ elist = pk_backend_get_filters (task);
+ *filters = pk_enum_list_to_string (elist);
+ g_object_unref (task);
+ g_object_unref (elist);
+
+ return TRUE;
+}
+
+/**
* pk_engine_get_seconds_idle:
* @engine: This class instance
**/
diff --git a/src/pk-engine.h b/src/pk-engine.h
index c2004db..b954a86 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -145,6 +145,12 @@ gboolean pk_engine_cancel_job_try (PkE
gboolean pk_engine_get_actions (PkEngine *engine,
gchar **actions,
GError **error);
+gboolean pk_engine_get_groups (PkEngine *engine,
+ gchar **groups,
+ GError **error);
+gboolean pk_engine_get_filters (PkEngine *engine,
+ gchar **filters,
+ GError **error);
guint pk_engine_get_seconds_idle (PkEngine *engine);
G_END_DECLS
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index f35db84..1a5901b 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -139,7 +139,13 @@
<!-- General methods -->
<method name="GetActions">
- <arg type="s" name="actions" direction="out"/> <!-- list of supported actions "groups;install;remove" etc -->
+ <arg type="s" name="actions" direction="out"/> <!-- list of supported actions -->
+ </method>
+ <method name="GetGroups">
+ <arg type="s" name="groups" direction="out"/> <!-- list of supported groups -->
+ </method>
+ <method name="GetFilters">
+ <arg type="s" name="filters" direction="out"/> <!-- list of supported filters -->
</method>
</interface>
diff-tree 2d30206e8d6b5312641f8970a7be9ae1a2583695 (from 7d66c380ed7c6d2b3795673f7233fb370d1a6066)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 9 16:57:56 2007 +0100
allow us to get the actions from the console client
diff --git a/client/pk-console.c b/client/pk-console.c
index af452da..9c73e4b 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -31,6 +31,7 @@
#include <pk-debug.h>
#include <pk-task-client.h>
#include <pk-package-id.h>
+#include <pk-enum-list.h>
/**
* pk_console_package_cb:
@@ -138,6 +139,8 @@ pk_console_parse_multiple_commands (PkTa
const gchar *value = NULL;
const gchar *details = NULL;
guint remove;
+ PkEnumList *elist;
+ gchar *text;
mode = g_ptr_array_index (array, 0);
if (array->len > 1) {
@@ -253,6 +256,20 @@ pk_console_parse_multiple_commands (PkTa
pk_task_client_set_sync (tclient, TRUE);
pk_task_client_get_updates (tclient);
remove = 2;
+ } else if (strcmp (value, "actions") == 0) {
+ /* get backend actions */
+ text = pk_task_client_get_actions (tclient);
+
+ /* push into a PkEnumList */
+ elist = pk_enum_list_new ();
+ pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
+ pk_enum_list_from_string (elist, text);
+ pk_enum_list_print (elist);
+
+ /* don't leak */
+ g_free (text);
+ g_object_unref (elist);
+ remove = 2;
} else {
pk_console_usage ("invalid get type");
}
diff --git a/libpackagekit/pk-enum-list.c b/libpackagekit/pk-enum-list.c
index a0d42f0..f652d46 100644
--- a/libpackagekit/pk-enum-list.c
+++ b/libpackagekit/pk-enum-list.c
@@ -151,6 +151,32 @@ pk_enum_list_to_string (PkEnumList *elis
}
/**
+ * pk_enum_list_print:
+ **/
+gboolean
+pk_enum_list_print (PkEnumList *elist)
+{
+ guint i;
+ guint value;
+ const gchar *text = NULL;
+
+ if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
+ g_print ("Printing actions:\n");
+ }
+ for (i=0; i<elist->priv->data->len; i++) {
+ value = GPOINTER_TO_UINT (g_ptr_array_index (elist->priv->data, i));
+ if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
+ text = pk_action_enum_to_text (value);
+ } else {
+ pk_error ("unknown type %i (did you use pk_enum_list_set_type?)", elist->priv->type);
+ }
+ g_print ("%s\n", text);
+ }
+
+ return TRUE;
+}
+
+/**
* pk_enum_list_append:
**/
gboolean
diff --git a/libpackagekit/pk-enum-list.h b/libpackagekit/pk-enum-list.h
index 65ec9cd..58efa14 100644
--- a/libpackagekit/pk-enum-list.h
+++ b/libpackagekit/pk-enum-list.h
@@ -58,11 +58,12 @@ gboolean pk_enum_list_set_type (PkEnu
PkEnumListType type);
gboolean pk_enum_list_from_string (PkEnumList *elist,
const gchar *enums);
-gchar *pk_enum_list_to_string (PkEnumList *alist);
-gboolean pk_enum_list_contains (PkEnumList *alist,
+gchar *pk_enum_list_to_string (PkEnumList *elist);
+gboolean pk_enum_list_contains (PkEnumList *elist,
guint value);
-gboolean pk_enum_list_append (PkEnumList *alist,
+gboolean pk_enum_list_append (PkEnumList *elist,
guint value);
+gboolean pk_enum_list_print (PkEnumList *elist);
gboolean pk_enum_list_append_multiple (PkEnumList *elist,
guint value, ...);
diff-tree 7d66c380ed7c6d2b3795673f7233fb370d1a6066 (from da9248a72b0859bef2194097437acb215b49f4c5)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 9 16:47:12 2007 +0100
make the PkActionList into a more generic PkEnumList for future usage in the filter and groups code
diff --git a/TODO b/TODO
index 52f7143..c8d9fb9 100644
--- a/TODO
+++ b/TODO
@@ -6,14 +6,12 @@ but write jobs are done in serial. Maybe
paused state?
NOTE: RELEASE BLOCKER
-*** Write some XML documentation ***
-The backends/README file is woefully inadaquate for backend writers or even
-people who just want to know how PK works.
-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 methods so backends can advertise filters and groups ***
+Add GetFilters and GetGroups into the API and command line tools
+
*** Split up PolicyKit install into different types ***
Have different permissions for signed and unsigned repos.
@@ -50,6 +48,7 @@ string updates
string obsoletes
string update_text
}
+NOTE: RELEASE BLOCKER
*** Have to have an UpdatesChanged signal ***
For the icon to update after we've done a system upgrade
diff --git a/libpackagekit/Makefile.am b/libpackagekit/Makefile.am
index 9e558ca..56b7437 100644
--- a/libpackagekit/Makefile.am
+++ b/libpackagekit/Makefile.am
@@ -28,7 +28,7 @@ libpackagekit_include_HEADERS = \
pk-debug.h \
pk-connection.h \
pk-package-id.h \
- pk-action-list.h \
+ pk-enum-list.h \
pk-enum.h \
pk-task-common.h \
pk-task-monitor.h \
@@ -47,8 +47,8 @@ libpackagekit_la_SOURCES = \
pk-connection.h \
pk-package-id.h \
pk-package-id.c \
- pk-action-list.c \
- pk-action-list.h \
+ pk-enum-list.c \
+ pk-enum-list.h \
pk-enum.h \
pk-enum.c \
pk-task-common.c \
@@ -83,6 +83,8 @@ pk_self_test_SOURCES = \
pk-debug.h \
pk-enum.h \
pk-enum.c \
+ pk-enum-list.h \
+ pk-enum-list.c \
pk-package-id.h \
pk-package-id.c \
pk-self-test.c \
diff --git a/libpackagekit/pk-enum-list.c b/libpackagekit/pk-enum-list.c
new file mode 100644
index 0000000..a0d42f0
--- /dev/null
+++ b/libpackagekit/pk-enum-list.c
@@ -0,0 +1,317 @@
+/* -*- 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 <string.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-enum.h"
+#include "pk-enum-list.h"
+
+static void pk_enum_list_class_init (PkEnumListClass *klass);
+static void pk_enum_list_init (PkEnumList *enum_list);
+static void pk_enum_list_finalize (GObject *object);
+
+#define PK_ENUM_LIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_ENUM_LIST, PkEnumListPrivate))
+
+struct PkEnumListPrivate
+{
+ PkEnumListType type;
+ GPtrArray *data;
+};
+
+G_DEFINE_TYPE (PkEnumList, pk_enum_list, G_TYPE_OBJECT)
+
+/**
+ * pk_enum_list_set_type:
+ **/
+gboolean
+pk_enum_list_set_type (PkEnumList *elist, PkEnumListType type)
+{
+ elist->priv->type = type;
+ return TRUE;
+}
+
+/**
+ * pk_enum_list_append_multiple:
+ **/
+gboolean
+pk_enum_list_append_multiple (PkEnumList *elist, guint value, ...)
+{
+ va_list args;
+ guint i;
+ guint value_temp;
+
+ /* create a new list. A list must have at least one entry */
+ g_ptr_array_add (elist->priv->data, GUINT_TO_POINTER(value));
+
+ /* process the valist */
+ va_start (args, value);
+ for (i=0;; i++) {
+ value_temp = va_arg (args, guint);
+ if (value_temp == 0) break;
+ g_ptr_array_add (elist->priv->data, GUINT_TO_POINTER(value_temp));
+ }
+ va_end (args);
+
+ return TRUE;
+}
+
+
+/**
+ * pk_enum_list_from_string:
+ **/
+gboolean
+pk_enum_list_from_string (PkEnumList *elist, const gchar *enums)
+{
+ gchar **sections;
+ guint i;
+ guint value_temp = 0;
+
+ if (enums == NULL) {
+ pk_warning ("enums null");
+ return FALSE;
+ }
+
+ /* split by delimeter ';' */
+ sections = g_strsplit (enums, ";", 0);
+ for (i=0; sections[i]; i++) {
+ if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
+ value_temp = pk_action_enum_from_text (sections[i]);
+ } else {
+ pk_error ("unknown type %i (did you use pk_enum_list_set_type?)", elist->priv->type);
+ }
+ g_ptr_array_add (elist->priv->data, GUINT_TO_POINTER(value_temp));
+ }
+ g_strfreev (sections);
+ return TRUE;
+}
+
+/**
+ * pk_enum_list_to_string:
+ **/
+gchar *
+pk_enum_list_to_string (PkEnumList *elist)
+{
+ guint i;
+ GString *string;
+ guint value;
+ guint length;
+ const gchar *text = NULL;
+
+ length = elist->priv->data->len;
+ if (length == 0) {
+ return g_strdup ("none");
+ }
+
+ string = g_string_new ("");
+ for (i=0; i<length; i++) {
+ value = GPOINTER_TO_UINT (g_ptr_array_index (elist->priv->data, i));
+ if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
+ text = pk_action_enum_to_text (value);
+ } else {
+ pk_error ("unknown type %i (did you use pk_enum_list_set_type?)", elist->priv->type);
+ }
+ g_string_append (string, text);
+ g_string_append (string, ";");
+ }
+
+ /* remove last ';' */
+ g_string_set_size (string, string->len - 1);
+
+ return g_string_free (string, FALSE);
+}
+
+/**
+ * pk_enum_list_append:
+ **/
+gboolean
+pk_enum_list_append (PkEnumList *elist, guint value)
+{
+ g_ptr_array_add (elist->priv->data, GUINT_TO_POINTER(value));
+ return TRUE;
+}
+
+/**
+ * pk_enum_list_contains:
+ **/
+gboolean
+pk_enum_list_contains (PkEnumList *elist, guint value)
+{
+ guint i;
+ for (i=0; i<elist->priv->data->len; i++) {
+ if (GPOINTER_TO_UINT (g_ptr_array_index (elist->priv->data, i)) == value) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
+ * pk_enum_list_class_init:
+ **/
+static void
+pk_enum_list_class_init (PkEnumListClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = pk_enum_list_finalize;
+ g_type_class_add_private (klass, sizeof (PkEnumListPrivate));
+}
+
+/**
+ * pk_enum_list_init:
+ **/
+static void
+pk_enum_list_init (PkEnumList *elist)
+{
+ elist->priv = PK_ENUM_LIST_GET_PRIVATE (elist);
+ elist->priv->data = g_ptr_array_new ();
+ elist->priv->type = PK_ENUM_LIST_TYPE_UNKNOWN;
+}
+
+/**
+ * pk_enum_list_finalize:
+ **/
+static void
+pk_enum_list_finalize (GObject *object)
+{
+ PkEnumList *elist;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (PK_IS_ENUM_LIST (object));
+ elist = PK_ENUM_LIST (object);
+ g_return_if_fail (elist->priv != NULL);
+
+ g_ptr_array_free (elist->priv->data, TRUE);
+
+ G_OBJECT_CLASS (pk_enum_list_parent_class)->finalize (object);
+}
+
+/**
+ * pk_enum_list_new:
+ **/
+PkEnumList *
+pk_enum_list_new (void)
+{
+ PkEnumList *elist;
+ elist = g_object_new (PK_TYPE_ENUM_LIST, NULL);
+ return PK_ENUM_LIST (elist);
+}
+
+/***************************************************************************
+ *** MAKE CHECK TESTS ***
+ ***************************************************************************/
+#ifdef PK_BUILD_TESTS
+#include <libselftest.h>
+
+void
+libst_enum_list (LibSelfTest *test)
+{
+ if (libst_start (test, "PkEnumList", CLASS_AUTO) == FALSE) {
+ return;
+ }
+
+ PkEnumList *elist;
+ gboolean ret;
+ gchar *text;
+
+ /************************************************************
+ **************** ENUM ******************
+ ************************************************************/
+ libst_title (test, "get a new PkEnumList object");
+ elist = pk_enum_list_new ();
+ if (elist != NULL) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, NULL);
+ }
+
+ /************************************************************/
+ libst_title (test, "set action builder");
+ ret = pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
+ if (ret == TRUE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, NULL);
+ }
+
+ /************************************************************/
+ libst_title (test, "get empty list");
+ text = pk_enum_list_to_string (elist);
+ if (strcmp (text, "none") == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "invalid '%s', should be 'none'", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "append single");
+ ret = pk_enum_list_append (elist, PK_ACTION_ENUM_SEARCH_NAME);
+ if (ret == TRUE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, NULL);
+ }
+
+ /************************************************************/
+ libst_title (test, "get single list");
+ text = pk_enum_list_to_string (elist);
+ if (strcmp (text, "search-name") == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "invalid '%s', should be 'search-name'", text);
+ }
+ g_free (text);
+
+ /************************************************************/
+ libst_title (test, "add multiple");
+ ret = pk_enum_list_append_multiple (elist, PK_ACTION_ENUM_SEARCH_DETAILS, PK_ACTION_ENUM_SEARCH_GROUP, 0);
+ if (ret == TRUE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, NULL);
+ }
+
+ /************************************************************/
+ libst_title (test, "get multiple list");
+ text = pk_enum_list_to_string (elist);
+ if (strcmp (text, "search-name;search-details;search-group") == 0) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "invalid '%s', should be 'search-name;search-details;search-group'", text);
+ }
+ g_free (text);
+
+ g_object_unref (elist);
+ libst_end (test);
+}
+#endif
+
diff --git a/libpackagekit/pk-enum-list.h b/libpackagekit/pk-enum-list.h
new file mode 100644
index 0000000..65ec9cd
--- /dev/null
+++ b/libpackagekit/pk-enum-list.h
@@ -0,0 +1,71 @@
+/* -*- 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_ENUM_LIST_H
+#define __PK_ENUM_LIST_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define PK_TYPE_ENUM_LIST (pk_enum_list_get_type ())
+#define PK_ENUM_LIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_ENUM_LIST, PkEnumList))
+#define PK_ENUM_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_ENUM_LIST, PkEnumListClass))
+#define PK_IS_ENUM_LIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_ENUM_LIST))
+#define PK_IS_ENUM_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_ENUM_LIST))
+#define PK_ENUM_LIST_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_ENUM_LIST, PkEnumListClass))
+
+typedef struct PkEnumListPrivate PkEnumListPrivate;
+
+typedef struct
+{
+ GObject parent;
+ PkEnumListPrivate *priv;
+} PkEnumList;
+
+typedef struct
+{
+ GObjectClass parent_class;
+} PkEnumListClass;
+
+typedef enum {
+ PK_ENUM_LIST_TYPE_ACTION,
+ PK_ENUM_LIST_TYPE_UNKNOWN
+} PkEnumListType;
+
+GType pk_enum_list_get_type (void);
+PkEnumList *pk_enum_list_new (void);
+
+gboolean pk_enum_list_set_type (PkEnumList *elist,
+ PkEnumListType type);
+gboolean pk_enum_list_from_string (PkEnumList *elist,
+ const gchar *enums);
+gchar *pk_enum_list_to_string (PkEnumList *alist);
+gboolean pk_enum_list_contains (PkEnumList *alist,
+ guint value);
+gboolean pk_enum_list_append (PkEnumList *alist,
+ guint value);
+gboolean pk_enum_list_append_multiple (PkEnumList *elist,
+ guint value, ...);
+
+G_END_DECLS
+
+#endif /* __PK_ENUM_LIST_H */
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index a739917..7cca080 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -305,9 +305,9 @@ pk_action_enum_to_text (PkTaskAction act
#include <libselftest.h>
void
-libst_task_utils (LibSelfTest *test)
+libst_enum (LibSelfTest *test)
{
- if (libst_start (test, "PkTaskUtils", CLASS_AUTO) == FALSE) {
+ if (libst_start (test, "PkEnum", CLASS_AUTO) == FALSE) {
return;
}
diff --git a/libpackagekit/pk-self-test.c b/libpackagekit/pk-self-test.c
index 87d4675..ae490b1 100644
--- a/libpackagekit/pk-self-test.c
+++ b/libpackagekit/pk-self-test.c
@@ -24,8 +24,9 @@
#include <libselftest.h>
/* prototypes */
-void libst_task_utils (LibSelfTest *test);
void libst_package_id (LibSelfTest *test);
+void libst_enum (LibSelfTest *test);
+void libst_enum_list (LibSelfTest *test);
int
main (int argc, char **argv)
@@ -36,8 +37,9 @@ main (int argc, char **argv)
libst_init (&test);
/* tests go here */
- libst_task_utils (&test);
libst_package_id (&test);
+ libst_enum (&test);
+ libst_enum_list (&test);
return (libst_finish (&test));
}
diff --git a/src/pk-backend-internal.h b/src/pk-backend-internal.h
index e055d67..d33d18a 100644
--- a/src/pk-backend-internal.h
+++ b/src/pk-backend-internal.h
@@ -23,7 +23,7 @@
#define __PK_BACKEND_INTERNAL_H
#include <glib-object.h>
-#include <pk-action-list.h>
+#include <pk-enum-list.h>
#include "pk-backend.h"
G_BEGIN_DECLS
@@ -55,7 +55,7 @@ typedef PkBackend PkTask;
/* general */
GType pk_backend_get_type (void);
PkBackend *pk_backend_new (void);
-PkActionList *pk_backend_get_actions (PkBackend *backend);
+PkEnumList *pk_backend_get_actions (PkBackend *backend);
gdouble pk_backend_get_runtime (PkBackend *backend);
gboolean pk_backend_load (PkBackend *backend,
const gchar *name);
diff --git a/src/pk-backend.c b/src/pk-backend.c
index a4096dd..a45b369 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -913,55 +913,58 @@ pk_backend_update_system (PkBackend *bac
/**
* pk_backend_get_actions:
+ *
+ * You need to g_object_unref the returned object
*/
-PkActionList *
+PkEnumList *
pk_backend_get_actions (PkBackend *backend)
{
- PkActionList *alist;
- alist = pk_action_list_new (PK_ACTION_ENUM_UNKNOWN);
+ PkEnumList *elist;
+ elist = pk_enum_list_new ();
+ pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
if (backend->desc->cancel_job_try != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_CANCEL_JOB);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_CANCEL_JOB);
}
if (backend->desc->get_depends != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_GET_DEPENDS);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_GET_DEPENDS);
}
if (backend->desc->get_description != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_GET_DESCRIPTION);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_GET_DESCRIPTION);
}
if (backend->desc->get_requires != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_GET_REQUIRES);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_GET_REQUIRES);
}
if (backend->desc->get_updates != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_GET_UPDATES);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_GET_UPDATES);
}
if (backend->desc->install_package != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_INSTALL_PACKAGE);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_INSTALL_PACKAGE);
}
if (backend->desc->refresh_cache != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_REFRESH_CACHE);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_REFRESH_CACHE);
}
if (backend->desc->remove_package != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_REMOVE_PACKAGE);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_REMOVE_PACKAGE);
}
if (backend->desc->search_details != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_SEARCH_DETAILS);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_SEARCH_DETAILS);
}
if (backend->desc->search_file != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_SEARCH_FILE);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_SEARCH_FILE);
}
if (backend->desc->search_group != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_SEARCH_GROUP);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_SEARCH_GROUP);
}
if (backend->desc->search_name != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_SEARCH_NAME);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_SEARCH_NAME);
}
if (backend->desc->update_package != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_UPDATE_PACKAGE);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_UPDATE_PACKAGE);
}
if (backend->desc->update_system != NULL) {
- pk_action_list_append (alist, PK_ACTION_ENUM_UPDATE_SYSTEM);
+ pk_enum_list_append (elist, PK_ACTION_ENUM_UPDATE_SYSTEM);
}
- return alist;
+ return elist;
}
/**
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 343db08..ab2183e 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -1388,7 +1388,7 @@ gboolean
pk_engine_get_actions (PkEngine *engine, gchar **actions, GError **error)
{
PkTask *task;
- PkActionList *alist;
+ PkEnumList *elist;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -1396,9 +1396,10 @@ pk_engine_get_actions (PkEngine *engine,
/* create a new task and start it */
task = pk_engine_new_task (engine);
pk_backend_load (task, engine->priv->backend);
- alist = pk_backend_get_actions (task);
+ elist = pk_backend_get_actions (task);
+ *actions = pk_enum_list_to_string (elist);
g_object_unref (task);
- *actions = pk_action_list_to_string (alist);
+ g_object_unref (elist);
return TRUE;
}
diff-tree da9248a72b0859bef2194097437acb215b49f4c5 (from f40ca4191b1907f95945abd1dd996a6ea27e7050)
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date: Sun Sep 9 12:55:22 2007 +0000
fixed memleak
diff --git a/src/pk-conf.c b/src/pk-conf.c
index 5d8cb24..66742a8 100644
--- a/src/pk-conf.c
+++ b/src/pk-conf.c
@@ -133,6 +133,7 @@ pk_conf_init (PkConf *conf)
conf->priv->keyfile = g_key_file_new ();
ret = g_key_file_load_from_file (conf->priv->keyfile, path,
G_KEY_FILE_KEEP_COMMENTS, NULL);
+ g_free (path);
if (ret == FALSE) {
pk_error ("failed to parse config file!");
}
diff-tree f40ca4191b1907f95945abd1dd996a6ea27e7050 (from c273b0b90fe0cd29fc92dc6b58b17a544a707ee2)
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date: Sun Sep 9 12:14:14 2007 +0000
use gui/text flags
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 4c6fbfa..f0a9ab3 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <pk-backend.h>
#include <unistd.h>
+#include <pk-debug.h>
#include <sqlite3.h>
#include <libbox/libbox-db.h>
@@ -119,7 +120,7 @@ find_packages_real (PkBackend *backend,
{
GList *list = NULL;
sqlite3 *db = NULL;
- gint devel_filter = 0;
+ gint search_filter = 0;
gboolean installed;
gboolean available;
gboolean devel;
@@ -134,11 +135,18 @@ find_packages_real (PkBackend *backend,
parse_filter (filter, &installed, &available, &devel, &nondevel, &gui, &text);
if (devel == TRUE) {
- devel_filter = devel_filter | PKG_DEVEL;
+ search_filter = search_filter | PKG_DEVEL;
}
if (nondevel == TRUE) {
- devel_filter = devel_filter | PKG_NON_DEVEL;
+ search_filter = search_filter | PKG_NON_DEVEL;
}
+ if (gui == TRUE) {
+ search_filter = search_filter | PKG_GUI;
+ }
+ if (text == TRUE) {
+ search_filter = search_filter | PKG_TEXT;
+ }
+ pk_debug("filter: %d", search_filter);
pk_backend_no_percentage_updates (backend);
@@ -156,11 +164,11 @@ find_packages_real (PkBackend *backend,
pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
} else {
if (installed == TRUE && available == TRUE) {
- list = box_db_repos_packages_search_all(db, (gchar *)search, devel_filter);
+ list = box_db_repos_packages_search_all(db, (gchar *)search, search_filter);
} else if (installed == TRUE) {
- list = box_db_repos_packages_search_installed(db, (gchar *)search, devel_filter);
+ list = box_db_repos_packages_search_installed(db, (gchar *)search, search_filter);
} else if (available == TRUE) {
- list = box_db_repos_packages_search_available(db, (gchar *)search, devel_filter);
+ list = box_db_repos_packages_search_available(db, (gchar *)search, search_filter);
}
add_packages_from_list (backend, list);
box_db_repos_package_list_free (list);
diff-tree c273b0b90fe0cd29fc92dc6b58b17a544a707ee2 (from f1c7a4f98a1d5449af1819c498417905fe135f0f)
Author: Tom Parker <palfrey at tevp.net>
Date: Sat Sep 8 20:04:47 2007 +0200
Add python API, and convert pkt to using it
packagekit.py provides a simple PackageKit python API, along with the
pkt client as an example user. The python API at the moment mirrors
the actions supported by the APT backend (as that's mainly what I'm
testing with), but should be expanded to be able to support the full
set of actions (or at least the set supported by the user's backend
of choice).
diff --git a/python/.gitignore b/python/.gitignore
new file mode 100644
index 0000000..0d20b64
--- /dev/null
+++ b/python/.gitignore
@@ -0,0 +1 @@
+*.pyc
diff --git a/python/packagekit.py b/python/packagekit.py
new file mode 100644
index 0000000..934c45b
--- /dev/null
+++ b/python/packagekit.py
@@ -0,0 +1,147 @@
+# PackageKit python interface
+#
+# Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
+#
+# 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 v2 as published by
+# the Free Software Foundation.
+
+from types import *
+import dbus
+from dbus.mainloop.glib import DBusGMainLoop
+import gobject
+
+class PackageKitException(Exception):
+ def __init__(self):
+ Exception.__init__(self)
+
+ def __init__(self,e=None):
+ Exception.__init__(self)
+ if e == None:
+ self._pk_name = None
+ self._full_str = None
+ else:
+ if not isinstance(e,dbus.exceptions.DBusException):
+ raise Exception,"Can only handle DBusExceptions"
+ self._pk_name = str(e.get_dbus_name())
+ self._full_str = str(e)
+
+ def get_backend_name(self):
+ return self._pk_name
+
+ def __str__(self):
+ if self._full_str!=None:
+ return self._full_str
+ else:
+ return ""
+
+class PackageKitNotStarted(PackageKitException):
+ pass
+
+class PackageKitAccessDenied(PackageKitException):
+ pass
+
+class PackageKitJobFailure(PackageKitException):
+ pass
+
+class PackageKitBackendFailure(PackageKitException):
+ pass
+
+def dbusException(func):
+ def wrapper(*args,**kwargs):
+ try:
+ return func(*args,**kwargs)
+ except dbus.exceptions.DBusException,e:
+ if e.get_dbus_name() == "org.freedesktop.DBus.Error.AccessDenied":
+ raise PackageKitAccessDenied
+ elif e.get_dbus_name() == "org.freedesktop.DBus.Error.NoReply":
+ raise PackageKitBackendFailure
+ else:
+ raise PackageKitException(e)
+ except Exception:
+ print "wibble"
+ raise
+ return wrapper
+
+def job_id(func):
+ def wrapper(*args,**kwargs):
+ jid = func(*args,**kwargs)
+ if jid == -1:
+ raise PackageKitJobFailure
+ else:
+ return jid
+ return wrapper
+
+class PackageKit:
+ def __init__(self):
+ DBusGMainLoop(set_as_default=True)
+ bus = dbus.SystemBus()
+ try:
+ pk = bus.get_object('org.freedesktop.PackageKit', '/org/freedesktop/PackageKit')
+ self.pk_iface = dbus.Interface(pk, dbus_interface='org.freedesktop.PackageKit')
+ except dbus.exceptions.DBusException,e:
+ if e.get_dbus_name() == "org.freedesktop.DBus.Error.ServiceUnknown":
+ raise PackageKitNotStarted
+ else:
+ raise PackageKitException(e)
+
+ self.job = None
+ self.progress = 0.0
+ bus.add_signal_receiver(self.catchall_signal_handler, interface_keyword='dbus_interface', member_keyword='member',dbus_interface="org.freedesktop.PackageKit")
+
+ def run(self):
+ self.loop = gobject.MainLoop()
+ self.loop.run()
+
+ def catchall_signal_handler(self,*args, **kwargs):
+ if args[0] != self.job and kwargs['member']!="JobListChanged":
+ return
+ if kwargs['member'] == "Finished":
+ loop.quit()
+ self.Finish()
+ elif kwargs['member'] == "PercentageChanged":
+ progress = float(args[1])+(progress%1.0)
+ self.Percentage(progress)
+ elif kwargs['member'] == "SubPercentageChanged":
+ progress = (float(args[1])/100.0)+int(progress)
+ self.Percentage(progress)
+ elif kwargs['member'] == "JobStatusChanged":
+ self.JobStatus(args[1])
+ elif kwargs['member'] == "Package":
+ self.Package(args[2],args[3])
+ elif kwargs['member'] in ["NoPercentageUpdates","JobListChanged"]:
+ pass
+ else:
+ print "Caught signal %s"% kwargs['member']
+ for arg in args:
+ print " " + str(arg)
+
+ def Percentage(self,value):
+ pass
+
+ def JobStatus(self,string):
+ pass
+
+ def Finish(self):
+ pass
+
+ @dbusException
+ @job_id
+ def SearchName(self,pattern,filter="none"):
+ return self.pk_iface.SearchName(filter,pattern)
+
+ @dbusException
+ @job_id
+ def GetDescription(package_id):
+ return pk_iface.GetDescription(package_id)
+
+ @dbusException
+ @job_id
+ def RefreshCache(force=False):
+ return pk_iface.RefreshCache(force)
+
+# hack to avoid exporting them
+del job_id
+del dbusException
diff --git a/python/pkt b/python/pkt
new file mode 100755
index 0000000..e8b789a
--- /dev/null
+++ b/python/pkt
@@ -0,0 +1,83 @@
+#!/usr/bin/python
+#
+# "pkt" python test program for PackageKit
+#
+# pkt serves both as a simple PackageKit client, and as an example user of the
+# PackageKit python API
+#
+# Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
+#
+# 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 v2 as published by
+# the Free Software Foundation.
+
+from sys import argv,exit
+from optparse import OptionParser
+from types import FunctionType
+
+from packagekit import *
+
+class pkt(PackageKit):
+ def Percentage(self,progress):
+ print "Progress: %.2f%%"%progress
+
+ def JobStatus(self,type):
+ print "Job type: %s"%type
+
+ def Package(self,name,description):
+ print "Package: %s - %s"%(name,description)
+
+try:
+ p = pkt()
+except PackageKitNotStarted:
+ print "PackageKit doesn't appear to be started. You may need to enable dbus autostart"
+ exit(1)
+
+def search(*args):
+ patt = " ".join(args[0])
+ return p.SearchName(patt)
+
+def desc(*args):
+ if len(args)!=1 or len(args[0])!=1:
+ print "desc only takes single arg"
+ return -1
+ return p.GetDescription(args[0][0])
+
+def update(args):
+ if len(args)>0 and len(args[0])>0:
+ print "update doesn't take args"
+ return -1
+ return p.RefreshCache()
+
+def usage():
+ print "Usage: %s <command> <options>"%argv[0]
+ print "Valid commands are:"
+ for k in globals().keys():
+ if k in ["usage","catchall_signal_handler"]: #ignore
+ continue
+ g = globals()[k]
+ if type(g) == FunctionType:
+ print "\t%s"%k
+ exit(1)
+
+parser = OptionParser()
+(options, args) = parser.parse_args()
+
+if len(args)==0:
+ usage()
+
+if not globals().has_key(args[0]):
+ print "Don't know operation '%s'"%args[0]
+ usage()
+
+try:
+ job = globals()[args[0]](args[1:])
+except PackageKitAccessDenied:
+ print "You don't have sufficient permissions to access PackageKit (on the org.freedesktop.PackageKit dbus service)"
+ exit(1)
+except PackageKitJobFailure:
+ usage()
+
+p.run()
diff --git a/tools/pkt b/tools/pkt
deleted file mode 100755
index b868322..0000000
--- a/tools/pkt
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
-#
-# 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 v2 as published by
-# the Free Software Foundation.
-
-from sys import argv,exit
-from types import *
-import dbus
-from dbus.mainloop.glib import DBusGMainLoop
-DBusGMainLoop(set_as_default=True)
-import gobject
-from optparse import OptionParser
-
-bus = dbus.SystemBus()
-try:
- pk = bus.get_object('org.freedesktop.PackageKit', '/org/freedesktop/PackageKit')
- pk_iface = dbus.Interface(pk, dbus_interface='org.freedesktop.PackageKit')
-except dbus.exceptions.DBusException,e:
- if e.get_dbus_name() == "org.freedesktop.DBus.Error.ServiceUnknown":
- print "PackageKit doesn't appear to be started. You may need to enable dbus autostart"
- exit(1)
- else:
- raise
-
-job = None
-progress = 0.0
-
-def catchall_signal_handler(*args, **kwargs):
- global job,progress
- if args[0] != job and kwargs['member']!="JobListChanged":
- print args,job,kwargs
- raise Exception
- if kwargs['member'] == "Finished":
- loop.quit()
- elif kwargs['member'] == "PercentageChanged":
- progress = float(args[1])+(progress%1.0)
- print "Progress: %.2f%%"%progress
- elif kwargs['member'] == "SubPercentageChanged":
- progress = (float(args[1])/100.0)+int(progress)
- print "Progress: %.2f%%"%progress
- elif kwargs['member'] == "JobStatusChanged":
- print "Job type: %s"%args[1]
- elif kwargs['member'] == "Package":
- print "Package: %s - %s"%(args[2],args[3])
- elif kwargs['member'] in ["NoPercentageUpdates","JobListChanged"]:
- pass
- else:
- print "Caught signal %s"% kwargs['member']
- for arg in args:
- print " " + str(arg)
-
-bus.add_signal_receiver(catchall_signal_handler, interface_keyword='dbus_interface', member_keyword='member',dbus_interface="org.freedesktop.PackageKit")
-
-def search(*args):
- patt = " ".join(args[0])
- return pk_iface.SearchName("none",patt)
-
-def desc(*args):
- if len(args)!=1 or len(args[0])!=1:
- print "desc only takes single arg"
- return -1
- return pk_iface.GetDescription(args[0][0])
-
-def update(args):
- if len(args)>0 and len(args[0])>0:
- print "update doesn't take args"
- return -1
- return pk_iface.RefreshCache(False)
-
-def usage():
- print "Usage: %s <command> <options>"%argv[0]
- print "Valid commands are:"
- for k in globals().keys():
- if k in ["usage","catchall_signal_handler"]: #ignore
- continue
- g = globals()[k]
- if type(g) == FunctionType:
- print "\t%s"%k
- exit(1)
-
-parser = OptionParser()
-(options, args) = parser.parse_args()
-
-if len(args)==0:
- usage()
-
-if not globals().has_key(args[0]):
- print "Don't know operation '%s'"%args[0]
- usage()
-
-try:
- job = globals()[args[0]](args[1:])
-except dbus.exceptions.DBusException,e:
- if e.get_dbus_name() == "org.freedesktop.DBus.Error.AccessDenied":
- print "You don't have sufficient permissions to access PackageKit (on the org.freedesktop.PackageKit dbus service)"
- exit(1)
- else:
- raise
-
-if job == -1:
- usage()
-
-loop = gobject.MainLoop()
-loop.run()
diff-tree f1c7a4f98a1d5449af1819c498417905fe135f0f (from bbe17f66efaabdff969d75587f9257e719587965)
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date: Sat Sep 8 18:10:43 2007 +0000
use thread for get_description function
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index ffeb5d5..4c6fbfa 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -39,7 +39,8 @@ typedef struct {
typedef struct {
PkBackend *backend;
-} UpdateData;
+ gchar *package_id;
+} ThreadData;
static sqlite3*
@@ -237,7 +238,7 @@ get_updates_thread(gpointer data)
{
GList *list = NULL;
sqlite3 *db = NULL;
- UpdateData *d = (UpdateData*) data;
+ ThreadData *d = (ThreadData*) data;
pk_backend_change_job_status (d->backend, PK_STATUS_ENUM_QUERY);
@@ -255,6 +256,41 @@ get_updates_thread(gpointer data)
return NULL;
}
+static void*
+get_description_thread(gpointer data)
+{
+ PkPackageId *pi;
+ PackageSearch *ps;
+ GList *list;
+ ThreadData *d = (ThreadData*) data;
+
+ pi = pk_package_id_new_from_string (d->package_id);
+ if (pi == NULL) {
+ pk_backend_error_code (d->backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
+ pk_backend_finished (d->backend, PK_EXIT_ENUM_FAILED);
+ return NULL;
+ }
+
+ pk_backend_change_job_status (d->backend, PK_STATUS_ENUM_QUERY);
+ list = find_package_by_id (pi);
+ ps = (PackageSearch*) list->data;
+ if (list == NULL) {
+ pk_backend_error_code (d->backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "cannot find package by id");
+ pk_backend_finished (d->backend, PK_EXIT_ENUM_FAILED);
+ return NULL;
+ }
+
+ pk_backend_description (d->backend, pi->name, PK_GROUP_ENUM_OTHER, ps->description, "");
+
+ pk_package_id_free (pi);
+ box_db_repos_package_list_free (list);
+
+ pk_backend_finished (d->backend, PK_EXIT_ENUM_SUCCESS);
+ g_free (d->package_id);
+ g_free (d);
+
+ return NULL;
+}
/* ===================================================================== */
@@ -282,35 +318,23 @@ backend_destroy (PkBackend *backend)
static void
backend_get_description (PkBackend *backend, const gchar *package_id)
{
- PkPackageId *pi;
- PackageSearch *ps;
- GList *list;
+ ThreadData *data = g_new0(ThreadData, 1);
g_return_if_fail (backend != NULL);
- pi = pk_package_id_new_from_string (package_id);
- if (pi == NULL) {
- pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
- pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
- return;
- }
+ if (data == NULL) {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory");
+ pk_backend_finished(backend, PK_EXIT_ENUM_FAILED);
+ } else {
+ data->backend = backend;
+ data->package_id = g_strdup(package_id);
- pk_backend_change_job_status (backend, PK_STATUS_ENUM_QUERY);
- list = find_package_by_id (pi);
- ps = (PackageSearch*) list->data;
- if (list == NULL) {
- pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "cannot find package by id");
- pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
- return;
+ if (g_thread_create(get_description_thread, data, FALSE, NULL) == NULL) {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_CREATE_THREAD_FAILED, "Failed to create thread");
+ pk_backend_finished(backend, PK_EXIT_ENUM_FAILED);
+ }
}
-
- pk_backend_description (backend, pi->name, PK_GROUP_ENUM_OTHER, ps->description, "");
-
- pk_package_id_free (pi);
- box_db_repos_package_list_free (list);
-
- pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
return;
}
@@ -320,7 +344,7 @@ backend_get_description (PkBackend *back
static void
backend_get_updates (PkBackend *backend)
{
- UpdateData *data = g_new0(UpdateData, 1);
+ ThreadData *data = g_new0(ThreadData, 1);
g_return_if_fail (backend != NULL);
@@ -334,7 +358,6 @@ backend_get_updates (PkBackend *backend)
pk_backend_error_code(backend, PK_ERROR_ENUM_CREATE_THREAD_FAILED, "Failed to create thread");
pk_backend_finished(backend, PK_EXIT_ENUM_FAILED);
}
-
}
}
diff-tree bbe17f66efaabdff969d75587f9257e719587965 (from d6ee5ff2d52d922c44329e9b355fe0d2c0553e56)
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date: Sat Sep 8 17:52:31 2007 +0000
set correct job status
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 576f942..ffeb5d5 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -128,7 +128,8 @@ find_packages_real (PkBackend *backend,
g_return_if_fail (backend != NULL);
- pk_backend_change_job_status (backend, PK_ROLE_ENUM_QUERY);
+ pk_backend_change_job_status (backend, PK_STATUS_ENUM_QUERY);
+
parse_filter (filter, &installed, &available, &devel, &nondevel, &gui, &text);
if (devel == TRUE) {
@@ -138,7 +139,6 @@ find_packages_real (PkBackend *backend,
devel_filter = devel_filter | PKG_NON_DEVEL;
}
- pk_backend_change_job_status (backend, PK_STATUS_ENUM_QUERY);
pk_backend_no_percentage_updates (backend);
db = db_open();
@@ -239,6 +239,8 @@ get_updates_thread(gpointer data)
sqlite3 *db = NULL;
UpdateData *d = (UpdateData*) data;
+ pk_backend_change_job_status (d->backend, PK_STATUS_ENUM_QUERY);
+
db = db_open ();
list = box_db_repos_packages_for_upgrade (db);
@@ -293,6 +295,7 @@ backend_get_description (PkBackend *back
return;
}
+ pk_backend_change_job_status (backend, PK_STATUS_ENUM_QUERY);
list = find_package_by_id (pi);
ps = (PackageSearch*) list->data;
if (list == NULL) {
@@ -302,7 +305,6 @@ backend_get_description (PkBackend *back
}
- pk_backend_change_job_status (backend, PK_ROLE_ENUM_QUERY);
pk_backend_description (backend, pi->name, PK_GROUP_ENUM_OTHER, ps->description, "");
pk_package_id_free (pi);
@@ -322,8 +324,6 @@ backend_get_updates (PkBackend *backend)
g_return_if_fail (backend != NULL);
- pk_backend_change_job_status (backend, PK_STATUS_ENUM_QUERY);
-
if (data == NULL) {
pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory");
pk_backend_finished(backend, PK_EXIT_ENUM_FAILED);
@@ -351,7 +351,7 @@ backend_refresh_cache (PkBackend *backen
pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
return;
}
- pk_backend_change_job_status (backend, PK_ROLE_ENUM_REFRESH_CACHE);
+ pk_backend_change_job_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
pk_backend_spawn_helper (backend, "refresh-cache.sh", NULL);
}
diff-tree d6ee5ff2d52d922c44329e9b355fe0d2c0553e56 (from a4146405995efa72dd465a087b65deef03637861)
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date: Sat Sep 8 16:56:25 2007 +0000
fixed wrong logic in --with-default-backend
diff --git a/configure.ac b/configure.ac
index ba571e7..dc5ddc3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -184,9 +184,9 @@ AC_MSG_RESULT(yes)
dnl ---------------------------------------------------------------------------
dnl - Compile time default choice of backend
dnl ---------------------------------------------------------------------------
-AC_ARG_WITH([backend],
+AC_ARG_WITH([default_backend],
AS_HELP_STRING([--with-default-backend=<option>],
- [Default backend to use dummy,apt,yum,conary (dummy)]))
+ [Default backend to use dummy,apt,yum,conary,box (dummy)]))
# default to a sane option for the installed tool
if test x$with_default_backend = x; then
if test -f /usr/bin/yum ; then
@@ -249,7 +249,7 @@ AC_DEFUN([APT_BACKEND],
fi
])
-if test x$with_backend = xapt; then
+if test x$with_default_backend = xapt; then
AC_ARG_WITH(libapt-pkg-lib,
AC_HELP_STRING([--with-libapt-pkg-lib=DIR],[look for the libapt-pkg library in DIR]),
@@ -315,7 +315,7 @@ if test x$with_backend = xapt; then
AC_SUBST(APT_PKG_TYPE)
fi
-if test x$with_backend = xbox; then
+if test x$with_default_backend = xbox; then
PKG_CHECK_MODULES(BOX, libbox)
AC_SUBST(BOX_CFLAGS)
AC_SUBST(BOX_LIBS)
@@ -326,11 +326,11 @@ AC_SUBST(PK_PLUGIN_DIR, "\$(libdir)/pack
AC_SUBST(PK_PLUGIN_CFLAGS, "-I\$(top_srcdir)/src -I\$(top_srcdir)/libpackagekit $GLIB_CFLAGS $DBUS_CFLAGS $GMODULE_CFLAGS")
AC_SUBST(PK_PLUGIN_LIBS, "$GLIB_LIBS $DBUS_LIBS $GMODULE_LIBS")
-AM_CONDITIONAL(BACKEND_TYPE_DUMMY, [test x$with_backend = xdummy], [using dummy backend])
-AM_CONDITIONAL(BACKEND_TYPE_APT, [test x$with_backend = xapt], [using APT backend])
-AM_CONDITIONAL(BACKEND_TYPE_YUM, [test x$with_backend = xyum], [using YUM backend])
-AM_CONDITIONAL(BACKEND_TYPE_CONARY, [test x$with_backend = xconary], [using CONARY backend])
-AM_CONDITIONAL(BACKEND_TYPE_BOX, [test x$with_backend = xbox], [using BOX backend])
+AM_CONDITIONAL(BACKEND_TYPE_DUMMY, [test x$with_default_backend = xdummy], [using dummy backend])
+AM_CONDITIONAL(BACKEND_TYPE_APT, [test x$with_default_backend = xapt], [using APT backend])
+AM_CONDITIONAL(BACKEND_TYPE_YUM, [test x$with_default_backend = xyum], [using YUM backend])
+AM_CONDITIONAL(BACKEND_TYPE_CONARY, [test x$with_default_backend = xconary], [using CONARY backend])
+AM_CONDITIONAL(BACKEND_TYPE_BOX, [test x$with_default_backend = xbox], [using BOX backend])
dnl ---------------------------------------------------------------------------
diff-tree a4146405995efa72dd465a087b65deef03637861 (from ed33f3adc7e164a5e8f4ae90627d8f5c1b250d04)
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date: Sat Sep 8 16:32:18 2007 +0000
added temporary workaround for segmentation fault
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index f2ae5ea..576f942 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -23,6 +23,7 @@
#include <glib.h>
#include <string.h>
#include <pk-backend.h>
+#include <unistd.h>
#include <sqlite3.h>
#include <libbox/libbox-db.h>
@@ -162,6 +163,8 @@ find_packages_real (PkBackend *backend,
}
add_packages_from_list (backend, list);
box_db_repos_package_list_free (list);
+ // FIXME: temporary workaround
+ sleep(1);
pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
}
}
More information about the PackageKit
mailing list