#include "webcit.h"
#include "webserver.h"
#include "groupdav.h"
+#include "calendar.h"
HashList *MsgHeaderHandler = NULL;
HashList *MsgEvaluators = NULL;
StrBuf *FoundCharset,
StrBuf **Error)
{
- wcsession *WCC = WC;
StrBuf *Buf;
StrBuf *HdrToken;
headereval *Hdr;
/* now we put the body mimepart we read above into the mimelist */
Put(Msg->AllAttach, SKEY(Msg->MsgBody->PartNum), Msg->MsgBody, DestroyMime);
- /* Generate a reply-to address */
- if (StrLength(Msg->Rfca) > 0) {
- if (Msg->reply_to == NULL)
- Msg->reply_to = NewStrBuf();
- if (StrLength(Msg->from) > 0) {
- StrBufPrintf(Msg->reply_to, "%s <%s>", ChrPtr(Msg->from), ChrPtr(Msg->Rfca));
- }
- else {
- FlushStrBuf(Msg->reply_to);
- StrBufAppendBuf(Msg->reply_to, Msg->Rfca, 0);
- }
- }
- else
- {
- if ((StrLength(Msg->OtherNode)>0) &&
- (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_nodename))) &&
- (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_humannode)) ))
- {
- if (Msg->reply_to == NULL)
- Msg->reply_to = NewStrBuf();
- StrBufPrintf(Msg->reply_to,
- "%s @ %s",
- ChrPtr(Msg->from),
- ChrPtr(Msg->OtherNode));
- }
- else {
- if (Msg->reply_to == NULL)
- Msg->reply_to = NewStrBuf();
- FlushStrBuf(Msg->reply_to);
- StrBufAppendBuf(Msg->reply_to, Msg->from, 0);
- }
- }
FreeStrBuf(&Buf);
FreeStrBuf(&HdrToken);
return 1;
}
-void
+long
HttpStatus(long CitadelStatus)
{
long httpstatus = 502;
break;
}
-
+ return httpstatus;
}
/*
GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
}
if (vViewMsg == NULL) {
- return; // TODO: print message
+ return; /* TODO: print message */
}
ViewMsg = (RoomRenderer*) vViewMsg;
void display_enter(void)
{
char buf[SIZ];
- long now;
const StrBuf *display_name = NULL;
int recipient_required = 0;
int subject_required = 0;
int recipient_bad = 0;
int is_anonymous = 0;
wcsession *WCC = WC;
-
- now = time(NULL);
+ int i = 0;
+ long replying_to;
if (havebstr("force_room")) {
gotoroom(sbstr("force_room"));
return;
}
+
+ /*
+ * If the "replying_to" variable is set, it refers to a message
+ * number from which we must extract some header fields...
+ */
+ replying_to = lbstr("replying_to");
+ if (replying_to > 0) {
+ char wefw[1024] = "";
+ char msgn[256] = "";
+ char from[256] = "";
+ char node[256] = "";
+ char rfca[256] = "";
+ char rcpt[SIZ] = "";
+ char cccc[SIZ] = "";
+ serv_printf("MSG0 %ld|1", replying_to);
+ serv_getln(buf, sizeof buf);
+ if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+
+ if ( (!strncasecmp(buf, "subj=", 5)) && (strlen(buf) > 5) ) {
+ StrBuf *subj = NewStrBuf();
+ if (!strcasecmp(bstr("replying_mode"), "forward")) {
+ if (strncasecmp(&buf[5], "Fw:", 3)) {
+ StrBufAppendBufPlain(subj, HKEY("Fw: "), 0);
+ }
+ }
+ else {
+ if (strncasecmp(&buf[5], "Re:", 3)) {
+ StrBufAppendBufPlain(subj, HKEY("Re: "), 0);
+ }
+ }
+ StrBufAppendBufPlain(subj, &buf[5], -1, 0);
+ PutBstr(HKEY("subject"), subj);
+ }
+
+ else if (!strncasecmp(buf, "wefw=", 5)) {
+ int rrtok;
+ int rrlen;
+ safestrncpy(wefw, &buf[5], sizeof wefw);
+
+ /* Trim down excessively long lists of thread references. We eliminate the
+ * second one in the list so that the thread root remains intact.
+ */
+ rrtok = num_tokens(wefw, '|');
+ rrlen = strlen(wefw);
+ if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
+ remove_token(wefw, 1, '|');
+ }
+ }
+
+ else if (!strncasecmp(buf, "msgn=", 5)) {
+ safestrncpy(msgn, &buf[5], sizeof msgn);
+ }
+
+ else if (!strncasecmp(buf, "from=", 5)) {
+ safestrncpy(from, &buf[5], sizeof from);
+ for (i=0; i<strlen(from); ++i) {
+ if (from[i] == ',') from[i] = ' ';
+ }
+ }
+
+ else if (!strncasecmp(buf, "rcpt=", 5)) {
+ safestrncpy(rcpt, &buf[5], sizeof rcpt);
+ }
+
+ else if (!strncasecmp(buf, "cccc=", 5)) {
+ safestrncpy(cccc, &buf[5], sizeof cccc);
+ }
+
+ else if (!strncasecmp(buf, "node=", 5)) {
+ safestrncpy(node, &buf[5], sizeof node);
+ }
+
+ else if (!strncasecmp(buf, "rfca=", 5)) {
+ safestrncpy(rfca, &buf[5], sizeof rfca);
+ }
+
+ }
+
+ if (strlen(wefw) + strlen(msgn) > 0) {
+ StrBuf *refs = NewStrBuf();
+ if (!IsEmptyStr(wefw)) {
+ StrBufAppendBufPlain(refs, wefw, -1, 0);
+ }
+ if ( (!IsEmptyStr(wefw)) && (!IsEmptyStr(msgn)) ) {
+ StrBufAppendBufPlain(refs, HKEY("|"), 0);
+ }
+ if (!IsEmptyStr(msgn)) {
+ StrBufAppendBufPlain(refs, msgn, -1, 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 = NewStrBuf();
+ if (!IsEmptyStr(rfca)) {
+ StrBufAppendPrintf(to_rcpt, "%s <%s>", from, rfca);
+ }
+ else {
+ StrBufAppendPrintf(to_rcpt, "%s", from);
+ if ( (!IsEmptyStr(node))
+ && (strcasecmp(node, ChrPtr(WC->serv_info->serv_nodename)))
+ ) {
+ StrBufAppendPrintf(to_rcpt, " @ %s", node);
+ }
+ }
+ 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 = NewStrBuf();
+ if (!IsEmptyStr(rcpt)) {
+ StrBufAppendPrintf(cc_rcpt, "%s", rcpt);
+ }
+ if ( (!IsEmptyStr(rcpt)) && (!IsEmptyStr(cccc)) ) {
+ StrBufAppendPrintf(cc_rcpt, ", ");
+ }
+ if (!IsEmptyStr(cccc)) {
+ StrBufAppendPrintf(cc_rcpt, "%s", cccc);
+ }
+ PutBstr(HKEY("cc"), cc_rcpt);
+ }
+
+ }
+
/*
* Otherwise proceed normally.
* Do a custom room banner with no navbar...
if (havebstr("recp") &&
havebstr("cc" ) &&
havebstr("bcc" )) {
- recipient_bad = 1;
+ recipient_bad = 1; /* TODO: and now????? */
}
}
else if (buf[0] != '2') { /* Any other error means that we cannot continue */
}
-/*
- * 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("<div id=\"banner\">\n");
- wc_printf("<h1>");
- wc_printf(_("Confirm move of message"));
- wc_printf("</h1>");
- wc_printf("</div>\n");
-
- wc_printf("<div id=\"content\" class=\"service\">\n");
-
- wc_printf("<CENTER>");
-
- wc_printf(_("Move this message to:"));
- wc_printf("<br>\n");
-
- wc_printf("<form METHOD=\"POST\" action=\"move_msg\">\n");
- wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
- wc_printf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
-
- wc_printf("<SELECT NAME=\"target_room\" SIZE=5>\n");
- serv_puts("LKRA");
- serv_getln(buf, sizeof buf);
- if (buf[0] == '1') {
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- extract_token(targ, buf, 0, '|', sizeof targ);
- wc_printf("<OPTION>");
- escputs(targ);
- wc_printf("\n");
- }
- }
- wc_printf("</SELECT>\n");
- wc_printf("<br>\n");
-
- wc_printf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
- wc_printf(" ");
- wc_printf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
- wc_printf("</form></CENTER>\n");
-
- wc_printf("</CENTER>\n");
- wDumpContent(1);
-}
-
/*
* Generic function to output an arbitrary MIME attachment from
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);