2007-08-09 [colin] 2.10.0cvs109
[claws.git] / src / folder.c
index 5ed9790d58ce2c4d6a12cd17ef077ea3bff48e24..8e06c7a6a34aa5b7ae48b6ceabd006d4748a4fee 100644 (file)
@@ -2094,6 +2094,9 @@ gint folder_item_scan_full(FolderItem *item, gboolean filtering)
                if (!MSG_IS_IGNORE_THREAD(msginfo->flags) && procmsg_msg_has_flagged_parent(msginfo, MSG_IGNORE_THREAD)) {
                        procmsg_msginfo_change_flags(msginfo, MSG_IGNORE_THREAD, 0, MSG_NEW | MSG_UNREAD, 0);
                }
+               if (!MSG_IS_WATCH_THREAD(msginfo->flags) && procmsg_msg_has_flagged_parent(msginfo, MSG_WATCH_THREAD)) {
+                       procmsg_msginfo_set_flags(msginfo, MSG_WATCH_THREAD, 0);
+               }
                if(prefs_common.thread_by_subject && !msginfo->inreplyto &&
                        !msginfo->references && !MSG_IS_IGNORE_THREAD(msginfo->flags) &&
                        (parent_msginfo = subject_table_lookup(subject_table, msginfo->subject)))
@@ -2685,10 +2688,27 @@ static gint folder_item_get_msg_num_by_file(FolderItem *dest, const gchar *file)
 
        if ((folder_has_parent_of_type(dest, F_QUEUE)) || 
            (folder_has_parent_of_type(dest, F_DRAFT)))
-               while (fgets(buf, sizeof(buf), fp) != NULL)
+               while (fgets(buf, sizeof(buf), fp) != NULL) {
+                       /* new way */
+                       if ((!strncmp(buf, "X-Claws-End-Special-Headers: 1",
+                               strlen("X-Claws-End-Special-Headers:"))) ||
+                           (!strncmp(buf, "X-Sylpheed-End-Special-Headers: 1",
+                               strlen("X-Sylpheed-End-Special-Headers:"))))
+                               break;
+                       /* old way */
                        if (buf[0] == '\r' || buf[0] == '\n') break;
+                       /* from other mailers */
+                       if (!strncmp(buf, "Date: ", 6)
+                       ||  !strncmp(buf, "To: ", 4)
+                       ||  !strncmp(buf, "From: ", 6)
+                       ||  !strncmp(buf, "Subject: ", 9)) {
+                               rewind(fp);
+                               break;
+                       }
+               }
 
        procheader_get_header_fields(fp, hentry);
+       debug_print("looking for %s\n", hentry[0].body);
        if (hentry[0].body) {
                extract_parenthesis(hentry[0].body, '<', '>');
                remove_space(hentry[0].body);
@@ -2733,6 +2753,9 @@ static void copy_msginfo_flags(MsgInfo *source, MsgInfo *dest)
        if (procmsg_msg_has_flagged_parent(dest, MSG_IGNORE_THREAD))
                perm_flags |= MSG_IGNORE_THREAD;
 
+       if (procmsg_msg_has_flagged_parent(dest, MSG_WATCH_THREAD))
+               perm_flags |= MSG_WATCH_THREAD;
+
        /* Unset tmp flags that should not be copied */
        tmp_flags &= ~(MSG_MOVE | MSG_COPY | MSG_MOVE_DONE);
 
@@ -2875,6 +2898,7 @@ gint folder_item_add_msgs(FolderItem *dest, GSList *file_list,
                                        folderscan = TRUE;
                                }
                                num = folder_item_get_msg_num_by_file(dest, fileinfo->file);
+                               debug_print("got num %d\n", num);
                        }
 
                        if (num > lastnum)
@@ -3553,7 +3577,12 @@ static gchar *folder_item_get_tags_file(FolderItem *item)
 
        identifier = folder_item_get_identifier(item);
        g_return_val_if_fail(identifier != NULL, NULL);
-       
+
+#ifdef G_OS_WIN32
+       while (strchr(identifier, '/'))
+               *strchr(identifier, '/') = '\\';
+#endif
+
        path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
                           "tagsdb", G_DIR_SEPARATOR_S,
                           identifier, NULL);
@@ -3998,7 +4027,7 @@ void folder_item_apply_processing(FolderItem *item)
                 /* apply post global rules */
                filter_message_by_msginfo(post_global_processing, msginfo, NULL,
                                FILTERING_POST_PROCESSING, NULL);
-               if (curmsg % 10 == 0)
+               if (curmsg % 1000 == 0)
                        GTK_EVENTS_FLUSH();
        }
        prefs_common.apply_per_account_filtering_rules = last_apply_per_account;