talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 70d4cce5c4200119be1a50ce23b1c227c0056f67
parent a6913537c97260ec3e51914e66f4443b61fe81a0
Author: Holger Berndt <hb@claws-mail.org>
Date:   Mon, 25 Jun 2018 23:22:26 +0200

GData plugin: Request interactive auth only in case of auth issues

At the same time, make (now potentially ignored) errors more visible
in the status bar in the same way as background mail fetching errors
are reported.

Fixes bug #3754
Modified version of the patch by Viacheslav Gagara on that bug report.

Diffstat:
Msrc/plugins/gdata/cm_gdata_contacts.c | 18+++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/plugins/gdata/cm_gdata_contacts.c b/src/plugins/gdata/cm_gdata_contacts.c @@ -501,6 +501,7 @@ static void cm_gdata_interactive_auth() static void cm_gdata_refresh_ready(GDataOAuth2Authorizer *auth, GAsyncResult *res, gpointer data) { GError *error = NULL; + gboolean start_interactive_auth = FALSE; if(gdata_authorizer_refresh_authorization_finish(GDATA_AUTHORIZER(auth), res, &error) == FALSE) { @@ -508,10 +509,25 @@ static void cm_gdata_refresh_ready(GDataOAuth2Authorizer *auth, GAsyncResult *re if(!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { log_error(LOG_PROTOCOL, _("GData plugin: Authorization refresh error: %s\n"), error->message); + + if(mainwindow_get_mainwindow()) + { + mainwindow_show_error(); + } } + + /* Only start an interactive auth session in case of authorization issues, but not + * for e.g. sporadic network issues or other non-authorization-related problems. */ + start_interactive_auth = + g_error_matches(error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED) || + g_error_matches(error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_FORBIDDEN); + g_error_free(error); - cm_gdata_interactive_auth(); + if(start_interactive_auth) + { + cm_gdata_interactive_auth(); + } return; }