2005-03-30 [colin] 1.9.6cvs14
authorColin Leroy <colin@colino.net>
Wed, 30 Mar 2005 20:29:56 +0000 (20:29 +0000)
committerColin Leroy <colin@colino.net>
Wed, 30 Mar 2005 20:29:56 +0000 (20:29 +0000)
* src/common/utils.h
* src/common/utils.c
* src/common/defs.h
* src/matcher.c
* src/msgcache.c
* src/news.c
* src/procmsg.c
* src/procmsg.h
* src/quote_fmt_parse.y
* src/summaryview.c
Update references system. Patch by Alfons

13 files changed:
ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/common/defs.h
src/common/utils.c
src/common/utils.h
src/matcher.c
src/msgcache.c
src/news.c
src/procmsg.c
src/procmsg.h
src/quote_fmt_parse.y
src/summaryview.c

index 2a79f5ec9552fc27a7e6c60b1ba52a6cba823b8f..c38167470d2071b2952e2d26fdcd56443f7629e7 100644 (file)
@@ -1,3 +1,17 @@
+2005-03-30 [colin]     1.9.6cvs14
+
+       * src/common/utils.h
+       * src/common/utils.c
+       * src/common/defs.h
+       * src/matcher.c
+       * src/msgcache.c
+       * src/news.c
+       * src/procmsg.c
+       * src/procmsg.h
+       * src/quote_fmt_parse.y
+       * src/summaryview.c
+               Update references system. Patch by Alfons
+
 2005-03-30 [colin]     1.9.6cvs13
 
        * src/common/socket.c
index 59b78330ee50809a3fe8fea8231b27d7c0ba704d..3923bbf547d1f32abec31aa47c4df4e29471cefc 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.16.2.14 -r 1.16.2.15 src/msgcache.c; cvs diff -u -r 1.5 -r 1.6 src/msgcache.h; ) > 1.9.6cvs11.patchset
 ( cvs diff -u -r 1.12.2.20 -r 1.12.2.21 src/action.c; cvs diff -u -r 1.5.10.7 -r 1.5.10.8 src/addrgather.c; cvs diff -u -r 1.6.10.4 -r 1.6.10.5 src/addrharvest.c; cvs diff -u -r 1.2.4.5 -r 1.2.4.6 src/browseldap.c; cvs diff -u -r 1.382.2.114 -r 1.382.2.115 src/compose.c; cvs diff -u -r 1.3.2.7 -r 1.3.2.8 src/exphtmldlg.c; cvs diff -u -r 1.1.4.9 -r 1.1.4.10 src/expldifdlg.c; cvs diff -u -r 1.12.2.6 -r 1.12.2.7 src/html.c; cvs diff -u -r 1.3.2.1 -r 1.3.2.2 src/html.h; cvs diff -u -r 1.4.12.4 -r 1.4.12.5 src/importmutt.c; cvs diff -u -r 1.1.14.4 -r 1.1.14.5 src/importpine.c; cvs diff -u -r 1.115.2.30 -r 1.115.2.31 src/main.c; cvs diff -u -r 1.274.2.32 -r 1.274.2.33 src/mainwindow.c; cvs diff -u -r 1.94.2.48 -r 1.94.2.49 src/messageview.c; cvs diff -u -r 1.204.2.33 -r 1.204.2.34 src/prefs_common.c; cvs diff -u -r 1.103.2.13 -r 1.103.2.14 src/prefs_common.h; cvs diff -u -r 1.47.2.17 -r 1.47.2.18 src/procheader.c; cvs diff -u -r 1.395.2.61 -r 1.395.2.62 src/summaryview.c; cvs diff -u -r 1.68.2.6 -r 1.68.2.7 src/summaryview.h; cvs diff -u -r 1.96.2.50 -r 1.96.2.51 src/textview.c; cvs diff -u -r 1.36.2.26 -r 1.36.2.27 src/common/utils.c; cvs diff -u -r 1.5.2.10 -r 1.5.2.11 src/gtk/gtkutils.c; cvs diff -u -r 1.4.2.8 -r 1.4.2.9 src/gtk/gtkutils.h; cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/plugins/pgpmime/passphrase.c; ) > 1.9.6cvs12.patchset
 ( cvs diff -u -r 1.13.2.10 -r 1.13.2.11 src/common/socket.c; ) > 1.9.6cvs13.patchset
