2007-01-16 [paul] 2.7.1cvs6
authorColin Leroy <colin@colino.net>
Tue, 16 Jan 2007 08:13:56 +0000 (08:13 +0000)
committerColin Leroy <colin@colino.net>
Tue, 16 Jan 2007 08:13:56 +0000 (08:13 +0000)
* src/action.c
* src/compose.c
* src/mimeview.c
* src/procmime.c
* src/textview.c
Save and use errno for procmime_get_part

ChangeLog
PATCHSETS
configure.ac
src/action.c
src/compose.c
src/mimeview.c
src/procmime.c
src/textview.c

index 17b9c6aef43191d172306e646a35a0dfa4c5fdc0..9f87650ccd9d47caa905787a0eed7ebf7f1c30a7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-01-16 [paul]      2.7.1cvs6
+
+       * src/action.c
+       * src/compose.c
+       * src/mimeview.c
+       * src/procmime.c
+       * src/textview.c
+               Save and use errno for procmime_get_part
+
 2007-01-16 [colin]     2.7.1cvs5
 
        * src/imap.c
index 856c287ea2e20020fed9a6add2c7da6053aab133..fc84b2f01d01f0cc180a65eadddaa1019c4666fe 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.4.68 -r 1.1.4.69 src/etpan/imap-thread.c;  ) > 2.7.1cvs3.patchset
 ( cvs diff -u -r 1.179.2.148 -r 1.179.2.149 src/imap.c;  cvs diff -u -r 1.1.4.69 -r 1.1.4.70 src/etpan/imap-thread.c;  ) > 2.7.1cvs4.patchset
 ( cvs diff -u -r 1.179.2.149 -r 1.179.2.150 src/imap.c;  ) > 2.7.1cvs5.patchset
