/*
* 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
#include "alertpanel.h"
#include "news.h"
#include "imap.h"
+#include "hooks.h"
typedef struct _FlagInfo FlagInfo;
static GHashTable *procmsg_read_mark_file (const gchar *folder);
void procmsg_msginfo_write_flags (MsgInfo *msginfo);
-static void procmsg_update_unread_children (MsgInfo *info, gboolean newly_marked);
GHashTable *procmsg_msg_hash_table_create(GSList *mlist)
{
ret = -1;
if (ret < 0)
- g_warning(_("Cache data is corrupted\n"));
+ g_warning("Cache data is corrupted\n");
return ret;
}
#define READ_CACHE_DATA_INT(n, fp) \
{ \
if (fread(&n, sizeof(n), 1, fp) != 1) { \
- g_warning(_("Cache data is corrupted\n")); \
+ g_warning("Cache data is corrupted\n"); \
procmsg_msginfo_free(msginfo); \
break; \
} \
g_return_if_fail(path != NULL);
if ((fp = procmsg_open_mark_file(path, TRUE)) == NULL) {
- g_warning(_("can't open mark file\n"));
+ g_warning("can't open mark file\n");
g_free(path);
return;
}
/* reopen with append mode */
fclose(fp);
if ((fp = fopen(markfile, "ab")) == NULL)
- g_warning(_("Can't open mark file with append mode.\n"));
+ g_warning("Can't open mark file with append mode.\n");
} else {
/* open with overwrite mode if mark file doesn't exist or
version is different */
if ((fp = fopen(markfile, "wb")) == NULL)
- g_warning(_("Can't open mark file with write mode.\n"));
+ g_warning("Can't open mark file with write mode.\n");
else {
ver = MARK_VERSION;
WRITE_CACHE_DATA_INT(ver, fp);
g_hash_table_lookup(msgid_table, msgid) == NULL)
g_hash_table_insert(msgid_table, (gchar *)msgid, node);
- subject = msginfo->subject;
- found_subject = subject_table_lookup(subject_table,
- (gchar *) subject);
- if (found_subject == NULL)
- subject_table_insert(subject_table, (gchar *) subject,
- node);
- else {
- /* replace if msg in table is older than current one
- * can add here more stuff. */
- if ( ((MsgInfo*)(found_subject->data))->date_t >
- ((MsgInfo*)(node->data))->date_t ) {
- subject_table_remove(subject_table, (gchar *) subject);
- subject_table_insert(subject_table, (gchar *) subject, node);
- }
+ if (prefs_common.thread_by_subject) {
+ subject = msginfo->subject;
+ found_subject = subject_table_lookup(subject_table,
+ (gchar *) subject);
+ if (found_subject == NULL)
+ subject_table_insert(subject_table, (gchar *) subject,
+ node);
+ else {
+ /* replace if msg in table is older than current one
+ * can add here more stuff. */
+ if ( ((MsgInfo*)(found_subject->data))->date_t >
+ ((MsgInfo*)(node->data))->date_t ) {
+ subject_table_remove(subject_table, (gchar *) subject);
+ subject_table_insert(subject_table, (gchar *) subject, node);
+ }
+ }
}
}
* threaded by subject line. we need to handle this in a special way to prevent
* circular reference from a node that has already been threaded by IN-REPLY-TO
* but is also in the subject line hash table */
- for (node = root->children; node != NULL; ) {
- next = node->next;
- msginfo = (MsgInfo *) node->data;
- parent = NULL;
- if (subject_is_reply(msginfo->subject)) {
- parent = subject_table_lookup(subject_table,
- msginfo->subject);
- /* the node may already be threaded by IN-REPLY-TO,
- so go up in the tree to find the parent node */
- if (parent != NULL) {
- if (g_node_is_ancestor(node, parent))
- parent = NULL;
- if (parent == node)
- parent = NULL;
- }
-
- if (parent) {
- g_node_unlink(node);
- g_node_append(parent, node);
- /* CLAWS: ignore thread */
- if (MSG_IS_IGNORE_THREAD(((MsgInfo *)parent->data)->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
- g_node_traverse(node, G_PRE_ORDER, G_TRAVERSE_ALL, -1, procmsg_ignore_node, NULL);
+ if (prefs_common.thread_by_subject) {
+ for (node = root->children; node != NULL; ) {
+ next = node->next;
+ msginfo = (MsgInfo *) node->data;
+ parent = NULL;
+ if (subject_is_reply(msginfo->subject)) {
+ parent = subject_table_lookup(subject_table,
+ msginfo->subject);
+ /* the node may already be threaded by IN-REPLY-TO,
+ so go up in the tree to find the parent node */
+ if (parent != NULL) {
+ if (g_node_is_ancestor(node, parent))
+ parent = NULL;
+ if (parent == node)
+ parent = NULL;
}
- }
- }
- node = next;
- }
+ if (parent) {
+ g_node_unlink(node);
+ g_node_append(parent, node);
+ /* CLAWS: ignore thread */
+ if (MSG_IS_IGNORE_THREAD(((MsgInfo *)parent->data)->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
+ g_node_traverse(node, G_PRE_ORDER, G_TRAVERSE_ALL, -1, procmsg_ignore_node, NULL);
+ }
+ }
+ }
+ node = next;
+ }
+ }
+
g_hash_table_destroy(subject_table);
g_hash_table_destroy(msgid_table);
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)
filename = folder_item_fetch_msg(msginfo->folder, msginfo->msgnum);
if (!filename)
- g_warning(_("can't fetch message %d\n"), msginfo->msgnum);
+ g_warning("can't fetch message %d\n", msginfo->msgnum);
return filename;
}
}
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) {
file = folder_item_fetch_msg(queue, msginfo->msgnum);
if (file) {
if (procmsg_send_message_queue(file) < 0) {
- g_warning(_("Sending queued message %d failed.\n"), msginfo->msgnum);
+ g_warning("Sending queued message %d failed.\n", msginfo->msgnum);
ret = -1;
} else {
/* CLAWS:
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;
}
g_return_if_fail(msginfo);
if ((tmpfp = procmime_get_first_text_content(msginfo)) == NULL) {
- g_warning(_("Can't get text part\n"));
+ g_warning("Can't get text part\n");
return;
}
g_snprintf(buf, sizeof(buf) - 1, cmdline, prtmp);
else {
if (cmdline)
- g_warning(_("Print command line is invalid: `%s'\n"),
+ g_warning("Print command line is invalid: `%s'\n",
cmdline);
g_snprintf(buf, sizeof(buf) - 1, def_cmd, prtmp);
}
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;
+ debug_print("freeing msginfo %d is %s\n", msginfo->msgnum, msginfo->folder ? msginfo->folder->path : "(nil)");
+
+ 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 (to_list) {
debug_print("Sending message by mail\n");
if (!from) {
- g_warning(_("Queued message header is broken.\n"));
+ g_warning("Queued message header is broken.\n");
mailval = -1;
} else if (mailac && mailac->use_mail_command &&
mailac->mail_command && (* mailac->mail_command)) {
if (!mailac) {
mailac = account_find_from_smtp_server(from, smtpserver);
if (!mailac) {
- g_warning(_("Account not found. "
- "Using current account...\n"));
+ g_warning("Account not found. "
+ "Using current account...\n");
mailac = cur_account;
}
}
else {
PrefsAccount tmp_ac;
- g_warning(_("Account not found.\n"));
+ g_warning("Account not found.\n");
memset(&tmp_ac, 0, sizeof(PrefsAccount));
tmp_ac.address = from;
}
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)) ?
} else {
if (change_file_mode_rw(tmpfp, tmp) < 0) {
FILE_OP_ERROR(tmp, "chmod");
- g_warning(_("can't change file mode\n"));
+ g_warning("can't change file mode\n");
}
while ((newsval == 0) && fgets(buf, sizeof(buf), fp) != NULL) {
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);
-
- msginfo_update_item(msginfo);
+ 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);
}
void procmsg_msginfo_set_flags(MsgInfo *msginfo, MsgPermFlags perm_flags, MsgTmpFlags tmp_flags)
{
FolderItem *item;
+ MsgInfoUpdate msginfo_update;
g_return_if_fail(msginfo != NULL);
item = msginfo->folder;
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)) {
+ if ((perm_flags & MSG_MARKED) || (MSG_IS_MARKED(msginfo->flags)
+ && !MSG_IS_IGNORE_THREAD(msginfo->flags))) {
procmsg_update_unread_children(msginfo, FALSE);
}
}
- if (MSG_IS_IMAP(msginfo->flags))
+ if (msginfo->folder->folder->type == F_IMAP)
imap_msg_set_perm_flags(msginfo, perm_flags);
msginfo->flags.perm_flags |= perm_flags;
msginfo->flags.tmp_flags |= tmp_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);
}
void procmsg_msginfo_unset_flags(MsgInfo *msginfo, MsgPermFlags perm_flags, MsgTmpFlags tmp_flags)
{
FolderItem *item;
+ MsgInfoUpdate msginfo_update;
g_return_if_fail(msginfo != NULL);
item = msginfo->folder;
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);
}
- if (MSG_IS_IMAP(msginfo->flags))
+ if (msginfo->folder->folder->type == F_IMAP)
imap_msg_unset_perm_flags(msginfo, perm_flags);
msginfo->flags.perm_flags &= ~perm_flags;
msginfo->flags.tmp_flags &= ~tmp_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);
}
procmsg_write_flags(msginfo, fp);
fclose(fp);
} else {
- g_warning(_("Can't open mark file.\n"));
+ g_warning("Can't open mark file.\n");
}
g_free(destdir);
}
-gboolean procmsg_msg_has_marked_parent (MsgInfo *info)
+/*!
+ *\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);
- if (tmp && MSG_IS_MARKED(tmp->flags)) {
+ 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 = procmsg_msg_has_marked_parent(tmp);
+ gboolean result;
+
+ 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 {
+ g_hash_table_insert(parentmsgs, info, "1");
+ result = procmsg_msg_has_flagged_parent_real(
+ tmp, perm_flags, parentmsgs);
+ }
procmsg_msginfo_free(tmp);
return result;
} else {
}
} else
return FALSE;
-}
+}
-GSList *procmsg_find_children (MsgInfo *info)
+/*!
+ *\brief Callback for cleaning up hash of parentmsgs
+ */
+gboolean parentmsgs_hash_remove(gpointer key,
+ gpointer value,
+ gpointer user_data)
{
- GSList *children = NULL;
- GSList *all, *cur;
-
- g_return_val_if_fail(info!=NULL, NULL);
+ 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_func(MsgInfo *info,
+ GSList *children, GSList *all)
+{
+ GSList *cur;
+
+ g_return_val_if_fail(info!=NULL, children);
if (info->msgid == NULL)
- return NULL;
- all = folder_item_get_msg_list(info->folder);
+ return children;
+
for (cur = all; cur != NULL; cur = g_slist_next(cur)) {
MsgInfo *tmp = (MsgInfo *)cur->data;
if (tmp->inreplyto && !strcmp(tmp->inreplyto, info->msgid)) {
- GSList *grand_children;
- children = g_slist_prepend(children, tmp);
- grand_children = procmsg_find_children(tmp);
- children = slist_concat_unique(children, grand_children);
- g_slist_free(grand_children);
+ /* Check if message is already in the list */
+ if ((children == NULL) ||
+ (g_slist_index(children, tmp) == -1)) {
+ children = g_slist_prepend(children,
+ procmsg_msginfo_new_ref(tmp));
+ children = procmsg_find_children_func(tmp,
+ children,
+ all);
+ }
}
- if (tmp && tmp != info)
- procmsg_msginfo_free(tmp);
}
-
return children;
}
-static void procmsg_update_unread_children (MsgInfo *info, gboolean newly_marked)
+GSList *procmsg_find_children (MsgInfo *info)
+{
+ GSList *children;
+ GSList *all, *cur;
+
+ g_return_val_if_fail(info!=NULL, NULL);
+ all = folder_item_get_msg_list(info->folder);
+ children = procmsg_find_children_func(info, NULL, all);
+ if (children != NULL) {
+ for (cur = all; cur != NULL; cur = g_slist_next(cur)) {
+ /* this will not free the used pointers
+ created with procmsg_msginfo_new_ref */
+ procmsg_msginfo_free((MsgInfo *)cur->data);
+ }
+ }
+ g_slist_free(all);
+
+ return children;
+}
+
+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);
}
+ g_slist_free(children);
}
-/*
- * callback handling
+/**
+ * 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
*/
-GSList *msginfo_update_callbacks_list = NULL;
-gint msginfo_update_callbacks_nextid = 0;
-
-struct MsgInfoUpdateCallback
-{
- gint id;
- MsgInfoUpdateFunc func;
- gpointer data;
-};
-
-gint msginfo_update_callback_register(MsgInfoUpdateFunc func, gpointer data)
-{
- struct MsgInfoUpdateCallback *callback;
-
- g_return_val_if_fail(func != NULL, -1);
-
- msginfo_update_callbacks_nextid++;
-
- callback = g_new0(struct MsgInfoUpdateCallback, 1);
- callback->id = msginfo_update_callbacks_nextid;
- callback->func = func;
- callback->data = data;
-
- msginfo_update_callbacks_list =
- g_slist_append(msginfo_update_callbacks_list, callback);
-
- return msginfo_update_callbacks_nextid;
-}
-
-void msginfo_update_callback_unregister(gint id)
+void procmsg_msginfo_set_to_folder(MsgInfo *msginfo, FolderItem *to_folder)
{
- GSList *list, *next;
-
- for (list = msginfo_update_callbacks_list; list != NULL; list = next) {
- struct MsgInfoUpdateCallback *callback;
-
- next = list->next;
-
- callback = list->data;
- if (callback->id == id) {
- msginfo_update_callbacks_list =
- g_slist_remove(msginfo_update_callbacks_list, callback);
- g_free(callback);
- }
+ if(msginfo->to_folder != NULL) {
+ msginfo->to_folder->op_count--;
+ folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
}
-}
-
-static void msginfo_update_callback_execute(MsgInfo *info)
-{
- GSList *list;
-
- for (list = msginfo_update_callbacks_list; list != NULL; list = list->next) {
- struct MsgInfoUpdateCallback *callback;
-
- callback = list->data;
- callback->func(info, callback->data);
+ msginfo->to_folder = to_folder;
+ if(to_folder != NULL) {
+ to_folder->op_count++;
+ folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
}
}
-
-void msginfo_update_item(MsgInfo *info)
-{
- msginfo_update_callback_execute(info);
-}