summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2015-10-05 21:11:16 +0200
committerMilan Crha <mcrha@redhat.com>2015-10-05 21:12:41 +0200
commit2030e471a26b3b51dc0e911028713028f82de532 (patch)
tree09d193b815158c23eb1f4bccc77a74343a8bdecf
parent3fc24c8d5fee270e384ee5152a9f18b82942066e (diff)
downloadevolution-data-server-2030e471a26b3b51dc0e911028713028f82de532.tar.gz
Bug 732931 - Google CalDAV returns whole calendar on UID comp-filter
-rw-r--r--calendar/backends/caldav/e-cal-backend-caldav.c57
1 files changed, 43 insertions, 14 deletions
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index 8778982bf..5047ef1ba 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -1343,7 +1343,8 @@ compat_libxml_output_buffer_get_content (xmlOutputBufferPtr buf,
* supports 'getctag' extension. */
static gboolean
check_calendar_changed_on_server (ECalBackendCalDAV *cbdav,
- gboolean save_ctag)
+ gboolean save_ctag,
+ GCancellable *cancellable)
{
xmlOutputBufferPtr buf;
SoupMessage *message;
@@ -1394,7 +1395,7 @@ check_calendar_changed_on_server (ECalBackendCalDAV *cbdav,
buf_content, buf_size);
/* Send the request now */
- send_and_handle_redirection (cbdav, message, NULL, NULL, NULL);
+ send_and_handle_redirection (cbdav, message, NULL, cancellable, NULL);
/* Clean up the memory */
xmlOutputBufferClose (buf);
@@ -1446,7 +1447,8 @@ caldav_server_list_objects (ECalBackendCalDAV *cbdav,
gint *len,
GSList *only_hrefs,
time_t start_time,
- time_t end_time)
+ time_t end_time,
+ GCancellable *cancellable)
{
xmlOutputBufferPtr buf;
SoupMessage *message;
@@ -1547,7 +1549,7 @@ caldav_server_list_objects (ECalBackendCalDAV *cbdav,
buf_content, buf_size);
/* Send the request now */
- send_and_handle_redirection (cbdav, message, NULL, NULL, NULL);
+ send_and_handle_redirection (cbdav, message, NULL, cancellable, NULL);
/* Clean up the memory */
xmlOutputBufferClose (buf);
@@ -1585,6 +1587,27 @@ caldav_server_list_objects (ECalBackendCalDAV *cbdav,
return result;
}
+static void
+caldav_synchronize_cache (ECalBackendCalDAV *cbdav,
+ time_t start_time,
+ time_t end_time,
+ gboolean can_check_ctag,
+ GCancellable *cancellable);
+
+static gboolean
+caldav_server_query_google_for_uid (ECalBackendCalDAV *cbdav,
+ const gchar *uid,
+ GCancellable *cancellable,
+ GError **error)
+{
+ if (!check_calendar_changed_on_server (cbdav, FALSE, cancellable))
+ return FALSE;
+
+ caldav_synchronize_cache (cbdav, 0, 0, FALSE, cancellable);
+
+ return !g_cancellable_is_cancelled (cancellable);
+}
+
static gboolean
caldav_server_query_for_uid (ECalBackendCalDAV *cbdav,
const gchar *uid,
@@ -1609,6 +1632,9 @@ caldav_server_query_for_uid (ECalBackendCalDAV *cbdav,
g_return_val_if_fail (E_IS_CAL_BACKEND_CALDAV (cbdav), FALSE);
g_return_val_if_fail (uid && *uid, FALSE);
+ if (cbdav->priv->is_google)
+ return caldav_server_query_google_for_uid (cbdav, uid, cancellable, error);
+
/* Allocate the soup message */
message = soup_message_new ("REPORT", cbdav->priv->uri);
if (message == NULL)
@@ -2293,10 +2319,11 @@ free_comp_list (gpointer cclist)
* be still there.
*/
static void
-synchronize_cache (ECalBackendCalDAV *cbdav,
- time_t start_time,
- time_t end_time,
- gboolean can_check_ctag)
+caldav_synchronize_cache (ECalBackendCalDAV *cbdav,
+ time_t start_time,
+ time_t end_time,
+ gboolean can_check_ctag,
+ GCancellable *cancellable)
{
CalDAVObject *sobjs, *object;
GSList *c_objs, *c_iter; /* list of all items known from our cache */
@@ -2308,7 +2335,7 @@ synchronize_cache (ECalBackendCalDAV *cbdav,
/* intentionally do server-side checking first, and then the bool test,
to store actual ctag value first, and then update the content, to not
do it again the next time this function is called */
- if (!check_calendar_changed_on_server (cbdav, start_time == (time_t) 0) && can_check_ctag) {
+ if (!check_calendar_changed_on_server (cbdav, start_time == (time_t) 0, cancellable) && can_check_ctag) {
/* no changes on the server, no update required */
return;
}
@@ -2317,7 +2344,7 @@ synchronize_cache (ECalBackendCalDAV *cbdav,
sobjs = NULL;
/* get list of server objects */
- if (!caldav_server_list_objects (cbdav, &sobjs, &len, NULL, start_time, end_time))
+ if (!caldav_server_list_objects (cbdav, &sobjs, &len, NULL, start_time, end_time, cancellable))
return;
c_objs = e_cal_backend_store_get_components (cbdav->priv->store);
@@ -2456,7 +2483,7 @@ synchronize_cache (ECalBackendCalDAV *cbdav,
}
count = 0;
- if (!caldav_server_list_objects (cbdav, &up_sobjs, &count, to_fetch, 0, 0)) {
+ if (!caldav_server_list_objects (cbdav, &up_sobjs, &count, to_fetch, 0, 0, cancellable)) {
fprintf (stderr, "CalDAV - failed to retrieve bunch of items\n"); fflush (stderr);
break;
}
@@ -2528,7 +2555,9 @@ is_google_uri (const gchar *uri)
suri = soup_uri_new (uri);
g_return_val_if_fail (suri != NULL, FALSE);
- res = suri->host && g_ascii_strcasecmp (suri->host, "www.google.com") == 0;
+ res = suri->host && (
+ g_ascii_strcasecmp (suri->host, "www.google.com") == 0 ||
+ g_ascii_strcasecmp (suri->host, "apidata.googleusercontent.com") == 0);
soup_uri_free (suri);
@@ -2622,11 +2651,11 @@ caldav_synch_slave_loop (gpointer data)
time (&now);
/* check for events in the month before/after today first,
* to show user actual data as soon as possible */
- synchronize_cache (cbdav, time_add_week_with_zone (now, -5, utc), time_add_week_with_zone (now, +5, utc), can_check_ctag);
+ caldav_synchronize_cache (cbdav, time_add_week_with_zone (now, -5, utc), time_add_week_with_zone (now, +5, utc), can_check_ctag, NULL);
if (cbdav->priv->slave_cmd != SLAVE_SHOULD_SLEEP) {
/* and then check for changes in a whole calendar */
- synchronize_cache (cbdav, 0, 0, can_check_ctag);
+ caldav_synchronize_cache (cbdav, 0, 0, can_check_ctag, NULL);
}
if (caldav_debug_show (DEBUG_SERVER_ITEMS)) {