Blame SOURCES/evolution-3.8.5-copy-move-recurrences.patch

c72ca9
Backport of upstream commits:
c72ca9
c72ca9
commit 37768f933d00b64bfc5f902ccc2ecc85fee2b918
c72ca9
Adding new strings to copy/move event/task/memo and handle possible errors on those operations
c72ca9
   
c72ca9
commit 96c6e7bc26132d31c87e05a6ef702b008a47ac85
c72ca9
Add EShellView to E{Calendar,MemoList,TaskList}Selector
c72ca9
  
c72ca9
commit ed2bc85f4fe13a67aec032c8dddef0614df6419f
c72ca9
Bug #657808 - Copy/move of a single instance should grab whole serie
c72ca9
c72ca9
diff -up evolution-3.8.5/calendar/calendar.error.xml.copy-move-recurrences evolution-3.8.5/calendar/calendar.error.xml
c72ca9
--- evolution-3.8.5/calendar/calendar.error.xml.copy-move-recurrences	2013-07-18 14:10:38.000000000 +0200
c72ca9
+++ evolution-3.8.5/calendar/calendar.error.xml	2013-11-04 22:11:17.120317884 +0100
c72ca9
@@ -307,4 +307,16 @@
c72ca9
     <secondary>{0}</secondary>
c72ca9
   </error>
c72ca9
 
c72ca9
+  <error id="failed-copy-event" type="error" default="GTK_RESPONSE_YES">
c72ca9
+    
c72ca9
+    <_primary>Failed to copy an event into the calendar '{0}'</_primary>
c72ca9
+    <secondary>{1}</secondary>
c72ca9
+  </error>
c72ca9
+
c72ca9
+  <error id="failed-move-event" type="error" default="GTK_RESPONSE_YES">
c72ca9
+    
c72ca9
+    <_primary>Failed to move an event into the calendar '{0}'</_primary>
c72ca9
+    <secondary>{1}</secondary>
c72ca9
+  </error>
c72ca9
+
c72ca9
 </error-list>
c72ca9
diff -up evolution-3.8.5/calendar/gui/comp-util.c.copy-move-recurrences evolution-3.8.5/calendar/gui/comp-util.c
c72ca9
--- evolution-3.8.5/calendar/gui/comp-util.c.copy-move-recurrences	2013-07-23 14:52:29.000000000 +0200
c72ca9
+++ evolution-3.8.5/calendar/gui/comp-util.c	2013-11-04 22:11:17.120317884 +0100
c72ca9
@@ -813,3 +813,366 @@ icalcomp_suggest_filename (icalcomponent
c72ca9
 
c72ca9
 	return g_strconcat (summary, ".ics", NULL);
c72ca9
 }
