commit e038e256b53afd1b711cca6a52a61d10907bb058
parent c28ed2b99d428e4b363c60afc7fb7721b8b50859
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:
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;
}