aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-07-10 02:42:35 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-07-10 02:42:35 +0000
commit8184b1fe44c098265726a5aa6e219f420ac77c42 (patch)
tree5c116b1bb08b3c11f9da0bdcc05df55b13bb37f1
parent8d1e36be855c14b28f2902a2274c256db675bd79 (diff)
restore reply/forward target on reedit.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1851 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog5
-rw-r--r--ChangeLog.ja5
-rw-r--r--src/compose.c120
-rw-r--r--src/send_message.c4
4 files changed, 132 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ede2c588..08c1cb0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-07-10
+
+ * src/compose.c: restore reply/forward target on reedit.
+ * src/send_message.c: send_get_queue_info(): fixed memory leaks.
+
2007-07-09
* src/compose.c
diff --git a/ChangeLog.ja b/ChangeLog.ja
index e9b32ad0..95f28226 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,8 @@
+2007-07-10
+
+ * src/compose.c: 再編集時に返信/転送対象を再取得するようにした。
+ * src/send_message.c: send_get_queue_info(): メモリリークを修正。
+
2007-07-09
* src/compose.c
diff --git a/src/compose.c b/src/compose.c
index 31f5c49f..26354fb4 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -208,6 +208,8 @@ static gint compose_parse_header (Compose *compose,
MsgInfo *msginfo);
static gchar *compose_parse_references (const gchar *ref,
const gchar *msgid);
+static gint compose_parse_source_msg (Compose *compose,
+ MsgInfo *msginfo);
static gchar *compose_quote_fmt (Compose *compose,
MsgInfo *msginfo,
@@ -1100,6 +1102,7 @@ void compose_reedit(MsgInfo *msginfo)
compose->targetinfo = procmsg_msginfo_copy(msginfo);
if (compose_parse_header(compose, msginfo) < 0) return;
+ compose_parse_source_msg(compose, msginfo);
undo_block(compose->undostruct);
@@ -1515,6 +1518,90 @@ static gchar *compose_parse_references(const gchar *ref, const gchar *msgid)
return new_ref_str;
}
+static gint compose_parse_source_msg(Compose *compose, MsgInfo *msginfo)
+{
+ static HeaderEntry hentry[] = {{"X-Sylpheed-Reply:", NULL, FALSE},
+ {"X-Sylpheed-Forward:", NULL, FALSE},
+ {"REP:", NULL, FALSE},
+ {"FWD:", NULL, FALSE},
+ {NULL, NULL, FALSE}};
+
+ enum
+ {
+ H_X_SYLPHEED_REPLY = 0,
+ H_X_SYLPHEED_FORWARD = 1,
+ H_REP = 2,
+ H_FWD = 3
+ };
+
+ gchar *file;
+ FILE *fp;
+ gchar *str;
+ gchar buf[BUFFSIZE];
+ gint hnum;
+ gchar *id;
+ gchar *msg;
+ gint num;
+ gchar **paths;
+ gint i;
+ FolderItem *item;
+
+ g_return_val_if_fail(msginfo != NULL, -1);
+
+ file = procmsg_get_message_file(msginfo);
+
+ if ((fp = g_fopen(file, "rb")) == NULL) {
+ FILE_OP_ERROR(file, "fopen");
+ return -1;
+ }
+
+ while ((hnum = procheader_get_one_field(buf, sizeof(buf), fp, hentry))
+ != -1) {
+ str = buf + strlen(hentry[hnum].name);
+ while (g_ascii_isspace(*str))
+ ++str;
+ if ((hnum == H_X_SYLPHEED_REPLY || hnum == H_REP) &&
+ !compose->replyto) {
+ id = g_path_get_dirname(str);
+ msg = g_path_get_basename(str);
+ 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) {
+ compose->replyinfo =
+ folder_item_get_msginfo(item, num);
+ }
+ g_free(msg);
+ g_free(id);
+ } else if (hnum == H_X_SYLPHEED_FORWARD || hnum == H_FWD) {
+ paths = g_strsplit(str, "\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 *msginfo;
+ msginfo = folder_item_get_msginfo
+ (item, num);
+ if (msginfo)
+ compose->forward_mlist = g_slist_append(compose->forward_mlist, msginfo);
+ }
+ g_free(msg);
+ g_free(id);
+ }
+ g_strfreev(paths);
+ }
+ }
+
+ fclose(fp);
+ g_free(file);
+
+ return 0;
+}
+
static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
const gchar *fmt, const gchar *qmark,
const gchar *body)
@@ -4099,10 +4186,39 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
procmime_get_encoding_str(encoding));
}
- /* X-Sylpheed header */
- if (is_draft)
+ /* X-Sylpheed headers */
+ if (is_draft) {
+ gchar *id;
+
fprintf(fp, "X-Sylpheed-Account-Id: %d\n",
compose->account->account_id);
+ if (compose->replyinfo) {
+ id = folder_item_get_identifier
+ (compose->replyinfo->folder);
+ if (id) {
+ fprintf(fp, "X-Sylpheed-Reply: %s/%u\n",
+ id, compose->replyinfo->msgnum);
+ g_free(id);
+ }
+ } else if (compose->forward_mlist) {
+ MsgInfo *fwinfo =
+ (MsgInfo *)compose->forward_mlist->data;
+ GSList *cur;
+
+ id = folder_item_get_identifier(fwinfo->folder);
+ if (id) {
+ fprintf(fp, "X-Sylpheed-Forward: %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);
+ }
+ }
+ }
/* separator between header and body */
fputs("\n", fp);
diff --git a/src/send_message.c b/src/send_message.c
index 1adcf542..01b9b4ed 100644
--- a/src/send_message.c
+++ b/src/send_message.c
@@ -199,6 +199,8 @@ QueueInfo *send_get_queue_info(const gchar *file)
qinfo->replyinfo =
procmsg_get_msginfo(item, num);
}
+ g_free(msg);
+ g_free(id);
break;
case Q_FORWARD_TARGETS:
paths = g_strsplit(p, "\n", 0);
@@ -214,6 +216,8 @@ QueueInfo *send_get_queue_info(const gchar *file)
if (msginfo)
qinfo->forward_mlist = g_slist_append(qinfo->forward_mlist, msginfo);
}
+ g_free(msg);
+ g_free(id);
}
g_strfreev(paths);
break;