aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/publish-calendar
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2008-04-18 00:59:08 +0800
committerMilan Crha <mcrha@src.gnome.org>2008-04-18 00:59:08 +0800
commite9a0cfe1a901f41456575a2cd07158f1947b873c (patch)
treeafaedd4dd4c72cbf773142e592324d83bd05b950 /plugins/publish-calendar
parentb24bdfcc8d3e43499f1e81351f69ac667cedd08a (diff)
downloadgsoc2013-evolution-e9a0cfe1a901f41456575a2cd07158f1947b873c.tar
gsoc2013-evolution-e9a0cfe1a901f41456575a2cd07158f1947b873c.tar.gz
gsoc2013-evolution-e9a0cfe1a901f41456575a2cd07158f1947b873c.tar.bz2
gsoc2013-evolution-e9a0cfe1a901f41456575a2cd07158f1947b873c.tar.lz
gsoc2013-evolution-e9a0cfe1a901f41456575a2cd07158f1947b873c.tar.xz
gsoc2013-evolution-e9a0cfe1a901f41456575a2cd07158f1947b873c.tar.zst
gsoc2013-evolution-e9a0cfe1a901f41456575a2cd07158f1947b873c.zip
** Fix for bug #526741 (gnome-vfs to gio/gvfs port)
2008-04-17 Milan Crha <mcrha@redhat.com> ** Fix for bug #526741 (gnome-vfs to gio/gvfs port) * configure.in: Drop dependency on gnome-vfs, depend on gio instead. * addressbook/gui/contact-editor/e-contact-editor.c: Do not include gnome-vfs. * calendar/gui/e-meeting-store.c: (start_async_read), (freebusy_async), (async_read): Read data with gio, not with gnome-vfs. * calendar/gui/e-meeting-store.c: (async_close): Function removed. * calendar/gui/migration.c: * calendar/gui/e-memos.c: * calendar/gui/alarm-notify/notify-main.c: * calendar/gui/e-tasks.c: * calendar/gui/main.c: * calendar/gui/e-meeting-list-view.c: Do not include gnome-vfs. * calendar/gui/dialogs/comp-editor.c: (set_attachment_list): * calendar/gui/dialogs/comp-editor.c: (attachment_guess_mime_type): Function removed, use e-util function instead. * calendar/gui/e-cal-popup.c: (temp_save_part): Reflect changes in CamelStreamVFS. * calendar/gui/e-cal-popup.c: (ecalp_apps_open_in), (ecalp_apps_popup_free), (ecalp_standard_menu_factory): Use gio to fill popup and launch app. * calendar/gui/e-cal-component-preview.h: (e_cal_comp_preview_url_requested_cb): * calendar/gui/e-cal-component-preview.c: (e_cal_comp_preview_url_requested_cb): New helper function to manage file:// urls for GtkHTML component. * calendar/gui/e-cal-component-preview.c: (e_cal_component_preview_init): * calendar/gui/e-cal-component-memo-preview.c: (e_cal_comp_preview_url_requested_cb): Use above helper function. * calendar/gui/e-cal-component-memo-preview.c: (url_requested_cb): * calendar/gui/e-cal-component-preview.c: (url_requested_cb): Function removed. * composer/e-msg-composer.h: (e_msg_composer_guess_mime_type): * composer/e-msg-composer.c: (e_msg_composer_guess_mime_type), (handle_uri), (e_msg_composer_add_inline_image_from_file): Use shared e_util_guess_mime_type instead of its own. * e-util/e-gui-utils.c: Do not include gnome-vfs. * e-util/e-util.c: (e_write_file_uri), (e_file_get_save_path): * e-util/e-dialog-utils.c: (e_file_can_save), (e_file_check_local): Use gio instead of gnome-vfs. * e-util/e-util.h: * e-util/e-util.c: (e_util_guess_mime_type), (e_util_filename_to_uri), (e_util_uri_to_filename), (e_util_read_file): New helper functions. * mail/Makefile.am: * mail/em-vfs-stream.h: * mail/em-vfs-stream.c: Removed from project, not used anywhere. * mail/em-menu.c: * mail/em-config.c: Do not include gnome-vfs. * mail/mail-ops.c: (save_messages_exec), (save_part_exec): Changes related to Data Server change of CamelStreamVFS. * mail/em-format.c: (em_format_describe_part): * mail/em-format-html-display.c: (efhd_bonobo_object), (efhd_find_handler), (efhd_use_component), (efhd_bonobo_unknown), (efhd_check_server_prop), (efhd_format_attachment): Drop use of deprecated gnome-vfs functions. * mail/em-utils.c: (em_utils_snoop_type): Use gio to guess the mime_type. * mail/em-popup.c: (emp_apps_open_in), (emp_apps_popup_free), (emp_standard_menu_factory): Use gio to fill popup and launch app. * plugins/import-ics-attachments/icsimporter.c: Do not include gnome-vfs. * plugins/ipod-sync/ical-format.c: (do_save_calendar_ical): * plugins/ipod-sync/ipod-sync.c: (destination_save_addressbook): Write to gio GOutputStream instead of gnome-vfs handle. * plugins/ipod-sync/format-handler.h: (open_for_writing): * plugins/ipod-sync/ipod-sync.c: (open_for_writing): New helper function. * plugins/publish-calendar/publish-format-fb.h: (publish_calendar_as_fb): * plugins/publish-calendar/publish-format-fb.c: (write_calendar), (publish_calendar_as_fb): * plugins/publish-calendar/publish-format-ical.h: (publish_calendar_as_ical): * plugins/publish-calendar/publish-format-ical.c: (write_calendar), (publish_calendar_as_ical): Use gio GOutputStream instead of gnome-vfs handle. * plugins/publish-calendar/url-editor-dialog.c: (create_uri): Use glib function to escape URI. * plugins/publish-calendar/publish-location.c: (migrateURI): Use EUri to parse URI. * plugins/publish-calendar/publish-calendar.c: (publish_online), (unmount_done_cb), (struct mnt_struct), (mount_ready_cb), (ask_password), (ask_question), (mount_first), (publish): Use gio instead of gnome-vfs for opening (remote) files. * plugins/save-calendar/ical-format.c: (do_save_calendar_ical): * plugins/save-calendar/csv-format.c: (do_save_calendar_csv): * plugins/save-calendar/rdf-format.c: (do_save_calendar_rdf): Use gio GOutpuStream instead of gnome-vfs handle. * plugins/save-calendar/format-handler.h: (open_for_writing): * plugins/save-calendar/save-calendar.c: (open_for_writing): New helper function. * shell/e-shell-window-commands.c: (command_quick_reference): Use gio instead of gnome-vfs. * widgets/misc/e-attachment.h: (struct _EAttachment): * widgets/misc/e-attachment.c: (finalise), (init), (attachment_guess_mime_type), (e_attachment_new), (struct DownloadInfo), (download_info_free), (data_ready_cb), (download_to_local_path), (e_attachment_new_remote_file): Use gio instead of gnome-vfs to download remote files. * widgets/misc/e-image-chooser.c: (image_drag_data_received_cb): Use new util function to read file. * widgets/misc/e-attachment-bar.c: (size_to_string): Stolen from gnome-vfs. svn path=/trunk/; revision=35378
Diffstat (limited to 'plugins/publish-calendar')
-rw-r--r--plugins/publish-calendar/ChangeLog16
-rw-r--r--plugins/publish-calendar/publish-calendar.c285
-rw-r--r--plugins/publish-calendar/publish-format-fb.c41
-rw-r--r--plugins/publish-calendar/publish-format-fb.h4
-rw-r--r--plugins/publish-calendar/publish-format-ical.c37
-rw-r--r--plugins/publish-calendar/publish-format-ical.h4
-rw-r--r--plugins/publish-calendar/publish-location.c20
-rw-r--r--plugins/publish-calendar/url-editor-dialog.c4
8 files changed, 302 insertions, 109 deletions
diff --git a/plugins/publish-calendar/ChangeLog b/plugins/publish-calendar/ChangeLog
index 7d1a09468e..7837857825 100644
--- a/plugins/publish-calendar/ChangeLog
+++ b/plugins/publish-calendar/ChangeLog
@@ -1,3 +1,19 @@
+2008-04-17 Milan Crha <mcrha@redhat.com>
+
+ ** Part of fix for bug #526739
+
+ * publish-format-fb.h: (publish_calendar_as_fb):
+ * publish-format-fb.c: (write_calendar), (publish_calendar_as_fb):
+ * publish-format-ical.h: (publish_calendar_as_ical):
+ * publish-format-ical.c: (write_calendar), (publish_calendar_as_ical):
+ Use gio GOutputStream instead of gnome-vfs handle.
+ * url-editor-dialog.c: (create_uri): Use glib function to escape URI.
+ * publish-location.c: (migrateURI): Use EUri to parse URI.
+ * publish-calendar.c: (publish_online), (unmount_done_cb),
+ (struct mnt_struct), (mount_ready_cb), (ask_password), (ask_question),
+ (mount_first), (publish):
+ Use gio instead of gnome-vfs for opening (remote) files.
+
2007-12-14 Tobias Mueller <tobiasmue@svn.gnome.org>
Patch by <nickspoon0@gmail.com>
diff --git a/plugins/publish-calendar/publish-calendar.c b/plugins/publish-calendar/publish-calendar.c
index fd5b283c1a..29788afa39 100644
--- a/plugins/publish-calendar/publish-calendar.c
+++ b/plugins/publish-calendar/publish-calendar.c
@@ -24,7 +24,8 @@
#include <glade/glade.h>
#include <gconf/gconf-client.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs.h>
+#include <gio/gio.h>
+#include <libedataserver/e-url.h>
#include <libedataserverui/e-passwords.h>
#include <calendar/gui/e-cal-popup.h>
#include <calendar/gui/e-cal-config.h>
@@ -63,15 +64,228 @@ publish_uri_async (EPublishUri *uri)
}
static void
+publish_online (EPublishUri *uri, GFile *file, GError **perror)
+{
+ GOutputStream *stream;
+ GError *error = NULL;
+
+ stream = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &error));
+
+ if (!stream || error) {
+ if (stream)
+ g_object_unref (stream);
+
+ if (perror) {
+ *perror = error;
+ } else if (error) {
+ g_warning ("Couldn't open %s: %s", uri->location, error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Couldn't open %s: Unknown error", uri->location);
+ }
+ return;
+ }
+
+ switch (uri->publish_format) {
+ case URI_PUBLISH_AS_ICAL:
+ publish_calendar_as_ical (stream, uri);
+ break;
+ case URI_PUBLISH_AS_FB:
+ publish_calendar_as_fb (stream, uri);
+ break;
+ /*
+ case URI_PUBLISH_AS_HTML:
+ publish_calendar_as_html (handle, uri);
+ break;
+ */
+ }
+
+ update_timestamp (uri);
+
+ g_output_stream_close (stream, NULL, NULL);
+ g_object_unref (stream);
+}
+
+static void
+unmount_done_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ GError *error = NULL;
+
+ g_mount_unmount_finish (G_MOUNT (source_object), res, &error);
+
+ if (error) {
+ g_warning ("Unmount failed: %s", error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref (source_object);
+}
+
+struct mnt_struct {
+ EPublishUri *uri;
+ GFile *file;
+ GMountOperation *mount_op;
+};
+
+static void
+mount_ready_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ struct mnt_struct *ms = (struct mnt_struct *) user_data;
+ GError *error = NULL;
+ GMount *mount;
+
+ g_file_mount_enclosing_volume_finish (G_FILE (source_object), res, &error);
+
+ if (error) {
+ if (error->code != G_IO_ERROR_CANCELLED)
+ g_warning ("Mount of %s failed: %s", ms->uri->location, error->message);
+
+ g_error_free (error);
+ if (ms)
+ g_object_unref (ms->mount_op);
+ g_free (ms);
+
+ g_object_unref (source_object);
+
+ return;
+ }
+
+ g_return_if_fail (ms != NULL);
+
+ publish_online (ms->uri, ms->file, NULL);
+
+ g_object_unref (ms->mount_op);
+ g_free (ms);
+
+ mount = g_file_find_enclosing_mount (G_FILE (source_object), NULL, NULL);
+ if (mount)
+ g_mount_unmount (mount, G_MOUNT_UNMOUNT_NONE, NULL, unmount_done_cb, NULL);
+
+ g_object_unref (source_object);
+}
+
+static void
+ask_password (GMountOperation *op, const gchar *message, const gchar *default_user, const gchar *default_domain, GAskPasswordFlags flags, gpointer user_data)
+{
+ struct mnt_struct *ms = (struct mnt_struct *) user_data;
+ gchar *username, *password;
+ gboolean req_pass = FALSE;
+ EUri *euri;
+
+ g_return_if_fail (ms != NULL);
+
+ /* we can ask only for a password */
+ if ((flags & G_ASK_PASSWORD_NEED_PASSWORD) == 0)
+ return;
+
+ euri = e_uri_new (ms->uri->location);
+ username = euri->user;
+ password = e_passwords_get_password ("Calendar", ms->uri->location);
+ req_pass = ((username && *username) && !(ms->uri->service_type == TYPE_ANON_FTP &&
+ !strcmp (username, "anonymous"))) ? TRUE:FALSE;
+
+ if (!password && req_pass) {
+ gboolean remember = FALSE;
+
+ password = e_passwords_ask_password (_("Enter password"), "", ms->uri->location, message,
+ E_PASSWORDS_REMEMBER_FOREVER|E_PASSWORDS_SECRET|E_PASSWORDS_ONLINE,
+ &remember,
+ NULL);
+
+ if (!password) {
+ /* user canceled password dialog */
+ g_mount_operation_reply (op, G_MOUNT_OPERATION_ABORTED);
+ e_uri_free (euri);
+
+ return;
+ }
+ }
+
+ if (!req_pass)
+ g_mount_operation_set_anonymous (op, TRUE);
+ else {
+ g_mount_operation_set_anonymous (op, FALSE);
+ g_mount_operation_set_username (op, username);
+ g_mount_operation_set_password (op, password);
+ }
+
+ g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED);
+
+ e_uri_free (euri);
+}
+
+static void
+ask_question (GMountOperation *op, const char *message, const char *choices[])
+{
+ /* this has been stolen from file-chooser */
+ GtkWidget *dialog;
+ int cnt, len;
+ char *primary;
+ const char *secondary = NULL;
+ int res;
+
+ primary = strstr (message, "\n");
+ if (primary) {
+ secondary = primary + 1;
+ primary = g_strndup (message, strlen (message) - strlen (primary));
+ }
+
+ gdk_threads_enter ();
+ dialog = gtk_message_dialog_new (NULL,
+ 0, GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE, "%s", primary);
+ g_free (primary);
+
+ if (secondary) {
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", secondary);
+ }
+
+ if (choices) {
+ /* First count the items in the list then
+ * add the buttons in reverse order */
+ for (len = 0; choices[len] != NULL; len++) {
+ ;
+ }
+
+ for (cnt = len - 1; cnt >= 0; cnt--) {
+ gtk_dialog_add_button (GTK_DIALOG (dialog), choices[cnt], cnt);
+ }
+ }
+
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (res >= 0) {
+ g_mount_operation_set_choice (op, res);
+ g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED);
+ } else {
+ g_mount_operation_reply (op, G_MOUNT_OPERATION_ABORTED);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ gdk_threads_leave ();
+}
+
+static void
+mount_first (EPublishUri *uri, GFile *file)
+{
+ struct mnt_struct *ms = g_malloc (sizeof (struct mnt_struct));
+
+ ms->uri = uri;
+ ms->file = g_object_ref (file);
+ ms->mount_op = g_mount_operation_new ();
+
+ g_signal_connect (ms->mount_op, "ask-password", G_CALLBACK (ask_password), ms);
+ g_signal_connect (ms->mount_op, "ask-question", G_CALLBACK (ask_question), ms);
+
+ g_file_mount_enclosing_volume (file, G_MOUNT_MOUNT_NONE, ms->mount_op, NULL, mount_ready_cb, ms);
+}
+
+static void
publish (EPublishUri *uri)
{
if (online) {
- GnomeVFSURI *vfs_uri = NULL;
- GnomeVFSResult result;
- GnomeVFSHandle *handle;
- gchar *password;
- const char *username;
- gboolean req_pass = FALSE;
+ GError *error = NULL;
+ GFile *file;
if (g_slist_find (queued_publishes, uri))
queued_publishes = g_slist_remove (queued_publishes, uri);
@@ -79,60 +293,25 @@ publish (EPublishUri *uri)
if (!uri->enabled)
return;
- vfs_uri = gnome_vfs_uri_new (uri->location);
+ file = g_file_new_for_uri (uri->location);
- password = e_passwords_get_password ("Calendar", uri->location);
- username = gnome_vfs_uri_get_user_name (vfs_uri);
- req_pass = ((username && *username) && !(uri->service_type == TYPE_ANON_FTP &&
- !strcmp (username, "anonymous"))) ? TRUE:FALSE;
+ g_return_if_fail (file != NULL);
- if (!password && req_pass) {
- gboolean remember = FALSE;
- char *prompt = g_strdup_printf (_("Enter the password for `%s'"), uri->location);
+ publish_online (uri, file, &error);
- password = e_passwords_ask_password (_("Enter password"), "", uri->location, prompt,
- E_PASSWORDS_REMEMBER_FOREVER|E_PASSWORDS_SECRET|E_PASSWORDS_ONLINE,
- &remember,
- NULL);
- g_free (prompt);
- }
-
- gnome_vfs_uri_set_password (vfs_uri, password);
-
- if (vfs_uri == NULL) {
- fprintf (stderr, "Couldn't create uri %s\n", uri->location);
- /* FIXME: EError */
- g_free (password);
- return;
- }
+ if (error && error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_MOUNTED) {
+ g_error_free (error);
+ error = NULL;
- result = gnome_vfs_create_uri (&handle, vfs_uri, GNOME_VFS_OPEN_WRITE, FALSE, 0666);
- if (result != GNOME_VFS_OK) {
- /* FIXME: EError */
- fprintf (stderr, "Couldn't open %s: %s\n", uri->location, gnome_vfs_result_to_string (result));
- g_free (password);
- return;
+ mount_first (uri, file);
}
- switch (uri->publish_format) {
- case URI_PUBLISH_AS_ICAL:
- publish_calendar_as_ical (handle, uri);
- break;
- case URI_PUBLISH_AS_FB:
- publish_calendar_as_fb (handle, uri);
- break;
-/*
- case URI_PUBLISH_AS_HTML:
- publish_calendar_as_html (handle, uri);
- break;
-*/
+ if (error) {
+ g_warning ("Couldn't open %s: %s", uri->location, error->message);
+ g_error_free (error);
}
- update_timestamp (uri);
-
- result = gnome_vfs_close (handle);
- gnome_vfs_uri_unref (vfs_uri);
- g_free (password);
+ g_object_unref (file);
} else {
if (g_slist_find (queued_publishes, uri) == NULL)
queued_publishes = g_slist_prepend (queued_publishes, uri);
diff --git a/plugins/publish-calendar/publish-format-fb.c b/plugins/publish-calendar/publish-format-fb.c
index 7a4eae3b65..711b68cea7 100644
--- a/plugins/publish-calendar/publish-format-fb.c
+++ b/plugins/publish-calendar/publish-format-fb.c
@@ -22,7 +22,6 @@
#include <string.h>
#include <time.h>
#include <gconf/gconf-client.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libedataserver/e-source.h>
#include <libedataserver/e-source-list.h>
#include <libecal/e-cal.h>
@@ -32,7 +31,7 @@
#include "publish-format-fb.h"
static gboolean
-write_calendar (gchar *uid, ESourceList *source_list, GnomeVFSHandle *handle)
+write_calendar (gchar *uid, ESourceList *source_list, GOutputStream *stream)
{
ESource *source;
ECal *client = NULL;
@@ -43,6 +42,7 @@ write_calendar (gchar *uid, ESourceList *source_list, GnomeVFSHandle *handle)
icalcomponent *top_level;
char *email = NULL;
GList *users = NULL;
+ gboolean res = FALSE;
utc = icaltimezone_get_utc_timezone ();
start = time_day_begin_with_zone (start, utc);
@@ -57,9 +57,11 @@ write_calendar (gchar *uid, ESourceList *source_list, GnomeVFSHandle *handle)
}
if (!e_cal_open (client, TRUE, &error)) {
- /* FIXME: EError */
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
g_object_unref (client);
- g_error_free (error);
return FALSE;
}
@@ -73,8 +75,6 @@ write_calendar (gchar *uid, ESourceList *source_list, GnomeVFSHandle *handle)
if (e_cal_get_free_busy (client, users, start, end, &objects, &error)) {
char *ical_string;
- GnomeVFSFileSize bytes_written;
- GnomeVFSResult result;
while (objects) {
ECalComponent *comp = objects->data;
@@ -84,33 +84,27 @@ write_calendar (gchar *uid, ESourceList *source_list, GnomeVFSHandle *handle)
}
ical_string = icalcomponent_as_ical_string (top_level);
- if ((result = gnome_vfs_write (handle, (gconstpointer) ical_string, strlen (ical_string), &bytes_written)) != GNOME_VFS_OK) {
- /* FIXME: EError */
- gnome_vfs_close (handle);
- return FALSE;
- }
- } else {
- /* FIXME: EError */
- g_object_unref (client);
- g_error_free (error);
- if (users)
- g_list_free (users);
- g_free (email);
+ res = g_output_stream_write_all (stream, ical_string, strlen (ical_string), NULL, NULL, &error);
- return FALSE;
+ g_free (ical_string);
}
if (users)
g_list_free (users);
g_free (email);
-
g_object_unref (client);
- return TRUE;
+
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ return res;
}
void
-publish_calendar_as_fb (GnomeVFSHandle *handle, EPublishUri *uri)
+publish_calendar_as_fb (GOutputStream *stream, EPublishUri *uri)
{
GSList *l;
ESourceList *source_list;
@@ -123,7 +117,8 @@ publish_calendar_as_fb (GnomeVFSHandle *handle, EPublishUri *uri)
l = uri->events;
while (l) {
gchar *uid = l->data;
- write_calendar (uid, source_list, handle);
+ if (!write_calendar (uid, source_list, stream))
+ break;
l = g_slist_next (l);
}
g_object_unref (source_list);
diff --git a/plugins/publish-calendar/publish-format-fb.h b/plugins/publish-calendar/publish-format-fb.h
index c6af2a886e..69be11394e 100644
--- a/plugins/publish-calendar/publish-format-fb.h
+++ b/plugins/publish-calendar/publish-format-fb.h
@@ -19,12 +19,12 @@
*
*/
-#include <libgnomevfs/gnome-vfs.h>
+#include <gio/gio.h>
#include "publish-location.h"
#ifndef PUBLISH_FORMAT_FB_H
#define PUBLISH_FORMAT_FB_H
-void publish_calendar_as_fb (GnomeVFSHandle *handle, EPublishUri *uri);
+void publish_calendar_as_fb (GOutputStream *stream, EPublishUri *uri);
#endif
diff --git a/plugins/publish-calendar/publish-format-ical.c b/plugins/publish-calendar/publish-format-ical.c
index 5f620accc9..b1f160d98e 100644
--- a/plugins/publish-calendar/publish-format-ical.c
+++ b/plugins/publish-calendar/publish-format-ical.c
@@ -21,7 +21,6 @@
#include <string.h>
#include <gconf/gconf-client.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libedataserver/e-source.h>
#include <libedataserver/e-source-list.h>
#include <libecal/e-cal.h>
@@ -65,13 +64,14 @@ append_tz_to_comp (gpointer key, gpointer value, icalcomponent *toplevel)
}
static gboolean
-write_calendar (gchar *uid, ESourceList *source_list, GnomeVFSHandle *handle)
+write_calendar (gchar *uid, ESourceList *source_list, GOutputStream *stream)
{
ESource *source;
ECal *client = NULL;
GError *error = NULL;
GList *objects;
icalcomponent *top_level;
+ gboolean res = FALSE;
source = e_source_list_peek_source_by_uid (source_list, uid);
if (source)
@@ -82,9 +82,11 @@ write_calendar (gchar *uid, ESourceList *source_list, GnomeVFSHandle *handle)
}
if (!e_cal_open (client, TRUE, &error)) {
- /* FIXME: EError */
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
g_object_unref (client);
- g_error_free (error);
return FALSE;
}
@@ -93,8 +95,6 @@ write_calendar (gchar *uid, ESourceList *source_list, GnomeVFSHandle *handle)
if (e_cal_get_object_list (client, "#t", &objects, &error)) {
char *ical_string;
- GnomeVFSFileSize bytes_written = 0;
- GnomeVFSResult result;
CompTzData tdata;
tdata.zones = g_hash_table_new (g_str_hash, g_str_equal);
@@ -113,24 +113,22 @@ write_calendar (gchar *uid, ESourceList *source_list, GnomeVFSHandle *handle)
tdata.zones = NULL;
ical_string = icalcomponent_as_ical_string (top_level);
- if ((result = gnome_vfs_write (handle, (gconstpointer) ical_string, strlen (ical_string), &bytes_written)) != GNOME_VFS_OK) {
- /* FIXME: EError */
- gnome_vfs_close (handle);
- return FALSE;
- }
- } else {
- /* FIXME: EError */
- g_object_unref (client);
- g_error_free (error);
- return FALSE;
+ res = g_output_stream_write_all (stream, ical_string, strlen (ical_string), NULL, NULL, &error);
+ g_free (ical_string);
}
g_object_unref (client);
- return TRUE;
+
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ return res;
}
void
-publish_calendar_as_ical (GnomeVFSHandle *handle, EPublishUri *uri)
+publish_calendar_as_ical (GOutputStream *stream, EPublishUri *uri)
{
GSList *l;
ESourceList *source_list;
@@ -143,7 +141,8 @@ publish_calendar_as_ical (GnomeVFSHandle *handle, EPublishUri *uri)
l = uri->events;
while (l) {
gchar *uid = l->data;
- write_calendar (uid, source_list, handle);
+ if (!write_calendar (uid, source_list, stream))
+ break;
l = g_slist_next (l);
}
g_object_unref (source_list);
diff --git a/plugins/publish-calendar/publish-format-ical.h b/plugins/publish-calendar/publish-format-ical.h
index 35040d110a..ae76bc076f 100644
--- a/plugins/publish-calendar/publish-format-ical.h
+++ b/plugins/publish-calendar/publish-format-ical.h
@@ -19,12 +19,12 @@
*
*/
-#include <libgnomevfs/gnome-vfs.h>
+#include <gio/gio.h>
#include "publish-location.h"
#ifndef PUBLISH_FORMAT_ICAL_H
#define PUBLISH_FORMAT_ICAL_H
-void publish_calendar_as_ical (GnomeVFSHandle *handle, EPublishUri *uri);
+void publish_calendar_as_ical (GOutputStream *stream, EPublishUri *uri);
#endif
diff --git a/plugins/publish-calendar/publish-location.c b/plugins/publish-calendar/publish-location.c
index e4414a8109..34793bf932 100644
--- a/plugins/publish-calendar/publish-location.c
+++ b/plugins/publish-calendar/publish-location.c
@@ -24,7 +24,7 @@
#include "publish-location.h"
#include <libxml/tree.h>
#include <gconf/gconf-client.h>
-#include <libgnomevfs/gnome-vfs.h>
+#include <libedataserver/e-url.h>
#include <libedataserverui/e-passwords.h>
#include <string.h>
@@ -36,8 +36,8 @@ migrateURI (const gchar *xml, xmlDocPtr doc)
xmlChar *location, *enabled, *frequency, *username;
xmlNodePtr root, p;
EPublishUri *uri;
- GnomeVFSURI *vfs_uri;
gchar *password, *temp;
+ EUri *euri;
client = gconf_client_get_default ();
uris = gconf_client_get_list (client, "/apps/evolution/calendar/publish/uris", GCONF_VALUE_STRING, NULL);
@@ -59,18 +59,22 @@ migrateURI (const gchar *xml, xmlDocPtr doc)
frequency = xmlGetProp (root, (const unsigned char *)"frequency");
username = xmlGetProp (root, (const unsigned char *)"username");
- vfs_uri = gnome_vfs_uri_new ((char *)location);
+ euri = e_uri_new ((const char *)location);
- if (!vfs_uri) {
+ if (!euri) {
g_warning ("Could not form the uri for %s \n", location);
goto cleanup;
}
- gnome_vfs_uri_set_user_name ((GnomeVFSURI *)vfs_uri, (char *)username);
- temp = gnome_vfs_uri_to_string (vfs_uri, GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD | GNOME_VFS_URI_HIDE_PASSWORD);
- uri->location = g_strdup_printf ("dav://%s", temp);
+ if (euri->user)
+ g_free (euri->user);
+
+ euri->user = g_strdup ((const char *)username);
+
+ temp = e_uri_to_string (euri, FALSE);
+ uri->location = g_strdup_printf ("dav://%s", strstr (temp, "//") + 2);
g_free (temp);
- gnome_vfs_uri_unref (vfs_uri);
+ e_uri_free (euri);
if (enabled != NULL)
uri->enabled = atoi ((char *)enabled);
diff --git a/plugins/publish-calendar/url-editor-dialog.c b/plugins/publish-calendar/url-editor-dialog.c
index 627c64fa87..f818cabb67 100644
--- a/plugins/publish-calendar/url-editor-dialog.c
+++ b/plugins/publish-calendar/url-editor-dialog.c
@@ -23,7 +23,7 @@
#include "url-editor-dialog.h"
#include <libedataserverui/e-passwords.h>
#include <libedataserver/e-url.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <glib.h>
#include <string.h>
#include <e-util/e-util-private.h>
@@ -46,7 +46,7 @@ create_uri (UrlEditorDialog *dialog)
server = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->server_entry)));
file = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->file_entry)));
port = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->port_entry)));
- username = gnome_vfs_escape_string (gtk_entry_get_text (GTK_ENTRY (dialog->username_entry)));
+ username = g_uri_escape_string (gtk_entry_get_text (GTK_ENTRY (dialog->username_entry)), "", FALSE);
password = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->password_entry)));
switch (uri->service_type) {