[packagekit] packagekit: Branch 'master' - 4 commits

Richard Hughes hughsient at kemper.freedesktop.org
Thu Sep 20 16:21:01 PDT 2007


 backends/test/pk-backend-test-fail.c |   32 +++++++++
 libpackagekit/pk-enum-list.c         |   22 +++---
 libpackagekit/pk-enum-list.h         |    2 
 libpackagekit/pk-enum.c              |   36 -----------
 libpackagekit/pk-enum.h              |   25 -------
 libpackagekit/pk-task-client.c       |    2 
 src/pk-backend.c                     |   67 +++++++++++++++-----
 src/pk-engine.c                      |  113 +++++++++++++++++++++++++++++++++--
 src/pk-engine.h                      |    1 
 9 files changed, 206 insertions(+), 94 deletions(-)

New commits:
diff-tree 06a79c186ebe8c0acdc5a477a2d59856d1462577 (from 790ee533f1797745c9c99a3c5a59857913ea8cf5)
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Sep 20 23:13:04 2007 +0100

    warn against backend calling finish in the initialize routine

diff --git a/src/pk-backend.c b/src/pk-backend.c
index df35a1f..80e41e8 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -66,6 +66,7 @@ struct _PkBackendPrivate
 	GTimer			*timer;
 	PkSpawn			*spawn;
 	gboolean		 is_killable;
+	gboolean		 during_initialize;
 	gboolean		 assigned;
 	gboolean		 set_error;
 	PkNetwork		*network;
@@ -157,9 +158,12 @@ pk_backend_load (PkBackend *backend, con
 		pk_error ("could not find description in plugin %s, not loading", backend_name);
 	}
 
+	/* initialize, but protect against dodgy backends */
+	backend->priv->during_initialize = TRUE;
 	if (backend->desc->initialize) {
 		backend->desc->initialize (backend);
 	}
+	backend->priv->during_initialize = FALSE;
 
 	/* did we fail? */
 	if (backend->priv->set_error == TRUE) {
@@ -824,9 +828,15 @@ pk_backend_finished (PkBackend *backend)
 	g_return_val_if_fail (backend != NULL, FALSE);
 	g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
 
+	/* are we trying to finish in init? */
+	if (backend->priv->during_initialize == TRUE) {
+		g_print ("You can't call pk_backend_finished in backend_initialize!\n");
+		pk_error ("Internal error, cannot continue");
+	}
+
 	/* check we have no threads running */
 	if (pk_thread_list_number_running (backend->priv->thread_list) != 0) {
-		g_print ("ERROR: There are threads running and the task has been asked to finish!\n");
+		g_print ("There are threads running and the task has been asked to finish!\n");
 		g_print ("If you are using :\n");
 		g_print ("* pk_backend_thread_helper\n");
 		g_print ("   - You should _not_ use pk_backend_finished directly");
@@ -1421,6 +1431,7 @@ pk_backend_init (PkBackend *backend)
 	backend->priv->assigned = FALSE;
 	backend->priv->is_killable = FALSE;
 	backend->priv->set_error = FALSE;
+	backend->priv->during_initialize = FALSE;
 	backend->priv->spawn = NULL;
 	backend->priv->handle = NULL;
 	backend->priv->xcached_package_id = NULL;
diff-tree 790ee533f1797745c9c99a3c5a59857913ea8cf5 (from 84bfd1a2488ff650968eabdd5ceeba1028cf7d34)
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Sep 20 23:05:20 2007 +0100

    if the init failed in the backend, abort the transaction

diff --git a/backends/test/pk-backend-test-fail.c b/backends/test/pk-backend-test-fail.c
index f039cb4..b503196 100644
--- a/backends/test/pk-backend-test-fail.c
+++ b/backends/test/pk-backend-test-fail.c
@@ -33,8 +33,6 @@ backend_initialize (PkBackend *backend)
 	g_return_if_fail (backend != NULL);
 	pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
 			       "Failed to initialize package manager");
-	pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
-			       "Failed to initialize package manager");
 }
 
 /**
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 035fde2..df35a1f 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -132,6 +132,11 @@ pk_backend_load (PkBackend *backend, con
 
 	g_return_val_if_fail (backend_name != NULL, FALSE);
 
+	if (backend->priv->handle != NULL) {
+		pk_warning ("pk_backend_load called multiple times. This is bad");
+		return FALSE;
+	}
+
 	/* save the backend name */
 	backend->priv->name = g_strdup (backend_name);
 