c72ca9
+
c72ca9
+typedef struct _AsyncContext {
c72ca9
+	ECalClient *src_client;
c72ca9
+	icalcomponent *icalcomp_clone;
c72ca9
+	gboolean do_copy;
c72ca9
+} AsyncContext;
c72ca9
+
c72ca9
+struct ForeachTzidData
c72ca9
+{
c72ca9
+	ECalClient *source_client;
c72ca9
+	ECalClient *destination_client;
c72ca9
+	GCancellable *cancellable;
c72ca9
+	GError **error;
c72ca9
+	gboolean success;
c72ca9
+};
c72ca9
+
c72ca9
+static void
c72ca9
+async_context_free (AsyncContext *async_context)
c72ca9
+{
c72ca9
+	if (async_context->src_client)
c72ca9
+		g_object_unref (async_context->src_client);
c72ca9
+
c72ca9
+	if (async_context->icalcomp_clone)
c72ca9
+		icalcomponent_free (async_context->icalcomp_clone);
c72ca9
+
c72ca9
+	g_slice_free (AsyncContext, async_context);
c72ca9
+}
c72ca9
+
c72ca9
+static void
c72ca9
+add_timezone_to_cal_cb (icalparameter *param,
c72ca9
+			gpointer data)
c72ca9
+{
c72ca9
+	struct ForeachTzidData *ftd = data;
c72ca9
+	icaltimezone *tz = NULL;
c72ca9
+	const gchar *tzid;
c72ca9
+
c72ca9
+	g_return_if_fail (ftd != NULL);
c72ca9
+	g_return_if_fail (ftd->source_client != NULL);
c72ca9
+	g_return_if_fail (ftd->destination_client != NULL);
c72ca9
+
c72ca9
+	if (!ftd->success)
c72ca9
+		return;
c72ca9
+
c72ca9
+	if (ftd->cancellable && g_cancellable_is_cancelled (ftd->cancellable)) {
c72ca9
+		ftd->success = FALSE;
c72ca9
+		return;
c72ca9
+	}
c72ca9
+
c72ca9
+	tzid = icalparameter_get_tzid (param);
c72ca9
+	if (!tzid || !*tzid)
c72ca9
+		return;
c72ca9
+
c72ca9
+	if (e_cal_client_get_timezone_sync (ftd->source_client, tzid, &tz, ftd->cancellable, NULL) && tz)
c72ca9
+		ftd->success = e_cal_client_add_timezone_sync (
c72ca9
+				ftd->destination_client, tz, ftd->cancellable, ftd->error);
c72ca9
+}
c72ca9
+
c72ca9
+/* Helper for cal_comp_transfer_item_to() */
c72ca9
+static void
c72ca9
+cal_comp_transfer_item_to_thread (GSimpleAsyncResult *simple,
c72ca9
+				  GObject *source_object,
c72ca9
+				  GCancellable *cancellable)
c72ca9
+{
c72ca9
+	AsyncContext *async_context;
c72ca9
+	GError *local_error = NULL;
c72ca9
+
c72ca9
+	async_context = g_simple_async_result_get_op_res_gpointer (simple);
c72ca9
+
c72ca9
+	cal_comp_transfer_item_to_sync (
c72ca9
+		async_context->src_client,
c72ca9
+		E_CAL_CLIENT (source_object),
c72ca9
+		async_context->icalcomp_clone,
c72ca9
+		async_context->do_copy,
c72ca9
+		cancellable, &local_error);
c72ca9
+
c72ca9
+	if (local_error != NULL)
c72ca9
+		g_simple_async_result_take_error (simple, local_error);
c72ca9
+}
c72ca9
+
c72ca9
+void
c72ca9
+cal_comp_transfer_item_to (ECalClient *src_client,
c72ca9
+			   ECalClient *dest_client,
c72ca9
+			   icalcomponent *icalcomp_vcal,
c72ca9
+			   gboolean do_copy,
c72ca9
+			   GCancellable *cancellable,
c72ca9
+			   GAsyncReadyCallback callback,
c72ca9
+			   gpointer user_data)
c72ca9
+{
c72ca9
+	GSimpleAsyncResult *simple;
c72ca9
+	AsyncContext *async_context;
c72ca9
+
c72ca9
+	g_return_val_if_fail (E_IS_CAL_CLIENT (src_client), FALSE);
c72ca9
+	g_return_val_if_fail (E_IS_CAL_CLIENT (dest_client), FALSE);
c72ca9
+	g_return_val_if_fail (icalcomp_vcal != NULL, FALSE);
c72ca9
+
c72ca9
+	async_context = g_slice_new0 (AsyncContext);
c72ca9
+	async_context->src_client = g_object_ref (src_client);
c72ca9
+	async_context->icalcomp_clone = icalcomponent_new_clone (icalcomp_vcal);
c72ca9
+	async_context->do_copy = do_copy;
c72ca9
+
c72ca9
+	simple = g_simple_async_result_new (
c72ca9
+		G_OBJECT (dest_client), callback, user_data,
c72ca9
+		cal_comp_transfer_item_to);
c72ca9
+
c72ca9
+	g_simple_async_result_set_check_cancellable (simple, cancellable);
c72ca9
+
c72ca9
+	g_simple_async_result_set_op_res_gpointer (
c72ca9
+		simple, async_context, (GDestroyNotify) async_context_free);
c72ca9
+
c72ca9
+	g_simple_async_result_run_in_thread (
c72ca9
+		simple, cal_comp_transfer_item_to_thread,
c72ca9
+		G_PRIORITY_DEFAULT, cancellable);
c72ca9
+
c72ca9
+	g_object_unref (simple);
c72ca9
+}
c72ca9
+
c72ca9
+gboolean
c72ca9
+cal_comp_transfer_item_to_finish (ECalClient *client,
c72ca9
+				  GAsyncResult *result,
c72ca9
+				  GError **error)
c72ca9
+{
c72ca9
+	GSimpleAsyncResult *simple;
c72ca9
+
c72ca9
+	g_return_val_if_fail (
c72ca9
+		g_simple_async_result_is_valid (result, G_OBJECT (client), cal_comp_transfer_item_to),
c72ca9
+		FALSE);
c72ca9
+
c72ca9
+	simple = G_SIMPLE_ASYNC_RESULT (result);
c72ca9
+
c72ca9
+	if (g_simple_async_result_propagate_error (simple, error))
c72ca9
+		return FALSE;
c72ca9
+
c72ca9
+	return TRUE;
c72ca9
+}
c72ca9
+
c72ca9
+gboolean
c72ca9
+cal_comp_transfer_item_to_sync (ECalClient *src_client,
c72ca9
+				ECalClient *dest_client,
c72ca9
+				icalcomponent *icalcomp_vcal,
c72ca9
+				gboolean do_copy,
c72ca9
+				GCancellable *cancellable,
c72ca9
+				GError **error)
c72ca9
+{
c72ca9
+	icalcomponent *icalcomp;
c72ca9
+	icalcomponent *icalcomp_event, *subcomp;
c72ca9
+	icalcomponent_kind icalcomp_kind;
c72ca9
+	const gchar *uid;
c72ca9
+	gchar *new_uid = NULL;
c72ca9
+	struct ForeachTzidData ftd;
c72ca9
+	ECalClientSourceType source_type;
c72ca9
+	GHashTable *processed_uids;
c72ca9
+	gboolean success = FALSE;
c72ca9
+
c72ca9
+	g_return_val_if_fail (E_IS_CAL_CLIENT (src_client), FALSE);
c72ca9
+	g_return_val_if_fail (E_IS_CAL_CLIENT (dest_client), FALSE);
c72ca9
+	g_return_val_if_fail (icalcomp_vcal != NULL, FALSE);
c72ca9
+
c72ca9
+	icalcomp_event = icalcomponent_get_inner (icalcomp_vcal);
c72ca9
+	g_return_val_if_fail (icalcomp_event != NULL, FALSE);
c72ca9
+
c72ca9
+	source_type = e_cal_client_get_source_type (src_client);
c72ca9
+	switch (source_type) {
c72ca9
+		case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
c72ca9
+			icalcomp_kind = ICAL_VEVENT_COMPONENT;
c72ca9
+			break;
c72ca9
+		case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
c72ca9
+			icalcomp_kind = ICAL_VTODO_COMPONENT;
c72ca9
+			break;
c72ca9
+		case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
c72ca9
+			icalcomp_kind = ICAL_VJOURNAL_COMPONENT;
c72ca9
+			break;
c72ca9
+		default:
c72ca9
+			g_return_val_if_reached (FALSE);
c72ca9
+	}
c72ca9
+
c72ca9
+	processed_uids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
c72ca9
+
c72ca9
+	icalcomp_event = icalcomponent_get_first_component (icalcomp_vcal, icalcomp_kind);
c72ca9
+	/*
c72ca9
+	 * This check should be removed in the near future.
c72ca9
+	 * We should be able to work properly with multiselection, which means that we always
c72ca9
+	 * will receive a component with subcomponents.
c72ca9
+	 */
c72ca9
+	if (icalcomp_event == NULL)
c72ca9
+		icalcomp_event = icalcomp_vcal;
c72ca9
+	for (;
c72ca9
+	     icalcomp_event;
c72ca9
+	     icalcomp_event = icalcomponent_get_next_component (icalcomp_vcal, icalcomp_kind)) {
c72ca9
+		GError *local_error = NULL;
c72ca9
+
c72ca9
+		uid = icalcomponent_get_uid (icalcomp_event);
c72ca9
+
c72ca9
+		if (g_hash_table_lookup (processed_uids, uid))
c72ca9
+			continue;
c72ca9
+
c72ca9
+		success = e_cal_client_get_object_sync (dest_client, uid, NULL, &icalcomp, cancellable, &local_error);
c72ca9
+		if (success) {
c72ca9
+			success = e_cal_client_modify_object_sync (
c72ca9
+				dest_client, icalcomp_event, CALOBJ_MOD_ALL, cancellable, error);
c72ca9
+
c72ca9
+			icalcomponent_free (icalcomp);
c72ca9
+			if (!success)
c72ca9
+				goto exit;
c72ca9
+
c72ca9
+			if (!do_copy) {
c72ca9
+				ECalObjModType mod_type = CALOBJ_MOD_THIS;
c72ca9
+
c72ca9
+				/* Remove the item from the source calendar. */
c72ca9
+				if (e_cal_util_component_is_instance (icalcomp_event) ||
c72ca9
+				    e_cal_util_component_has_recurrences (icalcomp_event))
c72ca9
+					mod_type = CALOBJ_MOD_ALL;
c72ca9
+
c72ca9
+				success = e_cal_client_remove_object_sync (
c72ca9
+						src_client, uid, NULL, mod_type, cancellable, error);
c72ca9
+				if (!success)
c72ca9
+					goto exit;
c72ca9
+			}
c72ca9
+
c72ca9
+			continue;
c72ca9
+		} else if (local_error != NULL && !g_error_matches (
c72ca9
+					local_error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) {
c72ca9
+			g_propagate_error (error, local_error);
c72ca9
+			goto exit;
c72ca9
+		} else {
c72ca9
+			g_clear_error (&local_error);
c72ca9
+		}
c72ca9
+
c72ca9
+		if (e_cal_util_component_is_instance (icalcomp_event)) {
c72ca9
+			GSList *ecalcomps = NULL, *eiter;
c72ca9
+			ECalComponent *comp ;
c72ca9
+
c72ca9
+			success = e_cal_client_get_objects_for_uid_sync (src_client, uid, &ecalcomps, cancellable, error);
c72ca9
+			if (!success)
c72ca9
+				goto exit;
c72ca9
+
c72ca9
+			if (ecalcomps && !ecalcomps->next) {
c72ca9
+				/* only one component, no need for a vCalendar list */
c72ca9
+				comp = ecalcomps->data;
c72ca9
+				icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp));
c72ca9
+			} else {
c72ca9
+				icalcomp = icalcomponent_new (ICAL_VCALENDAR_COMPONENT);
c72ca9
+				for (eiter = ecalcomps; eiter; eiter = g_slist_next (eiter)) {
c72ca9
+					comp = eiter->data;
c72ca9
+
c72ca9
+					icalcomponent_add_component (icalcomp,
c72ca9
+						icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp)));
c72ca9
+				}
c72ca9
+			}
c72ca9
+
c72ca9
+			e_cal_client_free_ecalcomp_slist (ecalcomps);
c72ca9
+		} else {
c72ca9
+			icalcomp = icalcomponent_new_clone (icalcomp_event);
c72ca9
+		}
c72ca9
+
c72ca9
+		if (do_copy) {
c72ca9
+			/* Change the UID to avoid problems with duplicated UID */
c72ca9
+			new_uid = e_cal_component_gen_uid ();
c72ca9
+			if (icalcomponent_isa (icalcomp) == ICAL_VCALENDAR_COMPONENT) {
c72ca9
+				/* in case of a vCalendar, the component might have detached instances,
c72ca9
+				   thus change the UID on all of the subcomponents of it */
c72ca9
+				for (subcomp = icalcomponent_get_first_component (icalcomp, icalcomp_kind);
c72ca9
+				     subcomp;
c72ca9
+				     subcomp = icalcomponent_get_next_component (icalcomp, icalcomp_kind)) {
c72ca9
+					icalcomponent_set_uid (subcomp, new_uid);
c72ca9
+				}
c72ca9
+			} else {
c72ca9
+				icalcomponent_set_uid (icalcomp, new_uid);
c72ca9
+			}
c72ca9
+			g_free (new_uid);
c72ca9
+			new_uid = NULL;
c72ca9
+		}
c72ca9
+
c72ca9
+		ftd.source_client = src_client;
c72ca9
+		ftd.destination_client = dest_client;
c72ca9
+		ftd.cancellable = cancellable;
c72ca9
+		ftd.error = error;
c72ca9
+		ftd.success = TRUE;
c72ca9
+
c72ca9
+		if (icalcomponent_isa (icalcomp) == ICAL_VCALENDAR_COMPONENT) {
c72ca9
+			/* in case of a vCalendar, the component might have detached instances,
c72ca9
+			   thus check timezones on all of the subcomponents of it */
c72ca9
+			for (subcomp = icalcomponent_get_first_component (icalcomp, icalcomp_kind);
c72ca9
+			     subcomp && ftd.success;
c72ca9
+			     subcomp = icalcomponent_get_next_component (icalcomp, icalcomp_kind)) {
c72ca9
+				icalcomponent_foreach_tzid (subcomp, add_timezone_to_cal_cb, &ftd);
c72ca9
+			}
c72ca9
+		} else {
c72ca9
+			icalcomponent_foreach_tzid (icalcomp, add_timezone_to_cal_cb, &ftd);
c72ca9
+		}
c72ca9
+
c72ca9
+		if (!ftd.success) {
c72ca9
+			success = FALSE;
c72ca9
+			goto exit;
c72ca9
+		}
c72ca9
+
c72ca9
+		if (icalcomponent_isa (icalcomp) == ICAL_VCALENDAR_COMPONENT) {
c72ca9
+			gboolean did_add = FALSE;
c72ca9
+
c72ca9
+			/* in case of a vCalendar, the component might have detached instances,
c72ca9
+			   thus add the master object first, and then all of the subcomponents of it */
c72ca9
+			for (subcomp = icalcomponent_get_first_component (icalcomp, icalcomp_kind);
c72ca9
+			     subcomp && !did_add;
c72ca9
+			     subcomp = icalcomponent_get_next_component (icalcomp, icalcomp_kind)) {
c72ca9
+				if (icaltime_is_null_time (icalcomponent_get_recurrenceid (subcomp))) {
c72ca9
+					did_add = TRUE;
c72ca9
+					success = e_cal_client_create_object_sync (dest_client, subcomp,
c72ca9
+						&new_uid, cancellable, error);
c72ca9
+					g_free (new_uid);
c72ca9
+				}
c72ca9
+			}
c72ca9
+
c72ca9
+			if (!success) {
c72ca9
+				icalcomponent_free (icalcomp);
c72ca9
+				goto exit;
c72ca9
+			}
c72ca9
+
c72ca9
+			/* deal with detached instances */
c72ca9
+			for (subcomp = icalcomponent_get_first_component (icalcomp, icalcomp_kind);
c72ca9
+			     subcomp && success;
c72ca9
+			     subcomp = icalcomponent_get_next_component (icalcomp, icalcomp_kind)) {
c72ca9
+				if (!icaltime_is_null_time (icalcomponent_get_recurrenceid (subcomp))) {
c72ca9
+					if (did_add) {
c72ca9
+						success = e_cal_client_modify_object_sync (dest_client, subcomp,
c72ca9
+							CALOBJ_MOD_THIS, cancellable, error);
c72ca9
+					} else {
c72ca9
+						/* just in case there are only detached instances and no master object */
c72ca9
+						did_add = TRUE;
c72ca9
+						success = e_cal_client_create_object_sync (dest_client, subcomp,
c72ca9
+							&new_uid, cancellable, error);
c72ca9
+						g_free (new_uid);
c72ca9
+					}
c72ca9
+				}
c72ca9
+			}
c72ca9
+		} else {
c72ca9
+			success = e_cal_client_create_object_sync (dest_client, icalcomp, &new_uid, cancellable, error);
c72ca9
+			g_free (new_uid);
c72ca9
+		}
c72ca9
+
c72ca9
+		icalcomponent_free (icalcomp);
c72ca9
+		if (!success)
c72ca9
+			goto exit;
c72ca9
+
c72ca9
+		if (!do_copy) {
c72ca9
+			ECalObjModType mod_type = CALOBJ_MOD_THIS;
c72ca9
+
c72ca9
+			/* Remove the item from the source calendar. */
c72ca9
+			if (e_cal_util_component_is_instance (icalcomp_event) ||
c72ca9
+			    e_cal_util_component_has_recurrences (icalcomp_event))
c72ca9
+				mod_type = CALOBJ_MOD_ALL;
c72ca9
+
c72ca9
+			success = e_cal_client_remove_object_sync (src_client, uid, NULL, mod_type, cancellable, error);
c72ca9
+			if (!success)
c72ca9
+				goto exit;
c72ca9
+		}
c72ca9
+
c72ca9
+		g_hash_table_insert (processed_uids, g_strdup (uid), GINT_TO_POINTER (1));
c72ca9
+	}
c72ca9
+
c72ca9
+ exit:
c72ca9
+	g_hash_table_destroy (processed_uids);
c72ca9
+
c72ca9
+	return success;
c72ca9
+}
c72ca9
diff -up evolution-3.8.5/calendar/gui/comp-util.h.copy-move-recurrences evolution-3.8.5/calendar/gui/comp-util.h
c72ca9
--- evolution-3.8.5/calendar/gui/comp-util.h.copy-move-recurrences	2013-07-23 14:52:35.000000000 +0200
c72ca9
+++ evolution-3.8.5/calendar/gui/comp-util.h	2013-11-04 22:11:17.121317884 +0100
c72ca9
@@ -75,4 +75,21 @@ void comp_util_sanitize_recurrence_maste
c72ca9
 
