/*
- * $Id$
+ * Display the outbound SMTP queue
*/
-/**
- * \defgroup SMTPqueue Display the outbound SMTP queue
- * \ingroup CitadelConfig
- */
-/*@{*/
+
#include "webcit.h"
-/**
- * \brief display one message in the queue
+/*
+ * display one message in the queue
*/
void display_queue_msg(long msgnum)
{
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 ( (IsEmptyStr(buf) == 0) && (in_body == 0) ) {
+ if ( (IsEmptyStr(buf)) && (in_body == 0) ) {
in_body = 1;
}
}
if (!strcasecmp(keyword, "bounceto")) {
+ char *atsign;
extract_token(sender, buf, 1, '|', sizeof sender);
/* Strip off local hostname if it's our own */
- char *atsign;
atsign = strchr(sender, '@');
if (atsign != NULL) {
++atsign;
- if (!strcasecmp(atsign, serv_info.serv_nodename)) {
+ if (!strcasecmp(atsign, ChrPtr(WC->serv_info->serv_nodename))) {
--atsign;
*atsign = 0;
}
}
if (!strcasecmp(keyword, "remote")) {
- int RcptLen;
- int TRcptLen;
- int TDsn;
- int NLen;
+ thismsg[0] = 0;
+
extract_token(thisrecp, buf, 1, '|', sizeof thisrecp);
extract_token(thisdsn, buf, 3, '|', sizeof thisdsn);
- RcptLen = strlen(recipients);
- TRcptLen = strlen(thisrecp);
- TDsn = strlen(thisdsn);
- if ( RcptLen + TRcptLen + TDsn + 100
- < sizeof recipients) {
- if (!IsEmptyStr(recipients)) {
- // copy the \0 to be sure..
- memcpy (&recipients[RcptLen], "<br />\0", 7);
- RcptLen += 6;
+
+ if (!IsEmptyStr(thisrecp)) {
+ stresc(thismsg, sizeof thismsg, thisrecp, 1, 1);
+ if (!IsEmptyStr(thisdsn)) {
+ strcat(thismsg, "<br /> <i>");
+ stresc(&thismsg[strlen(thismsg)], sizeof thismsg,
+ thisdsn, 1, 1);
+ strcat(thismsg, "</i>");
+ }
+ thismsg_len = strlen(thismsg);
+
+ if ((recipients_len + thismsg_len + 100) < sizeof recipients) {
+ if (!IsEmptyStr(recipients)) {
+ strcpy(&recipients[recipients_len], "<br />");
+ recipients_len += 6;
+ }
+ strcpy(&recipients[recipients_len], thismsg);
+ recipients_len += thismsg_len;
}
- NLen = stresc(&recipients[RcptLen],
- sizeof recipients - RcptLen,
- thisrecp, 1, 1);
- if (NLen != -1)
- {
- RcptLen += NLen;
- NLen = sizeof "<br /> <i>";
- memcpy(recipients, "<br /> <i>",
- NLen);
- RcptLen += NLen - 1;
- NLen = stresc(&recipients[RcptLen],
- sizeof recipients - RcptLen,
- thisdsn, 1, 1);
- if (NLen != -1)
- memcpy (recipients, "</i>\0", 5);
- } /// else bail out?
}
}
}
- wprintf("<tr><td>");
- wprintf("%ld<br />", msgnum);
- wprintf(" <a href=\"javascript:DeleteQueueMsg(%ld,%ld);\">%s</a>",
+ wc_printf("<tr><td>");
+ wc_printf("%ld<br />", msgnum);
+ wc_printf(" <a href=\"javascript:DeleteSMTPqueueMsg(%ld,%ld);\">%s</a>",
msgnum, msgid, _("(Delete)")
);
- wprintf("</td><td>");
+ wc_printf("</td><td>");
if (submitted > 0) {
- fmt_date(buf, submitted, 1);
- wprintf("%s", buf);
+ webcit_fmt_date(buf, 1024, submitted, 1);
+ wc_printf("%s", buf);
}
else {
- wprintf(" ");
+ wc_printf(" ");
}
- wprintf("</td><td>");
+ wc_printf("</td><td>");
if (last_attempt > 0) {
- fmt_date(buf, last_attempt, 1);
- wprintf("%s", buf);
+ webcit_fmt_date(buf, 1024, last_attempt, 1);
+ wc_printf("%s", buf);
}
else {
- wprintf(" ");
+ wc_printf(" ");
}
- wprintf("</td><td>");
+ wc_printf("</td><td>");
escputs(sender);
- wprintf("</td><td>");
- wprintf("%s", recipients);
- wprintf("</td></tr>\n");
+ wc_printf("</td><td>");
+ wc_printf("%s", recipients);
+ wc_printf("</td></tr>\n");
}
void display_smtpqueue_inner_div(void) {
+ message_summary *Msg = NULL;
+ wcsession *WCC = WC;
int i;
int num_msgs;
+ StrBuf *Buf;
+ SharedMessageStatus Stat;
+ memset(&Stat, 0, sizeof(SharedMessageStatus));
/* Check to see if we can go to the __CitadelSMTPspoolout__ room.
* If not, we don't have access to the queue.
*/
- gotoroom("__CitadelSMTPspoolout__");
- if (!strcasecmp(WC->wc_roomname, "__CitadelSMTPspoolout__")) {
-
- num_msgs = load_msg_ptrs("MSGS ALL", 0);
+ Buf = NewStrBufPlain(HKEY("__CitadelSMTPspoolout__"));
+ gotoroom(Buf);
+ FreeStrBuf(&Buf);
+ if (!strcasecmp(ChrPtr(WCC->CurRoom.name), "__CitadelSMTPspoolout__")) {
+
+ Stat.maxload = 10000;
+ Stat.lowest_found = (-1);
+ Stat.highest_found = (-1);
+ num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL);
if (num_msgs > 0) {
- wprintf("<table class=\"mailbox_summary\" rules=rows "
- "cellpadding=2 style=\"width:100%%;-moz-user-select:none;\">"
+ wc_printf("<table class=\"mailbox_summary\" rules=rows "
+ "cellpadding=2 style=\"width:100%%;\">"
);
- wprintf("<tr><td><b><i>");
- wprintf(_("Message ID"));
- wprintf("</i></b></td><td><b><i>");
- wprintf(_("Date/time submitted"));
- wprintf("</i></b></td><td><b><i>");
- wprintf(_("Last attempt"));
- wprintf("</i></b></td><td><b><i>");
- wprintf(_("Sender"));
- wprintf("</i></b></td><td><b><i>");
- wprintf(_("Recipients"));
- wprintf("</i></b></td></tr>\n");
-
- for (i=0; i<num_msgs; ++i) {
- display_queue_msg(WC->msgarr[i]);
+ wc_printf("<tr><td><b><i>");
+ wc_printf(_("Message ID"));
+ wc_printf("</i></b></td><td><b><i>");
+ wc_printf(_("Date/time submitted"));
+ wc_printf("</i></b></td><td><b><i>");
+ wc_printf(_("Last attempt"));
+ wc_printf("</i></b></td><td><b><i>");
+ wc_printf(_("Sender"));
+ wc_printf("</i></b></td><td><b><i>");
+ wc_printf(_("Recipients"));
+ wc_printf("</i></b></td></tr>\n");
+
+ for (i=0; (i < num_msgs) && (i < Stat.maxload); ++i) {
+ Msg = GetMessagePtrAt(i, WCC->summ);
+ if (Msg != NULL) {
+ display_queue_msg(Msg->msgnum);
+ }
}
- wprintf("</table>");
+ wc_printf("</table>");
}
else {
- wprintf("<br /><br /><div align=\"center\">");
- wprintf(_("The queue is empty."));
- wprintf("</div><br /><br />");
+ wc_printf("<br /><br /><div align=\"center\">");
+ wc_printf(_("The queue is empty."));
+ wc_printf("</div><br /><br />");
}
}
else {
- wprintf("<br /><br /><div align=\"center\">");
- wprintf(_("You do not have permission to view this resource."));
- wprintf("</div><br /><br />");
+ wc_printf("<br /><br /><div align=\"center\">");
+ wc_printf(_("You do not have permission to view this resource."));
+ wc_printf("</div><br /><br />");
}
-
+ output_headers(0, 0, 0, 0, 0, 0);
+ end_burst();
}
-/**
- * \brief display the outbound SMTP queue
+/*
+ * display the outbound SMTP queue
*/
void display_smtpqueue(void)
{
output_headers(1, 1, 2, 0, 0, 0);
- wprintf("<script type=\"text/javascript\"> \n"
- "function RefreshQueueDisplay() { \n"
- " new Ajax.Updater('smtpqueue_inner_div', \n"
- " 'display_smtpqueue_inner_div', { method: 'get', \n"
- " parameters: Math.random() } ); \n"
- "} \n"
- " \n"
- "function DeleteQueueMsg(msgnum1, msgnum2) { \n"
- " new Ajax.Request( \n"
- " 'ajax_servcmd', { \n"
- " method: 'post', \n"
- " parameters: 'g_cmd=DELE ' + msgnum1 + ',' + msgnum2, \n"
- " onComplete: RefreshQueueDisplay() \n"
- " } \n"
- " ); \n"
- "} \n"
- " \n"
- "</script> \n"
- );
-
- wprintf("<div id=\"banner\">\n");
- wprintf("<h1>");
- wprintf(_("View the outbound SMTP queue"));
- wprintf("</h1>\n");
- wprintf("</div>\n");
+ wc_printf("<div id=\"banner\">\n");
+ wc_printf("<h1>");
+ wc_printf(_("View the outbound SMTP queue"));
+ wc_printf("</h1>\n");
+ wc_printf("</div>\n");
- wprintf("<div id=\"content\" class=\"service\">\n");
+ wc_printf("<div id=\"content\" class=\"service\">\n");
- wprintf("<div class=\"fix_scrollbar_bug\">"
+ wc_printf("<div class=\"fix_scrollbar_bug\">"
"<table class=\"smtpqueue_background\">"
"<tr><td valign=top>\n");
- wprintf("<div id=\"smtpqueue_inner_div\">");
-
- display_smtpqueue_inner_div();
-
- wprintf("</div>"
+ wc_printf("<div id=\"smtpqueue_inner_div\">"
+ "<div align=\"center\"><img src=\"static/throbber.gif\"></div>"
+ "</div>"
"<div align=\"center\">"
- "<a href=\"javascript:RefreshQueueDisplay();\">%s</a>"
+ "<a href=\"javascript:RefreshSMTPqueueDisplay();\">%s</a>"
"</div>"
"</td></tr></table></div>\n", _("Refresh this page")
);
- wDumpContent(1);
-
-}
+ StrBufAppendPrintf(WC->trailing_javascript, "RefreshSMTPqueueDisplay();\n");
+ wDumpContent(1);
+}
-/*@}*/
+void
+InitModule_SMTP_QUEUE
+(void)
+{
+ WebcitAddUrlHandler(HKEY("display_smtpqueue"), "", 0, display_smtpqueue, 0);
+ WebcitAddUrlHandler(HKEY("display_smtpqueue_inner_div"), "", 0, display_smtpqueue_inner_div, 0);
+}