]> code.citadel.org Git - citadel.git/blobdiff - webcit/smtpqueue.c
SMTP-Queue display: wrap lines after ; so we get one line per error message.
[citadel.git] / webcit / smtpqueue.c
index 0ce44e3281f6f169a1aa14dd760799525093475d..8bf02a7f60f8cb752d5aee22a2528e1fe3b74885 100644 (file)
@@ -126,54 +126,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);
@@ -186,23 +186,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;
 }
 
@@ -250,6 +250,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)
@@ -257,6 +258,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?
 }
 
@@ -311,7 +324,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;
 }
 
@@ -333,7 +349,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;
        }
 }
@@ -364,16 +383,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;
 }