aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/save-calendar
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavan@src.gnome.org>2006-04-22 03:23:18 +0800
committerSrinivasa Ragavan <sragavan@src.gnome.org>2006-04-22 03:23:18 +0800
commit6d472a771799cc453ad065b78f4635a7919f4769 (patch)
tree7dbf948f17415d6a1d37564225f6fad561a2b1d2 /plugins/save-calendar
parent5eceef8c7f89897442bc888ff0239378fe25fe04 (diff)
downloadgsoc2013-evolution-6d472a771799cc453ad065b78f4635a7919f4769.tar
gsoc2013-evolution-6d472a771799cc453ad065b78f4635a7919f4769.tar.gz
gsoc2013-evolution-6d472a771799cc453ad065b78f4635a7919f4769.tar.bz2
gsoc2013-evolution-6d472a771799cc453ad065b78f4635a7919f4769.tar.lz
gsoc2013-evolution-6d472a771799cc453ad065b78f4635a7919f4769.tar.xz
gsoc2013-evolution-6d472a771799cc453ad065b78f4635a7919f4769.tar.zst
gsoc2013-evolution-6d472a771799cc453ad065b78f4635a7919f4769.zip
Added code to see if the file already exist.
svn path=/trunk/; revision=31856
Diffstat (limited to 'plugins/save-calendar')
-rw-r--r--plugins/save-calendar/ChangeLog7
-rw-r--r--plugins/save-calendar/ical-format.c50
2 files changed, 38 insertions, 19 deletions
diff --git a/plugins/save-calendar/ChangeLog b/plugins/save-calendar/ChangeLog
index 6ca73daddb..8f47a22bbc 100644
--- a/plugins/save-calendar/ChangeLog
+++ b/plugins/save-calendar/ChangeLog
@@ -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:
diff --git a/plugins/save-calendar/ical-format.c b/plugins/save-calendar/ical-format.c
index 459bd4c254..f4620b89a2 100644
--- a/plugins/save-calendar/ical-format.c
+++ b/plugins/save-calendar/ical-format.c
@@ -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 *handler, EPlugin *ep, ECalPopupTargetSourc
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 *handler, EPlugin *ep, ECalPopupTargetSourc
}
/* 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);