[evolution-ews] Implement ewscal_set_reccurence_exception() - A function that adds a list of excluded occurrences in



commit c2fc5ce673a0cc0aefc97b354d1c9d7041ae525b
Author: Or Goshen <orx goshen intel com>
Date:   Sun May 22 12:23:18 2011 +0300

    Implement ewscal_set_reccurence_exception() - A function that adds a list of excluded occurrences in element DeletedOccurrences in a SOAP message

 src/calendar/e-cal-backend-ews-utils.c |   52 ++++++++++++++++++++++++++++++++
 src/calendar/e-cal-backend-ews-utils.h |    1 +
 2 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews-utils.c b/src/calendar/e-cal-backend-ews-utils.c
index 732fc3c..6c868b6 100644
--- a/src/calendar/e-cal-backend-ews-utils.c
+++ b/src/calendar/e-cal-backend-ews-utils.c
@@ -407,3 +407,55 @@ void ewscal_set_reccurence (ESoapMessage *msg, icalproperty *rrule, icaltimetype
 exit:
 	e_soap_message_end_element (msg); /* "Recurrence" */
 }
+
+static struct icaltimetype
+icalcomponent_get_datetime(icalcomponent *comp, icalproperty *prop)
+{
+	/* Extract datetime with proper timezone */
+	icalcomponent *c;
+	icalparameter *param;
+	struct icaltimetype ret;
+
+	ret = icalvalue_get_datetime (icalproperty_get_value(prop));
+
+	if ((param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER)) != NULL) {
+		const char *tzid = icalparameter_get_tzid (param);
+		icaltimezone *tz = NULL;
+
+		for (c = comp; c != NULL; c = icalcomponent_get_parent (c)) {
+			tz = icalcomponent_get_timezone (c, tzid);
+			if (tz != NULL)	break;
+		}
+
+		if (tz == NULL)
+			tz = icaltimezone_get_builtin_timezone_from_tzid(tzid);
+
+		if (tz != NULL)
+			ret = icaltime_set_timezone(&ret, tz);
+	}
+
+	return ret;
+}
+
+void ewscal_set_reccurence_exceptions (ESoapMessage *msg, icalcomponent *comp)
+{
+	icalproperty *exdate;
+
+	/* Make sure we have at least 1 excluded occurrence */
+	exdate = icalcomponent_get_first_property (comp,ICAL_EXDATE_PROPERTY);
+	if (!exdate) return;
+
+	e_soap_message_start_element (msg, "DeletedOccurrences", NULL, NULL);
+
+	for (; exdate; exdate = icalcomponent_get_next_property (comp, ICAL_EXDATE_PROPERTY)) {
+		struct icaltimetype exdatetime = icalcomponent_get_datetime(comp, exdate);
+
+		e_soap_message_start_element (msg, "DeletedOccurrence", NULL, NULL);
+
+		ewscal_set_date (msg, "Start", &exdatetime);
+
+		e_soap_message_end_element (msg); /* "DeletedOccurrence" */
+	}
+
+	e_soap_message_end_element (msg); /* "DeletedOccurrences" */
+}
diff --git a/src/calendar/e-cal-backend-ews-utils.h b/src/calendar/e-cal-backend-ews-utils.h
index 1ba6534..e8d85d4 100644
--- a/src/calendar/e-cal-backend-ews-utils.h
+++ b/src/calendar/e-cal-backend-ews-utils.h
@@ -34,6 +34,7 @@ void e_ews_collect_attendees(icalcomponent *comp, GSList **required, GSList **op
 void ewscal_set_time (ESoapMessage *msg, const gchar *name, icaltimetype *t);
 void ewscal_set_timezone (ESoapMessage *msg, const gchar *name, icaltimezone *icaltz);
 void ewscal_set_reccurence (ESoapMessage *msg, icalproperty *rrule, icaltimetype *dtstart);
+void ewscal_set_reccurence_exceptions (ESoapMessage *msg, icalcomponent *comp);
 
 G_END_DECLS
 



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