2007-08-17 [colin] 2.10.0cvs128
[claws.git] / src / folder.c
index 5ed9790d58ce2c4d6a12cd17ef077ea3bff48e24..85eb5654ada5463aabc5bb89d95dea6867ae9509 100644 (file)
@@ -1788,7 +1788,6 @@ static gint syncronize_flags(FolderItem *item, MsgInfoList *msglist)
 
        relation = g_relation_new(2);
        g_relation_index(relation, 0, g_direct_hash, g_direct_equal);
-       folder_item_set_batch(item, TRUE);
        if ((ret = item->folder->klass->get_flags(
            item->folder, item, msglist, relation)) == 0) {
                GTuples *tuples;
@@ -1797,6 +1796,7 @@ static gint syncronize_flags(FolderItem *item, MsgInfoList *msglist)
                gboolean skip;
 
                folder_item_update_freeze();
+               folder_item_set_batch(item, TRUE);
                for (cur = msglist; cur != NULL; cur = g_slist_next(cur)) {
                        msginfo = (MsgInfo *) cur->data;
                
@@ -1814,9 +1814,9 @@ static gint syncronize_flags(FolderItem *item, MsgInfoList *msglist)
                                        ~permflags & msginfo->flags.perm_flags, 0);
                        }
                }
+               folder_item_set_batch(item, FALSE);
                folder_item_update_thaw();
        }
-       folder_item_set_batch(item, FALSE);
        g_relation_destroy(relation);   
 
        return ret;
@@ -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;