From c2b0ac470bcbc1c508814b274909c44caadb4e5a Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 7 Jan 2011 04:56:41 +0000 Subject: send_message_queue_all(): refactored. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2780 ee746299-78ed-0310-b773-934348b2243d --- src/send_message.c | 72 +++++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 33 deletions(-) (limited to 'src/send_message.c') diff --git a/src/send_message.c b/src/send_message.c index 3ecbb876..cd65935e 100644 --- a/src/send_message.c +++ b/src/send_message.c @@ -213,7 +213,7 @@ QueueInfo *send_get_queue_info(const gchar *file) return qinfo; } -gint send_get_queue_contents(QueueInfo *qinfo, const gchar *dest) +static gint send_get_queue_contents(QueueInfo *qinfo, const gchar *dest) { FILE *fp; glong pos; @@ -244,6 +244,42 @@ gint send_get_queue_contents(QueueInfo *qinfo, const gchar *dest) return 0; } +static gint send_save_queued_message(QueueInfo *qinfo, gboolean filter_msgs) +{ + FolderItem *outbox; + gboolean drop_done = FALSE; + gchar tmp[MAXPATHLEN + 1]; + + 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) + return -1; + + 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); + + drop_done = fltinfo->drop_done; + filter_info_free(fltinfo); + } + + if (!drop_done) { + outbox = account_get_special_folder(qinfo->ac, F_OUTBOX); + procmsg_save_to_outbox(outbox, tmp); + } + + g_unlink(tmp); + + return 0; +} + void send_queue_info_free(QueueInfo *qinfo) { if (qinfo == NULL) return; @@ -341,7 +377,6 @@ gint send_message_queue_all(FolderItem *queue, gboolean save_msgs, gchar *file; MsgInfo *msginfo = (MsgInfo *)cur->data; QueueInfo *qinfo; - gchar tmp[MAXPATHLEN + 1]; file = procmsg_get_message_file(msginfo); if (!file) @@ -362,37 +397,8 @@ gint send_message_queue_all(FolderItem *queue, gboolean save_msgs, else if (qinfo->forward_targets) send_message_set_forward_flags(qinfo->forward_targets); - 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; - gboolean drop_done = FALSE; - - 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); - - drop_done = fltinfo->drop_done; - filter_info_free(fltinfo); - } - - if (!drop_done) { - outbox = account_get_special_folder - (qinfo->ac, F_OUTBOX); - procmsg_save_to_outbox(outbox, tmp); - } - } - g_unlink(tmp); - } + if (save_msgs) + send_save_queued_message(qinfo, filter_msgs); send_queue_info_free(qinfo); g_free(file); -- cgit v1.2.3