X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fmessages.c;h=2915ce1480d5b623c2320395ee8e7cad63830c56;hb=7ba7f73f95cad7f4ecd7f986e12095e9bb546126;hp=6e30c98d30e2f3f176a2be4df1afdb5cff39ade3;hpb=a773f0786e2b7884703bdc4067bef08526881f57;p=citadel.git
diff --git a/webcit/messages.c b/webcit/messages.c
index 6e30c98d3..2915ce148 100644
--- a/webcit/messages.c
+++ b/webcit/messages.c
@@ -1,10 +1,27 @@
/*
* Functions which deal with the fetching and displaying of messages.
+ *
+ * Copyright (c) 1996-2011 by the citadel.org team
+ *
+ * This program is open source software. You can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "webcit.h"
#include "webserver.h"
-#include "groupdav.h"
+#include "dav.h"
+#include "calendar.h"
HashList *MsgHeaderHandler = NULL;
HashList *MsgEvaluators = NULL;
@@ -30,7 +47,6 @@ int load_message(message_summary *Msg,
StrBuf *FoundCharset,
StrBuf **Error)
{
- wcsession *WCC = WC;
StrBuf *Buf;
StrBuf *HdrToken;
headereval *Hdr;
@@ -52,7 +68,7 @@ int load_message(message_summary *Msg,
*Error = NewStrBuf();
StrBufAppendPrintf(*Error, "");
StrBufAppendPrintf(*Error, _("ERROR:"));
- StrBufAppendPrintf(*Error, " %s
\n", &buf[4]);
+ StrBufAppendPrintf(*Error, " %s
\n", &buf[4]);
FreeStrBuf(&Buf);
return 0;
}
@@ -70,7 +86,7 @@ int load_message(message_summary *Msg,
Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/html"));
StrBufAppendPrintf(Msg->MsgBody->Data, "
0) {
+ StrBuf *refs = NewStrBuf();
+ if (StrLength(wefw) > 0) {
+ StrBufAppendBuf(refs, wefw, 0);
+ }
+ if ( (StrLength(wefw) > 0) &&
+ (StrLength(msgn) > 0) )
+ {
+ StrBufAppendBufPlain(refs, HKEY("|"), 0);
+ }
+ if (StrLength(msgn) > 0) {
+ StrBufAppendBuf(refs, msgn, 0);
+ }
+ PutBstr(HKEY("references"), refs);
+ }
+
+ /*
+ * If this is a Reply or a ReplyAll, copy the sender's email into the To: field
+ */
+ if ( (!strcasecmp(bstr("replying_mode"), "reply"))
+ || (!strcasecmp(bstr("replying_mode"), "replyall"))
+ ) {
+ StrBuf *to_rcpt;
+ if (StrLength(rfca) > 0) {
+ to_rcpt = NewStrBuf();
+ StrBufAppendBuf(to_rcpt, from, 0);
+ StrBufAppendBufPlain(to_rcpt, HKEY(" <"), 0);
+ StrBufAppendBuf(to_rcpt, rfca, 0);
+ StrBufAppendBufPlain(to_rcpt, HKEY(">"), 0);
+ }
+ else {
+ to_rcpt = from;
+ from = NULL;
+ if ( (StrLength(node) > 0)
+ && (strcasecmp(ChrPtr(node), ChrPtr(WC->serv_info->serv_nodename)))
+ ) {
+ StrBufAppendBufPlain(to_rcpt, HKEY(" @ "), 0);
+ StrBufAppendBuf(to_rcpt, node, 0);
+ }
+ }
+ PutBstr(HKEY("recp"), to_rcpt);
+ }
+
+ /*
+ * Only if this is a ReplyAll, copy all recipients into the Cc: field
+ */
+ if ( (!strcasecmp(bstr("replying_mode"), "replyall"))
+ ) {
+ StrBuf *cc_rcpt = rcpt;
+ rcpt = NULL;
+ if (StrLength(cccc) > 0) {
+ if (cc_rcpt != NULL) {
+ StrBufAppendPrintf(cc_rcpt, ", ");
+ StrBufAppendBuf(cc_rcpt, cccc, 0);
+ } else {
+ cc_rcpt = cccc;
+ cccc = NULL;
+ }
+ }
+ if (cc_rcpt != NULL)
+ PutBstr(HKEY("cc"), cc_rcpt);
+ }
+ FreeStrBuf(&wefw);
+ FreeStrBuf(&msgn);
+ FreeStrBuf(&from);
+ FreeStrBuf(&node);
+ FreeStrBuf(&rfca);
+ FreeStrBuf(&rcpt);
+ FreeStrBuf(&cccc);
+ }
+ FreeStrBuf(&Line);
/*
* Otherwise proceed normally.
* Do a custom room banner with no navbar...
@@ -1411,20 +1591,22 @@ void display_enter(void)
ChrPtr(Bcc),
ChrPtr(Wikipage));
serv_puts(ChrPtr(CmdBuf));
- serv_getln(buf, sizeof buf);
- FreeStrBuf(&CmdBuf);
+ StrBuf_ServGetln(CmdBuf);
- if (!strncmp(buf, "570", 3)) { /* 570 means we have an invalid recipient listed */
- if (havebstr("recp") &&
- havebstr("cc" ) &&
- havebstr("bcc" )) {
- recipient_bad = 1;
- }
+ rc = GetServerStatusMsg(CmdBuf, &Result, 0, 0);
+
+ 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 (buf[0] != '2') { /* Any other error means that we cannot continue */
- wc_printf("%s
\n", &buf[4]); /* TODO -> important message */
+ else if (rc != 2) { /* Any other error means that we cannot continue */
+ AppendImportantMessage(ChrPtr(CmdBuf) + 4, StrLength(CmdBuf) - 4);
+ FreeStrBuf(&CmdBuf);
+ readloop(readnew, eUseDefault);
return;
}
+ FreeStrBuf(&CmdBuf);
}
if (recipient_required)
PutBstr(HKEY("__RCPTREQUIRED"), NewStrBufPlain(HKEY("1")));
@@ -1445,10 +1627,10 @@ void display_enter(void)
void delete_msg(void)
{
long msgid;
- char buf[SIZ];
-
+ StrBuf *Line;
+
msgid = lbstr("msgid");
-
+ Line = NewStrBuf();
if ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
serv_printf("DELE %ld", msgid);
}
@@ -1456,8 +1638,9 @@ void delete_msg(void)
serv_printf("MOVE %ld|_TRASH_|0", msgid);
}
- serv_getln(buf, sizeof buf);
- sprintf(WC->ImportantMessage, "%s", &buf[4]);
+ StrBuf_ServGetln(Line);
+ GetServerStatusMsg(Line, NULL, 1, 0);
+
readloop(readnew, eUseDefault);
}
@@ -1468,76 +1651,24 @@ void delete_msg(void)
void move_msg(void)
{
long msgid;
- char buf[SIZ];
msgid = lbstr("msgid");
if (havebstr("move_button")) {
- sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
- serv_puts(buf);
- serv_getln(buf, sizeof buf);
- sprintf(WC->ImportantMessage, "%s", &buf[4]);
+ StrBuf *Line;
+ serv_printf("MOVE %ld|%s", msgid, bstr("target_room"));
+ Line = NewStrBuf();
+ StrBuf_ServGetln(Line);
+ GetServerStatusMsg(Line, NULL, 1, 0);
+ FreeStrBuf(&Line);
} else {
- sprintf(WC->ImportantMessage, (_("The message was not moved.")));
+ AppendImportantMessage(_("The message was not moved."), -1);
}
readloop(readnew, eUseDefault);
}
-/*
- * Confirm move of a message
- */
-void confirm_move_msg(void)
-{
- long msgid;
- char buf[SIZ];
- char targ[SIZ];
-
- msgid = lbstr("msgid");
-
-
- output_headers(1, 1, 2, 0, 0, 0);
- wc_printf("\n");
- wc_printf("
");
- wc_printf(_("Confirm move of message"));
- wc_printf("
");
- wc_printf("\n");
-
- wc_printf("\n");
-
- wc_printf("
");
-
- wc_printf(_("Move this message to:"));
- wc_printf("
\n");
-
- wc_printf("\n");
-
- wc_printf("\n");
- wDumpContent(1);
-}
-
/*
* Generic function to output an arbitrary MIME attachment from
@@ -1590,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;
@@ -1603,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) {
@@ -1627,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();
@@ -1828,11 +1976,9 @@ InitModule_MSG
WebcitAddUrlHandler(HKEY("post"), "", 0, post_message, PROHIBIT_STARTPAGE);
WebcitAddUrlHandler(HKEY("move_msg"), "", 0, move_msg, PROHIBIT_STARTPAGE);
WebcitAddUrlHandler(HKEY("delete_msg"), "", 0, delete_msg, PROHIBIT_STARTPAGE);
- WebcitAddUrlHandler(HKEY("confirm_move_msg"), "", 0, confirm_move_msg, PROHIBIT_STARTPAGE);
WebcitAddUrlHandler(HKEY("msg"), "", 0, embed_message, NEED_URL);
WebcitAddUrlHandler(HKEY("message"), "", 0, handle_one_message, NEED_URL|XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
WebcitAddUrlHandler(HKEY("printmsg"), "", 0, print_message, NEED_URL);
- WebcitAddUrlHandler(HKEY("mobilemsg"), "", 0, mobile_message_view, NEED_URL);
WebcitAddUrlHandler(HKEY("msgheaders"), "", 0, display_headers, NEED_URL);
WebcitAddUrlHandler(HKEY("mimepart"), "", 0, view_mimepart, NEED_URL);
@@ -1845,6 +1991,16 @@ InitModule_MSG
/* json */
WebcitAddUrlHandler(HKEY("roommsgs"), "", 0, jsonMessageList,0);
+
+ l_subj = FourHash("subj", 4);
+ l_wefw = FourHash("wefw", 4);
+ l_msgn = FourHash("msgn", 4);
+ l_from = FourHash("from", 4);
+ l_rcpt = FourHash("rcpt", 4);
+ l_cccc = FourHash("cccc", 4);
+ l_node = FourHash("node", 4);
+ l_rfca = FourHash("rfca", 4);
+
return ;
}