c72ca9
 gchar *icalcomp_suggest_filename (icalcomponent *icalcomp, const gchar *default_name);
c72ca9
 
c72ca9
+void cal_comp_transfer_item_to			(ECalClient *src_client,
c72ca9
+						 ECalClient *dest_client,
c72ca9
+						 icalcomponent *icalcomp_vcal,
c72ca9
+						 gboolean do_copy,
c72ca9
+						 GCancellable *cancellable,
c72ca9
+						 GAsyncReadyCallback callback,
c72ca9
+						 gpointer user_data);
c72ca9
+gboolean cal_comp_transfer_item_to_finish	(ECalClient *client,
c72ca9
+						 GAsyncResult *result,
c72ca9
+						 GError **error);
c72ca9
+gboolean cal_comp_transfer_item_to_sync		(ECalClient *src_client,
c72ca9
+						 ECalClient *dest_client,
c72ca9
+						 icalcomponent *icalcomp_event,
c72ca9
+						 gboolean do_copy,
c72ca9
+						 GCancellable *cancellable,
c72ca9
+						 GError **error);
c72ca9
+
c72ca9
 #endif
c72ca9
diff -up evolution-3.8.5/calendar/gui/e-calendar-selector.c.copy-move-recurrences evolution-3.8.5/calendar/gui/e-calendar-selector.c
c72ca9
--- evolution-3.8.5/calendar/gui/e-calendar-selector.c.copy-move-recurrences	2013-07-23 14:52:35.000000000 +0200
c72ca9
+++ evolution-3.8.5/calendar/gui/e-calendar-selector.c	2013-11-04 22:11:17.122317884 +0100
c72ca9
@@ -20,7 +20,10 @@
c72ca9
 
c72ca9
 #include <config.h>
c72ca9
 
c72ca9
+#include <glib/gi18n.h>
c72ca9
+
c72ca9
 #include "e-calendar-selector.h"
c72ca9
+#include "comp-util.h"
c72ca9
 
c72ca9
 #include <libecal/libecal.h>
c72ca9
 
c72ca9
@@ -29,7 +32,9 @@
c72ca9
 	((obj), E_TYPE_CALENDAR_SELECTOR, ECalendarSelectorPrivate))
c72ca9
 
c72ca9
 struct _ECalendarSelectorPrivate {
c72ca9
-	gint dummy_value;
c72ca9
+	EShellView *shell_view;
c72ca9
+
c72ca9
+	gpointer transfer_alert; /* weak pointer to EAlert */
c72ca9
 };
c72ca9
 
c72ca9
 G_DEFINE_TYPE (
c72ca9
@@ -37,113 +42,193 @@ G_DEFINE_TYPE (
c72ca9
 	e_calendar_selector,
c72ca9
 	E_TYPE_CLIENT_SELECTOR)
c72ca9
 
c72ca9
-static gboolean
c72ca9
-calendar_selector_update_single_object (ECalClient *client,
c72ca9
-                                        icalcomponent *icalcomp)
c72ca9
+enum {
c72ca9
+	PROP_0,
c72ca9
+	PROP_SHELL_VIEW,
c72ca9
+};
c72ca9
+
c72ca9
+static void
c72ca9
+cal_transferring_update_alert (ECalendarSelector *calendar_selector,
c72ca9
+			       EShellView *shell_view,
c72ca9
+			       const gchar *domain,
c72ca9
+			       const gchar *calendar,
c72ca9
+			       const gchar *message)
c72ca9
 {
c72ca9
-	gchar *uid;
c72ca9
-	icalcomponent *tmp_icalcomp;
c72ca9
+	ECalendarSelectorPrivate *priv;
c72ca9
+	EShellContent *shell_content;
c72ca9
+	EAlert *alert;
c72ca9
+
c72ca9
+	g_return_if_fail (calendar_selector != NULL);
c72ca9
+	g_return_if_fail (calendar_selector->priv != NULL);
c72ca9
+
c72ca9
+	priv = calendar_selector->priv;
c72ca9
+
c72ca9
+	if (priv->transfer_alert) {
c72ca9
+		e_alert_response (
c72ca9
+			priv->transfer_alert,
c72ca9
+			e_alert_get_default_response (priv->transfer_alert));
c72ca9
+		priv->transfer_alert = NULL;
c72ca9
+	}
c72ca9
 
c72ca9
-	uid = (gchar *) icalcomponent_get_uid (icalcomp);
c72ca9
+	if (!message)
c72ca9
+		return;
c72ca9
 
c72ca9
-	if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) {
c72ca9
-		icalcomponent_free (tmp_icalcomp);
c72ca9
+	alert = e_alert_new (domain, calendar, message, NULL);
c72ca9
+	g_return_if_fail (alert != NULL);
c72ca9
 
c72ca9
-		return e_cal_client_modify_object_sync (
c72ca9
-			client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL);
c72ca9
-	}
c72ca9
+	priv->transfer_alert = alert;
c72ca9
+	g_object_add_weak_pointer (G_OBJECT (alert), &priv->transfer_alert);
c72ca9
+	e_alert_start_timer (priv->transfer_alert, 300);
c72ca9
+
c72ca9
+	shell_content = e_shell_view_get_shell_content (shell_view);
c72ca9
+	e_alert_sink_submit_alert (E_ALERT_SINK (shell_content), priv->transfer_alert);
c72ca9
+	g_object_unref (priv->transfer_alert);
c72ca9
+}
c72ca9
 
c72ca9
-	uid = NULL;
c72ca9
-	if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL))
c72ca9
-		return FALSE;
c72ca9
+typedef struct _TransferItemToData {
c72ca9
+	ESource *destination;
c72ca9
+	ESourceSelector *selector;
c72ca9
+	EClient *src_client;
c72ca9
+	EShellView *shell_view;
c72ca9
+	EActivity *activity;
c72ca9
+	icalcomponent *icalcomp;
c72ca9
+	const gchar *display_name;
c72ca9
+	gboolean do_copy;
c72ca9
+} TransferItemToData;
c72ca9
 
c72ca9
-	if (uid)
c72ca9
-		icalcomponent_set_uid (icalcomp, uid);
c72ca9
-	g_free (uid);
c72ca9
+static void
c72ca9
+transfer_item_to_cb (GObject *source_object,
c72ca9
+		     GAsyncResult *result,
c72ca9
+		     gpointer user_data)
c72ca9
+{
c72ca9
+	TransferItemToData *titd = user_data;
c72ca9
+	GError *error = NULL;
c72ca9
+	GCancellable *cancellable;
c72ca9
+	gboolean success;
c72ca9
 
c72ca9
-	return TRUE;
c72ca9
+	success = cal_comp_transfer_item_to_finish (E_CAL_CLIENT (source_object), result, &error);
c72ca9
+
c72ca9
+	if (!success) {
c72ca9
+		cal_transferring_update_alert (
c72ca9
+			E_CALENDAR_SELECTOR (titd->selector),
c72ca9
+			titd->shell_view,
c72ca9
+			titd->do_copy ? "calendar:failed-copy-event" : "calendar:failed-move-event",
c72ca9
+			titd->display_name,
c72ca9
+			error->message);
c72ca9
+		g_clear_error (&error);
c72ca9
+	}
c72ca9
+
c72ca9
+	cancellable = e_activity_get_cancellable (titd->activity);
c72ca9
+	e_activity_set_state (
c72ca9
+		titd->activity,
c72ca9
+		g_cancellable_is_cancelled (cancellable) ? E_ACTIVITY_CANCELLED : E_ACTIVITY_COMPLETED);
c72ca9
+
c72ca9
+	g_object_unref (titd->activity);
c72ca9
+	icalcomponent_free (titd->icalcomp);
c72ca9
+	g_free (titd);
c72ca9
 }
c72ca9
 
c72ca9
-static gboolean
c72ca9
-calendar_selector_update_objects (ECalClient *client,
c72ca9
-                                  icalcomponent *icalcomp)
c72ca9
+static void
c72ca9
+destination_client_connect_cb (GObject *source_object,
c72ca9
+			       GAsyncResult *result,
c72ca9
+			       gpointer user_data)
c72ca9
 {
c72ca9
-	icalcomponent *subcomp;
c72ca9
-	icalcomponent_kind kind;
c72ca9
+	EClient *client;
c72ca9
+	TransferItemToData *titd = user_data;
c72ca9
+	GCancellable *cancellable;
c72ca9
+	GError *error = NULL;
c72ca9
 
c72ca9
-	kind = icalcomponent_isa (icalcomp);
c72ca9
-	if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT)
c72ca9
-		return calendar_selector_update_single_object (
c72ca9
-			client, icalcomp);
c72ca9
-	else if (kind != ICAL_VCALENDAR_COMPONENT)
c72ca9
-		return FALSE;
c72ca9
-
c72ca9
-	subcomp = icalcomponent_get_first_component (
c72ca9
-		icalcomp, ICAL_ANY_COMPONENT);
c72ca9
-	while (subcomp != NULL) {
c72ca9
-		gboolean success;
c72ca9
-
c72ca9
-		kind = icalcomponent_isa (subcomp);
c72ca9
-		if (kind == ICAL_VTIMEZONE_COMPONENT) {
c72ca9
-			icaltimezone *zone;
c72ca9
-			GError *error = NULL;
c72ca9
-
c72ca9
-			zone = icaltimezone_new ();
c72ca9
-			icaltimezone_set_component (zone, subcomp);
c72ca9
-
c72ca9
-			e_cal_client_add_timezone_sync (client, zone, NULL, &error);
c72ca9
-			icaltimezone_free (zone, 1);
c72ca9
-
c72ca9
-			if (error != NULL) {
c72ca9
-				g_warning (
c72ca9
-					"%s: Failed to add timezone: %s",
c72ca9
-					G_STRFUNC, error->message);
c72ca9
-				g_error_free (error);
c72ca9
-				return FALSE;
c72ca9
-			}
c72ca9
-		} else if (kind == ICAL_VTODO_COMPONENT ||
c72ca9
-			kind == ICAL_VEVENT_COMPONENT) {
c72ca9
-			success = calendar_selector_update_single_object (
c72ca9
-				client, subcomp);
c72ca9
-			if (!success)
c72ca9
-				return FALSE;
c72ca9
-		}
c72ca9
+	client = e_client_selector_get_client_finish (E_CLIENT_SELECTOR (source_object), result, &error);
c72ca9
 
c72ca9
-		subcomp = icalcomponent_get_next_component (
c72ca9
-			icalcomp, ICAL_ANY_COMPONENT);
c72ca9
+	/* Sanity check. */
c72ca9
+	g_return_if_fail (
c72ca9
+		((client != NULL) && (error == NULL)) ||
c72ca9
+		((client == NULL) && (error != NULL)));
c72ca9
+
c72ca9
+	cancellable = e_activity_get_cancellable (titd->activity);
c72ca9
+
c72ca9
+	if (error != NULL) {
c72ca9
+		cal_transferring_update_alert (
c72ca9
+			E_CALENDAR_SELECTOR (titd->selector),
c72ca9
+			titd->shell_view,
c72ca9
+			titd->do_copy ? "calendar:failed-copy-event" : "calendar:failed-move-event",
c72ca9
+			titd->display_name,
c72ca9
+			error->message);
c72ca9
+		g_clear_error (&error);
c72ca9
+
c72ca9
+		goto exit;
c72ca9
 	}
c72ca9
 
c72ca9
-	return TRUE;
c72ca9
+	if (g_cancellable_is_cancelled (cancellable))
c72ca9
+		goto exit;
c72ca9
+
c72ca9
+	cal_comp_transfer_item_to (
c72ca9
+		E_CAL_CLIENT (titd->src_client), E_CAL_CLIENT (client),
c72ca9
+		titd->icalcomp, titd->do_copy, cancellable, transfer_item_to_cb, titd);
c72ca9
+
c72ca9
+	return;
c72ca9
+
c72ca9
+exit:
c72ca9
+	e_activity_set_state (
c72ca9
+		titd->activity,
c72ca9
+		g_cancellable_is_cancelled (cancellable) ? E_ACTIVITY_CANCELLED : E_ACTIVITY_COMPLETED);
c72ca9
+
c72ca9
+	g_object_unref (titd->activity);
c72ca9
+	icalcomponent_free (titd->icalcomp);
c72ca9
+	g_free (titd);
c72ca9
+
c72ca9
 }
