return fp;
}
+static GNode * subject_table_lookup(GHashTable * subject_table,
+ gchar * subject)
+{
+ if (subject == NULL)
+ subject = "";
+
+ if (g_strncasecmp(subject, "Re: ", 4) == 0)
+ return g_hash_table_lookup(subject_table, subject + 4);
+ else
+ return g_hash_table_lookup(subject_table, subject);
+}
+
+static void subject_table_insert(GHashTable * subject_table, gchar * subject,
+ GNode * node)
+{
+ if (subject == NULL)
+ subject = "";
+
+ if (g_strncasecmp(subject, "Re: ", 4) == 0)
+ g_hash_table_insert(subject_table, subject + 4, node);
+ else
+ g_hash_table_insert(subject_table, subject, node);
+}
+
/* return the reversed thread tree */
GNode *procmsg_get_thread_tree(GSList *mlist)
{
GNode *root, *parent, *node, *next;
- GHashTable *table;
+ GHashTable *msgid_table;
+ GHashTable *subject_table;
MsgInfo *msginfo;
const gchar *msgid;
+ const gchar *subject;
root = g_node_new(NULL);
- table = g_hash_table_new(g_str_hash, g_str_equal);
+ msgid_table = g_hash_table_new(g_str_hash, g_str_equal);
+ subject_table = g_hash_table_new(g_str_hash, g_str_equal);
for (; mlist != NULL; mlist = mlist->next) {
msginfo = (MsgInfo *)mlist->data;
parent = root;
if (msginfo->inreplyto) {
- parent = g_hash_table_lookup(table, msginfo->inreplyto);
+ parent = g_hash_table_lookup(msgid_table, msginfo->inreplyto);
if (parent == NULL) {
parent = root;
} else {
(parent, parent == root ? parent->children : NULL,
msginfo);
if ((msgid = msginfo->msgid) &&
- g_hash_table_lookup(table, msgid) == NULL)
- g_hash_table_insert(table, (gchar *)msgid, node);
+ g_hash_table_lookup(msgid_table, msgid) == NULL)
+ g_hash_table_insert(msgid_table, (gchar *)msgid, node);
+
+ subject = msginfo->subject;
+ if (subject_table_lookup(subject_table,
+ (gchar *) subject) == NULL)
+ subject_table_insert(subject_table, (gchar *)subject,
+ node);
}
/* complete the unfinished threads */
for (node = root->children; node != NULL; ) {
next = node->next;
msginfo = (MsgInfo *)node->data;
- if (msginfo->inreplyto) {
- parent = g_hash_table_lookup(table, msginfo->inreplyto);
- if (parent && parent != node) {
- g_node_unlink(node);
- g_node_insert_before
- (parent, parent->children, node);
- if(MSG_IS_IGNORE_THREAD(((MsgInfo *)parent->data)->flags)) {
- MSG_SET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
- }
+ parent = NULL;
+
+ if (msginfo->inreplyto)
+ parent = g_hash_table_lookup(msgid_table, msginfo->inreplyto);
+ if (parent == NULL)
+ parent = subject_table_lookup(subject_table, msginfo->subject);
+
+
+ if (parent && parent != node) {
+ g_node_unlink(node);
+ g_node_insert_before
+ (parent, parent->children, node);
+ if(MSG_IS_IGNORE_THREAD(((MsgInfo *)parent->data)->flags)) {
+ MSG_SET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
}
}
node = next;
}
- g_hash_table_destroy(table);
+ g_hash_table_destroy(subject_table);
+ g_hash_table_destroy(msgid_table);
return root;
}
static GtkCTreeNode * subject_table_lookup(GHashTable *subject_table,
gchar * subject)
{
+ if (subject == NULL)
+ subject = "";
+
if (g_strncasecmp(subject, "Re: ", 4) == 0)
return g_hash_table_lookup(subject_table, subject + 4);
else
static void subject_table_insert(GHashTable *subject_table, gchar * subject,
GtkCTreeNode * node)
{
+ if (subject == NULL)
+ subject = "";
+
if (g_strncasecmp(subject, "Re: ", 4) == 0)
g_hash_table_insert(subject_table, subject + 4, node);
else
g_hash_table_insert(subject_table, subject, node);
}
+static void subject_table_remove(GHashTable *subject_table, gchar * subject)
+{
+ if (subject == NULL)
+ subject = "";
+
+ if (g_strncasecmp(subject, "Re: ", 4) == 0)
+ g_hash_table_remove(subject_table, subject + 4);
+ else
+ g_hash_table_remove(subject_table, subject);
+}
+
static void summary_set_ctree_from_list(SummaryView *summaryview,
GSList *mlist)
{
if (msginfo->msgid)
g_hash_table_insert(msgid_table,
msginfo->msgid, node);
+
+ subject_table_insert(subject_table,
+ msginfo->subject,
+ node);
}
mlist = g_slist_reverse(mlist);
}
msginfo->msgid))
g_hash_table_remove(summaryview->msgid_table,
msginfo->msgid);
-
- if (msginfo->subject &&
- node == subject_table_lookup(summaryview->subject_table,
- msginfo->subject)) {
- gchar *s = msginfo->subject + (g_strncasecmp(msginfo->subject, "Re: ", 4) == 0 ? 4 : 0);
- g_hash_table_remove(summaryview->subject_table, s);
- }
}
}
msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
+ 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 && parent != node) {
- gtk_ctree_move(ctree, node, parent, NULL);
- gtk_ctree_expand(ctree, node);
- }
}
- else if (msginfo && msginfo->subject) {
- parent = g_hash_table_lookup
- (summaryview->subject_table, msginfo->subject);
- if (parent && parent != node) {
- gtk_ctree_move(ctree, node, parent, NULL);
- gtk_ctree_expand(ctree, node);
- }
+
+ if (parent == NULL) {
+ parent = subject_table_lookup
+ (summaryview->subject_table,
+ msginfo->subject);
+ }
+
+ if (parent && parent != node) {
+ gtk_ctree_move(ctree, node, parent, NULL);
+ gtk_ctree_expand(ctree, node);
}
node = next;