[evolution-ews] Create added attachments when a calendar item is modified



commit a888c418bc9e9c1c31b4a61fc12287b9054b2616
Author: Or Goshen <orx goshen intel com>
Date:   Mon Jun 20 18:17:33 2011 +0300

    Create added attachments when a calendar item is modified

 src/calendar/e-cal-backend-ews.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index b862fe7..eb52843 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -1320,6 +1320,7 @@ ews_cal_modify_object_cb (GObject *object, GAsyncResult *res, gpointer user_data
 	icalproperty *icalprop;
 	icalcomponent *icalcomp;
 	ECalComponentId *id;
+	GSList *original_attachments = NULL, *modified_attachments = NULL, *added_attachments, *removed_attachments;
 
 	if (!e_ews_connection_update_items_finish (cnc, res, &ids, &error)) {
 		/* The calendar UI doesn't *display* errors unless they have
@@ -1328,6 +1329,9 @@ ews_cal_modify_object_cb (GObject *object, GAsyncResult *res, gpointer user_data
 		return;
 	}
 
+	g_object_ref (modify_data->comp);
+	g_object_ref (modify_data->oldcomp);
+
 	e_cal_backend_store_freeze_changes(priv->store);
 
 	item_id = e_ews_item_get_id((EEwsItem *)ids->data);
@@ -1368,6 +1372,34 @@ ews_cal_modify_object_cb (GObject *object, GAsyncResult *res, gpointer user_data
 
 	e_cal_backend_store_thaw_changes (priv->store);
 
+	/* Attachments */
+	e_cal_component_get_attachment_list (modify_data->oldcomp, &original_attachments);
+	e_cal_component_get_attachment_list (modify_data->comp, &modified_attachments);
+
+	ewscal_get_attach_differences (original_attachments, modified_attachments, &removed_attachments, &added_attachments);
+	g_slist_free (original_attachments);
+	g_slist_free (modified_attachments);
+
+	if (added_attachments) {
+		EwsCreateAttachmentsData *attach_data = g_new0(EwsCreateAttachmentsData, 1);
+
+		attach_data->cbews = g_object_ref (modify_data->cbews);
+		attach_data->comp = g_object_ref (modify_data->comp);
+
+		e_ews_connection_create_attachments_start (cnc, EWS_PRIORITY_MEDIUM,
+							   item_id, added_attachments,
+							   ews_create_attachments_cb, NULL, attach_data);
+
+		g_slist_free (added_attachments);
+	}
+	if (removed_attachments) {
+		/* TODO: Implement removing attachments */
+		g_slist_free (removed_attachments);
+	}
+
+	g_object_unref (modify_data->comp);
+	g_object_unref (modify_data->oldcomp);
+
 	icalproperty_free (icalprop);
 	e_cal_component_free_id (id);
 	g_free(comp_str);



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