[evolution-data-server/gnome-3-22] Bug 775699 - Only latest 100 tasks downloaded from the Google
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-22] Bug 775699 - Only latest 100 tasks downloaded from the Google
- Date: Mon, 27 Feb 2017 10:19:12 +0000 (UTC)
commit 682e27517890fe3582a94b104d328f97d5eff8a3
Author: Milan Crha <mcrha redhat com>
Date: Mon Feb 27 11:17:38 2017 +0100
Bug 775699 - Only latest 100 tasks downloaded from the Google
calendar/backends/gtasks/e-cal-backend-gtasks.c | 55 ++++++++++++++++++-----
configure.ac | 2 +-
2 files changed, 44 insertions(+), 13 deletions(-)
---
diff --git a/calendar/backends/gtasks/e-cal-backend-gtasks.c b/calendar/backends/gtasks/e-cal-backend-gtasks.c
index d381ad6..9250af0 100644
--- a/calendar/backends/gtasks/e-cal-backend-gtasks.c
+++ b/calendar/backends/gtasks/e-cal-backend-gtasks.c
@@ -36,8 +36,13 @@
#define EDC_ERROR_EX(_code, _msg) e_data_cal_create_error (_code, _msg)
#define GTASKS_KEY_LAST_UPDATED "last-updated"
+#define GTASKS_KEY_VERSION "version"
#define X_EVO_GTASKS_SELF_LINK "X-EVOLUTION-GTASKS-SELF-LINK"
+/* Current data version; when doesn't match with the stored,
+ then fetches everything again. */
+#define GTASKS_DATA_VERSION "1"
+
#define PROPERTY_LOCK(_gtasks) g_mutex_lock (&(_gtasks)->priv->property_mutex)
#define PROPERTY_UNLOCK(_gtasks) g_mutex_unlock (&(_gtasks)->priv->property_mutex)
@@ -55,6 +60,26 @@ struct _ECalBackendGTasksPrivate {
G_DEFINE_TYPE (ECalBackendGTasks, e_cal_backend_gtasks, E_TYPE_CAL_BACKEND)
+static gboolean
+ecb_gtasks_check_data_version_locked (ECalBackendGTasks *gtasks)
+{
+ const gchar *key;
+ gboolean data_version_correct;
+
+ g_return_val_if_fail (E_IS_CAL_BACKEND_GTASKS (gtasks), FALSE);
+
+ key = e_cal_backend_store_get_key_value (gtasks->priv->store, GTASKS_KEY_VERSION);
+ data_version_correct = g_strcmp0 (key, GTASKS_DATA_VERSION) == 0;
+
+ return data_version_correct;
+}
+
+static void
+ecb_gtasks_store_data_version_locked (ECalBackendGTasks *gtasks)
+{
+ e_cal_backend_store_put_key_value (gtasks->priv->store, GTASKS_KEY_VERSION, GTASKS_DATA_VERSION);
+}
+
static GCancellable *
ecb_gtasks_ref_cancellable (ECalBackendGTasks *gtasks)
{
@@ -438,9 +463,13 @@ ecb_gtasks_update_thread (gpointer user_data)
PROPERTY_LOCK (gtasks);
- key = e_cal_backend_store_get_key_value (gtasks->priv->store, GTASKS_KEY_LAST_UPDATED);
- if (!key || !g_time_val_from_iso8601 (key, &last_updated))
+ if (ecb_gtasks_check_data_version_locked (gtasks)) {
+ key = e_cal_backend_store_get_key_value (gtasks->priv->store, GTASKS_KEY_LAST_UPDATED);
+ if (!key || !g_time_val_from_iso8601 (key, &last_updated))
+ last_updated.tv_sec = 0;
+ } else {
last_updated.tv_sec = 0;
+ }
PROPERTY_UNLOCK (gtasks);
@@ -464,7 +493,6 @@ ecb_gtasks_update_thread (gpointer user_data)
#ifdef HAVE_LIBGDATA_TASKS_PAGINATION_FUNCTIONS
while (feed && !g_cancellable_is_cancelled (cancellable) && !local_error) {
- const gchar *next_page_token;
#else
if (feed) {
#endif
@@ -540,11 +568,10 @@ ecb_gtasks_update_thread (gpointer user_data)
PROPERTY_UNLOCK (gtasks);
#ifdef HAVE_LIBGDATA_TASKS_PAGINATION_FUNCTIONS
- next_page_token = gdata_feed_get_next_page_token (feed);
- if (!next_page_token || !*next_page_token)
+ if (!gdata_feed_get_entries (feed))
break;
- gdata_tasks_query_set_page_token (tasks_query, next_page_token);
+ gdata_query_next_page (GDATA_QUERY (tasks_query));
g_clear_object (&feed);
@@ -568,6 +595,8 @@ ecb_gtasks_update_thread (gpointer user_data)
e_cal_backend_store_put_key_value (gtasks->priv->store, GTASKS_KEY_LAST_UPDATED, strtm);
g_free (strtm);
+ ecb_gtasks_store_data_version_locked (gtasks);
+
PROPERTY_UNLOCK (gtasks);
}
@@ -616,14 +645,16 @@ ecb_gtasks_start_update (ECalBackendGTasks *gtasks)
taskslist_time = gdata_entry_get_updated (entry);
if (taskslist_time > 0) {
- GTimeVal stored;
- const gchar *key;
-
PROPERTY_LOCK (gtasks);
- key = e_cal_backend_store_get_key_value (gtasks->priv->store,
GTASKS_KEY_LAST_UPDATED);
- if (key && g_time_val_from_iso8601 (key, &stored))
- changed = taskslist_time != stored.tv_sec;
+ if (ecb_gtasks_check_data_version_locked (gtasks)) {
+ GTimeVal stored;
+ const gchar *key;
+
+ key = e_cal_backend_store_get_key_value (gtasks->priv->store,
GTASKS_KEY_LAST_UPDATED);
+ if (key && g_time_val_from_iso8601 (key, &stored))
+ changed = taskslist_time != stored.tv_sec;
+ }
PROPERTY_UNLOCK (gtasks);
}
diff --git a/configure.ac b/configure.ac
index b2cd3a0..b62bd40 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1618,7 +1618,7 @@ if test "x$enable_google" = xyes; then
save_libs=$LIBS; LIBS="$GDATA_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <gdata/gdata.h>]],
- [[const gchar *next_page_token; next_page_token = gdata_feed_get_next_page_token (NULL);
gdata_tasks_query_set_page_token (NULL, next_page_token);]])],
+ [[gdata_feed_get_next_page_token (NULL); gdata_query_next_page (NULL);]])],
[AC_DEFINE(HAVE_LIBGDATA_TASKS_PAGINATION_FUNCTIONS, 1, [Define to 1 when the libgdata
provides GTasks pagination functions]) ac_cv_have_gdgtpf=yes],[ac_cv_have_gdgtpf=no])
CFLAGS=$save_cflags
LIBS=$save_libs
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]