summaryrefslogtreecommitdiff
path: root/libedataserver
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-04-15 18:54:41 -0400
committerMatthew Barnes <mbarnes@redhat.com>2013-04-15 19:07:07 -0400
commit5115e6118bc030d2437d7fa73bb50f1fd31e28d3 (patch)
treed23069bcd907f37e28e20c774776269e1d0dd196 /libedataserver
parent965c0f3ccae57035730161fe9baf6aaf42b97c5f (diff)
downloadevolution-data-server-5115e6118bc030d2437d7fa73bb50f1fd31e28d3.tar.gz
Automatically strip D-Bus info from error messages.
I mistakenly assumed code generated by the gdbus-codegen tool would automatically strip off the D-Bus error name from error messages, but that apparently is not possible according to my discussion with David Zeuthen in [1], since it would break g_dbus_error_is_remote_error(). Distinguishing between local and remote errors strikes me as a rarely needed corner case, and is certainly not worth the extra step imposed on applications when dealing with something as fundamental as GError. This commit prevents the D-Bus error name from leaking through in any Evolution-Data-Server client-facing library functions. Also rename any stack-allocated GError pointers to 'local_error' to help distinguish them from GError "out" parameters which are always named 'error'. This is just to improve variable name consistency. [1] https://bugzilla.gnome.org/697819
Diffstat (limited to 'libedataserver')
-rw-r--r--libedataserver/e-source-registry.c118
-rw-r--r--libedataserver/e-source.c163
2 files changed, 167 insertions, 114 deletions
diff --git a/libedataserver/e-source-registry.c b/libedataserver/e-source-registry.c
index 6c4f2fdad..5ad52cbd3 100644
--- a/libedataserver/e-source-registry.c
+++ b/libedataserver/e-source-registry.c
@@ -125,7 +125,6 @@ struct _AuthContext {
ESourceAuthenticationResult auth_result;
GcrSecretExchange *secret_exchange;
gboolean authenticating;
- gboolean success;
GError **error;
};
@@ -564,24 +563,24 @@ source_registry_new_source (ESourceRegistry *registry,
GMainContext *main_context;
ESource *source;
const gchar *object_path;
- GError *error = NULL;
+ GError *local_error = NULL;
/* We don't want the ESource emitting "changed" signals from
* the manager thread, so we pass it the same main context the
* registry uses for scheduling signal emissions. */
main_context = registry->priv->main_context;
- source = e_source_new (dbus_object, main_context, &error);
+ source = e_source_new (dbus_object, main_context, &local_error);
object_path = g_dbus_object_get_object_path (dbus_object);
/* The likelihood of an error here is slim, so it's
* sufficient to just print a warning if one occurs. */
- if (error != NULL) {
+ if (local_error != NULL) {
g_warn_if_fail (source == NULL);
g_critical (
"ESourceRegistry: Failed to create a "
"data source object for path '%s': %s",
- object_path, error->message);
- g_error_free (error);
+ object_path, local_error->message);
+ g_error_free (local_error);
return NULL;
}
@@ -1048,6 +1047,7 @@ source_registry_initable_init (GInitable *initable,
{
ESourceRegistry *registry;
ThreadClosure *closure;
+ GError *local_error = NULL;
registry = E_SOURCE_REGISTRY (initable);
@@ -1082,6 +1082,7 @@ source_registry_initable_init (GInitable *initable,
/* Check for error in the manager thread. */
if (closure->error != NULL) {
+ g_dbus_error_strip_remote_error (closure->error);
g_propagate_error (error, closure->error);
closure->error = NULL;
return FALSE;
@@ -1115,10 +1116,13 @@ source_registry_initable_init (GInitable *initable,
G_DBUS_PROXY_FLAGS_NONE,
SOURCES_DBUS_SERVICE_NAME,
DBUS_OBJECT_PATH,
- cancellable, error);
+ cancellable, &local_error);
- if (registry->priv->dbus_source_manager == NULL)
+ if (local_error != NULL) {
+ g_dbus_error_strip_remote_error (local_error);
+ g_propagate_error (error, local_error);
return FALSE;
+ }
/* Allow authentication prompts for all exported data sources
* when a new EDBusSourceManagerProxy is created. The thought
@@ -1459,7 +1463,7 @@ source_registry_authenticate_thread (GSimpleAsyncResult *simple,
GCancellable *cancellable)
{
AsyncContext *async_context;
- GError *error = NULL;
+ GError *local_error = NULL;
async_context = g_simple_async_result_get_op_res_gpointer (simple);
@@ -1467,10 +1471,10 @@ source_registry_authenticate_thread (GSimpleAsyncResult *simple,
E_SOURCE_REGISTRY (object),
async_context->source,
async_context->auth,
- cancellable, &error);
+ cancellable, &local_error);
- if (error != NULL)
- g_simple_async_result_take_error (simple, error);
+ if (local_error != NULL)
+ g_simple_async_result_take_error (simple, local_error);
}
/* Helper for e_source_registry_authenticate_sync() */
@@ -1507,7 +1511,6 @@ source_registry_authenticate_respond_cb (AuthContext *auth_context)
auth_context->dbus_auth,
NULL, &non_fatal_error);
g_main_loop_quit (auth_context->main_loop);
- auth_context->success = FALSE;
/* If an error occurred while attempting to authenticate,
* tell the server to cancel the authentication session. */
@@ -1517,7 +1520,6 @@ source_registry_authenticate_respond_cb (AuthContext *auth_context)
auth_context->cancellable,
&non_fatal_error);
g_main_loop_quit (auth_context->main_loop);
- auth_context->success = FALSE;
/* If the password was accepted, let the server know so it
* can close any authentication dialogs and save the user
@@ -1528,7 +1530,6 @@ source_registry_authenticate_respond_cb (AuthContext *auth_context)
auth_context->cancellable,
&non_fatal_error);
g_main_loop_quit (auth_context->main_loop);
- auth_context->success = TRUE;
/* If the password was rejected, let the server know so it can
* indicate failure and request a different password, and then
@@ -1543,6 +1544,7 @@ source_registry_authenticate_respond_cb (AuthContext *auth_context)
/* Leave breadcrumbs if something went wrong,
* but don't fail the whole operation over it. */
if (non_fatal_error != NULL) {
+ g_dbus_error_strip_remote_error (non_fatal_error);
g_warning ("%s: %s", G_STRFUNC, non_fatal_error->message);
g_error_free (non_fatal_error);
}
@@ -1621,7 +1623,6 @@ source_registry_authenticate_dismissed_cb (EDBusAuthenticator *dbus_auth,
}
g_main_loop_quit (auth_context->main_loop);
- auth_context->success = FALSE;
}
/* Helper for e_source_registry_authenticate_sync() */
@@ -1638,7 +1639,7 @@ source_registry_call_authenticate_for_source (ESourceRegistry *registry,
gchar *prompt_title = NULL;
gchar *prompt_message = NULL;
gchar *prompt_description = NULL;
- gboolean success;
+ GError *local_error = NULL;
g_object_ref (source);
@@ -1685,10 +1686,10 @@ source_registry_call_authenticate_for_source (ESourceRegistry *registry,
&prompt_message,
&prompt_description);
- success = e_dbus_source_manager_call_authenticate_sync (
+ e_dbus_source_manager_call_authenticate_sync (
registry->priv->dbus_source_manager, uid,
prompt_title, prompt_message, prompt_description,
- out_object_path, cancellable, error);
+ out_object_path, cancellable, &local_error);
g_free (prompt_title);
g_free (prompt_message);
@@ -1696,7 +1697,13 @@ source_registry_call_authenticate_for_source (ESourceRegistry *registry,
g_object_unref (source);
- return success;
+ if (local_error != NULL) {
+ g_dbus_error_strip_remote_error (local_error);
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
}
/**
@@ -1735,7 +1742,7 @@ e_source_registry_authenticate_sync (ESourceRegistry *registry,
EDBusAuthenticator *dbus_auth;
gchar *encryption_key;
gchar *object_path = NULL;
- gboolean success;
+ GError *local_error = NULL;
g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FALSE);
g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
@@ -1744,11 +1751,13 @@ e_source_registry_authenticate_sync (ESourceRegistry *registry,
/* This extracts authentication prompt details for the ESource
* before initiating an authentication session with the server,
* so split it out of the main algorithm for clarity's sake. */
- success = source_registry_call_authenticate_for_source (
- registry, auth, source, &object_path, cancellable, error);
+ source_registry_call_authenticate_for_source (
+ registry, auth, source, &object_path,
+ cancellable, &local_error);
- if (!success) {
+ if (local_error != NULL) {
g_warn_if_fail (object_path == NULL);
+ g_propagate_error (error, local_error);
return FALSE;
}
@@ -1761,20 +1770,23 @@ e_source_registry_authenticate_sync (ESourceRegistry *registry,
G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
SOURCES_DBUS_SERVICE_NAME,
- object_path, cancellable, error);
+ object_path, cancellable, &local_error);
g_free (object_path);
- if (dbus_auth == NULL) {
- success = FALSE;
+ /* Sanity check. */
+ g_return_val_if_fail (
+ ((dbus_auth != NULL) && (local_error == NULL)) ||
+ ((dbus_auth == NULL) && (local_error != NULL)), FALSE);
+
+ if (local_error != NULL)
goto exit;
- }
auth_context = g_slice_new0 (AuthContext);
auth_context->auth = g_object_ref (auth);
auth_context->dbus_auth = dbus_auth; /* takes ownership */
auth_context->main_loop = g_main_loop_new (main_context, FALSE);
- auth_context->error = error;
+ auth_context->error = &local_error;
/* This just needs to be something other than
* E_SOURCE_AUTHENTICATION_ERROR so we don't trip
@@ -1804,15 +1816,13 @@ e_source_registry_authenticate_sync (ESourceRegistry *registry,
* authentication session. This must happen AFTER we've
* connected to the response signal since the server may
* already have a response ready and waiting for us. */
- success = e_dbus_authenticator_call_ready_sync (
- dbus_auth, encryption_key, cancellable, error);
+ e_dbus_authenticator_call_ready_sync (
+ dbus_auth, encryption_key, cancellable, &local_error);
g_free (encryption_key);
- if (success) {
+ if (local_error == NULL)
g_main_loop_run (auth_context->main_loop);
- success = auth_context->success;
- }
auth_context_free (auth_context);
@@ -1826,7 +1836,13 @@ exit:
g_main_context_unref (main_context);
- return success;
+ if (local_error != NULL) {
+ g_dbus_error_strip_remote_error (local_error);
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
}
/**
@@ -1929,17 +1945,17 @@ source_registry_commit_source_thread (GSimpleAsyncResult *simple,
GCancellable *cancellable)
{
AsyncContext *async_context;
- GError *error = NULL;
+ GError *local_error = NULL;
async_context = g_simple_async_result_get_op_res_gpointer (simple);
e_source_registry_commit_source_sync (
E_SOURCE_REGISTRY (object),
async_context->source,
- cancellable, &error);
+ cancellable, &local_error);
- if (error != NULL)
- g_simple_async_result_take_error (simple, error);
+ if (local_error != NULL)
+ g_simple_async_result_take_error (simple, local_error);
}
/**
@@ -2100,17 +2116,17 @@ source_registry_create_sources_thread (GSimpleAsyncResult *simple,
GCancellable *cancellable)
{
AsyncContext *async_context;
- GError *error = NULL;
+ GError *local_error = NULL;
async_context = g_simple_async_result_get_op_res_gpointer (simple);
e_source_registry_create_sources_sync (
E_SOURCE_REGISTRY (object),
async_context->list_of_sources,
- cancellable, &error);
+ cancellable, &local_error);
- if (error != NULL)
- g_simple_async_result_take_error (simple, error);
+ if (local_error != NULL)
+ g_simple_async_result_take_error (simple, local_error);
}
/* Helper for e_source_registry_create_sources_sync() */
@@ -2185,7 +2201,7 @@ e_source_registry_create_sources_sync (ESourceRegistry *registry,
GVariant *variant;
GList *link;
gulong object_added_id;
- gboolean success;
+ GError *local_error = NULL;
g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FALSE);
@@ -2225,9 +2241,9 @@ e_source_registry_create_sources_sync (ESourceRegistry *registry,
create_context);
/* This function sinks the floating GVariant reference. */
- success = e_dbus_source_manager_call_create_sources_sync (
+ e_dbus_source_manager_call_create_sources_sync (
registry->priv->dbus_source_manager,
- variant, cancellable, error);
+ variant, cancellable, &local_error);
g_variant_builder_clear (&builder);
@@ -2235,7 +2251,7 @@ e_source_registry_create_sources_sync (ESourceRegistry *registry,
* But also set a short timeout to avoid getting stuck here in
* case the registry service adds sources to its orphan table,
* which prevents them from being exported over D-Bus. */
- if (success) {
+ if (local_error == NULL) {
GSource *timeout_source;
timeout_source = g_timeout_source_new_seconds (2);
@@ -2256,7 +2272,13 @@ e_source_registry_create_sources_sync (ESourceRegistry *registry,
g_main_context_pop_thread_default (create_context->main_context);
create_context_free (create_context);
- return success;
+ if (local_error != NULL) {
+ g_dbus_error_strip_remote_error (local_error);
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
}
/**
diff --git a/libedataserver/e-source.c b/libedataserver/e-source.c
index 5f9d8c84d..365974e10 100644
--- a/libedataserver/e-source.c
+++ b/libedataserver/e-source.c
@@ -387,7 +387,7 @@ source_set_property_from_key_file (GObject *object,
{
gchar *key;
GValue *value;
- GError *error = NULL;
+ GError *local_error = NULL;
value = g_slice_new0 (GValue);
key = e_source_parameter_to_key (pspec->name);
@@ -401,8 +401,8 @@ source_set_property_from_key_file (GObject *object,
gint v_int;
v_int = g_key_file_get_integer (
- key_file, group_name, key, &error);
- if (error == NULL) {
+ key_file, group_name, key, &local_error);
+ if (local_error == NULL) {
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, v_int);
}
@@ -411,8 +411,8 @@ source_set_property_from_key_file (GObject *object,
gint64 v_int64;
v_int64 = g_key_file_get_int64 (
- key_file, group_name, key, &error);
- if (error == NULL) {
+ key_file, group_name, key, &local_error);
+ if (local_error == NULL) {
g_value_init (value, G_TYPE_INT64);
g_value_set_int64 (value, v_int64);
}
@@ -422,8 +422,8 @@ source_set_property_from_key_file (GObject *object,
gchar *v_str;
v_str = g_key_file_get_string (
- key_file, group_name, key, &error);
- if (error == NULL) {
+ key_file, group_name, key, &local_error);
+ if (local_error == NULL) {
v_uint64 = g_ascii_strtoull (v_str, NULL, 16);
g_value_init (value, G_TYPE_UINT64);
@@ -436,8 +436,8 @@ source_set_property_from_key_file (GObject *object,
gboolean v_boolean;
v_boolean = g_key_file_get_boolean (
- key_file, group_name, key, &error);
- if (error == NULL) {
+ key_file, group_name, key, &local_error);
+ if (local_error == NULL) {
g_value_init (value, G_TYPE_BOOLEAN);
g_value_set_boolean (value, v_boolean);
}
@@ -446,8 +446,8 @@ source_set_property_from_key_file (GObject *object,
gchar *nick;
nick = g_key_file_get_string (
- key_file, group_name, key, &error);
- if (error == NULL) {
+ key_file, group_name, key, &local_error);
+ if (local_error == NULL) {
GParamSpecEnum *enum_pspec;
GEnumValue *enum_value;
@@ -466,8 +466,8 @@ source_set_property_from_key_file (GObject *object,
gdouble v_double;
v_double = g_key_file_get_double (
- key_file, group_name, key, &error);
- if (error == NULL) {
+ key_file, group_name, key, &local_error);
+ if (local_error == NULL) {
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, v_double);
}
@@ -477,8 +477,8 @@ source_set_property_from_key_file (GObject *object,
/* Get the localized string if present. */
v_string = g_key_file_get_locale_string (
- key_file, group_name, key, NULL, &error);
- if (error == NULL) {
+ key_file, group_name, key, NULL, &local_error);
+ if (local_error == NULL) {
g_value_init (value, G_TYPE_STRING);
g_value_take_string (value, v_string);
}
@@ -487,8 +487,8 @@ source_set_property_from_key_file (GObject *object,
gchar **strv;
strv = g_key_file_get_string_list (
- key_file, group_name, key, NULL, &error);
- if (error == NULL) {
+ key_file, group_name, key, NULL, &local_error);
+ if (local_error == NULL) {
g_value_init (value, G_TYPE_STRV);
g_value_take_boxed (value, strv);
}
@@ -498,8 +498,8 @@ source_set_property_from_key_file (GObject *object,
/* Create the GFile from the URI string. */
uri = g_key_file_get_locale_string (
- key_file, group_name, key, NULL, &error);
- if (error == NULL) {
+ key_file, group_name, key, NULL, &local_error);
+ if (local_error == NULL) {
GFile *file = NULL;
if (uri != NULL && *uri != '\0')
file = g_file_new_for_uri (uri);
@@ -516,10 +516,10 @@ source_set_property_from_key_file (GObject *object,
/* If a value could not be retrieved from the key
* file, restore the property to its default value. */
- if (error != NULL) {
+ if (local_error != NULL) {
g_value_init (value, pspec->value_type);
g_param_value_set_default (pspec, value);
- g_error_free (error);
+ g_error_free (local_error);
}
if (G_IS_VALUE (value)) {
@@ -646,17 +646,18 @@ source_notify_dbus_data_cb (EDBusSource *dbus_source,
GParamSpec *pspec,
ESource *source)
{
- GError *error = NULL;
+ GError *local_error = NULL;
g_rec_mutex_lock (&source->priv->lock);
/* Since the source data came from a GKeyFile structure on the
* server-side, this should never fail. But we'll print error
* messages to the terminal just in case. */
- if (!source_parse_dbus_data (source, &error)) {
- g_return_if_fail (error != NULL);
- g_warning ("%s", error->message);
- g_error_free (error);
+ source_parse_dbus_data (source, &local_error);
+
+ if (local_error != NULL) {
+ g_warning ("%s", local_error->message);
+ g_error_free (local_error);
}
g_rec_mutex_unlock (&source->priv->lock);
@@ -926,7 +927,7 @@ source_remove_sync (ESource *source,
{
EDBusSourceRemovable *dbus_interface = NULL;
GDBusObject *dbus_object;
- gboolean success;
+ GError *local_error = NULL;
dbus_object = e_source_ref_dbus_object (source);
if (dbus_object != NULL) {
@@ -945,12 +946,18 @@ source_remove_sync (ESource *source,
return FALSE;
}
- success = e_dbus_source_removable_call_remove_sync (
- dbus_interface, cancellable, error);
+ e_dbus_source_removable_call_remove_sync (
+ dbus_interface, cancellable, &local_error);
g_object_unref (dbus_interface);
- return success;
+ if (local_error != NULL) {
+ g_dbus_error_strip_remote_error (local_error);
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
}
/* Helper for source_remove() */
@@ -959,12 +966,12 @@ source_remove_thread (GSimpleAsyncResult *simple,
GObject *object,
GCancellable *cancellable)
{
- GError *error = NULL;
+ GError *local_error = NULL;
- e_source_remove_sync (E_SOURCE (object), cancellable, &error);
+ e_source_remove_sync (E_SOURCE (object), cancellable, &local_error);
- if (error != NULL)
- g_simple_async_result_take_error (simple, error);
+ if (local_error != NULL)
+ g_simple_async_result_take_error (simple, local_error);
}
static void
@@ -1011,8 +1018,8 @@ source_write_sync (ESource *source,
{
EDBusSourceWritable *dbus_interface = NULL;
GDBusObject *dbus_object;
- gboolean success;
gchar *data;
+ GError *local_error = NULL;
dbus_object = e_source_ref_dbus_object (source);
if (dbus_object != NULL) {
@@ -1033,14 +1040,20 @@ source_write_sync (ESource *source,
data = e_source_to_string (source, NULL);
- success = e_dbus_source_writable_call_write_sync (
- dbus_interface, data, cancellable, error);
+ e_dbus_source_writable_call_write_sync (
+ dbus_interface, data, cancellable, &local_error);
g_free (data);
g_object_unref (dbus_interface);
- return success;
+ if (local_error != NULL) {
+ g_dbus_error_strip_remote_error (local_error);
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
}
/* Helper for source_write() */
@@ -1049,12 +1062,12 @@ source_write_thread (GSimpleAsyncResult *simple,
GObject *object,
GCancellable *cancellable)
{
- GError *error = NULL;
+ GError *local_error = NULL;
- e_source_write_sync (E_SOURCE (object), cancellable, &error);
+ e_source_write_sync (E_SOURCE (object), cancellable, &local_error);
- if (error != NULL)
- g_simple_async_result_take_error (simple, error);
+ if (local_error != NULL)
+ g_simple_async_result_take_error (simple, local_error);
}
static void
@@ -1103,7 +1116,7 @@ source_remote_create_sync (ESource *source,
EDBusSourceRemoteCreatable *dbus_interface = NULL;
GDBusObject *dbus_object;
gchar *uid, *data;
- gboolean success;
+ GError *local_error = NULL;
dbus_object = e_source_ref_dbus_object (source);
if (dbus_object != NULL) {
@@ -1126,15 +1139,21 @@ source_remote_create_sync (ESource *source,
uid = e_source_dup_uid (scratch_source);
data = e_source_to_string (scratch_source, NULL);
- success = e_dbus_source_remote_creatable_call_create_sync (
- dbus_interface, uid, data, cancellable, error);
+ e_dbus_source_remote_creatable_call_create_sync (
+ dbus_interface, uid, data, cancellable, &local_error);
g_free (data);
g_free (uid);
g_object_unref (dbus_interface);
- return success;
+ if (local_error != NULL) {
+ g_dbus_error_strip_remote_error (local_error);
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
}
/* Helper for source_remote_create() */
@@ -1144,17 +1163,17 @@ source_remote_create_thread (GSimpleAsyncResult *simple,
GCancellable *cancellable)
{
AsyncContext *async_context;
- GError *error = NULL;
+ GError *local_error = NULL;
async_context = g_simple_async_result_get_op_res_gpointer (simple);
e_source_remote_create_sync (
E_SOURCE (object),
async_context->scratch_source,
- cancellable, &error);
+ cancellable, &local_error);
- if (error != NULL)
- g_simple_async_result_take_error (simple, error);
+ if (local_error != NULL)
+ g_simple_async_result_take_error (simple, local_error);
}
static void
@@ -1210,7 +1229,7 @@ source_remote_delete_sync (ESource *source,
{
EDBusSourceRemoteDeletable *dbus_interface = NULL;
GDBusObject *dbus_object;
- gboolean success;
+ GError *local_error = NULL;
dbus_object = e_source_ref_dbus_object (source);
if (dbus_object != NULL) {
@@ -1230,12 +1249,18 @@ source_remote_delete_sync (ESource *source,
return FALSE;
}
- success = e_dbus_source_remote_deletable_call_delete_sync (
- dbus_interface, cancellable, error);
+ e_dbus_source_remote_deletable_call_delete_sync (
+ dbus_interface, cancellable, &local_error);
g_object_unref (dbus_interface);
- return success;
+ if (local_error != NULL) {
+ g_dbus_error_strip_remote_error (local_error);
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
}
/* Helper for source_remote_delete() */
@@ -1244,13 +1269,13 @@ source_remote_delete_thread (GSimpleAsyncResult *simple,
GObject *object,
GCancellable *cancellable)
{
- GError *error = NULL;
+ GError *local_error = NULL;
e_source_remote_delete_sync (
- E_SOURCE (object), cancellable, &error);
+ E_SOURCE (object), cancellable, &local_error);
- if (error != NULL)
- g_simple_async_result_take_error (simple, error);
+ if (local_error != NULL)
+ g_simple_async_result_take_error (simple, local_error);
}
static void
@@ -1300,7 +1325,7 @@ source_get_oauth2_access_token_sync (ESource *source,
{
EDBusSourceOAuth2Support *dbus_interface = NULL;
GDBusObject *dbus_object;
- gboolean success;
+ GError *local_error = NULL;
dbus_object = e_source_ref_dbus_object (source);
if (dbus_object != NULL) {
@@ -1320,13 +1345,19 @@ source_get_oauth2_access_token_sync (ESource *source,
return FALSE;
}
- success = e_dbus_source_oauth2_support_call_get_access_token_sync (
+ e_dbus_source_oauth2_support_call_get_access_token_sync (
dbus_interface, out_access_token,
- out_expires_in, cancellable, error);
+ out_expires_in, cancellable, &local_error);
g_object_unref (dbus_interface);
- return success;
+ if (local_error != NULL) {
+ g_dbus_error_strip_remote_error (local_error);
+ g_propagate_error (error, local_error);
+ return FALSE;
+ }
+
+ return TRUE;
}
/* Helper for source_get_oauth2_access_token() */
@@ -1336,7 +1367,7 @@ source_get_oauth2_access_token_thread (GSimpleAsyncResult *simple,
GCancellable *cancellable)
{
AsyncContext *async_context;
- GError *error = NULL;
+ GError *local_error = NULL;
async_context = g_simple_async_result_get_op_res_gpointer (simple);
@@ -1344,10 +1375,10 @@ source_get_oauth2_access_token_thread (GSimpleAsyncResult *simple,
E_SOURCE (object), cancellable,
&async_context->access_token,
&async_context->expires_in,
- &error);
+ &local_error);
- if (error != NULL)
- g_simple_async_result_take_error (simple, error);
+ if (local_error != NULL)
+ g_simple_async_result_take_error (simple, local_error);
}
static void