[gnome-software] trivial: Add two new error values
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Add two new error values
- Date: Fri, 10 Jun 2016 14:04:45 +0000 (UTC)
commit ed73cc8489d7c90bd879fdfe61c807de1a50b2be
Author: Richard Hughes <richard hughsie com>
Date: Fri Jun 10 14:33:46 2016 +0100
trivial: Add two new error values
Also, if we get either of these just stop processing plugins and return the
error as a failure.
src/gs-plugin-loader.c | 25 +++++++++++++++++++++++++
src/gs-plugin.h | 4 ++++
2 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 935e8db..b5eb72d 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -835,6 +835,16 @@ gs_plugin_loader_set_app_error (GsApp *app, GError *error)
}
}
+static gboolean
+gs_plugin_loader_is_auth_error (GError *err)
+{
+ if (g_error_matches (err, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_AUTH_REQUIRED))
+ return TRUE;
+ if (g_error_matches (err, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_AUTH_INVALID))
+ return TRUE;
+ return FALSE;
+}
+
/**
* gs_plugin_loader_run_action:
**/
@@ -883,6 +893,14 @@ gs_plugin_loader_run_action (GsPluginLoader *plugin_loader,
function_name);
continue;
}
+
+ /* abort early to allow main thread to process */
+ if (gs_plugin_loader_is_auth_error (error_local)) {
+ g_propagate_error (error, error_local);
+ error_local = NULL;
+ return FALSE;
+ }
+
g_warning ("failed to call %s on %s: %s",
function_name,
gs_plugin_get_name (plugin),
@@ -2750,6 +2768,13 @@ gs_plugin_loader_review_action_thread_cb (GTask *task,
state->function_name);
continue;
}
+
+ /* abort early to allow main thread to process */
+ if (gs_plugin_loader_is_auth_error (error_local)) {
+ g_task_return_error (task, error_local);
+ error_local = NULL;
+ return;
+ }
g_warning ("failed to call %s on %s: %s",
state->function_name,
gs_plugin_get_name (plugin),
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index 230c4a1..c534f80 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -104,6 +104,8 @@ typedef enum {
* @GS_PLUGIN_ERROR_NO_NETWORK: No network connection available
* @GS_PLUGIN_ERROR_NO_SECURITY: Security policy forbid action
* @GS_PLUGIN_ERROR_NO_SPACE: No disk space to allow action
+ * @GS_PLUGIN_ERROR_AUTH_REQUIRED: Authentication was required
+ * @GS_PLUGIN_ERROR_AUTH_INVALID: Provided authentication was invalid
*
* The failure error types.
**/
@@ -114,6 +116,8 @@ typedef enum {
GS_PLUGIN_ERROR_NO_NETWORK,
GS_PLUGIN_ERROR_NO_SECURITY,
GS_PLUGIN_ERROR_NO_SPACE,
+ GS_PLUGIN_ERROR_AUTH_REQUIRED,
+ GS_PLUGIN_ERROR_AUTH_INVALID,
/*< private >*/
GS_PLUGIN_ERROR_LAST
} GsPluginError;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]