[packagekit] packagekit: Branch 'master' - 9 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Fri Sep 7 09:17:20 PDT 2007
TODO | 9
backends/apt/pk-backend-apt.cpp | 70 +--
backends/apt/pk-task-apt.cpp.delete.me | 102 ++--
backends/box/pk-backend-box.c | 36 -
backends/conary/pk-backend-conary.c | 8
backends/dummy/pk-backend-dummy.c | 38 -
backends/test/pk-backend-test.c | 28 -
backends/yum/pk-backend-yum.c | 12
client/pk-console.c | 2
client/pk-monitor.c | 2
libpackagekit/Makefile.am | 13
libpackagekit/pk-action-list.c | 205 +++++++++
libpackagekit/pk-action-list.h | 42 +
libpackagekit/pk-enum.c | 317 ++++++++++++++
libpackagekit/pk-enum.h | 143 ++++++
libpackagekit/pk-task-client.c | 8
libpackagekit/pk-task-client.h | 2
libpackagekit/pk-task-common.c | 198 +++++++++
libpackagekit/pk-task-common.h | 2
libpackagekit/pk-task-list.c | 2
libpackagekit/pk-task-list.h | 2
libpackagekit/pk-task-monitor.c | 14
libpackagekit/pk-task-monitor.h | 2
libpackagekit/pk-task-utils.c | 713 ---------------------------------
libpackagekit/pk-task-utils.h | 160 -------
src/pk-backend-internal.h | 2
src/pk-backend.c | 92 ++--
src/pk-backend.h | 2
src/pk-engine.c | 22 -
tools/add-error-enum.sh | 2
tools/pkt | 109 +++++
tools/pkt.py | 31 -
32 files changed, 1256 insertions(+), 1134 deletions(-)
New commits:
diff-tree c3d3c7a0d46504ac6d5619a0373ef8e362310d8e (from 7312db561aac4b204ff23bc1ac68f76da1e548d2)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Sep 7 17:06:05 2007 +0100
move pktaskutils to pk-enum, as that's what it is...
diff --git a/libpackagekit/Makefile.am b/libpackagekit/Makefile.am
index ee9effa..9e558ca 100644
--- a/libpackagekit/Makefile.am
+++ b/libpackagekit/Makefile.am
@@ -29,7 +29,7 @@ libpackagekit_include_HEADERS = \
pk-connection.h \
pk-package-id.h \
pk-action-list.h \
- pk-task-utils.h \
+ pk-enum.h \
pk-task-common.h \
pk-task-monitor.h \
pk-task-client.h \
@@ -49,8 +49,8 @@ libpackagekit_la_SOURCES = \
pk-package-id.c \
pk-action-list.c \
pk-action-list.h \
- pk-task-utils.h \
- pk-task-utils.c \
+ pk-enum.h \
+ pk-enum.c \
pk-task-common.c \
pk-task-common.h \
pk-task-monitor.c \
@@ -81,8 +81,8 @@ check_PROGRAMS = \
pk_self_test_SOURCES = \
pk-debug.c \
pk-debug.h \
- pk-task-utils.h \
- pk-task-utils.c \
+ pk-enum.h \
+ pk-enum.c \
pk-package-id.h \
pk-package-id.c \
pk-self-test.c \
diff --git a/libpackagekit/pk-action-list.h b/libpackagekit/pk-action-list.h
index 94cfecb..08a1f47 100644
--- a/libpackagekit/pk-action-list.h
+++ b/libpackagekit/pk-action-list.h
@@ -23,7 +23,7 @@
#define __PK_ACTION_LIST_H
#include <glib-object.h>
-#include <pk-task-utils.h>
+#include <pk-enum.h>
G_BEGIN_DECLS
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
new file mode 100644
index 0000000..32098b4
--- /dev/null
+++ b/libpackagekit/pk-enum.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>
+#include <glib/gi18n.h>
+
+#include "pk-debug.h"
+#include "pk-enum.h"
+
+typedef struct {
+ guint value;
+ const gchar *string;
+} PkTaskEnumMatch;
+
+static PkTaskEnumMatch task_exit[] = {
+ {PK_EXIT_ENUM_UNKNOWN, "unknown"}, /* fall though value */
+ {PK_EXIT_ENUM_SUCCESS, "success"},
+ {PK_EXIT_ENUM_FAILED, "failed"},
+ {PK_EXIT_ENUM_CANCELED, "canceled"},
+ {0, NULL},
+};
+
+static PkTaskEnumMatch task_status[] = {
+ {PK_STATUS_ENUM_UNKNOWN, "unknown"}, /* fall though value */
+ {PK_STATUS_ENUM_SETUP, "setup"},
+ {PK_STATUS_ENUM_QUERY, "query"},
+ {PK_STATUS_ENUM_REFRESH_CACHE, "refresh-cache"},
+ {PK_STATUS_ENUM_REMOVE, "remove"},
+ {PK_STATUS_ENUM_DOWNLOAD, "download"},
+ {PK_STATUS_ENUM_INSTALL, "install"},
+ {PK_STATUS_ENUM_UPDATE, "update"},
+ {0, NULL},
+};
+
+static PkTaskEnumMatch task_role[] = {
+ {PK_ROLE_ENUM_UNKNOWN, "unknown"}, /* fall though value */
+ {PK_ROLE_ENUM_QUERY, "query"},
+ {PK_ROLE_ENUM_REFRESH_CACHE, "refresh-cache"},
+ {PK_ROLE_ENUM_PACKAGE_REMOVE, "package-remove"},
+ {PK_ROLE_ENUM_PACKAGE_INSTALL, "package-install"},
+ {PK_ROLE_ENUM_PACKAGE_UPDATE, "package-update"},
+ {PK_ROLE_ENUM_SYSTEM_UPDATE, "system-update"},
+ {0, NULL},
+};
+
+static PkTaskEnumMatch task_error[] = {
+ {PK_ERROR_ENUM_UNKNOWN, "unknown"}, /* fall though value */
+ {PK_ERROR_ENUM_OOM, "out-of-memory"},
+ {PK_ERROR_ENUM_NO_NETWORK, "no-network"},
+ {PK_ERROR_ENUM_NOT_SUPPORTED, "not-supported"},
+ {PK_ERROR_ENUM_INTERNAL_ERROR, "internal-error"},
+ {PK_ERROR_ENUM_GPG_FAILURE, "gpg-failure"},
+ {PK_ERROR_ENUM_FILTER_INVALID, "filter-invalid"},
+ {PK_ERROR_ENUM_PACKAGE_ID_INVALID, "package-id-invalid"},
+ {PK_ERROR_ENUM_TRANSACTION_ERROR, "transaction-error"},
+ {PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, "package-not-installed"},
+ {PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED, "package-already-installed"},
+ {PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, "package-download-failed"},
+ {PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "dep-resolution-failed"},
+ {PK_ERROR_ENUM_CREATE_THREAD_FAILED, "create-thread-failed"},
+ {0, NULL},
+};
+
+static PkTaskEnumMatch task_restart[] = {
+ {PK_RESTART_ENUM_NONE, "none"},
+ {PK_RESTART_ENUM_SYSTEM, "system"},
+ {PK_RESTART_ENUM_SESSION, "session"},
+ {PK_RESTART_ENUM_APPLICATION, "application"},
+ {0, NULL},
+};
+
+static PkTaskEnumMatch task_group[] = {
+ {PK_GROUP_ENUM_ACCESSIBILITY, "accessibility"},
+ {PK_GROUP_ENUM_ACCESSORIES, "accessories"},
+ {PK_GROUP_ENUM_EDUCATION, "education"},
+ {PK_GROUP_ENUM_GAMES, "games"},
+ {PK_GROUP_ENUM_GRAPHICS, "graphics"},
+ {PK_GROUP_ENUM_INTERNET, "internet"},
+ {PK_GROUP_ENUM_OFFICE, "office"},
+ {PK_GROUP_ENUM_OTHER, "other"},
+ {PK_GROUP_ENUM_PROGRAMMING, "programming"},
+ {PK_GROUP_ENUM_MULTIMEDIA, "multimedia"},
+ {PK_GROUP_ENUM_SYSTEM, "system"},
+ {0, NULL},
+};
+
+static PkTaskEnumMatch task_action[] = {
+ {PK_ACTION_ENUM_INSTALL, "install"},
+ {PK_ACTION_ENUM_REMOVE, "remove"},
+ {PK_ACTION_ENUM_UPDATE, "update"},
+ {PK_ACTION_ENUM_GET_UPDATES, "get-updates"},
+ {PK_ACTION_ENUM_REFRESH_CACHE, "refresh-cache"},
+ {PK_ACTION_ENUM_UPDATE_SYSTEM, "update-system"},
+ {PK_ACTION_ENUM_SEARCH_NAME, "search-name"},
+ {PK_ACTION_ENUM_SEARCH_DETAILS, "search-details"},
+ {PK_ACTION_ENUM_SEARCH_GROUP, "search-group"},
+ {PK_ACTION_ENUM_SEARCH_FILE, "search-file"},
+ {PK_ACTION_ENUM_GET_DEPENDS, "get-depends"},
+ {PK_ACTION_ENUM_GET_REQUIRES, "get-requires"},
+ {PK_ACTION_ENUM_GET_DESCRIPTION, "get-description"},
+ {0, NULL},
+};
+
+/**
+ * pk_task_enum_find_value:
+ */
+static guint
+pk_task_enum_find_value (PkTaskEnumMatch *table, const gchar *string)
+{
+ guint i;
+ const gchar *string_tmp;
+
+ /* return the first entry on non-found or error */
+ if (string == NULL) {
+ return table[0].value;
+ }
+ for (i=0;;i++) {
+ string_tmp = table[i].string;
+ if (string_tmp == NULL) {
+ break;
+ }
+ if (strcmp (string, string_tmp) == 0) {
+ return table[i].value;
+ }
+ }
+ return table[0].value;
+}
+
+/**
+ * pk_task_enum_find_string:
+ */
+static const gchar *
+pk_task_enum_find_string (PkTaskEnumMatch *table, guint value)
+{
+ guint i;
+ guint tmp;
+ const gchar *string_tmp;
+
+ for (i=0;;i++) {
+ string_tmp = table[i].string;
+ if (string_tmp == NULL) {
+ break;
+ }
+ tmp = table[i].value;
+ if (tmp == value) {
+ return table[i].string;
+ }
+ }
+ return table[0].string;
+}
+
+/**
+ * pk_exit_enum_from_text:
+ */
+PkTaskExit
+pk_exit_enum_from_text (const gchar *exit)
+{
+ return pk_task_enum_find_value (task_exit, exit);
+}
+
+/**
+ * pk_exit_enum_to_text:
+ **/
+const gchar *
+pk_exit_enum_to_text (PkTaskExit exit)
+{
+ return pk_task_enum_find_string (task_exit, exit);
+}
+
+/**
+ * pk_status_enum_from_text:
+ **/
+PkTaskStatus
+pk_status_enum_from_text (const gchar *status)
+{
+ return pk_task_enum_find_value (task_status, status);
+}
+
+/**
+ * pk_status_enum_to_text:
+ **/
+const gchar *
+pk_status_enum_to_text (PkTaskStatus status)
+{
+ return pk_task_enum_find_string (task_status, status);
+}
+
+/**
+ * pk_role_enum_from_text:
+ **/
+PkTaskRole
+pk_role_enum_from_text (const gchar *role)
+{
+ return pk_task_enum_find_value (task_role, role);
+}
+
+/**
+ * pk_role_enum_to_text:
+ **/
+const gchar *
+pk_role_enum_to_text (PkTaskRole role)
+{
+ return pk_task_enum_find_string (task_role, role);
+}
+
+/**
+ * pk_error_enum_from_text:
+ **/
+PkTaskErrorCode
+pk_error_enum_from_text (const gchar *code)
+{
+ return pk_task_enum_find_value (task_error, code);
+}
+
+/**
+ * pk_error_enum_to_text:
+ **/
+const gchar *
+pk_error_enum_to_text (PkTaskErrorCode code)
+{
+ return pk_task_enum_find_string (task_error, code);
+}
+
+/**
+ * pk_restart_enum_from_text:
+ **/
+PkTaskRestart
+pk_restart_enum_from_text (const gchar *restart)
+{
+ return pk_task_enum_find_value (task_restart, restart);
+}
+
+/**
+ * pk_restart_enum_to_text:
+ **/
+const gchar *
+pk_restart_enum_to_text (PkTaskRestart restart)
+{
+ return pk_task_enum_find_string (task_restart, restart);
+}
+
+/**
+ * pk_group_enum_from_text:
+ **/
+PkTaskGroup
+pk_group_enum_from_text (const gchar *group)
+{
+ return pk_task_enum_find_value (task_group, group);
+}
+
+/**
+ * pk_group_enum_to_text:
+ **/
+const gchar *
+pk_group_enum_to_text (PkTaskGroup group)
+{
+ return pk_task_enum_find_string (task_group, group);
+}
+
+/**
+ * pk_action_enum_from_text:
+ **/
+PkTaskAction
+pk_action_enum_from_text (const gchar *action)
+{
+ return pk_task_enum_find_value (task_action, action);
+}
+
+/**
+ * pk_action_enum_to_text:
+ **/
+const gchar *
+pk_action_enum_to_text (PkTaskAction action)
+{
+ return pk_task_enum_find_string (task_action, action);
+}
+
+/***************************************************************************
+ *** MAKE CHECK TESTS ***
+ ***************************************************************************/
+#ifdef PK_BUILD_TESTS
+#include <libselftest.h>
+
+void
+libst_task_utils (LibSelfTest *test)
+{
+ if (libst_start (test, "PkTaskUtils", CLASS_AUTO) == FALSE) {
+ return;
+ }
+
+ libst_end (test);
+}
+#endif
+
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
new file mode 100644
index 0000000..63580e3
--- /dev/null
+++ b/libpackagekit/pk-enum.h
@@ -0,0 +1,143 @@
+/* -*- 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_H
+#define __PK_ENUM_H
+
+#include <glib-object.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+/* what we asked to do */
+typedef enum {
+ PK_ROLE_ENUM_QUERY,
+ PK_ROLE_ENUM_REFRESH_CACHE,
+ PK_ROLE_ENUM_SYSTEM_UPDATE,
+ PK_ROLE_ENUM_PACKAGE_REMOVE,
+ PK_ROLE_ENUM_PACKAGE_INSTALL,
+ PK_ROLE_ENUM_PACKAGE_UPDATE,
+ PK_ROLE_ENUM_UNKNOWN
+} PkTaskRole;
+
+/* what we are actually doing */
+typedef enum {
+ PK_STATUS_ENUM_SETUP,
+ PK_STATUS_ENUM_QUERY,
+ PK_STATUS_ENUM_REMOVE,
+ PK_STATUS_ENUM_REFRESH_CACHE,
+ PK_STATUS_ENUM_DOWNLOAD,
+ PK_STATUS_ENUM_INSTALL,
+ PK_STATUS_ENUM_UPDATE,
+ PK_STATUS_ENUM_UNKNOWN
+} PkTaskStatus;
+
+typedef enum {
+ PK_EXIT_ENUM_SUCCESS,
+ PK_EXIT_ENUM_FAILED,
+ PK_EXIT_ENUM_CANCELED,
+ PK_EXIT_ENUM_UNKNOWN
+} PkTaskExit;
+
+typedef enum {
+ PK_RESTART_ENUM_NONE,
+ PK_RESTART_ENUM_APPLICATION,
+ PK_RESTART_ENUM_SESSION,
+ PK_RESTART_ENUM_SYSTEM
+} PkTaskRestart;
+
+typedef enum {
+ PK_ERROR_ENUM_OOM,
+ PK_ERROR_ENUM_NO_NETWORK,
+ PK_ERROR_ENUM_NOT_SUPPORTED,
+ PK_ERROR_ENUM_INTERNAL_ERROR,
+ PK_ERROR_ENUM_GPG_FAILURE,
+ PK_ERROR_ENUM_PACKAGE_ID_INVALID,
+ PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED,
+ PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED,
+ PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED,
+ PK_ERROR_ENUM_DEP_RESOLUTION_FAILED,
+ PK_ERROR_ENUM_FILTER_INVALID,
+ PK_ERROR_ENUM_CREATE_THREAD_FAILED,
+ PK_ERROR_ENUM_TRANSACTION_ERROR,
+ PK_ERROR_ENUM_UNKNOWN
+} PkTaskErrorCode;
+
+typedef enum {
+ PK_GROUP_ENUM_ACCESSIBILITY,
+ PK_GROUP_ENUM_ACCESSORIES,
+ PK_GROUP_ENUM_EDUCATION,
+ PK_GROUP_ENUM_GAMES,
+ PK_GROUP_ENUM_GRAPHICS,
+ PK_GROUP_ENUM_INTERNET,
+ PK_GROUP_ENUM_OFFICE,
+ PK_GROUP_ENUM_OTHER,
+ PK_GROUP_ENUM_PROGRAMMING,
+ PK_GROUP_ENUM_MULTIMEDIA,
+ PK_GROUP_ENUM_SYSTEM,
+ PK_GROUP_ENUM_UNKNOWN
+} PkTaskGroup;
+
+typedef enum {
+ PK_ACTION_ENUM_INSTALL = 1,
+ PK_ACTION_ENUM_REMOVE,
+ PK_ACTION_ENUM_UPDATE,
+ PK_ACTION_ENUM_GET_UPDATES,
+ PK_ACTION_ENUM_CANCEL_JOB,
+ PK_ACTION_ENUM_REFRESH_CACHE,
+ PK_ACTION_ENUM_UPDATE_SYSTEM,
+ PK_ACTION_ENUM_SEARCH_NAME,
+ PK_ACTION_ENUM_SEARCH_DETAILS,
+ PK_ACTION_ENUM_SEARCH_GROUP,
+ PK_ACTION_ENUM_SEARCH_FILE,
+ PK_ACTION_ENUM_GET_DEPENDS,
+ PK_ACTION_ENUM_GET_REQUIRES,
+ PK_ACTION_ENUM_GET_DESCRIPTION,
+ PK_ACTION_ENUM_INSTALL_PACKAGE,
+ PK_ACTION_ENUM_REMOVE_PACKAGE,
+ PK_ACTION_ENUM_UPDATE_PACKAGE,
+ PK_ACTION_ENUM_UNKNOWN
+} PkTaskAction;
+
+PkTaskExit pk_exit_enum_from_text (const gchar *exit);
+const gchar *pk_exit_enum_to_text (PkTaskExit exit);
+
+PkTaskStatus pk_status_enum_from_text (const gchar *status);
+const gchar *pk_status_enum_to_text (PkTaskStatus status);
+
+PkTaskRole pk_role_enum_from_text (const gchar *role);
+const gchar *pk_role_enum_to_text (PkTaskRole role);
+
+PkTaskErrorCode pk_error_enum_from_text (const gchar *code);
+const gchar *pk_error_enum_to_text (PkTaskErrorCode code);
+
+PkTaskRestart pk_restart_enum_from_text (const gchar *restart);
+const gchar *pk_restart_enum_to_text (PkTaskRestart restart);
+
+PkTaskGroup pk_group_enum_from_text (const gchar *group);
+const gchar *pk_group_enum_to_text (PkTaskGroup group);
+
+PkTaskAction pk_action_enum_from_text (const gchar *action);
+const gchar *pk_action_enum_to_text (PkTaskAction action);
+
+G_END_DECLS
+
+#endif /* __PK_ENUM_H */
diff --git a/libpackagekit/pk-task-client.h b/libpackagekit/pk-task-client.h
index 39bec5e..b119034 100644
--- a/libpackagekit/pk-task-client.h
+++ b/libpackagekit/pk-task-client.h
@@ -23,7 +23,7 @@
#define __PK_TASK_CLIENT_H
#include <glib-object.h>
-#include "pk-task-utils.h"
+#include "pk-enum.h"
G_BEGIN_DECLS
diff --git a/libpackagekit/pk-task-list.h b/libpackagekit/pk-task-list.h
index 3fc2250..d0f7717 100644
--- a/libpackagekit/pk-task-list.h
+++ b/libpackagekit/pk-task-list.h
@@ -24,7 +24,7 @@
#include <glib-object.h>
#include "pk-task-monitor.h"
-#include "pk-task-utils.h"
+#include "pk-enum.h"
G_BEGIN_DECLS
diff --git a/libpackagekit/pk-task-monitor.h b/libpackagekit/pk-task-monitor.h
index c8109f9..405bbec 100644
--- a/libpackagekit/pk-task-monitor.h
+++ b/libpackagekit/pk-task-monitor.h
@@ -23,7 +23,7 @@
#define __PK_TASK_MONITOR_H
#include <glib-object.h>
-#include "pk-task-utils.h"
+#include "pk-enum.h"
G_BEGIN_DECLS
diff --git a/libpackagekit/pk-task-utils.c b/libpackagekit/pk-task-utils.c
deleted file mode 100644
index 2ca23aa..0000000
--- a/libpackagekit/pk-task-utils.c
+++ /dev/null
@@ -1,320 +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-task-utils.h"
-
-typedef struct {
- guint value;
- const gchar *string;
-} PkTaskEnumMatch;
-
-static PkTaskEnumMatch task_exit[] = {
- {PK_EXIT_ENUM_UNKNOWN, "unknown"}, /* fall though value */
- {PK_EXIT_ENUM_SUCCESS, "success"},
- {PK_EXIT_ENUM_FAILED, "failed"},
- {PK_EXIT_ENUM_CANCELED, "canceled"},
- {0, NULL},
-};
-
-static PkTaskEnumMatch task_status[] = {
- {PK_STATUS_ENUM_UNKNOWN, "unknown"}, /* fall though value */
- {PK_STATUS_ENUM_SETUP, "setup"},
- {PK_STATUS_ENUM_QUERY, "query"},
- {PK_STATUS_ENUM_REFRESH_CACHE, "refresh-cache"},
- {PK_STATUS_ENUM_REMOVE, "remove"},
- {PK_STATUS_ENUM_DOWNLOAD, "download"},
- {PK_STATUS_ENUM_INSTALL, "install"},
- {PK_STATUS_ENUM_UPDATE, "update"},
- {0, NULL},
-};
-
-static PkTaskEnumMatch task_role[] = {
- {PK_ROLE_ENUM_UNKNOWN, "unknown"}, /* fall though value */
- {PK_ROLE_ENUM_QUERY, "query"},
- {PK_ROLE_ENUM_REFRESH_CACHE, "refresh-cache"},
- {PK_ROLE_ENUM_PACKAGE_REMOVE, "package-remove"},
- {PK_ROLE_ENUM_PACKAGE_INSTALL, "package-install"},
- {PK_ROLE_ENUM_PACKAGE_UPDATE, "package-update"},
- {PK_ROLE_ENUM_SYSTEM_UPDATE, "system-update"},
- {0, NULL},
-};
-
-static PkTaskEnumMatch task_error[] = {
- {PK_ERROR_ENUM_UNKNOWN, "unknown"}, /* fall though value */
- {PK_ERROR_ENUM_OOM, "out-of-memory"},
- {PK_ERROR_ENUM_NO_NETWORK, "no-network"},
- {PK_ERROR_ENUM_NOT_SUPPORTED, "not-supported"},
- {PK_ERROR_ENUM_INTERNAL_ERROR, "internal-error"},
- {PK_ERROR_ENUM_GPG_FAILURE, "gpg-failure"},
- {PK_ERROR_ENUM_FILTER_INVALID, "filter-invalid"},
- {PK_ERROR_ENUM_PACKAGE_ID_INVALID, "package-id-invalid"},
- {PK_ERROR_ENUM_TRANSACTION_ERROR, "transaction-error"},
- {PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, "package-not-installed"},
- {PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED, "package-already-installed"},
- {PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, "package-download-failed"},
- {PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "dep-resolution-failed"},
- {PK_ERROR_ENUM_CREATE_THREAD_FAILED, "create-thread-failed"},
- {0, NULL},
-};
-
-static PkTaskEnumMatch task_restart[] = {
- {PK_RESTART_ENUM_NONE, "none"},
- {PK_RESTART_ENUM_SYSTEM, "system"},
- {PK_RESTART_ENUM_SESSION, "session"},
- {PK_RESTART_ENUM_APPLICATION, "application"},
- {0, NULL},
-};
-
-static PkTaskEnumMatch task_group[] = {
- {PK_GROUP_ENUM_ACCESSIBILITY, "accessibility"},
- {PK_GROUP_ENUM_ACCESSORIES, "accessories"},
- {PK_GROUP_ENUM_EDUCATION, "education"},
- {PK_GROUP_ENUM_GAMES, "games"},
- {PK_GROUP_ENUM_GRAPHICS, "graphics"},
- {PK_GROUP_ENUM_INTERNET, "internet"},
- {PK_GROUP_ENUM_OFFICE, "office"},
- {PK_GROUP_ENUM_OTHER, "other"},
- {PK_GROUP_ENUM_PROGRAMMING, "programming"},
- {PK_GROUP_ENUM_MULTIMEDIA, "multimedia"},
- {PK_GROUP_ENUM_SYSTEM, "system"},
- {0, NULL},
-};
-
-static PkTaskEnumMatch task_action[] = {
- {PK_ACTION_ENUM_INSTALL, "install"},
- {PK_ACTION_ENUM_REMOVE, "remove"},
- {PK_ACTION_ENUM_UPDATE, "update"},
- {PK_ACTION_ENUM_GET_UPDATES, "get-updates"},
- {PK_ACTION_ENUM_REFRESH_CACHE, "refresh-cache"},
- {PK_ACTION_ENUM_UPDATE_SYSTEM, "update-system"},
- {PK_ACTION_ENUM_SEARCH_NAME, "search-name"},
- {PK_ACTION_ENUM_SEARCH_DETAILS, "search-details"},
- {PK_ACTION_ENUM_SEARCH_GROUP, "search-group"},
- {PK_ACTION_ENUM_SEARCH_FILE, "search-file"},
- {PK_ACTION_ENUM_GET_DEPENDS, "get-depends"},
- {PK_ACTION_ENUM_GET_REQUIRES, "get-requires"},
- {PK_ACTION_ENUM_GET_DESCRIPTION, "get-description"},
- {0, NULL},
-};
-
-/**
- * pk_task_enum_find_value:
- */
-static guint
-pk_task_enum_find_value (PkTaskEnumMatch *table, const gchar *string)
-{
- guint i;
- const gchar *string_tmp;
-
- /* return the first entry on non-found or error */
- if (string == NULL) {
- return table[0].value;
- }
- for (i=0;;i++) {
- string_tmp = table[i].string;
- if (string_tmp == NULL) {
- break;
- }
- if (strcmp (string, string_tmp) == 0) {
- return table[i].value;
- }
- }
- return table[0].value;
-}
-
-/**
- * pk_task_enum_find_string:
- */
-static const gchar *
-pk_task_enum_find_string (PkTaskEnumMatch *table, guint value)
-{
- guint i;
- guint tmp;
- const gchar *string_tmp;
-
- for (i=0;;i++) {
- string_tmp = table[i].string;
- if (string_tmp == NULL) {
- break;
- }
- tmp = table[i].value;
- if (tmp == value) {
- return table[i].string;
- }
- }
- return table[0].string;
-}
-
-/**
- * pk_exit_enum_from_text:
- */
-PkTaskExit
-pk_exit_enum_from_text (const gchar *exit)
-{
- return pk_task_enum_find_value (task_exit, exit);
-}
-
-/**
- * pk_exit_enum_to_text:
- **/
-const gchar *
-pk_exit_enum_to_text (PkTaskExit exit)
-{
- return pk_task_enum_find_string (task_exit, exit);
-}
-
-/**
- * pk_status_enum_from_text:
- **/
-PkTaskStatus
-pk_status_enum_from_text (const gchar *status)
-{
- return pk_task_enum_find_value (task_status, status);
-}
-
-/**
- * pk_status_enum_to_text:
- **/
-const gchar *
-pk_status_enum_to_text (PkTaskStatus status)
-{
- return pk_task_enum_find_string (task_status, status);
-}
-
-/**
- * pk_role_enum_from_text:
- **/
-PkTaskRole
-pk_role_enum_from_text (const gchar *role)
-{
- return pk_task_enum_find_value (task_role, role);
-}
-
-/**
- * pk_role_enum_to_text:
- **/
-const gchar *
-pk_role_enum_to_text (PkTaskRole role)
-{
- return pk_task_enum_find_string (task_role, role);
-}
-
-/**
- * pk_error_enum_from_text:
- **/
-PkTaskErrorCode
-pk_error_enum_from_text (const gchar *code)
-{
- return pk_task_enum_find_value (task_error, code);
-}
-
-/**
- * pk_error_enum_to_text:
- **/
-const gchar *
-pk_error_enum_to_text (PkTaskErrorCode code)
-{
- return pk_task_enum_find_string (task_error, code);
-}
-
-/**
- * pk_restart_enum_from_text:
- **/
-PkTaskRestart
-pk_restart_enum_from_text (const gchar *restart)
-{
- return pk_task_enum_find_value (task_restart, restart);
-}
-
-/**
- * pk_restart_enum_to_text:
- **/
-const gchar *
-pk_restart_enum_to_text (PkTaskRestart restart)
-{
- return pk_task_enum_find_string (task_restart, restart);
-}
-
-/**
- * pk_group_enum_from_text:
- **/
-PkTaskGroup
-pk_group_enum_from_text (const gchar *group)
-{
- return pk_task_enum_find_value (task_group, group);
-}
-
-/**
- * pk_group_enum_to_text:
- **/
-const gchar *
-pk_group_enum_to_text (PkTaskGroup group)
-{
- return pk_task_enum_find_string (task_group, group);
-}
-
-/**
- * pk_action_enum_from_text:
- **/
-PkTaskAction
-pk_action_enum_from_text (const gchar *action)
-{
- return pk_task_enum_find_value (task_action, action);
-}
-
-/**
- * pk_action_enum_to_text:
- **/
-const gchar *
-pk_action_enum_to_text (PkTaskAction action)
-{
- return pk_task_enum_find_string (task_action, action);
-}
-
-/***************************************************************************
- *** MAKE CHECK TESTS ***
- ***************************************************************************/
-#ifdef PK_BUILD_TESTS
-#include <libselftest.h>
-
-void
-libst_task_utils (LibSelfTest *test)
-{
- gboolean ret;
- gchar *text;
-
- if (libst_start (test, "PkTaskUtils", CLASS_AUTO) == FALSE) {
- return;
- }
-
- libst_end (test);
-}
-#endif
-
diff --git a/libpackagekit/pk-task-utils.h b/libpackagekit/pk-task-utils.h
deleted file mode 100644
index 84c4769..0000000
--- a/libpackagekit/pk-task-utils.h
+++ /dev/null
@@ -1,143 +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_TASK_UTILS_H
-#define __PK_TASK_UTILS_H
-
-#include <glib-object.h>
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-/* what we asked to do */
-typedef enum {
- PK_ROLE_ENUM_QUERY,
- PK_ROLE_ENUM_REFRESH_CACHE,
- PK_ROLE_ENUM_SYSTEM_UPDATE,
- PK_ROLE_ENUM_PACKAGE_REMOVE,
- PK_ROLE_ENUM_PACKAGE_INSTALL,
- PK_ROLE_ENUM_PACKAGE_UPDATE,
- PK_ROLE_ENUM_UNKNOWN
-} PkTaskRole;
-
-/* what we are actually doing */
-typedef enum {
- PK_STATUS_ENUM_SETUP,
- PK_STATUS_ENUM_QUERY,
- PK_STATUS_ENUM_REMOVE,
- PK_STATUS_ENUM_REFRESH_CACHE,
- PK_STATUS_ENUM_DOWNLOAD,
- PK_STATUS_ENUM_INSTALL,
- PK_STATUS_ENUM_UPDATE,
- PK_STATUS_ENUM_UNKNOWN
-} PkTaskStatus;
-
-typedef enum {
- PK_EXIT_ENUM_SUCCESS,
- PK_EXIT_ENUM_FAILED,
- PK_EXIT_ENUM_CANCELED,
- PK_EXIT_ENUM_UNKNOWN
-} PkTaskExit;
-
-typedef enum {
- PK_RESTART_ENUM_NONE,
- PK_RESTART_ENUM_APPLICATION,
- PK_RESTART_ENUM_SESSION,
- PK_RESTART_ENUM_SYSTEM
-} PkTaskRestart;
-
-typedef enum {
- PK_ERROR_ENUM_OOM,
- PK_ERROR_ENUM_NO_NETWORK,
- PK_ERROR_ENUM_NOT_SUPPORTED,
- PK_ERROR_ENUM_INTERNAL_ERROR,
- PK_ERROR_ENUM_GPG_FAILURE,
- PK_ERROR_ENUM_PACKAGE_ID_INVALID,
- PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED,
- PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED,
- PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED,
- PK_ERROR_ENUM_DEP_RESOLUTION_FAILED,
- PK_ERROR_ENUM_FILTER_INVALID,
- PK_ERROR_ENUM_CREATE_THREAD_FAILED,
- PK_ERROR_ENUM_TRANSACTION_ERROR,
- PK_ERROR_ENUM_UNKNOWN
-} PkTaskErrorCode;
-
-typedef enum {
- PK_GROUP_ENUM_ACCESSIBILITY,
- PK_GROUP_ENUM_ACCESSORIES,
- PK_GROUP_ENUM_EDUCATION,
- PK_GROUP_ENUM_GAMES,
- PK_GROUP_ENUM_GRAPHICS,
- PK_GROUP_ENUM_INTERNET,
- PK_GROUP_ENUM_OFFICE,
- PK_GROUP_ENUM_OTHER,
- PK_GROUP_ENUM_PROGRAMMING,
- PK_GROUP_ENUM_MULTIMEDIA,
- PK_GROUP_ENUM_SYSTEM,
- PK_GROUP_ENUM_UNKNOWN
-} PkTaskGroup;
-
-typedef enum {
- PK_ACTION_ENUM_INSTALL = 1,
- PK_ACTION_ENUM_REMOVE,
- PK_ACTION_ENUM_UPDATE,
- PK_ACTION_ENUM_GET_UPDATES,
- PK_ACTION_ENUM_CANCEL_JOB,
- PK_ACTION_ENUM_REFRESH_CACHE,
- PK_ACTION_ENUM_UPDATE_SYSTEM,
- PK_ACTION_ENUM_SEARCH_NAME,
- PK_ACTION_ENUM_SEARCH_DETAILS,
- PK_ACTION_ENUM_SEARCH_GROUP,
- PK_ACTION_ENUM_SEARCH_FILE,
- PK_ACTION_ENUM_GET_DEPENDS,
- PK_ACTION_ENUM_GET_REQUIRES,
- PK_ACTION_ENUM_GET_DESCRIPTION,
- PK_ACTION_ENUM_INSTALL_PACKAGE,
- PK_ACTION_ENUM_REMOVE_PACKAGE,
- PK_ACTION_ENUM_UPDATE_PACKAGE,
- PK_ACTION_ENUM_UNKNOWN
-} PkTaskAction;
-
-PkTaskExit pk_exit_enum_from_text (const gchar *exit);
-const gchar *pk_exit_enum_to_text (PkTaskExit exit);
-
-PkTaskStatus pk_status_enum_from_text (const gchar *status);
-const gchar *pk_status_enum_to_text (PkTaskStatus status);
-
-PkTaskRole pk_role_enum_from_text (const gchar *role);
-const gchar *pk_role_enum_to_text (PkTaskRole role);
-
-PkTaskErrorCode pk_error_enum_from_text (const gchar *code);
-const gchar *pk_error_enum_to_text (PkTaskErrorCode code);
-
-PkTaskRestart pk_restart_enum_from_text (const gchar *restart);
-const gchar *pk_restart_enum_to_text (PkTaskRestart restart);
-
-PkTaskGroup pk_group_enum_from_text (const gchar *group);
-const gchar *pk_group_enum_to_text (PkTaskGroup group);
-
-PkTaskAction pk_action_enum_from_text (const gchar *action);
-const gchar *pk_action_enum_to_text (PkTaskAction action);
-
-G_END_DECLS
-
-#endif /* __PK_TASK_UTILS_H */
diff --git a/src/pk-backend.c b/src/pk-backend.c
index cb8312d..a4096dd 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -38,12 +38,12 @@
#include <glib/gi18n.h>
#include <gmodule.h>
#include <pk-package-id.h>
-#include <pk-task-utils.h>
+#include <pk-enum.h>
#include "pk-debug.h"
#include "pk-backend-internal.h"
#include "pk-marshal.h"
-#include "pk-task-utils.h"
+#include "pk-enum.h"
#include "pk-spawn.h"
#include "pk-network.h"
diff --git a/src/pk-backend.h b/src/pk-backend.h
index e903a51..47f513e 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -23,7 +23,7 @@
#define __PK_BACKEND_H
#include <glib.h>
-#include <pk-task-utils.h>
+#include <pk-enum.h>
#include <pk-package-id.h>
G_BEGIN_DECLS
diff --git a/src/pk-engine.c b/src/pk-engine.c
index bcd5cfc..343db08 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -42,7 +42,7 @@
#include <pk-debug.h>
#include <pk-task-common.h>
-#include <pk-task-utils.h>
+#include <pk-enum.h>
#include "pk-backend-internal.h"
#include "pk-engine.h"
diff --git a/tools/add-error-enum.sh b/tools/add-error-enum.sh
index c30ccd9..fe7c0cd 100755
--- a/tools/add-error-enum.sh
+++ b/tools/add-error-enum.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-$EDITOR backends/README libpackagekit/pk-task-utils.h libpackagekit/pk-task-utils.c ../gnome-packagekit/src/pk-common.c backends/yum/helpers/packagekit.py
+$EDITOR backends/README libpackagekit/pk-enum.h libpackagekit/pk-task-utils.c ../gnome-packagekit/src/pk-common.c backends/yum/helpers/packagekit.py
diff-tree 7312db561aac4b204ff23bc1ac68f76da1e548d2 (from e589dd9f1de9a7026e442c44035e1990407b0fd3)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Sep 7 16:52:34 2007 +0100
remove the unused old actions stuff
diff --git a/libpackagekit/pk-action-list.c b/libpackagekit/pk-action-list.c
index c72d640..e0c5b60 100644
--- a/libpackagekit/pk-action-list.c
+++ b/libpackagekit/pk-action-list.c
@@ -158,6 +158,47 @@ 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-task-utils.c b/libpackagekit/pk-task-utils.c
index d9dd636..2ca23aa 100644
--- a/libpackagekit/pk-task-utils.c
+++ b/libpackagekit/pk-task-utils.c
@@ -298,64 +298,6 @@ pk_action_enum_to_text (PkTaskAction act
return pk_task_enum_find_string (task_action, action);
}
-/**
- * pk_action_enum_build:
- **/
-gchar *
-pk_action_enum_build (PkTaskAction action, ...)
-{
- va_list args;
- guint i;
- GString *string;
- PkTaskAction action_temp;
-
- string = g_string_new (pk_action_enum_to_text (action));
- g_string_append (string, ";");
-
- /* process the valist */
- va_start (args, action);
- for (i=0;; i++) {
- action_temp = va_arg (args, PkTaskAction);
- if (action_temp == 0) break;
- g_string_append (string, pk_action_enum_to_text (action_temp));
- g_string_append (string, ";");
- }
- va_end (args);
-
- /* remove last ';' */
- g_string_set_size (string, string->len - 1);
-
- return g_string_free (string, FALSE);
-}
-
-/**
- * pk_action_enum_contains:
- **/
-gboolean
-pk_action_enum_contains (const gchar *actions, PkTaskAction action)
-{
- gchar **sections;
- guint i;
- guint ret = FALSE;
-
- if (actions == NULL) {
- pk_warning ("actions null");
- return FALSE;
- }
-
- /* split by delimeter ';' */
- sections = g_strsplit (actions, ";", 0);
-
- for (i=0; sections[i]; i++) {
- if (pk_action_enum_from_text (sections[i]) == action) {
- ret = TRUE;
- break;
- }
- }
- g_strfreev (sections);
- return ret;
-}
-
/***************************************************************************
*** MAKE CHECK TESTS ***
***************************************************************************/
@@ -372,46 +314,6 @@ libst_task_utils (LibSelfTest *test)
return;
}
- /************************************************************
- **************** 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);
-
libst_end (test);
}
#endif
diff --git a/libpackagekit/pk-task-utils.h b/libpackagekit/pk-task-utils.h
index f1e4533..84c4769 100644
--- a/libpackagekit/pk-task-utils.h
+++ b/libpackagekit/pk-task-utils.h
@@ -138,11 +138,6 @@ const gchar *pk_group_enum_to_text (Pk
PkTaskAction pk_action_enum_from_text (const gchar *action);
const gchar *pk_action_enum_to_text (PkTaskAction action);
-/* actions */
-gchar *pk_action_enum_build (PkTaskAction action, ...);
-gboolean pk_action_enum_contains (const gchar *actions,
- PkTaskAction action);
-
G_END_DECLS
#endif /* __PK_TASK_UTILS_H */
diff-tree e589dd9f1de9a7026e442c44035e1990407b0fd3 (from a8b9b90e23f518532d732beefadf1788334edd39)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Sep 7 16:50:05 2007 +0100
split off action list into it's own file
diff --git a/libpackagekit/Makefile.am b/libpackagekit/Makefile.am
index b4e9a62..ee9effa 100644
--- a/libpackagekit/Makefile.am
+++ b/libpackagekit/Makefile.am
@@ -28,6 +28,7 @@ libpackagekit_include_HEADERS = \
pk-debug.h \
pk-connection.h \
pk-package-id.h \
+ pk-action-list.h \
pk-task-utils.h \
pk-task-common.h \
pk-task-monitor.h \
@@ -46,6 +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-task-utils.h \
pk-task-utils.c \
pk-task-common.c \
diff --git a/libpackagekit/pk-action-list.c b/libpackagekit/pk-action-list.c
new file mode 100644
index 0000000..c72d640
--- /dev/null
+++ b/libpackagekit/pk-action-list.c
@@ -0,0 +1,164 @@
+/* -*- 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;
+ }
+ libst_end (test);
+}
+#endif
+
diff --git a/libpackagekit/pk-action-list.h b/libpackagekit/pk-action-list.h
new file mode 100644
index 0000000..94cfecb
--- /dev/null
+++ b/libpackagekit/pk-action-list.h
@@ -0,0 +1,42 @@
+/* -*- 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-task-utils.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 --git a/libpackagekit/pk-task-utils.c b/libpackagekit/pk-task-utils.c
index 65cb8ab..d9dd636 100644
--- a/libpackagekit/pk-task-utils.c
+++ b/libpackagekit/pk-task-utils.c
@@ -356,122 +356,6 @@ pk_action_enum_contains (const gchar *ac
return ret;
}
-/**
- * pk_util_action_new:
- **/
-PkActionList *
-pk_util_action_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_util_action_new_from_string:
- **/
-PkActionList *
-pk_util_action_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_util_action_free:
- **/
-gboolean
-pk_util_action_free (PkActionList *alist)
-{
- g_ptr_array_free (alist, TRUE);
- return TRUE;
-}
-
-/**
- * pk_util_action_to_string:
- **/
-gchar *
-pk_util_action_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_util_action_append:
- **/
-gboolean
-pk_util_action_append (PkActionList *alist, PkTaskAction action)
-{
- g_ptr_array_add (alist, GUINT_TO_POINTER(action));
- return TRUE;
-}
-
-/**
- * pk_util_action_contains:
- **/
-gboolean
-pk_util_action_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 ***
***************************************************************************/
diff --git a/libpackagekit/pk-task-utils.h b/libpackagekit/pk-task-utils.h
index 35b112d..f1e4533 100644
--- a/libpackagekit/pk-task-utils.h
+++ b/libpackagekit/pk-task-utils.h
@@ -143,16 +143,6 @@ gchar *pk_action_enum_build (PkTaskAc
gboolean pk_action_enum_contains (const gchar *actions,
PkTaskAction action);
-typedef GPtrArray PkActionList;
-PkActionList *pk_util_action_new (PkTaskAction action, ...);
-PkActionList *pk_util_action_new_from_string (const gchar *actions);
-gchar *pk_util_action_to_string (PkActionList *alist);
-gboolean pk_util_action_contains (PkActionList *alist,
- PkTaskAction action);
-gboolean pk_util_action_append (PkActionList *alist,
- PkTaskAction action);
-gboolean pk_util_action_free (PkActionList *alist);
-
G_END_DECLS
#endif /* __PK_TASK_UTILS_H */
diff --git a/src/pk-backend-internal.h b/src/pk-backend-internal.h
index 926ac6f..e055d67 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-task-utils.h>
+#include <pk-action-list.h>
#include "pk-backend.h"
G_BEGIN_DECLS
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 7a455a0..cb8312d 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -918,48 +918,48 @@ PkActionList *
pk_backend_get_actions (PkBackend *backend)
{
PkActionList *alist;
- alist = pk_util_action_new (PK_ACTION_ENUM_UNKNOWN);
+ alist = pk_action_list_new (PK_ACTION_ENUM_UNKNOWN);
if (backend->desc->cancel_job_try != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_CANCEL_JOB);
+ pk_action_list_append (alist, PK_ACTION_ENUM_CANCEL_JOB);
}
if (backend->desc->get_depends != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_GET_DEPENDS);
+ pk_action_list_append (alist, PK_ACTION_ENUM_GET_DEPENDS);
}
if (backend->desc->get_description != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_GET_DESCRIPTION);
+ pk_action_list_append (alist, PK_ACTION_ENUM_GET_DESCRIPTION);
}
if (backend->desc->get_requires != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_GET_REQUIRES);
+ pk_action_list_append (alist, PK_ACTION_ENUM_GET_REQUIRES);
}
if (backend->desc->get_updates != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_GET_UPDATES);
+ pk_action_list_append (alist, PK_ACTION_ENUM_GET_UPDATES);
}
if (backend->desc->install_package != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_INSTALL_PACKAGE);
+ pk_action_list_append (alist, PK_ACTION_ENUM_INSTALL_PACKAGE);
}
if (backend->desc->refresh_cache != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_REFRESH_CACHE);
+ pk_action_list_append (alist, PK_ACTION_ENUM_REFRESH_CACHE);
}
if (backend->desc->remove_package != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_REMOVE_PACKAGE);
+ pk_action_list_append (alist, PK_ACTION_ENUM_REMOVE_PACKAGE);
}
if (backend->desc->search_details != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_SEARCH_DETAILS);
+ pk_action_list_append (alist, PK_ACTION_ENUM_SEARCH_DETAILS);
}
if (backend->desc->search_file != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_SEARCH_FILE);
+ pk_action_list_append (alist, PK_ACTION_ENUM_SEARCH_FILE);
}
if (backend->desc->search_group != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_SEARCH_GROUP);
+ pk_action_list_append (alist, PK_ACTION_ENUM_SEARCH_GROUP);
}
if (backend->desc->search_name != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_SEARCH_NAME);
+ pk_action_list_append (alist, PK_ACTION_ENUM_SEARCH_NAME);
}
if (backend->desc->update_package != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_UPDATE_PACKAGE);
+ pk_action_list_append (alist, PK_ACTION_ENUM_UPDATE_PACKAGE);
}
if (backend->desc->update_system != NULL) {
- pk_util_action_append (alist, PK_ACTION_ENUM_UPDATE_SYSTEM);
+ pk_action_list_append (alist, PK_ACTION_ENUM_UPDATE_SYSTEM);
}
return alist;
}
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 1b10ede..bcd5cfc 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -1398,7 +1398,7 @@ pk_engine_get_actions (PkEngine *engine,
pk_backend_load (task, engine->priv->backend);
alist = pk_backend_get_actions (task);
g_object_unref (task);
- *actions = pk_util_action_to_string (alist);
+ *actions = pk_action_list_to_string (alist);
return TRUE;
}
diff-tree a8b9b90e23f518532d732beefadf1788334edd39 (from d3c9c3a0aaaae9ee1099ff4a8d649b40bc2e4cba)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Sep 7 16:39:46 2007 +0100
move the filter bits into the comon file
diff --git a/libpackagekit/pk-task-common.c b/libpackagekit/pk-task-common.c
index 2dcc757..352e309 100644
--- a/libpackagekit/pk-task-common.c
+++ b/libpackagekit/pk-task-common.c
@@ -35,3 +35,201 @@
#include "pk-debug.h"
#include "pk-task-common.h"
+/**
+ * pk_task_filter_check_part:
+ **/
+gboolean
+pk_task_filter_check_part (const gchar *filter)
+{
+ if (filter == NULL) {
+ return FALSE;
+ }
+ if (strlen (filter) == 0) {
+ return FALSE;
+ }
+ if (strcmp (filter, "none") == 0) {
+ return TRUE;
+ }
+ if (strcmp (filter, "installed") == 0) {
+ return TRUE;
+ }
+ if (strcmp (filter, "~installed") == 0) {
+ return TRUE;
+ }
+ if (strcmp (filter, "devel") == 0) {
+ return TRUE;
+ }
+ if (strcmp (filter, "~devel") == 0) {
+ return TRUE;
+ }
+ if (strcmp (filter, "gui") == 0) {
+ return TRUE;
+ }
+ if (strcmp (filter, "~gui") == 0) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
+ * pk_task_filter_check:
+ **/
+gboolean
+pk_task_filter_check (const gchar *filter)
+{
+ gchar **sections;
+ guint i;
+ guint length;
+ gboolean ret;
+
+ if (filter == NULL) {
+ pk_warning ("filter null");
+ return FALSE;
+ }
+ if (strlen (filter) == 0) {
+ pk_warning ("filter zero length");
+ return FALSE;
+ }
+
+ /* split by delimeter ';' */
+ sections = g_strsplit (filter, ";", 0);
+ length = g_strv_length (sections);
+ ret = FALSE;
+ for (i=0; i<length; i++) {
+ /* only one wrong part is enough to fail the filter */
+ if (strlen (sections[i]) == 0) {
+ goto out;
+ }
+ if (pk_task_filter_check_part (sections[i]) == FALSE) {
+ goto out;
+ }
+ }
+ ret = TRUE;
+out:
+ g_strfreev (sections);
+ return ret;
+}
+
+/***************************************************************************
+ *** MAKE CHECK TESTS ***
+ ***************************************************************************/
+#ifdef PK_BUILD_TESTS
+#include <libselftest.h>
+
+void
+libst_task_common (LibSelfTest *test)
+{
+ gboolean ret;
+ gchar *text;
+ const gchar *temp;
+
+ if (libst_start (test, "PkTaskCommon", CLASS_AUTO) == FALSE) {
+ return;
+ }
+
+ /************************************************************
+ **************** FILTERS ******************
+ ************************************************************/
+ temp = NULL;
+ libst_title (test, "test a fail filter (null)");
+ ret = pk_task_filter_check (temp);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "passed the filter '%s'", temp);
+ }
+
+ /************************************************************/
+ temp = "";
+ libst_title (test, "test a fail filter ()");
+ ret = pk_task_filter_check (temp);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "passed the filter '%s'", temp);
+ }
+
+ /************************************************************/
+ temp = ";";
+ libst_title (test, "test a fail filter (;)");
+ ret = pk_task_filter_check (temp);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "passed the filter '%s'", temp);
+ }
+
+ /************************************************************/
+ temp = "moo";
+ libst_title (test, "test a fail filter (invalid)");
+ ret = pk_task_filter_check (temp);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "passed the filter '%s'", temp);
+ }
+
+ /************************************************************/
+ temp = "moo;foo";
+ libst_title (test, "test a fail filter (invalid, multiple)");
+ ret = pk_task_filter_check (temp);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "passed the filter '%s'", temp);
+ }
+
+ /************************************************************/
+ temp = "gui;;";
+ libst_title (test, "test a fail filter (valid then zero length)");
+ ret = pk_task_filter_check (temp);
+ if (ret == FALSE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "passed the filter '%s'", temp);
+ }
+
+ /************************************************************/
+ temp = "none";
+ libst_title (test, "test a pass filter (none)");
+ ret = pk_task_filter_check (temp);
+ if (ret == TRUE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed the filter '%s'", temp);
+ }
+
+ /************************************************************/
+ temp = "gui";
+ libst_title (test, "test a pass filter (single)");
+ ret = pk_task_filter_check (temp);
+ if (ret == TRUE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed the filter '%s'", temp);
+ }
+
+ /************************************************************/
+ temp = "devel;~gui";
+ libst_title (test, "test a pass filter (multiple)");
+ ret = pk_task_filter_check (temp);
+ if (ret == TRUE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed the filter '%s'", temp);
+ }
+
+ /************************************************************/
+ temp = "~gui;~installed";
+ libst_title (test, "test a pass filter (multiple2)");
+ ret = pk_task_filter_check (temp);
+ if (ret == TRUE) {
+ libst_success (test, NULL);
+ } else {
+ libst_failed (test, "failed the filter '%s'", temp);
+ }
+
+ libst_end (test);
+}
+#endif
+
diff --git a/libpackagekit/pk-task-common.h b/libpackagekit/pk-task-common.h
index 252a1aa..b4b6c51 100644
--- a/libpackagekit/pk-task-common.h
+++ b/libpackagekit/pk-task-common.h
@@ -30,6 +30,8 @@ G_BEGIN_DECLS
#define PK_DBUS_PATH "/org/freedesktop/PackageKit"
#define PK_DBUS_INTERFACE "org.freedesktop.PackageKit"
+gboolean pk_task_filter_check (const gchar *filter);
+
G_END_DECLS
#endif /* __PK_TASK_H */
diff --git a/libpackagekit/pk-task-utils.c b/libpackagekit/pk-task-utils.c
index 0a65c8e..65cb8ab 100644
--- a/libpackagekit/pk-task-utils.c
+++ b/libpackagekit/pk-task-utils.c
@@ -299,81 +299,6 @@ pk_action_enum_to_text (PkTaskAction act
}
/**
- * pk_task_filter_check_part:
- **/
-gboolean
-pk_task_filter_check_part (const gchar *filter)
-{
- if (filter == NULL) {
- return FALSE;
- }
- if (strlen (filter) == 0) {
- return FALSE;
- }
- if (strcmp (filter, "none") == 0) {
- return TRUE;
- }
- if (strcmp (filter, "installed") == 0) {
- return TRUE;
- }
- if (strcmp (filter, "~installed") == 0) {
- return TRUE;
- }
- if (strcmp (filter, "devel") == 0) {
- return TRUE;
- }
- if (strcmp (filter, "~devel") == 0) {
- return TRUE;
- }
- if (strcmp (filter, "gui") == 0) {
- return TRUE;
- }
- if (strcmp (filter, "~gui") == 0) {
- return TRUE;
- }
- return FALSE;
-}
-
-/**
- * pk_task_filter_check:
- **/
-gboolean
-pk_task_filter_check (const gchar *filter)
-{
- gchar **sections;
- guint i;
- guint length;
- gboolean ret;
-
- if (filter == NULL) {
- pk_warning ("filter null");
- return FALSE;
- }
- if (strlen (filter) == 0) {
- pk_warning ("filter zero length");
- return FALSE;
- }
-
- /* split by delimeter ';' */
- sections = g_strsplit (filter, ";", 0);
- length = g_strv_length (sections);
- ret = FALSE;
- for (i=0; i<length; i++) {
- /* only one wrong part is enough to fail the filter */
- if (strlen (sections[i]) == 0) {
- goto out;
- }
- if (pk_task_filter_check_part (sections[i]) == FALSE) {
- goto out;
- }
- }
- ret = TRUE;
-out:
- g_strfreev (sections);
- return ret;
-}
-
-/**
* pk_action_enum_build:
**/
gchar *
@@ -558,115 +483,11 @@ libst_task_utils (LibSelfTest *test)
{
gboolean ret;
gchar *text;
- const gchar *temp;
if (libst_start (test, "PkTaskUtils", CLASS_AUTO) == FALSE) {
return;
}
-
- /************************************************************
- **************** FILTERS ******************
- ************************************************************/
- temp = NULL;
- libst_title (test, "test a fail filter (null)");
- ret = pk_task_filter_check (temp);
- if (ret == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "passed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "";
- libst_title (test, "test a fail filter ()");
- ret = pk_task_filter_check (temp);
- if (ret == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "passed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = ";";
- libst_title (test, "test a fail filter (;)");
- ret = pk_task_filter_check (temp);
- if (ret == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "passed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "moo";
- libst_title (test, "test a fail filter (invalid)");
- ret = pk_task_filter_check (temp);
- if (ret == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "passed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "moo;foo";
- libst_title (test, "test a fail filter (invalid, multiple)");
- ret = pk_task_filter_check (temp);
- if (ret == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "passed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "gui;;";
- libst_title (test, "test a fail filter (valid then zero length)");
- ret = pk_task_filter_check (temp);
- if (ret == FALSE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "passed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "none";
- libst_title (test, "test a pass filter (none)");
- ret = pk_task_filter_check (temp);
- if (ret == TRUE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "failed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "gui";
- libst_title (test, "test a pass filter (single)");
- ret = pk_task_filter_check (temp);
- if (ret == TRUE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "failed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "devel;~gui";
- libst_title (test, "test a pass filter (multiple)");
- ret = pk_task_filter_check (temp);
- if (ret == TRUE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "failed the filter '%s'", temp);
- }
-
- /************************************************************/
- temp = "~gui;~installed";
- libst_title (test, "test a pass filter (multiple2)");
- ret = pk_task_filter_check (temp);
- if (ret == TRUE) {
- libst_success (test, NULL);
- } else {
- libst_failed (test, "failed the filter '%s'", temp);
- }
-
/************************************************************
**************** ACTIONS ******************
************************************************************/
@@ -681,7 +502,7 @@ libst_task_utils (LibSelfTest *test)
/************************************************************/
libst_title (test, "test the action building (multiple)");
- text = pk_action_enum_build (PK_ACTION_ENUM_INSTALL, PK_TASK_ACTION_SEARCH_NAME, PK_TASK_ACTION_GET_DEPENDS, 0);
+ 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 {
diff --git a/libpackagekit/pk-task-utils.h b/libpackagekit/pk-task-utils.h
index d8021f0..35b112d 100644
--- a/libpackagekit/pk-task-utils.h
+++ b/libpackagekit/pk-task-utils.h
@@ -138,8 +138,6 @@ const gchar *pk_group_enum_to_text (Pk
PkTaskAction pk_action_enum_from_text (const gchar *action);
const gchar *pk_action_enum_to_text (PkTaskAction action);
-gboolean pk_task_filter_check (const gchar *filter);
-
/* actions */
gchar *pk_action_enum_build (PkTaskAction action, ...);
gboolean pk_action_enum_contains (const gchar *actions,
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 16ca474..1b10ede 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -41,7 +41,9 @@
#include <pk-package-id.h>
#include <pk-debug.h>
-#include "pk-task-utils.h"
+#include <pk-task-common.h>
+#include <pk-task-utils.h>
+
#include "pk-backend-internal.h"
#include "pk-engine.h"
#include "pk-marshal.h"
diff-tree d3c9c3a0aaaae9ee1099ff4a8d649b40bc2e4cba (from f886bdeae807e472d1fcfc76a6b80b8c64aaae67)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Sep 7 16:16:09 2007 +0100
rename some of the enum methods, removing task from the name
diff --git a/TODO b/TODO
index a470b5d..fbbb22d 100644
--- a/TODO
+++ b/TODO
@@ -22,7 +22,6 @@ string updates
string obsoletes
string update_text
}
-* Change _TASK_ to ENUM in the enums
* Have to have an UpdatesChanged signal for the icon to update after we've done
a system upgrade
* Have to load parameters from a conf file:
diff --git a/backends/apt/pk-task-apt.cpp.delete.me b/backends/apt/pk-task-apt.cpp.delete.me
index f74cbef..898c765 100644
--- a/backends/apt/pk-task-apt.cpp.delete.me
+++ b/backends/apt/pk-task-apt.cpp.delete.me
@@ -108,7 +108,7 @@ gchar *
pk_task_get_actions (void)
{
gchar *actions;
- actions = pk_task_action_build (PK_ACTION_ENUM_REFRESH_CACHE,
+ actions = pk_action_enum_build (PK_ACTION_ENUM_REFRESH_CACHE,
PK_ACTION_ENUM_UPDATE_SYSTEM,
PK_ACTION_ENUM_SEARCH_NAME,
PK_ACTION_ENUM_SEARCH_DETAILS,
diff --git a/client/pk-console.c b/client/pk-console.c
index 23d4856..af452da 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -323,7 +323,7 @@ pk_console_finished_cb (PkTaskClient *tc
static void
pk_console_error_code_cb (PkTaskClient *tclient, PkTaskErrorCode error_code, const gchar *details, gpointer data)
{
- g_print ("Error: %s : %s\n", pk_task_error_code_to_text (error_code), details);
+ 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 cc1297a..d59f9d4 100644
--- a/client/pk-monitor.c
+++ b/client/pk-monitor.c
@@ -48,7 +48,7 @@ pk_monitor_task_list_changed_cb (PkTaskL
static void
pk_monitor_error_code_cb (PkTaskList *tlist, PkTaskErrorCode error_code, const gchar *details, gpointer data)
{
- g_print ("Error: %s : %s\n", pk_task_error_code_to_text (error_code), details);
+ g_print ("Error: %s : %s\n", pk_error_enum_to_text (error_code), details);
}
/**
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
index 4759361..ae03767 100644
--- a/libpackagekit/pk-task-client.c
+++ b/libpackagekit/pk-task-client.c
@@ -1051,7 +1051,7 @@ pk_task_client_require_restart_cb (PkTas
/* always use the 'worst' possible restart scenario */
if (restart > tclient->priv->require_restart) {
tclient->priv->require_restart = restart;
- pk_debug ("restart status now %s", pk_task_restart_to_text (restart));
+ pk_debug ("restart status now %s", pk_restart_enum_to_text (restart));
}
}
diff --git a/libpackagekit/pk-task-list.c b/libpackagekit/pk-task-list.c
index be9d58d..98f7b3b 100644
--- a/libpackagekit/pk-task-list.c
+++ b/libpackagekit/pk-task-list.c
@@ -85,7 +85,7 @@ pk_task_list_print (PkTaskList *tlist)
}
for (i=0; i<length; i++) {
item = g_ptr_array_index (tlist->priv->task_list, i);
- g_print ("%i %s %s", item->job, pk_task_status_to_text (item->role), item->package_id);
+ g_print ("%i %s %s", item->job, pk_status_enum_to_text (item->role), item->package_id);
}
g_print ("\n");
return TRUE;
diff --git a/libpackagekit/pk-task-monitor.c b/libpackagekit/pk-task-monitor.c
index ed14568..300aa0a 100644
--- a/libpackagekit/pk-task-monitor.c
+++ b/libpackagekit/pk-task-monitor.c
@@ -119,7 +119,7 @@ pk_task_monitor_get_status (PkTaskMonito
pk_warning ("GetJobStatus failed!");
return FALSE;
}
- *status = pk_task_status_from_text (status_text);
+ *status = pk_status_enum_from_text (status_text);
return TRUE;
}
@@ -152,7 +152,7 @@ pk_task_monitor_get_role (PkTaskMonitor
g_error_free (error);
return FALSE;
}
- *role = pk_task_role_from_text (role_text);
+ *role = pk_role_enum_from_text (role_text);
if (package_id != NULL) {
*package_id = g_strdup (package_id_temp);
}
@@ -175,7 +175,7 @@ pk_task_monitor_finished_cb (DBusGProxy
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
if (job == tmonitor->priv->job) {
- exit = pk_task_exit_from_text (exit_text);
+ exit = pk_exit_enum_from_text (exit_text);
pk_debug ("emit finished %i, %i", exit, runtime);
g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_FINISHED], 0, exit, runtime);
}
@@ -248,7 +248,7 @@ pk_task_monitor_job_status_changed_cb (D
g_return_if_fail (tmonitor != NULL);
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
- status = pk_task_status_from_text (status_text);
+ status = pk_status_enum_from_text (status_text);
if (job == tmonitor->priv->job) {
pk_debug ("emit job-status-changed %i", status);
@@ -293,7 +293,7 @@ pk_task_monitor_description_cb (DBusGPro
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
if (job == tmonitor->priv->job) {
- group = pk_task_group_from_text (group_text);
+ group = pk_group_enum_from_text (group_text);
pk_debug ("emit description %s, %i, %s, %s", package_id, group, description, url);
g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_DESCRIPTION], 0, package_id, group, description, url);
}
@@ -314,7 +314,7 @@ pk_task_monitor_error_code_cb (DBusGProx
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
if (job == tmonitor->priv->job) {
- code = pk_task_error_code_from_text (code_text);
+ code = pk_error_enum_from_text (code_text);
pk_debug ("emit error-code %i, %s", code, details);
g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_ERROR_CODE], 0, code, details);
}
@@ -335,7 +335,7 @@ pk_task_monitor_require_restart_cb (DBus
g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
if (job == tmonitor->priv->job) {
- restart = pk_task_restart_from_text (restart_text);
+ restart = pk_restart_enum_from_text (restart_text);
pk_debug ("emit require-restart %i, %s", restart, details);
g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_REQUIRE_RESTART], 0, restart, details);
}
diff --git a/libpackagekit/pk-task-utils.c b/libpackagekit/pk-task-utils.c
index 76c721f..0a65c8e 100644
--- a/libpackagekit/pk-task-utils.c
+++ b/libpackagekit/pk-task-utils.c
@@ -173,127 +173,127 @@ pk_task_enum_find_string (PkTaskEnumMatc
}
/**
- * pk_task_exit_from_text:
+ * pk_exit_enum_from_text:
*/
PkTaskExit
-pk_task_exit_from_text (const gchar *exit)
+pk_exit_enum_from_text (const gchar *exit)
{
return pk_task_enum_find_value (task_exit, exit);
}
/**
- * pk_task_exit_to_text:
+ * pk_exit_enum_to_text:
**/
const gchar *
-pk_task_exit_to_text (PkTaskExit exit)
+pk_exit_enum_to_text (PkTaskExit exit)
{
return pk_task_enum_find_string (task_exit, exit);
}
/**
- * pk_task_status_from_text:
+ * pk_status_enum_from_text:
**/
PkTaskStatus
-pk_task_status_from_text (const gchar *status)
+pk_status_enum_from_text (const gchar *status)
{
return pk_task_enum_find_value (task_status, status);
}
/**
- * pk_task_status_to_text:
+ * pk_status_enum_to_text:
**/
const gchar *
-pk_task_status_to_text (PkTaskStatus status)
+pk_status_enum_to_text (PkTaskStatus status)
{
return pk_task_enum_find_string (task_status, status);
}
/**
- * pk_task_role_from_text:
+ * pk_role_enum_from_text:
**/
PkTaskRole
-pk_task_role_from_text (const gchar *role)
+pk_role_enum_from_text (const gchar *role)
{
return pk_task_enum_find_value (task_role, role);
}
/**
- * pk_task_role_to_text:
+ * pk_role_enum_to_text:
**/
const gchar *
-pk_task_role_to_text (PkTaskRole role)
+pk_role_enum_to_text (PkTaskRole role)
{
return pk_task_enum_find_string (task_role, role);
}
/**
- * pk_task_error_code_from_text:
+ * pk_error_enum_from_text:
**/
PkTaskErrorCode
-pk_task_error_code_from_text (const gchar *code)
+pk_error_enum_from_text (const gchar *code)
{
return pk_task_enum_find_value (task_error, code);
}
/**
- * pk_task_error_code_to_text:
+ * pk_error_enum_to_text:
**/
const gchar *
-pk_task_error_code_to_text (PkTaskErrorCode code)
+pk_error_enum_to_text (PkTaskErrorCode code)
{
return pk_task_enum_find_string (task_error, code);
}
/**
- * pk_task_restart_from_text:
+ * pk_restart_enum_from_text:
**/
PkTaskRestart
-pk_task_restart_from_text (const gchar *restart)
+pk_restart_enum_from_text (const gchar *restart)
{
return pk_task_enum_find_value (task_restart, restart);
}
/**
- * pk_task_restart_to_text:
+ * pk_restart_enum_to_text:
**/
const gchar *
-pk_task_restart_to_text (PkTaskRestart restart)
+pk_restart_enum_to_text (PkTaskRestart restart)
{
return pk_task_enum_find_string (task_restart, restart);
}
/**
- * pk_task_group_from_text:
+ * pk_group_enum_from_text:
**/
PkTaskGroup
-pk_task_group_from_text (const gchar *group)
+pk_group_enum_from_text (const gchar *group)
{
return pk_task_enum_find_value (task_group, group);
}
/**
- * pk_task_group_to_text:
+ * pk_group_enum_to_text:
**/
const gchar *
-pk_task_group_to_text (PkTaskGroup group)
+pk_group_enum_to_text (PkTaskGroup group)
{
return pk_task_enum_find_string (task_group, group);
}
/**
- * pk_task_action_from_text:
+ * pk_action_enum_from_text:
**/
PkTaskAction
-pk_task_action_from_text (const gchar *action)
+pk_action_enum_from_text (const gchar *action)
{
return pk_task_enum_find_value (task_action, action);
}
/**
- * pk_task_action_to_text:
+ * pk_action_enum_to_text:
**/
const gchar *
-pk_task_action_to_text (PkTaskAction action)
+pk_action_enum_to_text (PkTaskAction action)
{
return pk_task_enum_find_string (task_action, action);
}
@@ -374,17 +374,17 @@ out:
}
/**
- * pk_task_action_build:
+ * pk_action_enum_build:
**/
gchar *
-pk_task_action_build (PkTaskAction action, ...)
+pk_action_enum_build (PkTaskAction action, ...)
{
va_list args;
guint i;
GString *string;
PkTaskAction action_temp;
- string = g_string_new (pk_task_action_to_text (action));
+ string = g_string_new (pk_action_enum_to_text (action));
g_string_append (string, ";");
/* process the valist */
@@ -392,7 +392,7 @@ pk_task_action_build (PkTaskAction actio
for (i=0;; i++) {
action_temp = va_arg (args, PkTaskAction);
if (action_temp == 0) break;
- g_string_append (string, pk_task_action_to_text (action_temp));
+ g_string_append (string, pk_action_enum_to_text (action_temp));
g_string_append (string, ";");
}
va_end (args);
@@ -404,10 +404,10 @@ pk_task_action_build (PkTaskAction actio
}
/**
- * pk_task_action_contains:
+ * pk_action_enum_contains:
**/
gboolean
-pk_task_action_contains (const gchar *actions, PkTaskAction action)
+pk_action_enum_contains (const gchar *actions, PkTaskAction action)
{
gchar **sections;
guint i;
@@ -422,7 +422,7 @@ pk_task_action_contains (const gchar *ac
sections = g_strsplit (actions, ";", 0);
for (i=0; sections[i]; i++) {
- if (pk_task_action_from_text (sections[i]) == action) {
+ if (pk_action_enum_from_text (sections[i]) == action) {
ret = TRUE;
break;
}
@@ -482,7 +482,7 @@ pk_util_action_new_from_string (const gc
alist = g_ptr_array_new ();
for (i=0; sections[i]; i++) {
- action_temp = pk_task_action_from_text (sections[i]);
+ action_temp = pk_action_enum_from_text (sections[i]);
g_ptr_array_add (alist, GUINT_TO_POINTER(action_temp));
}
g_strfreev (sections);
@@ -512,7 +512,7 @@ pk_util_action_to_string (PkActionList *
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_task_action_to_text (action));
+ g_string_append (string, pk_action_enum_to_text (action));
g_string_append (string, ";");
}
@@ -671,7 +671,7 @@ libst_task_utils (LibSelfTest *test)
**************** ACTIONS ******************
************************************************************/
libst_title (test, "test the action building (single)");
- text = pk_task_action_build (PK_ACTION_ENUM_INSTALL, 0);
+ text = pk_action_enum_build (PK_ACTION_ENUM_INSTALL, 0);
if (strcmp (text, "install") == 0) {
libst_success (test, NULL);
} else {
@@ -681,7 +681,7 @@ libst_task_utils (LibSelfTest *test)
/************************************************************/
libst_title (test, "test the action building (multiple)");
- text = pk_task_action_build (PK_ACTION_ENUM_INSTALL, PK_TASK_ACTION_SEARCH_NAME, PK_TASK_ACTION_GET_DEPENDS, 0);
+ text = pk_action_enum_build (PK_ACTION_ENUM_INSTALL, PK_TASK_ACTION_SEARCH_NAME, PK_TASK_ACTION_GET_DEPENDS, 0);
if (strcmp (text, "install;search-name;get-depends") == 0) {
libst_success (test, NULL);
} else {
@@ -690,7 +690,7 @@ libst_task_utils (LibSelfTest *test)
/************************************************************/
libst_title (test, "test the action checking (present)");
- ret = pk_task_action_contains (text, PK_ACTION_ENUM_INSTALL);
+ ret = pk_action_enum_contains (text, PK_ACTION_ENUM_INSTALL);
if (ret == TRUE) {
libst_success (test, NULL);
} else {
@@ -699,7 +699,7 @@ libst_task_utils (LibSelfTest *test)
/************************************************************/
libst_title (test, "test the action checking (not-present)");
- ret = pk_task_action_contains (text, PK_ACTION_ENUM_REMOVE);
+ ret = pk_action_enum_contains (text, PK_ACTION_ENUM_REMOVE);
if (ret == FALSE) {
libst_success (test, NULL);
} else {
diff --git a/libpackagekit/pk-task-utils.h b/libpackagekit/pk-task-utils.h
index f5d787f..d8021f0 100644
--- a/libpackagekit/pk-task-utils.h
+++ b/libpackagekit/pk-task-utils.h
@@ -117,32 +117,32 @@ typedef enum {
PK_ACTION_ENUM_UNKNOWN
} PkTaskAction;
-PkTaskExit pk_task_exit_from_text (const gchar *exit);
-const gchar *pk_task_exit_to_text (PkTaskExit exit);
+PkTaskExit pk_exit_enum_from_text (const gchar *exit);
+const gchar *pk_exit_enum_to_text (PkTaskExit exit);
-PkTaskStatus pk_task_status_from_text (const gchar *status);
-const gchar *pk_task_status_to_text (PkTaskStatus status);
+PkTaskStatus pk_status_enum_from_text (const gchar *status);
+const gchar *pk_status_enum_to_text (PkTaskStatus status);
-PkTaskRole pk_task_role_from_text (const gchar *role);
-const gchar *pk_task_role_to_text (PkTaskRole role);
+PkTaskRole pk_role_enum_from_text (const gchar *role);
+const gchar *pk_role_enum_to_text (PkTaskRole role);
-PkTaskErrorCode pk_task_error_code_from_text (const gchar *code);
-const gchar *pk_task_error_code_to_text (PkTaskErrorCode code);
+PkTaskErrorCode pk_error_enum_from_text (const gchar *code);
+const gchar *pk_error_enum_to_text (PkTaskErrorCode code);
-PkTaskRestart pk_task_restart_from_text (const gchar *restart);
-const gchar *pk_task_restart_to_text (PkTaskRestart restart);
+PkTaskRestart pk_restart_enum_from_text (const gchar *restart);
+const gchar *pk_restart_enum_to_text (PkTaskRestart restart);
-PkTaskGroup pk_task_group_from_text (const gchar *group);
-const gchar *pk_task_group_to_text (PkTaskGroup group);
+PkTaskGroup pk_group_enum_from_text (const gchar *group);
+const gchar *pk_group_enum_to_text (PkTaskGroup group);
-PkTaskAction pk_task_action_from_text (const gchar *action);
-const gchar *pk_task_action_to_text (PkTaskAction action);
+PkTaskAction pk_action_enum_from_text (const gchar *action);
+const gchar *pk_action_enum_to_text (PkTaskAction action);
gboolean pk_task_filter_check (const gchar *filter);
/* actions */
-gchar *pk_task_action_build (PkTaskAction action, ...);
-gboolean pk_task_action_contains (const gchar *actions,
+gchar *pk_action_enum_build (PkTaskAction action, ...);
+gboolean pk_action_enum_contains (const gchar *actions,
PkTaskAction action);
typedef GPtrArray PkActionList;
diff --git a/src/pk-backend.c b/src/pk-backend.c
index bde5aa7..7a455a0 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -207,7 +207,7 @@ pk_backend_parse_common_output (PkBacken
ret = FALSE;
goto out;
}
- group = pk_task_group_from_text (sections[2]);
+ group = pk_group_enum_from_text (sections[2]);
pk_backend_description (backend, sections[1], group, sections[3], sections[4]);
} else {
pk_warning ("invalid command '%s'", command);
@@ -268,7 +268,7 @@ pk_backend_parse_common_error (PkBackend
ret = FALSE;
goto out;
}
- error_enum = pk_task_error_code_from_text (sections[1]);
+ error_enum = pk_error_enum_from_text (sections[1]);
pk_backend_error_code (backend, error_enum, sections[2]);
} else if (strcmp (command, "requirerestart") == 0) {
if (size != 3) {
@@ -276,7 +276,7 @@ pk_backend_parse_common_error (PkBackend
ret = FALSE;
goto out;
}
- restart_enum = pk_task_restart_from_text (sections[1]);
+ restart_enum = pk_restart_enum_from_text (sections[1]);
pk_backend_require_restart (backend, restart_enum, sections[2]);
} else if (strcmp (command, "status") == 0) {
if (size != 2) {
@@ -284,7 +284,7 @@ pk_backend_parse_common_error (PkBackend
ret = FALSE;
goto out;
}
- status_enum = pk_task_status_from_text (sections[1]);
+ status_enum = pk_status_enum_from_text (sections[1]);
pk_backend_change_job_status (backend, status_enum);
} else if (strcmp (command, "allow-interrupt") == 0) {
if (size != 2) {
@@ -475,9 +475,9 @@ pk_backend_set_job_role (PkBackend *back
/* Should only be called once... */
if (backend->priv->role != PK_ROLE_ENUM_UNKNOWN) {
pk_error ("cannot set role more than once, already %s",
- pk_task_role_to_text (backend->priv->role));
+ pk_role_enum_to_text (backend->priv->role));
}
- pk_debug ("setting role to %s (string is '%s')", pk_task_role_to_text (role), package_id);
+ 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);
return TRUE;
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 2a48ae0..16ca474 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -258,7 +258,7 @@ pk_engine_job_status_changed_cb (PkTask
pk_warning ("could not find task");
return;
}
- status_text = pk_task_status_to_text (status);
+ status_text = pk_status_enum_to_text (status);
pk_debug ("emitting job-status-changed job:%i, '%s'", map->job, status_text);
g_signal_emit (engine, signals [PK_ENGINE_JOB_STATUS_CHANGED], 0, map->job, status_text);
@@ -366,7 +366,7 @@ pk_engine_error_code_cb (PkTask *task, P
pk_warning ("could not find task");
return;
}
- code_text = pk_task_error_code_to_text (code);
+ code_text = pk_error_enum_to_text (code);
pk_debug ("emitting error-code job:%i %s, '%s'", map->job, code_text, details);
g_signal_emit (engine, signals [PK_ENGINE_ERROR_CODE], 0, map->job, code_text, details);
pk_engine_reset_timer (engine);
@@ -389,7 +389,7 @@ pk_engine_require_restart_cb (PkTask *ta
pk_warning ("could not find task");
return;
}
- restart_text = pk_task_restart_to_text (restart);
+ restart_text = pk_restart_enum_to_text (restart);
pk_debug ("emitting error-code job:%i %s, '%s'", map->job, restart_text, details);
g_signal_emit (engine, signals [PK_ENGINE_REQUIRE_RESTART], 0, map->job, restart_text, details);
pk_engine_reset_timer (engine);
@@ -413,7 +413,7 @@ pk_engine_description_cb (PkTask *task,
pk_warning ("could not find task");
return;
}
- group_text = pk_task_group_to_text (group);
+ group_text = pk_group_enum_to_text (group);
pk_debug ("emitting description job:%i, %s, %s, %s, %s", map->job, package_id, group_text, detail, url);
g_signal_emit (engine, signals [PK_ENGINE_DESCRIPTION], 0, map->job, package_id, group_text, detail, url);
@@ -437,7 +437,7 @@ pk_engine_finished_cb (PkTask *task, PkT
pk_warning ("could not find task");
return;
}
- exit_text = pk_task_exit_to_text (exit);
+ exit_text = pk_exit_enum_to_text (exit);
/* find the length of time we have been running */
time = pk_backend_get_runtime (task);
@@ -1318,7 +1318,7 @@ pk_engine_get_job_status (PkEngine *engi
return FALSE;
}
pk_backend_get_job_status (map->task, &status_enum);
- *status = g_strdup (pk_task_status_to_text (status_enum));
+ *status = g_strdup (pk_status_enum_to_text (status_enum));
return TRUE;
}
@@ -1343,7 +1343,7 @@ pk_engine_get_job_role (PkEngine *engine
return FALSE;
}
pk_backend_get_job_role (map->task, &role_enum, package_id);
- *role = g_strdup (pk_task_role_to_text (role_enum));
+ *role = g_strdup (pk_role_enum_to_text (role_enum));
return TRUE;
}
diff-tree f886bdeae807e472d1fcfc76a6b80b8c64aaae67 (from 914cc04a2939531a63b31376b63be3f7bce83654)
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Sep 7 16:12:14 2007 +0100
remove the _TASK_ in the enumerated defines
diff --git a/TODO b/TODO
index 55ef718..a470b5d 100644
--- a/TODO
+++ b/TODO
@@ -13,7 +13,7 @@ Core:
* Add logging so we can see what was installed/removed and when
* Add "when installed" data into description
* Add "installed by 'Richard Hughes'" data into description
-* /var/db/PackageKit/$package_id/installed_by, when_installed
+* package_di,installed_by, when_installed into sqlite database
* Add GetUpdateDetail(s=package_id)
UpdateDetail(
string url
@@ -22,7 +22,13 @@ string updates
string obsoletes
string update_text
}
-* Remove the _TASK_ in the enums
+* Change _TASK_ to ENUM in the enums
+* Have to have an UpdatesChanged signal for the icon to update after we've done
+ a system upgrade
+* Have to load parameters from a conf file:
+ - autoshutdown-timeout
+ - default-backend
+ - logging-detail
Backends:
* Complete conary backend
diff --git a/backends/apt/pk-backend-apt.cpp b/backends/apt/pk-backend-apt.cpp
index 6bbf20d..ce45293 100644
--- a/backends/apt/pk-backend-apt.cpp
+++ b/backends/apt/pk-backend-apt.cpp
@@ -160,7 +160,7 @@ void *do_update_thread(gpointer data)
OpTextProgress Prog;
/* easy as that */
- pk_backend_change_job_status(ud->backend, PK_TASK_STATUS_REFRESH_CACHE);
+ pk_backend_change_job_status(ud->backend, PK_STATUS_ENUM_REFRESH_CACHE);
Cache = getCache();
@@ -168,8 +168,8 @@ void *do_update_thread(gpointer data)
pkgSourceList List;
if (List.ReadMainList() == false)
{
- pk_backend_error_code(ud->backend, PK_TASK_ERROR_CODE_UNKNOWN, "Failure reading lists");
- pk_backend_finished(ud->backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code(ud->backend, PK_ERROR_ENUM_UNKNOWN, "Failure reading lists");
+ pk_backend_finished(ud->backend, PK_EXIT_ENUM_FAILED);
return NULL;
}
@@ -181,8 +181,8 @@ void *do_update_thread(gpointer data)
if (_error->PendingError() == true)
{
_error->DumpErrors();
- pk_backend_error_code(ud->backend, PK_TASK_ERROR_CODE_UNKNOWN, "Unable to lock the list directory");
- pk_backend_finished(ud->backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code(ud->backend, PK_ERROR_ENUM_UNKNOWN, "Unable to lock the list directory");
+ pk_backend_finished(ud->backend, PK_EXIT_ENUM_FAILED);
return NULL;
}
}
@@ -194,14 +194,14 @@ void *do_update_thread(gpointer data)
// Populate it with the source selection
if (List.GetIndexes(&Fetcher) == false)
{
- pk_backend_error_code(ud->backend, PK_TASK_ERROR_CODE_UNKNOWN, "Failed to populate the source selection");
+ pk_backend_error_code(ud->backend, PK_ERROR_ENUM_UNKNOWN, "Failed to populate the source selection");
goto do_update_clean;
}
// Run it
if (Fetcher.Run() == pkgAcquire::Failed)
{
- pk_backend_error_code(ud->backend, PK_TASK_ERROR_CODE_UNKNOWN, "Failed to run the fetcher");
+ pk_backend_error_code(ud->backend, PK_ERROR_ENUM_UNKNOWN, "Failed to run the fetcher");
goto do_update_clean;
}
@@ -229,7 +229,7 @@ void *do_update_thread(gpointer data)
if (Fetcher.Clean(_config->FindDir("Dir::State::lists")) == false ||
Fetcher.Clean(_config->FindDir("Dir::State::lists") + "partial/") == false)
{
- pk_backend_error_code(ud->backend, PK_TASK_ERROR_CODE_UNKNOWN, "Failed to clean out any old list files");
+ pk_backend_error_code(ud->backend, PK_ERROR_ENUM_UNKNOWN, "Failed to clean out any old list files");
goto do_update_clean;
}
}
@@ -238,7 +238,7 @@ void *do_update_thread(gpointer data)
Cache = getCache();
if (Cache->BuildCaches(Prog,false) == false)
{
- pk_backend_error_code(ud->backend, PK_TASK_ERROR_CODE_UNKNOWN, "Failed to prepare the cache");
+ pk_backend_error_code(ud->backend, PK_ERROR_ENUM_UNKNOWN, "Failed to prepare the cache");
goto do_update_clean;
}
@@ -246,17 +246,17 @@ void *do_update_thread(gpointer data)
pk_debug("Some index files failed to download, they have been ignored, or old ones used instead.");
else if (Failed == true)
{
- pk_backend_error_code(ud->backend, PK_TASK_ERROR_CODE_UNKNOWN, "Generic Error");
+ pk_backend_error_code(ud->backend, PK_ERROR_ENUM_UNKNOWN, "Generic Error");
goto do_update_clean;
}
delete Stat;
- pk_backend_finished(ud->backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished(ud->backend, PK_EXIT_ENUM_SUCCESS);
return NULL;
do_update_clean:
delete Stat;
- pk_backend_finished(ud->backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished(ud->backend, PK_EXIT_ENUM_FAILED);
return NULL;
}
@@ -268,24 +268,24 @@ static void backend_refresh_cache(PkBack
/* check network state */
if (pk_backend_network_is_online(backend) == FALSE)
{
- pk_backend_error_code(backend, PK_TASK_ERROR_CODE_NO_NETWORK, "Cannot refresh cache whilst offline");
- pk_backend_finished(backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code(backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
+ pk_backend_finished(backend, PK_EXIT_ENUM_FAILED);
return;
}
UpdateData *data = g_new(UpdateData, 1);
if (data == NULL)
{
- pk_backend_error_code(backend, PK_TASK_ERROR_CODE_OOM, "Failed to allocate memory for update task");
- pk_backend_finished(backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory for update task");
+ pk_backend_finished(backend, PK_EXIT_ENUM_FAILED);
}
else
{
data->backend = backend;
if (g_thread_create(do_update_thread, data, false, NULL) == NULL)
{
- pk_backend_error_code(backend, PK_TASK_ERROR_CODE_CREATE_THREAD_FAILED, "Failed to create update thread");
- pk_backend_finished(backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code(backend, PK_ERROR_ENUM_CREATE_THREAD_FAILED, "Failed to create update thread");
+ pk_backend_finished(backend, PK_EXIT_ENUM_FAILED);
}
}
}
@@ -358,7 +358,7 @@ static void *get_search_thread(gpointer
search_task *st = (search_task *) data;
ExDescFile *DFList = NULL;
- pk_backend_change_job_status(st->backend, PK_TASK_STATUS_QUERY);
+ pk_backend_change_job_status(st->backend, PK_STATUS_ENUM_QUERY);
pk_backend_no_percentage_updates(st->backend);
pk_debug("finding %s", st->search);
@@ -372,8 +372,8 @@ static void *get_search_thread(gpointer
memset(Pattern, 0, sizeof(*Pattern));
if (regcomp(Pattern, st->search, REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
{
- pk_backend_error_code(st->backend, PK_TASK_ERROR_CODE_UNKNOWN, "regex compilation error");
- pk_backend_finished(st->backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code(st->backend, PK_ERROR_ENUM_UNKNOWN, "regex compilation error");
+ pk_backend_finished(st->backend, PK_EXIT_ENUM_FAILED);
goto search_task_cleanup;
}
@@ -441,7 +441,7 @@ static void *get_search_thread(gpointer
}
}
- pk_backend_finished(st->backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished(st->backend, PK_EXIT_ENUM_SUCCESS);
search_task_cleanup:
for (ExDescFile * J = DFList; J->Df != 0; J++)
@@ -465,8 +465,8 @@ pk_backend_search(PkBackend * backend, c
search_task *data = g_new(struct search_task, 1);
if (data == NULL)
{
- pk_backend_error_code(backend, PK_TASK_ERROR_CODE_OOM, "Failed to allocate memory for search task");
- pk_backend_finished(backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory for search task");
+ pk_backend_finished(backend, PK_EXIT_ENUM_FAILED);
}
else
{
@@ -477,8 +477,8 @@ pk_backend_search(PkBackend * backend, c
if (g_thread_create(get_search_thread, data, false, NULL) == NULL)
{
- pk_backend_error_code(backend, PK_TASK_ERROR_CODE_UNKNOWN, "Failed to spawn thread");
- pk_backend_finished(backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code(backend, PK_ERROR_ENUM_UNKNOWN, "Failed to spawn thread");
+ pk_backend_finished(backend, PK_EXIT_ENUM_FAILED);
}
}
return TRUE;
@@ -549,7 +549,7 @@ static void *get_description_thread(gpoi
{
desc_task *dt = (desc_task *) data;
- pk_backend_change_job_status(dt->backend, PK_TASK_STATUS_QUERY);
+ pk_backend_change_job_status(dt->backend, PK_STATUS_ENUM_QUERY);
pk_backend_no_percentage_updates(dt->backend);
pk_debug("finding %s", dt->pi->name);
@@ -566,10 +566,10 @@ static void *get_description_thread(gpoi
pkgCache::VerIterator V = Plcy.GetCandidateVer(P);
GHashTable *pkg = PackageRecord(V);
pk_backend_description(dt->backend,dt->pi->name,
- PK_TASK_GROUP_OTHER,(const gchar*)g_hash_table_lookup(pkg,"Description"),"");
+ PK_GROUP_ENUM_OTHER,(const gchar*)g_hash_table_lookup(pkg,"Description"),"");
g_hash_table_unref(pkg);
}
- pk_backend_finished(dt->backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished(dt->backend, PK_EXIT_ENUM_SUCCESS);
return NULL;
}
@@ -583,8 +583,8 @@ backend_get_description (PkBackend *back
desc_task *data = g_new(struct desc_task, 1);
if (data == NULL)
{
- pk_backend_error_code(backend, PK_TASK_ERROR_CODE_OOM, "Failed to allocate memory for search task");
- pk_backend_finished(backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory for search task");
+ pk_backend_finished(backend, PK_EXIT_ENUM_FAILED);
return;
}
@@ -592,15 +592,15 @@ backend_get_description (PkBackend *back
data->pi = pk_package_id_new_from_string(package_id);
if (data->pi == NULL)
{
- pk_backend_error_code(backend, PK_TASK_ERROR_CODE_PACKAGE_ID_INVALID, "invalid package id");
- pk_backend_finished(backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code(backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package 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_TASK_ERROR_CODE_CREATE_THREAD_FAILED, "Failed to spawn description thread");
- pk_backend_finished(backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code(backend, PK_ERROR_ENUM_CREATE_THREAD_FAILED, "Failed to spawn description thread");
+ pk_backend_finished(backend, PK_EXIT_ENUM_FAILED);
}
return;
}
diff --git a/backends/apt/pk-task-apt.cpp.delete.me b/backends/apt/pk-task-apt.cpp.delete.me
index 28946d5..f74cbef 100644
--- a/backends/apt/pk-task-apt.cpp.delete.me
+++ b/backends/apt/pk-task-apt.cpp.delete.me
@@ -108,11 +108,11 @@ gchar *
pk_task_get_actions (void)
{
gchar *actions;
- actions = pk_task_action_build (PK_TASK_ACTION_REFRESH_CACHE,
- PK_TASK_ACTION_UPDATE_SYSTEM,
- PK_TASK_ACTION_SEARCH_NAME,
- PK_TASK_ACTION_SEARCH_DETAILS,
- PK_TASK_ACTION_GET_DESCRIPTION,
+ actions = pk_task_action_build (PK_ACTION_ENUM_REFRESH_CACHE,
+ PK_ACTION_ENUM_UPDATE_SYSTEM,
+ PK_ACTION_ENUM_SEARCH_NAME,
+ PK_ACTION_ENUM_SEARCH_DETAILS,
+ PK_ACTION_ENUM_GET_DESCRIPTION,
0);
return actions;
}
@@ -182,7 +182,7 @@ void *DoUpdate(gpointer data)
OpTextProgress Prog;
/* easy as that */
- pk_task_change_job_status(ud->task, PK_TASK_STATUS_REFRESH_CACHE);
+ pk_task_change_job_status(ud->task, PK_STATUS_ENUM_REFRESH_CACHE);
Cache = getCache();
@@ -190,8 +190,8 @@ void *DoUpdate(gpointer data)
pkgSourceList List;
if (List.ReadMainList() == false)
{
- pk_task_error_code(ud->task, PK_TASK_ERROR_CODE_UNKNOWN, "Failure reading lists");
- pk_task_finished(ud->task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(ud->task, PK_ERROR_ENUM_UNKNOWN, "Failure reading lists");
+ pk_task_finished(ud->task, PK_EXIT_ENUM_FAILED);
return NULL;
}
@@ -203,8 +203,8 @@ void *DoUpdate(gpointer data)
if (_error->PendingError() == true)
{
_error->DumpErrors();
- pk_task_error_code(ud->task, PK_TASK_ERROR_CODE_UNKNOWN, "Unable to lock the list directory");
- pk_task_finished(ud->task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(ud->task, PK_ERROR_ENUM_UNKNOWN, "Unable to lock the list directory");
+ pk_task_finished(ud->task, PK_EXIT_ENUM_FAILED);
return NULL;
}
}
@@ -216,14 +216,14 @@ void *DoUpdate(gpointer data)
// Populate it with the source selection
if (List.GetIndexes(&Fetcher) == false)
{
- pk_task_error_code(ud->task, PK_TASK_ERROR_CODE_UNKNOWN, "Generic Error");
+ pk_task_error_code(ud->task, PK_ERROR_ENUM_UNKNOWN, "Generic Error");
goto do_update_clean;
}
// Run it
if (Fetcher.Run() == pkgAcquire::Failed)
{
- pk_task_error_code(ud->task, PK_TASK_ERROR_CODE_UNKNOWN, "Generic Error");
+ pk_task_error_code(ud->task, PK_ERROR_ENUM_UNKNOWN, "Generic Error");
goto do_update_clean;
}
@@ -250,7 +250,7 @@ void *DoUpdate(gpointer data)
{
if (Fetcher.Clean(_config->FindDir("Dir::State::lists")) == false || Fetcher.Clean(_config->FindDir("Dir::State::lists") + "partial/") == false)
{
- pk_task_error_code(ud->task, PK_TASK_ERROR_CODE_UNKNOWN, "Generic Error");
+ pk_task_error_code(ud->task, PK_ERROR_ENUM_UNKNOWN, "Generic Error");
goto do_update_clean;
}
}
@@ -259,7 +259,7 @@ void *DoUpdate(gpointer data)
Cache = getCache();
if (Cache->BuildCaches(Prog,false) == false)
{
- pk_task_error_code(ud->task, PK_TASK_ERROR_CODE_UNKNOWN, "Generic Error");
+ pk_task_error_code(ud->task, PK_ERROR_ENUM_UNKNOWN, "Generic Error");
goto do_update_clean;
}
@@ -267,17 +267,17 @@ void *DoUpdate(gpointer data)
pk_debug("Some index files failed to download, they have been ignored, or old ones used instead.");
else if (Failed == true)
{
- pk_task_error_code(ud->task, PK_TASK_ERROR_CODE_UNKNOWN, "Generic Error");
+ pk_task_error_code(ud->task, PK_ERROR_ENUM_UNKNOWN, "Generic Error");
goto do_update_clean;
}
delete Stat;
- pk_task_finished(ud->task, PK_TASK_EXIT_SUCCESS);
+ pk_task_finished(ud->task, PK_EXIT_ENUM_SUCCESS);
return NULL;
do_update_clean:
delete Stat;
- pk_task_finished(ud->task, PK_TASK_EXIT_FAILED);
+ pk_task_finished(ud->task, PK_EXIT_ENUM_FAILED);
return NULL;
}
@@ -297,24 +297,24 @@ gboolean pk_task_refresh_cache(PkTask *
/* check network state */
if (pk_network_is_online(task->priv->network) == FALSE)
{
- pk_task_error_code(task, PK_TASK_ERROR_CODE_NO_NETWORK, "Cannot refresh cache whilst offline");
- pk_task_finished(task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(task, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
+ pk_task_finished(task, PK_EXIT_ENUM_FAILED);
return TRUE;
}
UpdateData *data = g_new(UpdateData, 1);
if (data == NULL)
{
- pk_task_error_code(task, PK_TASK_ERROR_CODE_UNKNOWN, "can't allocate memory for update task");
- pk_task_finished(task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(task, PK_ERROR_ENUM_UNKNOWN, "can't allocate memory for update task");
+ pk_task_finished(task, PK_EXIT_ENUM_FAILED);
}
else
{
data->task = task;
if (g_thread_create(DoUpdate,data, false, NULL) == NULL)
{
- pk_task_error_code(task, PK_TASK_ERROR_CODE_UNKNOWN, "can't spawn update thread");
- pk_task_finished(task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(task, PK_ERROR_ENUM_UNKNOWN, "can't spawn update thread");
+ pk_task_finished(task, PK_EXIT_ENUM_FAILED);
}
}
return TRUE;
@@ -434,7 +434,7 @@ static void *do_search_task(gpointer dat
search_task *st = (search_task *) data;
ExDescFile *DFList = NULL;
- pk_task_change_job_status(st->task, PK_TASK_STATUS_QUERY);
+ pk_task_change_job_status(st->task, PK_STATUS_ENUM_QUERY);
pk_task_no_percentage_updates(st->task);
pk_debug("finding %s", st->search);
@@ -448,8 +448,8 @@ static void *do_search_task(gpointer dat
memset(Pattern, 0, sizeof(*Pattern));
if (regcomp(Pattern, st->search, REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
{
- pk_task_error_code(st->task, PK_TASK_ERROR_CODE_UNKNOWN, "regex compilation error");
- pk_task_finished(st->task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(st->task, PK_ERROR_ENUM_UNKNOWN, "regex compilation error");
+ pk_task_finished(st->task, PK_EXIT_ENUM_FAILED);
goto search_task_cleanup;
}
@@ -517,7 +517,7 @@ static void *do_search_task(gpointer dat
}
}
- pk_task_finished(st->task, PK_TASK_EXIT_SUCCESS);
+ pk_task_finished(st->task, PK_EXIT_ENUM_SUCCESS);
search_task_cleanup:
for (ExDescFile * J = DFList; J->Df != 0; J++)
@@ -548,16 +548,16 @@ pk_task_search(PkTask * task, const gcha
if (pk_task_filter_check(filter) == FALSE)
{
- pk_task_error_code(task, PK_TASK_ERROR_CODE_FILTER_INVALID, "filter '%s' not valid", filter);
- pk_task_finished(task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(task, PK_ERROR_ENUM_FILTER_INVALID, "filter '%s' not valid", filter);
+ pk_task_finished(task, PK_EXIT_ENUM_FAILED);
return TRUE;
}
search_task *data = g_new(struct search_task, 1);
if (data == NULL)
{
- pk_task_error_code(task, PK_TASK_ERROR_CODE_UNKNOWN, "can't allocate memory for search task");
- pk_task_finished(task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(task, PK_ERROR_ENUM_UNKNOWN, "can't allocate memory for search task");
+ pk_task_finished(task, PK_EXIT_ENUM_FAILED);
}
else
{
@@ -568,8 +568,8 @@ pk_task_search(PkTask * task, const gcha
if (g_thread_create(do_search_task, data, false, NULL) == NULL)
{
- pk_task_error_code(task, PK_TASK_ERROR_CODE_UNKNOWN, "can't spawn thread");
- pk_task_finished(task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(task, PK_ERROR_ENUM_UNKNOWN, "can't spawn thread");
+ pk_task_finished(task, PK_EXIT_ENUM_FAILED);
}
}
return TRUE;
@@ -610,10 +610,10 @@ void *do_search_file(gpointer data)
GDir *list = g_dir_open(ldir,0,&error);
if (error!=NULL)
{
- pk_task_error_code(st->task, PK_TASK_ERROR_CODE_INTERNAL_ERROR, "can't open %s",ldir);
+ pk_task_error_code(st->task, PK_ERROR_ENUM_INTERNAL_ERROR, "can't open %s",ldir);
g_free(ldir);
g_error_free(error);
- pk_task_finished(st->task, PK_TASK_EXIT_FAILED);
+ pk_task_finished(st->task, PK_EXIT_ENUM_FAILED);
return NULL;
}
const gchar * fname = NULL;
@@ -621,11 +621,11 @@ void *do_search_file(gpointer data)
{
//pk_task_package(st->task, J->installed, pid, P.ShortDesc().c_str());
}
- pk_task_error_code(st->task, PK_TASK_ERROR_CODE_INTERNAL_ERROR, "search file is incomplete");
- pk_task_finished(st->task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(st->task, PK_ERROR_ENUM_INTERNAL_ERROR, "search file is incomplete");
+ pk_task_finished(st->task, PK_EXIT_ENUM_FAILED);
g_dir_close(ldir);
g_free(ldir);
- //pk_task_finished(st->task, PK_TASK_EXIT_SUCCESS);
+ //pk_task_finished(st->task, PK_EXIT_ENUM_SUCCESS);
return NULL;
}
@@ -637,8 +637,8 @@ gboolean pk_task_search_file(PkTask * ta
search_task *data = g_new(struct search_task, 1);
if (data == NULL)
{
- pk_task_error_code(task, PK_TASK_ERROR_CODE_UNKNOWN, "can't allocate memory for search task");
- pk_task_finished(task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(task, PK_ERROR_ENUM_UNKNOWN, "can't allocate memory for search task");
+ pk_task_finished(task, PK_EXIT_ENUM_FAILED);
}
else
{
@@ -649,8 +649,8 @@ gboolean pk_task_search_file(PkTask * ta
if (g_thread_create(do_search_file, data, false, NULL) == NULL)
{
- pk_task_error_code(task, PK_TASK_ERROR_CODE_INTERNAL_ERROR, "can't spawn thread");
- pk_task_finished(task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(task, PK_ERROR_ENUM_INTERNAL_ERROR, "can't spawn thread");
+ pk_task_finished(task, PK_EXIT_ENUM_FAILED);
}
}
return TRUE;
@@ -760,7 +760,7 @@ static void *get_desc_task(gpointer data
{
desc_task *dt = (desc_task *) data;
- pk_task_change_job_status(dt->task, PK_TASK_STATUS_QUERY);
+ pk_task_change_job_status(dt->task, PK_STATUS_ENUM_QUERY);
pk_task_no_percentage_updates(dt->task);
pk_debug("finding %s", dt->pi->name);
@@ -776,10 +776,10 @@ static void *get_desc_task(gpointer data
// Find the proper version to use.
pkgCache::VerIterator V = Plcy.GetCandidateVer(P);
GHashTable *pkg = PackageRecord(V);
- pk_task_description(dt->task,dt->pi->name,PK_TASK_GROUP_OTHER,(const gchar*)g_hash_table_lookup(pkg,"Description"),"");
+ pk_task_description(dt->task,dt->pi->name,PK_GROUP_ENUM_OTHER,(const gchar*)g_hash_table_lookup(pkg,"Description"),"");
g_hash_table_unref(pkg);
}
- pk_task_finished(dt->task, PK_TASK_EXIT_SUCCESS);
+ pk_task_finished(dt->task, PK_EXIT_ENUM_SUCCESS);
return NULL;
}
@@ -799,8 +799,8 @@ gboolean pk_task_get_description(PkTask
desc_task *data = g_new(struct desc_task, 1);
if (data == NULL)
{
- pk_task_error_code(task, PK_TASK_ERROR_CODE_INTERNAL_ERROR, "can't allocate memory for search task");
- pk_task_finished(task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(task, PK_ERROR_ENUM_INTERNAL_ERROR, "can't allocate memory for search task");
+ pk_task_finished(task, PK_EXIT_ENUM_FAILED);
return TRUE;
}
@@ -808,15 +808,15 @@ gboolean pk_task_get_description(PkTask
data->pi = pk_package_id_new_from_string(package);
if (data->pi == NULL)
{
- pk_task_error_code(task, PK_TASK_ERROR_CODE_PACKAGE_ID_INVALID, "invalid package id");
- pk_task_finished(task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(task, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
+ pk_task_finished(task, PK_EXIT_ENUM_FAILED);
return TRUE;
}
if (g_thread_create(get_desc_task, data, false, NULL) == NULL)
{
- pk_task_error_code(task, PK_TASK_ERROR_CODE_INTERNAL_ERROR, "can't spawn thread");
- pk_task_finished(task, PK_TASK_EXIT_FAILED);
+ pk_task_error_code(task, PK_ERROR_ENUM_INTERNAL_ERROR, "can't spawn thread");
+ pk_task_finished(task, PK_EXIT_ENUM_FAILED);
}
return TRUE;
}
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 62367d3..2ba311f 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -111,7 +111,7 @@ find_packages (PkBackend *backend, const
gboolean gui;
gboolean text;
- pk_backend_change_job_status (backend, PK_TASK_ROLE_QUERY);
+ pk_backend_change_job_status (backend, PK_ROLE_ENUM_QUERY);
parse_filter (filter, &installed, &available, &devel, &nondevel, &gui, &text);
if (devel == TRUE) {
@@ -121,7 +121,7 @@ find_packages (PkBackend *backend, const
devel_filter = devel_filter | PKG_NON_DEVEL;
}
- pk_backend_change_job_status (backend, PK_TASK_STATUS_QUERY);
+ pk_backend_change_job_status (backend, PK_STATUS_ENUM_QUERY);
pk_backend_no_percentage_updates (backend);
db = box_db_open ("/");
@@ -134,12 +134,12 @@ find_packages (PkBackend *backend, const
list = box_db_repos_search_file (db, search);
add_packages_from_list (backend, list);
box_db_repos_package_list_free (list);
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
} else {
if (installed == FALSE && available == FALSE) {
- pk_backend_error_code (backend, PK_TASK_ERROR_CODE_UNKNOWN, "invalid search mode");
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code (backend, PK_ERROR_ENUM_UNKNOWN, "invalid search mode");
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
} else {
/* TODO: make it more async */
if (installed == TRUE && available == TRUE) {
@@ -151,7 +151,7 @@ find_packages (PkBackend *backend, const
}
add_packages_from_list (backend, list);
box_db_repos_package_list_free (list);
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
}
}
@@ -196,27 +196,27 @@ backend_get_description (PkBackend *back
pi = pk_package_id_new_from_string (package_id);
if (pi == NULL) {
- pk_backend_error_code (backend, PK_TASK_ERROR_CODE_PACKAGE_ID_INVALID, "invalid package id");
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
return;
}
list = find_package_by_id (pi);
ps = (PackageSearch*) list->data;
if (list == NULL) {
- pk_backend_error_code (backend, PK_TASK_ERROR_CODE_PACKAGE_ID_INVALID, "cannot find package by id");
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ 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;
}
- pk_backend_change_job_status (backend, PK_TASK_ROLE_QUERY);
- pk_backend_description (backend, pi->name, PK_TASK_GROUP_OTHER, ps->description, "");
+ 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);
box_db_repos_package_list_free (list);
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
return;
}
@@ -231,7 +231,7 @@ backend_get_updates (PkBackend *backend)
g_return_if_fail (backend != NULL);
- pk_backend_change_job_status (backend, PK_TASK_STATUS_QUERY);
+ pk_backend_change_job_status (backend, PK_STATUS_ENUM_QUERY);
db = box_db_open ("/");
box_db_attach_repo (db, "/", "core");
@@ -242,7 +242,7 @@ backend_get_updates (PkBackend *backend)
add_packages_from_list (backend, list);
box_db_repos_package_list_free (list);
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
box_db_detach_repo (db, "core");
box_db_close (db);
@@ -257,11 +257,11 @@ backend_refresh_cache (PkBackend *backen
g_return_if_fail (backend != NULL);
/* check network state */
if (pk_backend_network_is_online (backend) == FALSE) {
- pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NO_NETWORK, "Cannot refresh cache whilst offline");
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
return;
}
- pk_backend_change_job_status (backend, PK_TASK_ROLE_REFRESH_CACHE);
+ pk_backend_change_job_status (backend, PK_ROLE_ENUM_REFRESH_CACHE);
pk_backend_spawn_helper (backend, "refresh-cache.sh", NULL);
}
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index c379181..f1bac73 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -55,8 +55,8 @@ backend_install_package (PkBackend *back
g_return_if_fail (backend != NULL);
/* check network state */
if (pk_backend_network_is_online (backend) == FALSE) {
- pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NO_NETWORK, "Cannot install when offline");
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot install when offline");
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
return;
}
pk_backend_spawn_helper (backend, "install.py", package_id, NULL);
@@ -71,8 +71,8 @@ backend_refresh_cache (PkBackend *backen
g_return_if_fail (backend != NULL);
/* check network state */
if (pk_backend_network_is_online (backend) == FALSE) {
- pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NO_NETWORK, "Cannot refresh cache whilst offline");
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
return;
}
pk_backend_spawn_helper (backend, "refresh-cache.py", NULL);
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index 3d9fd91..007567f 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -65,7 +65,7 @@ backend_get_depends (PkBackend *backend,
"The GLib library");
pk_backend_package (backend, 1, "gtk2;gtk2-2.11.6-6.fc8;i386;fedora",
"GTK+ Libraries for GIMP");
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
}
/**
@@ -75,7 +75,7 @@ static void
backend_get_description (PkBackend *backend, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
- pk_backend_description (backend, "gnome-power-manager;2.6.19;i386;fedora", PK_TASK_GROUP_PROGRAMMING,
+ pk_backend_description (backend, "gnome-power-manager;2.6.19;i386;fedora", PK_GROUP_ENUM_PROGRAMMING,
"Scribus is an desktop open source page layout program with "
"the aim of producing commercial grade output in PDF and "
"Postscript, primarily, though not exclusively for Linux.\n"
@@ -84,7 +84,7 @@ backend_get_description (PkBackend *back
"understand tools, Scribus offers support for professional publishing "
"features, such as CMYK color, easy PDF creation, Encapsulated Postscript "
"import/export and creation of color separations.", "http://live.gnome.org/GnomePowerManager");
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
}
/**
@@ -98,7 +98,7 @@ backend_get_requires (PkBackend *backend
"The GLib library");
pk_backend_package (backend, 1, "gtk2;gtk2-2.11.6-6.fc8;i386;fedora",
"GTK+ Libraries for GIMP");
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
}
/**
@@ -113,7 +113,7 @@ backend_get_updates (PkBackend *backend)
pk_backend_package (backend, 1, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
"The Linux kernel (the core of the Linux operating system)");
pk_backend_package (backend, 1, "gtkhtml2;2.19.1-4.fc8;i386;fedora", "An HTML widget for GTK+ 2.0");
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
}
static gboolean
@@ -121,11 +121,11 @@ backend_install_timeout (gpointer data)
{
PkBackend *backend = (PkBackend *) data;
if (progress_percentage == 100) {
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
return FALSE;
}
if (progress_percentage == 50) {
- pk_backend_change_job_status (backend, PK_TASK_STATUS_INSTALL);
+ pk_backend_change_job_status (backend, PK_STATUS_ENUM_INSTALL);
}
progress_percentage += 10;
pk_backend_change_percentage (backend, progress_percentage);
@@ -150,7 +150,7 @@ static void
backend_refresh_cache (PkBackend *backend, gboolean force)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
}
/**
@@ -160,8 +160,8 @@ static void
backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean allow_deps)
{
g_return_if_fail (backend != NULL);
- pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NO_NETWORK, "No network connection available");
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "No network connection available");
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -173,7 +173,7 @@ backend_search_details (PkBackend *backe
g_return_if_fail (backend != NULL);
pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
"The vips documentation package.");
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
}
/**
@@ -185,7 +185,7 @@ backend_search_file (PkBackend *backend,
g_return_if_fail (backend != NULL);
pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
"The vips documentation package.");
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
}
/**
@@ -197,7 +197,7 @@ backend_search_group (PkBackend *backend
g_return_if_fail (backend != NULL);
pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
"The vips documentation package.");
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
}
/**
@@ -215,7 +215,7 @@ backend_search_name_timeout (gpointer da
"Scribus is an desktop open source page layout program");
pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
"The vips documentation package.");
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
return FALSE;
}
@@ -238,7 +238,7 @@ backend_update_package (PkBackend *backe
{
g_return_if_fail (backend != NULL);
pk_backend_package (backend, 1, package_id, "The same thing");
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
}
static gboolean
@@ -246,10 +246,10 @@ backend_update_system_timeout (gpointer
{
PkBackend *backend = (PkBackend *) data;
if (progress_percentage == 100) {
- pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+ pk_backend_finished (backend, PK_EXIT_ENUM_SUCCESS);
return FALSE;
}
- pk_backend_change_job_status (backend, PK_TASK_STATUS_UPDATE);
+ pk_backend_change_job_status (backend, PK_STATUS_ENUM_UPDATE);
progress_percentage += 10;
pk_backend_change_percentage (backend, progress_percentage);
return TRUE;
@@ -262,9 +262,9 @@ static void
backend_update_system (PkBackend *backend)
{
g_return_if_fail (backend != NULL);
- pk_backend_change_job_status (backend, PK_TASK_STATUS_DOWNLOAD);
+ pk_backend_change_job_status (backend, PK_STATUS_ENUM_DOWNLOAD);
progress_percentage = 0;
- pk_backend_require_restart (backend, PK_TASK_RESTART_SYSTEM, NULL);
+ pk_backend_require_restart (backend, PK_RESTART_ENUM_SYSTEM, NULL);
g_timeout_add (1000, backend_update_system_timeout, backend);
}
diff --git a/backends/test/pk-backend-test.c b/backends/test/pk-backend-test.c
index 1e67d2f..c7c1698 100644
--- a/backends/test/pk-backend-test.c
+++ b/backends/test/pk-backend-test.c
@@ -49,7 +49,7 @@ static void
backend_cancel_job_try (PkBackend *backend)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -59,7 +59,7 @@ static void
backend_get_depends (PkBackend *backend, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -69,7 +69,7 @@ static void
backend_get_description (PkBackend *backend, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -79,7 +79,7 @@ static void
backend_get_requires (PkBackend *backend, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -89,7 +89,7 @@ static void
backend_get_updates (PkBackend *backend)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -99,7 +99,7 @@ static void
backend_install_package (PkBackend *backend, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -109,7 +109,7 @@ static void
backend_refresh_cache (PkBackend *backend, gboolean force)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -119,7 +119,7 @@ static void
backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean allow_deps)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -129,7 +129,7 @@ static void
backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -139,7 +139,7 @@ static void
backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -149,7 +149,7 @@ static void
backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -159,7 +159,7 @@ static void
backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -169,7 +169,7 @@ static void
backend_update_package (PkBackend *backend, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
/**
@@ -179,7 +179,7 @@ static void
backend_update_system (PkBackend *backend)
{
g_return_if_fail (backend != NULL);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
PK_BACKEND_OPTIONS (
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 7e95a31..8a97a30 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -87,8 +87,8 @@ backend_install_package (PkBackend *back
g_return_if_fail (backend != NULL);
/* check network state */
if (pk_backend_network_is_online (backend) == FALSE) {
- pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NO_NETWORK, "Cannot install when offline");
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot install when offline");
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
return;
}
pk_backend_spawn_helper (backend, "install.py", package_id, NULL);
@@ -103,8 +103,8 @@ backend_refresh_cache (PkBackend *backen
g_return_if_fail (backend != NULL);
/* check network state */
if (pk_backend_network_is_online (backend) == FALSE) {
- pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NO_NETWORK, "Cannot refresh cache whilst offline");
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
return;
}
pk_backend_spawn_helper (backend, "refresh-cache.py", NULL);
@@ -169,8 +169,8 @@ backend_update_package (PkBackend *backe
g_return_if_fail (backend != NULL);
/* check network state */
if (pk_backend_network_is_online (backend) == FALSE) {
- pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NO_NETWORK, "Cannot update when offline");
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot update when offline");
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
return;
}
pk_backend_spawn_helper (backend, "update.py", package_id, NULL);
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
index 21e5f8a..4759361 100644
--- a/libpackagekit/pk-task-client.c
+++ b/libpackagekit/pk-task-client.c
@@ -205,7 +205,7 @@ pk_task_client_reset (PkTaskClient *tcli
tclient->priv->is_sync = FALSE;
tclient->priv->use_buffer = FALSE;
tclient->priv->job = 0;
- tclient->priv->last_status = PK_TASK_STATUS_UNKNOWN;
+ tclient->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
tclient->priv->is_finished = FALSE;
pk_task_client_remove_package_items (tclient);
return TRUE;
@@ -1142,8 +1142,8 @@ pk_task_client_init (PkTaskClient *tclie
tclient->priv->is_sync = FALSE;
tclient->priv->use_buffer = FALSE;
tclient->priv->job = 0;
- tclient->priv->last_status = PK_TASK_STATUS_UNKNOWN;
- tclient->priv->require_restart = PK_TASK_RESTART_NONE;
+ tclient->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
+ tclient->priv->require_restart = PK_RESTART_ENUM_NONE;
tclient->priv->is_finished = FALSE;
tclient->priv->package_items = g_ptr_array_new ();
diff --git a/libpackagekit/pk-task-utils.c b/libpackagekit/pk-task-utils.c
index efddcfc..76c721f 100644
--- a/libpackagekit/pk-task-utils.c
+++ b/libpackagekit/pk-task-utils.c
@@ -36,91 +36,91 @@ typedef struct {
} PkTaskEnumMatch;
static PkTaskEnumMatch task_exit[] = {
- {PK_TASK_EXIT_UNKNOWN, "unknown"}, /* fall though value */
- {PK_TASK_EXIT_SUCCESS, "success"},
- {PK_TASK_EXIT_FAILED, "failed"},
- {PK_TASK_EXIT_CANCELED, "canceled"},
+ {PK_EXIT_ENUM_UNKNOWN, "unknown"}, /* fall though value */
+ {PK_EXIT_ENUM_SUCCESS, "success"},
+ {PK_EXIT_ENUM_FAILED, "failed"},
+ {PK_EXIT_ENUM_CANCELED, "canceled"},
{0, NULL},
};
static PkTaskEnumMatch task_status[] = {
- {PK_TASK_STATUS_UNKNOWN, "unknown"}, /* fall though value */
- {PK_TASK_STATUS_SETUP, "setup"},
- {PK_TASK_STATUS_QUERY, "query"},
- {PK_TASK_STATUS_REFRESH_CACHE, "refresh-cache"},
- {PK_TASK_STATUS_REMOVE, "remove"},
- {PK_TASK_STATUS_DOWNLOAD, "download"},
- {PK_TASK_STATUS_INSTALL, "install"},
- {PK_TASK_STATUS_UPDATE, "update"},
+ {PK_STATUS_ENUM_UNKNOWN, "unknown"}, /* fall though value */
+ {PK_STATUS_ENUM_SETUP, "setup"},
+ {PK_STATUS_ENUM_QUERY, "query"},
+ {PK_STATUS_ENUM_REFRESH_CACHE, "refresh-cache"},
+ {PK_STATUS_ENUM_REMOVE, "remove"},
+ {PK_STATUS_ENUM_DOWNLOAD, "download"},
+ {PK_STATUS_ENUM_INSTALL, "install"},
+ {PK_STATUS_ENUM_UPDATE, "update"},
{0, NULL},
};
static PkTaskEnumMatch task_role[] = {
- {PK_TASK_ROLE_UNKNOWN, "unknown"}, /* fall though value */
- {PK_TASK_ROLE_QUERY, "query"},
- {PK_TASK_ROLE_REFRESH_CACHE, "refresh-cache"},
- {PK_TASK_ROLE_PACKAGE_REMOVE, "package-remove"},
- {PK_TASK_ROLE_PACKAGE_INSTALL, "package-install"},
- {PK_TASK_ROLE_PACKAGE_UPDATE, "package-update"},
- {PK_TASK_ROLE_SYSTEM_UPDATE, "system-update"},
+ {PK_ROLE_ENUM_UNKNOWN, "unknown"}, /* fall though value */
+ {PK_ROLE_ENUM_QUERY, "query"},
+ {PK_ROLE_ENUM_REFRESH_CACHE, "refresh-cache"},
+ {PK_ROLE_ENUM_PACKAGE_REMOVE, "package-remove"},
+ {PK_ROLE_ENUM_PACKAGE_INSTALL, "package-install"},
+ {PK_ROLE_ENUM_PACKAGE_UPDATE, "package-update"},
+ {PK_ROLE_ENUM_SYSTEM_UPDATE, "system-update"},
{0, NULL},
};
static PkTaskEnumMatch task_error[] = {
- {PK_TASK_ERROR_CODE_UNKNOWN, "unknown"}, /* fall though value */
- {PK_TASK_ERROR_CODE_OOM, "out-of-memory"},
- {PK_TASK_ERROR_CODE_NO_NETWORK, "no-network"},
- {PK_TASK_ERROR_CODE_NOT_SUPPORTED, "not-supported"},
- {PK_TASK_ERROR_CODE_INTERNAL_ERROR, "internal-error"},
- {PK_TASK_ERROR_CODE_GPG_FAILURE, "gpg-failure"},
- {PK_TASK_ERROR_CODE_FILTER_INVALID, "filter-invalid"},
- {PK_TASK_ERROR_CODE_PACKAGE_ID_INVALID, "package-id-invalid"},
- {PK_TASK_ERROR_CODE_TRANSACTION_ERROR, "transaction-error"},
- {PK_TASK_ERROR_CODE_PACKAGE_NOT_INSTALLED, "package-not-installed"},
- {PK_TASK_ERROR_CODE_PACKAGE_ALREADY_INSTALLED, "package-already-installed"},
- {PK_TASK_ERROR_CODE_PACKAGE_DOWNLOAD_FAILED, "package-download-failed"},
- {PK_TASK_ERROR_CODE_DEP_RESOLUTION_FAILED, "dep-resolution-failed"},
- {PK_TASK_ERROR_CODE_CREATE_THREAD_FAILED, "create-thread-failed"},
+ {PK_ERROR_ENUM_UNKNOWN, "unknown"}, /* fall though value */
+ {PK_ERROR_ENUM_OOM, "out-of-memory"},
+ {PK_ERROR_ENUM_NO_NETWORK, "no-network"},
+ {PK_ERROR_ENUM_NOT_SUPPORTED, "not-supported"},
+ {PK_ERROR_ENUM_INTERNAL_ERROR, "internal-error"},
+ {PK_ERROR_ENUM_GPG_FAILURE, "gpg-failure"},
+ {PK_ERROR_ENUM_FILTER_INVALID, "filter-invalid"},
+ {PK_ERROR_ENUM_PACKAGE_ID_INVALID, "package-id-invalid"},
+ {PK_ERROR_ENUM_TRANSACTION_ERROR, "transaction-error"},
+ {PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, "package-not-installed"},
+ {PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED, "package-already-installed"},
+ {PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, "package-download-failed"},
+ {PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "dep-resolution-failed"},
+ {PK_ERROR_ENUM_CREATE_THREAD_FAILED, "create-thread-failed"},
{0, NULL},
};
static PkTaskEnumMatch task_restart[] = {
- {PK_TASK_RESTART_NONE, "none"},
- {PK_TASK_RESTART_SYSTEM, "system"},
- {PK_TASK_RESTART_SESSION, "session"},
- {PK_TASK_RESTART_APPLICATION, "application"},
+ {PK_RESTART_ENUM_NONE, "none"},
+ {PK_RESTART_ENUM_SYSTEM, "system"},
+ {PK_RESTART_ENUM_SESSION, "session"},
+ {PK_RESTART_ENUM_APPLICATION, "application"},
{0, NULL},
};
static PkTaskEnumMatch task_group[] = {
- {PK_TASK_GROUP_ACCESSIBILITY, "accessibility"},
- {PK_TASK_GROUP_ACCESSORIES, "accessories"},
- {PK_TASK_GROUP_EDUCATION, "education"},
- {PK_TASK_GROUP_GAMES, "games"},
- {PK_TASK_GROUP_GRAPHICS, "graphics"},
- {PK_TASK_GROUP_INTERNET, "internet"},
- {PK_TASK_GROUP_OFFICE, "office"},
- {PK_TASK_GROUP_OTHER, "other"},
- {PK_TASK_GROUP_PROGRAMMING, "programming"},
- {PK_TASK_GROUP_MULTIMEDIA, "multimedia"},
- {PK_TASK_GROUP_SYSTEM, "system"},
+ {PK_GROUP_ENUM_ACCESSIBILITY, "accessibility"},
+ {PK_GROUP_ENUM_ACCESSORIES, "accessories"},
+ {PK_GROUP_ENUM_EDUCATION, "education"},
+ {PK_GROUP_ENUM_GAMES, "games"},
+ {PK_GROUP_ENUM_GRAPHICS, "graphics"},
+ {PK_GROUP_ENUM_INTERNET, "internet"},
+ {PK_GROUP_ENUM_OFFICE, "office"},
+ {PK_GROUP_ENUM_OTHER, "other"},
+ {PK_GROUP_ENUM_PROGRAMMING, "programming"},
+ {PK_GROUP_ENUM_MULTIMEDIA, "multimedia"},
+ {PK_GROUP_ENUM_SYSTEM, "system"},
{0, NULL},
};
static PkTaskEnumMatch task_action[] = {
- {PK_TASK_ACTION_INSTALL, "install"},
- {PK_TASK_ACTION_REMOVE, "remove"},
- {PK_TASK_ACTION_UPDATE, "update"},
- {PK_TASK_ACTION_GET_UPDATES, "get-updates"},
- {PK_TASK_ACTION_REFRESH_CACHE, "refresh-cache"},
- {PK_TASK_ACTION_UPDATE_SYSTEM, "update-system"},
- {PK_TASK_ACTION_SEARCH_NAME, "search-name"},
- {PK_TASK_ACTION_SEARCH_DETAILS, "search-details"},
- {PK_TASK_ACTION_SEARCH_GROUP, "search-group"},
- {PK_TASK_ACTION_SEARCH_FILE, "search-file"},
- {PK_TASK_ACTION_GET_DEPENDS, "get-depends"},
- {PK_TASK_ACTION_GET_REQUIRES, "get-requires"},
- {PK_TASK_ACTION_GET_DESCRIPTION, "get-description"},
+ {PK_ACTION_ENUM_INSTALL, "install"},
+ {PK_ACTION_ENUM_REMOVE, "remove"},
+ {PK_ACTION_ENUM_UPDATE, "update"},
+ {PK_ACTION_ENUM_GET_UPDATES, "get-updates"},
+ {PK_ACTION_ENUM_REFRESH_CACHE, "refresh-cache"},
+ {PK_ACTION_ENUM_UPDATE_SYSTEM, "update-system"},
+ {PK_ACTION_ENUM_SEARCH_NAME, "search-name"},
+ {PK_ACTION_ENUM_SEARCH_DETAILS, "search-details"},
+ {PK_ACTION_ENUM_SEARCH_GROUP, "search-group"},
+ {PK_ACTION_ENUM_SEARCH_FILE, "search-file"},
+ {PK_ACTION_ENUM_GET_DEPENDS, "get-depends"},
+ {PK_ACTION_ENUM_GET_REQUIRES, "get-requires"},
+ {PK_ACTION_ENUM_GET_DESCRIPTION, "get-description"},
{0, NULL},
};
@@ -671,7 +671,7 @@ libst_task_utils (LibSelfTest *test)
**************** ACTIONS ******************
************************************************************/
libst_title (test, "test the action building (single)");
- text = pk_task_action_build (PK_TASK_ACTION_INSTALL, 0);
+ text = pk_task_action_build (PK_ACTION_ENUM_INSTALL, 0);
if (strcmp (text, "install") == 0) {
libst_success (test, NULL);
} else {
@@ -681,7 +681,7 @@ libst_task_utils (LibSelfTest *test)
/************************************************************/
libst_title (test, "test the action building (multiple)");
- text = pk_task_action_build (PK_TASK_ACTION_INSTALL, PK_TASK_ACTION_SEARCH_NAME, PK_TASK_ACTION_GET_DEPENDS, 0);
+ text = pk_task_action_build (PK_ACTION_ENUM_INSTALL, PK_TASK_ACTION_SEARCH_NAME, PK_TASK_ACTION_GET_DEPENDS, 0);
if (strcmp (text, "install;search-name;get-depends") == 0) {
libst_success (test, NULL);
} else {
@@ -690,7 +690,7 @@ libst_task_utils (LibSelfTest *test)
/************************************************************/
libst_title (test, "test the action checking (present)");
- ret = pk_task_action_contains (text, PK_TASK_ACTION_INSTALL);
+ ret = pk_task_action_contains (text, PK_ACTION_ENUM_INSTALL);
if (ret == TRUE) {
libst_success (test, NULL);
} else {
@@ -699,7 +699,7 @@ libst_task_utils (LibSelfTest *test)
/************************************************************/
libst_title (test, "test the action checking (not-present)");
- ret = pk_task_action_contains (text, PK_TASK_ACTION_REMOVE);
+ ret = pk_task_action_contains (text, PK_ACTION_ENUM_REMOVE);
if (ret == FALSE) {
libst_success (test, NULL);
} else {
diff --git a/libpackagekit/pk-task-utils.h b/libpackagekit/pk-task-utils.h
index f90dff0..f5d787f 100644
--- a/libpackagekit/pk-task-utils.h
+++ b/libpackagekit/pk-task-utils.h
@@ -29,92 +29,92 @@ G_BEGIN_DECLS
/* what we asked to do */
typedef enum {
- PK_TASK_ROLE_QUERY,
- PK_TASK_ROLE_REFRESH_CACHE,
- PK_TASK_ROLE_SYSTEM_UPDATE,
- PK_TASK_ROLE_PACKAGE_REMOVE,
- PK_TASK_ROLE_PACKAGE_INSTALL,
- PK_TASK_ROLE_PACKAGE_UPDATE,
- PK_TASK_ROLE_UNKNOWN
+ PK_ROLE_ENUM_QUERY,
+ PK_ROLE_ENUM_REFRESH_CACHE,
+ PK_ROLE_ENUM_SYSTEM_UPDATE,
+ PK_ROLE_ENUM_PACKAGE_REMOVE,
+ PK_ROLE_ENUM_PACKAGE_INSTALL,
+ PK_ROLE_ENUM_PACKAGE_UPDATE,
+ PK_ROLE_ENUM_UNKNOWN
} PkTaskRole;
/* what we are actually doing */
typedef enum {
- PK_TASK_STATUS_SETUP,
- PK_TASK_STATUS_QUERY,
- PK_TASK_STATUS_REMOVE,
- PK_TASK_STATUS_REFRESH_CACHE,
- PK_TASK_STATUS_DOWNLOAD,
- PK_TASK_STATUS_INSTALL,
- PK_TASK_STATUS_UPDATE,
- PK_TASK_STATUS_UNKNOWN
+ PK_STATUS_ENUM_SETUP,
+ PK_STATUS_ENUM_QUERY,
+ PK_STATUS_ENUM_REMOVE,
+ PK_STATUS_ENUM_REFRESH_CACHE,
+ PK_STATUS_ENUM_DOWNLOAD,
+ PK_STATUS_ENUM_INSTALL,
+ PK_STATUS_ENUM_UPDATE,
+ PK_STATUS_ENUM_UNKNOWN
} PkTaskStatus;
typedef enum {
- PK_TASK_EXIT_SUCCESS,
- PK_TASK_EXIT_FAILED,
- PK_TASK_EXIT_CANCELED,
- PK_TASK_EXIT_UNKNOWN
+ PK_EXIT_ENUM_SUCCESS,
+ PK_EXIT_ENUM_FAILED,
+ PK_EXIT_ENUM_CANCELED,
+ PK_EXIT_ENUM_UNKNOWN
} PkTaskExit;
typedef enum {
- PK_TASK_RESTART_NONE,
- PK_TASK_RESTART_APPLICATION,
- PK_TASK_RESTART_SESSION,
- PK_TASK_RESTART_SYSTEM
+ PK_RESTART_ENUM_NONE,
+ PK_RESTART_ENUM_APPLICATION,
+ PK_RESTART_ENUM_SESSION,
+ PK_RESTART_ENUM_SYSTEM
} PkTaskRestart;
typedef enum {
- PK_TASK_ERROR_CODE_OOM,
- PK_TASK_ERROR_CODE_NO_NETWORK,
- PK_TASK_ERROR_CODE_NOT_SUPPORTED,
- PK_TASK_ERROR_CODE_INTERNAL_ERROR,
- PK_TASK_ERROR_CODE_GPG_FAILURE,
- PK_TASK_ERROR_CODE_PACKAGE_ID_INVALID,
- PK_TASK_ERROR_CODE_PACKAGE_NOT_INSTALLED,
- PK_TASK_ERROR_CODE_PACKAGE_ALREADY_INSTALLED,
- PK_TASK_ERROR_CODE_PACKAGE_DOWNLOAD_FAILED,
- PK_TASK_ERROR_CODE_DEP_RESOLUTION_FAILED,
- PK_TASK_ERROR_CODE_FILTER_INVALID,
- PK_TASK_ERROR_CODE_CREATE_THREAD_FAILED,
- PK_TASK_ERROR_CODE_TRANSACTION_ERROR,
- PK_TASK_ERROR_CODE_UNKNOWN
+ PK_ERROR_ENUM_OOM,
+ PK_ERROR_ENUM_NO_NETWORK,
+ PK_ERROR_ENUM_NOT_SUPPORTED,
+ PK_ERROR_ENUM_INTERNAL_ERROR,
+ PK_ERROR_ENUM_GPG_FAILURE,
+ PK_ERROR_ENUM_PACKAGE_ID_INVALID,
+ PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED,
+ PK_ERROR_ENUM_PACKAGE_ALREADY_INSTALLED,
+ PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED,
+ PK_ERROR_ENUM_DEP_RESOLUTION_FAILED,
+ PK_ERROR_ENUM_FILTER_INVALID,
+ PK_ERROR_ENUM_CREATE_THREAD_FAILED,
+ PK_ERROR_ENUM_TRANSACTION_ERROR,
+ PK_ERROR_ENUM_UNKNOWN
} PkTaskErrorCode;
typedef enum {
- PK_TASK_GROUP_ACCESSIBILITY,
- PK_TASK_GROUP_ACCESSORIES,
- PK_TASK_GROUP_EDUCATION,
- PK_TASK_GROUP_GAMES,
- PK_TASK_GROUP_GRAPHICS,
- PK_TASK_GROUP_INTERNET,
- PK_TASK_GROUP_OFFICE,
- PK_TASK_GROUP_OTHER,
- PK_TASK_GROUP_PROGRAMMING,
- PK_TASK_GROUP_MULTIMEDIA,
- PK_TASK_GROUP_SYSTEM,
- PK_TASK_GROUP_UNKNOWN
+ PK_GROUP_ENUM_ACCESSIBILITY,
+ PK_GROUP_ENUM_ACCESSORIES,
+ PK_GROUP_ENUM_EDUCATION,
+ PK_GROUP_ENUM_GAMES,
+ PK_GROUP_ENUM_GRAPHICS,
+ PK_GROUP_ENUM_INTERNET,
+ PK_GROUP_ENUM_OFFICE,
+ PK_GROUP_ENUM_OTHER,
+ PK_GROUP_ENUM_PROGRAMMING,
+ PK_GROUP_ENUM_MULTIMEDIA,
+ PK_GROUP_ENUM_SYSTEM,
+ PK_GROUP_ENUM_UNKNOWN
} PkTaskGroup;
typedef enum {
- PK_TASK_ACTION_INSTALL = 1,
- PK_TASK_ACTION_REMOVE,
- PK_TASK_ACTION_UPDATE,
- PK_TASK_ACTION_GET_UPDATES,
- PK_TASK_ACTION_CANCEL_JOB,
- PK_TASK_ACTION_REFRESH_CACHE,
- PK_TASK_ACTION_UPDATE_SYSTEM,
- PK_TASK_ACTION_SEARCH_NAME,
- PK_TASK_ACTION_SEARCH_DETAILS,
- PK_TASK_ACTION_SEARCH_GROUP,
- PK_TASK_ACTION_SEARCH_FILE,
- PK_TASK_ACTION_GET_DEPENDS,
- PK_TASK_ACTION_GET_REQUIRES,
- PK_TASK_ACTION_GET_DESCRIPTION,
- PK_TASK_ACTION_INSTALL_PACKAGE,
- PK_TASK_ACTION_REMOVE_PACKAGE,
- PK_TASK_ACTION_UPDATE_PACKAGE,
- PK_TASK_ACTION_UNKNOWN
+ PK_ACTION_ENUM_INSTALL = 1,
+ PK_ACTION_ENUM_REMOVE,
+ PK_ACTION_ENUM_UPDATE,
+ PK_ACTION_ENUM_GET_UPDATES,
+ PK_ACTION_ENUM_CANCEL_JOB,
+ PK_ACTION_ENUM_REFRESH_CACHE,
+ PK_ACTION_ENUM_UPDATE_SYSTEM,
+ PK_ACTION_ENUM_SEARCH_NAME,
+ PK_ACTION_ENUM_SEARCH_DETAILS,
+ PK_ACTION_ENUM_SEARCH_GROUP,
+ PK_ACTION_ENUM_SEARCH_FILE,
+ PK_ACTION_ENUM_GET_DEPENDS,
+ PK_ACTION_ENUM_GET_REQUIRES,
+ PK_ACTION_ENUM_GET_DESCRIPTION,
+ PK_ACTION_ENUM_INSTALL_PACKAGE,
+ PK_ACTION_ENUM_REMOVE_PACKAGE,
+ PK_ACTION_ENUM_UPDATE_PACKAGE,
+ PK_ACTION_ENUM_UNKNOWN
} PkTaskAction;
PkTaskExit pk_task_exit_from_text (const gchar *exit);
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 20e0790..bde5aa7 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -328,9 +328,9 @@ pk_backend_spawn_finished_cb (PkSpawn *s
/* only emit success with a zero exit code */
if (exitcode == 0) {
- exit = PK_TASK_EXIT_SUCCESS;
+ exit = PK_EXIT_ENUM_SUCCESS;
} else {
- exit = PK_TASK_EXIT_FAILED;
+ exit = PK_EXIT_ENUM_FAILED;
}
pk_backend_finished (backend, exit);
}
@@ -384,8 +384,8 @@ pk_backend_spawn_helper_internal (PkBack
ret = pk_spawn_command (backend->priv->spawn, command);
if (ret == FALSE) {
g_object_unref (backend->priv->spawn);
- pk_backend_error_code (backend, PK_TASK_ERROR_CODE_INTERNAL_ERROR, "Spawn of helper '%s' failed", command);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Spawn of helper '%s' failed", command);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
}
g_free (filename);
g_free (command);
@@ -432,8 +432,8 @@ pk_backend_spawn_helper (PkBackend *back
gboolean
pk_backend_not_implemented_yet (PkBackend *backend, const gchar *method)
{
- pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NOT_SUPPORTED, "the method '%s' is not implemented yet", method);
- pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+ pk_backend_error_code (backend, PK_ERROR_ENUM_NOT_SUPPORTED, "the method '%s' is not implemented yet", method);
+ pk_backend_finished (backend, PK_EXIT_ENUM_FAILED);
return TRUE;
}
@@ -473,7 +473,7 @@ pk_backend_set_job_role (PkBackend *back
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
/* Should only be called once... */
- if (backend->priv->role != PK_TASK_ROLE_UNKNOWN) {
+ if (backend->priv->role != PK_ROLE_ENUM_UNKNOWN) {
pk_error ("cannot set role more than once, already %s",
pk_task_role_to_text (backend->priv->role));
}
@@ -701,7 +701,7 @@ pk_backend_get_depends (PkBackend *backe
pk_backend_not_implemented_yet (backend, "GetDepends");
return FALSE;
}
- pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, package_id);
+ pk_backend_set_job_role (backend, PK_ROLE_ENUM_QUERY, package_id);
backend->desc->get_depends (backend, package_id);
backend->priv->assigned = TRUE;
return TRUE;
@@ -718,7 +718,7 @@ pk_backend_get_description (PkBackend *b
pk_backend_not_implemented_yet (backend, "GetDescription");
return FALSE;
}
- pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, package_id);
+ pk_backend_set_job_role (backend, PK_ROLE_ENUM_QUERY, package_id);
backend->desc->get_description (backend, package_id);
backend->priv->assigned = TRUE;
return TRUE;
@@ -735,7 +735,7 @@ pk_backend_get_requires (PkBackend *back
pk_backend_not_implemented_yet (backend, "GetRequires");
return FALSE;
}
- pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, package_id);
+ pk_backend_set_job_role (backend, PK_ROLE_ENUM_QUERY, package_id);
backend->desc->get_requires (backend, package_id);
backend->priv->assigned = TRUE;
return TRUE;
@@ -752,7 +752,7 @@ pk_backend_get_updates (PkBackend *backe
pk_backend_not_implemented_yet (backend, "GetUpdates");
return FALSE;
}
- pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, NULL);
+ pk_backend_set_job_role (backend, PK_ROLE_ENUM_QUERY, NULL);
backend->desc->get_updates (backend);
backend->priv->assigned = TRUE;
return TRUE;
@@ -769,7 +769,7 @@ pk_backend_install_package (PkBackend *b
pk_backend_not_implemented_yet (backend, "InstallPackage");
return FALSE;
}
- pk_backend_set_job_role (backend, PK_TASK_ROLE_PACKAGE_INSTALL, package_id);
+ pk_backend_set_job_role (backend, PK_ROLE_ENUM_PACKAGE_INSTALL, package_id);
backend->desc->install_package (backend, package_id);
backend->priv->assigned = TRUE;
return TRUE;
@@ -786,7 +786,7 @@ pk_backend_refresh_cache (PkBackend *bac
pk_backend_not_implemented_yet (backend, "RefreshCache");
return FALSE;
}
- pk_backend_set_job_role (backend, PK_TASK_ROLE_REFRESH_CACHE, NULL);
+ pk_backend_set_job_role (backend, PK_ROLE_ENUM_REFRESH_CACHE, NULL);
backend->desc->refresh_cache (backend, force);
backend->priv->assigned = TRUE;
return TRUE;
@@ -803,7 +803,7 @@ pk_backend_remove_package (PkBackend *ba
pk_backend_not_implemented_yet (backend, "RemovePackage");
return FALSE;
}
- pk_backend_set_job_role (backend, PK_TASK_ROLE_PACKAGE_REMOVE, package_id);
+ pk_backend_set_job_role (backend, PK_ROLE_ENUM_PACKAGE_REMOVE, package_id);
backend->desc->remove_package (backend, package_id, allow_deps);
backend->priv->assigned = TRUE;
return TRUE;
@@ -820,7 +820,7 @@ pk_backend_search_details (PkBackend *ba
pk_backend_not_implemented_yet (backend, "SearchDetails");
return FALSE;
}
- pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+ pk_backend_set_job_role (backend, PK_ROLE_ENUM_QUERY, search);
backend->desc->search_details (backend, filter, search);
backend->priv->assigned = TRUE;
return TRUE;
@@ -837,7 +837,7 @@ pk_backend_search_file (PkBackend *backe
pk_backend_not_implemented_yet (backend, "SearchFile");
return FALSE;
}
- pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+ pk_backend_set_job_role (backend, PK_ROLE_ENUM_QUERY, search);
backend->desc->search_file (backend, filter, search);
backend->priv->assigned = TRUE;
return TRUE;
@@ -854,7 +854,7 @@ pk_backend_search_group (PkBackend *back
pk_backend_not_implemented_yet (backend, "SearchGroup");
return FALSE;
}
- pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+ pk_backend_set_job_role (backend, PK_ROLE_ENUM_QUERY, search);
backend->desc->search_group (backend, filter, search);
backend->priv->assigned = TRUE;
return TRUE;
@@ -871,7 +871,7 @@ pk_backend_search_name (PkBackend *backe
pk_backend_not_implemented_yet (backend, "SearchName");
return FALSE;
}
- pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+ pk_backend_set_job_role (backend, PK_ROLE_ENUM_QUERY, search);
backend->desc->search_name (backend, filter, search);
backend->priv->assigned = TRUE;
return TRUE;
@@ -888,7 +888,7 @@ pk_backend_update_package (PkBackend *ba
pk_backend_not_implemented_yet (backend, "UpdatePackage");
return FALSE;
}
- pk_backend_set_job_role (backend, PK_TASK_ROLE_PACKAGE_UPDATE, package_id);
+ pk_backend_set_job_role (backend, PK_ROLE_ENUM_PACKAGE_UPDATE, package_id);
backend->desc->update_package (backend, package_id);
backend->priv->assigned = TRUE;
return TRUE;
@@ -905,7 +905,7 @@ pk_backend_update_system (PkBackend *bac
pk_backend_not_implemented_yet (backend, "UpdateSystem");
return FALSE;
}
- pk_backend_set_job_role (backend, PK_TASK_ROLE_SYSTEM_UPDATE, NULL);
+ pk_backend_set_job_role (backend, PK_ROLE_ENUM_SYSTEM_UPDATE, NULL);
backend->desc->update_system (backend);
backend->priv->assigned = TRUE;
return TRUE;
@@ -918,48 +918,48 @@ PkActionList *
pk_backend_get_actions (PkBackend *backend)
{
PkActionList *alist;
- alist = pk_util_action_new (PK_TASK_ACTION_UNKNOWN);
+ alist = pk_util_action_new (PK_ACTION_ENUM_UNKNOWN);
if (backend->desc->cancel_job_try != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_CANCEL_JOB);
+ pk_util_action_append (alist, PK_ACTION_ENUM_CANCEL_JOB);
}
if (backend->desc->get_depends != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_GET_DEPENDS);
+ pk_util_action_append (alist, PK_ACTION_ENUM_GET_DEPENDS);
}
if (backend->desc->get_description != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_GET_DESCRIPTION);
+ pk_util_action_append (alist, PK_ACTION_ENUM_GET_DESCRIPTION);
}
if (backend->desc->get_requires != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_GET_REQUIRES);
+ pk_util_action_append (alist, PK_ACTION_ENUM_GET_REQUIRES);
}
if (backend->desc->get_updates != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_GET_UPDATES);
+ pk_util_action_append (alist, PK_ACTION_ENUM_GET_UPDATES);
}
if (backend->desc->install_package != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_INSTALL_PACKAGE);
+ pk_util_action_append (alist, PK_ACTION_ENUM_INSTALL_PACKAGE);
}
if (backend->desc->refresh_cache != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_REFRESH_CACHE);
+ pk_util_action_append (alist, PK_ACTION_ENUM_REFRESH_CACHE);
}
if (backend->desc->remove_package != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_REMOVE_PACKAGE);
+ pk_util_action_append (alist, PK_ACTION_ENUM_REMOVE_PACKAGE);
}
if (backend->desc->search_details != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_SEARCH_DETAILS);
+ pk_util_action_append (alist, PK_ACTION_ENUM_SEARCH_DETAILS);
}
if (backend->desc->search_file != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_SEARCH_FILE);
+ pk_util_action_append (alist, PK_ACTION_ENUM_SEARCH_FILE);
}
if (backend->desc->search_group != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_SEARCH_GROUP);
+ pk_util_action_append (alist, PK_ACTION_ENUM_SEARCH_GROUP);
}
if (backend->desc->search_name != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_SEARCH_NAME);
+ pk_util_action_append (alist, PK_ACTION_ENUM_SEARCH_NAME);
}
if (backend->desc->update_package != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_UPDATE_PACKAGE);
+ pk_util_action_append (alist, PK_ACTION_ENUM_UPDATE_PACKAGE);
}
if (backend->desc->update_system != NULL) {
- pk_util_action_append (alist, PK_TASK_ACTION_UPDATE_SYSTEM);
+ pk_util_action_append (alist, PK_ACTION_ENUM_UPDATE_SYSTEM);
}
return alist;
}
@@ -1085,9 +1085,9 @@ pk_backend_init (PkBackend *backend)
backend->priv->is_killable = FALSE;
backend->priv->spawn = NULL;
backend->priv->package_id = NULL;
- backend->priv->role = PK_TASK_ROLE_UNKNOWN;
- backend->priv->status = PK_TASK_STATUS_UNKNOWN;
- backend->priv->exit = PK_TASK_EXIT_UNKNOWN;
+ backend->priv->role = PK_ROLE_ENUM_UNKNOWN;
+ backend->priv->status = PK_STATUS_ENUM_UNKNOWN;
+ backend->priv->exit = PK_EXIT_ENUM_UNKNOWN;
backend->priv->network = pk_network_new ();
}
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 6271555..2a48ae0 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -1099,7 +1099,7 @@ pk_engine_update_system (PkEngine *engin
for (i=0; i<length; i++) {
map = (PkEngineMap *) g_ptr_array_index (engine->priv->array, i);
ret = pk_backend_get_job_role (map->task, &role, NULL);
- if (ret == TRUE && role == PK_TASK_ROLE_SYSTEM_UPDATE) {
+ if (ret == TRUE && role == PK_ROLE_ENUM_SYSTEM_UPDATE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_DENIED,
"operation not yet supported by backend");
dbus_g_method_return_error (context, error);
diff-tree 914cc04a2939531a63b31376b63be3f7bce83654 (from 7754c96059b72210bf20c0e167d8d0ec1cfe04a5)
Author: Tom Parker <palfrey at tevp.net>
Date: Fri Sep 7 16:45:12 2007 +0200
Move pkt.py to pkt and add copyright
diff --git a/tools/pkt b/tools/pkt
new file mode 100755
index 0000000..b868322
--- /dev/null
+++ b/tools/pkt
@@ -0,0 +1,109 @@
+#!/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 --git a/tools/pkt.py b/tools/pkt.py
deleted file mode 100755
index 717807f..0000000
--- a/tools/pkt.py
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/python
-
-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 7754c96059b72210bf20c0e167d8d0ec1cfe04a5 (from 46e216e77ab6230eb7245be79c25bb181b76fcb7)
Author: Tom Parker <palfrey at tevp.net>
Date: Fri Aug 31 16:59:37 2007 +0200
pkt now needs a "none" filter, not ""
diff --git a/tools/pkt.py b/tools/pkt.py
index 5d9fbf6..717807f 100755
--- a/tools/pkt.py
+++ b/tools/pkt.py
@@ -50,7 +50,7 @@ bus.add_signal_receiver(catchall_signal_
def search(*args):
patt = " ".join(args[0])
- return pk_iface.SearchName("",patt)
+ return pk_iface.SearchName("none",patt)
def desc(*args):
if len(args)!=1 or len(args[0])!=1:
diff-tree 46e216e77ab6230eb7245be79c25bb181b76fcb7 (from 1a69fa9d9422c89f0767378cb1dedbd3626a85b8)
Author: Tom Parker <palfrey at tevp.net>
Date: Thu Aug 30 14:09:57 2007 +0200
Redo pkt as a better apt-* like tool
diff --git a/tools/pkt.py b/tools/pkt.py
old mode 100644
new mode 100755
index 85e6dfd..5d9fbf6
--- a/tools/pkt.py
+++ b/tools/pkt.py
@@ -1,31 +1,101 @@
#!/usr/bin/python
-from sys import argv
-
+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()
-pk = bus.get_object('org.freedesktop.PackageKit', '/org/freedesktop/PackageKit')
-pk_iface = dbus.Interface(pk, dbus_interface='org.freedesktop.PackageKit')
+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
- print ("Caught signal (in catchall handler) "
- + kwargs['dbus_interface'] + "." + kwargs['member'])
- for arg in args:
- print " " + str(arg)
+ global job,progress
+ if args[0] != job and kwargs['member']!="JobListChanged":
+ print args,job,kwargs
+ raise Exception
if kwargs['member'] == "Finished":
- if args[0] == job:
- loop.quit()
+ 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("",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
-bus.add_signal_receiver(catchall_signal_handler, interface_keyword='dbus_interface', member_keyword='member')
+if job == -1:
+ usage()
-job = pk_iface.SearchName("",argv[1])
-print "job",job
loop = gobject.MainLoop()
loop.run()
More information about the PackageKit
mailing list