From: Thorsten Maerz Date: Thu, 2 Jan 2003 04:16:13 +0000 (+0000) Subject: detect loops across several messages X-Git-Tag: rel_0_8_9~125 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=11f7df887dda5285a029d1f3e1ff0d8577fff23d detect loops across several messages --- diff --git a/ChangeLog.claws b/ChangeLog.claws index 492316c92..88378f7c1 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,9 @@ +2003-01-02 [thorsten] 0.8.8claws37 + + * src/procmsg.c + detect loops across several messages + as suggested by Christoph Hohmann + 2003-01-01 [match] 0.8.8claws36 * src/addrindex.c diff --git a/configure.in b/configure.in index 766a8d790..a14a4a09d 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=8 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws36 +EXTRA_VERSION=claws37 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/procmsg.c b/src/procmsg.c index 6c7369b40..2c46273a8 100644 --- a/src/procmsg.c +++ b/src/procmsg.c @@ -1599,26 +1599,42 @@ void procmsg_msginfo_write_flags(MsgInfo *msginfo) g_free(destdir); } -gboolean procmsg_msg_has_flagged_parent(MsgInfo *info, MsgPermFlags perm_flags) +/*! + *\brief check for flags (e.g. mark) in prior msgs of current thread + * + *\param info Current message + *\param perm_flags Flags to be checked + *\param parentmsgs Hash of prior msgs to avoid loops + * + *\return gboolean TRUE if perm_flags are found + */ +gboolean procmsg_msg_has_flagged_parent_real(MsgInfo *info, + MsgPermFlags perm_flags, GHashTable *parentmsgs) { MsgInfo *tmp; g_return_val_if_fail(info != NULL, FALSE); if (info != NULL && info->folder != NULL && info->inreplyto != NULL) { - tmp = folder_item_get_msginfo_by_msgid(info->folder, info->inreplyto); + tmp = folder_item_get_msginfo_by_msgid(info->folder, + info->inreplyto); if (tmp && (tmp->flags.perm_flags & perm_flags)) { procmsg_msginfo_free(tmp); return TRUE; } else if (tmp != NULL) { gboolean result; - if (tmp->msgnum == info->msgnum) { - debug_print("LOOP: message %s%c%d references itself\n", - folder_item_get_path(info->folder), + + if (g_hash_table_lookup(parentmsgs, info)) { + debug_print("loop detected: %s%c%d\n", + folder_item_get_path(info->folder), G_DIR_SEPARATOR, info->msgnum); result = FALSE; - } else - result = procmsg_msg_has_flagged_parent(tmp, perm_flags); + } else { + g_hash_table_insert(parentmsgs, info, "1"); + procmsg_msg_has_flagged_parent_real(tmp, + perm_flags, parentmsgs); + result = TRUE; + } procmsg_msginfo_free(tmp); return result; } else { @@ -1628,10 +1644,40 @@ gboolean procmsg_msg_has_flagged_parent(MsgInfo *info, MsgPermFlags perm_flags) return FALSE; } +/*! + *\brief Callback for cleaning up hash of parentmsgs + */ +gboolean parentmsgs_hash_remove(gpointer key, + gpointer value, + gpointer user_data) +{ + return TRUE; +} + +/*! + *\brief Set up list of parentmsgs + * See procmsg_msg_has_flagged_parent_real() + */ +gboolean procmsg_msg_has_flagged_parent(MsgInfo *info, MsgPermFlags perm_flags) +{ + gboolean result; + GHashTable *parentmsgs = g_hash_table_new(NULL, NULL); + + result = procmsg_msg_has_flagged_parent_real(info, perm_flags, parentmsgs); + g_hash_table_foreach_remove(parentmsgs, parentmsgs_hash_remove, NULL); + g_hash_table_destroy(parentmsgs); + return result; +} + +/*! + *\brief Check if msgs prior in thread are marked + * See procmsg_msg_has_flagged_parent_real() + */ gboolean procmsg_msg_has_marked_parent(MsgInfo *info) { return procmsg_msg_has_flagged_parent(info, MSG_MARKED); -} +} + GSList *procmsg_find_children (MsgInfo *info) {