sync with 0.7.8cvs1
authorPaul Mangan <paul@claws-mail.org>
Wed, 19 Jun 2002 07:31:13 +0000 (07:31 +0000)
committerPaul Mangan <paul@claws-mail.org>
Wed, 19 Jun 2002 07:31:13 +0000 (07:31 +0000)
14 files changed:
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/filtering.c
src/folder.c
src/imap.c
src/mbox_folder.c
src/messageview.c
src/mh.c
src/news.c
src/procheader.c
src/procheader.h
src/selective_download.c

index a995172..4f4fedf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2002-06-18
+
+       * src/folder.c: folder_build_tree(): use strtoul() instead of atoi()
+         for mtime to prevent flooring.
+       * src/imap.c:
+         imap_move_msg()
+         imap_move_msgs_with_dest()
+         imap_copy_msgs_with_dest(): fixed a bug that prevented multiple
+         message copy/move.
+         imap_parse_envelope()
+         imap_cmd_envelope(): use RFC822.HEADER instead of ENVELOPE to get
+         full information of messages and simplify the parser. Also fixed
+         the bug that References header was ignored on threading.
+         imap_parse_one_address()
+         imap_parse_address(): removed.
+         imap_get_header(): new. It reads the RFC822 header and returns
+         a newly allocated string.
+       * src/procheader.[ch]: changed procheader_parse() to
+         procheader_parse_stream() and added different interfaces for it.
+
 2002-06-17
 
        * po/zh_TW.Big5.po: fixed a mistake that caused a crash.
index 1c90ea8..ec78b3f 100644 (file)
@@ -1,3 +1,8 @@
+2002-06-18 [paul]      0.7.8claws8
+
+       * sync with 0.7.8cvs1
+               see ChangeLog 2002-06-18
+
 2002-06-18 [alfons]    0.7.8claws7
 
        * src/mainwindow.h
index c3e2729..9967f77 100644 (file)
@@ -1,3 +1,23 @@
+2002-06-18
+
+       * src/folder.c: folder_build_tree(): ·«¤ê²¼¤²¤òËɤ°¤¿¤á¤Ë mtime ¤Ë
+         atoi() ¤ÎÂå¤ï¤ê¤Ë strtoul() ¤ò»ÈÍÑ¡£
+       * src/imap.c:
+         imap_move_msg()
+         imap_move_msgs_with_dest()
+         imap_copy_msgs_with_dest(): Ê£¿ô¥á¥Ã¥»¡¼¥¸¤Î¥³¥Ô¡¼/°ÜÆ°¤ò˸¤²¤ë
+         ¥Ð¥°¤ò½¤Àµ¡£
+         imap_parse_envelope()
+         imap_cmd_envelope(): ¥á¥Ã¥»¡¼¥¸¤Î´°Á´¤Ê¾ðÊó¤ò¼èÆÀ¤·¡¢¥Ñ¡¼¥µ¤ò
+         Ã±½ã²½¤¹¤ë¤¿¤á¤Ë ENVELOPE ¤ÎÂå¤ï¤ê¤Ë RFC822.HEADER ¤ò»ÈÍÑ¡£
+         ¥¹¥ì¥Ã¥É¹½ÃۤκݤˠReferences ¥Ø¥Ã¥À¤¬Ìµ»ë¤µ¤ì¤Æ¤¤¤¿¥Ð¥°¤ò½¤Àµ¡£
+         imap_parse_one_address()
+         imap_parse_address(): ºï½ü¡£
+         imap_get_header(): ¿·µ¬¡£ RFC822 ¥Ø¥Ã¥À¤òÆɤߤ³¤ß¿·¤¿¤Ë³ÎÊݤµ¤ì¤¿
+         Ê¸»úÎó¤òÊÖ¤¹¡£
+       * src/procheader.[ch]: procheader_parse() ¤ò procheader_parse_stream()
+         ¤ËÊѹ¹¤·¡¢°Û¤Ê¤ë¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤òÄɲá£
+
 2002-06-17
 
        * po/zh_TW.Big5.po: ¥¯¥é¥Ã¥·¥å¤òµ¯¤³¤¹¥ß¥¹¤ò½¤Àµ¡£
index f4da0b7..6b88634 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws7
+EXTRA_VERSION=claws8
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 628a133..8756c53 100644 (file)
@@ -407,7 +407,7 @@ void filter_message(GSList *filtering_list, FolderItem *inbox,
                return;
        }
 