+( cvs diff -u -r 1.20.2.14 -r 1.20.2.15 src/common/utils.h; cvs diff -u -r 1.36.2.27 -r 1.36.2.28 src/common/utils.c; cvs diff -u -r 1.9.2.10 -r 1.9.2.11 src/common/defs.h; cvs diff -u -r 1.75.2.5 -r 1.75.2.6 src/matcher.c; cvs diff -u -r 1.16.2.15 -r 1.16.2.16 src/msgcache.c; cvs diff -u -r 1.101.2.9 -r 1.101.2.10 src/news.c; cvs diff -u -r 1.150.2.21 -r 1.150.2.22 src/procmsg.c; cvs diff -u -r 1.60.2.10 -r 1.60.2.11 src/procmsg.h; cvs diff -u -r 1.22.2.7 -r 1.22.2.8 src/quote_fmt_parse.y; cvs diff -u -r 1.395.2.62 -r 1.395.2.63 src/summaryview.c; ) > 1.9.6cvs14.patchset
index 719785d09975288e0748ed54c2fc559b4b3633d5..a4c29545c79ade5bd1e9954067d916bcacde3152 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=13
+EXTRA_VERSION=14
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 08e874b5a0b64147726aa4b5b5a30c7d29b16d6f..c4cff97e854c6724aa2cb9d4dba89af4954f9a8f 100644 (file)
@@ -77,7 +77,7 @@
 #define FOLDER_LIST            "folderlist.xml"
 #define CACHE_FILE             ".sylpheed_claws_cache"
 #define MARK_FILE              ".sylpheed_mark"
-#define CACHE_VERSION          23
+#define CACHE_VERSION          24
 #define MARK_VERSION           2
 
 #define DEFAULT_SIGNATURE      ".signature"
index c55f5d9d0dfc741a3f53432435f1b952c4054668..cc6c0f654fd2fadf24ea5894ce2fa6569ebb4be6 100644 (file)
@@ -917,7 +917,7 @@ GSList *address_list_append_with_comments(GSList *addr_list, const gchar *str)
        return address_list_append_real(addr_list, str, FALSE);
 }
 
-GSList *references_list_append(GSList *msgid_list, const gchar *str)
+GSList *references_list_prepend(GSList *msgid_list, const gchar *str)
 {
        const gchar *strp;
 
@@ -937,7 +937,7 @@ GSList *references_list_append(GSList *msgid_list, const gchar *str)
                msgid = g_strndup(start + 1, end - start - 1);
                g_strstrip(msgid);
                if (*msgid)
-                       msgid_list = g_slist_append(msgid_list, msgid);
+                       msgid_list = g_slist_prepend(msgid_list, msgid);
                else
                        g_free(msgid);
 
@@ -947,6 +947,17 @@ GSList *references_list_append(GSList *msgid_list, const gchar *str)
        return msgid_list;
 }
 
+GSList *references_list_append(GSList *msgid_list, const gchar *str)
+{
+       GSList *list;
+
+       list = references_list_prepend(NULL, str);
+       list = g_slist_reverse(list);
+       msgid_list = g_slist_concat(msgid_list, list);
+
+       return msgid_list;
+}
+
 GSList *newsgroup_list_append(GSList *group_list, const gchar *str)
 {
        gchar *work;
index a0bc8712f155d4da762c6204608773aa98a0c55c..b585cba91799c8ac1f2826256fbf15e3ec35c511 100644 (file)
@@ -295,6 +295,8 @@ GSList *address_list_append         (GSList         *addr_list,
                                         const gchar    *str);
 GSList *address_list_append_with_comments(GSList       *addr_list,
                                         const gchar    *str);
+GSList *references_list_prepend                (GSList         *msgid_list,
+                                        const gchar    *str);
 GSList *references_list_append         (GSList         *msgid_list,
                                         const gchar    *str);
 GSList *newsgroup_list_append          (GSList         *group_list,
index d116a93f15d79e5c7531f50450a26b216ad116c2..95c034a4ba792b8c9637254c08238a31f3011703 100644 (file)
@@ -508,10 +508,12 @@ gboolean matcherprop_match(MatcherProp *prop,
                return matcherprop_string_match(prop, info->inreplyto);
        case MATCHCRITERIA_NOT_INREPLYTO:
                return !matcherprop_string_match(prop, info->inreplyto);
-       case MATCHCRITERIA_REFERENCES:
-               return matcherprop_string_match(prop, info->references);
+       /* FIXME: Using inreplyto, but matching the (newly implemented)
+         * list of references is better */
+        case MATCHCRITERIA_REFERENCES:
+               return matcherprop_string_match(prop, info->inreplyto);
        case MATCHCRITERIA_NOT_REFERENCES:
-               return !matcherprop_string_match(prop, info->references);
+               return !matcherprop_string_match(prop, info->inreplyto);
        case MATCHCRITERIA_TEST:
                return matcherprop_match_test(prop, info);
        case MATCHCRITERIA_NOT_TEST:
@@ -1273,7 +1275,8 @@ gchar *matching_build_command(const gchar *cmd, MsgInfo *info)
                                size += STRLEN_DEFAULT(info->newsgroups, no_newsgroups) - 2;
                                break;
                        case 'r': /* references */
-                               size += STRLEN_DEFAULT(info->references, no_references) - 2;
+                                /* FIXME: using the inreplyto header for reference */
+                               size += STRLEN_DEFAULT(info->inreplyto, no_references) - 2;
                                break;
                        case 'F': /* file */
                                if (filename == NULL)
@@ -1337,8 +1340,8 @@ gchar *matching_build_command(const gchar *cmd, MsgInfo *info)
                                                no_newsgroups);
                                break;
                        case 'r': /* references */
-                               add_str_default(&p, info->references,
-                                               no_references);
+                                /* FIXME: using the inreplyto header for references */
+                               add_str_default(&p, info->inreplyto, no_references);
                                break;
                        case 'F': /* file */
                                if (filename != NULL)
index 6c51394352546aa1443578f877054af0ee84a384..0fde240719a494af9ae8dd90f0859a44857f6017 100644 (file)
@@ -270,7 +270,7 @@ gint msgcache_get_memory_usage(MsgCache *cache)
        } \
 }
 
