diff options
Diffstat (limited to 'plugins/ipod-sync/ical-format.c')
-rw-r--r-- | plugins/ipod-sync/ical-format.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/plugins/ipod-sync/ical-format.c b/plugins/ipod-sync/ical-format.c index 76dc433c69..f5005c1bda 100644 --- a/plugins/ipod-sync/ical-format.c +++ b/plugins/ipod-sync/ical-format.c @@ -27,7 +27,6 @@ #include <glib/gi18n.h> #include <gtk/gtkfilechooser.h> #include <gtk/gtkfilechooserdialog.h> -#include <libgnomevfs/gnome-vfs-ops.h> #include <gtk/gtkmessagedialog.h> #include <gtk/gtkstock.h> #include <gtk/gtk.h> @@ -37,7 +36,6 @@ #include <libecal/e-cal-util.h> #include <calendar/gui/e-cal-popup.h> #include <calendar/common/authentication.h> -#include <libgnomevfs/gnome-vfs.h> #include <string.h> #include "format-handler.h" @@ -80,8 +78,7 @@ do_save_calendar_ical (FormatHandler *handler, EPlugin *ep, ECalPopupTargetSourc error = NULL; if (e_cal_get_object_list (source_client, "#t", &objects, &error)) { - GnomeVFSResult result; - GnomeVFSHandle *handle; + GOutputStream *stream; while (objects != NULL) { icalcomponent *icalcomp = objects->data; @@ -93,29 +90,22 @@ 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)); - } - } + stream = open_for_writing (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (target->selector))), dest_uri, &error); - if (result == GNOME_VFS_OK) { - char *ical_str; - GnomeVFSFileSize bytes_written; + if (stream && !error) { + char *ical_str = icalcomponent_as_ical_string (top_level); - 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)); - } + g_output_stream_write_all (stream, ical_str, strlen (ical_str), NULL, NULL, &error); + g_output_stream_close (stream); - gnome_vfs_close (handle); + g_free (ical_str); } - } else { + + if (stream) + g_object_unref (stream); + } + + if (error) { display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (target->selector)), error->message); g_error_free (error); } |