/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
*
* 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 "inc.h"
static gint procmsg_send_message_queue_full(const gchar *file, gboolean keep_session, gchar **errstr,
- FolderItem *queue, gint msgnum);
-
+ FolderItem *queue, gint msgnum, gboolean *queued_removed);
+static void procmsg_update_unread_children (MsgInfo *info,
+ gboolean newly_marked);
enum
{
Q_SENDER = 0,
Q_CLAWS_HDRS_OLD = 16,
};
-GHashTable *procmsg_msg_hash_table_create(GSList *mlist)
-{
- GHashTable *msg_table;
-
- if (mlist == NULL) return NULL;
-
- msg_table = g_hash_table_new(NULL, g_direct_equal);
- procmsg_msg_hash_table_append(msg_table, mlist);
-
- return msg_table;
-}
-
-void procmsg_msg_hash_table_append(GHashTable *msg_table, GSList *mlist)
-{
- GSList *cur;
- MsgInfo *msginfo;
-
- if (msg_table == NULL || mlist == NULL) return;
-
- for (cur = mlist; cur != NULL; cur = cur->next) {
- msginfo = (MsgInfo *)cur->data;
-
- g_hash_table_insert(msg_table,
- GUINT_TO_POINTER(msginfo->msgnum),
- msginfo);
- }
-}
-
-GHashTable *procmsg_to_folder_hash_table_create(GSList *mlist)
-{
- GHashTable *msg_table;
- GSList *cur;
- MsgInfo *msginfo;
-
- if (mlist == NULL) return NULL;
-
- msg_table = g_hash_table_new(NULL, g_direct_equal);
-
- for (cur = mlist; cur != NULL; cur = cur->next) {
- msginfo = (MsgInfo *)cur->data;
- g_hash_table_insert(msg_table, msginfo->to_folder, msginfo);
- }
-
- return msg_table;
-}
-
-gint procmsg_get_last_num_in_msg_list(GSList *mlist)
-{
- GSList *cur;
- MsgInfo *msginfo;
- gint last = 0;
-
- for (cur = mlist; cur != NULL; cur = cur->next) {
- msginfo = (MsgInfo *)cur->data;
- if (msginfo && msginfo->msgnum > last)
- last = msginfo->msgnum;
- }
-
- return last;
-}
-
void procmsg_msg_list_free(GSList *mlist)
{
GSList *cur;
}
}
-void procmsg_empty_trash(FolderItem *trash)
+static void procmsg_empty_trash(FolderItem *trash)
{
GNode *node, *next;
if (!MSG_IS_LOCKED(msginfo->flags)) {
file = folder_item_fetch_msg(queue, msginfo->msgnum);
if (file) {
+ gboolean queued_removed = FALSE;
if (procmsg_send_message_queue_full(file,
!procmsg_is_last_for_account(queue, msginfo, elem),
- errstr, queue, msginfo->msgnum) < 0) {
+ errstr, queue, msginfo->msgnum, &queued_removed) < 0) {
g_warning("Sending queued message %d failed.\n",
msginfo->msgnum);
err++;
} else {
sent++;
- folder_item_remove_msg(queue, msginfo->msgnum);
+ if (!queued_removed)
+ folder_item_remove_msg(queue, msginfo->msgnum);
}
g_free(file);
}
return 0;
}
-gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
+static gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
gboolean is_queued)
{
gint num;
return memusage;
}
-gint procmsg_cmp_msgnum_for_sort(gconstpointer a, gconstpointer b)
-{
- const MsgInfo *msginfo1 = a;
- const MsgInfo *msginfo2 = b;
-
- if (!msginfo1)
- return -1;
- if (!msginfo2)
- return -1;
-
- return msginfo1->msgnum - msginfo2->msgnum;
-}
-
static gint procmsg_send_message_queue_full(const gchar *file, gboolean keep_session, gchar **errstr,
- FolderItem *queue, gint msgnum)
+ FolderItem *queue, gint msgnum, gboolean *queued_removed)
{
static HeaderEntry qentry[] = {{"S:", NULL, FALSE},
{"SSV:", NULL, FALSE},
if (save_clear_text || tmp_enc_file == NULL) {
gboolean saved = FALSE;
+ *queued_removed = FALSE;
if (queue && msgnum > 0) {
MsgInfo *queued_mail = folder_item_get_msginfo(queue, msgnum);
- if (folder_item_copy_msg(outbox, queued_mail) >= 0)
+ if (folder_item_move_msg(outbox, queued_mail) >= 0) {
+ debug_print("moved queued mail %d to sent folder\n", msgnum);
saved = TRUE;
+ *queued_removed = TRUE;
+ } else if (folder_item_copy_msg(outbox, queued_mail) >= 0) {
+ debug_print("copied queued mail %d to sent folder\n", msgnum);
+ saved = TRUE;
+ }
procmsg_msginfo_free(queued_mail);
}
- if (!saved)
+ if (!saved) {
+ debug_print("resaving clear text queued mail to sent folder\n");
procmsg_save_to_outbox(outbox, file, TRUE);
+ }
} else {
+ debug_print("saving encrpyted queued mail to sent folder\n");
procmsg_save_to_outbox(outbox, tmp_enc_file, FALSE);
}
}
return (newsval != 0 ? newsval : mailval);
}
-gint procmsg_send_message_queue(const gchar *file, gchar **errstr, FolderItem *queue, gint msgnum)
+gint procmsg_send_message_queue(const gchar *file, gchar **errstr, FolderItem *queue, gint msgnum, gboolean *queued_removed)
{
- gint result = procmsg_send_message_queue_full(file, FALSE, errstr, queue, msgnum);
+ gint result = procmsg_send_message_queue_full(file, FALSE, errstr, queue, msgnum, queued_removed);
toolbar_main_set_sensitive(mainwindow_get_mainwindow());
return result;
}
*
*\return gboolean TRUE if perm_flags are found
*/
-gboolean procmsg_msg_has_flagged_parent_real(MsgInfo *info,
+static gboolean procmsg_msg_has_flagged_parent_real(MsgInfo *info,
MsgPermFlags perm_flags, GHashTable *parentmsgs)
{
MsgInfo *tmp;
/*!
*\brief Callback for cleaning up hash of parentmsgs
*/
-gboolean parentmsgs_hash_remove(gpointer key,
+static gboolean parentmsgs_hash_remove(gpointer key,
gpointer value,
gpointer user_data)
{
}
-GSList *procmsg_find_children_func(MsgInfo *info,
+static GSList *procmsg_find_children_func(MsgInfo *info,
GSList *children, GSList *all)
{
GSList *cur;
return children;
}
-GSList *procmsg_find_children (MsgInfo *info)
+static GSList *procmsg_find_children (MsgInfo *info)
{
GSList *children;
GSList *all, *cur;
return children;
}
-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;
* \return TRUE if the message was moved and MsgInfo is now invalid,
* FALSE otherwise
*/
-gboolean procmsg_msginfo_filter(MsgInfo *msginfo, PrefsAccount* ac_prefs)
+static gboolean procmsg_msginfo_filter(MsgInfo *msginfo, PrefsAccount* ac_prefs)
{
MailFilteringData mail_filtering_data;