[evolution-ews] Revert "Kill X-EVOLUTION-ACCEPT-ID field; we just use X-EVOLUTION-ITEM-ID"



commit 8297e8eb3de5272a92b8aa4d91ad6905d002be11
Author: David Woodhouse <David Woodhouse intel com>
Date:   Sun Jul 31 13:12:46 2011 +0100

    Revert "Kill X-EVOLUTION-ACCEPT-ID field; we just use X-EVOLUTION-ITEM-ID"
    
    This reverts commit e00cd8506d345b3590be823a2eb0ba5da98eb0c9.
    
    The comments in the code are wrong; it's not actually storing the
    AssociatedCalendarItemId. It's storing the ID of the email bearing the
    invitation. I think. Someone will be along shortly to fix the comments
    to make it clear how this actually works...

 src/calendar/e-cal-backend-ews.c |   41 ++++++++++++++++++++++++++++---------
 src/camel/camel-ews-folder.c     |   14 ++++++++----
 2 files changed, 40 insertions(+), 15 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 4e39858..aa3b231 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -595,6 +595,36 @@ ews_cal_component_get_item_id (ECalComponent *comp, gchar **itemid, gchar **chan
 		*changekey = ck;
 }
 
+/* changekey can be NULL if you don't want it. itemid cannot. */
+static void
+ews_cal_component_get_calendar_item_accept_id (ECalComponent *comp, gchar **itemid, gchar **changekey)
+{
+	icalproperty *prop;
+	const gchar *id = NULL;
+	*itemid = NULL;
+
+	prop = icalcomponent_get_first_property (e_cal_component_get_icalcomponent (comp),
+		ICAL_X_PROPERTY);
+	while (prop) {
+		const gchar *x_name, *x_val;
+
+		x_name = icalproperty_get_x_name (prop);
+		x_val = icalproperty_get_x (prop);
+		if (!g_ascii_strcasecmp (x_name, "X-EVOLUTION-CHANGEKEY")) {
+			*changekey = g_strdup (x_val);
+		} else if (!g_ascii_strcasecmp (x_name, "X-EVOLUTION-ACCEPT-ID")) {
+			*itemid = g_strdup (x_val);
+		}
+
+		prop = icalcomponent_get_next_property (e_cal_component_get_icalcomponent (comp),
+			ICAL_X_PROPERTY);
+	}
+	if (!*itemid){
+		e_cal_component_get_uid(comp, &id);
+		*itemid = g_strdup (id);
+	}
+}
+
 
 static void
 add_comps_to_item_id_hash (ECalBackendEws *cbews)
@@ -2122,16 +2152,7 @@ e_cal_backend_ews_receive_objects (ECalBackend *backend, EDataCal *cal, EServerM
 
 		/*getting a data for meeting request response*/
 		response_type = e_ews_get_current_user_meeting_reponse (e_cal_component_get_icalcomponent (comp), priv->user_email);
-		ews_cal_component_get_item_id (comp, &item_id, &change_key);
-		if (!item_id) {
-			/* FIXME: How does Exchange even cope with this case? Don't we have to
-			   do something completely different if there's no AssociatedCalendarItemId
-			   in the email we received? Or if we received the email through a route
-			   other than an Exchange mailbox? */
-			const gchar *id;
-			e_cal_component_get_uid (comp, &id);
-			item_id = g_strdup (id);
-		}
+		ews_cal_component_get_calendar_item_accept_id (comp, &item_id, &change_key);
 
 		switch (method) {
 			case ICAL_METHOD_REQUEST:
diff --git a/src/camel/camel-ews-folder.c b/src/camel/camel-ews-folder.c
index 3b0a9fc..a169f3c 100644
--- a/src/camel/camel-ews-folder.c
+++ b/src/camel/camel-ews-folder.c
@@ -233,7 +233,7 @@ ews_update_mgtrequest_mime_calendar_itemid (const gchar* mime_fname, const EwsId
 			g_object_unref (tmpstream);
 			goto exit_msg;
 		}
-		/* Add details of AssociatedCalendarItemId */
+		/* Replace original random UID with AssociatedCalendarItemId (ItemId) */
 		ba = camel_stream_mem_get_byte_array (CAMEL_STREAM_MEM (tmpstream));
 		g_byte_array_append (ba, (guint8 *) "\0", 1);
 		icalcomp = icalparser_parse_string ((gchar *) ba->data);
@@ -241,10 +241,14 @@ ews_update_mgtrequest_mime_calendar_itemid (const gchar* mime_fname, const EwsId
 		icalprop = icalproperty_new_x (item_id->change_key);
 		icalproperty_set_x_name (icalprop, "X-EVOLUTION-CHANGEKEY");
 		icalcomponent_add_property (subcomp, icalprop);
-		icalprop = icalproperty_new_x (item_id->id);
-		icalproperty_set_x_name (icalprop, "X-EVOLUTION-ITEMID");
-		icalcomponent_add_property (subcomp, icalprop);
-
+		if (is_calendar_UID){
+			icalcomponent_set_uid (icalcomp, (gchar *) item_id->id);
+		}
+		else {
+			icalprop = icalproperty_new_x (item_id->id);
+			icalproperty_set_x_name (icalprop, "X-EVOLUTION-ACCEPT-ID");
+			icalcomponent_add_property (subcomp, icalprop);
+		}
 		calstring_new = icalcomponent_as_ical_string_r (icalcomp);
 		camel_mime_part_set_content (mimepart,
 					     (const gchar*) calstring_new, strlen (calstring_new),



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