[evolution-ews/gnome-2-28] Bug #659717 free busy not working
- From: Punit Jain <jpunit src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/gnome-2-28] Bug #659717 free busy not working
- Date: Tue, 27 Mar 2012 07:18:27 +0000 (UTC)
commit 40b172c17381cbce923ec79a2b7b8487910db465
Author: Punit Jain <jpunit novell com>
Date: Tue Mar 27 12:57:30 2012 +0530
Bug #659717 free busy not working
src/calendar/e-cal-backend-ews-utils.c | 38 +++++++++++++++++++++++++-----
src/server/e-ews-connection.c | 39 ++++++++++++++++++++++++++-----
2 files changed, 63 insertions(+), 14 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews-utils.c b/src/calendar/e-cal-backend-ews-utils.c
index 9a37beb..2160568 100644
--- a/src/calendar/e-cal-backend-ews-utils.c
+++ b/src/calendar/e-cal-backend-ews-utils.c
@@ -348,6 +348,27 @@ static void ewscal_add_availability_rrule (ESoapMessage *msg, icalproperty *prop
e_ews_message_write_string_parameter(msg, "DayOfWeek", NULL, number_to_weekday(icalrecurrencetype_day_day_of_week(recur.by_day[0])));
}
+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, int baseoffs)
{
char buffer[16];
@@ -392,16 +413,16 @@ void ewscal_set_availability_timezone (ESoapMessage *msg, icaltimezone *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;
-
+ /*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
@@ -421,7 +442,10 @@ void ewscal_set_availability_timezone (ESoapMessage *msg, icaltimezone *icaltz)
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 bfeba6b..4d18509 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -33,6 +33,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"
@@ -4510,7 +4511,7 @@ get_free_busy_response_cb (ESoapParameter *param, EwsNode *enode)
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");
@@ -4523,17 +4524,41 @@ get_free_busy_response_cb (ESoapParameter *param, EwsNode *enode)
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);
+ /*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 (t_val.tv_sec, 0);
+ 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);
+ /*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 (t_val.tv_sec, 0);
+ 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]