aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/ChangeLog10
-rw-r--r--widgets/misc/e-attachment-bar.c10
-rw-r--r--widgets/misc/e-attachment.c25
-rw-r--r--widgets/misc/e-attachment.h4
4 files changed, 41 insertions, 8 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index 305c682578..4bc064f4f8 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,5 +1,15 @@
2007-09-26 Milan Crha <mcrha@redhat.com>
+ ** Fix for bug #423401
+
+ * e-attachment.h: (e_attachment_new_remote_file):
+ * e-attachment.c: (struct DownloadInfo), (async_progress_update_cb),
+ (e_attachment_new_remote_file):
+ * e-attachment-bar.c: (e_attachment_bar_attach_remote_file):
+ Better error handling when attaching remote file.
+
+2007-09-26 Milan Crha <mcrha@redhat.com>
+
** Fix for bug #351333
* e-search-bar.c: (paint_search_text), (option_activated_cb):
diff --git a/widgets/misc/e-attachment-bar.c b/widgets/misc/e-attachment-bar.c
index 221558f937..0525887cc4 100644
--- a/widgets/misc/e-attachment-bar.c
+++ b/widgets/misc/e-attachment-bar.c
@@ -1203,19 +1203,21 @@ e_attachment_bar_attach_remote_file (EAttachmentBar *bar, const char *url, const
{
EAttachment *attachment;
CamelException ex;
+ GtkWindow *parent;
g_return_if_fail (E_IS_ATTACHMENT_BAR (bar));
if (!bar->priv->path)
bar->priv->path = e_mkdtemp ("attach-XXXXXX");
-
+
+ parent = (GtkWindow *) gtk_widget_get_toplevel ((GtkWidget *) bar);
camel_exception_init (&ex);
- if ((attachment = e_attachment_new_remote_file (url, disposition, bar->priv->path, &ex))) {
+ if ((attachment = e_attachment_new_remote_file (parent, url, disposition, bar->priv->path, &ex))) {
add_common (bar, attachment);
g_signal_connect (attachment, "update", G_CALLBACK (update_remote_file), bar);
} else {
- e_error_run ((GtkWindow *) gtk_widget_get_toplevel ((GtkWidget *) bar), "mail-composer:no-attach",
- attachment->file_name, camel_exception_get_description (&ex), NULL);
+ e_error_run (parent, "mail-composer:no-attach",
+ url, camel_exception_get_description (&ex), NULL);
camel_exception_clear (&ex);
}
}
diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c
index a69be8842d..14dad294f9 100644
--- a/widgets/misc/e-attachment.c
+++ b/widgets/misc/e-attachment.c
@@ -54,6 +54,7 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
+#include "e-util/e-error.h"
#include "e-util/e-mktemp.h"
#include "e-util/e-util-private.h"
@@ -316,6 +317,8 @@ e_attachment_new (const char *file_name, const char *disposition, CamelException
typedef struct DownloadInfo {
EAttachment *attachment;
char *file_name;
+ char *uri;
+ GtkWindow *parent; /* for error dialog */
} DownloadInfo;
static int
@@ -336,23 +339,37 @@ async_progress_update_cb (GnomeVFSAsyncHandle *handle,
if (info->phase == GNOME_VFS_XFER_PHASE_COMPLETED) {
CamelException ex;
- if (!info->file_size)
- goto error;
+ if (!info->file_size) {
+ if (info->vfs_status == GNOME_VFS_OK)
+ info->vfs_status = GNOME_VFS_ERROR_EOF;
+ goto error_msg;
+ }
download_info->attachment->handle = NULL;
camel_exception_init (&ex);
e_attachment_build_remote_file (download_info->file_name, download_info->attachment, "attachment", &ex);
+ if (camel_exception_is_set (&ex)) {
+ e_error_run (download_info->parent, "mail-composer:no-attach",
+ download_info->uri, camel_exception_get_description (&ex), NULL);
+ camel_exception_clear (&ex);
+ goto error;
+ }
download_info->attachment->percentage = -1;
download_info->attachment->is_available_local = TRUE;
g_signal_emit (download_info->attachment, signals[UPDATE], 0);
g_free (download_info->file_name);
+ g_free (download_info->uri);
g_free (download_info);
}
return TRUE;
case GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR:
+ error_msg:
+ e_error_run (download_info->parent, "mail-composer:no-attach",
+ download_info->uri, gnome_vfs_result_to_string (info->vfs_status), NULL);
error:
g_object_unref (download_info->attachment);
g_free (download_info->file_name);
+ g_free (download_info->uri);
g_free (download_info);
return FALSE;
default:
@@ -387,7 +404,7 @@ download_to_local_path (GnomeVFSURI *source_uri, GnomeVFSURI *target_uri, Downlo
}
EAttachment *
-e_attachment_new_remote_file (const char *uri, const char *disposition, const char *path, CamelException *ex)
+e_attachment_new_remote_file (GtkWindow *error_dlg_parent, const char *uri, const char *disposition, const char *path, CamelException *ex)
{
EAttachment *new;
DownloadInfo *download_info;
@@ -415,6 +432,8 @@ e_attachment_new_remote_file (const char *uri, const char *disposition, const ch
download_info = g_new (DownloadInfo, 1);
download_info->attachment = new;
download_info->file_name = g_strdup (new->file_name);
+ download_info->uri = g_strdup (uri);
+ download_info->parent = error_dlg_parent;
download_to_local_path (gnome_vfs_uri_new (uri), gnome_vfs_uri_new (new->file_name), download_info);
return new;
diff --git a/widgets/misc/e-attachment.h b/widgets/misc/e-attachment.h
index 53cdd80f6f..478dc07d22 100644
--- a/widgets/misc/e-attachment.h
+++ b/widgets/misc/e-attachment.h
@@ -26,6 +26,7 @@
#define __E_ATTACHMENT_H__
#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gtk/gtkwindow.h>
#include <glade/glade-xml.h>
#include <camel/camel-mime-part.h>
#include <camel/camel-exception.h>
@@ -83,7 +84,8 @@ GType e_attachment_get_type (void);
EAttachment *e_attachment_new (const char *file_name,
const char *disposition,
CamelException *ex);
-EAttachment * e_attachment_new_remote_file (const char *url,
+EAttachment * e_attachment_new_remote_file (GtkWindow *error_dlg_parent,
+ const char *url,
const char *disposition,
const char *path,
CamelException *ex);