[evolution-ews] Bug #659717 free busy not working



commit 428f9d0ccb7e905fbd63b204a0e4244ed09597ec
Author: Punit Jain <jpunit suse com>
Date:   Mon Mar 26 18:49:21 2012 +0530

    Bug #659717 free busy not working

 src/calendar/e-cal-backend-ews-utils.c |   38 +++++++++++++++++++++++-----
 src/server/e-ews-connection.c          |   43 +++++++++++++++++++++++++------
 2 files changed, 65 insertions(+), 16 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews-utils.c b/src/calendar/e-cal-backend-ews-utils.c
index a4bb0fd..1a4f7b0 100644
--- a/src/calendar/e-cal-backend-ews-utils.c
+++ b/src/calendar/e-cal-backend-ews-utils.c
@@ -373,6 +373,27 @@ ewscal_add_availability_rrule (ESoapMessage *msg,
 }
 
 static void
+ewscal_add_availability_default_timechange (ESoapMessage *msg)
+{
+
+	e_soap_message_start_element(msg, "StandardTime", NULL, NULL);
+	e_ews_message_write_string_parameter(msg, "Bias", NULL, "0");
+	e_ews_message_write_string_parameter(msg, "Time", NULL, "00:00:00");
+	e_ews_message_write_string_parameter(msg, "DayOrder", NULL, "0");
+	e_ews_message_write_string_parameter(msg, "Month", NULL, "0");
+	e_ews_message_write_string_parameter(msg, "DayOfWeek", NULL, "Sunday");
+	e_soap_message_end_element (msg);
+
+	e_soap_message_start_element(msg, "DaylightTime", NULL, NULL);
+	e_ews_message_write_string_parameter(msg, "Bias", NULL, "0");
+	e_ews_message_write_string_parameter(msg, "Time", NULL, "00:00:00");
+	e_ews_message_write_string_parameter(msg, "DayOrder", NULL, "0");
+	e_ews_message_write_string_parameter(msg, "Month", NULL, "0");
+	e_ews_message_write_string_parameter(msg, "DayOfWeek", NULL, "Sunday");
+	e_soap_message_end_element (msg);
+}
+
+static void
 ewscal_add_availability_timechange (ESoapMessage *msg,
                                     icalcomponent *comp,
                                     gint baseoffs)
@@ -421,16 +442,16 @@ ewscal_set_availability_timezone (ESoapMessage *msg,
 	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;
-
+	/*TimeZone is the root element of GetUserAvailabilityRequest*/
 	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;
+	if (xstd) {
+		prop = icalcomponent_get_first_property(xstd, ICAL_TZOFFSETTO_PROPERTY);
+		std_utcoffs = -icalproperty_get_tzoffsetto(prop)/60;
+	} else
+		std_utcoffs = 0;
 
 	/* This is the overall BaseOffset tag, which the Standard and Daylight
 	 * zones are offset from. It's redundant, but Exchange always sets it
@@ -450,7 +471,10 @@ ewscal_set_availability_timezone (ESoapMessage *msg,
 		e_soap_message_start_element(msg, "DaylightTime", NULL, NULL);
 		ewscal_add_availability_timechange (msg, xdaylight, std_utcoffs);
 		e_soap_message_end_element(msg); /* "DaylightTime" */
-	}
+	} else 
+		/* Set default values*/
+		ewscal_add_availability_default_timechange (msg);
+
 	e_soap_message_end_element(msg); /* "TimeZone" */
 }
 
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index 57009b9..9768760 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -32,6 +32,7 @@
 #include <glib/gstdio.h>
 #include <libical/icalcomponent.h>
 #include <libical/icalproperty.h>
+#include <libical/ical.h>
 #include "e-ews-connection.h"
 #include <libedataserver/e-flag.h>
 #include "e-ews-message.h"
@@ -4554,7 +4555,7 @@ get_free_busy_response_cb (ESoapParameter *param,
 	ESoapParameter *viewparam, *eventarray, *event_param, *subparam;
 	GTimeVal t_val;
 	const gchar *name;
-	gchar *value;
+	gchar *value, *new_val = NULL;
 	EwsAsyncData *async_data = g_simple_async_result_get_op_res_gpointer (enode->simple);
 
 	viewparam = e_soap_parameter_get_first_child_by_name (param, "FreeBusyView");
@@ -4567,17 +4568,41 @@ get_free_busy_response_cb (ESoapParameter *param,
 
 			if (!g_ascii_strcasecmp (name, "StartTime")) {
 				value = e_soap_parameter_get_string_value (subparam);
-				g_time_val_from_iso8601 (value, &t_val);
-				g_free (value);
-
-				ipt.start = icaltime_from_timet (t_val.tv_sec, 0);
+				/*We are sending UTC timezone and expect server to return in same*/
+				
+				/*Remove leading and trailing whitespace*/
+				g_strstrip (value);
+
+				if (g_utf8_strlen (value, -1) == 19) {
+					/*If server returns time without zone add Z to treat it in UTC*/
+					new_val = g_strdup_printf ("%sZ", value);
+					g_free (value);
+				} else
+					new_val = value;
+				
+				g_time_val_from_iso8601 (new_val, &t_val);
+				g_free (new_val);
+
+				ipt.start = icaltime_from_timet_with_zone (t_val.tv_sec, 0, NULL);
 
 			} else if (!g_ascii_strcasecmp (name, "EndTime")) {
 				value = e_soap_parameter_get_string_value (subparam);
-				g_time_val_from_iso8601 (value, &t_val);
-				g_free (value);
-
-				ipt.end = icaltime_from_timet (t_val.tv_sec, 0);
+				/*We are sending UTC timezone and expect server to return in same*/
+				
+				/*Remove leading and trailing whitespace*/
+				g_strstrip (value);
+
+				if (g_utf8_strlen (value, -1) == 19) {
+					/*If server returns time without zone add Z to treat it in UTC*/
+					new_val = g_strdup_printf ("%sZ", value);
+					g_free (value);
+				} else
+					new_val = value;
+
+				g_time_val_from_iso8601 (new_val, &t_val);
+				g_free (new_val);
+
+				ipt.end = icaltime_from_timet_with_zone (t_val.tv_sec, 0, NULL);
 
 				icalprop = icalproperty_new_freebusy (ipt);
 			} else if (!g_ascii_strcasecmp (name, "BusyType")) {



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