[evolution-data-server] I#42 - [Collection CalDAV] Populate calendar-auto-schedule for discovered sources
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] I#42 - [Collection CalDAV] Populate calendar-auto-schedule for discovered sources
- Date: Wed, 10 Oct 2018 16:22:38 +0000 (UTC)
commit 16d08e10d85d24d5e48743ba0aee536465e72a3c
Author: Milan Crha <mcrha redhat com>
Date: Wed Oct 10 18:22:50 2018 +0200
I#42 - [Collection CalDAV] Populate calendar-auto-schedule for discovered sources
Closes https://gitlab.gnome.org/GNOME/evolution-data-server/issues/42
src/libebackend/e-webdav-collection-backend.c | 33 ++++++++++++++---------
src/libedataserver/e-webdav-discover.c | 38 ++++++++++++++++++++++-----
src/libedataserver/e-webdav-discover.h | 12 +++++----
src/libedataserver/e-webdav-session.h | 3 ++-
4 files changed, 60 insertions(+), 26 deletions(-)
---
diff --git a/src/libebackend/e-webdav-collection-backend.c b/src/libebackend/e-webdav-collection-backend.c
index ce9feacfb..bcf00ec8e 100644
--- a/src/libebackend/e-webdav-collection-backend.c
+++ b/src/libebackend/e-webdav-collection-backend.c
@@ -88,6 +88,7 @@ webdav_collection_add_found_source (ECollectionBackend *collection,
SoupURI *uri,
const gchar *display_name,
const gchar *color,
+ gboolean calendar_auto_schedule,
GHashTable *known_sources)
{
ESourceRegistryServer *server;
@@ -195,21 +196,25 @@ webdav_collection_add_found_source (ECollectionBackend *collection,
e_source_webdav_set_display_name (webdav_extension, display_name);
e_source_set_enabled (source, TRUE);
- /* Also check whether the color format is as expected; it cannot
- be used gdk_rgba_parse here, because it required gdk/gtk. */
- if (source_type != E_WEBDAV_DISCOVER_SUPPORTS_CONTACTS && color &&
- sscanf (color, "#%02x%02x%02x", &rr, &gg, &bb) == 3) {
- gchar *safe_color;
+ if (source_type != E_WEBDAV_DISCOVER_SUPPORTS_CONTACTS) {
+ /* Also check whether the color format is as expected; cannot
+ use gdk_rgba_parse() here, because it requires gdk/gtk. */
+ if (color && sscanf (color, "#%02x%02x%02x", &rr, &gg, &bb) == 3) {
+ gchar *safe_color;
- /* In case an #RRGGBBAA is returned */
- safe_color = g_strdup_printf ("#%02x%02x%02x", rr, gg, bb);
+ /* In case an #RRGGBBAA is returned */
+ safe_color = g_strdup_printf ("#%02x%02x%02x", rr, gg, bb);
- if (is_new || g_strcmp0 (e_source_webdav_get_color (webdav_extension),
e_source_selectable_get_color (E_SOURCE_SELECTABLE (backend))) == 0)
- e_source_selectable_set_color (E_SOURCE_SELECTABLE (backend), safe_color);
+ if (is_new || g_strcmp0 (e_source_webdav_get_color (webdav_extension),
e_source_selectable_get_color (E_SOURCE_SELECTABLE (backend))) == 0)
+ e_source_selectable_set_color (E_SOURCE_SELECTABLE (backend),
safe_color);
- e_source_webdav_set_color (webdav_extension, safe_color);
+ e_source_webdav_set_color (webdav_extension, safe_color);
- g_free (safe_color);
+ g_free (safe_color);
+ }
+
+ if (is_new && calendar_auto_schedule)
+ e_source_webdav_set_calendar_auto_schedule (webdav_extension, TRUE);
}
if (is_new)
@@ -245,7 +250,9 @@ webdav_collection_process_discovered_sources (ECollectionBackend *collection,
for (ii = 0; ii < n_source_types; ii++) {
if ((discovered_source->supports & source_types[ii]) == source_types[ii])
webdav_collection_add_found_source (collection, source_types[ii], soup_uri,
- discovered_source->display_name, discovered_source->color,
known_sources);
+ discovered_source->display_name, discovered_source->color,
+ (discovered_source->supports &
E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE) != 0,
+ known_sources);
}
soup_uri_free (soup_uri);
@@ -502,7 +509,7 @@ e_webdav_collection_backend_discover_sync (EWebDAVCollectionBackend *webdav_back
if (e_source_collection_get_calendar_enabled (collection_extension) && calendar_url &&
e_webdav_discover_sources_full_sync (source, calendar_url,
- E_WEBDAV_DISCOVER_SUPPORTS_EVENTS | E_WEBDAV_DISCOVER_SUPPORTS_MEMOS |
E_WEBDAV_DISCOVER_SUPPORTS_TASKS,
+ E_WEBDAV_DISCOVER_SUPPORTS_EVENTS | E_WEBDAV_DISCOVER_SUPPORTS_MEMOS |
E_WEBDAV_DISCOVER_SUPPORTS_TASKS | E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE,
credentials, (EWebDAVDiscoverRefSourceFunc) e_source_registry_server_ref_source, server,
out_certificate_pem, out_certificate_errors, &discovered_sources, NULL, cancellable,
&local_error)) {
EWebDAVDiscoverSupports source_types[] = {
diff --git a/src/libedataserver/e-webdav-discover.c b/src/libedataserver/e-webdav-discover.c
index dd3378d3d..986cd49c2 100644
--- a/src/libedataserver/e-webdav-discover.c
+++ b/src/libedataserver/e-webdav-discover.c
@@ -56,7 +56,7 @@ e_webdav_discover_split_resources (WebDAVDiscoverData *wdd,
EWebDAVDiscoveredSource *discovered;
if (resource->kind == E_WEBDAV_RESOURCE_KIND_CALENDAR &&
- wdd->only_supports != E_WEBDAV_DISCOVER_SUPPORTS_NONE &&
+ (wdd->only_supports & (~E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE)) !=
E_WEBDAV_DISCOVER_SUPPORTS_NONE &&
(resource->supports & wdd->only_supports) == 0)
continue;
@@ -281,13 +281,13 @@ e_webdav_discover_propfind_uri_sync (EWebDAVSession *webdav,
e_xml_document_add_empty_element (xml, E_WEBDAV_NS_DAV, "principal-URL");
}
- if ((wdd->only_supports == E_WEBDAV_DISCOVER_SUPPORTS_NONE ||
+ if (((wdd->only_supports & (~E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE)) ==
E_WEBDAV_DISCOVER_SUPPORTS_NONE ||
(wdd->only_supports & (E_WEBDAV_DISCOVER_SUPPORTS_EVENTS | E_WEBDAV_DISCOVER_SUPPORTS_MEMOS |
E_WEBDAV_DISCOVER_SUPPORTS_TASKS)) != 0)) {
e_xml_document_add_empty_element (xml, E_WEBDAV_NS_CALDAV, "calendar-home-set");
e_xml_document_add_empty_element (xml, E_WEBDAV_NS_CALDAV, "calendar-user-address-set");
}
- if ((wdd->only_supports == E_WEBDAV_DISCOVER_SUPPORTS_NONE ||
+ if (((wdd->only_supports & (~E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE)) ==
E_WEBDAV_DISCOVER_SUPPORTS_NONE ||
(wdd->only_supports & (E_WEBDAV_DISCOVER_SUPPORTS_CONTACTS)) != 0)) {
e_xml_document_add_empty_element (xml, E_WEBDAV_NS_CARDDAV, "addressbook-home-set");
}
@@ -826,9 +826,10 @@ e_webdav_discover_sources_full_sync (ESource *source,
g_free (uri);
- if (!g_cancellable_is_cancelled (cancellable) && !wdd.calendars && (only_supports ==
E_WEBDAV_DISCOVER_SUPPORTS_NONE ||
- (only_supports & (E_WEBDAV_DISCOVER_SUPPORTS_EVENTS | E_WEBDAV_DISCOVER_SUPPORTS_MEMOS |
E_WEBDAV_DISCOVER_SUPPORTS_TASKS)) != 0) &&
- (!soup_uri_get_path (soup_uri) || !strstr (soup_uri_get_path (soup_uri),
"/.well-known/"))) {
+ if (!g_cancellable_is_cancelled (cancellable) && !wdd.calendars &&
+ ((only_supports & (~E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE)) ==
E_WEBDAV_DISCOVER_SUPPORTS_NONE ||
+ (only_supports & (E_WEBDAV_DISCOVER_SUPPORTS_EVENTS | E_WEBDAV_DISCOVER_SUPPORTS_MEMOS |
E_WEBDAV_DISCOVER_SUPPORTS_TASKS)) != 0) &&
+ (!soup_uri_get_path (soup_uri) || !strstr (soup_uri_get_path (soup_uri),
"/.well-known/"))) {
gchar *saved_path;
GError *local_error_2nd = NULL;
@@ -854,7 +855,8 @@ e_webdav_discover_sources_full_sync (ESource *source,
wdd.error = NULL;
}
- if (!g_cancellable_is_cancelled (cancellable) && !wdd.addressbooks && (only_supports ==
E_WEBDAV_DISCOVER_SUPPORTS_NONE ||
+ if (!g_cancellable_is_cancelled (cancellable) && !wdd.addressbooks &&
+ ((only_supports & (~E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE)) ==
E_WEBDAV_DISCOVER_SUPPORTS_NONE ||
(only_supports & (E_WEBDAV_DISCOVER_SUPPORTS_CONTACTS)) != 0) &&
(!soup_uri_get_path (soup_uri) || !strstr (soup_uri_get_path (soup_uri),
"/.well-known/"))) {
gchar *saved_path;
@@ -890,6 +892,28 @@ e_webdav_discover_sources_full_sync (ESource *source,
}
if (out_discovered_sources) {
+ if (only_supports == E_WEBDAV_DISCOVER_SUPPORTS_NONE ||
+ (only_supports & E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE) != 0) {
+ GSList *link;
+
+ for (link = wdd.calendars; link && !g_cancellable_is_cancelled (cancellable);
link = g_slist_next (link)) {
+ EWebDAVDiscoveredSource *discovered = link->data;
+ GHashTable *allows = NULL, *capabilities = NULL;
+
+ if (discovered && discovered->href &&
+ e_webdav_session_options_sync (webdav, discovered->href,
&capabilities, &allows, cancellable, NULL)) {
+ if (capabilities && g_hash_table_contains (capabilities,
E_WEBDAV_CAPABILITY_CALENDAR_AUTO_SCHEDULE))
+ discovered->supports |=
E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE;
+ }
+
+ if (allows)
+ g_hash_table_destroy (allows);
+
+ if (capabilities)
+ g_hash_table_destroy (capabilities);
+ }
+ }
+
if (wdd.calendars)
*out_discovered_sources = g_slist_concat (*out_discovered_sources,
wdd.calendars);
if (wdd.addressbooks)
diff --git a/src/libedataserver/e-webdav-discover.h b/src/libedataserver/e-webdav-discover.h
index 860499c75..a9df5c98f 100644
--- a/src/libedataserver/e-webdav-discover.h
+++ b/src/libedataserver/e-webdav-discover.h
@@ -25,15 +25,17 @@
#include <glib.h>
#include <libedataserver/e-source.h>
+#include <libedataserver/e-webdav-session.h>
G_BEGIN_DECLS
typedef enum {
- E_WEBDAV_DISCOVER_SUPPORTS_NONE = 0,
- E_WEBDAV_DISCOVER_SUPPORTS_CONTACTS = 1 << 0,
- E_WEBDAV_DISCOVER_SUPPORTS_EVENTS = 1 << 1,
- E_WEBDAV_DISCOVER_SUPPORTS_MEMOS = 1 << 2,
- E_WEBDAV_DISCOVER_SUPPORTS_TASKS = 1 << 3
+ E_WEBDAV_DISCOVER_SUPPORTS_NONE = E_WEBDAV_RESOURCE_SUPPORTS_NONE,
+ E_WEBDAV_DISCOVER_SUPPORTS_CONTACTS = E_WEBDAV_RESOURCE_SUPPORTS_CONTACTS,
+ E_WEBDAV_DISCOVER_SUPPORTS_EVENTS = E_WEBDAV_RESOURCE_SUPPORTS_EVENTS,
+ E_WEBDAV_DISCOVER_SUPPORTS_MEMOS = E_WEBDAV_RESOURCE_SUPPORTS_MEMOS,
+ E_WEBDAV_DISCOVER_SUPPORTS_TASKS = E_WEBDAV_RESOURCE_SUPPORTS_TASKS,
+ E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE = E_WEBDAV_RESOURCE_SUPPORTS_LAST << 1
} EWebDAVDiscoverSupports;
typedef struct _EWebDAVDiscoveredSource {
diff --git a/src/libedataserver/e-webdav-session.h b/src/libedataserver/e-webdav-session.h
index 0c7eb5450..6d9683214 100644
--- a/src/libedataserver/e-webdav-session.h
+++ b/src/libedataserver/e-webdav-session.h
@@ -97,7 +97,8 @@ typedef enum {
E_WEBDAV_RESOURCE_SUPPORTS_MEMOS = 1 << 2,
E_WEBDAV_RESOURCE_SUPPORTS_TASKS = 1 << 3,
E_WEBDAV_RESOURCE_SUPPORTS_FREEBUSY = 1 << 4,
- E_WEBDAV_RESOURCE_SUPPORTS_TIMEZONE = 1 << 5
+ E_WEBDAV_RESOURCE_SUPPORTS_TIMEZONE = 1 << 5,
+ E_WEBDAV_RESOURCE_SUPPORTS_LAST = E_WEBDAV_RESOURCE_SUPPORTS_TIMEZONE
} EWebDAVResourceSupports;
typedef struct _EWebDAVResource {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]