[evolution-ews/gnome-3-4] Bug #670506 - Task is adding time to due date from somewhere
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/gnome-3-4] Bug #670506 - Task is adding time to due date from somewhere
- Date: Fri, 3 Aug 2012 13:16:45 +0000 (UTC)
commit cd5c9fc026e978b6cd14f4257f28e066baa93e6c
Author: Milan Crha <mcrha redhat com>
Date: Fri Aug 3 15:16:16 2012 +0200
Bug #670506 - Task is adding time to due date from somewhere
src/calendar/e-cal-backend-ews-utils.c | 35 +++++++++++++++++++++++++++---
src/calendar/e-cal-backend-ews-utils.h | 2 +-
src/calendar/e-cal-backend-ews.c | 27 +++++++++++++++--------
src/server/e-ews-item-change.c | 36 ++++++++++++++++++++++++++++++++
src/server/e-ews-item-change.h | 5 ++++
5 files changed, 90 insertions(+), 15 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews-utils.c b/src/calendar/e-cal-backend-ews-utils.c
index a4bb0fd..5fb5dcf 100644
--- a/src/calendar/e-cal-backend-ews-utils.c
+++ b/src/calendar/e-cal-backend-ews-utils.c
@@ -154,15 +154,42 @@ ews_set_alarm (ESoapMessage *msg,
void
ewscal_set_time (ESoapMessage *msg,
const gchar *name,
- icaltimetype *t)
+ icaltimetype *t,
+ gboolean with_timezone)
{
gchar *str;
+ gchar *tz_ident = NULL;
+
+ if (with_timezone) {
+ if (t->is_utc || !t->zone || t->zone == icaltimezone_get_utc_timezone ()) {
+ tz_ident = g_strdup ("Z");
+ } else {
+ gint offset, is_daylight, hrs, mins;
+
+ offset = icaltimezone_get_utc_offset (
+ icaltimezone_get_utc_timezone (), t, &is_daylight);
- str = g_strdup_printf("%04d-%02d-%02dT%02d:%02d:%02d",
- t->year, t->month, t->day,
- t->hour, t->minute, t->second);
+ offset = offset * (-1);
+ hrs = offset / 60;
+ mins = offset % 60;
+
+ if (hrs < 0)
+ hrs *= -1;
+ if (mins < 0)
+ mins *= -1;
+
+ tz_ident = g_strdup_printf ("%s%02d:%02d", offset > 0 ? "+" : "-", hrs, mins);
+ }
+ }
+
+ str = g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:%02d%s",
+ t->year, t->month, t->day,
+ t->hour, t->minute, t->second,
+ tz_ident ? tz_ident : "");
e_ews_message_write_string_parameter (msg, name, NULL, str);
+
+ g_free (tz_ident);
g_free (str);
}
diff --git a/src/calendar/e-cal-backend-ews-utils.h b/src/calendar/e-cal-backend-ews-utils.h
index 1fc6fb9..db81bc3 100644
--- a/src/calendar/e-cal-backend-ews-utils.h
+++ b/src/calendar/e-cal-backend-ews-utils.h
@@ -34,7 +34,7 @@ G_BEGIN_DECLS
const gchar *e_ews_collect_organizer (icalcomponent *comp);
void e_ews_collect_attendees (icalcomponent *comp, GSList **required, GSList **optional, GSList **resource);
-void ewscal_set_time (ESoapMessage *msg, const gchar *name, icaltimetype *t);
+void ewscal_set_time (ESoapMessage *msg, const gchar *name, icaltimetype *t, gboolean with_timezone);
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);
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 3e138a7..208e435 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -1157,8 +1157,8 @@ convert_vevent_calcomp_to_xml (ESoapMessage *msg,
dtstart = icalcomponent_get_dtstart (icalcomp);
dtend = icalcomponent_get_dtend (icalcomp);
- ewscal_set_time (msg, "Start", &dtstart);
- ewscal_set_time (msg, "End", &dtend);
+ ewscal_set_time (msg, "Start", &dtstart, FALSE);
+ ewscal_set_time (msg, "End", &dtend, FALSE);
/* We have to do the time zone(s) later, or the server rejects the request */
/* All day event ? */
@@ -1233,7 +1233,7 @@ convert_vtodo_calcomp_to_xml (ESoapMessage *msg,
prop = icalcomponent_get_first_property (icalcomp, ICAL_DUE_PROPERTY);
if (prop) {
dt = icalproperty_get_due (prop);
- ewscal_set_time (msg, "DueDate", &dt);
+ ewscal_set_time (msg, "DueDate", &dt, TRUE);
}
prop = icalcomponent_get_first_property (icalcomp, ICAL_PERCENTCOMPLETE_PROPERTY);
@@ -1246,7 +1246,7 @@ convert_vtodo_calcomp_to_xml (ESoapMessage *msg,
prop = icalcomponent_get_first_property (icalcomp, ICAL_DTSTART_PROPERTY);
if (prop) {
dt = icalproperty_get_dtstart (prop);
- ewscal_set_time (msg, "StartDate", &dt);
+ ewscal_set_time (msg, "StartDate", &dt, TRUE);
}
prop = icalcomponent_get_first_property (icalcomp, ICAL_STATUS_PROPERTY);
@@ -1915,14 +1915,14 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
dtend_old = icalcomponent_get_dtend (icalcomp_old);
if (icaltime_compare (dtstart, dtstart_old) != 0) {
e_ews_message_start_set_item_field (msg, "Start", "calendar","CalendarItem");
- ewscal_set_time (msg, "Start", &dtstart);
+ ewscal_set_time (msg, "Start", &dtstart, FALSE);
e_ews_message_end_set_item_field (msg);
dt_changed = TRUE;
}
if (icaltime_compare (dtend, dtend_old) != 0) {
e_ews_message_start_set_item_field (msg, "End", "calendar", "CalendarItem");
- ewscal_set_time (msg, "End", &dtend);
+ ewscal_set_time (msg, "End", &dtend, FALSE);
e_ews_message_end_set_item_field (msg);
dt_changed = TRUE;
}
@@ -2032,8 +2032,10 @@ convert_vtodo_component_to_updatexml (ESoapMessage *msg,
if (prop) {
dt = icalproperty_get_due (prop);
e_ews_message_start_set_item_field (msg, "DueDate", "task", "Task");
- ewscal_set_time (msg, "DueDate", &dt);
+ ewscal_set_time (msg, "DueDate", &dt, TRUE);
e_ews_message_end_set_item_field (msg);
+ } else {
+ e_ews_message_add_delete_item_field (msg, "DueDate", "task");
}
prop = icalcomponent_get_first_property (icalcomp, ICAL_PERCENTCOMPLETE_PROPERTY);
@@ -2049,8 +2051,10 @@ convert_vtodo_component_to_updatexml (ESoapMessage *msg,
if (prop) {
dt = icalproperty_get_dtstart (prop);
e_ews_message_start_set_item_field (msg, "StartDate", "task", "Task");
- ewscal_set_time (msg, "StartDate", &dt);
+ ewscal_set_time (msg, "StartDate", &dt, TRUE);
e_ews_message_end_set_item_field (msg);
+ } else {
+ e_ews_message_add_delete_item_field (msg, "StartDate", "task");
}
prop = icalcomponent_get_first_property (icalcomp, ICAL_STATUS_PROPERTY);
@@ -2930,6 +2934,7 @@ add_item_to_cache (ECalBackendEws *cbews,
e_ews_item_task_has_due_date (item, &has_this_date);
if (has_this_date) {
due_date = icaltime_from_timet_with_zone (e_ews_item_get_due_date (item), 0, priv->default_zone);
+ due_date.is_date = 1;
icalprop = icalproperty_new_due (due_date);
icalcomponent_add_property (icalcomp, icalprop);
}
@@ -2939,6 +2944,7 @@ add_item_to_cache (ECalBackendEws *cbews,
e_ews_item_task_has_start_date (item, &has_this_date);
if (has_this_date) {
start_date = icaltime_from_timet_with_zone (e_ews_item_get_start_date (item), 0, priv->default_zone);
+ start_date.is_date = 1;
icalprop = icalproperty_new_dtstart (start_date);
icalcomponent_add_property (icalcomp, icalprop);
}
@@ -2948,6 +2954,7 @@ add_item_to_cache (ECalBackendEws *cbews,
e_ews_item_task_has_complete_date (item, &has_this_date);
if (has_this_date) {
complete_date = icaltime_from_timet_with_zone (e_ews_item_get_complete_date (item), 0, priv->default_zone);
+ complete_date.is_date = 1;
icalprop = icalproperty_new_completed (complete_date);
icalcomponent_add_property (icalcomp, icalprop);
}
@@ -3649,8 +3656,8 @@ prepare_free_busy_request (ESoapMessage *msg,
e_soap_message_start_element(msg, "TimeWindow", NULL, NULL);
t_start = icaltime_from_timet_with_zone (free_busy_data->start, 0, free_busy_data->timezone);
t_end = icaltime_from_timet_with_zone (free_busy_data->end, 0, free_busy_data->timezone);
- ewscal_set_time (msg, "StartTime", &t_start);
- ewscal_set_time (msg, "EndTime", &t_end);
+ ewscal_set_time (msg, "StartTime", &t_start, FALSE);
+ ewscal_set_time (msg, "EndTime", &t_end, FALSE);
e_soap_message_end_element(msg); /* "TimeWindow" */
e_ews_message_write_string_parameter (msg, "MergedFreeBusyIntervalInMinutes", NULL, "60");
diff --git a/src/server/e-ews-item-change.c b/src/server/e-ews-item-change.c
index 90bf32c..89b2a78 100644
--- a/src/server/e-ews-item-change.c
+++ b/src/server/e-ews-item-change.c
@@ -143,3 +143,39 @@ e_ews_message_end_set_item_field (ESoapMessage *msg)
e_soap_message_end_element (msg); /* CalendarItem */
e_soap_message_end_element (msg); /* SetItemField */
}
+
+void
+e_ews_message_add_delete_item_field (ESoapMessage *msg,
+ const gchar *name,
+ const gchar *fielduri_prefix)
+{
+ gchar *fielduri;
+
+ fielduri = g_strconcat (fielduri_prefix, ":", name, NULL);
+
+ e_soap_message_start_element (msg, "DeleteItemField", NULL, NULL);
+ e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI", fielduri);
+ e_soap_message_end_element (msg); /* DeleteItemField */
+
+ g_free (fielduri);
+}
+
+void
+e_ews_message_add_delete_item_field_indexed (ESoapMessage *msg,
+ const gchar *name,
+ const gchar *fielduri_prefix,
+ const gchar *field_index)
+{
+ gchar *fielduri;
+
+ fielduri = g_strconcat (fielduri_prefix, ":", name, NULL);
+
+ e_soap_message_start_element (msg, "DeleteItemField", NULL, NULL);
+ e_soap_message_start_element (msg, "IndexedFieldURI", NULL, NULL);
+ e_soap_message_add_attribute (msg, "FieldURI", fielduri, NULL, NULL);
+ e_soap_message_add_attribute (msg, "FieldIndex", field_index, NULL, NULL);
+ e_soap_message_end_element (msg); /* IndexedFieldURI */
+ e_soap_message_end_element (msg); /* DeleteItemField */
+
+ g_free (fielduri);
+}
diff --git a/src/server/e-ews-item-change.h b/src/server/e-ews-item-change.h
index 57fb39f..0928d04 100644
--- a/src/server/e-ews-item-change.h
+++ b/src/server/e-ews-item-change.h
@@ -47,6 +47,11 @@ void e_ews_message_end_set_indexed_item_field (ESoapMessage *msg, gboolean delet
void e_ews_message_end_set_item_field (ESoapMessage *msg);
+void e_ews_message_add_delete_item_field (ESoapMessage *msg, const gchar *name, const gchar *fielduri_prefix);
+
+void e_ews_message_add_delete_item_field_indexed (ESoapMessage *msg, const gchar *name, const gchar *fielduri_prefix, const gchar *field_index);
+
+
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]