sync with 0.8.11cvs41
authorPaul Mangan <paul@claws-mail.org>
Wed, 7 May 2003 07:36:15 +0000 (07:36 +0000)
committerPaul Mangan <paul@claws-mail.org>
Wed, 7 May 2003 07:36:15 +0000 (07:36 +0000)
13 files changed:
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.ac
src/action.c
src/common/utils.c
src/common/utils.h
src/compose.c
src/messageview.c
src/mimeview.c
src/procmime.c
src/procmsg.c
src/textview.c

index a9f4be0..6776eab 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2003-05-07
+
+       * src/compose.c: compose_insert_sig(): fixed a crash when signature
+         string contains illegal sequence.
+       * src/utils.[ch]: changed get_wcs_len() to get_mbs_len() for accuracy.
+
+2003-05-07
+
+       * major refactoring of MIME structure.
+       * src/procmime.c: procmime_scan_message(): decrypt message if
+         gpgme is enabled. Create multipart tree only if content-type is
+         multipart/* or message/rfc822.
+         procmime_scan_multipart_message(): fixed the scanning of
+         message/rfc822 part.
+       * src/action.c: parse_append_msgpart()
+         src/messageview.c: messageview_show()
+         src/mimeview.c: mimeview_show_message(): use procmime_scan_message()
+         instead of procmsg_open_message() and procmime_scan_mime_header().
+         mimeview_set_multipart_tree(): conform to the new MIME structure.
+       * src/textview.c: textview_show_part(): removed unnecessary check.
+       * src/procmsg.c: procmsg_open_message_decrypted(): fixed the file
+         pointer when decryption failed.
+
 2003-05-06
 
        * src/ssl.c: ssl_init_socket_with_method(): replaced log_warning()
index 964c5d4..460aae6 100644 (file)
@@ -1,3 +1,8 @@
+2003-05-07 [paul]      0.8.11claws146
+
+       * sync with 0.8.11cvs41
+               see ChangeLog 2003-05-07
+
 2003-05-06 [christoph] 0.8.11claws145
 
        * src/main.c
index 118abb9..6f5c34d 100644 (file)
@@ -1,3 +1,27 @@
+2003-05-07
+
+       * src/compose.c: compose_insert_sig(): ½ð̾ʸ»úÎó¤ËÉÔÀµ¤Ê¥·¡¼¥±¥ó¥¹
+         ¤¬´Þ¤Þ¤ì¤ë¤È¤­¤Î¥¯¥é¥Ã¥·¥å¤ò½¤Àµ¡£
+       * src/utils.[ch]: Àµ³Î¤µ¤Î¤¿¤á get_wcs_len() ¤ò get_mbs_len() ¤ËÊѹ¹¡£
+
+2003-05-07
+
+       * MIME ¹½Â¤¤ÎÂ礭¤Ê¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¡£
+       * src/procmime.c: procmime_scan_message(): gpgme ¤¬Í­¸ú¤Î¤È¤­¤Ï
+         ¥á¥Ã¥»¡¼¥¸¤òÉü¹æ²½¤¹¤ë¤è¤¦¤Ë¤·¤¿¡£ content-type ¤¬ multipart/*
+         ¤Þ¤¿¤Ï message/rfc822 ¤Î¾ì¹ç¤Î¤ß¥Þ¥ë¥Á¥Ñ¡¼¥È¥Ä¥ê¡¼¤òºîÀ®¡£
+         procmime_scan_multipart_message(): message/rfc822 ¥Ñ¡¼¥È¤ÎÁöºº
+         ¤ò½¤Àµ¡£
+       * src/action.c: parse_append_msgpart()
+         src/messageview.c: messageview_show()
+         src/mimeview.c: mimeview_show_message(): procmsg_open_message() ¤È
+         procmime_scan_mime_header() ¤ÎÂå¤ï¤ê¤Ë procmime_scan_message()
+         ¤ò»ÈÍÑ¡£
+         mimeview_set_multipart_tree(): ¿·¤·¤¤ MIME ¹½Â¤¤ËÂбþ¡£
+       * src/textview.c: textview_show_part(): ÉÔÍפʥÁ¥§¥Ã¥¯¤òºï½ü¡£
+       * src/procmsg.c: procmsg_open_message_decrypted(): Éü¹æ²½¤Ë¼ºÇÔ¤·¤¿
+         ¾ì¹ç¤Î¥Õ¥¡¥¤¥ë¥Ý¥¤¥ó¥¿¤ò½¤Àµ¡£
+
 2003-05-06
 
        * src/ssl.c: ssl_init_socket_with_method(): log_warning() ¤ò
index bd76559..65a50d5 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws145
+EXTRA_VERSION=claws146
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 3c0701e..4c4e5b9 100644 (file)
@@ -344,23 +344,8 @@ static gboolean parse_append_msgpart(GString *cmd, MsgInfo *msginfo,
        gint ret;
 
        if (!partinfo) {
-               FILE *fp;
-#if USE_GPGME
-               if ((fp = procmsg_open_message_decrypted(msginfo, &partinfo))
-                   == NULL) {
-                       alertpanel_error(_("Could not get message file."));
-                       return FALSE;
-               }
-#else
-               if ((fp = procmsg_open_message(msginfo)) == NULL) {
-                       alertpanel_error(_("Could not get message file."));
-                       return FALSE;
-               }
-               partinfo = procmime_scan_mime_header(fp);
-#endif
-               fclose(fp);
+               partinfo = procmime_scan_message(msginfo);
                if (!partinfo) {
-                       procmime_mimeinfo_free_all(partinfo);
                        alertpanel_error(_("Could not get message part."));
                        return FALSE;
                }
index 64640d8..77162e3 100644 (file)
@@ -488,7 +488,7 @@ wchar_t *wcscasestr(const wchar_t *haystack, const wchar_t *needle)
        return NULL;
 }
 
-gint get_wcs_len(const gchar *s)
+gint get_mbs_len(const gchar *s)
 {
        const gchar *p = s;
        gint mb_len;
index 76e5ef1..42e3611 100644 (file)
@@ -216,7 +216,7 @@ gint wcsncasecmp            (const wchar_t *s1,
                                 size_t         n);
 wchar_t *wcscasestr            (const wchar_t *haystack,
                                 const wchar_t *needle);
-gint get_wcs_len               (const gchar    *s);
+gint get_mbs_len               (const gchar    *s);
 
 gboolean is_next_nonascii      (const guchar *s);
 gint get_next_word_len         (const gchar *s);
index 8910d10..50bc4af 100644 (file)
@@ -1913,9 +1913,14 @@ static void compose_insert_sig(Compose *compose, gboolean replace)
 
                pos = gtkut_stext_find(text, 0, tmp, TRUE);
                if (pos != -1) {
-                       gtk_stext_set_point(text, pos);
-                       len = get_wcs_len(tmp);
-                       gtk_stext_forward_delete(text, len);
+                       len = get_mbs_len(tmp);
+                       if (len >= 0) {
+                               gtk_stext_set_point(text, pos);
+                               gtk_stext_forward_delete(text, len);
+                       } else {
+                               len = gtk_stext_get_length(text);
+                               gtk_stext_set_point(text, len);
+                       }
                } else {
                        len = gtk_stext_get_length(text);
                        gtk_stext_set_point(text, len);
index af4a969..87ece4f 100644 (file)
@@ -676,21 +676,13 @@ GList *messageview_get_window_list(void)
 void messageview_show(MessageView *messageview, MsgInfo *msginfo,
                      gboolean all_headers)
 {
-       FILE *fp;
        gchar *file;
        MimeInfo *mimeinfo;
 
        g_return_if_fail(msginfo != NULL);
 
-#if USE_GPGME
-       if ((fp = procmsg_open_message_decrypted(msginfo, &mimeinfo)) == NULL)
-               return;
-#else /* !USE_GPGME */
-       if ((fp = procmsg_open_message(msginfo)) == NULL) return;
-       mimeinfo = procmime_scan_mime_header(fp);
-#endif /* USE_GPGME */
-       fclose(fp);
-       if (!mimeinfo) return;
+       mimeinfo = procmime_scan_message(msginfo);
+       g_return_if_fail(mimeinfo != NULL);
 
        file = procmsg_get_message_file_path(msginfo);
        if (!file) {
index 8cd6c42..a7f1537 100644 (file)
@@ -279,7 +279,6 @@ void mimeview_show_message(MimeView *mimeview, MimeInfo *mimeinfo,
 {
        GtkCTree *ctree = GTK_CTREE(mimeview->ctree);
        GtkCTreeNode *node;
-       gchar buf[BUFFSIZE];
        FILE *fp;
 
        mimeview_clear(mimeview);
@@ -290,26 +289,17 @@ void mimeview_show_message(MimeView *mimeview, MimeInfo *mimeinfo,
 
        mimeview->mimeinfo = mimeinfo;
 
-       if ((fp = fopen(file, "rb")) == NULL) {
-               FILE_OP_ERROR(file, "fopen");
-               return;
-       }
        mimeview->file = g_strdup(file);
 
-       /* skip MIME part headers */
-       if (mimeinfo->mime_type == MIME_MULTIPART) {
-               if (fseek(fp, mimeinfo->fpos, SEEK_SET) < 0)
-                       perror("fseek");
-               while (fgets(buf, sizeof(buf), fp) != NULL)
-                       if (buf[0] == '\r' || buf[0] == '\n') break;
-       }
-
-       procmime_scan_multipart_message(mimeinfo, fp);
 #if USE_GPGME
-       if ((prefs_common.auto_check_signatures)
-           && (gpg_started))
+       if (prefs_common.auto_check_signatures && gpg_started) {
+               if ((fp = fopen(file, "rb")) == NULL) {
+                       FILE_OP_ERROR(file, "fopen");
+                       return;
+               }
                rfc2015_check_signature(mimeinfo, fp);
-       else
+               fclose(fp);
+       } else
                set_unchecked_signature(mimeinfo);
 #endif
 
@@ -332,7 +322,6 @@ void mimeview_show_message(MimeView *mimeview, MimeInfo *mimeinfo,
                     partinfo->mime_type == MIME_TEXT_HTML))
                        break;
        }
-       fclose(fp);
        textview_show_message(mimeview->messageview->textview, mimeinfo, file);
 
        if (!node)
@@ -376,27 +365,25 @@ static void mimeview_set_multipart_tree(MimeView *mimeview,
                                        MimeInfo *mimeinfo,
                                        GtkCTreeNode *parent)
 {
-       GtkCTreeNode *current = parent;
+       GtkCTreeNode *node;
 
        g_return_if_fail(mimeinfo != NULL);
 
-       if (!mimeinfo->sub && mimeinfo->parent)
-               current = mimeview_append_part(mimeview, mimeinfo, parent);
-       if (mimeinfo->sub && !mimeinfo->sub->children &&
-           mimeinfo->sub->mime_type != MIME_TEXT &&
-           mimeinfo->sub->mime_type != MIME_TEXT_HTML) {
-               mimeview_append_part(mimeview, mimeinfo->sub, parent);
-               return;
-       }
-
-       if (mimeinfo->sub)
-               mimeview_set_multipart_tree(mimeview, mimeinfo->sub, current);
-
        if (mimeinfo->children)
-               mimeview_set_multipart_tree(mimeview, mimeinfo->children, current);
-
-       if (mimeinfo->next)
-               mimeview_set_multipart_tree(mimeview, mimeinfo->next, parent);
+               mimeinfo = mimeinfo->children;
+
+       while (mimeinfo != NULL) {
+               node = mimeview_append_part(mimeview, mimeinfo, parent);
+
+               if (mimeinfo->children)
+                       mimeview_set_multipart_tree(mimeview, mimeinfo, node);
+               else if (mimeinfo->sub &&
+                        mimeinfo->sub->mime_type != MIME_TEXT &&
+                        mimeinfo->sub->mime_type != MIME_TEXT_HTML)
+                       mimeview_set_multipart_tree(mimeview, mimeinfo->sub,
+                                                   node);
+               mimeinfo = mimeinfo->next;
+       }
 }
 
 static gchar *get_part_name(MimeInfo *partinfo)
index 24dd3a1..b58f886 100644 (file)
@@ -167,6 +167,22 @@ MimeInfo *procmime_mimeinfo_next(MimeInfo *mimeinfo)
        return NULL;
 }
 
+#if 0
+void procmime_dump_mimeinfo(MimeInfo *mimeinfo)
+{
+       gint i;
+
+       g_print("\n");
+
+       for (; mimeinfo != NULL; mimeinfo = procmime_mimeinfo_next(mimeinfo)) {
+               for (i = 0; i < mimeinfo->level; i++)
+                       g_print("  ");
+               g_print("%s%s\n", mimeinfo->main ? "sub: " : "",
+                       mimeinfo->content_type);
+       }
+}
+#endif
+
 MimeInfo *procmime_scan_message(MsgInfo *msginfo)
 {
        FILE *fp;
@@ -174,22 +190,21 @@ MimeInfo *procmime_scan_message(MsgInfo *msginfo)
 
        g_return_val_if_fail(msginfo != NULL, NULL);
 
+#if USE_GPGME
+       if ((fp = procmsg_open_message_decrypted(msginfo, &mimeinfo)) == NULL)
+               return NULL;
+#else
        if ((fp = procmsg_open_message(msginfo)) == NULL) return NULL;
        mimeinfo = procmime_scan_mime_header(fp);
+#endif
 
        if (mimeinfo) {
-               if (mimeinfo->mime_type != MIME_MULTIPART) {
-                       if (fseek(fp, mimeinfo->fpos, SEEK_SET) < 0)
-                               perror("fseek");
-               }
-               if (mimeinfo->mime_type != MIME_TEXT)
+               mimeinfo->size = get_left_file_size(fp);
+               if (mimeinfo->mime_type == MIME_MULTIPART ||
+                   mimeinfo->mime_type == MIME_MESSAGE_RFC822)
                        procmime_scan_multipart_message(mimeinfo, fp);
        }
 
-#if USE_GPGME
-        if (prefs_common.auto_check_signatures)
-               rfc2015_check_signature(mimeinfo, fp);
-#endif
        fclose(fp);
 
        return mimeinfo;
@@ -202,10 +217,10 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp)
        gint boundary_len = 0;
        gchar buf[BUFFSIZE];
        glong fpos, prev_fpos;
-       gint npart;
 
        g_return_if_fail(mimeinfo != NULL);
-       g_return_if_fail(mimeinfo->mime_type != MIME_TEXT);
+       g_return_if_fail(mimeinfo->mime_type == MIME_MULTIPART ||
+                        mimeinfo->mime_type == MIME_MESSAGE_RFC822);
 
        if (mimeinfo->mime_type == MIME_MULTIPART) {
                g_return_if_fail(mimeinfo->boundary != NULL);
@@ -229,40 +244,34 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp)
                return;
        }
 
