diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2007-07-09 09:37:06 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2007-07-09 09:37:06 +0000 |
commit | 8d1e36be855c14b28f2902a2274c256db675bd79 (patch) | |
tree | af329e33cdd493d2be8891595cda8931ef72b6b4 | |
parent | 5ffaca8a5c8cd4b66e638dfad96acc95d3ab9c05 (diff) |
implemented add-reply-or-forward-mark after sending from queue.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1850 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ChangeLog.ja | 6 | ||||
-rw-r--r-- | src/compose.c | 25 | ||||
-rw-r--r-- | src/send_message.c | 155 | ||||
-rw-r--r-- | src/send_message.h | 3 |
5 files changed, 194 insertions, 1 deletions
@@ -1,5 +1,11 @@ 2007-07-09 + * src/compose.c + src/send_message.[ch]: implemented add-reply-or-forward-mark + after sending from queue. + +2007-07-09 + * src/compose.c: implemented add-forward-mark-after-sending. 2007-07-09 diff --git a/ChangeLog.ja b/ChangeLog.ja index 5d04be9f..e9b32ad0 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,5 +1,11 @@ 2007-07-09 + * src/compose.c + src/send_message.[ch]: 送信待ちからの送信後返信・転送マーク付加 + を実装。 + +2007-07-09 + * src/compose.c: 送信後転送マーク付加を実装。 2007-07-09 diff --git a/src/compose.c b/src/compose.c index 254d3c2b..31f5c49f 100644 --- a/src/compose.c +++ b/src/compose.c @@ -3621,6 +3621,31 @@ static gint compose_queue(Compose *compose, const gchar *file) fprintf(fp, "R:\n"); /* Sylpheed account ID */ fprintf(fp, "AID:%d\n", compose->account->account_id); + /* Reply target */ + if (compose->replyinfo) { + gchar *id; + id = folder_item_get_identifier(compose->replyinfo->folder); + if (id) { + fprintf(fp, "REP:%s/%u\n", + id, compose->replyinfo->msgnum); + g_free(id); + } + } + /* Forward target */ + if (compose->forward_mlist) { + gchar *id; + MsgInfo *fwinfo = (MsgInfo *)compose->forward_mlist->data; + id = folder_item_get_identifier(fwinfo->folder); + if (id) { + fprintf(fp, "FWD:%s/%u\n", id, fwinfo->msgnum); + for (cur = compose->forward_mlist->next; cur != NULL; + cur = cur->next) { + fwinfo = (MsgInfo *)cur->data; + fprintf(fp, " %s/%u\n", id, fwinfo->msgnum); + } + g_free(id); + } + } fprintf(fp, "\n"); while (fgets(buf, sizeof(buf), src_fp) != NULL) { diff --git a/src/send_message.c b/src/send_message.c index 8d58fd30..1adcf542 100644 --- a/src/send_message.c +++ b/src/send_message.c @@ -54,6 +54,8 @@ #include "socket.h" #include "utils.h" #include "inc.h" +#include "mainwindow.h" +#include "summaryview.h" #define SMTP_PORT 25 #if USE_SSL @@ -69,6 +71,10 @@ struct _SendProgressDialog gboolean cancelled; }; +static gint send_message_set_reply_flag (QueueInfo *qinfo); +static gint send_message_set_forward_flags + (QueueInfo *qinfo); + static gint send_message_local (const gchar *command, FILE *fp); static gint send_message_smtp (PrefsAccount *ac_prefs, @@ -126,7 +132,9 @@ enum Q_SENDER = 0, Q_SMTPSERVER = 1, Q_RECIPIENTS = 2, - Q_ACCOUNT_ID = 3 + Q_ACCOUNT_ID = 3, + Q_REPLY_TARGET = 4, + Q_FORWARD_TARGETS = 5 }; QueueInfo *send_get_queue_info(const gchar *file) @@ -135,11 +143,20 @@ QueueInfo *send_get_queue_info(const gchar *file) {"SSV:", NULL, FALSE}, {"R:", NULL, FALSE}, {"AID:", NULL, FALSE}, + {"REP:", NULL, FALSE}, + {"FWD:", NULL, FALSE}, {NULL, NULL, FALSE}}; FILE *fp; gchar buf[BUFFSIZE]; gint hnum; QueueInfo *qinfo; + gchar *id; + gchar *msg; + gint num; + FolderItem *item; + MsgInfo *msginfo; + gchar **paths; + gint i; g_return_val_if_fail(file != NULL, NULL); @@ -172,6 +189,34 @@ QueueInfo *send_get_queue_info(const gchar *file) case Q_ACCOUNT_ID: qinfo->ac = account_find_from_id(atoi(p)); break; + case Q_REPLY_TARGET: + id = g_path_get_dirname(p); + msg = g_path_get_basename(p); + num = to_number(msg); + item = folder_find_item_from_identifier(id); + g_print("folder id: %s (msg %d)\n", id, num); + if (num > 0 && item) { + qinfo->replyinfo = + procmsg_get_msginfo(item, num); + } + break; + case Q_FORWARD_TARGETS: + paths = g_strsplit(p, "\n", 0); + for (i = 0; paths[i] != NULL; i++) { + g_strstrip(paths[i]); + id = g_path_get_dirname(paths[i]); + msg = g_path_get_basename(paths[i]); + num = to_number(msg); + item = folder_find_item_from_identifier(id); + g_print("folder id: %s (msg %d)\n", id, num); + if (num > 0 && item) { + msginfo = procmsg_get_msginfo(item, num); + if (msginfo) + qinfo->forward_mlist = g_slist_append(qinfo->forward_mlist, msginfo); + } + } + g_strfreev(paths); + break; default: break; } @@ -238,6 +283,8 @@ void send_queue_info_free(QueueInfo *qinfo) g_slist_free(qinfo->to_list); g_free(qinfo->from); g_free(qinfo->server); + procmsg_msginfo_free(qinfo->replyinfo); + procmsg_msg_list_free(qinfo->forward_mlist); if (qinfo->fp) fclose(qinfo->fp); g_free(qinfo); @@ -340,6 +387,11 @@ gint send_message_queue_all(FolderItem *queue, gboolean save_msgs, continue; } + if (qinfo->replyinfo) + send_message_set_reply_flag(qinfo); + else if (qinfo->forward_mlist) + send_message_set_forward_flags(qinfo); + g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg.out.%08x", get_rc_dir(), G_DIR_SEPARATOR, g_random_int()); @@ -388,6 +440,107 @@ gint send_message_queue_all(FolderItem *queue, gboolean save_msgs, return ret; } +static gint send_message_set_reply_flag(QueueInfo *qinfo) +{ + MsgInfo *msginfo; + MsgInfo *replyinfo; + SummaryView *summaryview; + + g_return_val_if_fail(qinfo->replyinfo != NULL, -1); + g_return_val_if_fail(qinfo->replyinfo->folder != NULL, -1); + + replyinfo = qinfo->replyinfo; + + summaryview = main_window_get()->summaryview; + if (summaryview->folder_item == replyinfo->folder) { + msginfo = summary_get_msginfo_by_msgnum + (summaryview, replyinfo->msgnum); + if (msginfo) { + MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_FORWARDED); + MSG_SET_PERM_FLAGS(msginfo->flags, MSG_REPLIED); + MSG_SET_TMP_FLAGS(msginfo->flags, MSG_FLAG_CHANGED); + if (MSG_IS_IMAP(msginfo->flags)) + imap_msg_set_perm_flags(msginfo, MSG_REPLIED); + if (msginfo->folder) + msginfo->folder->mark_dirty = TRUE; + summary_update_by_msgnum(summaryview, msginfo->msgnum); + } + } else { + msginfo = replyinfo; + if (msginfo) { + MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_FORWARDED); + MSG_SET_PERM_FLAGS(msginfo->flags, MSG_REPLIED); + MSG_SET_TMP_FLAGS(msginfo->flags, MSG_FLAG_CHANGED); + if (MSG_IS_IMAP(msginfo->flags)) + imap_msg_set_perm_flags(msginfo, MSG_REPLIED); + if (msginfo->folder) + msginfo->folder->mark_dirty = TRUE; + procmsg_add_flags(msginfo->folder, msginfo->msgnum, + msginfo->flags); + + } + } + + return 0; +} + +static gint send_message_set_forward_flags(QueueInfo *qinfo) +{ + MsgInfo *msginfo; + MsgInfo *fwinfo; + GSList *cur; + SummaryView *summaryview; + + g_return_val_if_fail(qinfo->forward_mlist != NULL, -1); + + summaryview = main_window_get()->summaryview; + + for (cur = qinfo->forward_mlist; cur != NULL; cur = cur->next) { + fwinfo = (MsgInfo *)cur->data; + if (!fwinfo->folder) + return -1; + + if (summaryview->folder_item == fwinfo->folder) { + msginfo = summary_get_msginfo_by_msgnum + (summaryview, fwinfo->msgnum); + if (msginfo) { + MSG_UNSET_PERM_FLAGS(msginfo->flags, + MSG_REPLIED); + MSG_SET_PERM_FLAGS(msginfo->flags, + MSG_FORWARDED); + MSG_SET_TMP_FLAGS(msginfo->flags, + MSG_FLAG_CHANGED); + if (msginfo->folder) + msginfo->folder->mark_dirty = TRUE; + summary_update_by_msgnum + (summaryview, msginfo->msgnum); + } + } else { + msginfo = fwinfo; + if (msginfo) { + MSG_UNSET_PERM_FLAGS(msginfo->flags, + MSG_REPLIED); + MSG_SET_PERM_FLAGS(msginfo->flags, + MSG_FORWARDED); + MSG_SET_TMP_FLAGS(msginfo->flags, + MSG_FLAG_CHANGED); + if (msginfo->folder) + msginfo->folder->mark_dirty = TRUE; + procmsg_add_flags(msginfo->folder, + msginfo->msgnum, + msginfo->flags); + } + } + } + + fwinfo = (MsgInfo *)qinfo->forward_mlist->data; + if (MSG_IS_IMAP(fwinfo->flags)) + imap_msg_list_unset_perm_flags(qinfo->forward_mlist, + MSG_REPLIED); + + return 0; +} + static gint send_message_local(const gchar *command, FILE *fp) { gchar **argv; diff --git a/src/send_message.h b/src/send_message.h index 29e7eb53..6c39bba6 100644 --- a/src/send_message.h +++ b/src/send_message.h @@ -27,6 +27,7 @@ typedef struct _QueueInfo QueueInfo; #include "prefs_account.h" #include "folder.h" +#include "procmsg.h" struct _QueueInfo { @@ -34,6 +35,8 @@ struct _QueueInfo gchar *server; GSList *to_list; PrefsAccount *ac; + MsgInfo *replyinfo; + GSList *forward_mlist; FILE *fp; }; |