/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
if (!mlist) return;
+ folder_item_update_freeze();
+
for (cur = mlist; cur != NULL; cur = cur->next) {
msginfo = (MsgInfo *)cur->data;
if (!dest) {
dest = msginfo->to_folder;
movelist = g_slist_append(movelist, msginfo);
}
+ procmsg_msginfo_set_to_folder(msginfo, NULL);
}
if (movelist) {
folder_item_move_msgs_with_dest(dest, movelist);
g_slist_free(movelist);
}
+
+ folder_item_update_thaw();
}
void procmsg_copy_messages(GSList *mlist)
if (!mlist) return;
- /*
-
- Horrible: Scanning 2 times for every copy!
-
- hash = procmsg_to_folder_hash_table_create(mlist);
- folder_item_scan_foreach(hash);
- g_hash_table_destroy(hash);
- */
+ folder_item_update_freeze();
for (cur = mlist; cur != NULL; cur = cur->next) {
msginfo = (MsgInfo *)cur->data;
dest = msginfo->to_folder;
copylist = g_slist_append(copylist, msginfo);
}
+ procmsg_msginfo_set_to_folder(msginfo, NULL);
}
if (copylist) {
folder_item_copy_msgs_with_dest(dest, copylist);
g_slist_free(copylist);
}
+
+ folder_item_update_thaw();
}
gchar *procmsg_get_message_file_path(MsgInfo *msginfo)
}
if (MSG_IS_ENCRYPTED(msginfo->flags) &&
- !msginfo->plaintext_file &&
- !msginfo->decryption_failed) {
+ (!msginfo->plaintext_file || msginfo->decryption_failed)) {
rfc2015_decrypt_message(msginfo, mimeinfo_, fp);
if (msginfo->plaintext_file &&
!msginfo->decryption_failed) {
procmsg_msginfo_free(msginfo);
}
- folder_update_item(queue, FALSE);
-
return ret;
}
procmsg_msginfo_unset_flags(msginfo, ~0, 0);
procmsg_msginfo_free(msginfo);
}
+ folder_item_update(outbox, TRUE);
return 0;
}
full_msginfo->size = msginfo->size;
full_msginfo->mtime = msginfo->mtime;
full_msginfo->folder = msginfo->folder;
- full_msginfo->to_folder = msginfo->to_folder;
#if USE_GPGME
full_msginfo->plaintext_file = g_strdup(msginfo->plaintext_file);
full_msginfo->decryption_failed = msginfo->decryption_failed;
#endif
+ procmsg_msginfo_set_to_folder(full_msginfo, msginfo->to_folder);
return full_msginfo;
}
if (msginfo->refcnt > 0)
return;
+ if (msginfo->to_folder) {
+ msginfo->to_folder->op_count--;
+ folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
+ }
+
g_free(msginfo->fromspace);
g_free(msginfo->references);
g_free(msginfo->returnreceiptto);
Q_NEWS_ACCOUNT_ID = 5,
Q_SAVE_COPY_FOLDER = 6,
Q_REPLY_MESSAGE_ID = 7,
+ Q_FWD_MESSAGE_ID = 8
};
gint procmsg_send_message_queue(const gchar *file)
{"NAID:", NULL, FALSE},
{"SCF:", NULL, FALSE},
{"RMID:", NULL, FALSE},
+ {"FMID:", NULL, FALSE},
{NULL, NULL, FALSE}};
FILE *fp;
gint filepos;
GSList *newsgroup_list = NULL;
gchar *savecopyfolder = NULL;
gchar *replymessageid = NULL;
+ gchar *fwdmessageid = NULL;
gchar buf[BUFFSIZE];
gint hnum;
PrefsAccount *mailac = NULL, *newsac = NULL;
case Q_REPLY_MESSAGE_ID:
if (!replymessageid) replymessageid = g_strdup(p);
break;
+ case Q_FWD_MESSAGE_ID:
+ if (!fwdmessageid) fwdmessageid = g_strdup(p);
+ break;
}
}
filepos = ftell(fp);
}
if (mailval < 0) {
if (!local)
- alertpanel_error(
+ alertpanel_error_log(
_("Error occurred while sending the message to `%s'."),
mailac ? mailac->smtp_server : smtpserver);
else
- alertpanel_error(
+ alertpanel_error_log(
_("Error occurred while sending the message with command `%s'."),
(mailac && mailac->use_mail_command &&
mailac->mail_command && (*mailac->mail_command)) ?
procmsg_save_to_outbox(outbox, file, TRUE);
}
- if (replymessageid != NULL) {
+ if (replymessageid != NULL || fwdmessageid != NULL) {
gchar **tokens;
FolderItem *item;
- tokens = g_strsplit(replymessageid, "\x7f", 0);
+ if (replymessageid != NULL)
+ tokens = g_strsplit(replymessageid, "\x7f", 0);
+ else
+ tokens = g_strsplit(fwdmessageid, "\x7f", 0);
item = folder_find_item_from_identifier(tokens[0]);
if (item != NULL) {
MsgInfo *msginfo;
}
if (msginfo != NULL) {
- procmsg_msginfo_unset_flags(msginfo, MSG_FORWARDED, 0);
- procmsg_msginfo_set_flags(msginfo, MSG_REPLIED, 0);
-
+ if (replymessageid != NULL) {
+ procmsg_msginfo_unset_flags(msginfo, MSG_FORWARDED, 0);
+ procmsg_msginfo_set_flags(msginfo, MSG_REPLIED, 0);
+ }
+ else {
+ procmsg_msginfo_unset_flags(msginfo, MSG_REPLIED, 0);
+ procmsg_msginfo_set_flags(msginfo, MSG_FORWARDED, 0);
+ }
procmsg_msginfo_free(msginfo);
}
}
g_free(savecopyfolder);
g_free(replymessageid);
+ g_free(fwdmessageid);
return (newsval != 0 ? newsval : mailval);
}
if ((perm_flags & MSG_NEW) && !MSG_IS_NEW(msginfo->flags) &&
!MSG_IS_IGNORE_THREAD(msginfo->flags)) {
item->new++;
- item->need_update = TRUE;
}
/* if unread flag is set */
if ((perm_flags & MSG_UNREAD) && !MSG_IS_UNREAD(msginfo->flags) &&
!MSG_IS_IGNORE_THREAD(msginfo->flags)) {
item->unread++;
- item->need_update = TRUE;
}
if (!MSG_IS_UNREAD(msginfo->flags) &&(perm_flags & MSG_UNREAD)
&& procmsg_msg_has_marked_parent(msginfo)) {
item->unreadmarked++;
- item->need_update = TRUE;
}
if (!MSG_IS_MARKED(msginfo->flags) && (perm_flags & MSG_MARKED)) {
if ((perm_flags & MSG_IGNORE_THREAD) && !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
if (MSG_IS_NEW(msginfo->flags) || (perm_flags & MSG_NEW)) {
item->new--;
- item->need_update = TRUE;
}
if (MSG_IS_UNREAD(msginfo->flags) || (perm_flags & MSG_UNREAD)) {
item->unread--;
- item->need_update = TRUE;
}
if ((perm_flags & MSG_UNREAD) || (MSG_IS_UNREAD(msginfo->flags)
&& procmsg_msg_has_marked_parent(msginfo))) {
item->unreadmarked--;
- item->need_update = TRUE;
}
if ((perm_flags & MSG_MARKED) || (MSG_IS_MARKED(msginfo->flags)
&& !MSG_IS_IGNORE_THREAD(msginfo->flags))) {
msginfo_update.msginfo = msginfo;
hooks_invoke(MSGINFO_UPDATE_HOOKLIST, &msginfo_update);
+ folder_item_update(msginfo->folder, F_ITEM_UPDATE_MSGCNT);
CHANGE_FLAGS(msginfo);
procmsg_msginfo_write_flags(msginfo);
if ((perm_flags & MSG_NEW) && MSG_IS_NEW(msginfo->flags) &&
!MSG_IS_IGNORE_THREAD(msginfo->flags)) {
item->new--;
- item->need_update = TRUE;
}
/* if unread flag is unset */
if ((perm_flags & MSG_UNREAD) && MSG_IS_UNREAD(msginfo->flags) &&
!MSG_IS_IGNORE_THREAD(msginfo->flags)) {
item->unread--;
- item->need_update = TRUE;
}
if (MSG_IS_UNREAD(msginfo->flags) && (perm_flags & MSG_UNREAD)
&& !MSG_IS_IGNORE_THREAD(msginfo->flags)
&& procmsg_msg_has_marked_parent(msginfo)) {
item->unreadmarked--;
- item->need_update = TRUE;
}
if (MSG_IS_MARKED(msginfo->flags) && (perm_flags & MSG_MARKED)
if ((perm_flags & MSG_IGNORE_THREAD) && MSG_IS_IGNORE_THREAD(msginfo->flags)) {
if (MSG_IS_NEW(msginfo->flags) && !(perm_flags & MSG_NEW)) {
item->new++;
- item->need_update = TRUE;
}
if (MSG_IS_UNREAD(msginfo->flags) && !(perm_flags & MSG_UNREAD)) {
item->unread++;
- item->need_update = TRUE;
}
if (MSG_IS_UNREAD(msginfo->flags) && !(perm_flags & MSG_UNREAD)
&& procmsg_msg_has_marked_parent(msginfo)) {
item->unreadmarked++;
- item->need_update = TRUE;
}
if (MSG_IS_MARKED(msginfo->flags) && !(perm_flags & MSG_MARKED)) {
procmsg_update_unread_children(msginfo, TRUE);
msginfo_update.msginfo = msginfo;
hooks_invoke(MSGINFO_UPDATE_HOOKLIST, &msginfo_update);
+ folder_item_update(msginfo->folder, F_ITEM_UPDATE_MSGCNT);
CHANGE_FLAGS(msginfo);
procmsg_msginfo_write_flags(msginfo);
return children;
}
-static void procmsg_update_unread_children (MsgInfo *info, gboolean newly_marked)
+static void procmsg_update_unread_children(MsgInfo *info, gboolean newly_marked)
{
GSList *children = procmsg_find_children(info);
GSList *cur;
info->folder->unreadmarked++;
else
info->folder->unreadmarked--;
- info->folder->need_update = TRUE;
+ folder_item_update(info->folder, F_ITEM_UPDATE_MSGCNT);
}
procmsg_msginfo_free(tmp);
}
}
+
+/**
+ * Set the destination folder for a copy or move operation
+ *
+ * \param msginfo The message which's destination folder is changed
+ * \param to_folder The destination folder for the operation
+ */
+void procmsg_msginfo_set_to_folder(MsgInfo *msginfo, FolderItem *to_folder)
+{
+ if(msginfo->to_folder != NULL) {
+ msginfo->to_folder->op_count--;
+ folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
+ }
+ msginfo->to_folder = to_folder;
+ if(to_folder != NULL) {
+ to_folder->op_count++;
+ folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
+ }
+}