From 877b16da4a494077b72a1e03c62a481151aa80c1 Mon Sep 17 00:00:00 2001 From: hiro Date: Tue, 29 Mar 2005 04:40:26 +0000 Subject: modified message threading. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@191 ee746299-78ed-0310-b773-934348b2243d --- src/procheader.c | 25 ++++++++++++------------- src/procmsg.c | 24 +++++++++--------------- 2 files changed, 21 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/procheader.c b/src/procheader.c index 62047aa5..eff43f48 100644 --- a/src/procheader.c +++ b/src/procheader.c @@ -503,7 +503,6 @@ MsgInfo *procheader_parse_stream(FILE *fp, MsgFlags flags, gboolean full) MsgInfo *msginfo; gchar buf[BUFFSIZE]; - gchar *reference = NULL; gchar *p, *q; gchar *hp; HeaderEntry *hentry; @@ -571,19 +570,17 @@ MsgInfo *procheader_parse_stream(FILE *fp, MsgFlags flags, gboolean full) msginfo->references = references_list_prepend(msginfo->references, hp); - if (msginfo->references && !reference) - reference = g_strdup((gchar *)msginfo->references->data); break; case H_IN_REPLY_TO: - if (!reference) { - eliminate_parenthesis(hp, '(', ')'); - if ((p = strrchr(hp, '<')) != NULL && - strchr(p + 1, '>') != NULL) { - extract_parenthesis(p, '<', '>'); - remove_space(p); - if (*p != '\0') - reference = g_strdup(p); - } + if (msginfo->inreplyto) break; + + eliminate_parenthesis(hp, '(', ')'); + if ((p = strrchr(hp, '<')) != NULL && + strchr(p + 1, '>') != NULL) { + extract_parenthesis(p, '<', '>'); + remove_space(p); + if (*p != '\0') + msginfo->inreplyto = g_strdup(p); } break; case H_CONTENT_TYPE: @@ -633,7 +630,9 @@ MsgInfo *procheader_parse_stream(FILE *fp, MsgFlags flags, gboolean full) g_free(cc); } - msginfo->inreplyto = reference; + if (!msginfo->inreplyto && msginfo->references) + msginfo->inreplyto = + g_strdup((gchar *)msginfo->references->data); g_free(charset); diff --git a/src/procmsg.c b/src/procmsg.c index 4ff70aec..1a12f096 100644 --- a/src/procmsg.c +++ b/src/procmsg.c @@ -695,14 +695,14 @@ static FILE *procmsg_open_data_file(const gchar *file, guint 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) { - g_message("Mark/Cache version is different (%u != %u). " - "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; } @@ -779,22 +779,15 @@ GNode *procmsg_get_thread_tree(GSList *mlist) for (; mlist != NULL; mlist = mlist->next) { msginfo = (MsgInfo *)mlist->data; - parent = NULL; + parent = root; - if (msginfo->inreplyto) + /* only look for the real parent first */ + if (msginfo->inreplyto) { parent = g_hash_table_lookup(table, msginfo->inreplyto); - - if (!parent && msginfo->references) { - for (reflist = msginfo->references; - reflist != NULL; reflist = reflist->next) - if ((parent = g_hash_table_lookup - (table, reflist->data)) != NULL) - break; + if (parent == NULL) + parent = root; } - if (parent == NULL) - parent = root; - node = g_node_insert_data_before (parent, parent == root ? parent->children : NULL, msginfo); @@ -812,6 +805,7 @@ GNode *procmsg_get_thread_tree(GSList *mlist) if (msginfo->inreplyto) parent = g_hash_table_lookup(table, msginfo->inreplyto); + /* try looking for the indirect parent */ if (!parent && msginfo->references) { for (reflist = msginfo->references; reflist != NULL; reflist = reflist->next) -- cgit v1.2.3