-       for (npart = 0;; npart++) {
+       for (;;) {
                MimeInfo *partinfo;
                gboolean eom = FALSE;
 
                prev_fpos = fpos;
                debug_print("prev_fpos: %ld\n", fpos);
 
-               partinfo = procmime_scan_mime_header(fp);
-               if (!partinfo) break;
-               procmime_mimeinfo_insert(mimeinfo, partinfo);
-
-               if (partinfo->mime_type == MIME_MULTIPART) {
-                       if (partinfo->level < 8)
-                               procmime_scan_multipart_message(partinfo, fp);
-               } else if (partinfo->mime_type == MIME_MESSAGE_RFC822) {
+               if (mimeinfo->mime_type == MIME_MESSAGE_RFC822) {
                        MimeInfo *sub;
 
-                       partinfo->sub = sub = procmime_scan_mime_header(fp);
+                       mimeinfo->sub = sub = procmime_scan_mime_header(fp);
                        if (!sub) break;
 
-                       sub->level = partinfo->level + 1;
-                       sub->parent = partinfo;
-                       sub->main = partinfo;
-
-                       if (sub->level < 8) {
-                               if (sub->mime_type == MIME_MULTIPART) {
-                                       procmime_scan_multipart_message
-                                               (sub, fp);
-                               } else if (sub->mime_type == MIME_MESSAGE_RFC822) {
-                                       fseek(fp, sub->fpos, SEEK_SET);
-                                       procmime_scan_multipart_message
-                                               (sub, fp);
-                               }
-                       }
+                       sub->level = mimeinfo->level + 1;
+                       sub->parent = mimeinfo->parent;
+                       sub->main = mimeinfo;
+
+                       partinfo = sub;
+               } else {
+                       partinfo = procmime_scan_mime_header(fp);
+                       if (!partinfo) break;
+                       procmime_mimeinfo_insert(mimeinfo, partinfo);
+               }
+
+               if (partinfo->mime_type == MIME_MULTIPART ||
+                   partinfo->mime_type == MIME_MESSAGE_RFC822) {
+                       if (partinfo->level < 8)
+                               procmime_scan_multipart_message(partinfo, fp);
                }
 
                /* look for next boundary */
@@ -287,7 +296,8 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp)
                debug_print("partinfo->size: %d\n", partinfo->size);
                if (partinfo->sub && !partinfo->sub->sub &&
                    !partinfo->sub->children) {
-                       partinfo->sub->size = fpos - partinfo->sub->fpos - strlen(buf);
+                       partinfo->sub->size =
+                               fpos - partinfo->sub->fpos - strlen(buf);
                        debug_print("partinfo->sub->size: %d\n",
                                    partinfo->sub->size);
                }
index 11fd5b7..0f18169 100644 (file)
@@ -400,6 +400,7 @@ FILE *procmsg_open_message_decrypted(MsgInfo *msginfo, MimeInfo **mimeinfo)
 {
        FILE *fp;
        MimeInfo *mimeinfo_;
+       glong fpos;
 
        g_return_val_if_fail(msginfo != NULL, NULL);
 
@@ -419,7 +420,9 @@ FILE *procmsg_open_message_decrypted(MsgInfo *msginfo, MimeInfo **mimeinfo)
        }
 
        if (MSG_IS_ENCRYPTED(msginfo->flags) &&
-           (!msginfo->plaintext_file || msginfo->decryption_failed)) {
+           !msginfo->plaintext_file &&
+           !msginfo->decryption_failed) {
+               fpos = ftell(fp);
                rfc2015_decrypt_message(msginfo, mimeinfo_, fp);
                if (msginfo->plaintext_file &&
                    !msginfo->decryption_failed) {
@@ -432,6 +435,9 @@ FILE *procmsg_open_message_decrypted(MsgInfo *msginfo, MimeInfo **mimeinfo)
                                fclose(fp);
                                return NULL;
                        }
+               } else {
+                       if (fseek(fp, fpos, SEEK_SET) < 0)
+                               perror("fseek");
                }
        }
 
index d915701..b40966a 100644 (file)
@@ -473,12 +473,6 @@ static void textview_add_part(TextView *textview, MimeInfo *mimeinfo, FILE *fp)
 
        if (mimeinfo->mime_type == MIME_MULTIPART) return;
 
-       if (!mimeinfo->parent &&
-           mimeinfo->mime_type != MIME_TEXT &&
-           mimeinfo->mime_type != MIME_TEXT_HTML &&
-           mimeinfo->mime_type != MIME_TEXT_ENRICHED)
-               return;
-
        if (fseek(fp, mimeinfo->fpos, SEEK_SET) < 0) {
                perror("fseek");
                return;
@@ -1500,7 +1494,7 @@ gboolean textview_search_string(TextView *textview, const gchar *str,
 
        g_return_val_if_fail(str != NULL, FALSE);
 
-       len = get_wcs_len(str);
+       len = get_mbs_len(str);
        g_return_val_if_fail(len >= 0, FALSE);
 
        pos = textview->cur_pos;