X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fmessages.c;h=2915ce1480d5b623c2320395ee8e7cad63830c56;hb=7ba7f73f95cad7f4ecd7f986e12095e9bb546126;hp=207787d67fbcb626f7c51fb62dc28c664b189034;hpb=24f66e82047af56aab3b95912b13104aa71fb956;p=citadel.git diff --git a/webcit/messages.c b/webcit/messages.c index 207787d67..2915ce148 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -20,7 +20,7 @@ #include "webcit.h" #include "webserver.h" -#include "groupdav.h" +#include "dav.h" #include "calendar.h" HashList *MsgHeaderHandler = NULL; @@ -1007,13 +1007,13 @@ void post_message(void) const StrBuf *my_email_addr = NULL; StrBuf *CmdBuf = NULL; StrBuf *references = NULL; - int save_to_drafts; - long HeaderLen; + int saving_to_drafts = 0; + long HeaderLen = 0; - save_to_drafts = !strcasecmp(bstr("submit_action"), "drafts"); + saving_to_drafts = !strcasecmp(bstr("submit_action"), "draft"); Buf = NewStrBuf(); - if (save_to_drafts) { + if (saving_to_drafts) { /* temporarily change to the drafts room */ serv_puts("GOTO _DRAFTS_"); StrBuf_ServGetln(Buf); @@ -1071,12 +1071,12 @@ void post_message(void) CmdBuf = NewStrBufPlain(NULL, sizeof (CMD) + HeaderLen); StrBufPrintf(CmdBuf, CMD, - save_to_drafts?"":ChrPtr(Recp), + saving_to_drafts?"":ChrPtr(Recp), is_anonymous, ChrPtr(encoded_subject), ChrPtr(display_name), - save_to_drafts?"":ChrPtr(Cc), - save_to_drafts?"":ChrPtr(Bcc), + saving_to_drafts?"":ChrPtr(Cc), + saving_to_drafts?"":ChrPtr(Bcc), ChrPtr(Wikipage), ChrPtr(my_email_addr), ChrPtr(references)); @@ -1097,7 +1097,7 @@ void post_message(void) StrBuf_ServGetln(Buf); if (GetServerStatus(Buf, NULL) == 4) { - if (save_to_drafts) { + if (saving_to_drafts) { if ( (havebstr("recp")) || (havebstr("cc" )) || (havebstr("bcc" )) ) { @@ -1110,10 +1110,10 @@ void post_message(void) } } post_mime_to_server(); - if (save_to_drafts) { + if (saving_to_drafts) { AppendImportantMessage(_("Message has been saved to Drafts.\n"), -1); gotoroom(WCC->CurRoom.name); - display_enter(); + readloop(readnew, eUseDefault); FreeStrBuf(&Buf); return; } else if ( (havebstr("recp")) @@ -1127,10 +1127,11 @@ void post_message(void) } dont_post = lbstr("postseq"); } else { - syslog(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, ChrPtr(Buf) + 4); + syslog(9, "%s:%d: server post error: %s", __FILE__, __LINE__, ChrPtr(Buf) + 4); AppendImportantMessage(ChrPtr(Buf) + 4, StrLength(Buf) - 4); - if (save_to_drafts) gotoroom(WCC->CurRoom.name); display_enter(); + if (saving_to_drafts) gotoroom(WCC->CurRoom.name); + FreeStrBuf(&Recp); FreeStrBuf(&Buf); FreeStrBuf(&Cc); FreeStrBuf(&Bcc); @@ -1306,7 +1307,6 @@ void display_enter(void) const StrBuf *display_name = NULL; int recipient_required = 0; int subject_required = 0; - int recipient_bad = 0; int is_anonymous = 0; wcsession *WCC = WC; int i = 0; @@ -1322,7 +1322,9 @@ void display_enter(void) is_anonymous = 1; } - /* First test to see whether this is a room that requires recipients to be entered */ + /* + * First, do we have permission to enter messages in this room at all? + */ Line = NewStrBuf(); serv_puts("ENT0 0"); StrBuf_ServGetln(Line); @@ -1593,16 +1595,15 @@ void display_enter(void) rc = GetServerStatusMsg(CmdBuf, &Result, 0, 0); - if (Result == 570) { /* 570 means we have an invalid recipient listed */ - if (havebstr("recp") && - havebstr("cc" ) && - havebstr("bcc" )) { - recipient_bad = 1; /* TODO: and now????? */ - } + if ( (Result == 570) /* invalid or missing recipient(s) */ + || (Result == 550) /* higher access required to send Internet mail */ + ) { + /* These errors will have been displayed and are excusable */ } else if (rc != 2) { /* Any other error means that we cannot continue */ - wc_printf("%s
\n", ChrPtr(CmdBuf) +4); /* TODO -> important message */ + AppendImportantMessage(ChrPtr(CmdBuf) + 4, StrLength(CmdBuf) - 4); FreeStrBuf(&CmdBuf); + readloop(readnew, eUseDefault); return; } FreeStrBuf(&CmdBuf); @@ -1720,6 +1721,7 @@ void postpart(StrBuf *partnum, StrBuf *filename, int force_download) void mimepart(int force_download) { long msgnum; + long ErrorDetail; StrBuf *att; wcsession *WCC = WC; StrBuf *Buf; @@ -1733,7 +1735,7 @@ void mimepart(int force_download) serv_printf("OPNA %ld|%s", msgnum, ChrPtr(att)); StrBuf_ServGetln(Buf); - if (GetServerStatus(Buf, NULL) == 2) { + if (GetServerStatus(Buf, &ErrorDetail) == 2) { StrBufCutLeft(Buf, 4); bytes = StrBufExtract_long(Buf, 0, '|'); if (!force_download) { @@ -1757,7 +1759,23 @@ void mimepart(int force_download) http_transmit_thing(CT, 0); } else { StrBufCutLeft(Buf, 4); - hprintf("HTTP/1.1 404 %s\n", ChrPtr(Buf)); + switch (ErrorDetail) { + default: + case ERROR + MESSAGE_NOT_FOUND: + hprintf("HTTP/1.1 404 %s\n", ChrPtr(Buf)); + break; + case ERROR + NOT_LOGGED_IN: + hprintf("HTTP/1.1 401 %s\n", ChrPtr(Buf)); + break; + + case ERROR + HIGHER_ACCESS_REQUIRED: + hprintf("HTTP/1.1 403 %s\n", ChrPtr(Buf)); + break; + case ERROR + INTERNAL_ERROR: + case ERROR + TOO_BIG: + hprintf("HTTP/1.1 500 %s\n", ChrPtr(Buf)); + break; + } output_headers(0, 0, 0, 0, 0, 0); hprintf("Content-Type: text/plain\r\n"); begin_burst();