@@ -155,6 +160,13 @@ pk_backend_load (PkBackend *backend, con
 	if (backend->desc->initialize) {
 		backend->desc->initialize (backend);
 	}
+
+	/* did we fail? */
+	if (backend->priv->set_error == TRUE) {
+		pk_debug ("init failed...");
+		return FALSE;
+	}
+
 	return TRUE;
 }
 
@@ -1410,6 +1422,7 @@ pk_backend_init (PkBackend *backend)
 	backend->priv->is_killable = FALSE;
 	backend->priv->set_error = FALSE;
 	backend->priv->spawn = NULL;
+	backend->priv->handle = NULL;
 	backend->priv->xcached_package_id = NULL;
 	backend->priv->xcached_filter = NULL;
 	backend->priv->xcached_search = NULL;
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 27d3047..aff40b7 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -122,6 +122,7 @@ pk_engine_error_get_type (void)
 			ENUM_ENTRY (PK_ENGINE_ERROR_SEARCH_INVALID, "SearchInvalid"),
 			ENUM_ENTRY (PK_ENGINE_ERROR_FILTER_INVALID, "FilterInvalid"),
 			ENUM_ENTRY (PK_ENGINE_ERROR_INVALID_STATE, "InvalidState"),
+			ENUM_ENTRY (PK_ENGINE_ERROR_INITIALIZE_FAILED, "InitializeFailed"),
 			{ 0, 0, 0 }
 		};
 		etype = g_enum_register_static ("PkEngineError", values);
@@ -443,7 +444,8 @@ pk_engine_new_backend (PkEngine *engine)
 	backend = pk_backend_new ();
 	ret = pk_backend_load (backend, engine->priv->backend);
 	if (ret == FALSE) {
-		pk_error ("Cannot use backend '%s'", engine->priv->backend);
+		pk_warning ("Cannot use backend '%s'", engine->priv->backend);
+		return NULL;
 	}
 	pk_debug ("adding backend %p", backend);
 
