[evolution-ews] Make the DeleteItem API more user friendly



commit 53ef21eaef09bb552ee38b3d57571b126a4b46df
Author: Or Goshen <orx goshen intel com>
Date:   Thu May 26 11:28:51 2011 +0300

    Make the DeleteItem API more user friendly

 src/calendar/e-cal-backend-ews.c |    2 +-
 src/camel/camel-ews-folder.c     |    6 ++--
 src/server/e-ews-connection.c    |   59 ++++++++++++++++++++++++++++++++------
 src/server/e-ews-connection.h    |   42 ++++++++++++++++++--------
 4 files changed, 83 insertions(+), 26 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index c4dd89f..9400762 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -905,7 +905,7 @@ e_cal_backend_ews_remove_object (ECalBackend *backend, EDataCal *cal, EServerMet
 	remove_data->ids = g_slist_append (NULL, (gpointer)itemid);
 
 	e_ews_connection_delete_items_start (priv->cnc, EWS_PRIORITY_MEDIUM, remove_data->ids,
-					     "HardDelete", "SendToNone", NULL,
+					     EWS_HARD_DELETE, EWS_SEND_TO_NONE, FALSE,
 					     ews_cal_remove_object_cb, NULL,
 					     remove_data);
 	return;
diff --git a/src/camel/camel-ews-folder.c b/src/camel/camel-ews-folder.c
index 81efd5d..0c73837 100644
--- a/src/camel/camel-ews-folder.c
+++ b/src/camel/camel-ews-folder.c
@@ -1141,13 +1141,13 @@ ews_delete_messages (CamelFolder *folder, GSList *deleted_items, gboolean expung
 
 	if (deleted_items) {
 		GError *rerror = NULL;
-		const gchar *delete_type;
+		EwsDeleteType delete_type;
 
-		delete_type = expunge ? "HardDelete" : "MoveToDeletedItems";
+		delete_type = expunge ? EWS_HARD_DELETE : EWS_MOVE_TO_DELETED_ITEMS;
 
 		camel_service_lock (CAMEL_SERVICE (ews_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 		status = e_ews_connection_delete_items (cnc, EWS_PRIORITY_MEDIUM, deleted_items, delete_type,
-							"SendToNone", NULL, cancellable, &rerror);
+							EWS_SEND_TO_NONE, FALSE, cancellable, &rerror);
 		camel_service_unlock (CAMEL_SERVICE (ews_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 		if (status) {
diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index b60e98e..441ee3e 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -1608,13 +1608,53 @@ e_ews_connection_get_items	(EEwsConnection *cnc,
 	return result;
 }
 
+static const char *
+ews_delete_type_to_str (EwsDeleteType delete_type)
+{
+	switch (delete_type) {
+		case EWS_HARD_DELETE:
+			return "HardDelete";
+		case EWS_SOFT_DELETE:
+			return "SoftDelete";
+		case EWS_MOVE_TO_DELETED_ITEMS:
+			return "MoveToDeletedItems";
+	}
+	return NULL;
+}
+
+static const char *
+ews_send_cancels_to_str (EwsSendMeetingCancellationsType send_cancels)
+{
+	switch (send_cancels) {
+		case EWS_SEND_TO_NONE:
+			return "SendToNone";
+		case EWS_SEND_ONLY_TO_ALL:
+			return "SendOnlyToAll";
+		case EWS_SEND_TO_ALL_AND_SAVE_COPY:
+			return "SendToAllAndSaveCopy";
+	}
+	return NULL;
+}
+
+static const char *
+ews_affected_tasks_to_str (EwsAffectedTaskOccurrencesType affected_tasks)
+{
+	switch (affected_tasks) {
+		case EWS_ALL_OCCURRENCES:
+			return "AllOccurrences";
+		case EWS_SPECIFIED_OCCURRENCE_ONLY:
+			return "SpecifiedOccurrenceOnly";
+	}
+	return NULL;
+}
+
 void
 e_ews_connection_delete_items_start	(EEwsConnection *cnc,
 					 gint pri,
 					 GSList *ids,
-					 const gchar *delete_type,
-					 const gchar *send_cancels,
-					 const gchar *affected_tasks,
+					 EwsDeleteType delete_type,
+					 EwsSendMeetingCancellationsType send_cancels,
+					 EwsAffectedTaskOccurrencesType affected_tasks,
 					 GAsyncReadyCallback cb,
 					 GCancellable *cancellable,
 					 gpointer user_data)
@@ -1625,14 +1665,15 @@ e_ews_connection_delete_items_start	(EEwsConnection *cnc,
 	GSList *l;
 
 	msg = e_ews_message_new_with_header (cnc->priv->uri, "DeleteItem",
-					     "DeleteType", delete_type, EWS_EXCHANGE_2007);
+					     "DeleteType", ews_delete_type_to_str (delete_type), EWS_EXCHANGE_2007);
 
 	if (send_cancels)
 		e_soap_message_add_attribute (msg, "SendMeetingCancellations",
-					      send_cancels, NULL, NULL);
+					      ews_send_cancels_to_str (send_cancels), NULL, NULL);
+
 	if (affected_tasks)
 		e_soap_message_add_attribute (msg, "AffectedTaskOccurrences",
-					      affected_tasks, NULL, NULL);
+					      ews_affected_tasks_to_str (affected_tasks), NULL, NULL);
 
 	e_soap_message_start_element (msg, "ItemIds", "messages", NULL);
 
@@ -1680,9 +1721,9 @@ gboolean
 e_ews_connection_delete_items	(EEwsConnection *cnc,
 				 gint pri,
 				 GSList *ids,
-				 const gchar *delete_type,
-				 const gchar *send_cancels,
-				 const gchar *affected_tasks,
+				 EwsDeleteType delete_type,
+				 EwsSendMeetingCancellationsType send_cancels,
+				 EwsAffectedTaskOccurrencesType affected_tasks,
 				 GCancellable *cancellable,
 				 GError **error)
 {
diff --git a/src/server/e-ews-connection.h b/src/server/e-ews-connection.h
index e8764a6..fa005f7 100644
--- a/src/server/e-ews-connection.h
+++ b/src/server/e-ews-connection.h
@@ -71,6 +71,23 @@ typedef enum {
 
 } EwsContactsSearchScope;
 
+typedef enum {
+	EWS_HARD_DELETE = 1,
+	EWS_SOFT_DELETE,
+	EWS_MOVE_TO_DELETED_ITEMS
+} EwsDeleteType;
+
+typedef enum {
+	EWS_SEND_TO_NONE = 1,
+	EWS_SEND_ONLY_TO_ALL,
+	EWS_SEND_TO_ALL_AND_SAVE_COPY
+} EwsSendMeetingCancellationsType;
+
+typedef enum {
+	EWS_ALL_OCCURRENCES = 1,
+	EWS_SPECIFIED_OCCURRENCE_ONLY
+} EwsAffectedTaskOccurrencesType;
+
 GType		e_ews_connection_get_type	(void);
 EEwsConnection *e_ews_connection_new		(const gchar *uri,
 						 const gchar *username,
@@ -164,16 +181,15 @@ gboolean	e_ews_connection_get_items	(EEwsConnection *cnc,
 						 GCancellable *cancellable,
 						 GError **error);
 /* Delete folder items */
-void		e_ews_connection_delete_items_start
-						(EEwsConnection *cnc,
-						 gint pri,
-						 GSList *ids,
-						 const gchar *delete_type,
-						 const gchar *send_cancels,
-						 const gchar *affected_tasks,
-						 GAsyncReadyCallback cb,
-						 GCancellable *cancellable,
-						 gpointer user_data);
+void		e_ews_connection_delete_items_start	(EEwsConnection *cnc,
+					 gint pri,
+					 GSList *ids,
+					 EwsDeleteType delete_type,
+					 EwsSendMeetingCancellationsType send_cancels,
+					 EwsAffectedTaskOccurrencesType affected_tasks,
+					 GAsyncReadyCallback cb,
+					 GCancellable *cancellable,
+					 gpointer user_data);
 
 gboolean	e_ews_connection_delete_items_finish
 						(EEwsConnection *cnc,
@@ -183,9 +199,9 @@ gboolean	e_ews_connection_delete_items_finish
 gboolean	e_ews_connection_delete_items	(EEwsConnection *cnc,
 						 gint pri,
 						 GSList *ids,
-						 const gchar *delete_type,
-						 const gchar *send_cancels,
-						 const gchar *affected_tasks,
+						 EwsDeleteType delete_type,
+						 EwsSendMeetingCancellationsType send_cancels,
+						 EwsAffectedTaskOccurrencesType affected_tasks,
 						 GCancellable *cancellable,
 						 GError **error);
 



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