aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog7
-rw-r--r--addressbook/gui/widgets/eab-gui-util.c19
-rw-r--r--calendar/ChangeLog15
-rw-r--r--calendar/gui/dialogs/cal-attachment-select-file.c3
-rw-r--r--calendar/gui/dialogs/comp-editor.c26
-rw-r--r--calendar/gui/e-cal-popup.c4
-rw-r--r--calendar/gui/e-calendar-table.c13
-rw-r--r--calendar/gui/e-calendar-view.c15
-rw-r--r--calendar/gui/e-memo-table.c14
-rw-r--r--composer/ChangeLog8
-rw-r--r--composer/e-msg-composer-select-file.c16
-rw-r--r--composer/e-msg-composer.c15
-rw-r--r--e-util/ChangeLog9
-rw-r--r--e-util/e-dialog-utils.c12
-rw-r--r--e-util/e-util.c30
-rw-r--r--e-util/e-util.h2
-rw-r--r--mail/ChangeLog10
-rw-r--r--mail/em-utils.c30
-rw-r--r--mail/mail-ops.c14
19 files changed, 191 insertions, 71 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 2d43ef7eca..9d7dbe434f 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,10 @@
+2006-05-25 Srinivasa Ragavan <sragavan@novell.com>
+
+ ** Added code to save vcards/addressbooks to remote shares
+
+ * gui/widgets/eab-gui-util.c: (save_it), (eab_contact_save),
+ (eab_contact_list_save):
+
2006-05-17 Roozbeh Pournader <roozbeh@farsiweb.info>
Fix for gnome bug #341931, farsiweb #562
diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c
index 835a366467..62ca632acd 100644
--- a/addressbook/gui/widgets/eab-gui-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -340,28 +340,30 @@ static void
save_it(GtkWidget *widget, SaveAsInfo *info)
{
const char *filename;
+ char *uri;
gint error = 0;
gint response = 0;
#ifdef USE_GTKFILECHOOSER
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (info->filesel));
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (info->filesel));
#else
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (info->filesel));
#endif
-
- error = e_write_file (filename, info->vcard, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC);
-
- if (error == EEXIST) {
+
+ if (filename && g_file_test (filename, G_FILE_TEST_EXISTS)) {
response = file_exists(GTK_WINDOW (info->filesel), filename);
switch (response) {
case GTK_RESPONSE_ACCEPT : /* Overwrite */
- e_write_file(filename, info->vcard, O_WRONLY | O_CREAT | O_TRUNC);
break;
case GTK_RESPONSE_CANCEL : /* cancel */
return;
}
- } else if (error != 0) {
+ }
+
+ error = e_write_file_uri (uri, info->vcard);
+ if (error != 0) {
char *err_str_ext;
if (info->has_multiple_contacts) {
/* more than one, finding the total number of contacts might
@@ -379,9 +381,10 @@ save_it(GtkWidget *widget, SaveAsInfo *info)
*/
e_error_run (GTK_WINDOW (info->filesel), "addressbook:save-error",
err_str_ext, filename, g_strerror (errno));
+ gtk_widget_destroy(GTK_WIDGET(info->filesel));
return;
}
-
+
gtk_widget_destroy(GTK_WIDGET(info->filesel));
}
@@ -522,6 +525,7 @@ eab_contact_save (char *title, EContact *contact, GtkWindow *parent_window)
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filesel), g_get_home_dir ());
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filesel), file);
+ gtk_file_chooser_set_local_only (filesel, FALSE);
info->filesel = filesel;
info->vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
@@ -574,6 +578,7 @@ eab_contact_list_save (char *title, GList *list, GtkWindow *parent_window)
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_ACCEPT);
+ gtk_file_chooser_set_local_only (filesel, FALSE);
#else
filesel = gtk_file_selection_new(title);
#endif
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index b33abcea6b..4a1cfe64d5 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,18 @@
+2006-05-25 Srinivasa Ragavan <sragavan@novell.com>
+
+ ** Added support to save calendar/events/attachments to remote
+ shares in Calenda/Memo/Tasks components.
+
+ * gui/dialogs/cal-attachment-select-file.c: (run_selector),
+ (comp_editor_select_file_attachments):
+ * gui/dialogs/comp-editor.c: (drop_action), (cab_add),
+ (menu_insert_attachment_cb):
+ * gui/e-cal-popup.c: (temp_save_part):
+ * gui/e-calendar-table.c: (e_calendar_table_on_save_as):
+ * gui/e-calendar-view.c: (on_save_as),
+ (e_calendar_view_get_tooltips):
+ * gui/e-memo-table.c: (e_memo_table_on_save_as):
+
2006-05-23 Srinivasa Ragavan <sragavan@novell.com>
More alarm fixes
diff --git a/calendar/gui/dialogs/cal-attachment-select-file.c b/calendar/gui/dialogs/cal-attachment-select-file.c
index 2b7fb4fdae..79e4a75a77 100644
--- a/calendar/gui/dialogs/cal-attachment-select-file.c
+++ b/calendar/gui/dialogs/cal-attachment-select-file.c
@@ -82,6 +82,7 @@ run_selector(CompEditor *editor, const char *title, guint32 flags, gboolean *sho
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (selection), GTK_RESPONSE_OK);
+ gtk_file_chooser_set_local_only (selection, FALSE);
if ((flags & SELECTOR_MODE_SAVE) == 0)
gtk_file_chooser_set_select_multiple ((GtkFileChooser *) selection, (flags & SELECTOR_MODE_MULTI));
@@ -193,7 +194,7 @@ comp_editor_select_file_attachments (CompEditor *editor, gboolean *showinline_p)
#ifdef USE_GTKFILECHOOSER
GSList *l, *n;
- if ((l = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (selection)))) {
+ if ((l = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (selection)))) {
list = g_ptr_array_new ();
while (l) {
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 5aa39dae90..d024eb7213 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -295,7 +295,7 @@ drop_action(CompEditor *editor, GdkDragContext *context, guint32 action, GtkSele
else
e_attachment_bar_attach_remote_file
(E_ATTACHMENT_BAR (editor->priv->attachment_bar),
- str);
+ str, "attachment");
camel_url_free (url);
g_free (str);
@@ -1060,8 +1060,18 @@ cab_add(EPopup *ep, EPopupItem *item, void *data)
if (!file_list)
return;
for (i = 0; i < file_list->len; i++) {
- e_attachment_bar_attach (bar, file_list->pdata[i], is_inline ? "inline" : "attachment");
+ CamelURL *url;
+
+ url = camel_url_new (file_list->pdata[i], NULL);
+ if (url == NULL)
+ continue;
+
+ if (!g_ascii_strcasecmp (url->protocol, "file"))
+ e_attachment_bar_attach (bar, url->path, is_inline ? "inline" : "attachment");
+ else
+ e_attachment_bar_attach_remote_file (bar, file_list->pdata[i], is_inline ? "inline" : "attachment");
g_free (file_list->pdata[i]);
+ camel_url_free (url);
}
g_ptr_array_free (file_list, TRUE);
@@ -1355,8 +1365,18 @@ menu_insert_attachment_cb (BonoboUIComponent *uic,
if (!file_list)
return;
for (i = 0; i < file_list->len; i++) {
- e_attachment_bar_attach (bar, file_list->pdata[i], is_inline ? "inline" : "attachment");
+ CamelURL *url;
+
+ url = camel_url_new (file_list->pdata[i], NULL);
+ if (url == NULL)
+ continue;
+
+ if (!g_ascii_strcasecmp (url->protocol, "file"))
+ e_attachment_bar_attach (bar, url->path, is_inline ? "inline" : "attachment");
+ else
+ e_attachment_bar_attach_remote_file (bar, file_list->pdata[i], is_inline ? "inline" : "attachment");
g_free (file_list->pdata[i]);
+ camel_url_free (url);
}
g_ptr_array_free (file_list, TRUE);
diff --git a/calendar/gui/e-cal-popup.c b/calendar/gui/e-cal-popup.c
index 7e1d1ca040..32967f04b5 100644
--- a/calendar/gui/e-cal-popup.c
+++ b/calendar/gui/e-cal-popup.c
@@ -37,7 +37,7 @@
#include <libedataserverui/e-source-selector.h>
#include <camel/camel-mime-part.h>
-#include <camel/camel-stream-fs.h>
+#include <camel/camel-stream-vfs.h>
#include "e-util/e-util.h"
#include "e-util/e-i18n.h"
#include "e-util/e-mktemp.h"
@@ -135,7 +135,7 @@ temp_save_part(CamelMimePart *part, char *path, gboolean file)
}
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
- stream = camel_stream_fs_new_with_name (path, O_RDWR|O_CREAT|O_TRUNC, 0600);
+ stream = camel_stream_vfs_new_with_uri (path, O_WRONLY|O_CREAT|O_TRUNC, 0600);
if (!stream) {
/* TODO handle error conditions */
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c
index 259238bb42..955ee0fb58 100644
--- a/calendar/gui/e-calendar-table.c
+++ b/calendar/gui/e-calendar-table.c
@@ -1097,8 +1097,7 @@ e_calendar_table_on_save_as (EPopup *ep, EPopupItem *pitem, void *data)
ECalModelComponent *comp_data;
char *filename;
char *ical_string;
- FILE *file;
-
+
comp_data = e_calendar_table_get_selected_comp (cal_table);
if (comp_data == NULL)
return;
@@ -1112,16 +1111,10 @@ e_calendar_table_on_save_as (EPopup *ep, EPopupItem *pitem, void *data)
g_warning ("Couldn't convert item to a string");
return;
}
+
+ e_write_file_uri (filename, ical_string);
- file = g_fopen (filename, "w");
- if (file == NULL) {
- g_warning ("Couldn't save item");
- return;
- }
-
- fprintf (file, "%s", ical_string);
g_free (ical_string);
- fclose (file);
}
static void
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index ac2eb66556..c8408c647c 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -1239,9 +1239,8 @@ on_save_as (EPopup *ep, EPopupItem *pitem, void *data)
GList *selected;
char *filename;
char *ical_string;
- FILE *file;
ECalendarViewEvent *event;
-
+
selected = e_calendar_view_get_selected_events (cal_view);
if (!selected)
return;
@@ -1256,16 +1255,9 @@ on_save_as (EPopup *ep, EPopupItem *pitem, void *data)
g_warning ("Couldn't convert item to a string");
return;
}
-
- file = g_fopen (filename, "w");
- if (file == NULL) {
- g_warning ("Couldn't save item");
- return;
- }
-
- fprintf (file, "%s", ical_string);
+
+ e_write_file_uri (filename, ical_string);
g_free (ical_string);
- fclose (file);
g_list_free (selected);
}
@@ -2138,6 +2130,7 @@ e_calendar_view_get_tooltips (ECalendarViewEventData *data)
default_zone = e_calendar_view_get_timezone (data->cal_view);
pevent = data->get_view_event (data->cal_view, data->day, data->event_num);
+
client = pevent->comp_data->client;
clone_comp = icalcomponent_new_clone (pevent->comp_data->icalcomp);
diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c
index b63cde43d2..84ac373017 100644
--- a/calendar/gui/e-memo-table.c
+++ b/calendar/gui/e-memo-table.c
@@ -733,8 +733,7 @@ e_memo_table_on_save_as (EPopup *ep, EPopupItem *pitem, void *data)
ECalModelComponent *comp_data;
char *filename;
char *ical_string;
- FILE *file;
-
+
comp_data = get_selected_comp (memo_table);
if (comp_data == NULL)
return;
@@ -748,16 +747,9 @@ e_memo_table_on_save_as (EPopup *ep, EPopupItem *pitem, void *data)
g_warning ("Couldn't convert item to a string");
return;
}
-
- file = g_fopen (filename, "w");
- if (file == NULL) {
- g_warning ("Couldn't save item");
- return;
- }
-
- fprintf (file, ical_string);
+
+ e_write_file_uri (filename, ical_string);
g_free (ical_string);
- fclose (file);
}
static void
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 16c04468f2..a78ee2da77 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,11 @@
+2006-05-25 Srinivasa Ragavan <sragavan@novell.com>
+
+ Added support to attach from remote shares
+
+ * e-msg-composer-select-file.c: (get_selector),
+ (select_attach_response):
+ * e-msg-composer.c: (add_to_bar), (drop_action):
+
2006-03-09 Sam Yang <sam.yang@sun.com>
** Fixes #333971
diff --git a/composer/e-msg-composer-select-file.c b/composer/e-msg-composer-select-file.c
index 97b686ef7e..430bcb003a 100644
--- a/composer/e-msg-composer-select-file.c
+++ b/composer/e-msg-composer-select-file.c
@@ -83,6 +83,7 @@ get_selector(struct _EMsgComposer *composer, const char *title, guint32 flags)
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (selection), GTK_RESPONSE_OK);
+ gtk_file_chooser_set_local_only (selection, FALSE);
if ((flags & SELECTOR_MODE_SAVE) == 0)
gtk_file_chooser_set_select_multiple ((GtkFileChooser *) selection, (flags & SELECTOR_MODE_MULTI));
@@ -192,14 +193,16 @@ select_attach_response(GtkWidget *selector, guint response, struct _EMsgComposer
GSList *names;
EMsgComposerSelectAttachFunc func = g_object_get_data((GObject *)selector, "callback");
GtkToggleButton *showinline = g_object_get_data((GObject *)selector, "show-inline");
- char *path;
+ char *path = NULL;
#ifdef USE_GTKFILECHOOSER
- char *filename;
- names = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (selector));
+ char *filename = NULL;
+ names = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (selector));
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selector));
- path = g_path_get_dirname (filename);
- g_free (filename);
+ if (!filename) {
+ path = g_path_get_dirname (filename);
+ g_free (filename);
+ }
#else
char **files;
int i;
@@ -215,7 +218,8 @@ select_attach_response(GtkWidget *selector, guint response, struct _EMsgComposer
path = g_path_get_dirname (gtk_file_selection_get_filename (GTK_FILE_SELECTION (selector)));
#endif
- g_object_set_data_full ((GObject *) composer, "attach_path", path, g_free);
+ if (path)
+ g_object_set_data_full ((GObject *) composer, "attach_path", path, g_free);
func(composer, names, gtk_toggle_button_get_active(showinline));
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index e4bc7dbbde..fe66322c43 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -1782,8 +1782,19 @@ add_to_bar (EMsgComposer *composer, GSList *names, int is_inline)
EMsgComposerPrivate *p = composer->priv;
while (names) {
- e_attachment_bar_attach((EAttachmentBar *)p->attachment_bar, names->data, is_inline ? "inline" : "attachment");
+ CamelURL *url;
+
+ url = camel_url_new (names->data, NULL);
+ if (url == NULL)
+ continue;
+
+ if (!g_ascii_strcasecmp (url->protocol, "file")) {
+ e_attachment_bar_attach((EAttachmentBar *)p->attachment_bar, url->path, is_inline ? "inline" : "attachment");
+ } else {
+ e_attachment_bar_attach_remote_file ((EAttachmentBar *)p->attachment_bar, names->data, is_inline ? "inline" : "attachment");
+ }
names = g_slist_next(names);
+ camel_url_free (url);
}
}
@@ -2969,7 +2980,7 @@ drop_action(EMsgComposer *composer, GdkDragContext *context, guint32 action, Gtk
} else {
e_attachment_bar_attach_remote_file
(E_ATTACHMENT_BAR (p->attachment_bar),
- str);
+ str, "attachment");
}
g_free (str);
camel_url_free (url);
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index c4feb62919..3f7f44ce75 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,12 @@
+2006-05-25 Srinivasa Ragavan <sragavan@novell.com>
+
+ * e-dialog-utils.c: (save_ok), (e_file_dialog_save),
+ (save_folder_ok), (e_file_dialog_save_folder): Added code
+ to enable file chooser to work with remote shares
+ * e-util.c: (e_write_file), (e_write_file_uri): Added
+ a new api to write to remote shares.
+ * e-util.h:
+
2006-04-26 Li Yuan <li.yuan@sun.com>
* e-text-event-processor-emacs-like.c:
diff --git a/e-util/e-dialog-utils.c b/e-util/e-dialog-utils.c
index 63353a723e..44c5c24194 100644
--- a/e-util/e-dialog-utils.c
+++ b/e-util/e-dialog-utils.c
@@ -260,6 +260,7 @@ save_ok (GtkWidget *widget, gpointer data)
{
GtkWidget *fs;
char **filename = data;
+ char *uri;
const char *path;
int btn = GTK_RESPONSE_YES;
GConfClient *gconf = gconf_client_get_default();
@@ -268,6 +269,7 @@ save_ok (GtkWidget *widget, gpointer data)
fs = gtk_widget_get_toplevel (widget);
#ifdef USE_GTKFILECHOOSER
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fs));
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fs));
#else
path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs));
#endif
@@ -291,7 +293,7 @@ save_ok (GtkWidget *widget, gpointer data)
dir = g_path_get_dirname (path);
gconf_client_set_string(gconf, "/apps/evolution/mail/save_dir", dir, NULL);
g_free (dir);
- *filename = g_strdup (path);
+ *filename = uri;
}
g_object_unref(gconf);
@@ -333,7 +335,8 @@ e_file_dialog_save (const char *title, const char *fname)
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (selection), GTK_RESPONSE_ACCEPT);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (selection), dir);
-
+ gtk_file_chooser_set_local_only (selection, FALSE);
+
if (fname)
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER (selection), fname);
@@ -365,19 +368,21 @@ save_folder_ok (GtkWidget *widget, gpointer data)
{
GtkWidget *fs;
char **filename = data;
+ char *uri;
const char *path;
GConfClient *gconf = gconf_client_get_default();
fs = gtk_widget_get_toplevel (widget);
#ifdef USE_GTKFILECHOOSER
path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (fs));
+ uri = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (fs));
#else
path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs));
#endif
gconf_client_set_string(gconf, "/apps/evolution/mail/save_dir", path, NULL);
g_object_unref(gconf);
- *filename = g_strdup (path);
+ *filename = uri;
gtk_main_quit ();
}
@@ -419,6 +424,7 @@ e_file_dialog_save_folder (const char *title)
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (selection), GTK_RESPONSE_ACCEPT);
+ gtk_file_chooser_set_local_only (selection, FALSE);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (selection), dir);
g_signal_connect (G_OBJECT (selection), "response", G_CALLBACK (folderchooser_response), &filename);
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 73a1842919..bfafdc8771 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -39,6 +39,7 @@
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include <libgnome/gnome-util.h>
+#include <libgnomevfs/gnome-vfs.h>
#ifdef G_OS_WIN32
#include <windows.h>
@@ -239,6 +240,35 @@ e_write_file(const char *filename, const char *data, int flags)
}
gint
+e_write_file_uri (const char *filename, const char *data)
+{
+ guint64 length = strlen(data);
+ guint64 bytes;
+ GnomeVFSResult result;
+ GnomeVFSHandle *handle = NULL;
+
+ result = gnome_vfs_create (&handle, filename, GNOME_VFS_OPEN_WRITE, TRUE, 0755);
+ if (result != GNOME_VFS_OK) {
+ g_warning ("Couldn't save item");
+ return 1;
+ }
+
+ while (length > 0) {
+ gnome_vfs_write(handle, data, length, &bytes);
+ if (bytes > 0) {
+ length -= bytes;
+ data += bytes;
+ } else {
+ gnome_vfs_close(handle);
+ return 1;
+ }
+ }
+
+ gnome_vfs_close (handle);
+ return 0;
+}
+
+gint
e_write_file_mkstemp(char *filename, const char *data)
{
int fd;
diff --git a/e-util/e-util.h b/e-util/e-util.h
index b80915f8f0..559a1a1ee7 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -154,6 +154,8 @@ char *e_read_file (cons
int e_write_file (const char *filename,
const char *data,
int flags);
+int e_write_file_uri (const char *filename,
+ const char *data);
int e_write_file_mkstemp (char *filename,
const char *data);
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 53ec958e50..8074c83042 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,15 @@
2006-05-25 Srinivasa Ragavan <sragavan@novell.com>
+ ** Added remote shares save/load support across evolution.
+
+ * em-utils.c: (emu_file_check_local), (emu_get_save_filesel),
+ (emu_save_part_response), (emu_save_parts_response),
+ (emu_save_messages_response): Added code to save messages/attachments
+ to remote shares.
+ * mail-ops.c: (save_messages_save), (save_part_save):
+
+2006-05-25 Srinivasa Ragavan <sragavan@novell.com>
+
** fixes bug #342092
* em-popup.c: (emp_standard_menu_factory): Read the mime
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 76c817aa17..d59d99fc00 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -90,6 +90,23 @@ extern struct _CamelSession *session;
#define d(x)
+static gboolean
+emu_file_check_local (const char *name)
+{
+ CamelURL *url;
+ gboolean local = FALSE;
+
+ url = camel_url_new (name, NULL);
+ if (url == NULL)
+ return TRUE;
+
+ if (!g_ascii_strcasecmp (url->protocol, "file"))
+ local = TRUE;
+
+ camel_url_free (url);
+
+ return local;
+}
/**
* em_utils_prompt_user:
* @parent: parent window
@@ -374,6 +391,7 @@ emu_get_save_filesel (GtkWidget *parent, const char *title, const char *name, Gt
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_OK);
+ gtk_file_chooser_set_local_only (filesel, FALSE);
#else
char *filename;
@@ -454,20 +472,22 @@ static void
emu_save_part_response(GtkWidget *filesel, int response, CamelMimePart *part)
{
const char *path;
+ const char *uri;
if (response == GTK_RESPONSE_OK) {
#ifdef USE_GTKFILECHOOSER
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (filesel));
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filesel));
#else
path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
#endif
-
- if (!emu_can_save((GtkWindow *)filesel, path))
+
+ if (emu_file_check_local(uri) && !emu_can_save((GtkWindow *)filesel, path))
return;
emu_update_save_path(path, FALSE);
/* FIXME: popup error if it fails? */
- mail_save_part(part, path, NULL, NULL, FALSE);
+ mail_save_part(part, uri, NULL, NULL, FALSE);
}
gtk_widget_destroy((GtkWidget *)filesel);
@@ -512,7 +532,7 @@ emu_save_parts_response (GtkWidget *filesel, int response, GSList *parts)
GSList *selected;
if (response == GTK_RESPONSE_OK) {
#ifdef USE_GTKFILECHOOSER
- path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (filesel));
+ path = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (filesel));
#else
path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
#endif
@@ -627,7 +647,7 @@ emu_save_messages_response(GtkWidget *filesel, int response, struct _save_messag
if (response == GTK_RESPONSE_OK) {
#ifdef USE_GTKFILECHOOSER
- path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filesel));
+ path = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (filesel));
#else
path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
#endif
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 23dc550e0a..5c8c97e2fd 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -41,6 +41,7 @@
#include <camel/camel-mime-filter-from.h>
#include <camel/camel-stream-filter.h>
#include <camel/camel-stream-fs.h>
+#include <camel/camel-stream-vfs.h>
#include <camel/camel-mime-filter-charset.h>
#include <camel/camel-offline-folder.h>
#include <camel/camel-offline-store.h>
@@ -1985,14 +1986,7 @@ save_messages_save (struct _mail_msg *mm)
int fd, i;
char *from;
- fd = g_open (m->path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
- if (fd == -1) {
- camel_exception_setv(&mm->ex, CAMEL_EXCEPTION_SYSTEM,
- _("Unable to create output file: %s\n %s"), m->path, strerror(errno));
- return;
- }
-
- stream = camel_stream_fs_new_with_fd(fd);
+ stream = camel_stream_vfs_new_with_uri (m->path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
from_filter = camel_mime_filter_from_new();
filtered_stream = camel_stream_filter_new_with_stream(stream);
camel_stream_filter_add(filtered_stream, (CamelMimeFilter *)from_filter);
@@ -2099,13 +2093,13 @@ save_part_save (struct _mail_msg *mm)
CamelStream *stream;
if(!m->readonly){
- if (!(stream = camel_stream_fs_new_with_name (m->path, O_WRONLY | O_CREAT | O_TRUNC, 0666))) {
+ if (!(stream = camel_stream_vfs_new_with_uri (m->path, O_WRONLY | O_CREAT | O_TRUNC, 0666))) {
camel_exception_setv (&mm->ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot create output file: %s:\n %s"),
m->path, g_strerror (errno));
return;
}
- } else if (!(stream = camel_stream_fs_new_with_name (m->path, O_WRONLY | O_CREAT | O_TRUNC, 0444))) {
+ } else if (!(stream = camel_stream_vfs_new_with_uri (m->path, O_WRONLY | O_CREAT | O_TRUNC, 0444))) {
camel_exception_setv (&mm->ex, CAMEL_EXCEPTION_SYSTEM,
_("Cannot create output file: %s:\n %s"),
m->path, g_strerror (errno));