Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/save-calendar/ChangeLog,v
retrieving revision 1.28
diff -u -p -r1.28 ChangeLog
--- ChangeLog	12 Feb 2006 23:55:56 -0000	1.28
+++ ChangeLog	21 Apr 2006 19:20:45 -0000
@@ -1,3 +1,10 @@
+2006-04-22 Srinivasa Ragavan <sragavan@novell.com>
+
+	* ical-format.c (do_save_calendar_ical): Ask for overwrite, if the
+	file already exists.
+
+	** Fixes bug #329345
+
 2006-02-13  Karsten Bräckelmann  <guenther@rudersport.de>
 
 	* org-gnome-save-calendar.eplug.xml:
Index: ical-format.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/save-calendar/ical-format.c,v
retrieving revision 1.4
diff -u -p -r1.4 ical-format.c
--- ical-format.c	24 Aug 2005 03:13:50 -0000	1.4
+++ ical-format.c	21 Apr 2006 19:20:47 -0000
@@ -45,6 +45,7 @@
 #include <string.h>
 
 #include "format-handler.h"
+#include "e-util/e-error.h"
 
 static void
 display_error_message (GtkWidget *parent, const char *message)
@@ -64,6 +65,8 @@ do_save_calendar_ical (FormatHandler *ha
 	GError *error = NULL;
 	GList *objects;
 	icalcomponent *top_level = NULL;
+	GnomeVFSURI *uri;
+	gboolean doit = TRUE;	
 
 	primary_source = e_source_selector_peek_primary_selection (target->selector);
 
@@ -97,27 +100,36 @@ do_save_calendar_ical (FormatHandler *ha
 		}
 
 		/* save the file */
-		result = gnome_vfs_open (&handle, dest_uri, GNOME_VFS_OPEN_WRITE);
-		if (result != GNOME_VFS_OK) {
-			if ((result = gnome_vfs_create (&handle, dest_uri, GNOME_VFS_OPEN_WRITE,
-							TRUE, GNOME_VFS_PERM_USER_ALL)) != GNOME_VFS_OK) {
-				display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (target->selector)),
-					       gnome_vfs_result_to_string (result));
-			}
-		}
-
-		if (result == GNOME_VFS_OK) {
-			char *ical_str;
-			GnomeVFSFileSize bytes_written;
-
-			ical_str = icalcomponent_as_ical_string (top_level);
-			if ((result = gnome_vfs_write (handle, (gconstpointer) ical_str, strlen (ical_str), &bytes_written))
-			    != GNOME_VFS_OK) {
-				display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (target->selector)),
+		uri = gnome_vfs_uri_new (dest_uri);
+	
+		result = gnome_vfs_open_uri (&handle, uri, GNOME_VFS_OPEN_READ);
+		if (result == GNOME_VFS_OK)
+			doit = e_error_run(GTK_WINDOW(gtk_widget_get_toplevel (GTK_WIDGET (target->selector))),
+				 E_ERROR_ASK_FILE_EXISTS_OVERWRITE, dest_uri, NULL) == GTK_RESPONSE_OK;
+
+		if (doit) {
+			result = gnome_vfs_open (&handle, dest_uri, GNOME_VFS_OPEN_WRITE);
+			if (result != GNOME_VFS_OK) {
+				if ((result = gnome_vfs_create (&handle, dest_uri, GNOME_VFS_OPEN_WRITE,
+								TRUE, GNOME_VFS_PERM_USER_ALL)) != GNOME_VFS_OK) {
+					display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (target->selector)),
 						       gnome_vfs_result_to_string (result));
+					}
+			}
+	
+			if (result == GNOME_VFS_OK) {
+				char *ical_str;
+				GnomeVFSFileSize bytes_written;
+	
+				ical_str = icalcomponent_as_ical_string (top_level);
+				if ((result = gnome_vfs_write (handle, (gconstpointer) ical_str, strlen (ical_str), &bytes_written))
+				    != GNOME_VFS_OK) {
+					display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (target->selector)),
+								       gnome_vfs_result_to_string (result));
+				}
+	
+				gnome_vfs_close (handle);
 			}
-
-			gnome_vfs_close (handle);
 		}
 	} else {
 		display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (target->selector)), error->message);