c72ca9
 
c72ca9
 static void
c72ca9
-client_connect_cb (GObject *source_object,
c72ca9
-                   GAsyncResult *result,
c72ca9
-                   gpointer user_data)
c72ca9
+source_client_connect_cb (GObject *source_object,
c72ca9
+			  GAsyncResult *result,
c72ca9
+			  gpointer user_data)
c72ca9
 {
c72ca9
 	EClient *client;
c72ca9
-	icalcomponent *icalcomp = user_data;
c72ca9
+	TransferItemToData *titd = user_data;
c72ca9
+	GCancellable *cancellable;
c72ca9
 	GError *error = NULL;
c72ca9
 
c72ca9
-	g_return_if_fail (icalcomp != NULL);
c72ca9
-
c72ca9
-	client = e_client_selector_get_client_finish (
c72ca9
-		E_CLIENT_SELECTOR (source_object), result, &error);
c72ca9
+	client = e_client_selector_get_client_finish (E_CLIENT_SELECTOR (source_object), result, &error);
c72ca9
 
c72ca9
 	/* Sanity check. */
c72ca9
 	g_return_if_fail (
c72ca9
 		((client != NULL) && (error == NULL)) ||
c72ca9
 		((client == NULL) && (error != NULL)));
c72ca9
 
c72ca9
+	cancellable = e_activity_get_cancellable (titd->activity);
c72ca9
+
c72ca9
 	if (error != NULL) {
c72ca9
-		g_warning ("%s: %s", G_STRFUNC, error->message);
c72ca9
-		g_error_free (error);
c72ca9
+		cal_transferring_update_alert (
c72ca9
+			E_CALENDAR_SELECTOR (titd->selector),
c72ca9
+			titd->shell_view,
c72ca9
+			titd->do_copy ? "calendar:failed-copy-event" : "calendar:failed-move-event",
c72ca9
+			titd->display_name,
c72ca9
+			error->message);
c72ca9
+		g_clear_error (&error);
c72ca9
+
c72ca9
+		goto exit;
c72ca9
 	}
c72ca9
 
c72ca9
-	calendar_selector_update_objects (E_CAL_CLIENT (client), icalcomp);
c72ca9
-	g_object_unref (client);
c72ca9
+	if (g_cancellable_is_cancelled (cancellable))
c72ca9
+		goto exit;
c72ca9
+
c72ca9
+	titd->src_client = client;
c72ca9
+
c72ca9
+	e_client_selector_get_client (
c72ca9
+		E_CLIENT_SELECTOR (titd->selector), titd->destination, cancellable,
c72ca9
+		destination_client_connect_cb, titd);
c72ca9
+
c72ca9
+	return;
c72ca9
 
c72ca9
-	icalcomponent_free (icalcomp);
c72ca9
+exit:
c72ca9
+	e_activity_set_state (
c72ca9
+		titd->activity,
c72ca9
+		g_cancellable_is_cancelled (cancellable) ? E_ACTIVITY_CANCELLED : E_ACTIVITY_COMPLETED);
c72ca9
+
c72ca9
+	g_object_unref (titd->activity);
c72ca9
+	icalcomponent_free (titd->icalcomp);
c72ca9
+	g_free (titd);
c72ca9
 }
c72ca9
 
c72ca9
 static void
c72ca9
@@ -171,40 +256,148 @@ calendar_selector_data_dropped (ESourceS
c72ca9
                                 GdkDragAction action,
c72ca9
                                 guint info)
c72ca9
 {
c72ca9
-	GtkTreePath *path = NULL;
c72ca9
-	icalcomponent *icalcomp;
c72ca9
+	icalcomponent *icalcomp = NULL;
c72ca9
+	EActivity *activity;
c72ca9
+	EShellBackend *shell_backend;
c72ca9
+	EShellView *shell_view;
c72ca9
+	ESource *source = NULL;
c72ca9
+	ESourceRegistry *registry;
c72ca9
+	GCancellable *cancellable;
c72ca9
+	gchar **segments;
c72ca9
+	gchar *source_uid = NULL;
c72ca9
+	gchar *message;
c72ca9
+	const gchar *display_name;
c72ca9
 	const guchar *data;
c72ca9
-	gboolean success = FALSE;
c72ca9
-	gpointer object = NULL;
c72ca9
+	gboolean do_copy;
c72ca9
+	TransferItemToData *titd;
c72ca9
 
c72ca9
 	data = gtk_selection_data_get_data (selection_data);
c72ca9
-	icalcomp = icalparser_parse_string ((const gchar *) data);
c72ca9
+	g_return_val_if_fail (data != NULL, FALSE);
c72ca9
 
c72ca9
-	if (icalcomp == NULL)
c72ca9
+	segments = g_strsplit ((const gchar *) data, "\n", 2);
c72ca9
+	if (g_strv_length (segments) != 2)
c72ca9
 		goto exit;
c72ca9
 
c72ca9
-	/* FIXME Deal with GDK_ACTION_ASK. */
c72ca9
-	if (action == GDK_ACTION_COPY) {
c72ca9
-		gchar *uid;
c72ca9
+	source_uid = g_strdup (segments[0]);
c72ca9
+	icalcomp = icalparser_parse_string (segments[1]);
c72ca9
 
c72ca9
-		uid = e_cal_component_gen_uid ();
c72ca9
-		icalcomponent_set_uid (icalcomp, uid);
c72ca9
-	}
c72ca9
+	if (!icalcomp)
c72ca9
+		goto exit;
c72ca9
 
c72ca9
-	e_client_selector_get_client (
c72ca9
-		E_CLIENT_SELECTOR (selector), destination, NULL,
c72ca9
-		client_connect_cb, icalcomp);
c72ca9
+	registry = e_source_selector_get_registry (selector);
c72ca9
+	source = e_source_registry_ref_source (registry, source_uid);
c72ca9
+	if (!source)
c72ca9
+		goto exit;
c72ca9
+
c72ca9
+	shell_view = e_calendar_selector_get_shell_view (E_CALENDAR_SELECTOR (selector));
c72ca9
+	shell_backend = e_shell_view_get_shell_backend (shell_view);
c72ca9
+
c72ca9
+	display_name = e_source_get_display_name (destination);
c72ca9
 
c72ca9
-	success = TRUE;
c72ca9
+	do_copy = action == GDK_ACTION_COPY ? TRUE : FALSE;
c72ca9
+
c72ca9
+	message = do_copy ?
c72ca9
+		g_strdup_printf (_("Copying an event into the calendar %s"), display_name) :
c72ca9
+		g_strdup_printf (_("Moving an event into the calendar %s"), display_name);
c72ca9
+
c72ca9
+	cancellable = g_cancellable_new ();
c72ca9
+	activity = e_activity_new ();
c72ca9
+	e_activity_set_cancellable (activity, cancellable);
c72ca9
+	e_activity_set_state (activity, E_ACTIVITY_RUNNING);
c72ca9
+	e_activity_set_text (activity, message);
c72ca9
+	g_free (message);
c72ca9
+
c72ca9
+	e_shell_backend_add_activity (shell_backend, activity);
c72ca9
+
c72ca9
+	titd = g_new0 (TransferItemToData, 1);
c72ca9
+
c72ca9
+	titd->destination = destination;
c72ca9
+	titd->icalcomp = icalcomponent_new_clone (icalcomp);
c72ca9
+	titd->selector = selector;
c72ca9
+	titd->shell_view = shell_view;
c72ca9
+	titd->activity = activity;
c72ca9
+	titd->display_name = display_name;
c72ca9
+	titd->do_copy = do_copy;
c72ca9
+
c72ca9
+	e_client_selector_get_client (
c72ca9
+		E_CLIENT_SELECTOR (selector), source, cancellable,
c72ca9
+		source_client_connect_cb, titd);
c72ca9
 
c72ca9
 exit:
c72ca9
-	if (path != NULL)
c72ca9
-		gtk_tree_path_free (path);
c72ca9
+	if (source)
c72ca9
+		g_object_unref (source);
c72ca9
 
c72ca9
-	if (object != NULL)
c72ca9
-		g_object_unref (object);
c72ca9
+	if (icalcomp)
c72ca9
+		icalcomponent_free (icalcomp);
c72ca9
 
c72ca9
-	return success;
c72ca9
+	g_free (source_uid);
c72ca9
+	g_strfreev (segments);
c72ca9
+	return TRUE;
c72ca9
+}
c72ca9
+
c72ca9
+EShellView *
c72ca9
+e_calendar_selector_get_shell_view (ECalendarSelector *calendar_selector)
c72ca9
+{
c72ca9
+	g_return_val_if_fail (E_IS_CALENDAR_SELECTOR (calendar_selector), NULL);
c72ca9
+
c72ca9
+	return calendar_selector->priv->shell_view;
c72ca9
+}
c72ca9
+
c72ca9
+static void
c72ca9
+e_calendar_selector_set_shell_view (ECalendarSelector *calendar_selector,
c72ca9
+				    EShellView *shell_view)
c72ca9
+{
c72ca9
+	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
c72ca9
+	g_return_if_fail (calendar_selector->priv->shell_view == NULL);
c72ca9
+
c72ca9
+	calendar_selector->priv->shell_view = g_object_ref (shell_view);
c72ca9
+}
c72ca9
+
c72ca9
+static void
c72ca9
+calendar_selector_set_property (GObject *object,
c72ca9
+				guint property_id,
c72ca9
+				const GValue *value,
c72ca9
+				GParamSpec *pspec)
c72ca9
+{
c72ca9
+	switch (property_id) {
c72ca9
+		case PROP_SHELL_VIEW:
c72ca9
+			e_calendar_selector_set_shell_view (
c72ca9
+				E_CALENDAR_SELECTOR (object),
c72ca9
+				g_value_get_object (value));
c72ca9
+			return;
c72ca9
+	}
c72ca9
+
c72ca9
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
c72ca9
+}
c72ca9
+
c72ca9
+static void
c72ca9
+calendar_selector_get_property (GObject *object,
c72ca9
+				guint property_id,
c72ca9
+				GValue *value,
c72ca9
+				GParamSpec *pspec)
c72ca9
+{
c72ca9
+	switch (property_id) {
c72ca9
+		case PROP_SHELL_VIEW:
c72ca9
+			g_value_set_object (
c72ca9
+				value,
c72ca9
+				e_calendar_selector_get_shell_view (E_CALENDAR_SELECTOR (object)));
c72ca9
+			return;
c72ca9
+	}
c72ca9
+
c72ca9
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
c72ca9
+}
c72ca9
+
c72ca9
+static void
c72ca9
+calendar_selector_dispose (GObject *object)
c72ca9
+{
c72ca9
+	ECalendarSelectorPrivate *priv;
c72ca9
+
c72ca9
+	priv = E_CALENDAR_SELECTOR_GET_PRIVATE (object);
c72ca9
+
c72ca9
+	g_clear_object (&priv->shell_view);
c72ca9
+
c72ca9
+	/* Chain up to the parent' s dispose() method. */
c72ca9
+	G_OBJECT_CLASS (e_calendar_selector_parent_class)->dispose (object);
c72ca9
 }