-static FILE *msgcache_open_data_file(const gchar *file, gint version,
+static FILE *msgcache_open_data_file(const gchar *file, guint version,
                                     DataOpenMode mode,
                                     gchar *buf, size_t buf_size)
 {
@@ -293,14 +293,14 @@ static FILE *msgcache_open_data_file(const gchar *file, gint version,
 
        /* check version */
        if ((fp = fopen(file, "rb")) == NULL)
-               debug_print("Mark/Cache file not found\n");
+               debug_print("Mark/Cache file '%s' not found\n", file);
        else {
                if (buf && buf_size > 0)
                        setvbuf(fp, buf, _IOFBF, buf_size);
                if (fread(&data_ver, sizeof(data_ver), 1, fp) != 1 ||
                         version != data_ver) {
-                       debug_print("Mark/Cache version is different (%d != %d). "
-                                   "Discarding it.\n", data_ver, version);
+                       g_message("%s: Mark/Cache version is different (%u != %u). Discarding it.\n",
+                                 file, data_ver, version);
                        fclose(fp);
                        fp = NULL;
                }
@@ -391,6 +391,7 @@ MsgCache *msgcache_read_cache(FolderItem *item, const gchar *cache_file)
        MsgTmpFlags tmp_flags = 0;
        gchar file_buf[BUFFSIZE];
        guint32 num;
+        guint refnum;
        gboolean error = FALSE;
        StringConverter *conv = NULL;
        gchar *srccharset = NULL;
@@ -462,11 +463,22 @@ MsgCache *msgcache_read_cache(FolderItem *item, const gchar *cache_file)
                READ_CACHE_DATA(msginfo->subject, fp);
                READ_CACHE_DATA(msginfo->msgid, fp);
                READ_CACHE_DATA(msginfo->inreplyto, fp);
-               READ_CACHE_DATA(msginfo->references, fp);
                READ_CACHE_DATA(msginfo->xref, fp);
                READ_CACHE_DATA_INT(msginfo->planned_download, fp);
                READ_CACHE_DATA_INT(msginfo->total_size, fp);
 
+               READ_CACHE_DATA_INT(refnum, fp);
+               for (; refnum != 0; refnum--) {
+                       gchar *ref;
+
+                       READ_CACHE_DATA(ref, fp);
+                       msginfo->references =
+                               g_slist_prepend(msginfo->references, ref);
+               }
+               if (msginfo->references)
+                       msginfo->references =
+                               g_slist_reverse(msginfo->references);
+
                msginfo->folder = item;
                msginfo->flags.tmp_flags |= tmp_flags;
 
@@ -523,6 +535,7 @@ void msgcache_read_mark(MsgCache *cache, const gchar *mark_file)
 void msgcache_write_cache(MsgInfo *msginfo, FILE *fp)
 {
        MsgTmpFlags flags = msginfo->flags.tmp_flags & MSG_CACHED_FLAG_MASK;
+       GSList *cur;
 
        WRITE_CACHE_DATA_INT(msginfo->msgnum, fp);
        WRITE_CACHE_DATA_INT(msginfo->size, fp);
@@ -540,10 +553,14 @@ void msgcache_write_cache(MsgInfo *msginfo, FILE *fp)
        WRITE_CACHE_DATA(msginfo->subject, fp);
        WRITE_CACHE_DATA(msginfo->msgid, fp);
        WRITE_CACHE_DATA(msginfo->inreplyto, fp);
-       WRITE_CACHE_DATA(msginfo->references, fp);
        WRITE_CACHE_DATA(msginfo->xref, fp);
        WRITE_CACHE_DATA_INT(msginfo->planned_download, fp);
        WRITE_CACHE_DATA_INT(msginfo->total_size, fp);
+        
+       WRITE_CACHE_DATA_INT(g_slist_length(msginfo->references), fp);
+       for (cur = msginfo->references; cur != NULL; cur = cur->next) {
+               WRITE_CACHE_DATA((gchar *)cur->data, fp);
+       }
 }
 
 static void msgcache_write_flags(MsgInfo *msginfo, FILE *fp)
index ea361dceb25b460d8b12586a9b1cfae6b59227c2..c15da46ffc8c929174572b35269aa93b69ddc70f 100644 (file)
@@ -652,19 +652,27 @@ static MsgInfo *news_parse_xover(const gchar *xover_str)
 
         msginfo->subject = conv_unmime_header(subject, NULL);
 
-       extract_parenthesis(msgid, '<', '>');
-       remove_space(msgid);
-       if (*msgid != '\0')
-               msginfo->msgid = g_strdup(msgid);
-
-       msginfo->references = g_strdup(ref);
-       eliminate_parenthesis(ref, '(', ')');
-       if ((p = strrchr(ref, '<')) != NULL) {
-               extract_parenthesis(p, '<', '>');
-               remove_space(p);
-               if (*p != '\0')
-                       msginfo->inreplyto = g_strdup(p);
-       }
+        if (msgid) {
+                extract_parenthesis(msgid, '<', '>');
+                remove_space(msgid);
+                if (*msgid != '\0')
+                        msginfo->msgid = g_strdup(msgid);
+        }                        
+
+        /* FIXME: this is a quick fix; references' meaning was changed
+         * into having the actual list of references in the References: header.
+         * We need a GSList here, so msginfo_free() and msginfo_copy() can do 
+         * their things properly. */ 
+        if (ref) {         
+                msginfo->references = g_slist_append(msginfo->references, g_strdup(ref)); 
+                eliminate_parenthesis(ref, '(', ')');
+                if ((p = strrchr(ref, '<')) != NULL) {
+                        extract_parenthesis(p, '<', '>');
+                        remove_space(p);
+                        if (*p != '\0')
+                                msginfo->inreplyto = g_strdup(p);
+                }
+        }                
 
        /*
        msginfo->xref = g_strdup(xref);
index 38030e729401f9d9bca8dce3ed86f9fc59bae89f..a77a50066d2ac718fd475c7d2ecc07f21eb290a9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 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
@@ -223,6 +223,7 @@ GNode *procmsg_get_thread_tree(GSList *mlist)
        GRelation *subject_relation;
        MsgInfo *msginfo;
        const gchar *msgid;
+        GSList *reflist;
 
        root = g_node_new(NULL);
        msgid_table = g_hash_table_new(g_str_hash, g_str_equal);
@@ -253,20 +254,31 @@ GNode *procmsg_get_thread_tree(GSList *mlist)
 
        /* complete the unfinished threads */
        for (node = root->children; node != NULL; ) {
-               parent = NULL;
                next = node->next;
                msginfo = (MsgInfo *)node->data;
-               if (msginfo->inreplyto) { 
+               parent = NULL;
+               
+                if (msginfo->inreplyto)
                        parent = g_hash_table_lookup(msgid_table, msginfo->inreplyto);
-                       /* node should not be the parent, and node should not 
-                          be an ancestor of parent (circular reference) */
-                       if (parent && parent != node && 
-                           !g_node_is_ancestor(node, parent)) {
-                               g_node_unlink(node);
-                               g_node_insert_before
-                                       (parent, parent->children, node);
-                       }                               
+
+               /* try looking for the indirect parent */
+               if (!parent && msginfo->references) {
+                       for (reflist = msginfo->references;
+                            reflist != NULL; reflist = reflist->next)
+                               if ((parent = g_hash_table_lookup
+                                       (msgid_table, reflist->data)) != NULL)
+                                       break;
+                }                                        
+              
+               /* node should not be the parent, and node should not
+                  be an ancestor of parent (circular reference) */
+               if (parent && parent != node &&
+                   !g_node_is_ancestor(node, parent)) {
+                       g_node_unlink(node);
+                       g_node_insert_before
+                               (parent, parent->children, node);
                }
+               
                node = next;
        }
 
@@ -840,6 +852,7 @@ MsgInfo *procmsg_msginfo_new(void)
 MsgInfo *procmsg_msginfo_copy(MsgInfo *msginfo)
 {
        MsgInfo *newmsginfo;
+        GSList *refs;
 
        if (msginfo == NULL) return NULL;
 
@@ -876,7 +889,13 @@ MsgInfo *procmsg_msginfo_copy(MsgInfo *msginfo)
        MEMBDUP(xface);
        MEMBDUP(dispositionnotificationto);
        MEMBDUP(returnreceiptto);
-       MEMBDUP(references);
+
+        refs = msginfo->references;
+        for (refs = msginfo->references; refs != NULL; refs = refs->next) {
+                newmsginfo->references = g_slist_prepend
+                        (newmsginfo->references, g_strdup(refs->data)); 
+        }
+        newmsginfo->references = g_slist_reverse(newmsginfo->references);
 
        MEMBCOPY(score);
        MEMBCOPY(threadscore);
@@ -946,7 +965,6 @@ void procmsg_msginfo_free(MsgInfo *msginfo)
        }
 
        g_free(msginfo->fromspace);
-       g_free(msginfo->references);
        g_free(msginfo->returnreceiptto);
        g_free(msginfo->dispositionnotificationto);
        g_free(msginfo->xface);
@@ -967,6 +985,9 @@ void procmsg_msginfo_free(MsgInfo *msginfo)
        g_free(msginfo->account_server);
        g_free(msginfo->account_login);
        
+       slist_free_strings(msginfo->references);
+       g_slist_free(msginfo->references);
+
        g_free(msginfo->plaintext_file);
 
        g_free(msginfo);
@@ -1001,8 +1022,11 @@ guint procmsg_msginfo_memusage(MsgInfo *msginfo)
                memusage += strlen(msginfo->dispositionnotificationto);
        if (msginfo->returnreceiptto)
                memusage += strlen(msginfo->returnreceiptto);
+#warning FIXME: Calculate size of references list                
+#if 0
        if (msginfo->references)
                memusage += strlen(msginfo->references);
+#endif                
        if (msginfo->fromspace)
                memusage += strlen(msginfo->fromspace);
 
index 7c6a8b2c4199b5d62ff9b4f961c2a2cc5db803c4..8cc8fd9c3d0c2edc3366982681b0097000942f96 100644 (file)
@@ -195,7 +195,7 @@ struct _MsgInfo
        gchar *dispositionnotificationto;
        gchar *returnreceiptto;
 
-       gchar *references;
+       GSList *references;
        gchar *fromspace;
 
        gint score;
index 2d951e40d561670e85302cdde6eff2ab9a2f6b1b..29f6dd7e308cba659b13cf61c57bb758748ad0b3 100644 (file)
@@ -512,6 +512,7 @@ special:
        }
        | SHOW_REFERENCES
        {
+                /* CLAWS: use in reply to header */
                /* if (msginfo->references)
                        INSERT(msginfo->references); */
        }
@@ -631,6 +632,7 @@ query:
        }
        | QUERY_REFERENCES
        {
+                /* CLAWS: use in-reply-to header */
                /* add_visibility(msginfo->references != NULL); */
        }
        OPARENT quote_fmt CPARENT
index 3e8ba50590ec17d73a9980291c7026270cb93aa0..beb714f766f2e653c4fb29c619e24755c5f69f6a 100644 (file)
@@ -3663,6 +3663,7 @@ void summary_thread_build(SummaryView *summaryview)
        GtkCTreeNode *next;
        GtkCTreeNode *parent;
        MsgInfo *msginfo;
+        GSList *reflist;
 
        summary_lock(summaryview);
 
@@ -3682,12 +3683,18 @@ void summary_thread_build(SummaryView *summaryview)
 
                parent = NULL;
 
-               /* alfons - claws seems to prefer subject threading before
-                * inreplyto threading. we should look more deeply in this,
-                * because inreplyto should have precedence... */
                if (msginfo && msginfo->inreplyto) {
                        parent = g_hash_table_lookup(summaryview->msgid_table,
                                                     msginfo->inreplyto);
+                                                     
+                       if (!parent && msginfo->references) {
+                               for (reflist = msginfo->references;
+                                    reflist != NULL; reflist = reflist->next)
+                                       if ((parent = g_hash_table_lookup
+                                               (summaryview->msgid_table,
+                                                reflist->data)))
+                                               break;
+                       }
                }
 
                if (prefs_common.thread_by_subject && parent == NULL) {