evolution r37140 - in trunk/calendar: . gui



Author: mcrha
Date: Tue Jan 27 12:32:09 2009
New Revision: 37140
URL: http://svn.gnome.org/viewvc/evolution?rev=37140&view=rev

Log:
2009-01-27  Milan Crha  <mcrha redhat com>

	** Fix for bug #318003

	* gui/memos-component.c: (selector_tree_data_dropped):
	* gui/tasks-component.c: (selector_tree_data_dropped):
	* gui/calendar-component.c: (selector_tree_data_dropped),
	(create_component_view):
	* gui/comp-util.h: (cal_comp_process_source_list_drop):
	* gui/comp-util.c: (update_single_object), (update_objects),
	(cal_comp_process_source_list_drop):
	Support move of the event in day view when dropped over the source
	list. Use the same function for events/tasks/memos.

	* gui/e-day-view.c: (e_day_view_on_drag_data_get):
	Encode string data same as memos and tasks do, with a source UID.

	* gui/e-calendar-table.c: (e_calendar_table_copy_clipboard):
	* gui/e-memo-table.c: (e_memo_table_copy_clipboard):
	Removed inappropriate comments.



Modified:
   trunk/calendar/ChangeLog
   trunk/calendar/gui/calendar-component.c
   trunk/calendar/gui/comp-util.c
   trunk/calendar/gui/comp-util.h
   trunk/calendar/gui/e-calendar-table.c
   trunk/calendar/gui/e-day-view.c
   trunk/calendar/gui/e-memo-table.c
   trunk/calendar/gui/memos-component.c
   trunk/calendar/gui/tasks-component.c

Modified: trunk/calendar/gui/calendar-component.c
==============================================================================
--- trunk/calendar/gui/calendar-component.c	(original)
+++ trunk/calendar/gui/calendar-component.c	Tue Jan 27 12:32:09 2009
@@ -1020,94 +1020,42 @@
 }
 
 static gboolean
