[Commits] [SCM] claws branch, master, updated. 3.14.0-99-g8dc0092
holger at claws-mail.org
holger at claws-mail.org
Thu Sep 29 18:42:03 CEST 2016
The branch, master has been updated
via 8dc0092094239d785c272cfbbf5a74b7035a183d (commit)
via 86e01da0f3528e992f1a6e0874f0a64a81972312 (commit)
from 878fcaeb00a9044d13fc19d7658cd680880531f9 (commit)
Summary of changes:
src/plugins/gdata/cm_gdata_contacts.c | 36 +++++++++++++++++++++++++++------
1 file changed, 30 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit 8dc0092094239d785c272cfbbf5a74b7035a183d
Author: Holger Berndt <berndth at gmx.de>
Date: Wed Sep 28 22:44:00 2016 +0200
GData plugin: Refresh auth token periodically
Fixes bug #3638
diff --git a/src/plugins/gdata/cm_gdata_contacts.c b/src/plugins/gdata/cm_gdata_contacts.c
index b41d17c..5f527c7 100644
--- a/src/plugins/gdata/cm_gdata_contacts.c
+++ b/src/plugins/gdata/cm_gdata_contacts.c
@@ -48,6 +48,8 @@
#define GDATA_C2 "QYjIgZblg/4RMCnEqNQypcHZba9ePqAN"
#define GDATA_C3 "XHEZEgO06YbWfQWOyYhE/ny5Q10aNOZlkQ=="
+#define REFRESH_TIMEOUT_MINUTES 45.0
+
typedef struct
{
@@ -68,6 +70,7 @@ static gboolean cm_gdata_contacts_query_running = FALSE;
static gchar *contacts_group_id = NULL;
static GDataOAuth2Authorizer *authorizer = NULL;
static GDataContactsService *service = NULL;
+static GTimer *refresh_timer = NULL;
static void protect_fields_against_NULL(Contact *contact)
@@ -503,6 +506,8 @@ static void cm_gdata_refresh_ready(GDataOAuth2Authorizer *auth, GAsyncResult *re
log_message(LOG_PROTOCOL, _("GData plugin: Authorization refresh successful\n"));
+ g_timer_start(refresh_timer);
+
query_after_auth();
}
#endif
@@ -523,6 +528,7 @@ static guchar* decode(const gchar *in)
static void query()
{
gchar *token;
+ int elapsed_time_min;
if(cm_gdata_contacts_query_running)
{
@@ -550,7 +556,19 @@ static void query()
}
g_return_if_fail(service);
- if(!gdata_service_is_authorized(GDATA_SERVICE(service)))
+ if(!refresh_timer)
+ {
+ refresh_timer = g_timer_new();
+ }
+ g_return_if_fail(refresh_timer);
+
+ elapsed_time_min = (int)((g_timer_elapsed(refresh_timer, NULL)/60.0)+0.5);
+ if(elapsed_time_min > REFRESH_TIMEOUT_MINUTES)
+ {
+ log_message(LOG_PROTOCOL, _("GData plugin: Elapsed time since last refresh: %d minutes, refreshing now\n"), elapsed_time_min);
+ gdata_authorizer_refresh_authorization_async(GDATA_AUTHORIZER(authorizer), NULL, (GAsyncReadyCallback)cm_gdata_refresh_ready, NULL);
+ }
+ else if(!gdata_service_is_authorized(GDATA_SERVICE(service)))
{
#if GDATA_CHECK_VERSION(0,17,2)
/* Try to restore from saved refresh token.*/
@@ -654,6 +672,12 @@ void cm_gdata_contacts_done(void)
g_object_unref(G_OBJECT(service));
service = NULL;
}
+
+ if(refresh_timer)
+ {
+ g_timer_destroy(refresh_timer);
+ refresh_timer = NULL;
+ }
}
void cm_gdata_load_contacts_cache_from_file(void)
commit 86e01da0f3528e992f1a6e0874f0a64a81972312
Author: Holger Berndt <berndth at gmx.de>
Date: Wed Sep 28 22:22:27 2016 +0200
GData plugin: Make global data static
diff --git a/src/plugins/gdata/cm_gdata_contacts.c b/src/plugins/gdata/cm_gdata_contacts.c
index 0501f6c..b41d17c 100644
--- a/src/plugins/gdata/cm_gdata_contacts.c
+++ b/src/plugins/gdata/cm_gdata_contacts.c
@@ -63,11 +63,11 @@ typedef struct
} CmGDataContactsCache;
-CmGDataContactsCache contacts_cache;
-gboolean cm_gdata_contacts_query_running = FALSE;
-gchar *contacts_group_id = NULL;
-GDataOAuth2Authorizer *authorizer = NULL;
-GDataContactsService *service = NULL;
+static CmGDataContactsCache contacts_cache;
+static gboolean cm_gdata_contacts_query_running = FALSE;
+static gchar *contacts_group_id = NULL;
+static GDataOAuth2Authorizer *authorizer = NULL;
+static GDataContactsService *service = NULL;
static void protect_fields_against_NULL(Contact *contact)
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list