SMTP-Queue-View: templatize
[citadel.git] / webcit / smtpqueue.c
1 /* 
2  * Display the outbound SMTP queue
3  */
4
5 #include "webcit.h"
6 HashList *QItemHandlers = NULL;
7
8 /*
9  * display one message in the queue
10  */
11 void display_queue_msg(long msgnum)
12 {
13         char buf[1024];
14         char keyword[32];
15         int in_body = 0;
16         int is_delivery_list = 0;
17         time_t submitted = 0;
18         time_t attempted = 0;
19         time_t last_attempt = 0;
20         int number_of_attempts = 0;
21         char sender[256];
22         char recipients[65536];
23         int recipients_len = 0;
24         char thisrecp[256];
25         char thisdsn[256];
26         char thismsg[512];
27         int thismsg_len;
28         long msgid = 0;
29         int len;
30
31         strcpy(sender, "");
32         strcpy(recipients, "");
33         recipients_len = 0;
34
35         serv_printf("MSG2 %ld", msgnum);
36         serv_getln(buf, sizeof buf);
37         if (buf[0] != '1') return;
38
39         while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
40
41                 if (!IsEmptyStr(buf)) {
42                         len = strlen(buf);
43                         if (buf[len - 1] == 13) {
44                                 buf[len - 1] = 0;
45                         }
46                 }
47
48                 if ( (IsEmptyStr(buf)) && (in_body == 0) ) {
49                         in_body = 1;
50                 }
51
52                 if ( (!in_body)
53                    && (!strncasecmp(buf, "Content-type: application/x-citadel-delivery-list", 49))
54                 ) {
55                         is_delivery_list = 1;
56                 }
57
58                 if ( (in_body) && (!is_delivery_list) ) {
59                         while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
60                                 /* Not a delivery list; flush and return quietly. */
61                         }
62                         return;
63                 }
64
65                 if ( (in_body) && (is_delivery_list) ) {
66                         extract_token(keyword, buf, 0, '|', sizeof keyword);
67
68                         if (!strcasecmp(keyword, "msgid")) {
69                                 msgid = extract_long(buf, 1);
70                         }
71
72                         if (!strcasecmp(keyword, "submitted")) {
73                                 submitted = extract_long(buf, 1);
74                         }
75
76                         if (!strcasecmp(keyword, "attempted")) {
77                                 attempted = extract_long(buf, 1);
78                                 ++number_of_attempts;
79                                 if (attempted > last_attempt) {
80                                         last_attempt = attempted;
81                                 }
82                         }
83
84                         if (!strcasecmp(keyword, "bounceto")) {
85                                 char *atsign;
86                                 extract_token(sender, buf, 1, '|', sizeof sender);
87
88                                 /* Strip off local hostname if it's our own */
89                                 atsign = strchr(sender, '@');
90                                 if (atsign != NULL) {
91                                         ++atsign;
92                                         if (!strcasecmp(atsign, ChrPtr(WC->serv_info->serv_nodename))) {
93                                                 --atsign;
94                                                 *atsign = 0;
95                                         }
96                                 }
97                         }
98
99                         if (!strcasecmp(keyword, "remote")) {
100                                 thismsg[0] = 0;
101
102                                 extract_token(thisrecp, buf, 1, '|', sizeof thisrecp);
103                                 extract_token(thisdsn, buf, 3, '|', sizeof thisdsn);
104
105                                 if (!IsEmptyStr(thisrecp)) {
106                                         stresc(thismsg, sizeof thismsg, thisrecp, 1, 1);
107                                         if (!IsEmptyStr(thisdsn)) {
108                                                 strcat(thismsg, "<br>&nbsp;&nbsp;<i>");
109                                                 stresc(&thismsg[strlen(thismsg)], sizeof thismsg,
110                                                         thisdsn, 1, 1);
111                                                 strcat(thismsg, "</i>");
112                                         }
113                                         thismsg_len = strlen(thismsg);
114
115                                         if ((recipients_len + thismsg_len + 100) < sizeof recipients) {
116                                                 if (!IsEmptyStr(recipients)) {
117                                                         strcpy(&recipients[recipients_len], "<br>");
118                                                         recipients_len += 6;
119                                                 }
120                                                 strcpy(&recipients[recipients_len], thismsg);
121                                                 recipients_len += thismsg_len;
122                                         }
123                                 }
124
125                         }
126
127                 }
128
129         }
130
131         wc_printf("<tr><td>");
132         wc_printf("%ld<br>", msgnum);
133         wc_printf(" <a href=\"javascript:DeleteSMTPqueueMsg(%ld,%ld);\">%s</a>", 
134                 msgnum, msgid, _("(Delete)")
135         );
136
137         wc_printf("</td><td>");
138         if (submitted > 0) {
139                 webcit_fmt_date(buf, 1024, submitted, 1);
140                 wc_printf("%s", buf);
141         }
142         else {
143                 wc_printf("&nbsp;");
144         }
145
146         wc_printf("</td><td>");
147         if (last_attempt > 0) {
148                 webcit_fmt_date(buf, 1024, last_attempt, 1);
149                 wc_printf("%s", buf);
150         }
151         else {
152                 wc_printf("&nbsp;");
153         }
154
155         wc_printf("</td><td>");
156         escputs(sender);
157
158         wc_printf("</td><td>");
159         wc_printf("%s", recipients);
160         wc_printf("</td></tr>\n");
161
162 }
163
164
165 void display_smtpqueue_inner_div(void) {
166         message_summary *Msg = NULL;
167         wcsession *WCC = WC;
168         int i;
169         int num_msgs;
170         StrBuf *Buf;
171         SharedMessageStatus Stat;
172
173         memset(&Stat, 0, sizeof(SharedMessageStatus));
174         /* Check to see if we can go to the __CitadelSMTPspoolout__ room.
175          * If not, we don't have access to the queue.
176          */
177         Buf = NewStrBufPlain(HKEY("__CitadelSMTPspoolout__"));
178         gotoroom(Buf);
179         FreeStrBuf(&Buf);
180         if (!strcasecmp(ChrPtr(WCC->CurRoom.name), "__CitadelSMTPspoolout__")) {
181
182                 Stat.maxload = 10000;
183                 Stat.lowest_found = (-1);
184                 Stat.highest_found = (-1);
185 //              num_msgs = load_msg_ptrs("MSGS ALL|0|1", "SUBJ|;QMSG", &Stat, NULL);
186                 num_msgs = load_msg_ptrs("MSGS ", NULL, &Stat, NULL);
187                 if (num_msgs > 0) {
188                         wc_printf("<table class=\"mailbox_summary\" rules=rows "
189                                 "cellpadding=2 style=\"width:100%%;\">"
190                         );
191
192                         wc_printf("<tr><td><b><i>");
193                         wc_printf(_("Message ID"));
194                         wc_printf("</i></b></td><td><b><i>");
195                         wc_printf(_("Date/time submitted"));
196                         wc_printf("</i></b></td><td><b><i>");
197                         wc_printf(_("Last attempt"));
198                         wc_printf("</i></b></td><td><b><i>");
199                         wc_printf(_("Sender"));
200                         wc_printf("</i></b></td><td><b><i>");
201                         wc_printf(_("Recipients"));
202                         wc_printf("</i></b></td></tr>\n");
203
204                         for (i=0; (i < num_msgs) && (i < Stat.maxload); ++i) {
205                                 Msg = GetMessagePtrAt(i, WCC->summ);
206                                 if (Msg != NULL) {
207                                         display_queue_msg(Msg->msgnum);
208                                 }
209                         }
210
211                         wc_printf("</table>");
212
213                 }
214                 else {
215                         wc_printf("<br><br><div align=\"center\">");
216                         wc_printf(_("The queue is empty."));
217                         wc_printf("</div><br><br>");
218                 }
219         }
220         else {
221                 wc_printf("<br><br><div align=\"center\">");
222                 wc_printf(_("You do not have permission to view this resource."));
223                 wc_printf("</div><br><br>");
224         }
225         output_headers(0, 0, 0, 0, 0, 0);
226         end_burst();
227 }
228
229 /*
230  * display the outbound SMTP queue
231  */
232 void display_smtpqueue(void)
233 {
234         output_headers(1, 1, 2, 0, 0, 0);
235
236         wc_printf("<div id=\"banner\">\n");
237         wc_printf("<h1>");
238         wc_printf(_("View the outbound SMTP queue"));
239         wc_printf("</h1>\n");
240         wc_printf("</div>\n");
241
242         wc_printf("<div id=\"content\" class=\"service\">\n");
243
244         wc_printf("<table class=\"smtpqueue_background\">"
245                 "<tr><td valign=top>\n");
246
247         wc_printf("<div id=\"smtpqueue_inner_div\">"
248                 "<div align=\"center\"><img src=\"static/webcit_icons/throbber.gif\"></div>"
249                 "</div>"
250                 "<div align=\"center\">"
251                 "<a href=\"javascript:RefreshSMTPqueueDisplay();\">%s</a>"
252                 "</div>"
253                 "</td></tr></table>\n", _("Refresh this page")
254         );
255
256         StrBufAppendPrintf(WC->trailing_javascript, "RefreshSMTPqueueDisplay();\n");
257
258         wDumpContent(1);
259
260 }
261
262
263
264
265
266
267
268
269
270
271 typedef struct _mailq_entry {
272         StrBuf *Recipient;
273         StrBuf *StatusMessage;
274         int Status;
275         /**<
276          * 0 = No delivery has yet been attempted
277          * 2 = Delivery was successful
278          * 4 = A transient error was experienced ... try again later
279          * 5 = Delivery to this address failed permanently.  The error message
280          *     should be placed in the fourth field so that a bounce message may
281          *     be generated.
282          */
283
284         int n;
285         int Active;
286 }MailQEntry;
287
288 typedef struct queueitem {
289         long MessageID;
290         long QueMsgID;
291         long Submitted;
292         int FailNow;
293         HashList *MailQEntries;
294 /* copy of the currently parsed item in the MailQEntries list;
295  * if null add a new one.
296  */
297         MailQEntry *Current;
298         time_t ReattemptWhen;
299         time_t Retry;
300
301         long ActiveDeliveries;
302         StrBuf *EnvelopeFrom;
303         StrBuf *BounceTo;
304         ParsedURL *URL;
305         ParsedURL *FallBackHost;
306 } OneQueItem;
307
308
309 typedef void (*QItemHandler)(OneQueItem *Item, StrBuf *Line, const char **Pos);
310
311
312 void FreeMailQEntry(void *qv)
313 {
314         MailQEntry *Q = qv;
315         FreeStrBuf(&Q->Recipient);
316         FreeStrBuf(&Q->StatusMessage);
317         free(Q);
318 }
319 void FreeQueItem(OneQueItem **Item)
320 {
321         DeleteHash(&(*Item)->MailQEntries);
322         FreeStrBuf(&(*Item)->EnvelopeFrom);
323         FreeStrBuf(&(*Item)->BounceTo);
324         FreeURL(&(*Item)->URL);
325         free(*Item);
326         Item = NULL;
327 }
328 void HFreeQueItem(void *Item)
329 {
330         FreeQueItem((OneQueItem**)&Item);
331 }
332
333
334 OneQueItem *DeserializeQueueItem(StrBuf *RawQItem, long QueMsgID)
335 {
336         OneQueItem *Item;
337         const char *pLine = NULL;
338         StrBuf *Line;
339         StrBuf *Token;
340         
341         Item = (OneQueItem*)malloc(sizeof(OneQueItem));
342         memset(Item, 0, sizeof(OneQueItem));
343         Item->Retry = 0;
344         Item->MessageID = -1;
345         Item->QueMsgID = QueMsgID;
346
347         Token = NewStrBuf();
348         Line = NewStrBufPlain(NULL, 128);
349         while (pLine != StrBufNOTNULL) {
350                 const char *pItemPart = NULL;
351                 void *vHandler;
352
353                 StrBufExtract_NextToken(Line, RawQItem, &pLine, '\n');
354                 if (StrLength(Line) == 0) continue;
355                 StrBufExtract_NextToken(Token, Line, &pItemPart, '|');
356                 if (GetHash(QItemHandlers, SKEY(Token), &vHandler))
357                 {
358                         QItemHandler H;
359                         H = (QItemHandler) vHandler;
360                         H(Item, Line, &pItemPart);
361                 }
362         }
363         FreeStrBuf(&Line);
364         FreeStrBuf(&Token);
365 /*
366         Put(ActiveQItems,
367             LKEY(Item->MessageID),
368             Item,
369             HFreeQueItem);
370 */      
371
372         return Item;
373 }
374
375 void tmplput_MailQID(StrBuf *Target, WCTemplputParams *TP)
376 {
377         OneQueItem *Item = (OneQueItem*) CTX;
378         StrBufAppendPrintf(Target, "%ld", Item->QueMsgID);;
379 }
380 void tmplput_MailQPayloadID(StrBuf *Target, WCTemplputParams *TP)
381 {
382         OneQueItem *Item = (OneQueItem*) CTX;
383         StrBufAppendPrintf(Target, "%ld", Item->MessageID);
384 }
385 void tmplput_MailQBounceTo(StrBuf *Target, WCTemplputParams *TP)
386 {
387         OneQueItem *Item = (OneQueItem*) CTX;
388         StrBufAppendTemplate(Target, TP, Item->BounceTo, 0);
389 }
390 void tmplput_MailQAttempted(StrBuf *Target, WCTemplputParams *TP)
391 {
392         char datebuf[64];
393         OneQueItem *Item = (OneQueItem*) CTX;
394         webcit_fmt_date(datebuf, 64, Item->ReattemptWhen, DATEFMT_BRIEF);
395         StrBufAppendBufPlain(Target, datebuf, -1, 0);
396 }
397 void tmplput_MailQSubmitted(StrBuf *Target, WCTemplputParams *TP)
398 {
399         char datebuf[64];
400         OneQueItem *Item = (OneQueItem*) CTX;
401         webcit_fmt_date(datebuf, 64, Item->Submitted, DATEFMT_BRIEF);
402         StrBufAppendBufPlain(Target, datebuf, -1, 0);
403 }
404 void tmplput_MailQEnvelopeFrom(StrBuf *Target, WCTemplputParams *TP)
405 {
406         OneQueItem *Item = (OneQueItem*) CTX;
407         StrBufAppendTemplate(Target, TP, Item->EnvelopeFrom, 0);
408 }
409 void tmplput_MailQRetry(StrBuf *Target, WCTemplputParams *TP)
410 {
411         char datebuf[64];
412         OneQueItem *Item = (OneQueItem*) CTX;
413
414         if (Item->Retry == 0) {
415                 StrBufAppendBufPlain(Target, _("First Attempt pending"), -1, 0);
416         }
417         else {
418                 webcit_fmt_date(datebuf, sizeof(datebuf), Item->Retry, DATEFMT_BRIEF);
419                 StrBufAppendBufPlain(Target, datebuf, -1, 0);
420         }
421 }
422
423 void tmplput_MailQRCPT(StrBuf *Target, WCTemplputParams *TP)
424 {
425         MailQEntry *Entry = (MailQEntry*) CTX;
426         StrBufAppendTemplate(Target, TP, Entry->Recipient, 0);
427 }
428 void tmplput_MailQRCPTStatus(StrBuf *Target, WCTemplputParams *TP)
429 {
430         MailQEntry *Entry = (MailQEntry*) CTX;
431         StrBufAppendPrintf(Target, "%ld", Entry->Status);
432 }
433 void tmplput_MailQStatusMsg(StrBuf *Target, WCTemplputParams *TP)
434 {
435         MailQEntry *Entry = (MailQEntry*) CTX;
436         StrBufAppendTemplate(Target, TP, Entry->StatusMessage, 0);
437 }
438
439 HashList *iterate_get_Recipients(StrBuf *Target, WCTemplputParams *TP)
440 {
441         OneQueItem *Item = (OneQueItem*) CTX;
442         return Item->MailQEntries;
443 }
444
445
446 void NewMailQEntry(OneQueItem *Item)
447 {
448         Item->Current = (MailQEntry*) malloc(sizeof(MailQEntry));
449         memset(Item->Current, 0, sizeof(MailQEntry));
450
451         if (Item->MailQEntries == NULL)
452                 Item->MailQEntries = NewHash(1, Flathash);
453         Item->Current->StatusMessage = NewStrBuf();
454         Item->Current->n = GetCount(Item->MailQEntries);
455         Put(Item->MailQEntries,
456             IKEY(Item->Current->n),
457             Item->Current,
458             FreeMailQEntry);
459 }
460
461 void QItem_Handle_MsgID(OneQueItem *Item, StrBuf *Line, const char **Pos)
462 {
463         Item->MessageID = StrBufExtractNext_long(Line, Pos, '|');
464 }
465
466 void QItem_Handle_EnvelopeFrom(OneQueItem *Item, StrBuf *Line, const char **Pos)
467 {
468         if (Item->EnvelopeFrom == NULL)
469                 Item->EnvelopeFrom = NewStrBufPlain(NULL, StrLength(Line));
470         StrBufExtract_NextToken(Item->EnvelopeFrom, Line, Pos, '|');
471 }
472
473 void QItem_Handle_BounceTo(OneQueItem *Item, StrBuf *Line, const char **Pos)
474 {
475         if (Item->BounceTo == NULL)
476                 Item->BounceTo = NewStrBufPlain(NULL, StrLength(Line));
477         StrBufExtract_NextToken(Item->BounceTo, Line, Pos, '|');
478 }
479
480 void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
481 {
482         if (Item->Current == NULL)
483                 NewMailQEntry(Item);
484         if (Item->Current->Recipient == NULL)
485                 Item->Current->Recipient=NewStrBufPlain(NULL, StrLength(Line));
486         StrBufExtract_NextToken(Item->Current->Recipient, Line, Pos, '|');
487         Item->Current->Status = StrBufExtractNext_int(Line, Pos, '|');
488         StrBufExtract_NextToken(Item->Current->StatusMessage, Line, Pos, '|');
489         Item->Current = NULL; // TODO: is this always right?
490 }
491
492
493 void QItem_Handle_retry(OneQueItem *Item, StrBuf *Line, const char **Pos)
494 {
495         Item->Retry =
496                 StrBufExtractNext_int(Line, Pos, '|');
497         Item->Retry *= 2;
498 }
499
500
501 void QItem_Handle_Submitted(OneQueItem *Item, StrBuf *Line, const char **Pos)
502 {
503         Item->Submitted = atol(*Pos);
504
505 }
506
507 void QItem_Handle_Attempted(OneQueItem *Item, StrBuf *Line, const char **Pos)
508 {
509         Item->ReattemptWhen = StrBufExtractNext_int(Line, Pos, '|');
510 }
511
512
513
514
515
516
517
518
519 void render_QUEUE(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
520 {
521         WCTemplputParams SubTP;
522
523         memset(&SubTP, 0, sizeof(WCTemplputParams));
524         SubTP.Filter.ContextType = CTX_MAILQITEM;
525         SubTP.Context = DeserializeQueueItem(Mime->Data, Mime->msgnum);
526         DoTemplate(HKEY("view_mailq_message"),NULL, &SubTP);
527         FreeQueItem ((OneQueItem**)&SubTP.Context);
528 }
529
530 void
531 ServerShutdownModule_SMTP_QUEUE
532 (void)
533 {
534         DeleteHash(&QItemHandlers);
535 }
536 void
537 ServerStartModule_SMTP_QUEUE
538 (void)
539 {
540         QItemHandlers = NewHash(0, NULL);
541 }
542
543 int qview_PrintPageHeader(SharedMessageStatus *Stat, void **ViewSpecific)
544 {
545         if (!WC->is_aide)
546         {
547                 output_headers(1, 1, 1, 0, 0, 0);
548         }
549         else
550         {
551                 output_headers(1, 1, 2, 0, 0, 0);
552         }
553         return 0;
554 }
555
556 int qview_GetParamsGetServerCall(SharedMessageStatus *Stat,
557                                  void **ViewSpecific,
558                                  long oper,
559                                  char *cmd,
560                                  long len,
561                                  char *filter,
562                                  long flen)
563 {
564         if (!WC->is_aide)
565         {
566                 DoTemplate(HKEY("aide_required"), NULL, NULL);
567                 end_burst();
568
569                 return 300;
570         }
571         else {
572                 snprintf(cmd, len, "MSGS ALL|0|1");
573                 snprintf(filter, flen, "SUBJ|QMSG");
574                 DoTemplate(HKEY("view_mailq_header"), NULL, NULL);
575                 return 200;
576         }
577 }
578
579 /*
580  * Display task view
581  */
582 int qview_LoadMsgFromServer(SharedMessageStatus *Stat, 
583                             void **ViewSpecific, 
584                             message_summary* Msg, 
585                             int is_new, 
586                             int i)
587 {
588         wcsession *WCC = WC;
589         const StrBuf *Mime;
590
591         /* Not (yet?) needed here? calview *c = (calview *) *ViewSpecific; */
592         read_message(WCC->WBuf, HKEY("view_mailq_message_bearer"), Msg->msgnum, NULL, &Mime);
593
594         return 0;
595 }
596
597
598 int qview_RenderView_or_Tail(SharedMessageStatus *Stat, 
599                              void **ViewSpecific, 
600                              long oper)
601 {
602         wcsession *WCC = WC;
603         WCTemplputParams SubTP;
604
605         if (GetCount(WCC->summ) == 0)
606                 DoTemplate(HKEY("view_mailq_footer_empty"),NULL, &SubTP);
607         else
608                 DoTemplate(HKEY("view_mailq_footer"),NULL, &SubTP);
609         
610         return 0;
611 }
612 int qview_Cleanup(void **ViewSpecific)
613 {
614         wDumpContent(1);
615         return 0;
616 }
617
618 void 
619 InitModule_SMTP_QUEUE
620 (void)
621 {
622
623         Put(QItemHandlers, HKEY("msgid"), QItem_Handle_MsgID, reference_free_handler);
624         Put(QItemHandlers, HKEY("envelope_from"), QItem_Handle_EnvelopeFrom, reference_free_handler);
625         Put(QItemHandlers, HKEY("retry"), QItem_Handle_retry, reference_free_handler);
626         Put(QItemHandlers, HKEY("attempted"), QItem_Handle_Attempted, reference_free_handler);
627         Put(QItemHandlers, HKEY("remote"), QItem_Handle_Recipient, reference_free_handler);
628         Put(QItemHandlers, HKEY("bounceto"), QItem_Handle_BounceTo, reference_free_handler);
629         Put(QItemHandlers, HKEY("submitted"), QItem_Handle_Submitted, reference_free_handler);
630
631         WebcitAddUrlHandler(HKEY("display_smtpqueue"), "", 0, display_smtpqueue, 0);
632         WebcitAddUrlHandler(HKEY("display_smtpqueue_inner_div"), "", 0, display_smtpqueue_inner_div, 0);
633         RegisterMimeRenderer(HKEY("application/x-citadel-delivery-list"), render_QUEUE, 1, 9000);
634
635
636         RegisterNamespace("MAILQ:ID", 0, 0, tmplput_MailQID, NULL, CTX_MAILQITEM);
637         RegisterNamespace("MAILQ:PAYLOAD:ID", 0, 0, tmplput_MailQPayloadID, NULL, CTX_MAILQITEM);
638         RegisterNamespace("MAILQ:BOUNCETO", 0, 1, tmplput_MailQBounceTo, NULL, CTX_MAILQITEM);
639         RegisterNamespace("MAILQ:ATTEMPTED", 0, 0, tmplput_MailQAttempted, NULL, CTX_MAILQITEM);
640         RegisterNamespace("MAILQ:SUBMITTED", 0, 0, tmplput_MailQSubmitted, NULL, CTX_MAILQITEM);
641         RegisterNamespace("MAILQ:ENVELOPEFROM", 0, 1, tmplput_MailQEnvelopeFrom, NULL, CTX_MAILQITEM);
642         RegisterNamespace("MAILQ:RETRY", 0, 0, tmplput_MailQRetry, NULL, CTX_MAILQITEM);
643
644         RegisterNamespace("MAILQ:RCPT:ADDR", 0, 1, tmplput_MailQRCPT, NULL, CTX_MAILQ_RCPT);
645         RegisterNamespace("MAILQ:RCPT:STATUS", 0, 0, tmplput_MailQRCPTStatus, NULL, CTX_MAILQ_RCPT);
646         RegisterNamespace("MAILQ:RCPT:STATUSMSG", 0, 1, tmplput_MailQStatusMsg, NULL, CTX_MAILQ_RCPT);
647
648         RegisterIterator("MAILQ:RCPT", 0, NULL, iterate_get_Recipients, 
649                          NULL, NULL, CTX_MAILQ_RCPT, CTX_MAILQITEM, IT_NOFLAG);
650
651
652         RegisterReadLoopHandlerset(
653                 VIEW_QUEUE,
654                 qview_GetParamsGetServerCall,
655                 qview_PrintPageHeader,
656                 NULL, /* TODO: is this right? */
657                 NULL,
658                 qview_LoadMsgFromServer,
659                 qview_RenderView_or_Tail,
660                 qview_Cleanup);
661
662 }