-update_single_object (ECal *client, icalcomponent *icalcomp)
-{
-	char *uid;
-	icalcomponent *tmp_icalcomp;
-
-	uid = (char *) icalcomponent_get_uid (icalcomp);
-
-	if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL))
-		return e_cal_modify_object (client, icalcomp, CALOBJ_MOD_ALL, NULL);
-
-	return e_cal_create_object (client, icalcomp, &uid, NULL);
-}
-
-static gboolean
-update_objects (ECal *client, icalcomponent *icalcomp)
-{
-	icalcomponent *subcomp;
-	icalcomponent_kind kind;
-
-	kind = icalcomponent_isa (icalcomp);
-	if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT)
-		return update_single_object (client, icalcomp);
-	else if (kind != ICAL_VCALENDAR_COMPONENT)
-		return FALSE;
-
-	subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT);
-	while (subcomp) {
-		gboolean success;
-
-		kind = icalcomponent_isa (subcomp);
-		if (kind == ICAL_VTIMEZONE_COMPONENT) {
-			icaltimezone *zone;
-
-			zone = icaltimezone_new ();
-			icaltimezone_set_component (zone, subcomp);
-
-			success = e_cal_add_timezone (client, zone, NULL);
-			icaltimezone_free (zone, 1);
-			if (!success)
-				return success;
-		} else if (kind == ICAL_VTODO_COMPONENT ||
-			   kind == ICAL_VEVENT_COMPONENT) {
-			success = update_single_object (client, subcomp);
-			if (!success)
-				return success;
-		}
-
-		subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT);
-	}
-
-	return TRUE;
-}
-
-static gboolean
 selector_tree_data_dropped (ESourceSelector *selector,
                             GtkSelectionData *data,
                             ESource *destination,
                             GdkDragAction action,
-                            guint info)
+                            guint info,
+			    CalendarComponent *component)
 {
 	gboolean success = FALSE;
-	icalcomponent *icalcomp = NULL;
-	ECal *client = NULL;
-
-	icalcomp = icalparser_parse_string ((char *)data->data);
+	ECal *client;
 
-	if (icalcomp) {
-		char * uid;
+	client = auth_new_cal_from_source (destination, E_CAL_SOURCE_TYPE_EVENT);
 
-		/* FIXME deal with GDK_ACTION_ASK */
-		if (action == GDK_ACTION_COPY) {
-			uid = e_cal_component_gen_uid ();
-			icalcomponent_set_uid (icalcomp, uid);
-		}
+	if (!client || !e_cal_open (client, TRUE, NULL)) {
+		if (client)
+			g_object_unref (client);
 
-		client = auth_new_cal_from_source (destination,
-						   E_CAL_SOURCE_TYPE_EVENT);
+		return FALSE;
+	}
 
-		if (client) {
-			if (e_cal_open (client, TRUE, NULL)) {
-				success = TRUE;
-				update_objects (client, icalcomp);
+	if (data->data) {
+		icalcomponent *icalcomp = NULL;
+		char *comp_str; /* do not free this! */
+
+		/* data->data is "source_uid\ncomponent_string" */
+		comp_str = strchr ((char *)data->data, '\n');
+		if (comp_str) {
+			comp_str [0] = 0;
+			comp_str++;
+
+			icalcomp = icalparser_parse_string (comp_str);
+
+			if (icalcomp) {
+				success = cal_comp_process_source_list_drop (client, icalcomp, action, (char *)data->data, component->priv->source_list);
+				icalcomponent_free (icalcomp);
 			}
-
-			g_object_unref (client);
 		}
-
-		icalcomponent_free (icalcomp);
 	}
 
 	return success;
@@ -1324,7 +1272,7 @@
 
 	g_signal_connect (
 		component_view->source_selector, "data-dropped",
-		G_CALLBACK (selector_tree_data_dropped), NULL);
+		G_CALLBACK (selector_tree_data_dropped), calendar_component);
 
 	gtk_drag_dest_set(component_view->source_selector, GTK_DEST_DEFAULT_ALL, drag_types,
 			  num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE);

Modified: trunk/calendar/gui/comp-util.c
==============================================================================
--- trunk/calendar/gui/comp-util.c	(original)
+++ trunk/calendar/gui/comp-util.c	Tue Jan 27 12:32:09 2009
@@ -33,6 +33,7 @@
 #include "dialogs/delete-comp.h"
 #include <libecal/e-cal-component.h>
 #include "e-util/e-categories-config.h"
+#include "common/authentication.h"
 
 
 
@@ -607,3 +608,191 @@
 
 	e_cal_component_free_datetime (&olddate);
 }
+
+static gboolean
+update_single_object (ECal *client, icalcomponent *icalcomp, gboolean fail_on_modify)
+{
+	const char *uid;
+	char *tmp;
+	icalcomponent *tmp_icalcomp;
+	gboolean res;
+
+	uid = icalcomponent_get_uid (icalcomp);
+
+	if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL)) {
+		if (fail_on_modify)
+			return FALSE;
+
+		return e_cal_modify_object (client, icalcomp, CALOBJ_MOD_ALL, NULL);
+	}
+
+	tmp = NULL;
+	res = e_cal_create_object (client, icalcomp, &tmp, NULL);
+
+	g_free (tmp);
+
+	return res;
+}
+
+static gboolean
+update_objects (ECal *client, icalcomponent *icalcomp)
+{
+	icalcomponent *subcomp;
+	icalcomponent_kind kind;
+
+	kind = icalcomponent_isa (icalcomp);
+	if (kind == ICAL_VTODO_COMPONENT || 
+	    kind == ICAL_VEVENT_COMPONENT ||
+	    kind == ICAL_VJOURNAL_COMPONENT)
+		return update_single_object (client, icalcomp, kind == ICAL_VJOURNAL_COMPONENT);
+	else if (kind != ICAL_VCALENDAR_COMPONENT)
+		return FALSE;
+
+	subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT);
+	while (subcomp) {
+		gboolean success;
+
+		kind = icalcomponent_isa (subcomp);
+		if (kind == ICAL_VTIMEZONE_COMPONENT) {
+			icaltimezone *zone;
+
+			zone = icaltimezone_new ();
+			icaltimezone_set_component (zone, subcomp);
+
+			success = e_cal_add_timezone (client, zone, NULL);
+			icaltimezone_free (zone, 1);
+			if (!success)
+				return success;
+		} else if (kind == ICAL_VTODO_COMPONENT ||
+			   kind == ICAL_VEVENT_COMPONENT ||
+			   kind == ICAL_VJOURNAL_COMPONENT) {
+			success = update_single_object (client, subcomp, kind == ICAL_VJOURNAL_COMPONENT);
+			if (!success)
+				return success;
+		}
+
+		subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT);
+	}
+
+	return TRUE;
+}
+
+/**
+ * cal_comp_process_source_list_drop:
+ * Processes the drop signal over the ESourceList.
+ * @param destination Where to put the component.
+ * @param comp Component to move/copy.
+ * @param action What to do.
+ * @param source_uid Where the component comes from; used when moving.
+ * @param source_list The ESourceList over which the event was called.
+ * @return Whether was the operation successful.
+ **/
+gboolean
+cal_comp_process_source_list_drop (ECal *destination, icalcomponent *comp, GdkDragAction action, const char *source_uid, ESourceList *source_list)
+{
+	const char * uid;
+	char *old_uid = NULL;
+	icalcomponent *tmp_icalcomp = NULL;
+	GError *error = NULL;
+	gboolean success = FALSE;
+
+	g_return_val_if_fail (destination != NULL, FALSE);
+	g_return_val_if_fail (comp != NULL, FALSE);
+	g_return_val_if_fail (source_uid != NULL, FALSE);
+	g_return_val_if_fail (source_list != NULL, FALSE);
+
+	/* FIXME deal with GDK_ACTION_ASK */
+	if (action == GDK_ACTION_COPY) {
+		char *tmp;
+
+		old_uid = g_strdup (icalcomponent_get_uid (comp));
+		tmp = e_cal_component_gen_uid ();
+
+		icalcomponent_set_uid (comp, tmp);
+		g_free (tmp);
+	}
+
+	uid = icalcomponent_get_uid (comp);
+	if (!old_uid)
+		old_uid = g_strdup (uid);
+
+	if (!e_cal_get_object (destination, uid, NULL, &tmp_icalcomp, &error)) {
+		if ((error != NULL) && (error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND)) {
+			switch (e_cal_get_source_type (destination)) {
+			case E_CAL_SOURCE_TYPE_EVENT:
+				g_message ("Failed to search the object in destination event list: %s", error->message);
+				break;
+			case E_CAL_SOURCE_TYPE_TODO:
+				g_message ("Failed to search the object in destination task list: %s", error->message);
+				break;
+			case E_CAL_SOURCE_TYPE_JOURNAL:
+				g_message ("Failed to search the object in destination memo list: %s", error->message);
+				break;
+			default:
+				break;
+			}
+		} else {
+			/* this will report success by last item, but we don't care */
+			success = update_objects (destination, comp);
+
+			if (success && action == GDK_ACTION_MOVE) {
+				/* remove components rather here, because we know which has been moved */
+				ESource *source_source;
+				ECal *source_client;
+
+				source_source = e_source_list_peek_source_by_uid (source_list, source_uid);
+
+				if (source_source && !E_IS_SOURCE_GROUP (source_source) && !e_source_get_readonly (source_source)) {
+					source_client = auth_new_cal_from_source (source_source, e_cal_get_source_type (destination));
+
+					if (source_client) {
+						gboolean read_only = TRUE;
+
+						e_cal_is_read_only (source_client, &read_only, NULL);
+
+						if (!read_only && e_cal_open (source_client, TRUE, NULL))
+							e_cal_remove_object (source_client, old_uid, NULL);
+						else if (!read_only) {
+							switch (e_cal_get_source_type (destination)) {
+							case E_CAL_SOURCE_TYPE_EVENT:
+								g_message ("Cannot open source client to remove old event");
+								break;
+							case E_CAL_SOURCE_TYPE_TODO:
+								g_message ("Cannot open source client to remove old task");
+								break;
+							case E_CAL_SOURCE_TYPE_JOURNAL:
+								g_message ("Cannot open source client to remove old memo");
+								break;
+							default:
+								break;
+							}
+						}
+
+						g_object_unref (source_client);
+					} else {
+						switch (e_cal_get_source_type (destination)) {
+						case E_CAL_SOURCE_TYPE_EVENT:
+							g_message ("Cannot create source client to remove old event");
+							break;
+						case E_CAL_SOURCE_TYPE_TODO:
+							g_message ("Cannot create source client to remove old task");
+							break;
+						case E_CAL_SOURCE_TYPE_JOURNAL:
+							g_message ("Cannot create source client to remove old memo");
+							break;
+						default:
+							break;
+						}
+					}
+				}
+			}
+		}
+
+		g_clear_error (&error);
+	} else
+		icalcomponent_free (tmp_icalcomp);
+
+	g_free (old_uid);
+
+	return success;
+}