-       msginfo = procheader_parse(filename, msgflags, TRUE, FALSE);
+       msginfo = procheader_parse_file(filename, msgflags, TRUE, FALSE);
        
        g_free(filename);
 
index 34fbb8a..17ea90c 100644 (file)
@@ -26,6 +26,7 @@
 #include <glib.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 #include "intl.h"
 #include "folder.h"
@@ -1145,7 +1146,8 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
                 threaded = TRUE, ret_rcpt = FALSE, hidereadmsgs = FALSE;
        FolderSortKey sort_key = SORT_BY_NONE;
        FolderSortType sort_type = SORT_ASCENDING;
-       gint mtime = 0, new = 0, unread = 0, total = 0;
+       gint new = 0, unread = 0, total = 0;
+       time_t mtime = 0;
 
        g_return_val_if_fail(node->data != NULL, FALSE);
        if (!node->parent) return FALSE;
@@ -1183,7 +1185,7 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
                        if (!account) g_warning("account_id: %s not found\n",
                                                attr->value);
                } else if (!strcmp(attr->name, "mtime"))
-                       mtime = atoi(attr->value);
+                       mtime = strtoul(attr->value, NULL, 10);
                else if (!strcmp(attr->name, "new"))
                        new = atoi(attr->value);
                else if (!strcmp(attr->name, "unread"))
index 61b0e12..e4c25dc 100644 (file)
@@ -171,18 +171,9 @@ static gchar *imap_parse_atom              (SockInfo       *sock,
                                         gchar          *dest,
                                         gint            dest_len,
                                         GString        *str);
-static gchar *imap_parse_one_address   (SockInfo       *sock,
-                                        gchar          *start,
-                                        gchar          *out_from_str,
-                                        gchar          *out_fromname_str,
-                                        GString        *str);
-static gchar *imap_parse_address       (SockInfo       *sock,
-                                        gchar          *start,
-                                        gchar         **out_from_str,
-                                        gchar         **out_fromname_str,
-                                        GString        *str);
 static MsgFlags imap_parse_flags       (const gchar    *flag_str);
 static MsgInfo *imap_parse_envelope    (SockInfo       *sock,
+                                        FolderItem     *item,
                                         GString        *line_str);
 static gint imap_greeting              (SockInfo *sock,
                                         gboolean *is_preauth);
@@ -799,7 +790,7 @@ gint imap_move_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
        ret = imap_add_msg(folder, dest, srcfile, FALSE);
        g_free(srcfile);
 
-       if (ret == 0)
+       if (ret != -1)
                ret = folder_item_remove_msg(msginfo->folder, msginfo->msgnum);
 
        return ret;
