aboutsummaryrefslogtreecommitdiff
path: root/src/send_message.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-09-05 06:45:34 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-09-05 06:45:34 +0000
commitfa466fd5e1e6b481f6249979cfb7397caa875f5c (patch)
treed26111cc73dba81cd7c684f4528695bfcf16ee53 /src/send_message.c
parent02a672d5bfa50cad8ab5cb047125c708c68176ab (diff)
moved procmsg.c::procmsg_send_queue() to send_message.c::send_message_queue_all().
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@545 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/send_message.c')
-rw-r--r--src/send_message.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/send_message.c b/src/send_message.c
index 87072818..0579c619 100644
--- a/src/send_message.c
+++ b/src/send_message.c
@@ -44,6 +44,9 @@
#include "prefs_account.h"
#include "procheader.h"
#include "account.h"
+#include "folder.h"
+#include "procmsg.h"
+#include "filter.h"
#include "progressdialog.h"
#include "statusbar.h"
#include "inputdialog.h"
@@ -304,6 +307,81 @@ gint send_message_queue(QueueInfo *qinfo)
return val;
}
+gint send_message_queue_all(FolderItem *queue, gboolean save_msgs,
+ gboolean filter_msgs)
+{
+ gint ret = 0;
+ GSList *mlist = NULL;
+ GSList *cur;
+
+ if (!queue)
+ queue = folder_get_default_queue();
+ g_return_val_if_fail(queue != NULL, -1);
+
+ mlist = folder_item_get_msg_list(queue, FALSE);
+ mlist = procmsg_sort_msg_list(mlist, SORT_BY_NUMBER, SORT_ASCENDING);
+
+ for (cur = mlist; cur != NULL; cur = cur->next) {
+ gchar *file;
+ MsgInfo *msginfo = (MsgInfo *)cur->data;
+ QueueInfo *qinfo;
+ gchar tmp[MAXPATHLEN + 1];
+
+ file = procmsg_get_message_file(msginfo);
+ if (!file)
+ continue;
+
+ qinfo = send_get_queue_info(file);
+ if (!qinfo || send_message_queue(qinfo) < 0) {
+ g_warning("Sending queued message %d failed.\n",
+ msginfo->msgnum);
+ send_queue_info_free(qinfo);
+ g_free(file);
+ continue;
+ }
+
+ g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg.out.%08x",
+ get_rc_dir(), G_DIR_SEPARATOR, g_random_int());
+
+ if (send_get_queue_contents(qinfo, tmp) == 0) {
+ if (save_msgs) {
+ FolderItem *outbox;
+ outbox = account_get_special_folder
+ (qinfo->ac, F_OUTBOX);
+ procmsg_save_to_outbox(outbox, tmp);
+ }
+ if (filter_msgs) {
+ FilterInfo *fltinfo;
+
+ fltinfo = filter_info_new();
+ fltinfo->account = qinfo->ac;
+ fltinfo->flags.perm_flags = 0;
+ fltinfo->flags.tmp_flags = MSG_RECEIVED;
+
+ filter_apply(prefs_common.fltlist, tmp,
+ fltinfo);
+
+ filter_info_free(fltinfo);
+ }
+ g_unlink(tmp);
+ }
+
+ send_queue_info_free(qinfo);
+ g_free(file);
+
+ folder_item_remove_msg(queue, msginfo);
+ ret++;
+ }
+
+ procmsg_msg_list_free(mlist);
+
+ procmsg_clear_cache(queue);
+ queue->cache_dirty = FALSE;
+ queue->mtime = 0;
+
+ return ret;
+}
+
static gint send_message_local(const gchar *command, FILE *fp)
{
gchar **argv;