+( cvs diff -u -r 1.12.2.41 -r 1.12.2.42 src/action.c;  cvs diff -u -r 1.382.2.351 -r 1.382.2.352 src/compose.c;  cvs diff -u -r 1.83.2.98 -r 1.83.2.99 src/mimeview.c;  cvs diff -u -r 1.49.2.86 -r 1.49.2.87 src/procmime.c;  cvs diff -u -r 1.96.2.164 -r 1.96.2.165 src/textview.c;  ) > 2.7.1cvs6.patchset
index 1a80523b4f87d46aca7316a9789668b253ac80c0..ecc46dd0956583f5ab561ac6c562cfa5ff3fe378 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=7
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=5
+EXTRA_VERSION=6
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index cd5fa2e7af8793cf83871e1d8dca8ca42f4e5aba..4798c33568452166475843e00e2858533723e0d9 100644 (file)
@@ -400,7 +400,7 @@ static gboolean parse_append_msgpart(GString *cmd, MsgInfo *msginfo,
        g_free(filename);
 
        if (ret < 0) {
-               alertpanel_error(_("Can't get part of multipart message"));
+               alertpanel_error(_("Can't get part of multipart message: %s"), strerror(-ret));
                g_free(part_filename);
                return FALSE;
        }
index 613ca2b0994ef40e91bfaf64b90250867bb811e6..096cba17cf5bee80bc2e2e1ebbf799141f98ec4a 100644 (file)
@@ -3277,6 +3277,8 @@ static void compose_attach_parts(Compose *compose, MsgInfo *msginfo)
      
        child = (MimeInfo *) mimeinfo->node->children->data;
        while (child != NULL) {
+               gint err;
+
                if (child == encrypted) {
                        /* skip this part of tree */
                        NEXT_PART_NOT_CHILD(child);
@@ -3295,8 +3297,8 @@ static void compose_attach_parts(Compose *compose, MsgInfo *msginfo)
                }
 
                outfile = procmime_get_tmp_file_name(child);
-               if (procmime_get_part(outfile, child) < 0)
-                       g_warning("Can't get the part of multipart message.");
+               if ((err = procmime_get_part(outfile, child)) < 0)
+                       g_warning("Can't get the part of multipart message. (%s)", strerror(-err));
                else {
                        gchar *content_type;
 
index d0c4cadb07dae822c140343db4d4c918b39f2e7f..0e9ae9fa95feecac419261b81cd3263ae3ebcc11 100644 (file)
@@ -1331,6 +1331,7 @@ static void mimeview_drag_data_get(GtkWidget          *widget,
 {
        gchar *filename = NULL, *uriname, *tmp;
        MimeInfo *partinfo;
+       gint err;
 
        if (!mimeview->opened) return;
        if (!mimeview->file) return;
@@ -1382,9 +1383,11 @@ static void mimeview_drag_data_get(GtkWidget         *widget,
 
        g_free(tmp);
 
-       if (procmime_get_part(filename, partinfo) < 0)
+       if ((err = procmime_get_part(filename, partinfo)) < 0)
                alertpanel_error
-                       (_("Couldn't save the part of multipart message."));
+                       (_("Couldn't save the part of multipart message: %s"), 
+                               strerror(-err));
+
        uriname = g_strconcat("file://", filename, "\r\n", NULL);
 
        gtk_selection_data_set(selection_data, selection_data->target, 8,
@@ -1438,7 +1441,8 @@ static gboolean mimeview_write_part(const gchar *filename,
                                    MimeInfo *partinfo)
 {
        gchar *dir;
-       
+       gint err;
+
        dir= g_path_get_dirname(filename);
        if (!is_dir_exist(dir))
                make_dir_hier(dir);
@@ -1463,9 +1467,10 @@ static gboolean mimeview_write_part(const gchar *filename,
                if (G_ALERTALTERNATE != aval) return FALSE;
        }
 
-       if (procmime_get_part(filename, partinfo) < 0) {
+       if ((err = procmime_get_part(filename, partinfo)) < 0) {
                alertpanel_error
-                       (_("Couldn't save the part of multipart message."));
+                       (_("Couldn't save the part of multipart message: %s"), 
+                               strerror(-err));
                return FALSE;
        }
 
@@ -1629,6 +1634,7 @@ static void mimeview_display_as_text(MimeView *mimeview)
 static void mimeview_launch(MimeView *mimeview, MimeInfo *partinfo)
 {
        gchar *filename;
+       gint err;
 
        if (!mimeview->opened) return;
        if (!mimeview->file) return;
@@ -1640,9 +1646,10 @@ static void mimeview_launch(MimeView *mimeview, MimeInfo *partinfo)
 
        filename = procmime_get_tmp_file_name(partinfo);
 
-       if (procmime_get_part(filename, partinfo) < 0)
+       if ((err = procmime_get_part(filename, partinfo)) < 0)
                alertpanel_error
-                       (_("Couldn't save the part of multipart message."));
+                       (_("Couldn't save the part of multipart message: %s"), 
+                               strerror(-err));
        else
                mimeview_view_file(filename, partinfo, NULL, mimeview);
 
@@ -1668,14 +1675,15 @@ static void mimeview_open_part_with(MimeView *mimeview, MimeInfo *partinfo, gboo
        gchar *cmd;
        gchar *mime_command = NULL;
        gchar *content_type = NULL;
-
+       gint err;
        g_return_if_fail(partinfo != NULL);
 
        filename = procmime_get_tmp_file_name(partinfo);
 
-       if (procmime_get_part(filename, partinfo) < 0) {
+       if ((err = procmime_get_part(filename, partinfo)) < 0) {
                alertpanel_error
-                       (_("Couldn't save the part of multipart message."));
+                       (_("Couldn't save the part of multipart message: %s"), 
+                               strerror(-err));
                g_free(filename);
                return;
        }
index 2197972cb978651a20479685b5aa2ea03745c0ba..0ab8d1d91c733ed300992f310b5a0757cb0addca 100644 (file)
@@ -547,40 +547,49 @@ gint procmime_get_part(const gchar *outfile, MimeInfo *mimeinfo)
        FILE *infp, *outfp;
        gchar buf[BUFFSIZE];
        gint restlength, readlength;
+       gint saved_errno = 0;
 
        g_return_val_if_fail(outfile != NULL, -1);
        g_return_val_if_fail(mimeinfo != NULL, -1);
 
        if (mimeinfo->encoding_type != ENC_BINARY && !procmime_decode_content(mimeinfo))
-               return -1;
+               return -EINVAL;
 
        if ((infp = g_fopen(mimeinfo->data.filename, "rb")) == NULL) {
+               saved_errno = errno;
                FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
-               return -1;
+               return -(saved_errno);
        }
        if (fseek(infp, mimeinfo->offset, SEEK_SET) < 0) {
+               saved_errno = errno;
                FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
                fclose(infp);
-               return -1;
+               return -(saved_errno);
        }
        if ((outfp = g_fopen(outfile, "wb")) == NULL) {
+               saved_errno = errno;
                FILE_OP_ERROR(outfile, "fopen");
                fclose(infp);
-               return -1;
+               return -(saved_errno);
        }
 
        restlength = mimeinfo->length;
 
        while ((restlength > 0) && ((readlength = fread(buf, 1, restlength > BUFFSIZE ? BUFFSIZE : restlength, infp)) > 0)) {
-               fwrite(buf, 1, readlength, outfp);
+               if (fwrite(buf, 1, readlength, outfp) != readlength) {
+                       saved_errno = errno;
+                       fclose(outfp);
+                       return -(saved_errno);
+               }
                restlength -= readlength;
        }
 
        fclose(infp);
        if (fclose(outfp) == EOF) {
+               saved_errno = errno;
                FILE_OP_ERROR(outfile, "fclose");
                g_unlink(outfile);
-               return -1;
+               return -(saved_errno);
        }
 
        return 0;
index 46e5cf3be5fcd6ac96438cc99e3bce8398580ee4..ae27ad6e96d221919c7ac1891b89f34fcc6b22bb 100644 (file)
@@ -657,12 +657,13 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo)
                        gchar *filename;
                        ClickableText *uri;
                        gchar *uri_str;
+                       gint err;
                        START_TIMING("inserting image");
 
                        filename = procmime_get_tmp_file_name(mimeinfo);
 
-                       if (procmime_get_part(filename, mimeinfo) < 0) {
-                               g_warning("Can't get the image file.");
+                       if ((err = procmime_get_part(filename, mimeinfo)) < 0) {
+                               g_warning("Can't get the image file.(%s)", strerror(-err));
                                g_free(filename);
                                END_TIMING();
                                return;