Package: sylpheed
Severity: wishlist
Tags: patch

Hi,

I've made a patch to support the In-Reply-To in the mailto: url.

This is usefull for example with debian's mailing list to directly
answer a particular message from the archives.

I've already sent it to the sylpheed ml but I didn't get any answer, so
I post it here to avoid losing it.

Regards

Laurent Bigonville
Index: libsylph/utils.c
===================================================================
--- libsylph/utils.c	(révision 1531)
+++ libsylph/utils.c	(copie de travail)
@@ -1725,7 +1725,7 @@
 }
 
 gint scan_mailto_url(const gchar *mailto, gchar **to, gchar **cc, gchar **bcc,
-		     gchar **subject, gchar **body)
+		     gchar **subject, gchar **body, gchar **inreplyto)
 {
 	gchar *tmp_mailto;
 	gchar *p;
@@ -1741,8 +1741,10 @@
 		p++;
 	}
 
-	if (to && !*to)
-		*to = g_strdup(tmp_mailto);
+	if (to && !*to) {
+		*to = g_malloc(strlen(tmp_mailto) + 1);
+		decode_uri(*to, tmp_mailto);
+	}
 
 	while (p) {
 		gchar *field, *value;
@@ -1765,9 +1767,11 @@
 		if (*value == '\0') continue;
 
 		if (cc && !*cc && !g_ascii_strcasecmp(field, "cc")) {
-			*cc = g_strdup(value);
+			*cc = g_malloc(strlen(value) + 1);
+			decode_uri(*cc, value);
 		} else if (bcc && !*bcc && !g_ascii_strcasecmp(field, "bcc")) {
-			*bcc = g_strdup(value);
+			*bcc = g_malloc(strlen(value) + 1);
+			decode_uri(*bcc, value);
 		} else if (subject && !*subject &&
 			   !g_ascii_strcasecmp(field, "subject")) {
 			*subject = g_malloc(strlen(value) + 1);
@@ -1776,6 +1780,10 @@
 			   !g_ascii_strcasecmp(field, "body")) {
 			*body = g_malloc(strlen(value) + 1);
 			decode_uri(*body, value);
+		} else if (inreplyto && !*inreplyto && 
+			   !g_ascii_strcasecmp(field, "in-reply-to")) {
+			*inreplyto = g_malloc(strlen(value) + 1);
+			decode_uri(*inreplyto, value);
 		}
 	}
 
Index: libsylph/utils.h
===================================================================
--- libsylph/utils.h	(révision 1531)
+++ libsylph/utils.h	(copie de travail)
@@ -360,7 +360,8 @@
 					 gchar	       **cc,
 					 gchar	       **bcc,
 					 gchar	       **subject,
-					 gchar	       **body);
+					 gchar	       **body,
+					 gchar         **inreplyto);
 
 void set_startup_dir			(void);
 void set_rc_dir				(const gchar	*dir);
Index: src/compose.c
===================================================================
--- src/compose.c	(révision 1531)
+++ src/compose.c	(copie de travail)
@@ -1278,8 +1278,9 @@
 	gchar *cc = NULL;
 	gchar *subject = NULL;
 	gchar *body = NULL;
+	gchar *inreplyto = NULL;
 
-	scan_mailto_url(mailto, &to, &cc, NULL, &subject, &body);
+	scan_mailto_url(mailto, &to, &cc, NULL, &subject, &body, &inreplyto);
 
 	if (to)
 		compose_entry_set(compose, to, COMPOSE_ENTRY_TO);
@@ -1307,11 +1308,15 @@
 		if (compose->autowrap)
 			compose_wrap_all(compose);
 	}
+	if (inreplyto) {
+		compose->inreplyto = g_strdup(inreplyto);
+	}
 
 	g_free(to);
 	g_free(cc);
 	g_free(subject);
 	g_free(body);
+	g_free(inreplyto);
 }
 
 static void compose_entries_set_from_item(Compose *compose, FolderItem *item,
@@ -1424,7 +1429,7 @@
 		extract_address(hentry[H_LIST_POST].body);
 		if (hentry[H_LIST_POST].body[0] != '\0') {
 			scan_mailto_url(hentry[H_LIST_POST].body,
-					&to, NULL, NULL, NULL, NULL);
+					&to, NULL, NULL, NULL, NULL, NULL);
 			if (to) {
 				g_free(compose->ml_post);
 				compose->ml_post = to;
@@ -3842,8 +3847,13 @@
 	}
 
 	/* In-Reply-To */
-	if (compose->inreplyto && compose->to_list)
-		fprintf(fp, "In-Reply-To: <%s>\n", compose->inreplyto);
+	if (compose->inreplyto && compose->to_list && strlen(compose->inreplyto) > 0) {
+		if (compose->inreplyto[0] == '<'
+		   && compose->inreplyto[strlen(compose->inreplyto)-1] == '>')
+			fprintf(fp, "In-Reply-To: %s\n", compose->inreplyto);
+		else
+			fprintf(fp, "In-Reply-To: <%s>\n", compose->inreplyto);
+	}
 
 	/* References */
 	if (compose->references)

Attachment: pgp95JDwc1uhE.pgp
Description: PGP signature

Reply via email to