From: Art Cancro Date: Wed, 26 Mar 2008 21:15:32 +0000 (+0000) Subject: Handle RFC822 'References:' field and Citadel W (Wefewences) field X-Git-Tag: v7.86~2382 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=2bfaf9b78162ffd9a7604431ed6f35acb1468104 Handle RFC822 'References:' field and Citadel W (Wefewences) field --- diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index ebc419f6a..6f28a69a3 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -397,12 +397,64 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { processed = 1; } + else if (!strcasecmp(key, "References")) { + if (msg->cm_fields['W'] != NULL) { + free(msg->cm_fields['W']); + } + msg->cm_fields['W'] = strdup(value); + processed = 1; + } + + else if (!strcasecmp(key, "In-reply-to")) { + if (msg->cm_fields['W'] == NULL) { /* References: supersedes In-reply-to: */ + msg->cm_fields['W'] = strdup(value); + } + processed = 1; + } + + + /* Clean up and move on. */ free(key); /* Don't free 'value', it's actually the same buffer */ return(processed); } +/* + * Convert RFC822 references format (References) to Citadel references format (Weferences) + */ +void convert_references_to_wefewences(char *str) { + int bracket_nesting = 0; + char *ptr = str; + char *moveptr = NULL; + char ch; + + while(*ptr) { + ch = *ptr; + if (ch == '>') { + --bracket_nesting; + if (bracket_nesting < 0) bracket_nesting = 0; + } + if ((ch == '>') && (bracket_nesting == 0) && (*(ptr+1)) && (ptr>str) ) { + *ptr = '|'; + ++ptr; + } + else if (bracket_nesting > 0) { + ++ptr; + } + else { + moveptr = ptr; + while (*moveptr) { + *moveptr = *(moveptr+1); + ++moveptr; + } + } + if (ch == '<') ++bracket_nesting; + } + +} + + /* * Convert an RFC822 message (headers + body) to a CtdlMessage structure. * NOTE: the supplied buffer becomes part of the CtdlMessage structure, and @@ -484,6 +536,13 @@ struct CtdlMessage *convert_internet_message(char *rfc822) { msg->cm_fields['T'] = strdup(buf); } + /* If a W (references, or rather, Wefewences) field is present, we + * have to convert it from RFC822 format to Citadel format. + */ + if (msg->cm_fields['W'] != NULL) { + convert_references_to_wefewences(msg->cm_fields['W']); + } + return msg; } diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 74bec403a..81ee81aa8 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -100,7 +100,7 @@ char *msgkeys[] = { "time", "subj", NULL, - NULL, + "wefw", NULL, "cccc", NULL @@ -1689,6 +1689,20 @@ int CtdlOutputPreLoadedMsg( atol(mptr), DATESTRING_RFC822); cprintf("Date: %s%s", datestamp, nl); } + else if (i == 'W') { + cprintf("References: "); + k = num_tokens(mptr, '|'); + for (i=0; i", buf); + if (i == (k-1)) { + cprintf("%s", nl); + } + else { + cprintf(" "); + } + } + } } } if (subject_found == 0) { diff --git a/citadel/server.h b/citadel/server.h index cfdea64cd..302f7f00c 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -397,6 +397,6 @@ struct UseTable { /* ********** Important fields */ /* *************** Semi-important fields */ /* * Message text (MUST be last) */ -#define FORDER "IPTAFONHRDBCEJGKLQSVWXZYUM" +#define FORDER "IPTAFONHRDBCEWJGKLQSVXZYUM" #endif /* SERVER_H */ diff --git a/citadel/techdoc/hack.txt b/citadel/techdoc/hack.txt index 89c5cecea..21ad22039 100644 --- a/citadel/techdoc/hack.txt +++ b/citadel/techdoc/hack.txt @@ -285,8 +285,9 @@ T date/Time A 32-bit integer containing the date and time of U sUbject Optional. Developers may choose whether they wish to generate or display subject fields. V enVelope-to The recipient specified in incoming SMTP messages. -W Weferences Sort of like thread-id + references + in-reply-to - (not yet implemented. coming soon.) +W Wefewences Previous message ID's for conversation threading. When + converting from RFC822 we use References: if present, or + In-Reply-To: otherwise. Y carbon copY Optional, and only in Mail messages. 0 Error This field is typically never found in a message on disk or in transit. Message scanning modules are