c72ca9
 
c72ca9
 static void
c72ca9
@@ -217,9 +410,24 @@ e_calendar_selector_class_init (ECalenda
c72ca9
 
c72ca9
 	object_class = G_OBJECT_CLASS (class);
c72ca9
 	object_class->constructed = calendar_selector_constructed;
c72ca9
+	object_class->set_property = calendar_selector_set_property;
c72ca9
+	object_class->get_property = calendar_selector_get_property;
c72ca9
+	object_class->dispose = calendar_selector_dispose;
c72ca9
 
c72ca9
 	source_selector_class = E_SOURCE_SELECTOR_CLASS (class);
c72ca9
 	source_selector_class->data_dropped = calendar_selector_data_dropped;
c72ca9
+
c72ca9
+	g_object_class_install_property (
c72ca9
+		object_class,
c72ca9
+		PROP_SHELL_VIEW,
c72ca9
+		g_param_spec_object (
c72ca9
+			"shell-view",
c72ca9
+			NULL,
c72ca9
+			NULL,
c72ca9
+			E_TYPE_SHELL_VIEW,
c72ca9
+			G_PARAM_READWRITE |
c72ca9
+			G_PARAM_CONSTRUCT_ONLY |
c72ca9
+			G_PARAM_STATIC_STRINGS));
c72ca9
 }
c72ca9
 
c72ca9
 static void
c72ca9
@@ -235,12 +443,14 @@ e_calendar_selector_init (ECalendarSelec
c72ca9
 }
c72ca9
 
c72ca9
 GtkWidget *
c72ca9
-e_calendar_selector_new (EClientCache *client_cache)
c72ca9
+e_calendar_selector_new (EClientCache *client_cache,
c72ca9
+			 EShellView *shell_view)
c72ca9
 {
c72ca9
 	ESourceRegistry *registry;
c72ca9
 	GtkWidget *widget;
c72ca9
 
c72ca9
 	g_return_val_if_fail (E_IS_CLIENT_CACHE (client_cache), NULL);
c72ca9
+	g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
c72ca9
 
c72ca9
 	registry = e_client_cache_ref_registry (client_cache);
c72ca9
 
c72ca9
@@ -248,7 +458,9 @@ e_calendar_selector_new (EClientCache *c
c72ca9
 		E_TYPE_CALENDAR_SELECTOR,
c72ca9
 		"client-cache", client_cache,
c72ca9
 		"extension-name", E_SOURCE_EXTENSION_CALENDAR,
c72ca9
-		"registry", registry, NULL);
c72ca9
+		"registry", registry,
c72ca9
+		"shell-view", shell_view,
c72ca9
+		NULL);
c72ca9
 
c72ca9
 	g_object_unref (registry);
c72ca9
 
c72ca9
diff -up evolution-3.8.5/calendar/gui/e-calendar-selector.h.copy-move-recurrences evolution-3.8.5/calendar/gui/e-calendar-selector.h
c72ca9
--- evolution-3.8.5/calendar/gui/e-calendar-selector.h.copy-move-recurrences	2013-07-23 14:52:29.000000000 +0200
c72ca9
+++ evolution-3.8.5/calendar/gui/e-calendar-selector.h	2013-11-04 22:11:17.122317884 +0100
c72ca9
@@ -22,6 +22,7 @@
c72ca9
 #define E_CALENDAR_SELECTOR_H
c72ca9
 
c72ca9
 #include <e-util/e-util.h>
c72ca9
+#include <shell/e-shell-view.h>
c72ca9
 
c72ca9
 /* Standard GObject macros */
c72ca9
 #define E_TYPE_CALENDAR_SELECTOR \
c72ca9
@@ -58,7 +59,10 @@ struct _ECalendarSelectorClass {
c72ca9
 };
c72ca9
 
c72ca9
 GType		e_calendar_selector_get_type	(void);
c72ca9
-GtkWidget *	e_calendar_selector_new		(EClientCache *client_cache);
c72ca9
+GtkWidget *	e_calendar_selector_new		(EClientCache *client_cache,
c72ca9
+						 EShellView *shell_backend);
c72ca9
+EShellView *	e_calendar_selector_get_shell_view
c72ca9
+						(ECalendarSelector *calendar_selector);
c72ca9
 
c72ca9
 G_END_DECLS
c72ca9
 
c72ca9
diff -up evolution-3.8.5/calendar/gui/e-memo-list-selector.c.copy-move-recurrences evolution-3.8.5/calendar/gui/e-memo-list-selector.c
c72ca9
--- evolution-3.8.5/calendar/gui/e-memo-list-selector.c.copy-move-recurrences	2013-07-23 14:52:30.000000000 +0200
c72ca9
+++ evolution-3.8.5/calendar/gui/e-memo-list-selector.c	2013-11-04 22:11:17.122317884 +0100
c72ca9
@@ -32,7 +32,7 @@
c72ca9
 	((obj), E_TYPE_MEMO_LIST_SELECTOR, EMemoListSelectorPrivate))
c72ca9
 
c72ca9
 struct _EMemoListSelectorPrivate {
c72ca9
-	gint dummy_value;
c72ca9
+	EShellView *shell_view;
c72ca9
 };
c72ca9
 