Modified: trunk/calendar/gui/comp-util.h
==============================================================================
--- trunk/calendar/gui/comp-util.h	(original)
+++ trunk/calendar/gui/comp-util.h	Tue Jan 27 12:32:09 2009
@@ -57,4 +57,6 @@
 void cal_comp_set_dtstart_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate);
 void cal_comp_set_dtend_with_oldzone (ECal *client, ECalComponent *comp, const ECalComponentDateTime *pdate);
 
+gboolean cal_comp_process_source_list_drop (ECal *destination, icalcomponent *comp, GdkDragAction action, const char *source_uid, ESourceList *source_list);
+
 #endif

Modified: trunk/calendar/gui/e-calendar-table.c
==============================================================================
--- trunk/calendar/gui/e-calendar-table.c	(original)
+++ trunk/calendar/gui/e-calendar-table.c	Tue Jan 27 12:32:09 2009
@@ -1129,8 +1129,7 @@
 					 clipboard_get_calendar_cb,
 					 NULL, comp_str)) {
 
-		/* do not free this pointer, it owns libical */
-		/* g_free (comp_str); */
+		/* no-op */
 	} else {
 		gtk_clipboard_set_can_store (clipboard, target_types + 1, n_target_types - 1);
 	}

Modified: trunk/calendar/gui/e-day-view.c
==============================================================================
--- trunk/calendar/gui/e-day-view.c	(original)
+++ trunk/calendar/gui/e-day-view.c	Tue Jan 27 12:32:09 2009
@@ -7366,8 +7366,18 @@
 
 		comp_str = icalcomponent_as_ical_string_r (vcal);
 		if (comp_str) {
+			ESource *source = e_cal_get_source (event->comp_data->client);
+			const char *source_uid = e_source_peek_uid (source);
+			char *tmp;
+
+			if (!source_uid)
+				source_uid = "";
+
+			tmp = g_strconcat (source_uid, "\n", comp_str, NULL);
 			gtk_selection_data_set (selection_data, selection_data->target,
-						8, (unsigned char *)comp_str, strlen (comp_str));
+						8, (unsigned char *)tmp, strlen (tmp));
+
+			g_free (tmp);
 		}
 
 		icalcomponent_free (vcal);