@@ -609,6 +611,12 @@ pk_engine_refresh_cache (PkEngine *engin
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
 	ret = pk_backend_refresh_cache (backend, force);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -642,6 +650,12 @@ pk_engine_get_updates (PkEngine *engine,
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
 	ret = pk_backend_get_updates (backend);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -740,6 +754,12 @@ pk_engine_search_name (PkEngine *engine,
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
 	ret = pk_backend_search_name (backend, filter, search);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -786,6 +806,12 @@ pk_engine_search_details (PkEngine *engi
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
 	ret = pk_backend_search_details (backend, filter, search);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -832,6 +858,12 @@ pk_engine_search_group (PkEngine *engine
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
 	ret = pk_backend_search_group (backend, filter, search);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -878,6 +910,12 @@ pk_engine_search_file (PkEngine *engine,
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
 	ret = pk_backend_search_file (backend, filter, search);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -920,6 +958,12 @@ pk_engine_get_depends (PkEngine *engine,
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
 	ret = pk_backend_get_depends (backend, package_id);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -962,6 +1006,12 @@ pk_engine_get_requires (PkEngine *engine
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
 	ret = pk_backend_get_requires (backend, package_id);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1004,6 +1054,12 @@ pk_engine_get_update_detail (PkEngine *e
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
 	ret = pk_backend_get_update_detail (backend, package_id);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1038,6 +1094,12 @@ pk_engine_get_description (PkEngine *eng
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
 	ret = pk_backend_get_description (backend, package_id);
 	if (ret == FALSE) {
 		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1088,6 +1150,13 @@ pk_engine_update_system (PkEngine *engin
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+				     "Operation not yet supported by backend");
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+
 	ret = pk_backend_update_system (backend);
 	if (ret == FALSE) {
 		error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1139,6 +1208,13 @@ pk_engine_remove_package (PkEngine *engi
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+				     "Operation not yet supported by backend");
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+
 	ret = pk_backend_remove_package (backend, package_id, allow_deps);
 	if (ret == FALSE) {
 		error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1192,6 +1268,13 @@ pk_engine_install_package (PkEngine *eng
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+				     "Operation not yet supported by backend");
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+
 	ret = pk_backend_install_package (backend, package_id);
 	if (ret == FALSE) {
 		error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1245,6 +1328,13 @@ pk_engine_update_package (PkEngine *engi
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
+	if (backend == NULL) {
+		error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+				     "Operation not yet supported by backend");
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+
 	ret = pk_backend_update_package (backend, package_id);
 	if (ret == FALSE) {
 		error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1466,7 +1556,12 @@ pk_engine_get_actions (PkEngine *engine,
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
-	pk_backend_load (backend, engine->priv->backend);
+	if (backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
 	elist = pk_backend_get_actions (backend);
 	*actions = pk_enum_list_to_string (elist);
 	g_object_unref (backend);
@@ -1490,7 +1585,12 @@ pk_engine_get_groups (PkEngine *engine, 
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
-	pk_backend_load (backend, engine->priv->backend);
+	if (backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
 	elist = pk_backend_get_groups (backend);
 	*groups = pk_enum_list_to_string (elist);
 	g_object_unref (backend);
@@ -1514,7 +1614,12 @@ pk_engine_get_filters (PkEngine *engine,
 
 	/* create a new backend and start it */
 	backend = pk_engine_new_backend (engine);
-	pk_backend_load (backend, engine->priv->backend);
+	if (backend == NULL) {
+		g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+			     "Backend '%s' could not be initialized", engine->priv->backend);
+		return FALSE;
+	}
+
 	elist = pk_backend_get_filters (backend);
 	*filters = pk_enum_list_to_string (elist);
 	g_object_unref (backend);
diff --git a/src/pk-engine.h b/src/pk-engine.h
index 37f21fd..ea2e336 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -64,6 +64,7 @@ typedef enum
 	PK_ENGINE_ERROR_SEARCH_INVALID,
 	PK_ENGINE_ERROR_FILTER_INVALID,
 	PK_ENGINE_ERROR_INVALID_STATE,
+	PK_ENGINE_ERROR_INITIALIZE_FAILED,
 	PK_ENGINE_ERROR_LAST
 } PkEngineError;
 
diff-tree 84bfd1a2488ff650968eabdd5ceeba1028cf7d34 (from ac700de8925e9e0beebc13f5f00e6ce9915d811c)
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Sep 20 20:04:09 2007 +0100

    don't allow a duplicate error to be set

diff --git a/backends/test/pk-backend-test-fail.c b/backends/test/pk-backend-test-fail.c
index 063e8af..f039cb4 100644
--- a/backends/test/pk-backend-test-fail.c
+++ b/backends/test/pk-backend-test-fail.c
@@ -25,6 +25,30 @@
 #include <pk-backend.h>
 
 /**
+ * backend_initalize:
+ */
+static void
+backend_initialize (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
+			       "Failed to initialize package manager");
+	pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
+			       "Failed to initialize package manager");
+}
+
+/**
+ * backend_destroy:
+ */
+static void
+backend_destroy (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
+			       "Failed to release control");
+}
+
+/**
  * backend_get_groups:
  */
 static void
@@ -159,6 +183,10 @@ static void
 backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
 {
 	g_return_if_fail (backend != NULL);
+	pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
+			       "Error number 1");
+	pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
+			       "Duplicate error");
 	pk_backend_finished (backend);
 }
 
@@ -179,6 +207,8 @@ static void
 backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
 {
 	g_return_if_fail (backend != NULL);
+	pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
+			       "Error number 1");
 	pk_backend_finished (backend);
 }
 
@@ -206,8 +236,8 @@ PK_BACKEND_OPTIONS (
 	"Test Fail Backend",			/* description */
 	"0.0.1",				/* version */
 	"Richard Hughes <richard at hughsie.com>",	/* author */
-	NULL,					/* initalize */
-	NULL,					/* destroy */
+	backend_initialize,			/* initalize */
+	backend_destroy,			/* destroy */
 	backend_get_groups,			/* get_groups */
 	backend_get_filters,			/* get_filters */
 	backend_cancel,				/* cancel */
diff --git a/src/pk-backend.c b/src/pk-backend.c
index ce4fd1f..035fde2 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -67,6 +67,7 @@ struct _PkBackendPrivate
 	PkSpawn			*spawn;
 	gboolean		 is_killable;
 	gboolean		 assigned;
+	gboolean		 set_error;
 	PkNetwork		*network;
 	/* needed for gui coldplugging */
 	guint			 last_percentage;
@@ -729,6 +730,15 @@ pk_backend_error_code (PkBackend *backen
 	g_vsnprintf (buffer, 1024, format, args);
 	va_end (args);
 
+	/* did we set a duplicate error? */
+	if (backend->priv->set_error == TRUE) {
+		g_print ("pk_backend_error_code was used more than once in the same backend instance!\n");
+		g_print ("You tried to set '%s'\n", buffer);
+		pk_error ("Internal error, cannot continue");
+		return FALSE;
+	}
+	backend->priv->set_error = TRUE;
+
 	/* we mark any transaction with errors as failed */
 	backend->priv->exit = PK_EXIT_ENUM_FAILED;
 
@@ -1398,6 +1408,7 @@ pk_backend_init (PkBackend *backend)
 	backend->priv->timer = g_timer_new ();
 	backend->priv->assigned = FALSE;
 	backend->priv->is_killable = FALSE;
+	backend->priv->set_error = FALSE;
 	backend->priv->spawn = NULL;
 	backend->priv->xcached_package_id = NULL;
 	backend->priv->xcached_filter = NULL;
diff-tree ac700de8925e9e0beebc13f5f00e6ce9915d811c (from 5fab68022a89ef9e0d477e30ce11df01edc867d1)
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Sep 20 17:57:59 2007 +0100

    we don't need the action enum now we have a fully populated role

diff --git a/libpackagekit/pk-enum-list.c b/libpackagekit/pk-enum-list.c
index c449954..2a18d68 100644
--- a/libpackagekit/pk-enum-list.c
+++ b/libpackagekit/pk-enum-list.c
@@ -110,8 +110,8 @@ pk_enum_list_from_string (PkEnumList *el
 	/* split by delimeter ';' */
 	sections = g_strsplit (enums, ";", 0);
 	for (i=0; sections[i]; i++) {
-		if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
-			value_temp = pk_action_enum_from_text (sections[i]);
+		if (elist->priv->type == PK_ENUM_LIST_TYPE_ROLE) {
+			value_temp = pk_role_enum_from_text (sections[i]);
 		} else if (elist->priv->type == PK_ENUM_LIST_TYPE_GROUP) {
 			value_temp = pk_group_enum_from_text (sections[i]);
 		} else if (elist->priv->type == PK_ENUM_LIST_TYPE_FILTER) {
@@ -145,8 +145,8 @@ pk_enum_list_to_string (PkEnumList *elis
 	string = g_string_new ("");
 	for (i=0; i<length; i++) {
 		value = GPOINTER_TO_UINT (g_ptr_array_index (elist->priv->data, i));
-		if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
-			text = pk_action_enum_to_text (value);
+		if (elist->priv->type == PK_ENUM_LIST_TYPE_ROLE) {
+			text = pk_role_enum_to_text (value);
 		} else if (elist->priv->type == PK_ENUM_LIST_TYPE_GROUP) {
 			text = pk_group_enum_to_text (value);
 		} else if (elist->priv->type == PK_ENUM_LIST_TYPE_FILTER) {
@@ -174,7 +174,7 @@ pk_enum_list_print (PkEnumList *elist)
 	guint value;
 	const gchar *text = NULL;
 
-	if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
+	if (elist->priv->type == PK_ENUM_LIST_TYPE_ROLE) {
 		g_print ("Printing actions:\n");
 	} else if (elist->priv->type == PK_ENUM_LIST_TYPE_GROUP) {
 		g_print ("Printing groups:\n");
@@ -183,8 +183,8 @@ pk_enum_list_print (PkEnumList *elist)
 	}
 	for (i=0; i<elist->priv->data->len; i++) {
 		value = GPOINTER_TO_UINT (g_ptr_array_index (elist->priv->data, i));
-		if (elist->priv->type == PK_ENUM_LIST_TYPE_ACTION) {
-			text = pk_action_enum_to_text (value);
+		if (elist->priv->type == PK_ENUM_LIST_TYPE_ROLE) {
+			text = pk_role_enum_to_text (value);
 		} else if (elist->priv->type == PK_ENUM_LIST_TYPE_GROUP) {
 			text = pk_group_enum_to_text (value);
 		} else if (elist->priv->type == PK_ENUM_LIST_TYPE_FILTER) {
@@ -303,7 +303,7 @@ libst_enum_list (LibSelfTest *test)
 
 	/************************************************************/
 	libst_title (test, "set action builder");
-	ret = pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
+	ret = pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ROLE);
 	if (ret == TRUE) {
 		libst_success (test, NULL);
 	} else {
@@ -322,7 +322,7 @@ libst_enum_list (LibSelfTest *test)
 
 	/************************************************************/
 	libst_title (test, "append single");
-	ret = pk_enum_list_append (elist, PK_ACTION_ENUM_SEARCH_NAME);
+	ret = pk_enum_list_append (elist, PK_ROLE_ENUM_SEARCH_NAME);
 	if (ret == TRUE) {
 		libst_success (test, NULL);
 	} else {
@@ -341,7 +341,7 @@ libst_enum_list (LibSelfTest *test)
 
 	/************************************************************/
 	libst_title (test, "add multiple");
-	ret = pk_enum_list_append_multiple (elist, PK_ACTION_ENUM_SEARCH_DETAILS, PK_ACTION_ENUM_SEARCH_GROUP, -1);
+	ret = pk_enum_list_append_multiple (elist, PK_ROLE_ENUM_SEARCH_DETAILS, PK_ACTION_ENUM_SEARCH_GROUP, -1);
 	if (ret == TRUE) {
 		libst_success (test, NULL);
 	} else {
@@ -362,7 +362,7 @@ libst_enum_list (LibSelfTest *test)
 	/************************************************************/
 	libst_title (test, "set none enum list");
 	elist = pk_enum_list_new ();
-	pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
+	pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ROLE);
 	pk_enum_list_from_string (elist, "none");
 	if (elist->priv->data->len == 0) {
 		libst_success (test, NULL);
diff --git a/libpackagekit/pk-enum-list.h b/libpackagekit/pk-enum-list.h
index 8072803..4305851 100644
--- a/libpackagekit/pk-enum-list.h
+++ b/libpackagekit/pk-enum-list.h
@@ -47,7 +47,7 @@ typedef struct
 } PkEnumListClass;
 
 typedef enum {
-	PK_ENUM_LIST_TYPE_ACTION,
+	PK_ENUM_LIST_TYPE_ROLE,
 	PK_ENUM_LIST_TYPE_GROUP,
 	PK_ENUM_LIST_TYPE_FILTER,
 	PK_ENUM_LIST_TYPE_UNKNOWN
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 58bdf20..b5c132c 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -58,6 +58,7 @@ static PkTaskEnumMatch task_status[] = {
 
 static PkTaskEnumMatch task_role[] = {
 	{PK_ROLE_ENUM_UNKNOWN,			"unknown"},	/* fall though value */
+	{PK_ROLE_ENUM_CANCEL,			"cancel"},
 	{PK_ROLE_ENUM_GET_DEPENDS,		"get-depends"},
 	{PK_ROLE_ENUM_GET_UPDATE_DETAIL,	"get-update-detail"},
 	{PK_ROLE_ENUM_GET_DESCRIPTION,		"get-description"},
@@ -123,23 +124,6 @@ static PkTaskEnumMatch task_group[] = {
 	{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:
  */
@@ -314,24 +298,6 @@ pk_filter_enum_to_text (PkFilterEnum fil
 	return pk_task_enum_find_string (task_filter, filter);
 }
 
-/**
- * pk_action_enum_from_text:
- **/
-PkActionEnum
-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 (PkActionEnum action)
-{
-	return pk_task_enum_find_string (task_action, action);
-}
-
 /***************************************************************************
  ***                          MAKE CHECK TESTS                           ***
  ***************************************************************************/
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 3d1bca7..8555aff 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -29,6 +29,7 @@ G_BEGIN_DECLS
 
 /* what we asked to do */
 typedef enum {
+	PK_ROLE_ENUM_CANCEL,
 	PK_ROLE_ENUM_GET_DEPENDS,
 	PK_ROLE_ENUM_GET_UPDATE_DETAIL,
 	PK_ROLE_ENUM_GET_DESCRIPTION,
@@ -112,27 +113,6 @@ typedef enum {
 	PK_GROUP_ENUM_UNKNOWN
 } PkGroupEnum;
 
-typedef enum {
-	PK_ACTION_ENUM_INSTALL = 1,
-	PK_ACTION_ENUM_REMOVE,
-	PK_ACTION_ENUM_UPDATE,
-	PK_ACTION_ENUM_GET_UPDATES,
-	PK_ACTION_ENUM_CANCEL,
-	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
-} PkActionEnum;
-
 PkExitEnum	 pk_exit_enum_from_text			(const gchar	*exit);
 const gchar	*pk_exit_enum_to_text			(PkExitEnum	 exit);
 
@@ -154,9 +134,6 @@ const gchar	*pk_group_enum_to_text			(Pk
 PkFilterEnum	 pk_filter_enum_from_text		(const gchar	*filter);
 const gchar	*pk_filter_enum_to_text			(PkFilterEnum	 filter);
 
-PkActionEnum	 pk_action_enum_from_text		(const gchar	*action);
-const gchar	*pk_action_enum_to_text			(PkActionEnum	 action);
-
 G_END_DECLS
 
 #endif /* __PK_ENUM_H */
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
index f1c8441..ae8562c 100644
--- a/libpackagekit/pk-task-client.c
+++ b/libpackagekit/pk-task-client.c
@@ -924,7 +924,7 @@ pk_task_client_get_actions (PkTaskClient
 	g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
 
 	elist = pk_enum_list_new ();
-	pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
+	pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ROLE);
 
 	error = NULL;
 	ret = dbus_g_proxy_call (tclient->priv->proxy, "GetActions", &error,
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 15ed11d..ce4fd1f 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -1183,48 +1183,48 @@ pk_backend_get_actions (PkBackend *backe
 {
 	PkEnumList *elist;
 	elist = pk_enum_list_new ();
-	pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ACTION);
+	pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ROLE);
 	if (backend->desc->cancel != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_CANCEL);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_CANCEL);
 	}
 	if (backend->desc->get_depends != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_GET_DEPENDS);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_GET_DEPENDS);
 	}
 	if (backend->desc->get_description != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_GET_DESCRIPTION);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_GET_DESCRIPTION);
 	}
 	if (backend->desc->get_requires != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_GET_REQUIRES);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_GET_REQUIRES);
 	}
 	if (backend->desc->get_updates != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_GET_UPDATES);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_GET_UPDATES);
 	}
 	if (backend->desc->install_package != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_INSTALL_PACKAGE);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_PACKAGE_INSTALL);
 	}
 	if (backend->desc->refresh_cache != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_REFRESH_CACHE);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_REFRESH_CACHE);
 	}
 	if (backend->desc->remove_package != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_REMOVE_PACKAGE);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_PACKAGE_REMOVE);
 	}
 	if (backend->desc->search_details != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_SEARCH_DETAILS);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_SEARCH_DETAILS);
 	}
 	if (backend->desc->search_file != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_SEARCH_FILE);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_SEARCH_FILE);
 	}
 	if (backend->desc->search_group != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_SEARCH_GROUP);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_SEARCH_GROUP);
 	}
 	if (backend->desc->search_name != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_SEARCH_NAME);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_SEARCH_NAME);
 	}
 	if (backend->desc->update_package != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_UPDATE_PACKAGE);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_PACKAGE_UPDATE);
 	}
 	if (backend->desc->update_system != NULL) {
-		pk_enum_list_append (elist, PK_ACTION_ENUM_UPDATE_SYSTEM);
+		pk_enum_list_append (elist, PK_ROLE_ENUM_SYSTEM_UPDATE);
 	}
 	return elist;
 }



More information about the PackageKit mailing list