[evolution-data-server] I#87 - [CalDAV] Free/busy request uses wrong format for the time-range



commit 87a1dd69cf69aaf478e28ebfbc96047d72c73544
Author: Milan Crha <mcrha redhat com>
Date:   Thu Feb 21 17:52:48 2019 +0100

    I#87 - [CalDAV] Free/busy request uses wrong format for the time-range
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/issues/87

 .../backends/caldav/e-cal-backend-caldav.c         |  4 +--
 src/libedataserver/e-xml-document.c                | 39 ++++++++++++++++++++++
 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
@@ -578,6 +578,45 @@ e_xml_document_add_attribute_time (EXmlDocument *xml,
        g_free (strvalue);
 }
 
+/**
+ * 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
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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]