Modified: trunk/calendar/gui/e-memo-table.c
==============================================================================
--- trunk/calendar/gui/e-memo-table.c	(original)
+++ trunk/calendar/gui/e-memo-table.c	Tue Jan 27 12:32:09 2009
@@ -601,8 +601,7 @@
 	if (!gtk_clipboard_set_with_data(clipboard, target_types, n_target_types,
 					 clipboard_get_calendar_cb,
 					 NULL, comp_str)) {
-		/* do not free this pointer, it owns libical */
-		/* g_free (comp_str); */
+		/* no-op */
 	} else {
 		gtk_clipboard_set_can_store (clipboard, target_types + 1, n_target_types - 1);
 	}

Modified: trunk/calendar/gui/memos-component.c
==============================================================================
--- trunk/calendar/gui/memos-component.c	(original)
+++ trunk/calendar/gui/memos-component.c	Tue Jan 27 12:32:09 2009
@@ -647,67 +647,6 @@
 }
 
 static gboolean
-update_single_object (ECal *client, icalcomponent *icalcomp, gboolean fail_on_modify)
-{
-	char *uid;
-	icalcomponent *tmp_icalcomp;
-
-	d(g_message("memos-component.c: update_single_object called");)
-
-	uid = (char *) icalcomponent_get_uid (icalcomp);
-
-	if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL)) {
-		if (fail_on_modify)
-			return FALSE;
-		else
-			return e_cal_modify_object (client, icalcomp, CALOBJ_MOD_ALL, NULL);
-	}
-
-	return e_cal_create_object (client, icalcomp, &uid, NULL);
-}
-
-static gboolean
-update_objects (ECal *client, icalcomponent *icalcomp)
-{
-	icalcomponent *subcomp;
-	icalcomponent_kind kind;
-
-	d(g_message("memos-component.c: update_objects called");)
-
-	kind = icalcomponent_isa (icalcomp);
-	if (kind == ICAL_VJOURNAL_COMPONENT)
-		return update_single_object (client, icalcomp, TRUE);
-	else if (kind != ICAL_VCALENDAR_COMPONENT)
-		return FALSE;
-
-	subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT);
-	while (subcomp) {
-		gboolean success;
-
-		kind = icalcomponent_isa (subcomp);
-		if (kind == ICAL_VTIMEZONE_COMPONENT) {
-			icaltimezone *zone;
-
-			zone = icaltimezone_new ();
-			icaltimezone_set_component (zone, subcomp);
-
-			success = e_cal_add_timezone (client, zone, NULL);
-			icaltimezone_free (zone, 1);
-			if (!success)
-				return success;
-		} else if (kind == ICAL_VJOURNAL_COMPONENT) {
-			success = update_single_object (client, subcomp, TRUE);
-			if (!success)
-				return success;
-		}
-
-		subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT);
-	}
-
-	return TRUE;
-}
-
-static gboolean
 selector_tree_data_dropped (ESourceSelector *selector,
                             GtkSelectionData *data,
                             ESource *destination,
@@ -727,11 +666,8 @@
 		goto  finish;
 
 	components = cal_comp_selection_get_string_list (data);
-	for (p = components; p; p = p->next) {
-		const char * uid;
-		char *old_uid = NULL;
-		icalcomponent *tmp_icalcomp = NULL;
-		GError *error = NULL;
+	success = components != NULL;
+	for (p = components; p && success; p = p->next) {
 		char *comp_str; /* do not free this! */
 
 		/* p->data is "source_uid\ncomponent_string" */
@@ -746,58 +682,10 @@
 		if (!icalcomp)
 			continue;
 
-		/* FIXME deal with GDK_ACTION_ASK */
-		if (action == GDK_ACTION_COPY) {
-			old_uid = g_strdup (icalcomponent_get_uid (icalcomp));
-			uid = e_cal_component_gen_uid ();
-			icalcomponent_set_uid (icalcomp, uid);
-		}
-
-		uid = icalcomponent_get_uid (icalcomp);
-		if (!old_uid)
-			old_uid = g_strdup (uid);
-
-		if (!e_cal_get_object (client, uid, NULL, &tmp_icalcomp, &error)) {
-			if ((error != NULL) && (error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND))
-				g_message ("Failed to search the object in destination task list: %s",error->message);
-			else {
-				/* this will report success by last item, but we don't care */
-				success = update_objects (client, icalcomp);
-
-				if (success && action == GDK_ACTION_MOVE) {
-					/* remove components rather here, because we know which has been moved */
-					ESource *source_source;
-					ECal *source_client;
-
-					source_source = e_source_list_peek_source_by_uid (component->priv->source_list, p->data);
-
-					if (source_source && !E_IS_SOURCE_GROUP (source_source) && !e_source_get_readonly (source_source)) {
-						source_client = auth_new_cal_from_source (source_source, E_CAL_SOURCE_TYPE_JOURNAL);
-
-						if (source_client) {
-							gboolean read_only = TRUE;
-
-							e_cal_is_read_only (source_client, &read_only, NULL);
-
-							if (!read_only && e_cal_open (source_client, TRUE, NULL))
-								e_cal_remove_object (source_client, old_uid, NULL);
-							else if (!read_only)
-								g_message ("Cannot open source client to remove old memo");
-
-							g_object_unref (source_client);
-						} else
-							g_message ("Cannot create source client to remove old memo");
-					}
-				}
-			}
-
-			g_clear_error (&error);
-		} else
-			icalcomponent_free (tmp_icalcomp);
-
-		g_free (old_uid);
+		success = cal_comp_process_source_list_drop (client, icalcomp, action, p->data, component->priv->source_list);
 		icalcomponent_free (icalcomp);
 	}
+
 	g_slist_foreach (components, (GFunc)g_free, NULL);
 	g_slist_free (components);
 

Modified: trunk/calendar/gui/tasks-component.c
==============================================================================
--- trunk/calendar/gui/tasks-component.c	(original)
+++ trunk/calendar/gui/tasks-component.c	Tue Jan 27 12:32:09 2009
@@ -638,60 +638,6 @@
 }
 
 static gboolean
-update_single_object (ECal *client, icalcomponent *icalcomp)
-{
-	char *uid;
-	icalcomponent *tmp_icalcomp;
-
-	uid = (char *) icalcomponent_get_uid (icalcomp);
-
-	if (e_cal_get_object (client, uid, NULL, &tmp_icalcomp, NULL))
-		return e_cal_modify_object (client, icalcomp, CALOBJ_MOD_ALL, NULL);
-
-	return e_cal_create_object (client, icalcomp, &uid, NULL);
-}
-
-static gboolean
-update_objects (ECal *client, icalcomponent *icalcomp)
-{
-	icalcomponent *subcomp;
-	icalcomponent_kind kind;
-
-	kind = icalcomponent_isa (icalcomp);
-	if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT)
-		return update_single_object (client, icalcomp);
-	else if (kind != ICAL_VCALENDAR_COMPONENT)
-		return FALSE;
-
-	subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT);
-	while (subcomp) {
-		gboolean success;
-
-		kind = icalcomponent_isa (subcomp);
-		if (kind == ICAL_VTIMEZONE_COMPONENT) {
-			icaltimezone *zone;
-
-			zone = icaltimezone_new ();
-			icaltimezone_set_component (zone, subcomp);
-
-			success = e_cal_add_timezone (client, zone, NULL);
-			icaltimezone_free (zone, 1);
-			if (!success)
-				return success;
-		} else if (kind == ICAL_VTODO_COMPONENT ||
-			   kind == ICAL_VEVENT_COMPONENT) {
-			success = update_single_object (client, subcomp);
-			if (!success)
-				return success;
-		}
-
-		subcomp = icalcomponent_get_next_component (icalcomp, ICAL_ANY_COMPONENT);
-	}
-
-	return TRUE;
-}
-
-static gboolean
 selector_tree_data_dropped (ESourceSelector *selector,
                             GtkSelectionData *data,
                             ESource *destination,
@@ -711,11 +657,8 @@
 		goto  finish;
 
 	components = cal_comp_selection_get_string_list (data);
-	for (p = components; p; p = p->next) {
-		const char * uid;
-		char *old_uid = NULL;
-		icalcomponent *tmp_icalcomp = NULL;
-		GError *error = NULL;
+	success = components != NULL;
+	for (p = components; p && success; p = p->next) {
 		char *comp_str; /* do not free this! */
 
 		/* p->data is "source_uid\ncomponent_string" */
@@ -730,56 +673,7 @@
 		if (!icalcomp)
 			continue;
 
-		/* FIXME deal with GDK_ACTION_ASK */
-		if (action == GDK_ACTION_COPY) {
-			old_uid = g_strdup (icalcomponent_get_uid (icalcomp));
-			uid = e_cal_component_gen_uid ();
-			icalcomponent_set_uid (icalcomp, uid);
-		}
-
-		uid = icalcomponent_get_uid (icalcomp);
-		if (!old_uid)
-			old_uid = g_strdup (uid);
-
-		if (!e_cal_get_object (client, uid, NULL, &tmp_icalcomp, &error)) {
-			if ((error != NULL) && (error->code != E_CALENDAR_STATUS_OBJECT_NOT_FOUND))
-				g_message ("Failed to search the object in destination task list: %s",error->message);
-			else {
-				/* this will report success by last item, but we don't care */
-				success = update_objects (client, icalcomp);
-
-				if (success && action == GDK_ACTION_MOVE) {
-					/* remove components rather here, because we know which has been moved */
-					ESource *source_source;
-					ECal *source_client;
-
-					source_source = e_source_list_peek_source_by_uid (component->priv->source_list, p->data);
-
-					if (source_source && !E_IS_SOURCE_GROUP (source_source) && !e_source_get_readonly (source_source)) {
-						source_client = auth_new_cal_from_source (source_source, E_CAL_SOURCE_TYPE_TODO);
-
-						if (source_client) {
-							gboolean read_only = TRUE;
-
-							e_cal_is_read_only (source_client, &read_only, NULL);
-
-							if (!read_only && e_cal_open (source_client, TRUE, NULL))
-								e_cal_remove_object (source_client, old_uid, NULL);
-							else if (!read_only)
-								g_message ("Cannot open source client to remove old task");
-
-							g_object_unref (source_client);
-						} else
-							g_message ("Cannot create source client to remove old task");
-					}
-				}
-			}
-
-			g_clear_error (&error);
-		} else
-			icalcomponent_free (tmp_icalcomp);
-
-		g_free (old_uid);
+		success = cal_comp_process_source_list_drop (client, icalcomp, action, p->data, component->priv->source_list);
 		icalcomponent_free (icalcomp);
 	}
 	g_slist_foreach (components, (GFunc)g_free, NULL);



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