From: Art Cancro Date: Sat, 14 Oct 2006 22:11:48 +0000 (+0000) Subject: * Implemented the 'getsubaddress' callback, but then realized X-Git-Tag: v7.86~3903 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=b6c5ea1c7a079037339669e15fa4d002acb71374 * Implemented the 'getsubaddress' callback, but then realized that it is actually more proper to return SIEVE2_ERROR_UNSUPPORTED because Citadel doesn't have subaddresses. --- diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index a8487d38a..a456e3266 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -164,6 +164,8 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) strcpy(node, config.c_fqdn); strcpy(name, ""); + if (rfc822 == NULL) return; + /* extract full name - first, it's From minus */ strcpy(name, rfc822); stripout(name, '<', '>'); diff --git a/citadel/serv_sieve.c b/citadel/serv_sieve.c index bf096a6c7..0faaf3980 100644 --- a/citadel/serv_sieve.c +++ b/citadel/serv_sieve.c @@ -42,6 +42,7 @@ #include "policy.h" #include "database.h" #include "msgbase.h" +#include "internet_addressing.h" #include "tools.h" #ifdef HAVE_LIBSIEVE @@ -245,11 +246,25 @@ int ctdl_vacation(sieve2_context_t *s, void *my) /* * Callback function to parse addresses per local system convention - * FIXME implement this */ int ctdl_getsubaddress(sieve2_context_t *s, void *my) { + struct ctdl_sieve *cs = (struct ctdl_sieve *)my; + + /* + * Citadel doesn't support subaddresses, so just give up. + */ return SIEVE2_ERROR_UNSUPPORTED; + + /* libSieve does not take ownership of the memory used here. But, since we + * are just pointing to locations inside a struct which we are going to free + * later, we're ok. + */ + sieve2_setvalue_string(s, "user", cs->recp_user); + sieve2_setvalue_string(s, "detail", ""); /* we don't support user+detail@domain yet */ + sieve2_setvalue_string(s, "localpart", cs->recp_user); + sieve2_setvalue_string(s, "domain", cs->recp_node); + return SIEVE2_OK; } @@ -361,13 +376,17 @@ void sieve_do_msg(long msgnum, void *userdata) { sieve2_context_t *sieve2_context = u->sieve2_context; struct ctdl_sieve my; int res; + struct CtdlMessage *msg; lprintf(CTDL_DEBUG, "Performing sieve processing on msg <%ld>\n", msgnum); + msg = CtdlFetchMessage(msgnum, 0); + if (msg == NULL) return; + CC->redirect_buffer = malloc(SIZ); CC->redirect_len = 0; CC->redirect_alloc = SIZ; - CtdlOutputMsg(msgnum, MT_RFC822, HEADERS_ONLY, 0, 1, NULL); + CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ONLY, 0, 1); my.rfc822headers = CC->redirect_buffer; CC->redirect_buffer = NULL; CC->redirect_len = 0; @@ -379,6 +398,11 @@ void sieve_do_msg(long msgnum, void *userdata) { my.msgnum = msgnum; /* Keep track of the message number in our local store */ my.u = u; /* Hand off a pointer to the rest of this info */ + /* Keep track of the recipient so we can do handling based on it later */ + process_rfc822_addr(msg->cm_fields['R'], my.recp_user, my.recp_node, my.recp_name); + + free(msg); + sieve2_setvalue_string(sieve2_context, "allheaders", my.rfc822headers); lprintf(CTDL_DEBUG, "Calling sieve2_execute()\n"); diff --git a/citadel/serv_sieve.h b/citadel/serv_sieve.h index b58f2c72b..a8c6f52af 100644 --- a/citadel/serv_sieve.h +++ b/citadel/serv_sieve.h @@ -30,6 +30,9 @@ struct ctdl_sieve { long usernum; /* Owner of the mailbox we're processing */ long msgnum; /* Message base ID of the message being processed */ struct sdm_userdata *u; /* Info related to the current session */ + char recp_user[256]; + char recp_node[256]; + char recp_name[256]; };