aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--src/send_message.c72
-rw-r--r--src/send_message.h2
3 files changed, 43 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index 482b8b51..1e7df578 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-01-07
+
+ * src/send_message.[ch]: send_message_queue_all(): refactored.
+
2011-01-06
* libsylph/filter.c: filter_match_rule(): optimized by modifying the
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);
diff --git a/src/send_message.h b/src/send_message.h
index 7841f62e..814c81cb 100644
--- a/src/send_message.h
+++ b/src/send_message.h
@@ -45,8 +45,6 @@ gint send_message (const gchar *file,
GSList *to_list);
QueueInfo *send_get_queue_info (const gchar *file);
-gint send_get_queue_contents (QueueInfo *qinfo,
- const gchar *dest);
void send_queue_info_free (QueueInfo *qinfo);
gint send_message_queue (QueueInfo *qinfo);
gint send_message_queue_all (FolderItem *queue,