diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-10-10 08:10:02 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-10-10 08:10:02 +0800 |
commit | 45a3bf8c4557eea71a77afd8a6efcc01416ecdef (patch) | |
tree | f615af925957410ecf2f9c0bf82fc79c8726a7f6 /composer/e-msg-composer-attachment.c | |
parent | b457da9a980ac545fbb051bf6b7f80bfb070c867 (diff) | |
download | gsoc2013-evolution-45a3bf8c4557eea71a77afd8a6efcc01416ecdef.tar.gz gsoc2013-evolution-45a3bf8c4557eea71a77afd8a6efcc01416ecdef.tar.zst gsoc2013-evolution-45a3bf8c4557eea71a77afd8a6efcc01416ecdef.zip |
If the attachment fails, report the error to the user.
2001-10-09 Jeffrey Stedfast <fejj@ximian.com>
* e-msg-composer-attachment-bar.c (add_from_file): If the
attachment fails, report the error to the user.
* e-msg-composer-attachment.c (e_msg_composer_attachment_new): Now
takes a CamelException argument.
svn path=/trunk/; revision=13537
Diffstat (limited to 'composer/e-msg-composer-attachment.c')
-rw-r--r-- | composer/e-msg-composer-attachment.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c index 49af8bc122..0b2d08aec9 100644 --- a/composer/e-msg-composer-attachment.c +++ b/composer/e-msg-composer-attachment.c @@ -28,6 +28,7 @@ attachment manually. */ #include <sys/stat.h> +#include <errno.h> #include <gtk/gtknotebook.h> #include <gtk/gtktogglebutton.h> @@ -143,12 +144,14 @@ e_msg_composer_attachment_get_type (void) * e_msg_composer_attachment_new: * @file_name: filename to attach * @disposition: Content-Disposition of the attachment + * @ex: exception * * Return value: the new attachment, or %NULL on error **/ EMsgComposerAttachment * -e_msg_composer_attachment_new (const gchar *file_name, - const gchar *disposition) +e_msg_composer_attachment_new (const char *file_name, + const char *disposition, + CamelException *ex) { EMsgComposerAttachment *new; CamelMimePart *part; @@ -160,16 +163,28 @@ e_msg_composer_attachment_new (const gchar *file_name, g_return_val_if_fail (file_name != NULL, NULL); - if (stat (file_name, &statbuf) < 0) + if (stat (file_name, &statbuf) < 0) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Cannot attach file %s: %s"), + file_name, g_strerror (errno)); return NULL; + } /* return if it's not a regular file */ - if (!S_ISREG (statbuf.st_mode)) + if (!S_ISREG (statbuf.st_mode)) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Cannot attach file %s: not a regular file"), + file_name); return NULL; + } stream = camel_stream_fs_new_with_name (file_name, O_RDONLY, 0); - if (!stream) + if (!stream) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Cannot attach file %s: %s"), + file_name, g_strerror (errno)); return NULL; + } wrapper = camel_data_wrapper_new (); camel_data_wrapper_construct_from_stream (wrapper, stream); camel_object_unref (CAMEL_OBJECT (stream)); |