[gnome-software] Use GsPluginError in the plugin loader
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Use GsPluginError in the plugin loader
- Date: Thu, 19 May 2016 10:08:21 +0000 (UTC)
commit 750438435e8fce9a9bf4ee3a2388ab61698bf5d1
Author: Richard Hughes <richard hughsie com>
Date: Wed May 18 22:04:35 2016 +0100
Use GsPluginError in the plugin loader
We don't actually need our own quark.
src/gs-plugin-loader.c | 46 ++++++++++++++++++++--------------------------
src/gs-plugin-loader.h | 9 ---------
src/gs-shell-details.c | 4 ++--
src/gs-shell-extras.c | 12 ++++++------
4 files changed, 28 insertions(+), 43 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 43836de..b46259a 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -158,12 +158,6 @@ gs_plugin_loader_free_async_state (GsPluginLoaderAsyncState *state)
}
/**
- * gs_plugin_loader_error_quark:
- * Return value: Our personal error quark.
- **/
-G_DEFINE_QUARK (gs-plugin-loader-error-quark, gs_plugin_loader_error)
-
-/**
* gs_plugin_loader_app_sort_cb:
**/
static gint
@@ -849,8 +843,8 @@ gs_plugin_loader_run_action (GsPluginLoader *plugin_loader,
/* nothing ran */
if (!anything_ran) {
g_set_error (error,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_NOT_SUPPORTED,
"no plugin could handle %s",
function_name);
return FALSE;
@@ -1666,8 +1660,8 @@ gs_plugin_loader_search_thread_cb (GTask *task,
values = as_utils_search_tokenize (state->value);
if (values == NULL) {
g_task_return_new_error (task,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_NOT_SUPPORTED,
"no valid search terms");
return;
}
@@ -1732,8 +1726,8 @@ gs_plugin_loader_search_thread_cb (GTask *task,
gs_app_list_filter (state->list, gs_plugin_loader_get_app_is_compatible, plugin_loader);
if (gs_app_list_length (state->list) > 500) {
g_task_return_new_error (task,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_NOT_SUPPORTED,
"Too many search results returned");
return;
}
@@ -1895,8 +1889,8 @@ gs_plugin_loader_search_files_thread_cb (GTask *task,
gs_app_list_filter (state->list, gs_plugin_loader_get_app_is_compatible, plugin_loader);
if (gs_app_list_length (state->list) > 500) {
g_task_return_new_error (task,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_NOT_SUPPORTED,
"Too many search results returned");
return;
}
@@ -2058,8 +2052,8 @@ gs_plugin_loader_search_what_provides_thread_cb (GTask *task,
gs_app_list_filter (state->list, gs_plugin_loader_get_app_is_compatible, plugin_loader);
if (gs_app_list_length (state->list) > 500) {
g_task_return_new_error (task,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_NOT_SUPPORTED,
"Too many search results returned");
return;
}
@@ -2236,8 +2230,8 @@ gs_plugin_loader_get_categories_thread_cb (GTask *task,
/* success */
if (state->catlist->len == 0) {
g_task_return_new_error (task,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED,
"no categories to show");
return;
}
@@ -2690,8 +2684,8 @@ gs_plugin_loader_review_action_thread_cb (GTask *task,
/* nothing ran */
if (!anything_ran) {
g_set_error (&error,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_NOT_SUPPORTED,
"no plugin could handle %s",
state->function_name);
g_task_return_error (task, error);
@@ -3393,8 +3387,8 @@ gs_plugin_loader_setup (GsPluginLoader *plugin_loader,
/* check we're not stuck */
if (dep_loop_check++ > 100) {
g_set_error (error,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED,
"got stuck in dep loop");
return FALSE;
}
@@ -3768,8 +3762,8 @@ gs_plugin_loader_run_refresh (GsPluginLoader *plugin_loader,
/* nothing ran */
if (!anything_ran) {
g_set_error (error,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_NOT_SUPPORTED,
"no plugin could handle refresh");
return FALSE;
}
@@ -3966,8 +3960,8 @@ gs_plugin_loader_file_to_app_thread_cb (GTask *task,
/* success */
if (gs_app_list_length (state->list) != 1) {
g_task_return_new_error (task,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED,
"no application was created for %s",
g_file_get_path (state->file));
return;
diff --git a/src/gs-plugin-loader.h b/src/gs-plugin-loader.h
index d8f6284..f14e50c 100644
--- a/src/gs-plugin-loader.h
+++ b/src/gs-plugin-loader.h
@@ -31,7 +31,6 @@
G_BEGIN_DECLS
#define GS_TYPE_PLUGIN_LOADER (gs_plugin_loader_get_type ())
-#define GS_PLUGIN_LOADER_ERROR (gs_plugin_loader_error_quark ())
G_DECLARE_DERIVABLE_TYPE (GsPluginLoader, gs_plugin_loader, GS, PLUGIN_LOADER, GObject)
@@ -45,12 +44,6 @@ struct _GsPluginLoaderClass
void (*updates_changed) (GsPluginLoader *plugin_loader);
};
-typedef enum
-{
- GS_PLUGIN_LOADER_ERROR_FAILED,
- GS_PLUGIN_LOADER_ERROR_LAST
-} GsPluginLoaderError;
-
typedef enum {
GS_PLUGIN_LOADER_ACTION_INSTALL,
GS_PLUGIN_LOADER_ACTION_REMOVE,
@@ -70,8 +63,6 @@ typedef void (*GsPluginLoaderFinishedFunc) (GsPluginLoader *plugin_loader,
GsApp *app,
gpointer user_data);
-GQuark gs_plugin_loader_error_quark (void);
-
GsPluginLoader *gs_plugin_loader_new (void);
void gs_plugin_loader_get_installed_async (GsPluginLoader *plugin_loader,
GsPluginRefineFlags flags,
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index f89c977..d92282f 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -1375,8 +1375,8 @@ gs_shell_details_file_to_app_cb (GObject *source,
const gchar *msg;
if (g_error_matches (error,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED)) {
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_NOT_SUPPORTED)) {
/* TRANSLATORS: the file format was not recognised by
* any plugin, e.g. if you try installing a .tar.gz */
msg = _("The file is not supported.");
diff --git a/src/gs-shell-extras.c b/src/gs-shell-extras.c
index aaf4b90..b407d97 100644
--- a/src/gs-shell-extras.c
+++ b/src/gs-shell-extras.c
@@ -527,8 +527,8 @@ search_files_cb (GObject *source_object,
return;
}
if (g_error_matches (error,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED)) {
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED)) {
GsApp *app;
g_debug ("extras: no search result for %s, showing as missing", search_data->title);
@@ -578,8 +578,8 @@ file_to_app_cb (GObject *source_object,
return;
}
if (g_error_matches (error,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED)) {
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED)) {
g_debug ("extras: no search result for %s, showing as missing", search_data->title);
app = create_missing_app (search_data);
} else {
@@ -625,8 +625,8 @@ get_search_what_provides_cb (GObject *source_object,
return;
}
if (g_error_matches (error,
- GS_PLUGIN_LOADER_ERROR,
- GS_PLUGIN_LOADER_ERROR_FAILED)) {
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED)) {
GsApp *app;
g_debug ("extras: no search result for %s, showing as missing", search_data->title);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]