@@ -823,7 +814,7 @@ gint imap_move_msgs_with_dest(Folder *folder, FolderItem *dest,
        for (cur = msglist; cur != NULL; cur = cur->next) {
                msginfo = (MsgInfo *)cur->data;
                ret = imap_move_msg(folder, dest, msginfo);
-               if (ret != 0) break;
+               if (ret == -1) break;
        }
 
        return ret;
@@ -871,7 +862,7 @@ gint imap_copy_msgs_with_dest(Folder *folder, FolderItem *dest,
        for (cur = msglist; cur != NULL; cur = cur->next) {
                msginfo = (MsgInfo *)cur->data;
                ret = imap_copy_msg(folder, dest, msginfo);
-               if (ret != 0) break;
+               if (ret == -1) break;
        }
 
        return ret;
@@ -1520,12 +1511,12 @@ static GSList *imap_get_uncached_messages(IMAPSession *session,
                        g_free(tmp);
                        continue;
                }
-               /* log_print("IMAP4< %s\n", tmp); */
-               debug_print("IMAP4< %s\n", tmp);
+               log_print("IMAP4< %s\n", tmp);
                g_string_assign(str, tmp);
                g_free(tmp);
 
-               msginfo = imap_parse_envelope(SESSION(session)->sock, str);
+               msginfo = imap_parse_envelope
+                       (SESSION(session)->sock, item, str);
                if (!msginfo) {
                        log_warning(_("can't parse envelope: %s\n"), str->str);
                        continue;
@@ -1562,7 +1553,7 @@ static GSList *imap_delete_cached_messages(GSList *mlist, FolderItem *item,
        g_return_val_if_fail(item->folder != NULL, mlist);
        g_return_val_if_fail(item->folder->type == F_IMAP, mlist);
 
-       debug_print(_("Deleting cached messages %d - %d ... "),
+       debug_print(_("Deleting cached messages %u - %u ... "),
                    first_uid, last_uid);
 
        dir = folder_item_get_path(item);
@@ -1898,98 +1889,66 @@ static gchar *imap_parse_atom(SockInfo *sock, gchar *src,
        return cur_pos;
 }
 
-static gchar *imap_parse_one_address(SockInfo *sock, gchar *start,
-                                    gchar *out_from_str,
-                                    gchar *out_fromname_str,
-                                    GString *str)
+static gchar *imap_get_header(SockInfo *sock, gchar *cur_pos, gchar **headers,
+                             GString *str)
 {
-       gchar buf[IMAPBUFSIZE];
-       gchar *userid;
-       gchar *domain;
-       gchar *cur_pos = start;
-
-       cur_pos = imap_parse_atom(sock, cur_pos, buf, sizeof(buf), str);
-       conv_unmime_header(out_fromname_str, IMAPBUFSIZE, buf, NULL);
-
-       cur_pos = imap_parse_atom(sock, cur_pos, buf, sizeof(buf), str);
+       gchar *nextline;
+       gchar buf[32];
+       gint len;
+       gint block_len = 0;
 
-       cur_pos = imap_parse_atom(sock, cur_pos, buf, sizeof(buf), str);
-       Xstrdup_a(userid, buf, return cur_pos + 1);
+       *headers = NULL;
 
-       cur_pos = imap_parse_atom(sock, cur_pos, buf, sizeof(buf), str);
-       Xstrdup_a(domain, buf, return cur_pos + 1);
+       g_return_val_if_fail(str != NULL, cur_pos);
 
-       if (out_fromname_str[0] != '\0') {
-               g_snprintf(out_from_str, IMAPBUFSIZE, "\"%s\" <%s@%s>",
-                          out_fromname_str, userid, domain);
-       } else {
-               g_snprintf(out_from_str, IMAPBUFSIZE, "%s@%s",
-                          userid, domain);
-               strcpy(out_fromname_str, out_from_str);
-       }
+       while (isspace(*cur_pos)) cur_pos++;
 
-       while (*cur_pos == ' ') cur_pos++;
-       g_return_val_if_fail(*cur_pos == ')', NULL);
+       g_return_val_if_fail(*cur_pos == '{', cur_pos);
 
-       return cur_pos + 1;
-}
+       cur_pos = strchr_cpy(cur_pos + 1, '}', buf, sizeof(buf));
+       len = atoi(buf);
 
-static gchar *imap_parse_address(SockInfo *sock, gchar *start,
-                                gchar **out_from_str,
-                                gchar **out_fromname_str,
-                                GString *str)
-{
-       gchar buf[IMAPBUFSIZE];
-       gchar name_buf[IMAPBUFSIZE];
-       gchar *cur_pos = start;
-       GString *addr_str;
+       g_string_truncate(str, 0);
+       cur_pos = str->str;
 
-       if (out_from_str)     *out_from_str     = NULL;
-       if (out_fromname_str) *out_fromname_str = NULL;
-       buf[0] = name_buf[0] = '\0';
+       do {
+               if ((nextline = sock_getline(sock)) == NULL)
+                       return cur_pos;
+               block_len += strlen(nextline);
+               g_string_append(str, nextline);
+               cur_pos = str->str;
+               strretchomp(nextline);
+               /* debug_print("IMAP4< %s\n", nextline); */
+               g_free(nextline);
+       } while (block_len < len);
 
-       if (!strncmp(cur_pos, "NIL", 3)) {
-               if (out_from_str)     *out_from_str     = g_strdup("");
-               if (out_fromname_str) *out_fromname_str = g_strdup("");
-               return cur_pos + 3;
-       }
+       debug_print("IMAP4< [contents of RFC822.HEADER]\n");
 
-       g_return_val_if_fail(*cur_pos == '(', NULL);
-       cur_pos++;
+       *headers = g_strndup(cur_pos, len);
+       cur_pos += len;
 
-       addr_str = g_string_new(NULL);
+       while (isspace(*cur_pos)) cur_pos++;
+       while (*cur_pos == '\0') {
+               if ((nextline = sock_getline(sock)) == NULL)
+                       return cur_pos;
+               g_string_assign(str, nextline);
+               cur_pos = str->str;
+               strretchomp(nextline);
+               debug_print("IMAP4< %s\n", nextline);
+               g_free(nextline);
 
-       for (;;) {
-               gchar ch = *cur_pos++;
-               if (ch == ')') break;
-               if (ch == '(') {
-                       cur_pos = imap_parse_one_address
-                               (sock, cur_pos, buf, name_buf, str);
-                       if (!cur_pos) {
-                               g_string_free(addr_str, TRUE);
-                               return NULL;
-                       }
-                       if (addr_str->str[0] != '\0')
-                               g_string_append(addr_str, ", ");
-                       g_string_append(addr_str, buf);
-               }
+               while (isspace(*cur_pos)) cur_pos++;
        }
 
-       if (out_from_str)     *out_from_str     = g_strdup(addr_str->str);
-       if (out_fromname_str) *out_fromname_str = g_strdup(name_buf);
-
-       g_string_free(addr_str, TRUE);
-
        return cur_pos;
 }
 
 static MsgFlags imap_parse_flags(const gchar *flag_str)  
 {
        const gchar *p = flag_str;
-       MsgFlags flags;
+       MsgFlags flags = {0, 0};
 
        flags.perm_flags = MSG_UNREAD;
-       flags.tmp_flags  = MSG_IMAP;
 
        while ((p = strchr(p, '\\')) != NULL) {
                p++;
@@ -2010,38 +1969,38 @@ static MsgFlags imap_parse_flags(const gchar *flag_str)
        return flags;
 }
 
-static MsgInfo *imap_parse_envelope(SockInfo *sock, GString *line_str)
+static MsgInfo *imap_parse_envelope(SockInfo *sock, FolderItem *item,
+                                   GString *line_str)
 {
-       MsgInfo *msginfo;
        gchar buf[IMAPBUFSIZE];
-       gchar tmp[IMAPBUFSIZE];
+       MsgInfo *msginfo = NULL;
        gchar *cur_pos;
        gint msgnum;
        guint32 uid = 0;
        size_t size = 0;
-       gchar *date = NULL;
-       time_t date_t = 0;
-       gchar *subject = NULL;
-       gchar *tmp_from;
-       gchar *tmp_fromname;
-       gchar *from = NULL;
-       gchar *fromname = NULL;
-       gchar *tmp_to;
-       gchar *to = NULL;
-       gchar *inreplyto = NULL;
-       gchar *msgid = NULL;
-       MsgFlags flags = {0, 0};
+       MsgFlags flags = {0, 0}, imap_flags = {0, 0};
 
        g_return_val_if_fail(line_str != NULL, NULL);
        g_return_val_if_fail(line_str->str[0] == '*' &&
                             line_str->str[1] == ' ', NULL);
 
+       MSG_SET_TMP_FLAGS(flags, MSG_IMAP);
+       if (item->stype == F_QUEUE) {
+               MSG_SET_TMP_FLAGS(flags, MSG_QUEUED);
+       } else if (item->stype == F_DRAFT) {
+               MSG_SET_TMP_FLAGS(flags, MSG_DRAFT);
+       }
+
        cur_pos = line_str->str + 2;
 
-#define PARSE_ONE_ELEMENT(ch) \
-{ \
-       cur_pos = strchr_cpy(cur_pos, ch, buf, sizeof(buf)); \
-       g_return_val_if_fail(cur_pos != NULL, NULL); \
+#define PARSE_ONE_ELEMENT(ch)                                  \
+{                                                              \
+       cur_pos = strchr_cpy(cur_pos, ch, buf, sizeof(buf));    \
+       if (cur_pos == NULL) {                                  \
+               g_warning("cur_pos == NULL\n");                 \
+               procmsg_msginfo_free(msginfo);                  \
+               return NULL;                                    \
+       }                                                       \
 }
 
        PARSE_ONE_ELEMENT(' ');
@@ -2061,114 +2020,37 @@ static MsgInfo *imap_parse_envelope(SockInfo *sock, GString *line_str)
                        uid = strtoul(cur_pos, &cur_pos, 10);
                } else if (!strncmp(cur_pos, "FLAGS ", 6)) {
                        cur_pos += 6;
-                       g_return_val_if_fail(*cur_pos == '(', NULL);
+                       if (*cur_pos != '(') {
+                               g_warning("*cur_pos != '('\n");
+                               procmsg_msginfo_free(msginfo);
+                               return NULL;
+                       }
                        cur_pos++;
                        PARSE_ONE_ELEMENT(')');
-                       flags = imap_parse_flags(buf);
+                       imap_flags = imap_parse_flags(buf);
                } else if (!strncmp(cur_pos, "RFC822.SIZE ", 12)) {
                        cur_pos += 12;
                        size = strtol(cur_pos, &cur_pos, 10);
-               } else if (!strncmp(cur_pos, "ENVELOPE ", 9)) {
-                       cur_pos += 9;
-                       g_return_val_if_fail(*cur_pos == '(', NULL);
-                       cur_pos = imap_parse_atom
-                               (sock, cur_pos + 1, buf, sizeof(buf), line_str);
-                       if (buf[0] != '\0') {
-                               Xstrdup_a(date, buf, return NULL);
-                               date_t = procheader_date_parse(NULL, date, 0);
-                       }
-
-                       cur_pos = imap_parse_atom
-                               (sock, cur_pos, buf, sizeof(buf), line_str);
-                       if (buf[0] != '\0') {
-                               conv_unmime_header(tmp, sizeof(tmp), buf, NULL);
-                               Xstrdup_a(subject, tmp, return NULL);
-                       }
-
-                       g_return_val_if_fail(*cur_pos == ' ', NULL);
-                       cur_pos = imap_parse_address(sock, cur_pos + 1,
-                                                    &tmp_from, &tmp_fromname,
-                                                    line_str);
-                       g_return_val_if_fail(cur_pos != NULL, NULL);
-                       if (tmp_from && *tmp_from != '\0')
-                               Xstrdup_a(from, tmp_from,
-                                         {g_free(tmp_from);
-                                          g_free(tmp_fromname);
-                                          return NULL;});
-                       if (tmp_fromname && *tmp_fromname != '\0')
-                               Xstrdup_a(fromname, tmp_fromname,
-                                         {g_free(tmp_from);
-                                          g_free(tmp_fromname);
-                                          return NULL;});
-                       g_free(tmp_from);
-                       g_free(tmp_fromname);
-
-#define SKIP_ONE_ELEMENT() \
-{ \
-       g_return_val_if_fail(*cur_pos == ' ', NULL); \
-       cur_pos = imap_parse_address(sock, cur_pos + 1, NULL, NULL, \
-                                    line_str); \
-       g_return_val_if_fail(cur_pos != NULL, NULL); \
-}
-
-                       /* skip sender and reply-to */
-                       SKIP_ONE_ELEMENT();
-                       SKIP_ONE_ELEMENT();
-
-                       g_return_val_if_fail(*cur_pos == ' ', NULL);
-                       cur_pos = imap_parse_address(sock, cur_pos + 1,
-                                                    &tmp_to, NULL, line_str);
-                       g_return_val_if_fail(cur_pos != NULL, NULL);
-                       Xstrdup_a(to, tmp_to, {g_free(tmp_to); return NULL;});
-                       g_free(tmp_to);
-
-                       /* skip Cc and Bcc */
-                       SKIP_ONE_ELEMENT();
-                       SKIP_ONE_ELEMENT();
-
-#undef SKIP_ONE_ELEMENT
-
-                       g_return_val_if_fail(*cur_pos == ' ', NULL);
-                       cur_pos = imap_parse_atom
-                               (sock, cur_pos, buf, sizeof(buf), line_str);
-                       g_return_val_if_fail(cur_pos != NULL, NULL);
-                       if (buf[0] != '\0') {
-                               eliminate_parenthesis(buf, '(', ')');
-                               extract_parenthesis(buf, '<', '>');
-                               remove_space(buf);
-                               Xstrdup_a(inreplyto, buf, return NULL);
-                       }
-
-                       g_return_val_if_fail(*cur_pos == ' ', NULL);
-                       cur_pos = imap_parse_atom
-                               (sock, cur_pos, buf, sizeof(buf), line_str);
-                       g_return_val_if_fail(cur_pos != NULL, NULL);
-                       if (buf[0] != '\0') {
-                               extract_parenthesis(buf, '<', '>');
-                               remove_space(buf);
-                               Xstrdup_a(msgid, buf, return NULL);
-                       }
-
-                       g_return_val_if_fail(*cur_pos == ')', NULL);
-                       cur_pos++;
+               } else if (!strncmp(cur_pos, "RFC822.HEADER ", 14)) {
+                       gchar *headers;
+
+                       cur_pos += 14;
+                       cur_pos = imap_get_header(sock, cur_pos, &headers,
+                                                 line_str);
+                       msginfo = procheader_parse_str(headers, flags, FALSE, FALSE);
+                       g_free(headers);
                } else {
                        g_warning("invalid FETCH response: %s\n", cur_pos);
                        break;
                }
        }
 
-       msginfo = g_new0(MsgInfo, 1);
-       msginfo->msgnum = uid;
-       msginfo->size = size;
-       msginfo->date = g_strdup(date);
-       msginfo->date_t = date_t;
-       msginfo->subject = g_strdup(subject);
-       msginfo->from = g_strdup(from);
-       msginfo->fromname = g_strdup(fromname);
-       msginfo->to = g_strdup(to);
-       msginfo->inreplyto = g_strdup(inreplyto);
-       msginfo->msgid = g_strdup(msgid);
-       msginfo->flags = flags;
+       if (msginfo) {
+               msginfo->msgnum = uid;
+               msginfo->size = size;
+               msginfo->flags.tmp_flags |= imap_flags.tmp_flags;
+               msginfo->flags.perm_flags = imap_flags.perm_flags;
+       }
 
        return msginfo;
 }
@@ -2725,7 +2607,7 @@ static gint imap_cmd_copy(SockInfo *sock, guint32 uid, const gchar *destfolder)
 gint imap_cmd_envelope(SockInfo *sock, guint32 first_uid, guint32 last_uid)
 {
        imap_cmd_gen_send
-               (sock, "UID FETCH %d:%d (UID FLAGS RFC822.SIZE ENVELOPE)",
+               (sock, "UID FETCH %d:%d (UID FLAGS RFC822.SIZE RFC822.HEADER)",
                 first_uid, last_uid);
 
        return IMAP_SUCCESS;
index ba3e208..451169e 100644 (file)
@@ -729,7 +729,7 @@ static MsgInfo *mbox_parse_msg(FILE * fp, struct _message * msg,
                }
        }
 
-       msginfo = procheader_file_parse(fp, flags, FALSE, FALSE);
+       msginfo = procheader_parse_stream(fp, flags, FALSE, FALSE);
 
        if (!msginfo) return NULL;
 
index 10696cf..eef7487 100644 (file)
@@ -397,7 +397,7 @@ void messageview_show(MessageView *messageview, MsgInfo *msginfo,
         * in any case, checking tmpmsginfo->flags for MSG_UNREAD
         * fixes the return-receipt-request bug */
 
-       tmpmsginfo = procheader_parse(file, msginfo->flags, TRUE, TRUE);
+       tmpmsginfo = procheader_parse_file(file, msginfo->flags, TRUE, TRUE);
        if (MSG_IS_MIME(tmpmsginfo->flags))
                MSG_SET_TMP_FLAGS(msginfo->flags, MSG_MIME);
 
index 94b13b5..5aa3903 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -1045,7 +1045,7 @@ static MsgInfo *mh_parse_msg(const gchar *file, FolderItem *item)
                MSG_SET_TMP_FLAGS(flags, MSG_DRAFT);
        }
 
-       msginfo = procheader_parse(file, flags, FALSE, FALSE);
+       msginfo = procheader_parse_file(file, flags, FALSE, FALSE);
        if (!msginfo) return NULL;
 
        msginfo->msgnum = atoi(file);
index 37c2d4f..bbb2f03 100644 (file)
@@ -618,7 +618,7 @@ static gint news_remove_msg(Folder *folder, FolderItem *item, gint num)
        if (filename == NULL)
                return -1;
 
-       msginfo = procheader_parse(filename, msgflags, FALSE, FALSE);
+       msginfo = procheader_parse_file(filename, msgflags, FALSE, FALSE);
        if (msginfo == NULL)
                return -1;
 
index 8b0e85e..355c0e1 100644 (file)
@@ -416,6 +416,36 @@ void procheader_get_header_fields(FILE *fp, HeaderEntry hentry[])
        }
 }
 
+MsgInfo *procheader_parse_file(const gchar *file, MsgFlags flags,
+                              gboolean full, gboolean decrypted)
+{
+       FILE *fp;
+       MsgInfo *msginfo;
+
+       if ((fp = fopen(file, "rb")) == NULL) {
+               FILE_OP_ERROR(file, "fopen");
+               return NULL;
+       }
+
+       msginfo = procheader_parse_stream(fp, flags, full, decrypted);
+       fclose(fp);
+       return msginfo;
+}
+
+MsgInfo *procheader_parse_str(const gchar *str, MsgFlags flags, gboolean full,
+                             gboolean decrypted)
+{
+       FILE *fp;
+       MsgInfo *msginfo;
+
+       if ((fp = str_open_as_stream(str)) == NULL)
+               return NULL;
+
+       msginfo = procheader_parse_stream(fp, flags, full, decrypted);
+       fclose(fp);
+       return msginfo;
+}
+
 enum
 {
        H_DATE          = 0,
@@ -437,33 +467,8 @@ enum
        H_RETURN_RECEIPT_TO = 16
 };
 
-MsgInfo *procheader_parse(const gchar *file, MsgFlags flags,
-                         gboolean full, gboolean decrypted)
-{
-       FILE *fp;
-       MsgInfo *msginfo;
-
-       if ((fp = fopen(file, "rb")) == NULL) {
-               FILE_OP_ERROR(file, "fopen");
-               return NULL;
-       }
-
-       msginfo = procheader_file_parse(fp, flags, full, decrypted);
-
-       fclose(fp);
-
-       return msginfo;
-}
-
-
-/* FIXME: we should not allow headers in messages to change the sylpheed marks
- * so we're currently disabling setting any MsgFlags when detecting X-Seen,
- * Seen, X-Status, Status. See macro ALLOW_HEADER_HINT */  
-
-/* #define ALLOW_HEADER_HINT */
-
-MsgInfo *procheader_file_parse(FILE * fp, MsgFlags flags,
-                              gboolean full, gboolean decrypted)
+MsgInfo *procheader_parse_stream(FILE *fp, MsgFlags flags, gboolean full, 
+                                gboolean decrypted)
 {
        static HeaderEntry hentry_full[] = {{"Date:",           NULL, FALSE},
                                           {"From:",            NULL, TRUE},
@@ -499,7 +504,7 @@ MsgInfo *procheader_file_parse(FILE * fp, MsgFlags flags,
                                            {"X-Status:",       NULL, FALSE},
                                            {"From ",           NULL, FALSE},
                                            {NULL,              NULL, FALSE}};
-       
+
        MsgInfo *msginfo;
        gchar buf[BUFFSIZE], tmp[BUFFSIZE];
        gchar *reference = NULL;
@@ -530,7 +535,6 @@ MsgInfo *procheader_file_parse(FILE * fp, MsgFlags flags,
        while ((hnum = procheader_get_one_field(buf, sizeof(buf), fp, hentry))
               != -1) {
                hp = buf + strlen(hentry[hnum].name);
-
                while (*hp == ' ' || *hp == '\t') hp++;
 
                switch (hnum) {
index 6021380..fbf70dd 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2002 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -60,7 +60,15 @@ void procheader_header_free                  (Header         *header);
 
 void procheader_get_header_fields      (FILE           *fp,
                                         HeaderEntry     hentry[]);
-MsgInfo *procheader_parse              (const gchar    *file,
+MsgInfo *procheader_parse_file         (const gchar    *file,
+                                        MsgFlags        flags,
+                                        gboolean        full,
+                                        gboolean        decrypted);
+MsgInfo *procheader_parse_str          (const gchar    *str,
+                                        MsgFlags        flags,
+                                        gboolean        full,
+                                        gboolean        decrypted);
+MsgInfo *procheader_parse_stream       (FILE           *fp,
                                         MsgFlags        flags,
                                         gboolean        full,
                                         gboolean        decrypted);
index dd2b75e..70c166b 100644 (file)
@@ -247,7 +247,7 @@ MsgInfo *sd_get_msginfo_from_file(const gchar *filename)
        MsgInfo *msg;
        MsgFlags msgflags = { 0, 0 };
 
-       msg  = procheader_parse(filename, msgflags, TRUE, FALSE);
+       msg  = procheader_parse_file(filename, msgflags, TRUE, FALSE);
 
        if (!msg) {
                msginfo->subject = _("(No Subject)");