+2006-02-06 [colin] 2.0.0cvs21
+
+ * src/imap.c
+ Put the added file directly to cache if possible (will work
+ with next libetpan)
+ * src/filtering.c
+ * src/filtering.h
+ * src/inc.c
+ * src/folder.c
+ * src/mbox.c
+ Move and copy filtered messages by batches instead of one
+ by one - faster on IMAP
+ * src/procmsg.c
+ Add a function that'll possibly be useful later
+
2006-02-06 [colin] 2.0.0cvs20
* src/addressbook.c
( cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/gtk/icon_legend.c; ) > 2.0.0cvs18.patchset
( cvs diff -u -r 1.34.2.16 -r 1.34.2.17 po/it.po; ) > 2.0.0cvs19.patchset
( cvs diff -u -r 1.60.2.47 -r 1.60.2.48 src/addressbook.c; cvs diff -u -r 1.382.2.234 -r 1.382.2.235 src/compose.c; cvs diff -u -r 1.207.2.87 -r 1.207.2.88 src/folderview.c; cvs diff -u -r 1.20.2.10 -r 1.20.2.11 src/folderview.h; cvs diff -u -r 1.8.2.14 -r 1.8.2.15 src/headerview.c; cvs diff -u -r 1.96.2.93 -r 1.96.2.94 src/textview.c; cvs diff -u -r 1.83.2.63 -r 1.83.2.64 src/mimeview.c; cvs diff -u -r 1.1.2.10 -r 1.1.2.11 src/prefs_message.c; cvs diff -u -r 1.395.2.163 -r 1.395.2.164 src/summaryview.c; cvs diff -u -r 1.5.2.19 -r 1.5.2.20 src/gtk/gtkutils.c; cvs diff -u -r 1.4.2.16 -r 1.4.2.17 src/gtk/gtkutils.h; ) > 2.0.0cvs20.patchset
+( cvs diff -u -r 1.179.2.91 -r 1.179.2.92 src/imap.c; cvs diff -u -r 1.60.2.9 -r 1.60.2.10 src/filtering.c; cvs diff -u -r 1.21.2.4 -r 1.21.2.5 src/filtering.h; cvs diff -u -r 1.149.2.42 -r 1.149.2.43 src/inc.c; cvs diff -u -r 1.213.2.78 -r 1.213.2.79 src/folder.c; cvs diff -u -r 1.28.2.12 -r 1.28.2.13 src/mbox.c; cvs diff -u -r 1.150.2.50 -r 1.150.2.51 src/procmsg.c; ) > 2.0.0cvs21.patchset
MICRO_VERSION=0
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=20
+EXTRA_VERSION=21
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
g_free(prop);
}
+/* move and copy messages by batches to be faster on IMAP */
+void filtering_move_and_copy_msgs(GSList *msgs)
+{
+ GSList *messages = g_slist_copy(msgs);
+ FolderItem *last_item = NULL;
+ gboolean is_copy = FALSE, is_move = FALSE;
+
+ while (messages) {
+ GSList *batch = NULL, *cur;
+ gint found = 0;
+ debug_print("%d messages to filter\n", g_slist_length(messages));
+ for (cur = messages; cur; cur = cur->next) {
+ MsgInfo *info = (MsgInfo *)cur->data;
+ if (last_item == NULL) {
+ last_item = info->to_folder;
+ }
+ if (last_item == NULL)
+ continue;
+ debug_print("for %s\n", folder_item_get_path(last_item));
+ if (!is_copy && !is_move) {
+ if (info->is_copy)
+ is_copy = TRUE;
+ else if (info->is_move)
+ is_move = TRUE;
+ }
+ found++;
+ if (info->to_folder == last_item
+ && info->is_copy == is_copy
+ && info->is_move == is_move) {
+ batch = g_slist_append(batch, info);
+ }
+ }
+ if (found == 0) {
+ debug_print("no more messages to move/copy\n");
+ break;
+ }
+ for (cur = batch; cur; cur = cur->next) {
+ MsgInfo *info = (MsgInfo *)cur->data;
+ messages = g_slist_remove(messages, info);
+ }
+ if (g_slist_length(batch)) {
+ debug_print("%s %d messages to %s\n",
+ is_copy?"copying":"moving",
+ g_slist_length(batch),
+ folder_item_get_path(last_item));
+ if (is_copy) {
+ folder_item_copy_msgs(last_item, batch);
+ } else if (is_move) {
+ if (folder_item_move_msgs(last_item, batch) < 0)
+ folder_item_move_msgs(
+ folder_get_default_inbox(),
+ batch);
+ }
+ /* we don't reference the msginfos, because caller will do */
+ g_slist_free(batch);
+ batch = NULL;
+ }
+ last_item = NULL;
+ is_copy = FALSE;
+ is_move = FALSE;
+ debug_print("%d messages remaining\n", g_slist_length(messages));
+ }
+ /* we don't reference the msginfos, because caller will do */
+ g_slist_free(messages);
+}
+
/*
fitleringaction_apply
runs the action on one MsgInfo
return FALSE;
}
- if (folder_item_move_msg(dest_folder, info) == -1) {
- debug_print("*** could not move message\n");
- return FALSE;
- }
-
+ /* mark message to be moved */
+ info->is_move = TRUE;
+ info->to_folder = dest_folder;
+ debug_print("set to move to %s\n", folder_item_get_path(dest_folder));
return TRUE;
case MATCHACTION_COPY:
return FALSE;
}
- if (folder_item_copy_msg(dest_folder, info) == -1)
- return FALSE;
-
+ /* mark message to be copied */
+ info->is_copy = TRUE;
+ info->to_folder = dest_folder;
+ debug_print("set to copy to %s\n", folder_item_get_path(dest_folder));
return TRUE;
case MATCHACTION_DELETE:
void prefs_filtering_free(GSList *prefs_filtering);
FilteringProp * filteringprop_copy(FilteringProp *src);
-
+void filtering_move_and_copy_msgs(GSList *msglist);
extern GSList * filtering_rules;
extern GSList * pre_global_processing;
extern GSList * post_global_processing;
folder_item_update_freeze();
if (newmsg_list != NULL) {
- GSList *elem;
+ GSList *elem, *to_filter = NULL;
int total = g_slist_length(newmsg_list), cur = 0;
if ((filtering == TRUE) &&
(item->folder->account != NULL) &&
(item->folder->account->filter_on_recv) &&
procmsg_msginfo_filter(msginfo))
- procmsg_msginfo_free(msginfo);
+ to_filter = g_slist_append(to_filter, msginfo);
else
exists_list = g_slist_prepend(exists_list, msginfo);
}
+ filtering_move_and_copy_msgs(to_filter);
+ for (elem = to_filter; elem; elem = g_slist_next(elem)) {
+ MsgInfo *msginfo = (MsgInfo *)elem->data;
+ procmsg_msginfo_free(msginfo);
+ }
+
+ g_slist_free(to_filter);
g_slist_free(newmsg_list);
statusbar_progress_all(0,0,0);
make_dir_hier(path);
filename = g_strconcat(path, G_DIR_SEPARATOR_S, itos(uid), NULL);
g_free(path);
-
+ debug_print("trying to fetch cached %s\n", filename);
if (is_file_exist(filename)) {
/* see whether the local file represents the whole message
* or not. As the IMAP server reports size with \r chars,
statusbar_progress_all(0,0,0);
statusbar_pop_all();
return -1;
+ } else {
+ debug_print("appended new message as %d\n", new_uid);
+ /* put the local file in the imapcache, so that we don't
+ * have to fetch it back later. */
+ if (new_uid > 0) {
+ gchar *cache_path = folder_item_get_path(dest);
+ if (!is_dir_exist(cache_path))
+ make_dir_hier(cache_path);
+ if (is_dir_exist(cache_path)) {
+ gchar *cache_file = g_strconcat(
+ cache_path, G_DIR_SEPARATOR_S,
+ itos(new_uid), NULL);
+ copy_file(real_file, cache_file, TRUE);
+ debug_print("copied to cache: %s\n", cache_file);
+ g_free(cache_file);
+ }
+ g_free(cache_path);
+ }
}
if (relation != NULL)
if (!pop3_session->ac_prefs->filter_on_recv ||
!procmsg_msginfo_filter(msginfo))
folder_item_move_msg(inbox, msginfo);
+ }
+ filtering_move_and_copy_msgs(msglist);
+ for(msglist_element = msglist; msglist_element != NULL;
+ msglist_element = msglist_element->next) {
+ MsgInfo *msginfo = (MsgInfo *)msglist_element->data;
procmsg_msginfo_free(msginfo);
}
folder_item_update_thaw();
gint lines;
MsgInfo *msginfo;
gboolean more;
+ GSList *to_filter = NULL, *cur;
g_return_val_if_fail(dest != NULL, -1);
g_return_val_if_fail(mbox != NULL, -1);
}
msginfo = folder_item_get_msginfo(dropfolder, msgnum);
- if (!apply_filter || !procmsg_msginfo_filter(msginfo))
+ if (!apply_filter || !procmsg_msginfo_filter(msginfo)) {
folder_item_move_msg(dest, msginfo);
- procmsg_msginfo_free(msginfo);
+ procmsg_msginfo_free(msginfo);
+ } else
+ to_filter = g_slist_append(to_filter, msginfo);
msgs++;
} while (more);
+ filtering_move_and_copy_msgs(to_filter);
+ for (cur = to_filter; cur; cur = g_slist_next(cur)) {
+ MsgInfo *info = (MsgInfo *)cur->data;
+ procmsg_msginfo_free(info);
+ }
+
folder_item_update_thaw();
g_free(tmp_file);
fclose(outfp);
fclose(fp);
return 0;
+}
+#if 0
+gchar *procmsg_add_special_headers(const gchar *in, FolderItem *item)
+{
+ gchar *out = get_tmp_file();
+ FILE *fp = NULL;
+ PrefsAccount *account = NULL;
+ if (out == NULL)
+ return NULL;
+
+ fp = fopen(out, "wb");
+ if (fp == NULL) {
+ g_free(out);
+ return NULL;
+ }
+
+ if (item && item->prefs && item->prefs->enable_default_account)
+ account = account_find_from_id(item->prefs->default_account);
+
+ if (!account) account = cur_account;
+ if (!account) {
+ fclose(fp);
+ g_free(out);
+ return NULL;
+ }
+
+ fprintf(fp, "X-Sylpheed-Account-Id:%d\n", account->account_id);
+ fprintf(fp, "S:%s\n", account->address);
+ if (item && item->prefs && item->prefs->save_copy_to_folder) {
+ gchar *folderidentifier;
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn), prefs_common.savemsg);
+ folderidentifier = folder_item_get_identifier(item);
+ fprintf(fp, "SCF:%s\n", folderidentifier);
+ g_free(folderidentifier);
+ } else if (account_get_special_folder(account, F_OUTBOX)) {
+ gchar *folderidentifier = folder_item_get_identifier(account_get_special_folder
+ (compose->account, F_OUTBOX));
+ fprintf(fp, "SCF:%s\n", folderidentifier);
+ g_free(folderidentifier);
+ }
+
+ fprintf(fp, "\n");
+ fclose(fp);
+ return out;
}
+#endif
gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
gboolean is_queued)
{