[evolution-ews] Write a proper timezone data in a GetUserAvailability soap operation request
- From: Or Goshen <ogosh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Write a proper timezone data in a GetUserAvailability soap operation request
- Date: Tue, 5 Jul 2011 15:11:57 +0000 (UTC)
commit d44db280447cb4cfc6a09153e02b90c16c4d7517
Author: Or Goshen <orx goshen intel com>
Date: Tue Jul 5 18:19:46 2011 +0300
Write a proper timezone data in a GetUserAvailability soap operation request
src/calendar/e-cal-backend-ews-utils.c | 91 ++++++++++++++++++++++++++++++++
src/calendar/e-cal-backend-ews-utils.h | 1 +
src/calendar/e-cal-backend-ews.c | 8 ++-
3 files changed, 97 insertions(+), 3 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews-utils.c b/src/calendar/e-cal-backend-ews-utils.c
index 9e1f57d..7c694d0 100644
--- a/src/calendar/e-cal-backend-ews-utils.c
+++ b/src/calendar/e-cal-backend-ews-utils.c
@@ -289,6 +289,97 @@ void ewscal_set_timezone (ESoapMessage *msg, const gchar *name, icaltimezone *ic
e_soap_message_end_element(msg); /* "MeetingTimeZone" */
}
+static void ewscal_add_availability_rrule (ESoapMessage *msg, icalproperty *prop)
+{
+ struct icalrecurrencetype recur = icalproperty_get_rrule(prop);
+ char buffer[16];
+
+ snprintf (buffer, 16, "%d", icalrecurrencetype_day_position(recur.by_day[0]));
+ e_ews_message_write_string_parameter(msg, "DayOrder", NULL, buffer);
+
+ snprintf (buffer, 16, "%d", recur.by_month[0]);
+ e_ews_message_write_string_parameter(msg, "Month", NULL, buffer);
+
+ e_ews_message_write_string_parameter(msg, "DayOfWeek", NULL, number_to_weekday(icalrecurrencetype_day_day_of_week(recur.by_day[0]) - recur.week_start));
+}
+
+static void ewscal_add_availability_timechange (ESoapMessage *msg, icalcomponent *comp, int baseoffs)
+{
+ char buffer[16];
+ icalproperty *prop;
+ struct icaltimetype dtstart;
+ int utcoffs;
+
+ /* Calculate zone Offset from BaseOffset */
+ prop = icalcomponent_get_first_property(comp, ICAL_TZOFFSETTO_PROPERTY);
+ if (prop) {
+ utcoffs = -icalproperty_get_tzoffsetto(prop)/60;
+ utcoffs -= baseoffs;
+ snprintf (buffer, 16, "%d", utcoffs);
+ e_ews_message_write_string_parameter(msg, "Bias", NULL, buffer);
+ }
+
+ prop = icalcomponent_get_first_property(comp, ICAL_DTSTART_PROPERTY);
+ if (prop) {
+ dtstart = icalproperty_get_dtstart(prop);
+ snprintf(buffer, 16, "%02d:%02d:%02d", dtstart.hour, dtstart.minute, dtstart.second);
+ e_ews_message_write_string_parameter(msg, "Time", NULL, buffer);
+ }
+
+ prop = icalcomponent_get_first_property(comp, ICAL_RRULE_PROPERTY);
+ if (prop)
+ ewscal_add_availability_rrule (msg, prop);
+}
+
+void ewscal_set_availability_timezone (ESoapMessage *msg, icaltimezone *icaltz)
+{
+ icalcomponent *comp;
+ icalproperty *prop;
+ icalcomponent *xstd, *xdaylight;
+ int std_utcoffs;
+ gchar *offset;
+
+ if (!icaltz)
+ return;
+
+ comp = icaltimezone_get_component(icaltz);
+
+ xstd = icalcomponent_get_first_component(comp, ICAL_XSTANDARD_COMPONENT);
+ xdaylight = icalcomponent_get_first_component(comp, ICAL_XDAYLIGHT_COMPONENT);
+
+ /* Should never happen. Exchange will bail out */
+ if (!xstd || !xdaylight)
+ return;
+
+ e_soap_message_start_element(msg, "TimeZone", NULL, NULL);
+
+ /* Fetch the timezone offsets for the standard (or only) zone.
+ Negate it, because Exchange does it backwards */
+ prop = icalcomponent_get_first_property(xstd, ICAL_TZOFFSETTO_PROPERTY);
+ std_utcoffs = -icalproperty_get_tzoffsetto(prop)/60;
+
+ /* This is the overall BaseOffset tag, which the Standard and Daylight
+ zones are offset from. It's redundant, but Exchange always sets it
+ to the offset of the Standard zone, and the Offset in the Standard
+ zone to zero. So try to avoid problems by doing the same. */
+ offset = g_strdup_printf ("%d", std_utcoffs);
+ e_ews_message_write_string_parameter(msg, "Bias", NULL, offset);
+ g_free (offset);
+
+ if (xdaylight) {
+ /* Standard */
+ e_soap_message_start_element(msg, "StandardTime", NULL, NULL);
+ ewscal_add_availability_timechange (msg, xstd, std_utcoffs);
+ e_soap_message_end_element(msg); /* "StandardTime" */
+
+ /* DayLight */
+ e_soap_message_start_element(msg, "DaylightTime", NULL, NULL);
+ ewscal_add_availability_timechange (msg, xdaylight, std_utcoffs);
+ e_soap_message_end_element(msg); /* "DaylightTime" */
+ }
+ e_soap_message_end_element(msg); /* "TimeZone" */
+}
+
void ewscal_set_reccurence (ESoapMessage *msg, icalproperty *rrule, icaltimetype *dtstart)
{
char buffer[256];
diff --git a/src/calendar/e-cal-backend-ews-utils.h b/src/calendar/e-cal-backend-ews-utils.h
index 47b227f..f03cc0e 100644
--- a/src/calendar/e-cal-backend-ews-utils.h
+++ b/src/calendar/e-cal-backend-ews-utils.h
@@ -33,6 +33,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_availability_timezone (ESoapMessage *msg, icaltimezone *icaltz);
void ewscal_set_reccurence (ESoapMessage *msg, icalproperty *rrule, icaltimetype *dtstart);
void ewscal_set_reccurence_exceptions (ESoapMessage *msg, icalcomponent *comp);
void ewscal_get_attach_differences (const GSList *original, const GSList *modified, GSList **removed, GSList **added);
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index fb18027..60649ae 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -2828,13 +2828,15 @@ typedef struct {
} EwsFreeBusyData;
static void
-prepear_free_busy_request (ESoapMessage *msg, gpointer user_data)
+prepare_free_busy_request (ESoapMessage *msg, gpointer user_data)
{
EwsFreeBusyData *free_busy_data = user_data;
GList *addr;
icaltimetype t_start, t_end;
- e_soap_message_start_element(msg, "MailboxDataArray", NULL, NULL);
+ ewscal_set_availability_timezone (msg, free_busy_data->timezone);
+
+ e_soap_message_start_element(msg, "MailboxDataArray", "messages", NULL);
for (addr = free_busy_data->users; addr; addr = addr->next) {
e_soap_message_start_element(msg, "MailboxData", NULL, NULL);
@@ -2933,7 +2935,7 @@ e_cal_backend_ews_get_free_busy (ECalBackend *backend, EDataCal *cal,
e_ews_connection_get_free_busy_start (priv->cnc,
EWS_PRIORITY_MEDIUM,
- prepear_free_busy_request,
+ prepare_free_busy_request,
free_busy_data,
ews_cal_get_free_busy_cb,
cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]