c72ca9
 G_DEFINE_TYPE (
c72ca9
@@ -40,6 +40,11 @@ G_DEFINE_TYPE (
c72ca9
 	e_memo_list_selector,
c72ca9
 	E_TYPE_CLIENT_SELECTOR)
c72ca9
 
c72ca9
+enum {
c72ca9
+	PROP_0,
c72ca9
+	PROP_SHELL_VIEW
c72ca9
+};
c72ca9
+
c72ca9
 static gboolean
c72ca9
 memo_list_selector_update_single_object (ECalClient *client,
c72ca9
                                          icalcomponent *icalcomp)
c72ca9
@@ -323,6 +328,71 @@ memo_list_selector_data_dropped (ESource
c72ca9
 	return TRUE;
c72ca9
 }
c72ca9
 
c72ca9
+EShellView *
c72ca9
+e_memo_list_selector_get_shell_view (EMemoListSelector *memo_list_selector)
c72ca9
+{
c72ca9
+	g_return_val_if_fail (E_IS_MEMO_LIST_SELECTOR (memo_list_selector), NULL);
c72ca9
+
c72ca9
+	return memo_list_selector->priv->shell_view;
c72ca9
+}
c72ca9
+
c72ca9
+static void
c72ca9
+e_memo_list_selector_set_shell_view (EMemoListSelector *memo_list_selector,
c72ca9
+				     EShellView *shell_view)
c72ca9
+{
c72ca9
+	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
c72ca9
+	g_return_if_fail (memo_list_selector->priv->shell_view == NULL);
c72ca9
+
c72ca9
+	memo_list_selector->priv->shell_view = g_object_ref (shell_view);
c72ca9
+}
c72ca9
+
c72ca9
+static void
c72ca9
+memo_list_selector_set_property (GObject *object,
c72ca9
+				 guint property_id,
c72ca9
+				 const GValue *value,
c72ca9
+				 GParamSpec *pspec)
c72ca9
+{
c72ca9
+	switch (property_id) {
c72ca9
+		case PROP_SHELL_VIEW:
c72ca9
+			e_memo_list_selector_set_shell_view (
c72ca9
+				E_MEMO_LIST_SELECTOR (object),
c72ca9
+				g_value_get_object (value));
c72ca9
+			return;
c72ca9
+	}
c72ca9
+
c72ca9
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
c72ca9
+}
c72ca9
+
c72ca9
+static void
c72ca9
+memo_list_selector_get_property (GObject *object,
c72ca9
+				 guint property_id,
c72ca9
+				 GValue *value,
c72ca9
+				 GParamSpec *pspec)
c72ca9
+{
c72ca9
+	switch (property_id) {
c72ca9
+		case PROP_SHELL_VIEW:
c72ca9
+			g_value_set_object (
c72ca9
+				value,
c72ca9
+				e_memo_list_selector_get_shell_view (E_MEMO_LIST_SELECTOR (object)));
c72ca9
+			return;
c72ca9
+	}
c72ca9
+
c72ca9
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
c72ca9
+}
c72ca9
+
c72ca9
+static void
c72ca9
+memo_list_selector_dispose (GObject *object)
c72ca9
+{
c72ca9
+	EMemoListSelectorPrivate *priv;
c72ca9
+
c72ca9
+	priv = E_MEMO_LIST_SELECTOR_GET_PRIVATE (object);
c72ca9
+
c72ca9
+	g_clear_object (&priv->shell_view);
c72ca9
+
c72ca9
+	/* Chain up to the parent' s dispose() method. */
c72ca9
+	G_OBJECT_CLASS (e_memo_list_selector_parent_class)->dispose (object);
c72ca9
+}
c72ca9
+
c72ca9
 static void
c72ca9
 e_memo_list_selector_class_init (EMemoListSelectorClass *class)
c72ca9
 {
c72ca9
@@ -333,9 +403,24 @@ e_memo_list_selector_class_init (EMemoLi
c72ca9
 
c72ca9
 	object_class = G_OBJECT_CLASS (class);
c72ca9
 	object_class->constructed = memo_list_selector_constructed;
c72ca9
+	object_class->set_property = memo_list_selector_set_property;
c72ca9
+	object_class->get_property = memo_list_selector_get_property;
c72ca9
+	object_class->dispose = memo_list_selector_dispose;
c72ca9
 
c72ca9
 	source_selector_class = E_SOURCE_SELECTOR_CLASS (class);
c72ca9
 	source_selector_class->data_dropped = memo_list_selector_data_dropped;
c72ca9
+
c72ca9
+	g_object_class_install_property (
c72ca9
+		object_class,
c72ca9
+		PROP_SHELL_VIEW,
c72ca9
+		g_param_spec_object (
c72ca9
+			"shell-view",
c72ca9
+			NULL,
c72ca9
+			NULL,
c72ca9
+			E_TYPE_SHELL_VIEW,
c72ca9
+			G_PARAM_READWRITE |
c72ca9
+			G_PARAM_CONSTRUCT_ONLY |
c72ca9
+			G_PARAM_STATIC_STRINGS));
c72ca9
 }
c72ca9
 
c72ca9
 static void
c72ca9
@@ -351,12 +436,14 @@ e_memo_list_selector_init (EMemoListSele
c72ca9
 }
c72ca9
 
c72ca9
 GtkWidget *
c72ca9
-e_memo_list_selector_new (EClientCache *client_cache)
c72ca9
+e_memo_list_selector_new (EClientCache *client_cache,
c72ca9
+			  EShellView *shell_view)
c72ca9
 {
c72ca9
 	ESourceRegistry *registry;
c72ca9
 	GtkWidget *widget;
c72ca9
 
c72ca9
 	g_return_val_if_fail (E_IS_CLIENT_CACHE (client_cache), NULL);
c72ca9
+	g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
c72ca9
 
c72ca9
 	registry = e_client_cache_ref_registry (client_cache);
c72ca9
 
c72ca9
@@ -364,6 +451,7 @@ e_memo_list_selector_new (EClientCache *
c72ca9
 		E_TYPE_MEMO_LIST_SELECTOR,
c72ca9
 		"client-cache", client_cache,
c72ca9
 		"extension-name", E_SOURCE_EXTENSION_MEMO_LIST,
c72ca9
+		"shell-view", shell_view,
c72ca9
 		"registry", registry, NULL);
c72ca9
 
c72ca9
 	g_object_unref (registry);
c72ca9
diff -up evolution-3.8.5/calendar/gui/e-memo-list-selector.h.copy-move-recurrences evolution-3.8.5/calendar/gui/e-memo-list-selector.h
c72ca9
--- evolution-3.8.5/calendar/gui/e-memo-list-selector.h.copy-move-recurrences	2013-07-23 14:52:30.000000000 +0200
c72ca9
+++ evolution-3.8.5/calendar/gui/e-memo-list-selector.h	2013-11-04 22:11:17.123317884 +0100
c72ca9
@@ -27,6 +27,7 @@
c72ca9
 #define E_MEMO_LIST_SELECTOR_H
c72ca9
 
c72ca9
 #include <e-util/e-util.h>
c72ca9
+#include <shell/e-shell-view.h>
c72ca9
 
c72ca9
 /* Standard GObject macros */
c72ca9
 #define E_TYPE_MEMO_LIST_SELECTOR \
c72ca9
@@ -63,7 +64,10 @@ struct _EMemoListSelectorClass {
c72ca9
 };
c72ca9
 
c72ca9
 GType		e_memo_list_selector_get_type	(void);
c72ca9
-GtkWidget *	e_memo_list_selector_new	(EClientCache *client_cache);
c72ca9
+GtkWidget *	e_memo_list_selector_new	(EClientCache *client_cache,
c72ca9
+						 EShellView *shell_view);
c72ca9
+EShellView *	e_memo_list_selector_get_shell_view
c72ca9
+						(EMemoListSelector *memo_list_selector);
c72ca9
 
c72ca9
 G_END_DECLS
c72ca9
 
c72ca9
diff -up evolution-3.8.5/calendar/gui/e-task-list-selector.c.copy-move-recurrences evolution-3.8.5/calendar/gui/e-task-list-selector.c
c72ca9
--- evolution-3.8.5/calendar/gui/e-task-list-selector.c.copy-move-recurrences	2013-07-23 14:52:36.000000000 +0200
c72ca9
+++ evolution-3.8.5/calendar/gui/e-task-list-selector.c	2013-11-04 22:11:17.123317884 +0100
c72ca9
@@ -32,7 +32,7 @@
c72ca9
 	((obj), E_TYPE_TASK_LIST_SELECTOR, ETaskListSelectorPrivate))
c72ca9
 
c72ca9
 struct _ETaskListSelectorPrivate {
c72ca9
-	gint dummy_value;
c72ca9
+	EShellView *shell_view;
c72ca9
 };
c72ca9
 
c72ca9
 G_DEFINE_TYPE (
c72ca9
@@ -40,6 +40,11 @@ G_DEFINE_TYPE (
c72ca9
 	e_task_list_selector,
c72ca9
 	E_TYPE_CLIENT_SELECTOR)
c72ca9
 
c72ca9
+enum {
c72ca9
+	PROP_0,
c72ca9
+	PROP_SHELL_VIEW
c72ca9
+};
c72ca9
+
c72ca9
 static gboolean
c72ca9
 task_list_selector_update_single_object (ECalClient *client,
c72ca9
                                          icalcomponent *icalcomp)
c72ca9
@@ -325,6 +330,71 @@ task_list_selector_data_dropped (ESource
c72ca9
 	return TRUE;
c72ca9
 }
c72ca9
 
c72ca9
+EShellView *
c72ca9
+e_task_list_selector_get_shell_view (ETaskListSelector *task_list_selector)
c72ca9
+{
c72ca9
+	g_return_val_if_fail (E_IS_TASK_LIST_SELECTOR (task_list_selector), NULL);
c72ca9
+
c72ca9
+	return task_list_selector->priv->shell_view;
c72ca9
+}
c72ca9
+
c72ca9
+static void
c72ca9
+e_task_list_selector_set_shell_view (ETaskListSelector *task_list_selector,
c72ca9
+				     EShellView *shell_view)
c72ca9
+{
c72ca9
+	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
c72ca9
+	g_return_if_fail (task_list_selector->priv->shell_view == NULL);
c72ca9
+
c72ca9
+	task_list_selector->priv->shell_view = g_object_ref (shell_view);
c72ca9
+}
c72ca9
+
c72ca9
+static void
c72ca9
+task_list_selector_set_property (GObject *object,
c72ca9
+				 guint property_id,
c72ca9
+				 const GValue *value,
c72ca9
+				 GParamSpec *pspec)
c72ca9
+{
c72ca9
+	switch (property_id) {
c72ca9
+		case PROP_SHELL_VIEW:
c72ca9
+			e_task_list_selector_set_shell_view (
c72ca9
+				E_TASK_LIST_SELECTOR (object),
c72ca9
+				g_value_get_object (value));
c72ca9
+			return;
c72ca9
+	}
c72ca9
+
c72ca9
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
c72ca9
+}
c72ca9
+
c72ca9
+static void
c72ca9
+task_list_selector_get_property (GObject *object,
c72ca9
+				 guint property_id,
c72ca9
+				 GValue *value,
c72ca9
+				 GParamSpec *pspec)
c72ca9
+{
c72ca9
+	switch (property_id) {
c72ca9
+		case PROP_SHELL_VIEW:
c72ca9
+			g_value_set_object (
c72ca9
+				value,
c72ca9
+				e_task_list_selector_get_shell_view (E_TASK_LIST_SELECTOR (object)));
c72ca9
+			return;
c72ca9
+	}
c72ca9
+
c72ca9
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
c72ca9
+}
c72ca9
+
c72ca9
+static void
c72ca9
+task_list_selector_dispose (GObject *object)
c72ca9
+{
c72ca9
+	ETaskListSelectorPrivate *priv;
c72ca9
+
c72ca9
+	priv = E_TASK_LIST_SELECTOR_GET_PRIVATE (object);
c72ca9
+
c72ca9
+	g_clear_object (&priv->shell_view);
c72ca9
+
c72ca9
+	/* Chain up to the parent' s dispose() method. */
c72ca9
+	G_OBJECT_CLASS (e_task_list_selector_parent_class)->dispose (object);
c72ca9
+}
c72ca9
+
c72ca9
 static void
c72ca9
 e_task_list_selector_class_init (ETaskListSelectorClass *class)
c72ca9
 {
c72ca9
@@ -335,9 +405,24 @@ e_task_list_selector_class_init (ETaskLi
c72ca9
 
c72ca9
 	object_class = G_OBJECT_CLASS (class);
c72ca9
 	object_class->constructed = task_list_selector_constructed;
c72ca9
+	object_class->set_property = task_list_selector_set_property;
c72ca9
+	object_class->get_property = task_list_selector_get_property;
c72ca9
+	object_class->dispose = task_list_selector_dispose;
c72ca9
 
c72ca9
 	source_selector_class = E_SOURCE_SELECTOR_CLASS (class);
c72ca9
 	source_selector_class->data_dropped = task_list_selector_data_dropped;
c72ca9
+
c72ca9
+	g_object_class_install_property (
c72ca9
+		object_class,
c72ca9
+		PROP_SHELL_VIEW,
c72ca9
+		g_param_spec_object (
c72ca9
+			"shell-view",
c72ca9
+			NULL,
c72ca9
+			NULL,
c72ca9
+			E_TYPE_SHELL_VIEW,
c72ca9
+			G_PARAM_READWRITE |
c72ca9
+			G_PARAM_CONSTRUCT_ONLY |
c72ca9
+			G_PARAM_STATIC_STRINGS));
c72ca9
 }
c72ca9
 
c72ca9
 static void
c72ca9
@@ -353,12 +438,14 @@ e_task_list_selector_init (ETaskListSele
c72ca9
 }
c72ca9
 
c72ca9
 GtkWidget *
c72ca9
-e_task_list_selector_new (EClientCache *client_cache)
c72ca9
+e_task_list_selector_new (EClientCache *client_cache,
c72ca9
+			  EShellView *shell_view)
c72ca9
 {
c72ca9
 	ESourceRegistry *registry;
c72ca9
 	GtkWidget *widget;
c72ca9
 
c72ca9
 	g_return_val_if_fail (E_IS_CLIENT_CACHE (client_cache), NULL);
c72ca9
+	g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
c72ca9
 
c72ca9
 	registry = e_client_cache_ref_registry (client_cache);
c72ca9
 
c72ca9
@@ -366,6 +453,7 @@ e_task_list_selector_new (EClientCache *
c72ca9
 		E_TYPE_TASK_LIST_SELECTOR,
c72ca9
 		"client-cache", client_cache,
c72ca9
 		"extension-name", E_SOURCE_EXTENSION_TASK_LIST,
c72ca9
+		"shell-view", shell_view,
c72ca9
 		"registry", registry, NULL);
c72ca9
 
c72ca9
 	g_object_unref (registry);
c72ca9
diff -up evolution-3.8.5/calendar/gui/e-task-list-selector.h.copy-move-recurrences evolution-3.8.5/calendar/gui/e-task-list-selector.h
c72ca9
--- evolution-3.8.5/calendar/gui/e-task-list-selector.h.copy-move-recurrences	2013-07-23 14:52:30.000000000 +0200
c72ca9
+++ evolution-3.8.5/calendar/gui/e-task-list-selector.h	2013-11-04 22:11:17.123317884 +0100
c72ca9
@@ -27,6 +27,7 @@
c72ca9
 #define E_TASK_LIST_SELECTOR_H
c72ca9
 
c72ca9
 #include <e-util/e-util.h>
c72ca9
+#include <shell/e-shell-view.h>
c72ca9
 
c72ca9
 /* Standard GObject macros */
c72ca9
 #define E_TYPE_TASK_LIST_SELECTOR \
c72ca9
@@ -63,7 +64,10 @@ struct _ETaskListSelectorClass {
c72ca9
 };
c72ca9
 
c72ca9
 GType		e_task_list_selector_get_type	(void);
c72ca9
-GtkWidget *	e_task_list_selector_new	(EClientCache *client_cache);
c72ca9
+GtkWidget *	e_task_list_selector_new	(EClientCache *client_cache,
c72ca9
+						 EShellView *shell_view);
c72ca9
+EShellView *	e_task_list_selector_get_shell_view
c72ca9
+						(ETaskListSelector *task_list_selector);
c72ca9
 
c72ca9
 G_END_DECLS
c72ca9
 
c72ca9
diff -up evolution-3.8.5/modules/calendar/e-cal-shell-sidebar.c.copy-move-recurrences evolution-3.8.5/modules/calendar/e-cal-shell-sidebar.c
c72ca9
--- evolution-3.8.5/modules/calendar/e-cal-shell-sidebar.c.copy-move-recurrences	2013-07-23 14:51:47.000000000 +0200
c72ca9
+++ evolution-3.8.5/modules/calendar/e-cal-shell-sidebar.c	2013-11-04 22:11:17.124317884 +0100
c72ca9
@@ -576,7 +576,7 @@ cal_shell_sidebar_constructed (GObject *
c72ca9
 	container = widget;
c72ca9
 
c72ca9
 	client_cache = e_shell_get_client_cache (shell);
c72ca9
-	widget = e_calendar_selector_new (client_cache);
c72ca9
+	widget = e_calendar_selector_new (client_cache, shell_view);
c72ca9
 	e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE);
c72ca9
 	gtk_container_add (GTK_CONTAINER (container), widget);
c72ca9
 	a11y = gtk_widget_get_accessible (widget);
c72ca9
diff -up evolution-3.8.5/modules/calendar/e-cal-shell-view-private.c.copy-move-recurrences evolution-3.8.5/modules/calendar/e-cal-shell-view-private.c
c72ca9
--- evolution-3.8.5/modules/calendar/e-cal-shell-view-private.c.copy-move-recurrences	2013-07-23 14:51:48.000000000 +0200
c72ca9
+++ evolution-3.8.5/modules/calendar/e-cal-shell-view-private.c	2013-11-04 22:11:17.125317884 +0100
c72ca9
@@ -914,30 +914,78 @@ e_cal_shell_view_set_status_message (ECa
c72ca9
 	cal_shell_view->priv->calendar_activity = activity;
c72ca9
 }
c72ca9
 
c72ca9
-struct ForeachTzidData
c72ca9
+static void
c72ca9
+cal_transferring_update_alert (ECalShellView *cal_shell_view,
c72ca9
+			       const gchar *domain,
c72ca9
+			       const gchar *calendar,
c72ca9
+			       const gchar *message)
c72ca9
 {
c72ca9
-	ECalClient *source_client;
c72ca9
-	ECalClient *dest_client;
c72ca9
-};
c72ca9
+	ECalShellViewPrivate *priv;
c72ca9
+	EShellContent *shell_content;
c72ca9
+	EAlert *alert;
c72ca9
+
c72ca9
+	g_return_if_fail (cal_shell_view != NULL);
c72ca9
+	g_return_if_fail (cal_shell_view->priv != NULL);
c72ca9
+
c72ca9
+	priv = cal_shell_view->priv;
c72ca9
+
c72ca9
+	if (priv->transfer_alert) {
c72ca9
+		e_alert_response (
c72ca9
+			priv->transfer_alert,
c72ca9
+			e_alert_get_default_response (priv->transfer_alert));
c72ca9
+		priv->transfer_alert = NULL;
c72ca9
+	}
c72ca9
+
c72ca9
+	if (!message)
c72ca9
+		return;
c72ca9
+
c72ca9
+	alert = e_alert_new (domain, calendar, message, NULL);
c72ca9
+	g_return_if_fail (alert != NULL);
c72ca9
+
c72ca9
+	priv->transfer_alert = alert;
c72ca9
+	g_object_add_weak_pointer (G_OBJECT (alert), &priv->transfer_alert);
c72ca9
+	e_alert_start_timer (priv->transfer_alert, 300);
c72ca9
+
c72ca9
+	shell_content = e_shell_view_get_shell_content (E_SHELL_VIEW (cal_shell_view));
c72ca9
+	e_alert_sink_submit_alert (E_ALERT_SINK (shell_content), priv->transfer_alert);
c72ca9
+	g_object_unref (priv->transfer_alert);
c72ca9
+}
c72ca9
+
c72ca9
+typedef struct _TransferItemToData {
c72ca9
+	ECalShellView *cal_shell_view;
c72ca9
+	EActivity *activity;
c72ca9
+	const gchar *display_name;
c72ca9
+	gboolean remove;
c72ca9
+} TransferItemToData;
c72ca9
 
c72ca9
 static void
c72ca9
-add_timezone_to_cal_cb (icalparameter *param,
c72ca9
-                        gpointer data)
c72ca9
+transfer_item_to_cb (GObject *src_object,
c72ca9
+		     GAsyncResult *result,
c72ca9
+		     gpointer user_data)
c72ca9
 {
c72ca9
-	struct ForeachTzidData *ftd = data;
c72ca9
-	icaltimezone *tz = NULL;
c72ca9
-	const gchar *tzid;
c72ca9
-
c72ca9
-	g_return_if_fail (ftd != NULL);
c72ca9
-	g_return_if_fail (ftd->source_client != NULL);
c72ca9
-	g_return_if_fail (ftd->dest_client != NULL);
c72ca9
+	TransferItemToData *titd = user_data;
c72ca9
+	GError *error = NULL;
c72ca9
+	GCancellable *cancellable;
c72ca9
+	gboolean success;
c72ca9
 
c72ca9
-	tzid = icalparameter_get_tzid (param);
c72ca9
-	if (!tzid || !*tzid)
c72ca9
-		return;
c72ca9
+	success = cal_comp_transfer_item_to_finish (E_CAL_CLIENT (src_object), result, &error);
c72ca9
+
c72ca9
+	cancellable = e_activity_get_cancellable (titd->activity);
c72ca9
+	e_activity_set_state (
c72ca9
+		titd->activity,
c72ca9
+		g_cancellable_is_cancelled (cancellable) ? E_ACTIVITY_CANCELLED : E_ACTIVITY_COMPLETED);
c72ca9
+
c72ca9
+	if (!success) {
c72ca9
+		cal_transferring_update_alert (
c72ca9
+			titd->cal_shell_view,
c72ca9
+			titd->remove ? "calendar:failed-move-event" : "calendar:failed-copy-event",
c72ca9
+			titd->display_name,
c72ca9
+			error->message);
c72ca9
+		g_clear_error (&error);
c72ca9
+	}
c72ca9
 
c72ca9
-	if (e_cal_client_get_timezone_sync (ftd->source_client, tzid, &tz, NULL, NULL) && tz)
c72ca9
-		e_cal_client_add_timezone_sync (ftd->dest_client, tz, NULL, NULL);
c72ca9
+	g_object_unref (titd->activity);
c72ca9
+	g_free (titd);
c72ca9
 }
c72ca9
 
c72ca9
 void
c72ca9
@@ -946,129 +994,50 @@ e_cal_shell_view_transfer_item_to (ECalS
c72ca9
                                    ECalClient *destination_client,
c72ca9
                                    gboolean remove)
c72ca9
 {
c72ca9
-	icalcomponent *icalcomp;
c72ca9
-	icalcomponent *icalcomp_clone;
c72ca9
-	icalcomponent *icalcomp_event;
c72ca9
-	gboolean success;
c72ca9
-	const gchar *uid;
c72ca9
-
c72ca9
-	/* XXX This function should be split up into
c72ca9
-	 *     smaller, more understandable pieces. */
c72ca9
+	EActivity *activity;
c72ca9
+	EShellBackend *shell_backend;
c72ca9
+	ESource *source;
c72ca9
+	GCancellable *cancellable = NULL;
c72ca9
+	gchar *message;
c72ca9
+	const gchar *display_name;
c72ca9
+	TransferItemToData *titd;
c72ca9
 
c72ca9
 	g_return_if_fail (E_IS_CAL_SHELL_VIEW (cal_shell_view));
c72ca9
 	g_return_if_fail (event != NULL);
c72ca9
+	g_return_if_fail (is_comp_data_valid (event) != FALSE);
c72ca9
 	g_return_if_fail (E_IS_CAL_CLIENT (destination_client));
c72ca9
 
c72ca9
 	if (!is_comp_data_valid (event))
c72ca9
 		return;
c72ca9
 
c72ca9
-	icalcomp_event = event->comp_data->icalcomp;
c72ca9
-	uid = icalcomponent_get_uid (icalcomp_event);
c72ca9
-
c72ca9
-	/* Put the new object into the destination calendar. */
c72ca9
+	source = e_client_get_source (E_CLIENT (destination_client));
c72ca9
+	display_name = e_source_get_display_name (source);
c72ca9
 
c72ca9
-	success = e_cal_client_get_object_sync (
c72ca9
-		destination_client, uid, NULL, &icalcomp, NULL, NULL);
c72ca9
-
c72ca9
-	if (success) {
c72ca9
-		icalcomponent_free (icalcomp);
c72ca9
-		success = e_cal_client_modify_object_sync (
c72ca9
-			destination_client, icalcomp_event,
c72ca9
-			CALOBJ_MOD_ALL, NULL, NULL);
c72ca9
-
c72ca9
-		/* do not delete the event when it was found in the calendar */
c72ca9
-		return;
c72ca9
-	} else {
c72ca9
-		icalproperty *icalprop;
c72ca9
-		gchar *new_uid;
c72ca9
-		GError *error = NULL;
c72ca9
-		struct ForeachTzidData ftd;
c72ca9
-
c72ca9
-		ftd.source_client = event->comp_data->client;
c72ca9
-		ftd.dest_client = destination_client;
c72ca9
-
c72ca9
-		if (e_cal_util_component_is_instance (icalcomp_event)) {
c72ca9
-			success = e_cal_client_get_object_sync (
c72ca9
-				event->comp_data->client,
c72ca9
-				uid, NULL, &icalcomp, NULL, NULL);
c72ca9
-			if (success) {
c72ca9
-				/* Use master object when working
c72ca9
-				 * with a recurring event ... */
c72ca9
-				icalcomp_clone = icalcomponent_new_clone (icalcomp);
c72ca9
-				icalcomponent_free (icalcomp);
c72ca9
-			} else {
c72ca9
-				/* ... or remove the recurrence ID ... */
c72ca9
-				icalcomp_clone =
c72ca9
-					icalcomponent_new_clone (icalcomp_event);
c72ca9
-				if (e_cal_util_component_has_recurrences (icalcomp_clone)) {
c72ca9
-					/* ... for non-detached instances,
c72ca9
-					 * to make it a master object. */
c72ca9
-					icalprop = icalcomponent_get_first_property (
c72ca9
-						icalcomp_clone, ICAL_RECURRENCEID_PROPERTY);
c72ca9
-					if (icalprop != NULL)
c72ca9
-						icalcomponent_remove_property (
c72ca9
-							icalcomp_clone, icalprop);
c72ca9
-				}
c72ca9
-			}
c72ca9
-		} else
c72ca9
-			icalcomp_clone =
c72ca9
-				icalcomponent_new_clone (icalcomp_event);
c72ca9
-
c72ca9
-		icalprop = icalproperty_new_x ("1");
c72ca9
-		icalproperty_set_x_name (icalprop, "X-EVOLUTION-MOVE-CALENDAR");
c72ca9
-		icalcomponent_add_property (icalcomp_clone, icalprop);
c72ca9
-
c72ca9
-		if (!remove) {
c72ca9
-			/* Change the UID to avoid problems with
c72ca9
-			 * duplicated UIDs. */
c72ca9
-			new_uid = e_cal_component_gen_uid ();
c72ca9
-			icalcomponent_set_uid (icalcomp_clone, new_uid);
c72ca9
-			g_free (new_uid);
c72ca9
-		}
c72ca9
-
c72ca9
-		new_uid = NULL;
c72ca9
-		icalcomponent_foreach_tzid (
c72ca9
-			icalcomp_clone, add_timezone_to_cal_cb, &ftd);
c72ca9
-		success = e_cal_client_create_object_sync (
c72ca9
-			destination_client, icalcomp_clone,
c72ca9
-			&new_uid, NULL, &error);
c72ca9
-		if (!success) {
c72ca9
-			icalcomponent_free (icalcomp_clone);
c72ca9
-			g_warning (
c72ca9
-				"%s: Failed to create object: %s",
c72ca9
-				G_STRFUNC, error->message);
c72ca9
-			g_error_free (error);
c72ca9
-			return;
c72ca9
-		}
c72ca9
-
c72ca9
-		icalcomponent_free (icalcomp_clone);
c72ca9
-		g_free (new_uid);
c72ca9
-	}
c72ca9
-
c72ca9
-	if (remove) {
c72ca9
-		ECalClient *source_client = event->comp_data->client;
c72ca9
-
c72ca9
-		/* Remove the item from the source calendar. */
c72ca9
-		if (e_cal_util_component_is_instance (icalcomp_event) ||
c72ca9
-			e_cal_util_component_has_recurrences (icalcomp_event)) {
c72ca9
-			icaltimetype icaltime;
c72ca9
-			gchar *rid;
c72ca9
-
c72ca9
-			icaltime =
c72ca9
-				icalcomponent_get_recurrenceid (icalcomp_event);
c72ca9
-			if (!icaltime_is_null_time (icaltime))
c72ca9
-				rid = icaltime_as_ical_string_r (icaltime);
c72ca9
-			else
c72ca9
-				rid = NULL;
c72ca9
-			e_cal_client_remove_object_sync (
c72ca9
-				source_client, uid, rid,
c72ca9
-				CALOBJ_MOD_ALL, NULL, NULL);
c72ca9
-			g_free (rid);
c72ca9
-		} else
c72ca9
-			e_cal_client_remove_object_sync (
c72ca9
-				source_client, uid, NULL,
c72ca9
-				CALOBJ_MOD_THIS, NULL, NULL);
c72ca9
-	}
c72ca9
+	message = remove ?
c72ca9
+		g_strdup_printf (_("Moving an event into the calendar %s"), display_name) :
c72ca9
+		g_strdup_printf (_("Copying an event into the calendar %s"), display_name);
c72ca9
+
c72ca9
+	shell_backend = e_shell_view_get_shell_backend (E_SHELL_VIEW (cal_shell_view));
c72ca9
+
c72ca9
+	cancellable = g_cancellable_new ();
c72ca9
+	activity = e_activity_new ();
c72ca9
+	e_activity_set_cancellable (activity, cancellable);
c72ca9
+	e_activity_set_state (activity, E_ACTIVITY_RUNNING);
c72ca9
+	e_activity_set_text (activity, message);
c72ca9
+	g_free (message);
c72ca9
+
c72ca9
+	e_shell_backend_add_activity (shell_backend, activity);
c72ca9
+
c72ca9
+	titd = g_new0 (TransferItemToData, 1);
c72ca9
+
c72ca9
+	titd->cal_shell_view = cal_shell_view;
c72ca9
+	titd->activity = activity;
c72ca9
+	titd->display_name = display_name;
c72ca9
+	titd->remove = remove;
c72ca9
+
c72ca9
+	cal_comp_transfer_item_to (
c72ca9
+		event->comp_data->client, destination_client,
c72ca9
+		event->comp_data->icalcomp, !remove, cancellable, transfer_item_to_cb, titd);
c72ca9
 }
c72ca9
 
c72ca9
 void
c72ca9
diff -up evolution-3.8.5/modules/calendar/e-cal-shell-view-private.h.copy-move-recurrences evolution-3.8.5/modules/calendar/e-cal-shell-view-private.h
c72ca9
--- evolution-3.8.5/modules/calendar/e-cal-shell-view-private.h.copy-move-recurrences	2013-07-23 14:51:48.000000000 +0200
c72ca9
+++ evolution-3.8.5/modules/calendar/e-cal-shell-view-private.h	2013-11-04 22:11:17.125317884 +0100
c72ca9
@@ -115,6 +115,9 @@ struct _ECalShellViewPrivate {
c72ca9
 	gint search_direction; /* negative value is backward, positive is forward, zero is error; in days */
c72ca9
 	GSList *search_hit_cache; /* pointers on time_t for matched events */
c72ca9
 
c72ca9
+	/* Event/Task/Memo transferring */
c72ca9
+	gpointer transfer_alert; /* weak pointer to EAlert * */
c72ca9
+
c72ca9
         GFileMonitor *monitors[CHECK_NB];
c72ca9
 };
c72ca9
 
c72ca9
diff -up evolution-3.8.5/modules/calendar/e-memo-shell-sidebar.c.copy-move-recurrences evolution-3.8.5/modules/calendar/e-memo-shell-sidebar.c
c72ca9
--- evolution-3.8.5/modules/calendar/e-memo-shell-sidebar.c.copy-move-recurrences	2013-07-23 14:51:47.000000000 +0200
c72ca9
+++ evolution-3.8.5/modules/calendar/e-memo-shell-sidebar.c	2013-11-04 22:11:17.126317884 +0100
c72ca9
@@ -507,7 +507,7 @@ memo_shell_sidebar_constructed (GObject
c72ca9
 	container = GTK_CONTAINER (widget);
c72ca9
 
c72ca9
 	client_cache = e_shell_get_client_cache (shell);
c72ca9
-	widget = e_memo_list_selector_new (client_cache);
c72ca9
+	widget = e_memo_list_selector_new (client_cache, shell_view);
c72ca9
 	e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE);
c72ca9
 	gtk_container_add (container, widget);
c72ca9
 	a11y = gtk_widget_get_accessible (widget);
c72ca9
diff -up evolution-3.8.5/modules/calendar/e-task-shell-sidebar.c.copy-move-recurrences evolution-3.8.5/modules/calendar/e-task-shell-sidebar.c
c72ca9
--- evolution-3.8.5/modules/calendar/e-task-shell-sidebar.c.copy-move-recurrences	2013-07-23 14:51:47.000000000 +0200
c72ca9
+++ evolution-3.8.5/modules/calendar/e-task-shell-sidebar.c	2013-11-04 22:11:17.126317884 +0100
c72ca9
@@ -507,7 +507,7 @@ task_shell_sidebar_constructed (GObject
c72ca9
 	container = GTK_CONTAINER (widget);
c72ca9
 
c72ca9
 	client_cache = e_shell_get_client_cache (shell);
c72ca9
-	widget = e_task_list_selector_new (client_cache);
c72ca9
+	widget = e_task_list_selector_new (client_cache, shell_view);
c72ca9
 	e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE);
c72ca9
 	gtk_container_add (container, widget);
c72ca9
 	a11y = gtk_widget_get_accessible (widget);