[PATCH] revisited Re: Reply to Group?
- From: Peter Bloomfield <PeterBloomfield MindSpring com>
- To: balsa-list gnome org
- Subject: [PATCH] revisited Re: Reply to Group?
- Date: Thu, 15 Nov 2001 16:37:09 -0500
Here's a reworked patch, that tries to parse a List-Post header-line
more along the lines of RFC 2369. It ignores the line if the value
doesn't begin with '<', and it parses a comma-separated list of
alternative angle-bracket-enclosed URLs looking for the first `mailto:'
URL. Not finding one, it will then look for `x-beenthere' and
`x-mailing-list' lines.
This patch, against current cvs, *replaces* the earlier one.
Comments and suggestions welcome!
Peter
diff -dNru --exclude-from=excl balsa-cvs/src/sendmsg-window.c balsa-lists/src/sendmsg-window.c
--- balsa-cvs/src/sendmsg-window.c Mon Nov 12 17:15:12 2001
+++ balsa-lists/src/sendmsg-window.c Thu Nov 15 16:22:30 2001
@@ -123,6 +123,7 @@
static void sw_size_alloc_cb(GtkWidget * window, GtkAllocation * alloc);
static GString *
quoteBody(BalsaSendmsg * msg, LibBalsaMessage * message, SendType type);
+static void set_list_post_address(BalsaSendmsg * msg);
/* Standard DnD types */
enum {
@@ -2229,24 +2230,7 @@
gtk_entry_set_text(GTK_ENTRY(msg->to[1]), tmp);
g_free(tmp);
} else if ( type == SEND_REPLY_GROUP ) {
- if ( message->mailbox->mailing_list_address ) {
- tmp = libbalsa_address_to_gchar
- (message->mailbox->mailing_list_address, 0);
- gtk_entry_set_text(GTK_ENTRY(msg->to[1]), tmp);
- g_free(tmp);
- } else {
- GList *lst, *p;
- gchar **pair;
-
- lst = libbalsa_message_user_hdrs(message);
- for (p = g_list_first(lst); p; p = g_list_next(p)) {
- pair = p->data;
- if ( libbalsa_find_word(pair[0], "x-beenthere x-mailing-list to") )
- gtk_entry_set_text(GTK_ENTRY(msg->to[1]), pair[1]);
- g_strfreev(pair);
- }
- g_list_free(lst);
- }
+ set_list_post_address(msg);
}
/* Get the identity from the To: field of the original message */
@@ -3436,3 +3420,83 @@
return bsmsg;
}
+
+/* set_list_post_address:
+ * look for the address for posting messages to a list */
+static void
+set_list_post_address(BalsaSendmsg * msg)
+{
+ LibBalsaMessage *message = msg->orig_message;
+
+ if (message->mailbox->mailing_list_address) {
+ gchar *tmp =
+ libbalsa_address_to_gchar(message->mailbox->
+ mailing_list_address, 0);
+ gtk_entry_set_text(GTK_ENTRY(msg->to[1]), tmp);
+ g_free(tmp);
+ } else {
+ GList *lst, *p;
+ gchar **pair;
+
+ printf("Looking for list post address:");
+ lst = libbalsa_message_user_hdrs(message);
+ /* RFC 2369: look for "list-post": */
+ for (p = g_list_first(lst); p; p = g_list_next(p)) {
+ pair = p->data;
+ if (libbalsa_find_word(pair[0], "list-post")) {
+ gchar *url = pair[1];
+ printf(" found \"%s:%s\"\n", pair[0], url);
+ if (*url != '<')
+ /* RFC 2369: the field SHOULD be ignored */
+ continue;
+ /* RFC 2369: should use the left-most protocol that
+ * we support */
+ do {
+ gchar *close = strchr(++url, '>');
+ if (close)
+ *close = '\0';
+ if (g_strncasecmp(url, "mailto:", 7) == 0)
+ /* we support mailto! */
+ break;
+ if (close && *++close
+ && *(url = g_strchug(close)) == ',')
+ /* RFC 2369: Any characters following an
+ * angle bracket enclosed URL SHOULD be
+ * ignored, unless a comma is the first
+ * non-whitespace/comment character after
+ * the closing angle bracket. */
+ url = strchr(url, '<');
+ else
+ url = NULL;
+ } while (url);
+
+ if (url) {
+ printf("Address: \"%s\"\n", url + 7);
+ sendmsg_window_process_url(url + 7,
+ sendmsg_window_set_field,
+ msg);
+ break;
+ }
+ }
+ }
+
+ if (!p) {
+ /* we didn't find "list-post", so try some nonstandard
+ * alternatives: */
+ printf(" no list-post, ");
+ for (p = g_list_first(lst); p; p = g_list_next(p)) {
+ pair = p->data;
+ if (libbalsa_find_word(pair[0],
+ "x-beenthere x-mailing-list")) {
+ printf(" found \"%s:%s\"\n", pair[0], pair[1]);
+ gtk_entry_set_text(GTK_ENTRY(msg->to[1]), pair[1]);
+ break;
+ }
+ }
+ if (!p)
+ printf(" no useful x-* headers either!\n");
+ }
+ g_list_foreach(lst, (GFunc) g_strfreev, NULL);
+ g_list_free(lst);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]