diff options
author | Milan Crha <mcrha@redhat.com> | 2019-02-21 17:52:48 +0100 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2019-02-21 17:54:20 +0100 |
commit | 87a1dd69cf69aaf478e28ebfbc96047d72c73544 (patch) | |
tree | 3e8b99a8ce3bf85632903c70d7c9346c6f4ac9ad | |
parent | c8e7bbc533170fd94eb220f760a3ec4c24599cc6 (diff) | |
download | evolution-data-server-87a1dd69cf69aaf478e28ebfbc96047d72c73544.tar.gz |
I#87 - [CalDAV] Free/busy request uses wrong format for the time-range
Closes https://gitlab.gnome.org/GNOME/evolution-data-server/issues/87
-rw-r--r-- | src/calendar/backends/caldav/e-cal-backend-caldav.c | 4 | ||||
-rw-r--r-- | src/libedataserver/e-xml-document.c | 39 | ||||
-rw-r--r-- | src/libedataserver/e-xml-document.h | 5 |
3 files changed, 46 insertions, 2 deletions
diff --git a/src/calendar/backends/caldav/e-cal-backend-caldav.c b/src/calendar/backends/caldav/e-cal-backend-caldav.c index 39ab6c24f..9c1914a8f 100644 --- a/src/calendar/backends/caldav/e-cal-backend-caldav.c +++ b/src/calendar/backends/caldav/e-cal-backend-caldav.c @@ -1913,8 +1913,8 @@ ecb_caldav_get_free_busy_from_principal_sync (ECalBackendCalDAV *cbdav, xml = e_xml_document_new (E_WEBDAV_NS_CALDAV, "free-busy-query"); e_xml_document_start_element (xml, NULL, "time-range"); - e_xml_document_add_attribute_time (xml, NULL, "start", start); - e_xml_document_add_attribute_time (xml, NULL, "end", end); + e_xml_document_add_attribute_time_ical (xml, NULL, "start", start); + e_xml_document_add_attribute_time_ical (xml, NULL, "end", end); e_xml_document_end_element (xml); /* time-range */ success = e_webdav_session_report_sync (webdav, href, E_WEBDAV_DEPTH_INFINITY, xml, NULL, NULL, &content_type, &content, cancellable, error); diff --git a/src/libedataserver/e-xml-document.c b/src/libedataserver/e-xml-document.c index 74f4ad5dc..9bb54e7da 100644 --- a/src/libedataserver/e-xml-document.c +++ b/src/libedataserver/e-xml-document.c @@ -579,6 +579,45 @@ e_xml_document_add_attribute_time (EXmlDocument *xml, } /** + * e_xml_document_add_attribute_time_ical: + * @xml: an #EXmlDocument + * @ns_href: (nullable): optional namespace href for the new attribute, or %NULL + * @name: name of the attribute + * @value: time_t value of the attribute + * + * Adds a new attribute with a time_t value in iCalendar format to the current element. + * The format is "YYYYMMDDTHHMMSSZ". + * Use %NULL @ns_href, to use the default namespace, otherwise either previously + * added namespace with the same href from e_xml_document_add_namespaces() is picked, + * or a new namespace with generated prefix is added. + * + * Since: 3.32 + **/ +void +e_xml_document_add_attribute_time_ical (EXmlDocument *xml, + const gchar *ns_href, + const gchar *name, + time_t value) +{ + GDateTime *dt; + gchar *strvalue; + + g_return_if_fail (E_IS_XML_DOCUMENT (xml)); + g_return_if_fail (xml->priv->current_element != NULL); + g_return_if_fail (name != NULL); + + dt = g_date_time_new_from_unix_utc ((gint64) value); + g_return_if_fail (dt != NULL); + + strvalue = g_date_time_format (dt, "%Y%m%dT%H%M%SZ"); + + g_date_time_unref (dt); + + e_xml_document_add_attribute (xml, ns_href, name, strvalue); + g_free (strvalue); +} + +/** * e_xml_document_write_int: * @xml: an #EXmlDocument * @value: value to write as the content diff --git a/src/libedataserver/e-xml-document.h b/src/libedataserver/e-xml-document.h index b4177c56e..9ea3f77f3 100644 --- a/src/libedataserver/e-xml-document.h +++ b/src/libedataserver/e-xml-document.h @@ -114,6 +114,11 @@ void e_xml_document_add_attribute_time const gchar *ns_href, const gchar *name, time_t value); +void e_xml_document_add_attribute_time_ical + (EXmlDocument *xml, + const gchar *ns_href, + const gchar *name, + time_t value); void e_xml_document_write_int (EXmlDocument *xml, gint64 value); void e_xml_document_write_double (EXmlDocument *xml, |