[evolution-data-server] I#121 - CalDAV-advertised subscribed WebCal is not imported
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] I#121 - CalDAV-advertised subscribed WebCal is not imported
- Date: Tue, 4 Jun 2019 20:00:44 +0000 (UTC)
commit 91378c080cd8c352b56986931f9fb4bd1244ec67
Author: Milan Crha <mcrha redhat com>
Date: Tue Jun 4 22:02:13 2019 +0200
I#121 - CalDAV-advertised subscribed WebCal is not imported
Closes https://gitlab.gnome.org/GNOME/evolution-data-server/issues/121
src/libebackend/e-webdav-collection-backend.c | 9 +++++++-
src/libedataserver/e-webdav-discover.c | 26 +++++++++++++---------
src/libedataserver/e-webdav-discover.h | 3 ++-
src/libedataserver/e-webdav-session.c | 29 ++++++++++++++++++++-----
src/libedataserver/e-webdav-session.h | 3 ++-
src/libedataserverui/e-webdav-discover-widget.c | 3 ++-
6 files changed, 54 insertions(+), 19 deletions(-)
---
diff --git a/src/libebackend/e-webdav-collection-backend.c b/src/libebackend/e-webdav-collection-backend.c
index 26b30b2d4..d89fc737e 100644
--- a/src/libebackend/e-webdav-collection-backend.c
+++ b/src/libebackend/e-webdav-collection-backend.c
@@ -89,6 +89,7 @@ webdav_collection_add_found_source (ECollectionBackend *collection,
const gchar *display_name,
const gchar *color,
gboolean calendar_auto_schedule,
+ gboolean is_subscribed_icalendar,
GHashTable *known_sources)
{
ESourceRegistryServer *server;
@@ -135,6 +136,9 @@ webdav_collection_add_found_source (ECollectionBackend *collection,
g_return_if_fail (backend_name != NULL);
+ if (is_subscribed_icalendar && source_type != E_WEBDAV_DISCOVER_SUPPORTS_CONTACTS)
+ provider = "webcal";
+
server = e_collection_backend_ref_server (collection);
if (!server)
return;
@@ -166,7 +170,9 @@ webdav_collection_add_found_source (ECollectionBackend *collection,
child_webdav = e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND);
resource = e_source_get_extension (source, E_SOURCE_EXTENSION_RESOURCE);
- e_source_authentication_set_user (child_auth, e_source_collection_get_identity
(collection_extension));
+ if (!is_subscribed_icalendar)
+ e_source_authentication_set_user (child_auth, e_source_collection_get_identity
(collection_extension));
+
e_source_webdav_set_soup_uri (child_webdav, uri);
e_source_resource_set_identity (resource, identity);
@@ -251,6 +257,7 @@ webdav_collection_process_discovered_sources (ECollectionBackend *collection,
webdav_collection_add_found_source (collection, source_types[ii], soup_uri,
discovered_source->display_name, discovered_source->color,
(discovered_source->supports &
E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE) != 0,
+ (discovered_source->supports &
E_WEBDAV_DISCOVER_SUPPORTS_SUBSCRIBED_ICALENDAR) != 0,
known_sources);
}
diff --git a/src/libedataserver/e-webdav-discover.c b/src/libedataserver/e-webdav-discover.c
index 16ac99ca6..6054b0861 100644
--- a/src/libedataserver/e-webdav-discover.c
+++ b/src/libedataserver/e-webdav-discover.c
@@ -39,6 +39,8 @@ typedef struct _WebDAVDiscoverData {
GError **error;
} WebDAVDiscoverData;
+#define CUSTOM_SUPPORTS_FLAGS (E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE |
E_WEBDAV_DISCOVER_SUPPORTS_SUBSCRIBED_ICALENDAR)
+
static void
e_webdav_discover_split_resources (WebDAVDiscoverData *wdd,
const GSList *resources)
@@ -52,11 +54,12 @@ e_webdav_discover_split_resources (WebDAVDiscoverData *wdd,
if (resource && (
resource->kind == E_WEBDAV_RESOURCE_KIND_ADDRESSBOOK ||
- resource->kind == E_WEBDAV_RESOURCE_KIND_CALENDAR)) {
+ resource->kind == E_WEBDAV_RESOURCE_KIND_CALENDAR ||
+ resource->kind == E_WEBDAV_RESOURCE_KIND_SUBSCRIBED_ICALENDAR)) {
EWebDAVDiscoveredSource *discovered;
- if (resource->kind == E_WEBDAV_RESOURCE_KIND_CALENDAR &&
- (wdd->only_supports & (~E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE)) !=
E_WEBDAV_DISCOVER_SUPPORTS_NONE &&
+ if ((resource->kind == E_WEBDAV_RESOURCE_KIND_CALENDAR || resource->kind ==
E_WEBDAV_RESOURCE_KIND_SUBSCRIBED_ICALENDAR) &&
+ (wdd->only_supports & (~CUSTOM_SUPPORTS_FLAGS)) !=
E_WEBDAV_DISCOVER_SUPPORTS_NONE &&
(resource->supports & wdd->only_supports) == 0)
continue;
@@ -70,6 +73,9 @@ e_webdav_discover_split_resources (WebDAVDiscoverData *wdd,
if (resource->kind == E_WEBDAV_RESOURCE_KIND_ADDRESSBOOK) {
wdd->addressbooks = g_slist_prepend (wdd->addressbooks, discovered);
} else {
+ if (resource->kind == E_WEBDAV_RESOURCE_KIND_SUBSCRIBED_ICALENDAR)
+ discovered->supports |=
E_WEBDAV_DISCOVER_SUPPORTS_SUBSCRIBED_ICALENDAR;
+
wdd->calendars = g_slist_prepend (wdd->calendars, discovered);
}
}
@@ -125,7 +131,7 @@ e_webdav_discover_traverse_propfind_response_cb (EWebDAVSession *webdav,
if (full_href && *full_href && !g_hash_table_contains
(wdd->covered_hrefs, full_href) &&
e_webdav_session_list_sync (webdav, full_href,
E_WEBDAV_DEPTH_THIS_AND_CHILDREN,
E_WEBDAV_LIST_SUPPORTS | E_WEBDAV_LIST_DISPLAY_NAME |
E_WEBDAV_LIST_DESCRIPTION |
- E_WEBDAV_LIST_COLOR | E_WEBDAV_LIST_ONLY_ADDRESSBOOK,
+ E_WEBDAV_LIST_COLOR | E_WEBDAV_LIST_ONLY_ADDRESSBOOK |
E_WEBDAV_LIST_ALL,
&resources, wdd->cancellable, &local_error)) {
e_webdav_discover_split_resources (wdd, resources);
g_slist_free_full (resources, e_webdav_resource_free);
@@ -165,7 +171,7 @@ e_webdav_discover_traverse_propfind_response_cb (EWebDAVSession *webdav,
if (full_href && *full_href && !g_hash_table_contains
(wdd->covered_hrefs, full_href) &&
e_webdav_session_list_sync (webdav, full_href,
E_WEBDAV_DEPTH_THIS_AND_CHILDREN,
E_WEBDAV_LIST_SUPPORTS | E_WEBDAV_LIST_DISPLAY_NAME |
E_WEBDAV_LIST_DESCRIPTION |
- E_WEBDAV_LIST_COLOR | E_WEBDAV_LIST_ONLY_CALENDAR,
+ E_WEBDAV_LIST_COLOR | E_WEBDAV_LIST_ONLY_CALENDAR |
E_WEBDAV_LIST_ALL,
&resources, wdd->cancellable, &local_error)) {
e_webdav_discover_split_resources (wdd, resources);
g_slist_free_full (resources, e_webdav_resource_free);
@@ -259,7 +265,7 @@ e_webdav_discover_traverse_propfind_response_cb (EWebDAVSession *webdav,
!g_cancellable_is_cancelled (wdd->cancellable) &&
e_webdav_session_list_sync (webdav, href, E_WEBDAV_DEPTH_THIS,
E_WEBDAV_LIST_SUPPORTS | E_WEBDAV_LIST_DISPLAY_NAME |
E_WEBDAV_LIST_DESCRIPTION | E_WEBDAV_LIST_COLOR |
- (is_calendar ? E_WEBDAV_LIST_ONLY_CALENDAR : 0) | (is_addressbook ?
E_WEBDAV_LIST_ONLY_ADDRESSBOOK : 0),
+ (is_calendar ? E_WEBDAV_LIST_ONLY_CALENDAR : 0) | (is_addressbook ?
E_WEBDAV_LIST_ONLY_ADDRESSBOOK : 0) | E_WEBDAV_LIST_ALL,
&resources, wdd->cancellable, &local_error)) {
e_webdav_discover_split_resources (wdd, resources);
g_slist_free_full (resources, e_webdav_resource_free);
@@ -307,13 +313,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_CALENDAR_AUTO_SCHEDULE)) ==
E_WEBDAV_DISCOVER_SUPPORTS_NONE ||
+ if (((wdd->only_supports & (~CUSTOM_SUPPORTS_FLAGS)) == 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_CALENDAR_AUTO_SCHEDULE)) ==
E_WEBDAV_DISCOVER_SUPPORTS_NONE ||
+ if (((wdd->only_supports & (~CUSTOM_SUPPORTS_FLAGS)) == 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");
}
@@ -858,7 +864,7 @@ 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_CALENDAR_AUTO_SCHEDULE)) ==
E_WEBDAV_DISCOVER_SUPPORTS_NONE ||
+ ((only_supports & (~CUSTOM_SUPPORTS_FLAGS)) == 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;
@@ -887,7 +893,7 @@ e_webdav_discover_sources_full_sync (ESource *source,
}
if (!g_cancellable_is_cancelled (cancellable) && !wdd.addressbooks &&
- ((only_supports & (~E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE)) ==
E_WEBDAV_DISCOVER_SUPPORTS_NONE ||
+ ((only_supports & (~CUSTOM_SUPPORTS_FLAGS)) == 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;
diff --git a/src/libedataserver/e-webdav-discover.h b/src/libedataserver/e-webdav-discover.h
index a9df5c98f..623df891b 100644
--- a/src/libedataserver/e-webdav-discover.h
+++ b/src/libedataserver/e-webdav-discover.h
@@ -35,7 +35,8 @@ typedef enum {
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
+ E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE = E_WEBDAV_RESOURCE_SUPPORTS_LAST << 1,
+ E_WEBDAV_DISCOVER_SUPPORTS_SUBSCRIBED_ICALENDAR = E_WEBDAV_DISCOVER_SUPPORTS_CALENDAR_AUTO_SCHEDULE
<< 1
} EWebDAVDiscoverSupports;
typedef struct _EWebDAVDiscoveredSource {
diff --git a/src/libedataserver/e-webdav-session.c b/src/libedataserver/e-webdav-session.c
index accf5db31..00535b9db 100644
--- a/src/libedataserver/e-webdav-session.c
+++ b/src/libedataserver/e-webdav-session.c
@@ -3367,6 +3367,12 @@ e_webdav_session_extract_kind (xmlXPathContextPtr xpath_ctx,
if (e_xml_xpath_eval_exists (xpath_ctx, "%s/D:resourcetype/C:calendar", xpath_prop_prefix))
return E_WEBDAV_RESOURCE_KIND_CALENDAR;
+ /* These are subscribed iCalendar files, aka 'On The Web' calendars */
+ if (e_xml_xpath_eval_exists (xpath_ctx, "%s/D:resourcetype/D:collection", xpath_prop_prefix) &&
+ e_xml_xpath_eval_exists (xpath_ctx, "%s/D:resourcetype/CS:subscribed", xpath_prop_prefix) &&
+ e_xml_xpath_eval_exists (xpath_ctx, "%s/CS:source/D:href", xpath_prop_prefix))
+ return E_WEBDAV_RESOURCE_KIND_SUBSCRIBED_ICALENDAR;
+
if (e_xml_xpath_eval_exists (xpath_ctx, "%s/D:resourcetype/D:principal", xpath_prop_prefix))
return E_WEBDAV_RESOURCE_KIND_PRINCIPAL;
@@ -3547,11 +3553,19 @@ e_webdav_session_list_cb (EWebDAVSession *webdav,
glong last_modified;
gchar *description;
gchar *color;
+ gchar *source_href = NULL;
kind = e_webdav_session_extract_kind (xpath_ctx, xpath_prop_prefix);
if (kind == E_WEBDAV_RESOURCE_KIND_UNKNOWN)
return TRUE;
+ if (kind == E_WEBDAV_RESOURCE_KIND_SUBSCRIBED_ICALENDAR) {
+ source_href = e_webdav_session_extract_nonempty (xpath_ctx, xpath_prop_prefix,
"CS:source/D:href", NULL);
+
+ if (!source_href)
+ return TRUE;
+ }
+
supports = e_webdav_session_extract_supports (xpath_ctx, xpath_prop_prefix);
etag = e_webdav_session_extract_nonempty (xpath_ctx, xpath_prop_prefix, "D:getetag",
"CS:getctag");
display_name = e_webdav_session_extract_nonempty (xpath_ctx, xpath_prop_prefix,
"D:displayname", NULL);
@@ -3563,7 +3577,7 @@ e_webdav_session_list_cb (EWebDAVSession *webdav,
color = e_webdav_session_extract_nonempty (xpath_ctx, xpath_prop_prefix, "IC:calendar-color",
NULL);
resource = e_webdav_resource_new (kind, supports,
- href,
+ source_href ? source_href : href,
NULL, /* etag */
NULL, /* display_name */
NULL, /* content_type */
@@ -3579,6 +3593,8 @@ e_webdav_session_list_cb (EWebDAVSession *webdav,
resource->color = color;
*out_resources = g_slist_prepend (*out_resources, resource);
+
+ g_free (source_href);
}
return TRUE;
@@ -3641,6 +3657,12 @@ e_webdav_session_list_sync (EWebDAVSession *webdav,
e_xml_document_add_empty_element (xml, NULL, "resourcetype");
+ if (calendar_props) {
+ e_xml_document_add_namespaces (xml, "CS", E_WEBDAV_NS_CALENDARSERVER, NULL);
+
+ e_xml_document_add_empty_element (xml, E_WEBDAV_NS_CALENDARSERVER, "source");
+ }
+
if (calendar_props && (
(flags & E_WEBDAV_LIST_SUPPORTS) != 0 ||
(flags & E_WEBDAV_LIST_DESCRIPTION) != 0 ||
@@ -3659,11 +3681,8 @@ e_webdav_session_list_sync (EWebDAVSession *webdav,
if ((flags & E_WEBDAV_LIST_ETAG) != 0) {
e_xml_document_add_empty_element (xml, NULL, "getetag");
- if (calendar_props) {
- e_xml_document_add_namespaces (xml, "CS", E_WEBDAV_NS_CALENDARSERVER, NULL);
-
+ if (calendar_props)
e_xml_document_add_empty_element (xml, E_WEBDAV_NS_CALENDARSERVER, "getctag");
- }
}
if ((flags & E_WEBDAV_LIST_CONTENT_TYPE) != 0) {
diff --git a/src/libedataserver/e-webdav-session.h b/src/libedataserver/e-webdav-session.h
index 397078506..a542d0d77 100644
--- a/src/libedataserver/e-webdav-session.h
+++ b/src/libedataserver/e-webdav-session.h
@@ -87,7 +87,8 @@ typedef enum {
E_WEBDAV_RESOURCE_KIND_CALENDAR,
E_WEBDAV_RESOURCE_KIND_PRINCIPAL,
E_WEBDAV_RESOURCE_KIND_COLLECTION,
- E_WEBDAV_RESOURCE_KIND_RESOURCE
+ E_WEBDAV_RESOURCE_KIND_RESOURCE,
+ E_WEBDAV_RESOURCE_KIND_SUBSCRIBED_ICALENDAR
} EWebDAVResourceKind;
typedef enum {
diff --git a/src/libedataserverui/e-webdav-discover-widget.c b/src/libedataserverui/e-webdav-discover-widget.c
index 83444d2db..1c5facfbd 100644
--- a/src/libedataserverui/e-webdav-discover-widget.c
+++ b/src/libedataserverui/e-webdav-discover-widget.c
@@ -473,7 +473,8 @@ e_webdav_discover_content_fill_discovered_sources (GtkTreeView *tree_view,
gboolean show_color = FALSE;
GdkRGBA rgba;
- if (!source || (supports_filter && (source->supports & supports_filter) == 0) ||
!source->display_name)
+ if (!source || (supports_filter && (source->supports & supports_filter) == 0) ||
!source->display_name ||
+ (source->supports & E_WEBDAV_DISCOVER_SUPPORTS_SUBSCRIBED_ICALENDAR) != 0)
continue;
if (source->color && *source->color) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]