[evolution-ews] Bug #722416 - Don't change the timezone name
- From: Fabiano Fidêncio <ffidencio src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Bug #722416 - Don't change the timezone name
- Date: Fri, 7 Feb 2014 16:10:34 +0000 (UTC)
commit 2e69a0c4420b91ca74c456eb497f9fd9a93ccc1b
Author: Fabiano Fidêncio <fidencio redhat com>
Date: Wed Jan 22 04:46:57 2014 +0100
Bug #722416 - Don't change the timezone name
src/addressbook/e-book-backend-ews.c | 33 +++-
src/calendar/e-cal-backend-ews-utils.c | 228 ++++++++++++++---------
src/calendar/e-cal-backend-ews.c | 237 ++++++++++++++++++++----
src/camel/camel-ews-folder.c | 161 ++++++++++++++--
src/configuration/e-ews-config-utils.c | 16 +-
src/server/e-ews-connection.c | 222 +++++++---------------
src/server/e-ews-connection.h | 34 +++-
src/server/e-ews-item-change.c | 322 ++++++++++++++++++++++++++++++++
src/server/e-ews-item-change.h | 112 +++++++++++
src/server/e-ews-item.c | 121 +++++++++---
src/server/e-ews-item.h | 7 +-
src/server/e-ews-message.c | 24 +++
src/server/e-ews-message.h | 11 +
13 files changed, 1176 insertions(+), 352 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-ews.c b/src/addressbook/e-book-backend-ews.c
index 402a2ec..8e9d02a 100644
--- a/src/addressbook/e-book-backend-ews.c
+++ b/src/addressbook/e-book-backend-ews.c
@@ -381,6 +381,7 @@ get_photo (EBookBackendEws *ebews,
GError **error)
{
EContactPhoto *photo = NULL;
+ EEwsAdditionalProps *add_props = NULL;
EEwsAttachmentInfo *info;
GSList *contact_item_ids = NULL, *new_items = NULL;
GSList *attachments = NULL, *attachments_ids = NULL;
@@ -389,6 +390,9 @@ get_photo (EBookBackendEws *ebews,
const EwsId *id;
gsize len;
+ add_props = e_ews_additional_props_new ();
+ add_props->field_uri = g_strdup ("item:Attachments");
+
id = e_ews_item_get_id (item);
contact_item_ids = g_slist_prepend (contact_item_ids, g_strdup (id->id));
if (!e_ews_connection_get_items_sync (
@@ -396,7 +400,7 @@ get_photo (EBookBackendEws *ebews,
EWS_PRIORITY_MEDIUM,
contact_item_ids,
"IdOnly",
- "item:Attachments",
+ add_props,
FALSE,
NULL,
E_EWS_BODY_TYPE_TEXT,
@@ -434,6 +438,7 @@ get_photo (EBookBackendEws *ebews,
e_contact_photo_set_inlined (photo, content, len);
exit:
+ e_ews_additional_props_free (add_props);
g_slist_free_full (contact_item_ids, g_free);
g_slist_free_full (new_items, g_object_unref);
g_slist_free_full (attachments_ids, g_free);
@@ -960,6 +965,7 @@ ebews_set_photo_changes (EBookBackendEws *ebews,
GError **error)
{
EContactPhoto *old_photo, *new_photo;
+ EEwsAdditionalProps *add_props = NULL;
GSList *contact_item_ids = NULL, *new_items = NULL, *attachments_ids = NULL;
gchar *id = e_contact_get (old, E_CONTACT_UID);
const gchar *contact_photo_id;
@@ -977,13 +983,16 @@ ebews_set_photo_changes (EBookBackendEws *ebews,
if (photos_equal (old_photo, new_photo))
goto exit;
+ add_props = e_ews_additional_props_new ();
+ add_props->field_uri = g_strdup ("item:Attachments");
+
contact_item_ids = g_slist_append (contact_item_ids, id);
if (!e_ews_connection_get_items_sync (
ebews->priv->cnc,
EWS_PRIORITY_MEDIUM,
contact_item_ids,
"IdOnly",
- "item:Attachments",
+ add_props,
FALSE,
NULL,
E_EWS_BODY_TYPE_TEXT,
@@ -1011,6 +1020,7 @@ ebews_set_photo_changes (EBookBackendEws *ebews,
set_photo (ebews, new, new_photo, cancellable, error);
exit:
+ e_ews_additional_props_free (add_props);
e_contact_photo_free (old_photo);
e_contact_photo_free (new_photo);
g_slist_free_full (contact_item_ids, g_free);
@@ -2954,13 +2964,22 @@ ebews_fetch_items (EBookBackendEws *ebews,
g_slist_free (items);
/* TODO fetch attachments */
- if (contact_item_ids)
- if (!e_ews_connection_get_items_sync (
+ if (contact_item_ids) {
+ EEwsAdditionalProps *add_props;
+ add_props = e_ews_additional_props_new ();
+ add_props->field_uri = g_strdup (CONTACT_ITEM_PROPS);
+
+ ret = e_ews_connection_get_items_sync (
cnc, EWS_PRIORITY_MEDIUM,
- contact_item_ids, "Default", CONTACT_ITEM_PROPS,
+ contact_item_ids, "Default", add_props,
FALSE, NULL, E_EWS_BODY_TYPE_TEXT, &new_items, NULL, NULL,
- cancellable, error))
+ cancellable, error);
+
+ e_ews_additional_props_free (add_props);
+
+ if (!ret)
goto cleanup;
+ }
if (new_items) {
if (store_to_cache)
@@ -3017,7 +3036,7 @@ cleanup:
g_slist_free_full (dl_ids, g_free);
g_slist_free_full (contact_item_ids, g_free);
- return TRUE;
+ return ret;
}
static void
diff --git a/src/calendar/e-cal-backend-ews-utils.c b/src/calendar/e-cal-backend-ews-utils.c
index 0a66558..ded8d1b 100644
--- a/src/calendar/e-cal-backend-ews-utils.c
+++ b/src/calendar/e-cal-backend-ews-utils.c
@@ -1718,9 +1718,10 @@ convert_vevent_calcomp_to_xml (ESoapMessage *msg,
ECalComponent *comp = e_cal_component_new ();
GSList *required = NULL, *optional = NULL, *resource = NULL;
icaltimetype dtstart, dtend;
+ icaltimezone *tzid_start, *tzid_end;
icalproperty *prop;
- gboolean has_alarms;
- const gchar *value;
+ gboolean has_alarms, satisfies;
+ const gchar *ical_location_start, *ical_location_end, *value;
e_cal_component_set_icalcomponent (comp, icalcomp);
@@ -1752,7 +1753,28 @@ convert_vevent_calcomp_to_xml (ESoapMessage *msg,
/* start time, end time and meeting time zone */
dtstart = icalcomponent_get_dtstart (icalcomp);
+ tzid_start = (icaltimezone *) (dtstart.zone ? dtstart.zone : convert_data->default_zone);
+ ical_location_start = icaltimezone_get_location (tzid_start);
+
dtend = icalcomponent_get_dtend (icalcomp);
+ tzid_end = (icaltimezone *) (dtend.zone ? dtend.zone : convert_data->default_zone);
+ ical_location_end = icaltimezone_get_location (tzid_end);
+
+ satisfies = e_ews_connection_satisfies_server_version (convert_data->connection, E_EWS_EXCHANGE_2010);
+ if (satisfies) {
+ /* set iana timezone info as an extended property */
+ e_ews_message_add_extended_property_distinguished_name_string (
+ msg,
+ "PublicStrings",
+ "EvolutionEWSStartTimeZone",
+ ical_location_start);
+
+ e_ews_message_add_extended_property_distinguished_name_string (
+ msg,
+ "PublicStrings",
+ "EvolutionEWSEndTimeZone",
+ ical_location_end);
+ }
ewscal_set_time (msg, "Start", &dtstart, FALSE);
ewscal_set_time (msg, "End", &dtend, FALSE);
@@ -1800,27 +1822,16 @@ convert_vevent_calcomp_to_xml (ESoapMessage *msg,
/* We have to cast these because libical puts a const pointer into the
* icaltimetype, but its basic read-only icaltimezone_foo() functions
* take a non-const pointer! */
- if (e_ews_connection_satisfies_server_version (convert_data->connection, E_EWS_EXCHANGE_2010)) {
- const gchar *ical_location;
+ if (satisfies) {
const gchar *msdn_location;
- icaltimezone *tzid;
GSList *msdn_locations = NULL;
GSList *tzds = NULL;
- tzid = (icaltimezone *) (dtstart.zone ? dtstart.zone : convert_data->default_zone);
- ical_location = icaltimezone_get_location (tzid);
- msdn_location = e_cal_backend_ews_tz_util_get_msdn_equivalent (ical_location);
-
- msdn_locations = g_slist_prepend (msdn_locations, (gchar *) msdn_location);
-
- tzid = (icaltimezone *)
- (dtend.zone ? dtend.zone : convert_data->default_zone);
- ical_location = icaltimezone_get_location (tzid);
- msdn_location = e_cal_backend_ews_tz_util_get_msdn_equivalent (ical_location);
+ msdn_location = e_cal_backend_ews_tz_util_get_msdn_equivalent (ical_location_start);
+ msdn_locations = g_slist_append (msdn_locations, (gchar *) msdn_location);
- msdn_locations = g_slist_prepend (msdn_locations, (gchar *) msdn_location);
-
- msdn_locations = g_slist_reverse (msdn_locations);
+ msdn_location = e_cal_backend_ews_tz_util_get_msdn_equivalent (ical_location_end);
+ msdn_locations = g_slist_append (msdn_locations, (gchar *) msdn_location);
if (e_ews_connection_get_server_time_zones_sync (
convert_data->connection,
@@ -1836,9 +1847,7 @@ convert_vevent_calcomp_to_xml (ESoapMessage *msg,
g_slist_free (msdn_locations);
g_slist_free_full (tzds, (GDestroyNotify) e_ews_calendar_time_zone_definition_free);
} else {
- ewscal_set_meeting_timezone (
- msg,
- (icaltimezone *) (dtstart.zone ? dtstart.zone : convert_data->default_zone));
+ ewscal_set_meeting_timezone (msg, tzid_start);
}
e_soap_message_end_element (msg); /* "CalendarItem" */
@@ -2000,9 +2009,17 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
icalcomponent *icalcomp_old = e_cal_component_get_icalcomponent (convert_data->old_comp);
GSList *required = NULL, *optional = NULL, *resource = NULL;
icaltimetype dtstart, dtend, dtstart_old, dtend_old;
+ icaltimezone *tzid_start = NULL, *tzid_end = NULL;
icalproperty *prop, *transp;
const gchar *org_email_address = NULL, *value = NULL, *old_value = NULL;
- gboolean has_alarms, has_alarms_old, dt_changed = FALSE;
+ const gchar *ical_location_start = NULL, *ical_location_end = NULL;
+ const gchar *old_ical_location_start = NULL, *old_ical_location_end = NULL;
+ const gchar *old_msdn_location_start = NULL, *old_msdn_location_end = NULL;
+ const gchar *msdn_location_start = NULL, *msdn_location_end = NULL;
+ gboolean has_alarms, has_alarms_old;
+ gboolean dt_start_changed = FALSE, dt_end_changed = FALSE, dt_changed;
+ gboolean dt_start_changed_timezone_name = FALSE, dt_end_changed_timezone_name = FALSE;
+ gboolean satisfies;
gint alarm = 0, alarm_old = 0;
gchar *recid;
GError *error = NULL;
@@ -2110,23 +2127,81 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
/* Update other properties allowed only for meeting organizers*/
/*meeting dates*/
dtstart = icalcomponent_get_dtstart (icalcomp);
- dtend = icalcomponent_get_dtend (icalcomp);
dtstart_old = icalcomponent_get_dtstart (icalcomp_old);
+ dt_start_changed = icaltime_compare (dtstart, dtstart_old) != 0;
+ if (dtstart.zone != NULL) {
+ tzid_start = (icaltimezone *) dtstart.zone;
+ ical_location_start = icaltimezone_get_location (tzid_start);
+
+ old_ical_location_start = icaltimezone_get_location ((icaltimezone *)dtstart_old.zone);
+ if (g_strcmp0 (ical_location_start, old_ical_location_start) != 0)
+ dt_start_changed_timezone_name = TRUE;
+ }
+
+ dtend = icalcomponent_get_dtend (icalcomp);
dtend_old = icalcomponent_get_dtend (icalcomp_old);
- if (icaltime_compare (dtstart, dtstart_old) != 0) {
+ dt_end_changed = icaltime_compare (dtend, dtend_old) != 0;
+ if (dtend.zone != NULL) {
+ tzid_end = (icaltimezone *) dtend.zone;
+ ical_location_end = icaltimezone_get_location (tzid_end);
+
+ old_ical_location_end = icaltimezone_get_location ((icaltimezone *)dtend_old.zone);
+ if (g_strcmp0 (ical_location_end, old_ical_location_end) != 0)
+ dt_end_changed_timezone_name = TRUE;
+ }
+
+ satisfies = e_ews_connection_satisfies_server_version (convert_data->connection, E_EWS_EXCHANGE_2010);
+
+ if (satisfies) {
+ if (old_ical_location_start != NULL) {
+ old_msdn_location_start = e_cal_backend_ews_tz_util_get_msdn_equivalent
(old_ical_location_start);
+ msdn_location_start = e_cal_backend_ews_tz_util_get_msdn_equivalent
(ical_location_start);
+
+ if (g_strcmp0 (old_msdn_location_start, msdn_location_start) != 0)
+ dt_start_changed = TRUE;
+ }
+
+ if (old_ical_location_end != NULL) {
+ old_msdn_location_end = e_cal_backend_ews_tz_util_get_msdn_equivalent
(old_ical_location_end);
+ msdn_location_end = e_cal_backend_ews_tz_util_get_msdn_equivalent (ical_location_end);
+
+ if (g_strcmp0 (old_msdn_location_end, msdn_location_end) != 0)
+ dt_end_changed = TRUE;
+ }
+
+ if ((dt_start_changed || dt_start_changed_timezone_name) && ical_location_start != NULL)
+ e_ews_message_add_set_item_field_extended_distinguished_name_string (
+ msg,
+ NULL,
+ "CalendarItem",
+ "PublicStrings",
+ "EvolutionEWSStartTimeZone",
+ ical_location_start);
+
+ if ((dt_end_changed || dt_end_changed_timezone_name) && ical_location_end != NULL)
+ e_ews_message_add_set_item_field_extended_distinguished_name_string (
+ msg,
+ NULL,
+ "CalendarItem",
+ "PublicStrings",
+ "EvolutionEWSEndTimeZone",
+ ical_location_end);
+ }
+
+ if (dt_start_changed) {
e_ews_message_start_set_item_field (msg, "Start", "calendar","CalendarItem");
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) {
+ if (dt_end_changed) {
e_ews_message_start_set_item_field (msg, "End", "calendar", "CalendarItem");
ewscal_set_time (msg, "End", &dtend, FALSE);
e_ews_message_end_set_item_field (msg);
- dt_changed = TRUE;
}
+ dt_changed = dt_start_changed || dt_end_changed;
+
/*Check for All Day Event*/
if (dt_changed) {
if (icaltime_is_date (dtstart))
@@ -2135,7 +2210,6 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
convert_vevent_property_to_updatexml (msg, "IsAllDayEvent", "false", "calendar",
NULL, NULL);
}
- /*need to test it*/
e_ews_collect_attendees (icalcomp, &required, &optional, &resource);
if (required != NULL) {
e_ews_message_start_set_item_field (msg, "RequiredAttendees", "calendar", "CalendarItem");
@@ -2177,68 +2251,54 @@ convert_vevent_component_to_updatexml (ESoapMessage *msg,
e_ews_message_end_set_item_field (msg);
}
- /* We have to cast these because libical puts a const pointer into the
- * icaltimetype, but its basic read-only icaltimezone_foo() functions
- * take a non-const pointer! */
- if (e_ews_connection_satisfies_server_version (convert_data->connection, E_EWS_EXCHANGE_2010)) {
- const gchar *ical_location;
- const gchar *msdn_location;
- icaltimezone *tzid;
- GSList *msdn_locations = NULL;
- GSList *tzds = NULL;
+ if (dt_changed) {
+ if (satisfies && (msdn_location_start != NULL || msdn_location_end != NULL)) {
+ GSList *msdn_locations = NULL;
+ GSList *tzds = NULL;
- if (dtstart.zone != NULL) {
- tzid = (icaltimezone *) dtstart.zone;
- ical_location = icaltimezone_get_location (tzid);
- msdn_location = e_cal_backend_ews_tz_util_get_msdn_equivalent (ical_location);
- msdn_locations = g_slist_append (msdn_locations, (gchar *) msdn_location);
- }
+ if (msdn_location_start != NULL)
+ msdn_locations = g_slist_append (msdn_locations, (gchar *)
msdn_location_start);
- if (dtend.zone != NULL) {
- tzid = (icaltimezone *) dtend.zone;
- ical_location = icaltimezone_get_location (tzid);
- msdn_location = e_cal_backend_ews_tz_util_get_msdn_equivalent (ical_location);
- msdn_locations = g_slist_append (msdn_locations, (gchar *) msdn_location);
- }
+ if (msdn_location_end != NULL)
+ msdn_locations = g_slist_append (msdn_locations, (gchar *) msdn_location_end);
- if (e_ews_connection_get_server_time_zones_sync (
- convert_data->connection,
- EWS_PRIORITY_MEDIUM,
- msdn_locations,
- &tzds,
- NULL,
- NULL)) {
- GSList *tmp;
-
- tmp = tzds;
- if (dtstart.zone != NULL) {
- e_ews_message_start_set_item_field (msg, "StartTimeZone", "calendar",
"CalendarItem");
- ewscal_set_timezone (msg, "StartTimeZone", tmp->data);
- e_ews_message_end_set_item_field (msg);
-
- /*
- * Exchange server is smart enough to return the list of
- * ServerTimeZone without repeated elements
- */
- if (tmp->next != NULL)
- tmp = tmp->next;
- }
+ if (e_ews_connection_get_server_time_zones_sync (
+ convert_data->connection,
+ EWS_PRIORITY_MEDIUM,
+ msdn_locations,
+ &tzds,
+ NULL,
+ NULL)) {
+ GSList *tmp;
+
+ tmp = tzds;
+ if (dtstart.zone != NULL) {
+ e_ews_message_start_set_item_field (msg, "StartTimeZone", "calendar",
"CalendarItem");
+ ewscal_set_timezone (msg, "StartTimeZone", tmp->data);
+ e_ews_message_end_set_item_field (msg);
+
+ /*
+ * Exchange server is smart enough to return the list of
+ * ServerTimeZone without repeated elements
+ */
+ if (tmp->next != NULL)
+ tmp = tmp->next;
+ }
- if (dtend.zone != NULL) {
- e_ews_message_start_set_item_field (msg, "EndTimeZone", "calendar",
"CalendarItem");
- ewscal_set_timezone (msg, "EndTimeZone", tmp->data);
- e_ews_message_end_set_item_field (msg);
+ if (dtend.zone != NULL) {
+ e_ews_message_start_set_item_field (msg, "EndTimeZone", "calendar",
"CalendarItem");
+ ewscal_set_timezone (msg, "EndTimeZone", tmp->data);
+ e_ews_message_end_set_item_field (msg);
+ }
}
- }
- g_slist_free (msdn_locations);
- g_slist_free_full (tzds, (GDestroyNotify) e_ews_calendar_time_zone_definition_free);
- } else {
- e_ews_message_start_set_item_field (msg, "MeetingTimeZone", "calendar", "CalendarItem");
- ewscal_set_meeting_timezone (
- msg,
- (icaltimezone *) (dtstart.zone ? dtstart.zone : convert_data->default_zone));
- e_ews_message_end_set_item_field (msg);
+ g_slist_free (msdn_locations);
+ g_slist_free_full (tzds, (GDestroyNotify) e_ews_calendar_time_zone_definition_free);
+ } else {
+ e_ews_message_start_set_item_field (msg, "MeetingTimeZone", "calendar",
"CalendarItem");
+ ewscal_set_meeting_timezone (msg, tzid_start);
+ e_ews_message_end_set_item_field (msg);
+ }
}
e_ews_message_end_item_change (msg);
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 68175ea..c79447a 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -109,7 +109,8 @@ struct _ECalBackendEwsPrivate {
#define GET_ITEMS_SYNC_PROPERTIES_2010 \
GET_ITEMS_SYNC_PROPERTIES \
- " calendar:StartTimeZone"
+ " calendar:StartTimeZone" \
+ " calendar:EndTimeZone"
#define e_data_cal_error_if_fail(expr, _code) \
@@ -1399,6 +1400,10 @@ ews_create_object_cb (GObject *object,
g_slist_free (ids);
if (e_ews_item_get_item_type (item) == E_EWS_ITEM_TYPE_EVENT) {
+ EEwsAdditionalProps *add_props;
+
+ add_props = e_ews_additional_props_new ();
+ add_props->field_uri = g_strdup ("calendar:UID");
items = g_slist_append (items, item_id->id);
@@ -1407,10 +1412,12 @@ ews_create_object_cb (GObject *object,
cnc, EWS_PRIORITY_MEDIUM,
items,
"IdOnly",
- "calendar:UID",
+ add_props,
FALSE, NULL, E_EWS_BODY_TYPE_TEXT,
&items_req,
NULL, NULL, priv->cancellable, &error);
+
+ e_ews_additional_props_free (add_props);
if (!res && error != NULL) {
if (items_req)
g_slist_free_full (items_req, g_object_unref);
@@ -2692,6 +2699,35 @@ ews_get_attachments (ECalBackendEws *cbews,
PRIV_UNLOCK (cbews->priv);
}
+static icaltimezone *
+get_timezone (ETimezoneCache *timezone_cache,
+ const gchar *msdn_tzid,
+ const gchar *tzid,
+ const gchar *evo_ews_tzid)
+{
+ icaltimezone *zone = NULL;
+ const gchar *evo_ews_msdn_tzid;
+
+ zone = e_timezone_cache_get_timezone (timezone_cache, tzid);
+ if (zone == NULL)
+ zone = icaltimezone_get_builtin_timezone (tzid);
+
+ if (g_strcmp0 (tzid, evo_ews_tzid) == 0)
+ return zone;
+
+ if (evo_ews_tzid != NULL) {
+ evo_ews_msdn_tzid = e_cal_backend_ews_tz_util_get_msdn_equivalent (evo_ews_tzid);
+
+ if (g_strcmp0 (msdn_tzid, evo_ews_msdn_tzid) == 0) {
+ zone = e_timezone_cache_get_timezone (timezone_cache, evo_ews_tzid);
+ if (zone == NULL)
+ zone = icaltimezone_get_builtin_timezone (evo_ews_tzid);
+ }
+ }
+
+ return zone;
+}
+
static void
add_item_to_cache (ECalBackendEws *cbews,
EEwsItem *item)
@@ -2852,50 +2888,120 @@ add_item_to_cache (ECalBackendEws *cbews,
icalcomponent_add_component (vcomp,icalcomp);
} else {
struct icaltimetype dt;
- icaltimezone *zone;
const gchar *tzid;
mime_content = e_ews_item_get_mime_content (item);
vcomp = icalparser_parse_string (mime_content);
- /* Add the timezone */
- vtimezone = icalcomponent_get_first_component (vcomp, ICAL_VTIMEZONE_COMPONENT);
- if (vtimezone != NULL) {
- zone = icaltimezone_new ();
- vtimezone = icalcomponent_new_clone (vtimezone);
- icaltimezone_set_component (zone, vtimezone);
- e_timezone_cache_add_timezone (timezone_cache, zone);
- icaltimezone_free (zone, TRUE);
- }
-
- zone = NULL;
tzid = e_ews_item_get_tzid (item);
+ if (tzid == NULL) {
+ /*
+ * When we are working with Exchange server 2010 or newer, we have to handle a few
+ * things more than we do working old servers. These things are:
+ * - MSDN timezone names:
+ * Used setting StartTimeZone and EndTimeZone. MSDN timezone names are not
+ * the same used in libical, so we need to have a table of equivalence to
+ * convert from one to another and avoid show the MSDN timezone name to the
+ * user and save it in the ETimezoneCache.
+ * - EvoEWSStartTimeZone/EvoEWSEndTimeZone
+ * Used to keep track if the timezone shown to the user is the same one set
+ * by him/her. As we have a table of equivalence, sometimes the user sets a
+ * timezone but without EvoEWSStartTiemZone property, another timezone name,
+ * in the same offset, can be shown. And we want to avoid this.
+ * - DTEND property:
+ * As we have to work with DTEND setting an event when using EWS server 2010 or
+ * newer, we have to care about set it properly here, instead of use the same
+ * as is used in DTSTART.
+ */
+ icaltimezone *start_zone, *end_zone;
+ const gchar *start_tzid, *end_tzid;
+ const gchar *ical_start_tzid, *ical_end_tzid;
+ const gchar *evo_ews_start_tzid, *evo_ews_end_tzid;
- if (tzid != NULL) {
- const gchar *ical_location;
+ start_tzid = e_ews_item_get_start_tzid (item);
+ end_tzid = e_ews_item_get_end_tzid (item);
- ical_location = e_cal_backend_ews_tz_util_get_ical_equivalent (tzid);
+ ical_start_tzid = e_cal_backend_ews_tz_util_get_ical_equivalent (start_tzid);
+ ical_end_tzid = e_cal_backend_ews_tz_util_get_ical_equivalent (end_tzid);
- zone = e_timezone_cache_get_timezone (
+ evo_ews_start_tzid = e_ews_item_get_iana_start_time_zone (item);
+ evo_ews_end_tzid = e_ews_item_get_iana_end_time_zone (item);
+
+ /*
+ * We have a few timezones that don't have an equivalent MSDN timezone.
+ * For those, we will get ical_start_tzid being NULL and then we need to use
+ * start_tzid, which one has the libical's expected name.
+ */
+ start_zone = get_timezone (
timezone_cache,
- ical_location != NULL ? ical_location : tzid);
- }
+ start_tzid,
+ ical_start_tzid != NULL ? ical_start_tzid : start_tzid,
+ evo_ews_start_tzid);
+ end_zone = get_timezone (
+ timezone_cache,
+ end_tzid,
+ ical_end_tzid != NULL ? ical_end_tzid : end_tzid,
+ evo_ews_end_tzid);
- if (zone == NULL)
- zone = icaltimezone_get_builtin_timezone (tzid);
+ if (start_zone != NULL) {
+ icalcomp = icalcomponent_get_first_component (vcomp, kind);
- if (zone != NULL) {
- icalcomp = icalcomponent_get_first_component (vcomp, kind);
+ icalcomponent_add_component (
+ vcomp,
+ icalcomponent_new_clone (icaltimezone_get_component (start_zone)));
- icalcomponent_add_component (vcomp, icalcomponent_new_clone
(icaltimezone_get_component (zone)));
+ dt = icalcomponent_get_dtstart (icalcomp);
+ dt = icaltime_convert_to_zone (dt, start_zone);
+ icalcomponent_set_dtstart (icalcomp, dt);
- dt = icalcomponent_get_dtstart (icalcomp);
- dt = icaltime_convert_to_zone (dt, zone);
- icalcomponent_set_dtstart (icalcomp, dt);
+ e_timezone_cache_add_timezone (timezone_cache, start_zone);
- dt = icalcomponent_get_dtend (icalcomp);
- dt = icaltime_convert_to_zone (dt, zone);
- icalcomponent_set_dtend (icalcomp, dt);
+ if (end_zone != NULL) {
+ dt = icalcomponent_get_dtend (icalcomp);
+ dt = icaltime_convert_to_zone (dt, end_zone);
+ icalcomponent_set_dtend (icalcomp, dt);
+
+ e_timezone_cache_add_timezone (timezone_cache, end_zone);
+ }
+ }
+ } else {
+ /*
+ * When we are working with Exchange server older than 2010, we don't set different
+ * DTSTART and DTEND properties in VTIMEZONE. The reason of that is we don't use
+ * those properties settings/changing a meeting timezone.
+ * So, for older servers, here, we only set the DTSTART and DTEND properties with
+ * the same values.
+ */
+ icaltimezone *zone;
+
+ /* Add the timezone */
+ vtimezone = icalcomponent_get_first_component (vcomp, ICAL_VTIMEZONE_COMPONENT);
+ if (vtimezone != NULL) {
+ zone = icaltimezone_new ();
+ vtimezone = icalcomponent_new_clone (vtimezone);
+ icaltimezone_set_component (zone, vtimezone);
+ e_timezone_cache_add_timezone (timezone_cache, zone);
+ icaltimezone_free (zone, TRUE);
+ }
+
+ zone = e_timezone_cache_get_timezone (timezone_cache, tzid);
+
+ if (zone == NULL)
+ zone = icaltimezone_get_builtin_timezone (tzid);
+
+ if (zone != NULL) {
+ icalcomp = icalcomponent_get_first_component (vcomp, kind);
+
+ icalcomponent_add_component (vcomp, icalcomponent_new_clone
(icaltimezone_get_component (zone)));
+
+ dt = icalcomponent_get_dtstart (icalcomp);
+ dt = icaltime_convert_to_zone (dt, zone);
+ icalcomponent_set_dtstart (icalcomp, dt);
+
+ dt = icalcomponent_get_dtend (icalcomp);
+ dt = icaltime_convert_to_zone (dt, zone);
+ icalcomponent_set_dtend (icalcomp, dt);
+ }
}
}
/* Vevent or Vtodo */
@@ -3120,7 +3226,7 @@ static gboolean
ews_cal_sync_get_items_sync (ECalBackendEws *cbews,
const GSList *item_ids,
const gchar *default_props,
- const gchar *additional_props)
+ const EEwsAdditionalProps *add_props)
{
ECalBackendEwsPrivate *priv;
gboolean ret = FALSE;
@@ -3134,7 +3240,7 @@ ews_cal_sync_get_items_sync (ECalBackendEws *cbews,
EWS_PRIORITY_MEDIUM,
item_ids,
default_props,
- additional_props,
+ add_props,
FALSE,
NULL,
E_EWS_BODY_TYPE_TEXT,
@@ -3160,11 +3266,35 @@ ews_cal_sync_get_items_sync (ECalBackendEws *cbews,
modified_occurrences = e_ews_item_get_modified_occurrences (item);
if (modified_occurrences) {
+ EEwsAdditionalProps *modified_add_props;
+
+ modified_add_props = e_ews_additional_props_new ();
+ if (e_ews_connection_satisfies_server_version (priv->cnc, E_EWS_EXCHANGE_2010)) {
+ EEwsExtendedFieldURI *ext_uri;
+
+ modified_add_props->field_uri = g_strdup (GET_ITEMS_SYNC_PROPERTIES_2010);
+
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->distinguished_prop_set_id = g_strdup ("PublicStrings");
+ ext_uri->prop_name = g_strdup ("EvolutionEWSStartTimeZone");
+ ext_uri->prop_type = g_strdup ("String");
+ modified_add_props->extended_furis = g_slist_append
(modified_add_props->extended_furis, ext_uri);
+
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->distinguished_prop_set_id = g_strdup ("PublicStrings");
+ ext_uri->prop_name = g_strdup ("EvolutionEWSEndTimeZone");
+ ext_uri->prop_type = g_strdup ("String");
+ modified_add_props->extended_furis = g_slist_append
(modified_add_props->extended_furis, ext_uri);
+ } else {
+ modified_add_props->field_uri = g_strdup (GET_ITEMS_SYNC_PROPERTIES_2007);
+ }
+
ret = ews_cal_sync_get_items_sync (
cbews, modified_occurrences,
"IdOnly",
- e_ews_connection_satisfies_server_version (priv->cnc, E_EWS_EXCHANGE_2010) ?
- GET_ITEMS_SYNC_PROPERTIES_2010 : GET_ITEMS_SYNC_PROPERTIES_2007);
+ modified_add_props);
+
+ e_ews_additional_props_free (modified_add_props);
if (!ret)
goto exit;
@@ -3238,13 +3368,38 @@ cal_backend_ews_process_folder_items (ECalBackendEws *cbews,
}
e_cal_backend_store_thaw_changes (priv->store);
+
if (cal_item_ids) {
+ EEwsAdditionalProps *add_props;
+
+ add_props = e_ews_additional_props_new ();
+ if (e_ews_connection_satisfies_server_version (priv->cnc, E_EWS_EXCHANGE_2010)) {
+ EEwsExtendedFieldURI *ext_uri;
+
+ add_props->field_uri = g_strdup (GET_ITEMS_SYNC_PROPERTIES_2010);
+
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->distinguished_prop_set_id = g_strdup ("PublicStrings");
+ ext_uri->prop_name = g_strdup ("EvolutionEWSStartTimeZone");
+ ext_uri->prop_type = g_strdup ("String");
+ add_props->extended_furis = g_slist_append (add_props->extended_furis, ext_uri);
+
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->distinguished_prop_set_id = g_strdup ("PublicStrings");
+ ext_uri->prop_name = g_strdup ("EvolutionEWSEndTimeZone");
+ ext_uri->prop_type = g_strdup ("String");
+ add_props->extended_furis = g_slist_append (add_props->extended_furis, ext_uri);
+ } else {
+ add_props->field_uri = g_strdup (GET_ITEMS_SYNC_PROPERTIES_2007);
+ }
+
ews_cal_sync_get_items_sync (
cbews,
cal_item_ids,
"IdOnly",
- e_ews_connection_satisfies_server_version (priv->cnc, E_EWS_EXCHANGE_2010) ?
- GET_ITEMS_SYNC_PROPERTIES_2010 : GET_ITEMS_SYNC_PROPERTIES_2007);
+ add_props);
+
+ e_ews_additional_props_free (add_props);
}
if (task_memo_item_ids) {
@@ -3306,15 +3461,20 @@ ews_start_sync_thread (gpointer data)
old_sync_state = g_strdup (e_cal_backend_store_get_key_value (priv->store, SYNC_KEY));
do {
+ EEwsAdditionalProps *add_props;
+
includes_last_item = TRUE;
+ add_props = e_ews_additional_props_new ();
+ add_props->field_uri = g_strdup ("item:ItemClass");
+
ret = e_ews_connection_sync_folder_items_sync (
priv->cnc,
EWS_PRIORITY_MEDIUM,
old_sync_state,
priv->folder_id,
"IdOnly",
- "item:ItemClass",
+ add_props,
EWS_MAX_FETCH_COUNT,
&new_sync_state,
&includes_last_item,
@@ -3324,6 +3484,7 @@ ews_start_sync_thread (gpointer data)
priv->cancellable,
&error);
+ e_ews_additional_props_free (add_props);
g_free (old_sync_state);
old_sync_state = NULL;
diff --git a/src/camel/camel-ews-folder.c b/src/camel/camel-ews-folder.c
index db937dc..bb4aabc 100644
--- a/src/camel/camel-ews-folder.c
+++ b/src/camel/camel-ews-folder.c
@@ -62,19 +62,14 @@ which needs to be better organized via functions */
#define MAX_ATTACHMENT_SIZE 1*1024*1024 /*In bytes*/
/* there are written more follow-up flags, but it's read only few of them */
-#define SUMMARY_FOLLOWUP_FLAGS " mapi:int:0x1090" /* PidTagFlagStatus */ \
- " mapi:time:0x1091" /* PidTagFlagCompleteTime */ \
- " mapi:dist:string:Common:0x8530" /* PidLidFlagRequest */ \
- " mapi:dist:time:Task:0x8105" /* PidLidTaskDueDate */ \
- " mapi:string:0x007D" /* PidTagTransportMessageHeaders */
+#define SUMMARY_ITEM_FLAGS "item:ResponseObjects item:Sensitivity item:Importance item:Categories"
-#define SUMMARY_ITEM_FLAGS "item:ResponseObjects item:Sensitivity item:Importance item:Categories"
SUMMARY_FOLLOWUP_FLAGS
#define ITEM_PROPS "item:Subject item:DateTimeReceived item:DateTimeSent item:DateTimeCreated item:Size " \
"item:HasAttachments item:InReplyTo"
#define SUMMARY_ITEM_PROPS ITEM_PROPS " " SUMMARY_ITEM_FLAGS
-#define SUMMARY_MESSAGE_FLAGS SUMMARY_ITEM_FLAGS " message:IsRead mapi:int:0x0e07 mapi:int:0x0e17
mapi:int:0x1080 mapi:int:0x1081"
+#define SUMMARY_MESSAGE_FLAGS SUMMARY_ITEM_FLAGS " message:IsRead"
#define SUMMARY_MESSAGE_PROPS ITEM_PROPS " message:From message:Sender message:ToRecipients
message:CcRecipients " \
"message:BccRecipients message:IsRead message:References message:InternetMessageId " \
SUMMARY_MESSAGE_FLAGS
@@ -106,6 +101,73 @@ static gboolean ews_refresh_info_sync (CamelFolder *folder, GCancellable *cancel
G_DEFINE_TYPE (CamelEwsFolder, camel_ews_folder, CAMEL_TYPE_OFFLINE_FOLDER)
+static GSList *
+ews_folder_get_summary_followup_mapi_flags (void)
+{
+ GSList *list = NULL;
+ EEwsExtendedFieldURI *ext_uri;
+
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->prop_tag = g_strdup_printf ("%d", 0x1090); /* PidTagFlagStatus */
+ ext_uri->prop_type = g_strdup ("Integer");
+ list = g_slist_append (list, ext_uri);
+
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->prop_tag = g_strdup_printf ("%d", 0x1091); /* PidTagFlagCompleteTime */
+ ext_uri->prop_type = g_strdup ("SystemTime");
+ list = g_slist_append (list, ext_uri);
+
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->prop_tag = g_strdup_printf ("%d", 0x007D); /* PidTagTransportMessageHeaders */
+ ext_uri->prop_type = g_strdup ("String");
+ list = g_slist_append (list, ext_uri);
+
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->distinguished_prop_set_id = g_strdup ("Common");
+ ext_uri->prop_id = g_strdup_printf ("%d", 0x8530); /* PidLidFlagRequest */
+ ext_uri->prop_type = g_strdup ("String");
+ list = g_slist_append (list, ext_uri);
+
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->distinguished_prop_set_id = g_strdup ("Task");
+ ext_uri->prop_id = g_strdup_printf ("%d", 0x8105); /* PidLidTaskDueDate */
+ ext_uri->prop_type = g_strdup ("SystemTime");
+ list = g_slist_append (list, ext_uri);
+
+ return list;
+}
+
+static GSList *
+ews_folder_get_summary_message_mapi_flags (void)
+{
+ GSList *list;
+ EEwsExtendedFieldURI *ext_uri;
+
+ list = ews_folder_get_summary_followup_mapi_flags ();
+
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->prop_tag = g_strdup_printf ("%d", 0x0e07);
+ ext_uri->prop_type = g_strdup ("Integer");
+ list = g_slist_append (list, ext_uri);
+
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->prop_tag = g_strdup_printf ("%d", 0x0e17);
+ ext_uri->prop_type = g_strdup ("Integer");
+ list = g_slist_append (list, ext_uri);
+
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->prop_tag = g_strdup_printf ("%d", 0x1080);
+ ext_uri->prop_type = g_strdup ("Integer");
+ list = g_slist_append (list, ext_uri);
+
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->prop_tag = g_strdup_printf ("%d", 0x1081);
+ ext_uri->prop_type = g_strdup ("Integer");
+ list = g_slist_append (list, ext_uri);
+
+ return list;
+}
+
static gchar *
ews_get_filename (CamelFolder *folder,
const gchar *uid,
@@ -405,6 +467,7 @@ camel_ews_folder_get_message (CamelFolder *folder,
CamelEwsFolder *ews_folder;
CamelEwsFolderPrivate *priv;
EEwsConnection *cnc;
+ EEwsAdditionalProps *add_props = NULL;
CamelEwsStore *ews_store;
const gchar *mime_content;
CamelMimeMessage *message = NULL;
@@ -465,14 +528,18 @@ camel_ews_folder_get_message (CamelFolder *folder,
goto exit;
}
+ add_props = e_ews_additional_props_new ();
+ add_props->field_uri = g_strdup ("item:MimeContent");
+
res = e_ews_connection_get_items_sync (
- cnc, pri, ids, "IdOnly", "item:MimeContent",
+ cnc, pri, ids, "IdOnly", add_props,
TRUE, mime_dir, E_EWS_BODY_TYPE_ANY,
&items,
(ESoapProgressFn) camel_operation_progress,
(gpointer) cancellable,
cancellable, &local_error);
g_free (mime_dir);
+ e_ews_additional_props_free (add_props);
if (!res || !items) {
camel_ews_store_maybe_disconnect (ews_store, local_error);
@@ -496,15 +563,20 @@ camel_ews_folder_get_message (CamelFolder *folder,
const EwsId *calendar_item_accept_id = NULL;
gboolean is_calendar_UID = TRUE;
+ add_props = e_ews_additional_props_new ();
+ add_props->field_uri = g_strdup ("meeting:AssociatedCalendarItemId");
+
// Get AssociatedCalendarItemId with second get_items call
res = e_ews_connection_get_items_sync (
- cnc, pri, ids, "IdOnly",
- "meeting:AssociatedCalendarItemId",
+ cnc, pri, ids, "IdOnly", add_props,
FALSE, NULL, E_EWS_BODY_TYPE_ANY,
&items_req,
(ESoapProgressFn) camel_operation_progress,
(gpointer) cancellable,
cancellable, &local_error);
+
+ e_ews_additional_props_free (add_props);
+
if (!res || (items_req && e_ews_item_get_item_type (items_req->data) ==
E_EWS_ITEM_TYPE_ERROR)) {
if (items_req) {
g_object_unref (items_req->data);
@@ -1287,13 +1359,23 @@ sync_updated_items (CamelEwsFolder *ews_folder,
}
g_slist_free (updated_items);
- if (msg_ids)
+
+ if (msg_ids) {
+ EEwsAdditionalProps *add_props;
+
+ add_props = e_ews_additional_props_new ();
+ add_props->field_uri = g_strdup (SUMMARY_MESSAGE_FLAGS);
+ add_props->extended_furis = ews_folder_get_summary_message_mapi_flags ();
+
e_ews_connection_get_items_sync (
cnc, EWS_PRIORITY_MEDIUM,
- msg_ids, "IdOnly", SUMMARY_MESSAGE_FLAGS,
+ msg_ids, "IdOnly", add_props,
FALSE, NULL, E_EWS_BODY_TYPE_ANY, &items, NULL, NULL,
cancellable, &local_error);
+ e_ews_additional_props_free (add_props);
+ }
+
camel_ews_utils_sync_updated_items (ews_folder, items);
items = NULL;
if (local_error) {
@@ -1302,12 +1384,21 @@ sync_updated_items (CamelEwsFolder *ews_folder,
goto exit;
}
- if (generic_item_ids)
+ if (generic_item_ids) {
+ EEwsAdditionalProps *add_props;
+
+ add_props = e_ews_additional_props_new ();
+ add_props->field_uri = g_strdup (SUMMARY_ITEM_FLAGS);
+ add_props->extended_furis = ews_folder_get_summary_followup_mapi_flags ();
+
e_ews_connection_get_items_sync (
cnc, EWS_PRIORITY_MEDIUM,
- generic_item_ids, "IdOnly", SUMMARY_ITEM_FLAGS,
+ generic_item_ids, "IdOnly", add_props,
FALSE, NULL, E_EWS_BODY_TYPE_ANY, &items, NULL, NULL,
cancellable, &local_error);
+
+ e_ews_additional_props_free (add_props);
+ }
camel_ews_utils_sync_updated_items (ews_folder, items);
if (local_error) {
@@ -1370,13 +1461,23 @@ sync_created_items (CamelEwsFolder *ews_folder,
}
g_slist_free (created_items);
- if (msg_ids)
+
+ if (msg_ids) {
+ EEwsAdditionalProps *add_props;
+
+ add_props = e_ews_additional_props_new ();
+ add_props->field_uri = g_strdup (SUMMARY_MESSAGE_PROPS);
+ add_props->extended_furis = ews_folder_get_summary_message_mapi_flags ();
+
e_ews_connection_get_items_sync (
cnc, EWS_PRIORITY_MEDIUM,
- msg_ids, "IdOnly", SUMMARY_MESSAGE_PROPS,
+ msg_ids, "IdOnly", add_props,
FALSE, NULL, E_EWS_BODY_TYPE_ANY, &items, NULL, NULL,
cancellable, &local_error);
+ e_ews_additional_props_free (add_props);
+ }
+
if (local_error) {
camel_ews_store_maybe_disconnect (ews_store, local_error);
g_propagate_error (error, local_error);
@@ -1386,13 +1487,23 @@ sync_created_items (CamelEwsFolder *ews_folder,
camel_ews_utils_sync_created_items (ews_folder, cnc, items, cancellable);
items = NULL;
- if (post_item_ids)
+
+ if (post_item_ids) {
+ EEwsAdditionalProps *add_props;
+
+ add_props = e_ews_additional_props_new ();
+ add_props->field_uri = g_strdup (SUMMARY_POSTITEM_PROPS);
+ add_props->extended_furis = ews_folder_get_summary_followup_mapi_flags ();
+
e_ews_connection_get_items_sync (
cnc, EWS_PRIORITY_MEDIUM,
- post_item_ids, "IdOnly", SUMMARY_POSTITEM_PROPS,
+ post_item_ids, "IdOnly", add_props,
FALSE, NULL, E_EWS_BODY_TYPE_ANY, &items, NULL, NULL,
cancellable, &local_error);
+ e_ews_additional_props_free (add_props);
+ }
+
if (local_error) {
camel_ews_store_maybe_disconnect (ews_store, local_error);
g_propagate_error (error, local_error);
@@ -1402,19 +1513,29 @@ sync_created_items (CamelEwsFolder *ews_folder,
camel_ews_utils_sync_created_items (ews_folder, cnc, items, cancellable);
items = NULL;
- if (generic_item_ids)
+ if (generic_item_ids) {
+ EEwsAdditionalProps *add_props;
+
+ add_props = e_ews_additional_props_new ();
+ add_props->field_uri = g_strdup (SUMMARY_ITEM_PROPS);
+ add_props->extended_furis = ews_folder_get_summary_followup_mapi_flags ();
+
e_ews_connection_get_items_sync (
cnc, EWS_PRIORITY_MEDIUM,
- generic_item_ids, "IdOnly", SUMMARY_ITEM_PROPS,
+ generic_item_ids, "IdOnly", add_props,
FALSE, NULL, E_EWS_BODY_TYPE_ANY, &items, NULL, NULL,
cancellable, &local_error);
+ e_ews_additional_props_free (add_props);
+ }
+
camel_ews_utils_sync_created_items (ews_folder, cnc, items, cancellable);
if (local_error) {
camel_ews_store_maybe_disconnect (ews_store, local_error);
g_propagate_error (error, local_error);
}
+
exit:
if (msg_ids) {
g_slist_foreach (msg_ids, (GFunc) g_free, NULL);
diff --git a/src/configuration/e-ews-config-utils.c b/src/configuration/e-ews-config-utils.c
index 5cff7bf..fb080ab 100644
--- a/src/configuration/e-ews-config-utils.c
+++ b/src/configuration/e-ews-config-utils.c
@@ -655,16 +655,16 @@ ews_settings_get_folder_sizes_thread (gpointer user_data)
&fsd->error);
if (cnc) {
- EwsAdditionalProps *add_props;
- EwsExtendedFieldURI *ext_uri;
+ EEwsAdditionalProps *add_props;
+ EEwsExtendedFieldURI *ext_uri;
GSList *ids, *l, *folders_ids = NULL, *folders_list = NULL;
fsd->folder_sizes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
/* Use MAPI property to retrieve folder size */
- add_props = g_new0 (EwsAdditionalProps, 1);
- ext_uri = g_new0 (EwsExtendedFieldURI, 1);
- ext_uri->prop_tag = g_strdup ("0x0e08"); /* Folder size property tag */
+ add_props = e_ews_additional_props_new ();
+ ext_uri = e_ews_extended_field_uri_new ();
+ ext_uri->prop_tag = g_strdup_printf ("%d", 0x0e08); /* Folder size property tag */
ext_uri->prop_type = g_strdup ("Integer");
add_props->extended_furis = g_slist_prepend (add_props->extended_furis, ext_uri);
@@ -697,11 +697,7 @@ ews_settings_get_folder_sizes_thread (gpointer user_data)
g_slist_free_full (folders_list, g_object_unref);
g_slist_free_full (folders_ids, (GDestroyNotify) e_ews_folder_id_free);
g_slist_free_full (ids, g_free);
- g_free (ext_uri->prop_type);
- g_free (ext_uri->prop_tag);
- g_free (ext_uri);
- g_slist_free (add_props->extended_furis);
- g_free (add_props);
+ e_ews_additional_props_free (add_props);
g_object_unref (cnc);
}
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index 216145b..46cd0d6 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -357,6 +357,59 @@ e_ews_calendar_time_zone_definition_free (EEwsCalendarTimeZoneDefinition *tzd)
}
}
+EEwsExtendedFieldURI *
+e_ews_extended_field_uri_new (void)
+{
+ return g_new0 (EEwsExtendedFieldURI, 1);
+}
+
+void
+e_ews_extended_field_uri_free (EEwsExtendedFieldURI *ex_field_uri)
+{
+ if (ex_field_uri != NULL) {
+ g_free (ex_field_uri->distinguished_prop_set_id);
+ g_free (ex_field_uri->prop_set_id);
+ g_free (ex_field_uri->prop_tag);
+ g_free (ex_field_uri->prop_name);
+ g_free (ex_field_uri->prop_id);
+ g_free (ex_field_uri->prop_type);
+ g_free (ex_field_uri);
+ }
+}
+
+EEwsIndexedFieldURI *
+e_ews_indexed_field_uri_new (void)
+{
+ return g_new0 (EEwsIndexedFieldURI, 1);
+}
+
+void
+e_ews_indexed_field_uri_free (EEwsIndexedFieldURI *id_field_uri)
+{
+ if (id_field_uri != NULL) {
+ g_free (id_field_uri->field_uri);
+ g_free (id_field_uri->field_index);
+ g_free (id_field_uri);
+ }
+}
+
+EEwsAdditionalProps *
+e_ews_additional_props_new (void)
+{
+ return g_new0 (EEwsAdditionalProps, 1);
+}
+
+void
+e_ews_additional_props_free (EEwsAdditionalProps *add_props)
+{
+ if (add_props != NULL) {
+ g_free (add_props->field_uri);
+ g_slist_free_full (add_props->extended_furis, (GDestroyNotify) e_ews_extended_field_uri_free);
+ g_slist_free_full (add_props->indexed_furis, (GDestroyNotify) e_ews_indexed_field_uri_free);
+ g_free (add_props);
+ }
+}
+
static EwsNode *
ews_node_new ()
{
@@ -3508,7 +3561,7 @@ e_ews_connection_set_mailbox (EEwsConnection *cnc,
static void
ews_append_additional_props_to_msg (ESoapMessage *msg,
- EwsAdditionalProps *add_props)
+ const EEwsAdditionalProps *add_props)
{
GSList *l;
@@ -3531,7 +3584,7 @@ ews_append_additional_props_to_msg (ESoapMessage *msg,
if (add_props->extended_furis) {
for (l = add_props->extended_furis; l != NULL; l = g_slist_next (l)) {
- EwsExtendedFieldURI *ex_furi = (EwsExtendedFieldURI *) l->data;
+ EEwsExtendedFieldURI *ex_furi = l->data;
e_soap_message_start_element (msg, "ExtendedFieldURI", NULL, NULL);
@@ -3559,7 +3612,7 @@ ews_append_additional_props_to_msg (ESoapMessage *msg,
if (add_props->indexed_furis) {
for (l = add_props->indexed_furis; l != NULL; l = g_slist_next (l)) {
- EwsIndexedFieldURI *in_furi = (EwsIndexedFieldURI *) l->data;
+ EEwsIndexedFieldURI *in_furi = l->data;
e_soap_message_start_element (msg, "IndexedFieldURI", NULL, NULL);
@@ -3587,14 +3640,14 @@ ews_write_sort_order_to_msg (ESoapMessage *msg,
if (sort_order->uri_type == NORMAL_FIELD_URI)
e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL, "FieldURI",
(gchar *) sort_order->field_uri);
else if (sort_order->uri_type == INDEXED_FIELD_URI) {
- EwsIndexedFieldURI *in_furi = (EwsIndexedFieldURI *) sort_order->field_uri;
+ EEwsIndexedFieldURI *in_furi = sort_order->field_uri;
e_soap_message_start_element (msg, "IndexedFieldURI", NULL, NULL);
e_soap_message_add_attribute (msg, "FieldURI", in_furi->field_uri, NULL, NULL);
e_soap_message_add_attribute (msg, "FieldIndex", in_furi->field_index, NULL, NULL);
e_soap_message_end_element (msg);
} else if (sort_order->uri_type == EXTENDED_FIELD_URI) {
- EwsExtendedFieldURI *ex_furi = (EwsExtendedFieldURI *) sort_order->field_uri;
+ EEwsExtendedFieldURI *ex_furi = sort_order->field_uri;
e_soap_message_start_element (msg, "ExtendedFieldURI", NULL, NULL);
@@ -3635,7 +3688,7 @@ e_ews_connection_sync_folder_items (EEwsConnection *cnc,
const gchar *last_sync_state,
const gchar *fid,
const gchar *default_props,
- const gchar *additional_props,
+ const EEwsAdditionalProps *add_props,
guint max_entries,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -3660,18 +3713,7 @@ e_ews_connection_sync_folder_items (EEwsConnection *cnc,
e_soap_message_start_element (msg, "ItemShape", "messages", NULL);
e_ews_message_write_string_parameter (msg, "BaseShape", NULL, default_props);
- if (additional_props && *additional_props) {
- gchar **prop = g_strsplit (additional_props, " ", 0);
- gint i = 0;
-
- e_soap_message_start_element (msg, "AdditionalProperties", NULL, NULL);
- while (prop[i]) {
- e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL, NULL,
"FieldURI", prop[i]);
- i++;
- }
- g_strfreev (prop);
- e_soap_message_end_element (msg);
- }
+ ews_append_additional_props_to_msg (msg, add_props);
e_soap_message_end_element (msg);
@@ -3743,7 +3785,7 @@ e_ews_connection_sync_folder_items_sync (EEwsConnection *cnc,
const gchar *old_sync_state,
const gchar *fid,
const gchar *default_props,
- const gchar *additional_props,
+ const EEwsAdditionalProps *add_props,
guint max_entries,
gchar **new_sync_state,
gboolean *includes_last_item,
@@ -3763,7 +3805,7 @@ e_ews_connection_sync_folder_items_sync (EEwsConnection *cnc,
e_ews_connection_sync_folder_items (
cnc, pri, old_sync_state, fid, default_props,
- additional_props, max_entries, cancellable,
+ add_props, max_entries, cancellable,
e_async_closure_callback, closure);
result = e_async_closure_wait (closure);
@@ -3837,7 +3879,7 @@ e_ews_connection_find_folder_items (EEwsConnection *cnc,
gint pri,
EwsFolderId *fid,
const gchar *default_props,
- EwsAdditionalProps *add_props,
+ const EEwsAdditionalProps *add_props,
EwsSortOrder *sort_order,
const gchar *query,
EEwsFolderType type,
@@ -3936,7 +3978,7 @@ e_ews_connection_find_folder_items_sync (EEwsConnection *cnc,
gint pri,
EwsFolderId *fid,
const gchar *default_props,
- EwsAdditionalProps *add_props,
+ const EEwsAdditionalProps *add_props,
EwsSortOrder *sort_order,
const gchar *query,
EEwsFolderType type,
@@ -4146,102 +4188,12 @@ e_ews_connection_satisfies_server_version (EEwsConnection *cnc,
return cnc->priv->version >= version;
}
-static gboolean
-ews_decode_mapi_property_string_type (const gchar *type_string,
- EEwsMessageDataType *data_type)
-{
- g_return_val_if_fail (type_string != NULL, FALSE);
- g_return_val_if_fail (data_type != NULL, FALSE);
-
- if (g_ascii_strcasecmp (type_string, "boolean") == 0) {
- *data_type = E_EWS_MESSAGE_DATA_TYPE_BOOLEAN;
- return TRUE;
- }
-
- if (g_ascii_strcasecmp (type_string, "int") == 0) {
- *data_type = E_EWS_MESSAGE_DATA_TYPE_INT;
- return TRUE;
- }
-
- if (g_ascii_strcasecmp (type_string, "double") == 0) {
- *data_type = E_EWS_MESSAGE_DATA_TYPE_DOUBLE;
- return TRUE;
- }
-
- if (g_ascii_strcasecmp (type_string, "string") == 0) {
- *data_type = E_EWS_MESSAGE_DATA_TYPE_STRING;
- return TRUE;
- }
-
- if (g_ascii_strcasecmp (type_string, "time") == 0) {
- *data_type = E_EWS_MESSAGE_DATA_TYPE_TIME;
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-ews_decode_mapi_property_string_id (const gchar *hexa_id,
- guint32 *prop_id)
-{
- gint64 value;
-
- g_return_val_if_fail (hexa_id != NULL, FALSE);
- g_return_val_if_fail (prop_id != NULL, FALSE);
- g_return_val_if_fail (g_ascii_strncasecmp (hexa_id, "0x", 2) == 0, FALSE);
-
- value = g_ascii_strtoll (hexa_id + 2, NULL, 16);
- *prop_id = (guint32) value;
-
- return value != 0;
-}
-
-/* expects either "mapi:Type:0xPropId" or "mapi:dist:Type:SetId:0xPropId"
- where 'type' is one of boolean/int/double/string/time */
-static gboolean
-ews_decode_mapi_property_string (const gchar *prop_descr,
- EEwsMessageDataType *data_type,
- guint32 *prop_id,
- gchar **distinguished_set_id)
-{
- gchar **split;
- guint len;
- gboolean res = FALSE;
-
- g_return_val_if_fail (prop_descr != NULL, FALSE);
- g_return_val_if_fail (data_type != NULL, FALSE);
- g_return_val_if_fail (prop_id != NULL, FALSE);
- g_return_val_if_fail (distinguished_set_id != NULL, FALSE);
- g_return_val_if_fail (g_ascii_strncasecmp (prop_descr, "mapi:", 5) == 0, FALSE);
-
- split = g_strsplit (prop_descr, ":", 0);
- g_return_val_if_fail (split != NULL, FALSE);
-
- len = g_strv_length (split);
- if (len == 3
- && ews_decode_mapi_property_string_type (split[1], data_type)
- && ews_decode_mapi_property_string_id (split[2], prop_id)) {
- res = TRUE;
- } else if (len == 5
- && g_ascii_strcasecmp (split[1], "dist") == 0
- && ews_decode_mapi_property_string_type (split[2], data_type)
- && ews_decode_mapi_property_string_id (split[4], prop_id)) {
- *distinguished_set_id = g_strdup (split[3]);
- res = *distinguished_set_id && **distinguished_set_id;
- }
-
- g_strfreev (split);
-
- return res;
-}
-
void
e_ews_connection_get_items (EEwsConnection *cnc,
gint pri,
const GSList *ids,
const gchar *default_props,
- const gchar *additional_props,
+ const EEwsAdditionalProps *add_props,
gboolean include_mime,
const gchar *mime_directory,
EEwsBodyType body_type,
@@ -4296,42 +4248,8 @@ e_ews_connection_get_items (EEwsConnection *cnc,
break;
}
- if (additional_props && *additional_props) {
- gchar **prop = g_strsplit (additional_props, " ", 0);
- gint i = 0;
-
- e_soap_message_start_element (msg, "AdditionalProperties", NULL, NULL);
- while (prop[i]) {
- if (g_ascii_strncasecmp (prop[i], "mapi:", 5) == 0) {
- EEwsMessageDataType data_type;
- guint32 prop_id = -1;
- gchar *distinguished_set_id = NULL;
-
- if (ews_decode_mapi_property_string (prop[i], &data_type, &prop_id,
&distinguished_set_id)) {
- const gchar *prop_type = e_ews_message_data_type_get_xml_name
(data_type);
-
- if (prop_type) {
- if (distinguished_set_id) {
- e_ews_message_write_extended_distinguished_tag (msg,
distinguished_set_id, prop_id, prop_type);
- } else {
- e_ews_message_write_extended_tag (msg, prop_id,
prop_type);
- }
- } else {
- g_warning ("%s: Failed to decode mapi property type from
'%s'", G_STRFUNC, prop[i]);
- }
- } else {
- g_warning ("%s: Failed to decode mapi property from '%s'", G_STRFUNC,
prop[i]);
- }
+ ews_append_additional_props_to_msg (msg, add_props);
- g_free (distinguished_set_id);
- } else {
- e_ews_message_write_string_parameter_with_attribute (msg, "FieldURI", NULL,
NULL, "FieldURI", prop[i]);
- }
- i++;
- }
- g_strfreev (prop);
- e_soap_message_end_element (msg);
- }
e_soap_message_end_element (msg);
e_soap_message_start_element (msg, "ItemIds", "messages", NULL);
@@ -4394,7 +4312,7 @@ e_ews_connection_get_items_sync (EEwsConnection *cnc,
gint pri,
const GSList *ids,
const gchar *default_props,
- const gchar *additional_props,
+ const EEwsAdditionalProps *add_props,
gboolean include_mime,
const gchar *mime_directory,
EEwsBodyType body_type,
@@ -4414,7 +4332,7 @@ e_ews_connection_get_items_sync (EEwsConnection *cnc,
e_ews_connection_get_items (
cnc, pri,ids, default_props,
- additional_props, include_mime,
+ add_props, include_mime,
mime_directory, body_type, progress_fn,
progress_data, cancellable,
e_async_closure_callback, closure);
@@ -5831,7 +5749,7 @@ void
e_ews_connection_get_folder (EEwsConnection *cnc,
gint pri,
const gchar *folder_shape,
- EwsAdditionalProps *add_props,
+ const EEwsAdditionalProps *add_props,
GSList *folder_ids,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -5917,7 +5835,7 @@ gboolean
e_ews_connection_get_folder_sync (EEwsConnection *cnc,
gint pri,
const gchar *folder_shape,
- EwsAdditionalProps *add_props,
+ const EEwsAdditionalProps *add_props,
GSList *folder_ids,
GSList **folders,
GCancellable *cancellable,
diff --git a/src/server/e-ews-connection.h b/src/server/e-ews-connection.h
index 7ac47e9..a998441 100644
--- a/src/server/e-ews-connection.h
+++ b/src/server/e-ews-connection.h
@@ -181,18 +181,18 @@ typedef struct {
gchar *prop_name;
gchar *prop_id;
gchar *prop_type;
-} EwsExtendedFieldURI;
+} EEwsExtendedFieldURI;
typedef struct {
gchar *field_uri;
gchar *field_index;
-} EwsIndexedFieldURI;
+} EEwsIndexedFieldURI;
typedef struct {
gchar *field_uri;
GSList *extended_furis;
GSList *indexed_furis;
-} EwsAdditionalProps;
+} EEwsAdditionalProps;
typedef struct {
gchar *order;
@@ -377,6 +377,18 @@ EEwsCalendarTimeZoneDefinition *
void e_ews_calendar_time_zone_definition_free
(EEwsCalendarTimeZoneDefinition *tzd);
+EEwsExtendedFieldURI *
+ e_ews_extended_field_uri_new (void);
+void e_ews_extended_field_uri_free (EEwsExtendedFieldURI *ex_field_uri);
+
+EEwsIndexedFieldURI *
+ e_ews_indexed_field_uri_new (void);
+void e_ews_indexed_field_uri_free (EEwsIndexedFieldURI *id_field_uri);
+
+EEwsAdditionalProps *
+ e_ews_additional_props_new (void);
+void e_ews_additional_props_free (EEwsAdditionalProps *add_props);
+
EEwsNotificationEvent *
e_ews_notification_event_new (void);
void e_ews_notification_event_free (EEwsNotificationEvent *event);
@@ -447,7 +459,7 @@ void e_ews_connection_sync_folder_items
const gchar *old_sync_state,
const gchar *fid,
const gchar *default_props,
- const gchar *additional_props,
+ const EEwsAdditionalProps *add_props,
guint max_entries,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -467,7 +479,7 @@ gboolean e_ews_connection_sync_folder_items_sync
const gchar *old_sync_state,
const gchar *fid,
const gchar *default_props,
- const gchar *additional_props,
+ const EEwsAdditionalProps *add_props,
guint max_entries,
gchar **new_sync_state,
gboolean *includes_last_item,
@@ -486,7 +498,7 @@ void e_ews_connection_find_folder_items
gint pri,
EwsFolderId *fid,
const gchar *props,
- EwsAdditionalProps *add_props,
+ const EEwsAdditionalProps *add_props,
EwsSortOrder *sort_order,
const gchar *query,
EEwsFolderType type,
@@ -505,7 +517,7 @@ gboolean e_ews_connection_find_folder_items_sync
gint pri,
EwsFolderId *fid,
const gchar *default_props,
- EwsAdditionalProps *add_props,
+ const EEwsAdditionalProps *add_props,
EwsSortOrder *sort_order,
const gchar *query,
EEwsFolderType type,
@@ -532,7 +544,7 @@ void e_ews_connection_get_items (EEwsConnection *cnc,
gint pri,
const GSList *ids,
const gchar *default_props,
- const gchar *additional_props,
+ const EEwsAdditionalProps *add_props,
gboolean include_mime,
const gchar *mime_directory,
EEwsBodyType body_type,
@@ -550,7 +562,7 @@ gboolean e_ews_connection_get_items_sync (EEwsConnection *cnc,
gint pri,
const GSList *ids,
const gchar *default_props,
- const gchar *additional_props,
+ const EEwsAdditionalProps *add_props,
gboolean include_mime,
const gchar *mime_directory,
EEwsBodyType body_type,
@@ -856,7 +868,7 @@ gboolean e_ews_connection_move_folder_sync
void e_ews_connection_get_folder (EEwsConnection *cnc,
gint pri,
const gchar *folder_shape,
- EwsAdditionalProps *add_props,
+ const EEwsAdditionalProps *add_props,
GSList *folder_ids,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -870,7 +882,7 @@ gboolean e_ews_connection_get_folder_sync
(EEwsConnection *cnc,
gint pri,
const gchar *folder_shape,
- EwsAdditionalProps *add_props,
+ const EEwsAdditionalProps *add_props,
GSList *folder_ids,
GSList **folders,
GCancellable *cancellable,
diff --git a/src/server/e-ews-item-change.c b/src/server/e-ews-item-change.c
index 38270c1..f560de8 100644
--- a/src/server/e-ews-item-change.c
+++ b/src/server/e-ews-item-change.c
@@ -566,3 +566,325 @@ e_ews_message_add_extended_property_distinguished_tag_time (ESoapMessage *msg,
ews_message_add_extended_property_distinguished_tag (msg, set_id, prop_id,
E_EWS_MESSAGE_DATA_TYPE_TIME, &value);
}
+
+void
+e_ews_message_add_delete_item_field_extended_name (ESoapMessage *msg,
+ const gchar *name,
+ EEwsMessageDataType data_type)
+{
+ const gchar *prop_type = e_ews_message_data_type_get_xml_name (data_type);
+
+ g_return_if_fail (prop_type != NULL);
+
+ e_soap_message_start_element (msg, "DeleteItemField", NULL, NULL);
+ e_ews_message_write_extended_name (msg, name, prop_type);
+ e_soap_message_end_element (msg); /* DeleteItemField */
+}
+
+void
+e_ews_message_add_delete_item_field_extended_distinguished_name (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ EEwsMessageDataType data_type)
+{
+ const gchar *prop_type = e_ews_message_data_type_get_xml_name (data_type);
+
+ g_return_if_fail (prop_type != NULL);
+
+ e_soap_message_start_element (msg, "DeleteItemField", NULL, NULL);
+ e_ews_message_write_extended_distinguished_name (msg, set_id, name, prop_type);
+ e_soap_message_end_element (msg); /* DeleteItemField */
+}
+
+static void
+ews_message_add_extended_property_name (ESoapMessage *msg,
+ const gchar *name,
+ EEwsMessageDataType data_type,
+ gconstpointer value)
+{
+ const gchar *prop_type = e_ews_message_data_type_get_xml_name (data_type);
+
+ g_return_if_fail (prop_type != NULL);
+
+ e_soap_message_start_element (msg, "ExtendedProperty", NULL, NULL);
+
+ e_ews_message_write_extended_name (msg, name, prop_type);
+ ews_message_write_data_value (msg, data_type, value);
+
+ e_soap_message_end_element (msg); /* ExtendedProperty */
+}
+
+static void
+ews_message_add_extended_property_distinguished_name (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ EEwsMessageDataType data_type,
+ gconstpointer value)
+{
+ const gchar *prop_type = e_ews_message_data_type_get_xml_name (data_type);
+
+ g_return_if_fail (prop_type != NULL);
+
+ e_soap_message_start_element (msg, "ExtendedProperty", NULL, NULL);
+
+ e_ews_message_write_extended_distinguished_name (msg, set_id, name, prop_type);
+ ews_message_write_data_value (msg, data_type, value);
+
+ e_soap_message_end_element (msg); /* ExtendedProperty */
+}
+
+static void
+ews_message_add_set_item_field_extended_name (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *name,
+ EEwsMessageDataType data_type,
+ gconstpointer value)
+{
+ const gchar *prop_type = e_ews_message_data_type_get_xml_name (data_type);
+
+ g_return_if_fail (prop_type != NULL);
+
+ e_soap_message_start_element (msg, "SetItemField", NULL, NULL);
+ e_ews_message_write_extended_name (msg, name, prop_type);
+
+ e_soap_message_start_element (msg, elem_name, elem_prefix, NULL);
+ ews_message_add_extended_property_name (msg, name, data_type, value);
+ e_soap_message_end_element (msg); /* elem_name */
+
+ e_soap_message_end_element (msg); /* SetItemField */
+}
+
+static void
+ews_message_add_set_item_field_extended_distinguished_name (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *set_id,
+ const gchar *name,
+ EEwsMessageDataType data_type,
+ gconstpointer value)
+{
+ const gchar *prop_type = e_ews_message_data_type_get_xml_name (data_type);
+
+ g_return_if_fail (prop_type != NULL);
+
+ e_soap_message_start_element (msg, "SetItemField", NULL, NULL);
+
+ e_ews_message_write_extended_distinguished_name (msg, set_id, name, prop_type);
+
+ e_soap_message_start_element (msg, elem_name, elem_prefix, NULL);
+ ews_message_add_extended_property_distinguished_name (msg, set_id, name, data_type, value);
+ e_soap_message_end_element (msg); /* elem_name */
+
+ e_soap_message_end_element (msg); /* SetItemField */
+}
+
+void
+e_ews_message_add_set_item_field_extended_name_boolean (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *name,
+ gboolean value)
+{
+ ews_message_add_set_item_field_extended_name (msg, elem_prefix, elem_name, name,
+ E_EWS_MESSAGE_DATA_TYPE_BOOLEAN, &value);
+}
+
+void
+e_ews_message_add_set_item_field_extended_name_int (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *name,
+ gint value)
+{
+ ews_message_add_set_item_field_extended_name (msg, elem_prefix, elem_name, name,
+ E_EWS_MESSAGE_DATA_TYPE_INT, &value);
+}
+
+void
+e_ews_message_add_set_item_field_extended_name_double (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *name,
+ gdouble value)
+{
+ ews_message_add_set_item_field_extended_name (msg, elem_prefix, elem_name, name,
+ E_EWS_MESSAGE_DATA_TYPE_DOUBLE, &value);
+}
+
+void
+e_ews_message_add_set_item_field_extended_name_string (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *name,
+ const gchar *value)
+{
+ ews_message_add_set_item_field_extended_name (msg, elem_prefix, elem_name, name,
+ E_EWS_MESSAGE_DATA_TYPE_STRING, value);
+}
+
+void
+e_ews_message_add_set_item_field_extended_name_time (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *name,
+ time_t value)
+{
+ ews_message_add_set_item_field_extended_name (msg, elem_prefix, elem_name, name,
+ E_EWS_MESSAGE_DATA_TYPE_TIME, &value);
+}
+
+void
+e_ews_message_add_set_item_field_extended_distinguished_name_boolean (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *set_id,
+ const gchar *name,
+ gboolean value)
+{
+ ews_message_add_set_item_field_extended_distinguished_name (msg, elem_prefix, elem_name, set_id, name,
+ E_EWS_MESSAGE_DATA_TYPE_BOOLEAN, &value);
+}
+
+void
+e_ews_message_add_set_item_field_extended_distinguished_name_int (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *set_id,
+ const gchar *name,
+ gint value)
+{
+ ews_message_add_set_item_field_extended_distinguished_name (msg, elem_prefix, elem_name, set_id, name,
+ E_EWS_MESSAGE_DATA_TYPE_INT, &value);
+}
+
+void
+e_ews_message_add_set_item_field_extended_distinguished_name_double (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *set_id,
+ const gchar *name,
+ gdouble value)
+{
+ ews_message_add_set_item_field_extended_distinguished_name (msg, elem_prefix, elem_name, set_id, name,
+ E_EWS_MESSAGE_DATA_TYPE_DOUBLE, &value);
+}
+
+void
+e_ews_message_add_set_item_field_extended_distinguished_name_string (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *set_id,
+ const gchar *name,
+ const gchar *value)
+{
+ ews_message_add_set_item_field_extended_distinguished_name (msg, elem_prefix, elem_name, set_id, name,
+ E_EWS_MESSAGE_DATA_TYPE_STRING, value);
+}
+
+void
+e_ews_message_add_set_item_field_extended_distinguished_name_time (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *set_id,
+ const gchar *name,
+ time_t value)
+{
+ ews_message_add_set_item_field_extended_distinguished_name (msg, elem_prefix, elem_name, set_id, name,
+ E_EWS_MESSAGE_DATA_TYPE_TIME, &value);
+}
+
+void
+e_ews_message_add_extended_property_name_boolean (ESoapMessage *msg,
+ const gchar *name,
+ gboolean value)
+{
+ ews_message_add_extended_property_name (msg, name,
+ E_EWS_MESSAGE_DATA_TYPE_BOOLEAN, &value);
+}
+
+void
+e_ews_message_add_extended_property_name_int (ESoapMessage *msg,
+ const gchar *name,
+ gint value)
+{
+ ews_message_add_extended_property_name (msg, name,
+ E_EWS_MESSAGE_DATA_TYPE_INT, &value);
+}
+
+void
+e_ews_message_add_extended_property_name_double (ESoapMessage *msg,
+ const gchar *name,
+ gdouble value)
+{
+ ews_message_add_extended_property_name (msg, name,
+ E_EWS_MESSAGE_DATA_TYPE_DOUBLE, &value);
+}
+
+void
+e_ews_message_add_extended_property_name_string (ESoapMessage *msg,
+ const gchar *name,
+ const gchar *value)
+{
+ ews_message_add_extended_property_name (msg, name,
+ E_EWS_MESSAGE_DATA_TYPE_STRING, value);
+}
+
+void
+e_ews_message_add_extended_property_name_time (ESoapMessage *msg,
+ const gchar *name,
+ time_t value)
+{
+ ews_message_add_extended_property_name (msg, name,
+ E_EWS_MESSAGE_DATA_TYPE_TIME, &value);
+}
+
+void
+e_ews_message_add_extended_property_distinguished_name_boolean (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ gboolean value)
+{
+ ews_message_add_extended_property_distinguished_name (msg, set_id, name,
+ E_EWS_MESSAGE_DATA_TYPE_BOOLEAN, &value);
+}
+
+void
+e_ews_message_add_extended_property_distinguished_name_int (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ gint value)
+{
+ ews_message_add_extended_property_distinguished_name (msg, set_id, name,
+ E_EWS_MESSAGE_DATA_TYPE_INT, &value);
+}
+
+void
+e_ews_message_add_extended_property_distinguished_name_double (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ gdouble value)
+{
+ ews_message_add_extended_property_distinguished_name (msg, set_id, name,
+ E_EWS_MESSAGE_DATA_TYPE_DOUBLE, &value);
+}
+
+void
+e_ews_message_add_extended_property_distinguished_name_string (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ const gchar *value)
+{
+ ews_message_add_extended_property_distinguished_name (msg, set_id, name,
+ E_EWS_MESSAGE_DATA_TYPE_STRING, value);
+}
+
+void
+e_ews_message_add_extended_property_distinguished_name_time (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ time_t value)
+{
+ ews_message_add_extended_property_distinguished_name (msg, set_id, name,
+ E_EWS_MESSAGE_DATA_TYPE_TIME, &value);
+}
diff --git a/src/server/e-ews-item-change.h b/src/server/e-ews-item-change.h
index 0102daa..44b3392 100644
--- a/src/server/e-ews-item-change.h
+++ b/src/server/e-ews-item-change.h
@@ -173,6 +173,118 @@ void e_ews_message_add_extended_property_distinguished_tag_time
guint32 prop_id,
time_t value);
+void e_ews_message_add_delete_item_field_extended_name (ESoapMessage *msg,
+ const gchar *name,
+ EEwsMessageDataType data_type);
+
+void e_ews_message_add_delete_item_field_extended_distinguished_name
+ (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ EEwsMessageDataType data_type);
+
+void e_ews_message_add_set_item_field_extended_name_boolean (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *name,
+ gboolean value);
+void e_ews_message_add_set_item_field_extended_name_int (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *name,
+ gint value);
+void e_ews_message_add_set_item_field_extended_name_double (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *name,
+ gdouble value);
+void e_ews_message_add_set_item_field_extended_name_string (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *name,
+ const gchar *value);
+void e_ews_message_add_set_item_field_extended_name_time (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *name,
+ time_t value);
+void e_ews_message_add_set_item_field_extended_distinguished_name_boolean
+ (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *set_id,
+ const gchar *name,
+ gboolean value);
+void e_ews_message_add_set_item_field_extended_distinguished_name_int
+ (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *set_id,
+ const gchar *name,
+ gint value);
+void e_ews_message_add_set_item_field_extended_distinguished_name_double
+ (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *set_id,
+ const gchar *name,
+ gdouble value);
+void e_ews_message_add_set_item_field_extended_distinguished_name_string
+ (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *set_id,
+ const gchar *name,
+ const gchar *value);
+void e_ews_message_add_set_item_field_extended_distinguished_name_time
+ (ESoapMessage *msg,
+ const gchar *elem_prefix,
+ const gchar *elem_name,
+ const gchar *set_id,
+ const gchar *name,
+ time_t value);
+void e_ews_message_add_extended_property_name_boolean (ESoapMessage *msg,
+ const gchar *name,
+ gboolean value);
+void e_ews_message_add_extended_property_name_int (ESoapMessage *msg,
+ const gchar *name,
+ gint value);
+void e_ews_message_add_extended_property_name_double (ESoapMessage *msg,
+ const gchar *name,
+ gdouble value);
+void e_ews_message_add_extended_property_name_string (ESoapMessage *msg,
+ const gchar *name,
+ const gchar *value);
+void e_ews_message_add_extended_property_name_time (ESoapMessage *msg,
+ const gchar *name,
+ time_t value);
+void e_ews_message_add_extended_property_distinguished_name_boolean
+ (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ gboolean value);
+void e_ews_message_add_extended_property_distinguished_name_int
+ (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ gint value);
+void e_ews_message_add_extended_property_distinguished_name_double
+ (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ gdouble value);
+void e_ews_message_add_extended_property_distinguished_name_string
+ (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ const gchar *value);
+void e_ews_message_add_extended_property_distinguished_name_time
+ (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ time_t value);
+
+
G_END_DECLS
#endif
diff --git a/src/server/e-ews-item.c b/src/server/e-ews-item.c
index e7aad64..dde2cfa 100644
--- a/src/server/e-ews-item.c
+++ b/src/server/e-ews-item.c
@@ -181,7 +181,11 @@ struct _EEwsItemPrivate {
gchar *uid;
gchar *timezone;
+ gchar *start_timezone;
+ gchar *end_timezone;
gchar *contact_photo_id;
+ gchar *iana_start_time_zone;
+ gchar *iana_end_time_zone;
GSList *to_recipients;
GSList *cc_recipients;
@@ -268,9 +272,21 @@ e_ews_item_dispose (GObject *object)
g_free (priv->timezone);
priv->timezone = NULL;
+ g_free (priv->start_timezone);
+ priv->start_timezone = NULL;
+
+ g_free (priv->end_timezone);
+ priv->end_timezone = NULL;
+
g_free (priv->contact_photo_id);
priv->contact_photo_id = NULL;
+ g_free (priv->iana_start_time_zone);
+ priv->iana_start_time_zone = NULL;
+
+ g_free (priv->iana_end_time_zone);
+ priv->iana_end_time_zone = NULL;
+
g_slist_free_full (priv->to_recipients, (GDestroyNotify) e_ews_mailbox_free);
priv->to_recipients = NULL;
@@ -471,7 +487,7 @@ parse_extended_property (EEwsItemPrivate *priv,
{
EEwsMessageDataType data_type;
ESoapParameter *subparam;
- gchar *str, *setid;
+ gchar *str, *setid, *name, *value;
guint32 tag;
subparam = e_soap_parameter_get_first_child_by_name (param, "ExtendedFieldURI");
@@ -499,67 +515,80 @@ parse_extended_property (EEwsItemPrivate *priv,
}
g_free (str);
- str = e_soap_parameter_get_property (subparam, "PropertyTag");
- if (!str) {
- str = e_soap_parameter_get_property (subparam, "PropertyId");
- if (!str)
- return;
- }
+ name = e_soap_parameter_get_property (subparam, "PropertyName");
+ if (!name) {
+ str = e_soap_parameter_get_property (subparam, "PropertyTag");
+ if (!str) {
+ str = e_soap_parameter_get_property (subparam, "PropertyId");
+ if (!str)
+ return;
+ }
- tag = strtol (str, NULL, 0);
- g_free (str);
+ tag = strtol (str, NULL, 0);
+ g_free (str);
+ }
setid = e_soap_parameter_get_property (subparam, "DistinguishedPropertySetId");
subparam = e_soap_parameter_get_first_child_by_name (param, "Value");
if (!subparam) {
g_free (setid);
+ g_free (name);
return;
}
- str = e_soap_parameter_get_string_value (subparam);
- if (!str) {
+ value = e_soap_parameter_get_string_value (subparam);
+ if (!value) {
g_free (setid);
+ g_free (name);
return;
}
if (data_type == E_EWS_MESSAGE_DATA_TYPE_INT) {
- guint32 value;
+ guint32 num_value;
- value = strtol (str, NULL, 0);
+ num_value = strtol (value, NULL, 0);
switch (tag) {
case 0x01080: /* PidTagIconIndex */
- priv->mapi_icon_index = value;
+ priv->mapi_icon_index = num_value;
break;
case 0x1081:
- priv->mapi_last_verb_executed = value;
+ priv->mapi_last_verb_executed = num_value;
break;
case 0xe07:
- priv->mapi_message_flags = value;
+ priv->mapi_message_flags = num_value;
break;
case 0xe17:
- priv->mapi_message_status = value;
+ priv->mapi_message_status = num_value;
break;
}
}
if (setid) {
- GHashTable *set_hash = g_hash_table_lookup (priv->mapi_extended_sets, setid);
- if (!set_hash) {
- set_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
- g_hash_table_insert (priv->mapi_extended_sets, setid, set_hash);
- }
+ if (g_strcmp0 (name, "EvolutionEWSStartTimeZone") == 0) {
+ priv->iana_start_time_zone = g_strdup (value);
+ } else if (g_strcmp0 (name, "EvolutionEWSEndTimeZone") == 0) {
+ priv->iana_end_time_zone = g_strdup (value);
+ } else {
+ GHashTable *set_hash = g_hash_table_lookup (priv->mapi_extended_sets, setid);
+
+ if (!set_hash) {
+ set_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
g_free);
+ g_hash_table_insert (priv->mapi_extended_sets, setid, set_hash);
+ }
- g_hash_table_insert (set_hash, GUINT_TO_POINTER (tag), g_strdup (str));
+ g_hash_table_insert (set_hash, GUINT_TO_POINTER (tag), g_strdup (value));
+ }
} else {
- g_hash_table_insert (priv->mapi_extended_tags, GUINT_TO_POINTER (tag), g_strdup (str));
+ g_hash_table_insert (priv->mapi_extended_tags, GUINT_TO_POINTER (tag), g_strdup (value));
}
- g_free (str);
+ g_free (value);
+ g_free (name);
}
static void
@@ -1175,11 +1204,11 @@ e_ews_item_set_from_soap_parameter (EEwsItem *item,
priv->calendar_item_accept_id->id = e_soap_parameter_get_property (subparam, "Id");
priv->calendar_item_accept_id->change_key = e_soap_parameter_get_property (subparam,
"ChangeKey");
} else if (!g_ascii_strcasecmp (name, "StartTimeZone")) {
- if (priv->timezone != NULL)
- g_free (priv->timezone);
-
- priv->timezone = e_soap_parameter_get_property (subparam, "Id");
+ priv->start_timezone = e_soap_parameter_get_property (subparam, "Id");
+ } else if (!g_ascii_strcasecmp (name, "EndTimeZone")) {
+ priv->end_timezone = e_soap_parameter_get_property (subparam, "Id");
}
+
}
return TRUE;
@@ -1478,6 +1507,22 @@ e_ews_item_get_importance (EEwsItem *item)
return item->priv->importance;
}
+const gchar *
+e_ews_item_get_iana_start_time_zone (EEwsItem *item)
+{
+ g_return_val_if_fail (E_IS_EWS_ITEM (item), NULL);
+
+ return item->priv->iana_start_time_zone;
+}
+
+const gchar *
+e_ews_item_get_iana_end_time_zone (EEwsItem *item)
+{
+ g_return_val_if_fail (E_IS_EWS_ITEM (item), NULL);
+
+ return item->priv->iana_end_time_zone;
+}
+
EwsMailbox *
e_ews_item_mailbox_from_soap_param (ESoapParameter *param)
{
@@ -2199,6 +2244,24 @@ e_ews_item_get_tzid (EEwsItem *item)
}
const gchar *
+e_ews_item_get_start_tzid (EEwsItem *item)
+{
+ g_return_val_if_fail (E_IS_EWS_ITEM (item), NULL);
+
+ /* can be NULL */
+ return item->priv->start_timezone;
+}
+
+const gchar *
+e_ews_item_get_end_tzid (EEwsItem *item)
+{
+ g_return_val_if_fail (E_IS_EWS_ITEM (item), NULL);
+
+ /* can be NULL */
+ return item->priv->end_timezone;
+}
+
+const gchar *
e_ews_item_get_contact_photo_id (EEwsItem *item)
{
g_return_val_if_fail (E_IS_EWS_ITEM (item), NULL);
diff --git a/src/server/e-ews-item.h b/src/server/e-ews-item.h
index 3e3dddd..e75fb7a 100644
--- a/src/server/e-ews-item.h
+++ b/src/server/e-ews-item.h
@@ -347,8 +347,13 @@ gboolean e_ews_item_task_has_complete_date
(EEwsItem * item,
gboolean * has_date);
const gchar * e_ews_item_get_tzid (EEwsItem *item);
+const gchar * e_ews_item_get_start_tzid (EEwsItem *item);
+const gchar * e_ews_item_get_end_tzid (EEwsItem *item);
const gchar * e_ews_item_get_contact_photo_id (EEwsItem *item);
-
+const gchar * e_ews_item_get_iana_start_time_zone
+ (EEwsItem *item);
+const gchar * e_ews_item_get_iana_end_time_zone
+ (EEwsItem *item);
/* Folder Permissions */
EEwsPermission *e_ews_permission_new (EEwsPermissionUserType user_type,
diff --git a/src/server/e-ews-message.c b/src/server/e-ews-message.c
index 207c63e..b10ef27 100644
--- a/src/server/e-ews-message.c
+++ b/src/server/e-ews-message.c
@@ -255,3 +255,27 @@ e_ews_message_write_extended_distinguished_tag (ESoapMessage *msg,
g_free (num);
}
+
+void
+e_ews_message_write_extended_name (ESoapMessage *msg,
+ const gchar *name,
+ const gchar *prop_type)
+{
+ e_soap_message_start_element (msg, "ExtendedFieldURI", NULL, NULL);
+ e_soap_message_add_attribute (msg, "PropertyName", name, NULL, NULL);
+ e_soap_message_add_attribute (msg, "PropertyType", prop_type, NULL, NULL);
+ e_soap_message_end_element (msg); /* ExtendedFieldURI */
+}
+
+void
+e_ews_message_write_extended_distinguished_name (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ const gchar *prop_type)
+{
+ e_soap_message_start_element (msg, "ExtendedFieldURI", NULL, NULL);
+ e_soap_message_add_attribute (msg, "DistinguishedPropertySetId", set_id, NULL, NULL);
+ e_soap_message_add_attribute (msg, "PropertyName", name, NULL, NULL);
+ e_soap_message_add_attribute (msg, "PropertyType", prop_type, NULL, NULL);
+ e_soap_message_end_element (msg); /* ExtendedFieldURI */
+}
diff --git a/src/server/e-ews-message.h b/src/server/e-ews-message.h
index 43bbbde..2c5e0c4 100644
--- a/src/server/e-ews-message.h
+++ b/src/server/e-ews-message.h
@@ -92,6 +92,17 @@ void e_ews_message_write_extended_distinguished_tag
guint32 prop_id,
const gchar *prop_type);
+void e_ews_message_write_extended_name
+ (ESoapMessage *msg,
+ const gchar *name,
+ const gchar *prop_type);
+
+void e_ews_message_write_extended_distinguished_name
+ (ESoapMessage *msg,
+ const gchar *set_id,
+ const gchar *name,
+ const gchar *prop_type);
+
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]