]> code.citadel.org Git - citadel.git/blobdiff - webcit/smtpqueue.c
* split tasks view into its own file
[citadel.git] / webcit / smtpqueue.c
index d51ec4d78c67940ab1fc4a5f44b59eea97d1f237..503dc63932ce3865457ff3ee391b52f06a4b5fdf 100644 (file)
@@ -1,15 +1,13 @@
 /* 
- * $Id: $
+ * $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)
 {
@@ -23,12 +21,17 @@ 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);
@@ -36,13 +39,14 @@ void display_queue_msg(long msgnum)
 
        while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
 
-               if (strlen(buf) > 0) {
-                       if (buf[strlen(buf)-1] == 13) {
-                               buf[strlen(buf)-1] = 0;
+               if (!IsEmptyStr(buf)) {
+                       len = strlen(buf);
+                       if (buf[len - 1] == 13) {
+                               buf[len - 1] = 0;
                        }
                }
 
-               if ( (strlen(buf) == 0) && (in_body == 0) ) {
+               if ( (IsEmptyStr(buf)) && (in_body == 0) ) {
                        in_body = 1;
                }
 
@@ -79,14 +83,14 @@ void display_queue_msg(long msgnum)
                        }
 
                        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;
                                        }
@@ -94,18 +98,29 @@ void display_queue_msg(long msgnum)
                        }
 
                        if (!strcasecmp(keyword, "remote")) {
+                               thismsg[0] = 0;
+
                                extract_token(thisrecp, buf, 1, '|', sizeof thisrecp);
                                extract_token(thisdsn, buf, 3, '|', sizeof thisdsn);
 
-                               if (strlen(recipients) + strlen(thisrecp) + strlen(thisdsn) + 100
-                                  < sizeof recipients) {
-                                       if (strlen(recipients) > 0) {
-                                               strcat(recipients, "<br />");
+                               if (!IsEmptyStr(thisrecp)) {
+                                       stresc(thismsg, sizeof thismsg, thisrecp, 1, 1);
+                                       if (!IsEmptyStr(thisdsn)) {
+                                               strcat(thismsg, "<br />&nbsp;&nbsp;<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;
                                        }
-                                       stresc(&recipients[strlen(recipients)], thisrecp, 1, 1);
-                                       strcat(recipients, "<br />&nbsp;&nbsp;<i>");
-                                       stresc(&recipients[strlen(recipients)], thisdsn, 1, 1);
-                                       strcat(recipients, "</i>");
                                }
 
                        }
@@ -122,7 +137,7 @@ void display_queue_msg(long msgnum)
 
        wprintf("</td><td>");
        if (submitted > 0) {
-               fmt_date(buf, submitted, 1);
+               webcit_fmt_date(buf, 1024, submitted, 1);
                wprintf("%s", buf);
        }
        else {
@@ -131,7 +146,7 @@ void display_queue_msg(long msgnum)
 
        wprintf("</td><td>");
        if (last_attempt > 0) {
-               fmt_date(buf, last_attempt, 1);
+               webcit_fmt_date(buf, 1024, last_attempt, 1);
                wprintf("%s", buf);
        }
        else {
@@ -149,19 +164,26 @@ void display_queue_msg(long msgnum)
 
 
 void display_smtpqueue_inner_div(void) {
+       message_summary *Msg;
+       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__")) {
+       Buf = NewStrBufPlain(HKEY("__CitadelSMTPspoolout__"));
+       gotoroom(Buf);
+       FreeStrBuf(&Buf);
+       if (!strcasecmp(ChrPtr(WCC->wc_roomname), "__CitadelSMTPspoolout__")) {
 
-               num_msgs = load_msg_ptrs("MSGS ALL", 0);
+               num_msgs = load_msg_ptrs("MSGS ALL", &Msg);
                if (num_msgs > 0) {
                         wprintf("<table class=\"mailbox_summary\" rules=rows "
-                               "cellpadding=2 style=\"width:100%%;-moz-user-select:none;\">"
+                               "cellpadding=2 style=\"width:100%%;\">"
                        );
 
                        wprintf("<tr><td><b><i>");
@@ -177,7 +199,9 @@ void display_smtpqueue_inner_div(void) {
                        wprintf("</i></b></td></tr>\n");
 
                        for (i=0; i<num_msgs; ++i) {
-                               display_queue_msg(WC->msgarr[i]);
+                               Msg = GetMessagePtrAt(i, WCC->summ);
+
+                               display_queue_msg((Msg==NULL)? 0 : Msg->msgnum);
                        }
 
                        wprintf("</table>");
@@ -194,11 +218,12 @@ void display_smtpqueue_inner_div(void) {
                wprintf(_("You do not have permission to view this resource."));
                wprintf("</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)
 {
@@ -225,12 +250,12 @@ void display_smtpqueue(void)
        );
 
        wprintf("<div id=\"banner\">\n");
-       wprintf("<TABLE class=\"smtpqueue_banner\"><TR><TD>");
-       wprintf("<SPAN CLASS=\"titlebar\">");
+       wprintf("<h1>");
        wprintf(_("View the outbound SMTP queue"));
-       wprintf("</SPAN>\n");
-       wprintf("</TD></TR></TABLE>\n");
-       wprintf("</div>\n<div id=\"content\">\n");
+       wprintf("</h1>\n");
+       wprintf("</div>\n");
+
+       wprintf("<div id=\"content\" class=\"service\">\n");
 
        wprintf("<div class=\"fix_scrollbar_bug\">"
                "<table class=\"smtpqueue_background\">"
@@ -250,7 +275,10 @@ void display_smtpqueue(void)
 
 }
 
-
-
-
-/*@}*/
+void 
+InitModule_SMTP_QUEUE
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_smtpqueue"), display_smtpqueue, 0);
+       WebcitAddUrlHandler(HKEY("display_smtpqueue_inner_div"), display_smtpqueue_inner_div, 0);
+}