[evolution-ews] Set server calendar UID for newly created meetings



commit fb3b6db1d43f66c1ac5e1cf827785be73591a2b3
Author: Pavel Ocheretny <pocheretny src gnome org>
Date:   Mon Aug 1 22:43:13 2011 +0300

    Set server calendar UID for newly created meetings

 src/calendar/e-cal-backend-ews.c |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 705f201..1d7e2b5 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -1319,12 +1319,14 @@ ews_create_object_cb(GObject *object, GAsyncResult *res, gpointer user_data)
 	ECalBackendEws *cbews = create_data->cbews;
 	ECalBackendEwsPrivate *priv = cbews->priv;
 	GError *error = NULL;
-	GSList *ids = NULL, *attachments = NULL, *i, *exceptions = NULL;
+	GSList *ids = NULL, *attachments = NULL, *i, *exceptions = NULL, *items_req = NULL, *items = NULL;
 	const gchar *comp_uid;
 	const EwsId *item_id;
 	icalproperty *icalprop;
 	icalcomponent *icalcomp;
 	guint n_attach;
+	gboolean result;
+	EEwsItem *item;
 
 	/* get a list of ids from server (single item) */
 	e_ews_connection_create_items_finish(cnc, res, &ids, &error);
@@ -1335,8 +1337,31 @@ ews_create_object_cb(GObject *object, GAsyncResult *res, gpointer user_data)
 		return;
 	}
 
-	item_id = e_ews_item_get_id((EEwsItem *)ids->data);
+	item = (EEwsItem *)ids->data;
+	item_id = e_ews_item_get_id (item);
+
+	items = g_slist_append (items, item_id->id);
 	g_slist_free (ids);
+	/* get calender uid from server*/
+	result = e_ews_connection_get_items (cnc, EWS_PRIORITY_MEDIUM,
+					  items,
+					  "IdOnly",
+					  "calendar:UID",
+					  FALSE, NULL,
+					  &items_req,
+					  NULL, NULL, NULL, &error);
+		if (!res && error != NULL) {
+			if (items_req)
+				g_slist_free (items_req);
+			e_data_cal_notify_object_created(create_data->cal, create_data->context, error, NULL, NULL);
+			return;
+		}
+
+	item = (EEwsItem *)items_req->data;
+	item_id = e_ews_item_get_id (item);
+
+	g_slist_free (items);
+	g_slist_free (items_req);
 
 	/* attachments */
 	n_attach = e_cal_component_get_num_attachments (create_data->comp);
@@ -1363,6 +1388,8 @@ ews_create_object_cb(GObject *object, GAsyncResult *res, gpointer user_data)
 
 	/* set a new ical property containing the change key we got from the exchange server for future use */
 
+	e_cal_component_set_uid (create_data->comp, e_ews_item_get_uid (item));
+
 	icalprop = icalproperty_new_x (item_id->id);
 	icalproperty_set_x_name (icalprop, "X-EVOLUTION-ITEMID");
 	icalcomp = e_cal_component_get_icalcomponent(create_data->comp);



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