From 79d7fb817e842cf507c77a2252da56019a2b0a13 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 27 Oct 2006 18:19:47 +0000 Subject: [PATCH] Added a new screen to view the outbound SMTP queue. --- webcit/smtpqueue.c | 129 +++++++++++++++++++++++++++++++++++++------- webcit/vcard_edit.c | 4 -- 2 files changed, 111 insertions(+), 22 deletions(-) diff --git a/webcit/smtpqueue.c b/webcit/smtpqueue.c index bebc601f8..f41e38fa8 100644 --- a/webcit/smtpqueue.c +++ b/webcit/smtpqueue.c @@ -14,6 +14,20 @@ 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]; + char thisrecp[256]; + char thisdsn[256]; + + strcpy(sender, ""); + strcpy(recipients, ""); serv_printf("MSG2 %ld", msgnum); serv_getln(buf, sizeof buf); @@ -21,19 +35,96 @@ void display_queue_msg(long msgnum) while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { - wprintf(""); - wprintf(_("Message ID")); - wprintf(""); - wprintf(_("Date/time submitted")); - wprintf(""); - wprintf(_("Last attempt")); - wprintf(""); - wprintf(_("Sender")); - wprintf(""); - wprintf(_("Recipients")); - wprintf("\n"); + if (strlen(buf) > 0) { + if (buf[strlen(buf)-1] == 13) { + buf[strlen(buf)-1] = 0; + } + } + + if ( (strlen(buf) == 0) && (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, "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")) { + extract_token(sender, buf, 1, '|', sizeof sender); + } + + if (!strcasecmp(keyword, "remote")) { + 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, "
"); + } + stresc(&recipients[strlen(recipients)], thisrecp, 1, 1); + strcat(recipients, "
  "); + stresc(&recipients[strlen(recipients)], thisdsn, 1, 1); + strcat(recipients, ""); + } + + } + + } + + } + + wprintf(""); + wprintf("%ld", msgnum); + + wprintf(""); + if (submitted > 0) { + fmt_date(buf, submitted, 1); + wprintf("%s", buf); + } + else { + wprintf(" "); + } + + wprintf(""); + if (last_attempt > 0) { + fmt_date(buf, last_attempt, 1); + wprintf("%s", buf); } + else { + wprintf(" "); + } + + wprintf(""); + escputs(sender); + + wprintf(""); + wprintf("%s", recipients); + wprintf("\n"); } @@ -68,19 +159,21 @@ void display_smtpqueue(void) num_msgs = load_msg_ptrs("MSGS ALL", 0); if (num_msgs > 0) { + wprintf("" + ); - wprintf("
\n"); - wprintf("\n"); + wprintf("\n"); for (i=0; imsgarr[i]); diff --git a/webcit/vcard_edit.c b/webcit/vcard_edit.c index 678174519..187646193 100644 --- a/webcit/vcard_edit.c +++ b/webcit/vcard_edit.c @@ -90,10 +90,8 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to) { } sprintf(buf, "OPNA %ld|%s", msgnum, partnum); - lprintf(9, "%s\n", buf); serv_puts(buf); serv_getln(buf, sizeof buf); - lprintf(9, "%s\n", buf); if (buf[0] != '2') { convenience_page("770000", "Error", &buf[4]); return; @@ -104,8 +102,6 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to) { read_server_binary(serialized_vcard, total_len); - lprintf(9, "Serialized vcard:\n---\n%s\n---\n", serialized_vcard); - serv_puts("CLOS"); serv_getln(buf, sizeof buf); serialized_vcard[total_len] = 0; -- 2.39.2
"); + wprintf("
"); wprintf(_("Message ID")); - wprintf(""); + wprintf(""); wprintf(_("Date/time submitted")); - wprintf(""); + wprintf(""); wprintf(_("Last attempt")); - wprintf(""); + wprintf(""); wprintf(_("Sender")); - wprintf(""); + wprintf(""); wprintf(_("Recipients")); - wprintf("