[evolution-ews] Start using calendar_item_accept_id when we do not have AssociatedCalendarItemId



commit b44c0955c84f089fcf5d4d7b87a3bd486386ef86
Author: Pavel Ocheretny <pocheretny src gnome org>
Date:   Sun Jun 26 18:42:31 2011 +0300

    Start using calendar_item_accept_id when we do not have AssociatedCalendarItemId

 src/calendar/e-cal-backend-ews.c |   32 +++++++++++++++++++++++++++++++-
 src/camel/camel-ews-folder.c     |   15 ++++++++++++---
 2 files changed, 43 insertions(+), 4 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 8e55176..8d3c019 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -592,6 +592,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)
@@ -1793,7 +1823,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);
+		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 dd5bcec..5d16b98 100644
--- a/src/camel/camel-ews-folder.c
+++ b/src/camel/camel-ews-folder.c
@@ -183,7 +183,7 @@ ews_get_calendar_mime_part (CamelMimePart* mimepart)
 }
 
 static gchar *
-ews_update_mgtrequest_mime_calendar_itemid (const gchar* mime_fname, const EwsId* item_id, GError **error)
+ews_update_mgtrequest_mime_calendar_itemid (const gchar* mime_fname, const EwsId* item_id, gboolean is_calendar_UID, GError **error)
 {
 	CamelMimeParser *mimeparser;
 	CamelMimeMessage *msg;
@@ -237,11 +237,18 @@ ews_update_mgtrequest_mime_calendar_itemid (const gchar* mime_fname, const EwsId
 		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);
-		icalcomponent_set_uid (icalcomp, (gchar *) item_id->id);
 		subcomp = icalcomponent_get_first_component (icalcomp, ICAL_VEVENT_COMPONENT);
 		icalprop = icalproperty_new_x (item_id->change_key);
 		icalproperty_set_x_name (icalprop, "X-EVOLUTION-CHANGEKEY");
 		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),
@@ -387,6 +394,7 @@ camel_ews_folder_get_message (CamelFolder *folder, const gchar *uid, gint pri, G
 		e_ews_item_get_item_type (items->data) == E_EWS_ITEM_TYPE_MEETING_RESPONSE) {
 		GSList *items_req = NULL;
 		const EwsId *calendar_item_accept_id;
+		gboolean is_calendar_UID = TRUE;
 
 		// Get AssociatedCalendarItemId with second get_items call
 		res = e_ews_connection_get_items (cnc, pri, ids, "IdOnly", "meeting:AssociatedCalendarItemId",
@@ -406,8 +414,9 @@ camel_ews_folder_get_message (CamelFolder *folder, const gchar *uid, gint pri, G
 		/*In case of non-exchange based meetings invites the calendar backend have to create the meeting*/
 		if (!calendar_item_accept_id) {
 			calendar_item_accept_id = e_ews_item_get_id (items->data);
+			is_calendar_UID = FALSE;
 		}
-		mime_fname_new = ews_update_mgtrequest_mime_calendar_itemid (mime_content, calendar_item_accept_id, error);
+		mime_fname_new = ews_update_mgtrequest_mime_calendar_itemid (mime_content, calendar_item_accept_id, is_calendar_UID, error);
 		if (mime_fname_new)
 			mime_content = (const gchar *) mime_fname_new;
 



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