X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fimap%2Fimap_misc.c;h=9b15e4208af09f8f4f80752149fc6ff5919073c5;hb=a2fda4eafb51bbf58c04471522aa2d0f116c797e;hp=b8e50c2aa36d52db0200c502262a48e4f1129412;hpb=484502117fc2ce04627e3cc7c0efa40e6c18d272;p=citadel.git diff --git a/citadel/modules/imap/imap_misc.c b/citadel/modules/imap/imap_misc.c index b8e50c2aa..9b15e4208 100644 --- a/citadel/modules/imap/imap_misc.c +++ b/citadel/modules/imap/imap_misc.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "citadel.h" #include "server.h" #include "sysdep_decls.h" @@ -41,14 +42,13 @@ #include "policy.h" #include "database.h" #include "msgbase.h" -#include "tools.h" #include "internet_addressing.h" #include "serv_imap.h" #include "imap_tools.h" #include "imap_fetch.h" #include "imap_misc.h" #include "genstamp.h" - +#include "ctdl_module.h" @@ -351,6 +351,7 @@ void imap_append(int num_parms, char *parms[]) { int msgs, new; int i; char new_message_flags[SIZ]; + struct citimap *Imap; if (num_parms < 4) { cprintf("%s BAD usage error\r\n", parms[0]); @@ -385,20 +386,21 @@ void imap_append(int num_parms, char *parms[]) { return; } + Imap = IMAP; imap_free_transmitted_message(); /* just in case. */ - IMAP->transmitted_message = malloc(literal_length + 1); - if (IMAP->transmitted_message == NULL) { + Imap->transmitted_message = malloc(literal_length + 1); + if (Imap->transmitted_message == NULL) { cprintf("%s NO Cannot allocate memory.\r\n", parms[0]); return; } - IMAP->transmitted_length = literal_length; + Imap->transmitted_length = literal_length; cprintf("+ Transmit message now.\r\n"); bytes_transferred = 0; - ret = client_read(IMAP->transmitted_message, literal_length); - IMAP->transmitted_message[literal_length] = 0; + ret = client_read(Imap->transmitted_message, literal_length); + Imap->transmitted_message[literal_length] = 0; if (ret != 1) { cprintf("%s NO Read failed.\r\n", parms[0]); @@ -412,21 +414,21 @@ void imap_append(int num_parms, char *parms[]) { client_getln(buf, sizeof buf); /* Convert RFC822 newlines (CRLF) to Unix newlines (LF) */ - lprintf(CTDL_DEBUG, "Converting CRLF to LF\n"); + CtdlLogPrintf(CTDL_DEBUG, "Converting CRLF to LF\n"); stripped_length = 0; for (i=0; itransmitted_message[i], "\r\n", 2)) { - IMAP->transmitted_message[stripped_length++] = - IMAP->transmitted_message[i]; + if (strncmp(&Imap->transmitted_message[i], "\r\n", 2)) { + Imap->transmitted_message[stripped_length++] = + Imap->transmitted_message[i]; } } literal_length = stripped_length; - IMAP->transmitted_message[literal_length] = 0; /* reterminate it */ + Imap->transmitted_message[literal_length] = 0; /* reterminate it */ - lprintf(CTDL_DEBUG, "Converting message format\n"); - msg = convert_internet_message(IMAP->transmitted_message); - IMAP->transmitted_message = NULL; - IMAP->transmitted_length = 0; + CtdlLogPrintf(CTDL_DEBUG, "Converting message format\n"); + msg = convert_internet_message(Imap->transmitted_message); + Imap->transmitted_message = NULL; + Imap->transmitted_length = 0; ret = imap_grabroom(roomname, parms[2], 0); if (ret != 0) { @@ -439,7 +441,7 @@ void imap_append(int num_parms, char *parms[]) { * usergoto() formally takes us to the desired room. (If another * folder is selected, save its name so we can return there!!!!!) */ - if (IMAP->selected) { + if (Imap->selected) { strcpy(savedroom, CC->room.QRname); } usergoto(roomname, 0, 0, &msgs, &new); @@ -452,7 +454,7 @@ void imap_append(int num_parms, char *parms[]) { * private mailboxes. */ if (CC->logged_in) { - if ( (CC->room.QRflags & QR_MAILBOX) == 0) { + if ( ((CC->room.QRflags & QR_MAILBOX) == 0) && (config.c_imap_keep_from == 0)) { if (msg->cm_fields['A'] != NULL) free(msg->cm_fields['A']); if (msg->cm_fields['N'] != NULL) free(msg->cm_fields['N']); if (msg->cm_fields['H'] != NULL) free(msg->cm_fields['H']); @@ -465,7 +467,7 @@ void imap_append(int num_parms, char *parms[]) { /* * Can we post here? */ - ret = CtdlDoIHavePermissionToPostInThisRoom(buf, sizeof buf); + ret = CtdlDoIHavePermissionToPostInThisRoom(buf, sizeof buf, NULL, POST_LOGGED_IN); if (ret) { /* Nope ... print an error message */ @@ -493,7 +495,7 @@ void imap_append(int num_parms, char *parms[]) { * If another folder is selected, go back to that room so we can resume * our happy day without violent explosions. */ - if (IMAP->selected) { + if (Imap->selected) { usergoto(savedroom, 0, 0, &msgs, &new); }