X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsmtpqueue.c;h=2004bad8c6141494bb794dd463030063887e60b9;hb=5d38a76f8f06640e3a3f097d584ac52336110f7c;hp=b059ff905be033c10e6001dc3cd17ff2cea3bc72;hpb=d1c9cc5e3f2f2bd20c6a3a9e047e6ee6051b9d2c;p=citadel.git
diff --git a/webcit/smtpqueue.c b/webcit/smtpqueue.c
index b059ff905..2004bad8c 100644
--- a/webcit/smtpqueue.c
+++ b/webcit/smtpqueue.c
@@ -3,163 +3,10 @@
*/
#include "webcit.h"
+CtxType CTX_MAILQITEM = CTX_NONE;
+CtxType CTX_MAILQ_RCPT = CTX_NONE;
HashList *QItemHandlers = NULL;
-/*
- * display one message in the queue
- */
-void display_queue_msg(long msgnum)
-{
- char buf[1024];
- char keyword[32];
- int in_body = 0;
- int is_delivery_list = 0;
- time_t submitted = 0;
- time_t attempted = 0;
- time_t last_attempt = 0;
- int number_of_attempts = 0;
- char sender[256];
- char recipients[65536];
- int recipients_len = 0;
- char thisrecp[256];
- char thisdsn[256];
- char thismsg[512];
- int thismsg_len;
- long msgid = 0;
- int len;
-
- strcpy(sender, "");
- strcpy(recipients, "");
- recipients_len = 0;
-
- serv_printf("MSG2 %ld", msgnum);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '1') return;
-
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-
- if (!IsEmptyStr(buf)) {
- len = strlen(buf);
- if (buf[len - 1] == 13) {
- buf[len - 1] = 0;
- }
- }
-
- if ( (IsEmptyStr(buf)) && (in_body == 0) ) {
- in_body = 1;
- }
-
- if ( (!in_body)
- && (!strncasecmp(buf, "Content-type: application/x-citadel-delivery-list", 49))
- ) {
- is_delivery_list = 1;
- }
-
- if ( (in_body) && (!is_delivery_list) ) {
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- /* Not a delivery list; flush and return quietly. */
- }
- return;
- }
-
- if ( (in_body) && (is_delivery_list) ) {
- extract_token(keyword, buf, 0, '|', sizeof keyword);
-
- if (!strcasecmp(keyword, "msgid")) {
- msgid = extract_long(buf, 1);
- }
-
- if (!strcasecmp(keyword, "submitted")) {
- submitted = extract_long(buf, 1);
- }
-
- if (!strcasecmp(keyword, "attempted")) {
- attempted = extract_long(buf, 1);
- ++number_of_attempts;
- if (attempted > last_attempt) {
- last_attempt = attempted;
- }
- }
-
- if (!strcasecmp(keyword, "bounceto")) {
- char *atsign;
- extract_token(sender, buf, 1, '|', sizeof sender);
-
- /* Strip off local hostname if it's our own */
- atsign = strchr(sender, '@');
- if (atsign != NULL) {
- ++atsign;
- if (!strcasecmp(atsign, ChrPtr(WC->serv_info->serv_nodename))) {
- --atsign;
- *atsign = 0;
- }
- }
- }
-
- if (!strcasecmp(keyword, "remote")) {
- thismsg[0] = 0;
-
- extract_token(thisrecp, buf, 1, '|', sizeof thisrecp);
- extract_token(thisdsn, buf, 3, '|', sizeof thisdsn);
-
- if (!IsEmptyStr(thisrecp)) {
- stresc(thismsg, sizeof thismsg, thisrecp, 1, 1);
- if (!IsEmptyStr(thisdsn)) {
- strcat(thismsg, "
");
- stresc(&thismsg[strlen(thismsg)], sizeof thismsg,
- thisdsn, 1, 1);
- strcat(thismsg, "");
- }
- thismsg_len = strlen(thismsg);
-
- if ((recipients_len + thismsg_len + 100) < sizeof recipients) {
- if (!IsEmptyStr(recipients)) {
- strcpy(&recipients[recipients_len], "
");
- recipients_len += 6;
- }
- strcpy(&recipients[recipients_len], thismsg);
- recipients_len += thismsg_len;
- }
- }
-
- }
-
- }
-
- }
-
- wc_printf("
");
- wc_printf("%ld ", msgnum);
- wc_printf(" %s",
- msgnum, msgid, _("(Delete)")
- );
-
- wc_printf(" | ");
- if (submitted > 0) {
- webcit_fmt_date(buf, 1024, submitted, 1);
- wc_printf("%s", buf);
- }
- else {
- wc_printf(" ");
- }
-
- wc_printf(" | ");
- if (last_attempt > 0) {
- webcit_fmt_date(buf, 1024, last_attempt, 1);
- wc_printf("%s", buf);
- }
- else {
- wc_printf(" ");
- }
-
- wc_printf(" | ");
- escputs(sender);
-
- wc_printf(" | ");
- wc_printf("%s", recipients);
- wc_printf(" |
\n");
-
-}
typedef struct _mailq_entry {
@@ -281,54 +128,54 @@ OneQueItem *DeserializeQueueItem(StrBuf *RawQItem, long QueMsgID)
void tmplput_MailQID(StrBuf *Target, WCTemplputParams *TP)
{
- OneQueItem *Item = (OneQueItem*) CTX;
+ OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
StrBufAppendPrintf(Target, "%ld", Item->QueMsgID);;
}
void tmplput_MailQPayloadID(StrBuf *Target, WCTemplputParams *TP)
{
- OneQueItem *Item = (OneQueItem*) CTX;
+ OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
StrBufAppendPrintf(Target, "%ld", Item->MessageID);
}
void tmplput_MailQBounceTo(StrBuf *Target, WCTemplputParams *TP)
{
- OneQueItem *Item = (OneQueItem*) CTX;
+ OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
StrBufAppendTemplate(Target, TP, Item->BounceTo, 0);
}
void tmplput_MailQAttempted(StrBuf *Target, WCTemplputParams *TP)
{
char datebuf[64];
- OneQueItem *Item = (OneQueItem*) CTX;
+ OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
webcit_fmt_date(datebuf, 64, Item->ReattemptWhen, DATEFMT_BRIEF);
StrBufAppendBufPlain(Target, datebuf, -1, 0);
}
void tmplput_MailQSubmitted(StrBuf *Target, WCTemplputParams *TP)
{
char datebuf[64];
- OneQueItem *Item = (OneQueItem*) CTX;
+ OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
webcit_fmt_date(datebuf, 64, Item->Submitted, DATEFMT_BRIEF);
StrBufAppendBufPlain(Target, datebuf, -1, 0);
}
void tmplput_MailQEnvelopeFrom(StrBuf *Target, WCTemplputParams *TP)
{
- OneQueItem *Item = (OneQueItem*) CTX;
+ OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
StrBufAppendTemplate(Target, TP, Item->EnvelopeFrom, 0);
}
void tmplput_MailQSourceRoom(StrBuf *Target, WCTemplputParams *TP)
{
- OneQueItem *Item = (OneQueItem*) CTX;
+ OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
StrBufAppendTemplate(Target, TP, Item->SenderRoom, 0);
}
int Conditional_MailQ_HaveSourceRoom(StrBuf *Target, WCTemplputParams *TP)
{
- OneQueItem *Item = (OneQueItem*) CTX;
+ OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
return StrLength(Item->SenderRoom) > 0;
}
void tmplput_MailQRetry(StrBuf *Target, WCTemplputParams *TP)
{
char datebuf[64];
- OneQueItem *Item = (OneQueItem*) CTX;
+ OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
if (Item->Retry == 0) {
StrBufAppendBufPlain(Target, _("First Attempt pending"), -1, 0);
@@ -341,23 +188,23 @@ void tmplput_MailQRetry(StrBuf *Target, WCTemplputParams *TP)
void tmplput_MailQRCPT(StrBuf *Target, WCTemplputParams *TP)
{
- MailQEntry *Entry = (MailQEntry*) CTX;
+ MailQEntry *Entry = (MailQEntry*) CTX(CTX_MAILQ_RCPT);
StrBufAppendTemplate(Target, TP, Entry->Recipient, 0);
}
void tmplput_MailQRCPTStatus(StrBuf *Target, WCTemplputParams *TP)
{
- MailQEntry *Entry = (MailQEntry*) CTX;
+ MailQEntry *Entry = (MailQEntry*) CTX(CTX_MAILQ_RCPT);
StrBufAppendPrintf(Target, "%ld", Entry->Status);
}
void tmplput_MailQStatusMsg(StrBuf *Target, WCTemplputParams *TP)
{
- MailQEntry *Entry = (MailQEntry*) CTX;
+ MailQEntry *Entry = (MailQEntry*) CTX(CTX_MAILQ_RCPT);
StrBufAppendTemplate(Target, TP, Entry->StatusMessage, 0);
}
HashList *iterate_get_Recipients(StrBuf *Target, WCTemplputParams *TP)
{
- OneQueItem *Item = (OneQueItem*) CTX;
+ OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
return Item->MailQEntries;
}
@@ -405,6 +252,7 @@ void QItem_Handle_SenderRoom(OneQueItem *Item, StrBuf *Line, const char **Pos)
void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
{
+ const char *pch;
if (Item->Current == NULL)
NewMailQEntry(Item);
if (Item->Current->Recipient == NULL)
@@ -412,6 +260,18 @@ void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
StrBufExtract_NextToken(Item->Current->Recipient, Line, Pos, '|');
Item->Current->Status = StrBufExtractNext_int(Line, Pos, '|');
StrBufExtract_NextToken(Item->Current->StatusMessage, Line, Pos, '|');
+
+ pch = ChrPtr(Item->Current->StatusMessage);
+ while ((pch != NULL) && (*pch != '\0')) {
+ pch = strchr(pch, ';');
+ if (pch != NULL) {
+ pch ++;
+ if (*pch == ' ') {
+ StrBufPeek(Item->Current->StatusMessage,
+ pch, -1, '\n');
+ }
+ }
+ }
Item->Current = NULL; // TODO: is this always right?
}
@@ -466,7 +326,10 @@ ServerStartModule_SMTP_QUEUE
int qview_PrintPageHeader(SharedMessageStatus *Stat, void **ViewSpecific)
{
- output_headers(1, 1, 1, 0, 0, 0);
+ if (yesbstr("ListOnly"))
+ output_headers(1, 0, 0, 0, 0, 0);
+ else
+ output_headers(1, 1, 1, 0, 0, 0);
return 0;
}
@@ -488,7 +351,10 @@ int qview_GetParamsGetServerCall(SharedMessageStatus *Stat,
else {
snprintf(cmd, len, "MSGS ALL|0|1");
snprintf(filter, flen, "SUBJ|QMSG");
- DoTemplate(HKEY("view_mailq_header"), NULL, NULL);
+ if (yesbstr("ListOnly"))
+ DoTemplate(HKEY("view_mailq_table"), NULL, NULL);
+ else
+ DoTemplate(HKEY("view_mailq_header"), NULL, NULL);
return 200;
}
}
@@ -519,16 +385,22 @@ int qview_RenderView_or_Tail(SharedMessageStatus *Stat,
wcsession *WCC = WC;
WCTemplputParams SubTP;
- if (GetCount(WCC->summ) == 0)
- DoTemplate(HKEY("view_mailq_footer_empty"),NULL, &SubTP);
+ if (yesbstr("ListOnly"))
+ DoTemplate(HKEY("view_mailq_footer_listonly"),NULL, &SubTP);
else
- DoTemplate(HKEY("view_mailq_footer"),NULL, &SubTP);
-
+ {
+ if (GetCount(WCC->summ) == 0)
+ DoTemplate(HKEY("view_mailq_footer_empty"),NULL, &SubTP);
+ else
+ DoTemplate(HKEY("view_mailq_footer"),NULL, &SubTP);
+ }
+
return 0;
}
int qview_Cleanup(void **ViewSpecific)
{
- wDumpContent(1);
+
+ wDumpContent(yesbstr("ListOnly")?0:1);
return 0;
}
@@ -536,6 +408,8 @@ void
InitModule_SMTP_QUEUE
(void)
{
+ RegisterCTX(CTX_MAILQITEM);
+ RegisterCTX(CTX_MAILQ_RCPT);
RegisterQItemHandler(HKEY("msgid"), QItem_Handle_MsgID);
RegisterQItemHandler(HKEY("envelope_from"), QItem_Handle_EnvelopeFrom);