5 * message index functions
9 void DestroyMimeParts(wc_mime_attachment *Mime)
11 FreeStrBuf(&Mime->Name);
12 FreeStrBuf(&Mime->FileName);
13 FreeStrBuf(&Mime->PartNum);
14 FreeStrBuf(&Mime->Disposition);
15 FreeStrBuf(&Mime->ContentType);
16 FreeStrBuf(&Mime->Charset);
17 FreeStrBuf(&Mime->Data);
20 void DestroyMime(void *vMime)
22 wc_mime_attachment *Mime = (wc_mime_attachment*)vMime;
23 DestroyMimeParts(Mime);
27 void DestroyMessageSummary(void *vMsg)
29 message_summary *Msg = (message_summary*) vMsg;
31 FreeStrBuf(&Msg->from);
33 FreeStrBuf(&Msg->subj);
34 FreeStrBuf(&Msg->reply_inreplyto);
35 FreeStrBuf(&Msg->reply_references);
36 FreeStrBuf(&Msg->cccc);
37 FreeStrBuf(&Msg->hnod);
38 FreeStrBuf(&Msg->AllRcpt);
39 FreeStrBuf(&Msg->Room);
40 FreeStrBuf(&Msg->Rfca);
41 FreeStrBuf(&Msg->OtherNode);
43 FreeStrBuf(&Msg->reply_to);
45 DeleteHash(&Msg->Attachments); /**< list of Accachments */
46 DeleteHash(&Msg->Submessages);
47 DeleteHash(&Msg->AttachLinks);
48 DeleteHash(&Msg->AllAttach);
54 void RegisterMsgHdr(const char *HeaderName, long HdrNLen, ExamineMsgHeaderFunc evaluator, int type)
57 ev = (headereval*) malloc(sizeof(headereval));
58 ev->evaluator = evaluator;
60 Put(MsgHeaderHandler, HeaderName, HdrNLen, ev, NULL);
63 void RegisterMimeRenderer(const char *HeaderName, long HdrNLen, RenderMimeFunc MimeRenderer)
65 RenderMimeFuncStruct *f;
67 f = (RenderMimeFuncStruct*) malloc(sizeof(RenderMimeFuncStruct));
69 Put(MimeRenderHandler, HeaderName, HdrNLen, f, NULL);
73 /*----------------------------------------------------------------------------*/
76 * comparator for two longs in descending order.
78 int longcmp_r(const void *s1, const void *s2) {
82 l1 = *(long *)GetSearchPayload(s1);
83 l2 = *(long *)GetSearchPayload(s2);
85 if (l1 > l2) return(-1);
86 if (l1 < l2) return(+1);
91 * comparator for longs; descending order.
93 int qlongcmp_r(const void *s1, const void *s2) {
97 if (l1 > l2) return(-1);
98 if (l1 < l2) return(+1);
104 * comparator for message summary structs by ascending subject.
106 int summcmp_subj(const void *s1, const void *s2) {
107 message_summary *summ1;
108 message_summary *summ2;
110 summ1 = (message_summary *)GetSearchPayload(s1);
111 summ2 = (message_summary *)GetSearchPayload(s2);
112 return strcasecmp(ChrPtr(summ1->subj), ChrPtr(summ2->subj));
116 * comparator for message summary structs by descending subject.
118 int summcmp_rsubj(const void *s1, const void *s2) {
119 message_summary *summ1;
120 message_summary *summ2;
122 summ1 = (message_summary *)GetSearchPayload(s1);
123 summ2 = (message_summary *)GetSearchPayload(s2);
124 return strcasecmp(ChrPtr(summ2->subj), ChrPtr(summ1->subj));
127 * comparator for message summary structs by descending subject.
129 int groupchange_subj(const void *s1, const void *s2) {
130 message_summary *summ1;
131 message_summary *summ2;
133 summ1 = (message_summary *)s1;
134 summ2 = (message_summary *)s2;
135 return ChrPtr(summ2->subj)[0] != ChrPtr(summ1->subj)[0];
139 * comparator for message summary structs by ascending sender.
141 int summcmp_sender(const void *s1, const void *s2) {
142 message_summary *summ1;
143 message_summary *summ2;
145 summ1 = (message_summary *)GetSearchPayload(s1);
146 summ2 = (message_summary *)GetSearchPayload(s2);
147 return strcasecmp(ChrPtr(summ1->from), ChrPtr(summ2->from));
151 * comparator for message summary structs by descending sender.
153 int summcmp_rsender(const void *s1, const void *s2) {
154 message_summary *summ1;
155 message_summary *summ2;
157 summ1 = (message_summary *)GetSearchPayload(s1);
158 summ2 = (message_summary *)GetSearchPayload(s2);
159 return strcasecmp(ChrPtr(summ2->from), ChrPtr(summ1->from));
162 * comparator for message summary structs by descending sender.
164 int groupchange_sender(const void *s1, const void *s2) {
165 message_summary *summ1;
166 message_summary *summ2;
168 summ1 = (message_summary *)s1;
169 summ2 = (message_summary *)s2;
170 return strcasecmp(ChrPtr(summ2->from), ChrPtr(summ1->from)) != 0;
175 * comparator for message summary structs by ascending date.
177 int summcmp_date(const void *s1, const void *s2) {
178 message_summary *summ1;
179 message_summary *summ2;
181 summ1 = (message_summary *)GetSearchPayload(s1);
182 summ2 = (message_summary *)GetSearchPayload(s2);
184 if (summ1->date < summ2->date) return -1;
185 else if (summ1->date > summ2->date) return +1;
190 * comparator for message summary structs by descending date.
192 int summcmp_rdate(const void *s1, const void *s2) {
193 message_summary *summ1;
194 message_summary *summ2;
196 summ1 = (message_summary *)GetSearchPayload(s1);
197 summ2 = (message_summary *)GetSearchPayload(s2);
199 if (summ1->date < summ2->date) return +1;
200 else if (summ1->date > summ2->date) return -1;
205 * comparator for message summary structs by descending date.
207 const long DAYSECONDS = 24 * 60 * 60;
208 int groupchange_date(const void *s1, const void *s2) {
209 message_summary *summ1;
210 message_summary *summ2;
212 summ1 = (message_summary *)s1;
213 summ2 = (message_summary *)s2;
215 return (summ1->date % DAYSECONDS) != (summ2->date %DAYSECONDS);
219 /*----------------------------------------------------------------------------*/
220 /* Don't wanna know... or? */
221 void examine_pref(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
222 void examine_suff(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
223 void examine_path(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
224 void examine_content_encoding(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
226 /* TODO: do we care? */
229 void examine_nhdr(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
232 if (!strncasecmp(ChrPtr(HdrLine), "yes", 8))
235 int Conditional_ANONYMOUS_MESSAGE(StrBuf *Target, WCTemplputParams *TP)
237 message_summary *Msg = (message_summary*) CTX;
238 return Msg->nhdr != 0;
241 void examine_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
243 Msg->format_type = StrToi(HdrLine);
247 void examine_from(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
249 FreeStrBuf(&Msg->from);
250 Msg->from = NewStrBufPlain(NULL, StrLength(HdrLine));
251 StrBuf_RFC822_to_Utf8(Msg->from, HdrLine, WC->DefaultCharset, FoundCharset);
253 void tmplput_MAIL_SUMM_FROM(StrBuf *Target, WCTemplputParams *TP)
255 message_summary *Msg = (message_summary*) CTX;
256 StrBufAppendTemplate(Target, TP, Msg->from, 0);
261 void examine_subj(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
263 FreeStrBuf(&Msg->subj);
264 Msg->subj = NewStrBufPlain(NULL, StrLength(HdrLine));
265 StrBuf_RFC822_to_Utf8(Msg->subj, HdrLine, WC->DefaultCharset, FoundCharset);
267 void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
268 {/*////TODO: Fwd: and RE: filter!!*/
270 message_summary *Msg = (message_summary*) CTX;
271 StrBufAppendTemplate(Target, TP, Msg->subj, 0);
273 int Conditional_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
275 message_summary *Msg = (message_summary*) CTX;
276 return StrLength(Msg->subj) > 0;
280 void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
282 FreeStrBuf(&Msg->reply_inreplyto);
283 Msg->reply_inreplyto = NewStrBufPlain(NULL, StrLength(HdrLine));
284 StrBuf_RFC822_to_Utf8(Msg->reply_inreplyto, HdrLine, WC->DefaultCharset, FoundCharset);
286 void tmplput_MAIL_SUMM_INREPLYTO(StrBuf *Target, WCTemplputParams *TP)
288 message_summary *Msg = (message_summary*) CTX;
289 StrBufAppendTemplate(Target, TP, Msg->reply_inreplyto, 0);
292 int Conditional_MAIL_SUMM_UNREAD(StrBuf *Target, WCTemplputParams *TP)
294 message_summary *Msg = (message_summary*) CTX;
295 return Msg->is_new != 0;
298 void examine_wefw(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
300 FreeStrBuf(&Msg->reply_references);
301 Msg->reply_references = NewStrBufPlain(NULL, StrLength(HdrLine));
302 StrBuf_RFC822_to_Utf8(Msg->reply_references, HdrLine, WC->DefaultCharset, FoundCharset);
304 void tmplput_MAIL_SUMM_REFIDS(StrBuf *Target, WCTemplputParams *TP)
306 message_summary *Msg = (message_summary*) CTX;
307 StrBufAppendTemplate(Target, TP, Msg->reply_references, 0);
311 void examine_cccc(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
313 FreeStrBuf(&Msg->cccc);
314 Msg->cccc = NewStrBufPlain(NULL, StrLength(HdrLine));
315 StrBuf_RFC822_to_Utf8(Msg->cccc, HdrLine, WC->DefaultCharset, FoundCharset);
316 if (Msg->AllRcpt == NULL)
317 Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
318 if (StrLength(Msg->AllRcpt) > 0) {
319 StrBufAppendBufPlain(Msg->AllRcpt, HKEY(", "), 0);
321 StrBufAppendBuf(Msg->AllRcpt, Msg->cccc, 0);
323 void tmplput_MAIL_SUMM_CCCC(StrBuf *Target, WCTemplputParams *TP)
325 message_summary *Msg = (message_summary*) CTX;
326 StrBufAppendTemplate(Target, TP, Msg->cccc, 0);
330 void examine_room(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
332 if ((StrLength(HdrLine) > 0) &&
333 (strcasecmp(ChrPtr(HdrLine), ChrPtr(WC->wc_roomname)))) {
334 FreeStrBuf(&Msg->Room);
335 Msg->Room = NewStrBufDup(HdrLine);
338 void tmplput_MAIL_SUMM_ORGROOM(StrBuf *Target, WCTemplputParams *TP)
340 message_summary *Msg = (message_summary*) CTX;
341 StrBufAppendTemplate(Target, TP, Msg->Room, 0);
345 void examine_rfca(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
347 FreeStrBuf(&Msg->Rfca);
348 Msg->Rfca = NewStrBufDup(HdrLine);
350 void tmplput_MAIL_SUMM_RFCA(StrBuf *Target, WCTemplputParams *TP)
352 message_summary *Msg = (message_summary*) CTX;
353 StrBufAppendTemplate(Target, TP, Msg->Rfca, 0);
355 int Conditional_MAIL_SUMM_RFCA(StrBuf *Target, WCTemplputParams *TP)
357 message_summary *Msg = (message_summary*) CTX;
358 return StrLength(Msg->Rfca) > 0;
360 int Conditional_MAIL_SUMM_CCCC(StrBuf *Target, WCTemplputParams *TP)
362 message_summary *Msg = (message_summary*) CTX;
363 return StrLength(Msg->cccc) > 0;
366 void examine_node(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
370 if ( (StrLength(HdrLine) > 0) &&
371 ((WC->room_flags & QR_NETWORK)
372 || ((strcasecmp(ChrPtr(HdrLine), ChrPtr(WCC->serv_info->serv_nodename))
373 && (strcasecmp(ChrPtr(HdrLine), ChrPtr(WCC->serv_info->serv_fqdn))))))) {
374 FreeStrBuf(&Msg->OtherNode);
375 Msg->OtherNode = NewStrBufDup(HdrLine);
378 void tmplput_MAIL_SUMM_OTHERNODE(StrBuf *Target, WCTemplputParams *TP)
380 message_summary *Msg = (message_summary*) CTX;
381 StrBufAppendTemplate(Target, TP, Msg->OtherNode, 0);
383 int Conditional_MAIL_SUMM_OTHERNODE(StrBuf *Target, WCTemplputParams *TP)
385 message_summary *Msg = (message_summary*) CTX;
386 return StrLength(Msg->OtherNode) > 0;
390 void examine_rcpt(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
392 FreeStrBuf(&Msg->to);
393 Msg->to = NewStrBufPlain(NULL, StrLength(HdrLine));
394 StrBuf_RFC822_to_Utf8(Msg->to, HdrLine, WC->DefaultCharset, FoundCharset);
395 if (Msg->AllRcpt == NULL)
396 Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
397 if (StrLength(Msg->AllRcpt) > 0) {
398 StrBufAppendBufPlain(Msg->AllRcpt, HKEY(", "), 0);
400 StrBufAppendBuf(Msg->AllRcpt, Msg->to, 0);
402 void tmplput_MAIL_SUMM_TO(StrBuf *Target, WCTemplputParams *TP)
404 message_summary *Msg = (message_summary*) CTX;
405 StrBufAppendTemplate(Target, TP, Msg->to, 0);
407 int Conditional_MAIL_SUMM_TO(StrBuf *Target, WCTemplputParams *TP)
409 message_summary *Msg = (message_summary*) CTX;
410 return StrLength(Msg->to) != 0;
412 int Conditional_MAIL_SUMM_SUBJ(StrBuf *Target, WCTemplputParams *TP)
414 message_summary *Msg = (message_summary*) CTX;
415 return StrLength(Msg->subj) != 0;
417 void tmplput_MAIL_SUMM_ALLRCPT(StrBuf *Target, WCTemplputParams *TP)
419 message_summary *Msg = (message_summary*) CTX;
420 StrBufAppendTemplate(Target, TP, Msg->AllRcpt, 0);
425 void tmplput_SUMM_COUNT(StrBuf *Target, WCTemplputParams *TP)
427 StrBufAppendPrintf(Target, "%d", GetCount( WC->summ));
430 HashList *iterate_get_mailsumm_All(StrBuf *Target, WCTemplputParams *TP)
434 void examine_time(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
436 Msg->date = StrTol(HdrLine);
439 void tmplput_MAIL_SUMM_DATE_BRIEF(StrBuf *Target, WCTemplputParams *TP)
442 message_summary *Msg = (message_summary*) CTX;
443 webcit_fmt_date(datebuf, 64, Msg->date, DATEFMT_BRIEF);
444 StrBufAppendBufPlain(Target, datebuf, -1, 0);
447 void tmplput_MAIL_SUMM_DATE_FULL(StrBuf *Target, WCTemplputParams *TP)
450 message_summary *Msg = (message_summary*) CTX;
451 webcit_fmt_date(datebuf, 64, Msg->date, DATEFMT_FULL);
452 StrBufAppendBufPlain(Target, datebuf, -1, 0);
454 void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, WCTemplputParams *TP)
456 message_summary *Msg = (message_summary*) CTX;
457 StrBufAppendPrintf(Target, "%ld", Msg->date, 0);
462 void render_MAIL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
464 const StrBuf *TemplateMime;
466 Mime->Data = NewStrBufPlain(NULL, Mime->length);
467 read_message(Mime->Data, HKEY("view_submessage"), Mime->msgnum, Mime->PartNum, &TemplateMime);
469 if ( (!IsEmptyStr(mime_submessages)) && (!section[0]) ) {
470 for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
471 extract_token(buf, mime_submessages, i, '|', sizeof buf);
472 / ** use printable_view to suppress buttons * /
473 wprintf("<blockquote>");
474 read_message(Mime->msgnum, 1, ChrPtr(Mime->Section));
475 wprintf("</blockquote>");
481 void render_MIME_VCard(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
485 if (StrLength(Mime->Data) > 0) {
488 /** If it's my vCard I can edit it */
489 if ( (!strcasecmp(ChrPtr(WCC->wc_roomname), USERCONFIGROOM))
490 || (!strcasecmp(&(ChrPtr(WCC->wc_roomname)[11]), USERCONFIGROOM))
491 || (WC->wc_view == VIEW_ADDRESSBOOK)
493 StrBufAppendPrintf(Buf, "<a href=\"edit_vcard?msgnum=%ld&partnum=%s\">",
494 Mime->msgnum, ChrPtr(Mime->PartNum));
495 StrBufAppendPrintf(Buf, "[%s]</a>", _("edit"));
498 /* In all cases, display the full card */
499 display_vcard(Buf, Mime->Data, 0, 1, NULL, Mime->msgnum);
500 FreeStrBuf(&Mime->Data);
506 void render_MIME_VNote(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
509 if (StrLength(Mime->Data) > 0) {
514 v = vnote_new_from_str(ChrPtr(Mime->Data));
518 memset(&TP, 0, sizeof(WCTemplputParams));
519 TP.Filter.ContextType = CTX_VNOTE;
521 DoTemplate(HKEY("mail_vnoteitem"),
526 FreeStrBuf(&Mime->Data);
530 FlushStrBuf(Mime->Data);
535 void render_MIME_ICS(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
537 if (StrLength(Mime->Data) == 0) {
540 if (StrLength(Mime->Data) > 0) {
541 cal_process_attachment(Mime);
547 void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
549 wc_mime_attachment *Mime;
552 Mime = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
553 memset(Mime, 0, sizeof(wc_mime_attachment));
554 Mime->msgnum = Msg->msgnum;
557 Mime->Name = NewStrBuf();
558 StrBufExtract_token(Buf, HdrLine, 0, '|');
559 StrBuf_RFC822_to_Utf8(Mime->Name, Buf, WC->DefaultCharset, FoundCharset);
560 StrBufTrim(Mime->Name);
562 StrBufExtract_token(Buf, HdrLine, 1, '|');
563 Mime->FileName = NewStrBuf();
564 StrBuf_RFC822_to_Utf8(Mime->FileName, Buf, WC->DefaultCharset, FoundCharset);
565 StrBufTrim(Mime->FileName);
567 Mime->PartNum = NewStrBuf();
568 StrBufExtract_token(Mime->PartNum, HdrLine, 2, '|');
569 StrBufTrim(Mime->PartNum);
570 if (strchr(ChrPtr(Mime->PartNum), '.') != NULL)
575 Mime->Disposition = NewStrBuf();
576 StrBufExtract_token(Mime->Disposition, HdrLine, 3, '|');
578 Mime->ContentType = NewStrBuf();
579 StrBufExtract_token(Mime->ContentType, HdrLine, 4, '|');
580 StrBufTrim(Mime->ContentType);
581 StrBufLowerCase(Mime->ContentType);
583 if (!strcmp(ChrPtr(Mime->ContentType), "application/octet-stream")) {
584 StrBufPlain(Mime->ContentType,
585 GuessMimeByFilename(SKEY(Mime->FileName)), -1);
587 Mime->length = StrBufExtract_int(HdrLine, 5, '|');
589 if ( (StrLength(Mime->FileName) == 0) && (StrLength(Mime->Name) > 0) ) {
590 StrBufAppendBuf(Mime->FileName, Mime->Name, 0);
593 if (StrLength(Msg->PartNum) > 0) {
595 StrBufPrintf(Buf, "%s.%s", ChrPtr(Msg->PartNum), ChrPtr(Mime->PartNum));
601 if (Msg->AllAttach == NULL)
602 Msg->AllAttach = NewHash(1,NULL);
603 Put(Msg->AllAttach, SKEY(Mime->PartNum), Mime, DestroyMime);
608 void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime)
612 /* just print the root-node */
613 if ((Mime->level == 1) &&
614 GetHash(MimeRenderHandler, SKEY(Mime->ContentType), &vMimeRenderer) &&
615 vMimeRenderer != NULL)
617 Mime->Renderer = (RenderMimeFuncStruct*) vMimeRenderer;
618 if (Msg->Submessages == NULL)
619 Msg->Submessages = NewHash(1,NULL);
620 Put(Msg->Submessages, SKEY(Mime->PartNum), Mime, reference_free_handler);
622 else if ((Mime->level == 1) &&
623 (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
624 && (!strncasecmp(ChrPtr(Mime->ContentType), "image/", 6)) ){
625 if (Msg->AttachLinks == NULL)
626 Msg->AttachLinks = NewHash(1,NULL);
627 Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
629 else if ((Mime->level == 1) &&
630 (StrLength(Mime->ContentType) > 0) &&
631 ( (!strcasecmp(ChrPtr(Mime->Disposition), "attachment"))
632 || (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
633 || (!strcasecmp(ChrPtr(Mime->Disposition), ""))))
635 if (Msg->AttachLinks == NULL)
636 Msg->AttachLinks = NewHash(1,NULL);
637 Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
638 if ((strcasecmp(ChrPtr(Mime->ContentType), "application/octet-stream") == 0) &&
639 (StrLength(Mime->FileName) > 0)) {
640 FlushStrBuf(Mime->ContentType);
641 StrBufAppendBufPlain(Mime->ContentType,
642 GuessMimeByFilename(SKEY(Mime->FileName)),
648 void tmplput_MAIL_SUMM_NATTACH(StrBuf *Target, WCTemplputParams *TP)
650 message_summary *Msg = (message_summary*) CTX;
651 StrBufAppendPrintf(Target, "%ld", GetCount(Msg->Attachments));
655 void examine_hnod(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
657 FreeStrBuf(&Msg->hnod);
658 Msg->hnod = NewStrBufPlain(NULL, StrLength(HdrLine));
659 StrBuf_RFC822_to_Utf8(Msg->hnod, HdrLine, WC->DefaultCharset, FoundCharset);
661 void tmplput_MAIL_SUMM_H_NODE(StrBuf *Target, WCTemplputParams *TP)
663 message_summary *Msg = (message_summary*) CTX;
664 StrBufAppendTemplate(Target, TP, Msg->hnod, 0);
666 int Conditional_MAIL_SUMM_H_NODE(StrBuf *Target, WCTemplputParams *TP)
668 message_summary *Msg = (message_summary*) CTX;
669 return StrLength(Msg->hnod) > 0;
674 void examine_text(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
676 Msg->MsgBody->Data = NewStrBufPlain(NULL, SIZ);
679 void examine_msg4_partnum(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
681 Msg->MsgBody->PartNum = NewStrBufDup(HdrLine);
682 StrBufTrim(Msg->MsgBody->PartNum);
685 void examine_content_lengh(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
687 Msg->MsgBody->length = StrTol(HdrLine);
688 Msg->MsgBody->size_known = 1;
691 void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
701 Msg->MsgBody->ContentType = NewStrBufDup(HdrLine);
702 sem = strchr(ChrPtr(HdrLine), ';');
705 Token = NewStrBufPlain(NULL, StrLength(HdrLine));
706 Value = NewStrBufPlain(NULL, StrLength(HdrLine));
707 len = sem - ChrPtr(HdrLine);
708 StrBufCutAt(Msg->MsgBody->ContentType, len, NULL);
709 while (sem != NULL) {
710 while (isspace(*(sem + 1)))
712 StrBufCutLeft(HdrLine, sem - ChrPtr(HdrLine));
713 sem = strchr(ChrPtr(HdrLine), ';');
715 len = sem - ChrPtr(HdrLine);
717 len = StrLength(HdrLine);
720 StrBufAppendBufPlain(Token, ChrPtr(HdrLine), len, 0);
721 eq = strchr(ChrPtr(Token), '=');
723 len = eq - ChrPtr(Token);
724 StrBufAppendBufPlain(Value, eq + 1, StrLength(Token) - len - 1, 0);
725 StrBufCutAt(Token, len, NULL);
730 if (GetHash(MsgHeaderHandler, SKEY(Token), &vHdr) &&
732 Hdr = (headereval*)vHdr;
733 Hdr->evaluator(Msg, Value, FoundCharset);
735 else lprintf(1, "don't know how to handle content type sub-header[%s]\n", ChrPtr(Token));
742 void tmplput_MAIL_SUMM_N(StrBuf *Target, WCTemplputParams *TP)
744 message_summary *Msg = (message_summary*) CTX;
745 StrBufAppendPrintf(Target, "%ld", Msg->msgnum);
750 int Conditional_MAIL_MIME_ALL(StrBuf *Target, WCTemplputParams *TP)
752 message_summary *Msg = (message_summary*) CTX;
753 return GetCount(Msg->Attachments) > 0;
756 int Conditional_MAIL_MIME_SUBMESSAGES(StrBuf *Target, WCTemplputParams *TP)
758 message_summary *Msg = (message_summary*) CTX;
759 return GetCount(Msg->Submessages) > 0;
762 int Conditional_MAIL_MIME_ATTACHLINKS(StrBuf *Target, WCTemplputParams *TP)
764 message_summary *Msg = (message_summary*) CTX;
765 return GetCount(Msg->AttachLinks) > 0;
768 int Conditional_MAIL_MIME_ATTACH(StrBuf *Target, WCTemplputParams *TP)
770 message_summary *Msg = (message_summary*) CTX;
771 return GetCount(Msg->AllAttach) > 0;
774 void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
780 MsgNum = LBstr(TKEY(0));
782 read_message(Buf, HKEY("view_message_replyquote"), MsgNum, NULL, &Mime);
783 StrBufAppendTemplate(Target, TP, Buf, 1);
787 void tmplput_EDIT_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
793 MsgNum = LBstr(TKEY(0));
795 read_message(Buf, HKEY("view_message_edit"), MsgNum, NULL, &Mime);
796 StrBufAppendTemplate(Target, TP, Buf, 1);
800 void tmplput_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
802 message_summary *Msg = (message_summary*) CTX;
803 StrBufAppendTemplate(Target, TP, Msg->MsgBody->Data, 0);
807 void render_MAIL_variformat(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
809 /* Messages in legacy Citadel variformat get handled thusly... */
810 StrBuf *Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
811 FmOut(Target, "JUSTIFY", Mime->Data);
812 FreeStrBuf(&Mime->Data);
816 void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
819 const char *ptr, *pte;
820 const char *BufPtr = NULL;
832 iconv_t ic = (iconv_t)(-1) ;
835 if ((StrLength(Mime->Data) == 0) && (Mime->length > 0)) {
836 FreeStrBuf(&Mime->Data);
842 if (StrLength(Mime->Charset) != 0)
844 else if (StrLength(FoundCharset) > 0)
846 else if (StrLength(WC->DefaultCharset) > 0)
847 cs = WC->DefaultCharset;
851 else if (!strcasecmp(ChrPtr(cs), "utf-8")) {
854 else if (!strcasecmp(ChrPtr(cs), "us-ascii")) {
858 ctdl_iconv_open("UTF-8", ChrPtr(cs), &ic);
859 if (ic == (iconv_t)(-1) ) {
860 lprintf(5, "%s:%d iconv_open(UTF-8, %s) failed: %s\n",
861 __FILE__, __LINE__, ChrPtr(Mime->Charset), strerror(errno));
866 Line = NewStrBufPlain(NULL, SIZ);
867 Line1 = NewStrBufPlain(NULL, SIZ);
868 Line2 = NewStrBufPlain(NULL, SIZ);
869 Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
871 while ((n = StrBufSipLine(Line, Mime->Data, &BufPtr), n >= 0) && !done)
877 len = StrLength(Line);
880 while ((ptr < pte) &&
889 if (i > 0) StrBufCutLeft(Line, i);
891 if (StrLength(Line) == 0) {
892 StrBufAppendBufPlain(Target, HKEY("<tt></tt><br />\n"), 0);
896 for (i = bn; i < bq; i++)
897 StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
898 for (i = bq; i < bn; i++)
899 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
902 StrBufConvert(Line, Line1, &ic);
905 StrBufAppendBufPlain(Target, HKEY("<tt>"), 0);
906 UrlizeText(Line1, Line, Line2);
908 StrEscAppend(Target, Line1, NULL, 0, 0);
909 StrBufAppendBufPlain(Target, HKEY("</tt><br />\n"), 0);
913 for (i = 0; i < bn; i++)
914 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
916 StrBufAppendBufPlain(Target, HKEY("</i><br />"), 0);
918 if (ic != (iconv_t)(-1) ) {
923 FreeStrBuf(&Mime->Data);
925 FlushStrBuf(Mime->ContentType);
926 StrBufAppendBufPlain(Mime->ContentType, HKEY("text/html"), 0);
927 FlushStrBuf(Mime->Charset);
928 StrBufAppendBufPlain(Mime->Charset, HKEY("UTF-8"), 0);
934 void render_MAIL_html(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
938 if (StrLength(Mime->Data) == 0)
941 Buf = NewStrBufPlain(NULL, StrLength(Mime->Data));
943 /* HTML is fun, but we've got to strip it first */
944 output_html(ChrPtr(Mime->Charset),
945 (WC->wc_view == VIEW_WIKI ? 1 : 0),
948 FreeStrBuf(&Mime->Data);
952 void render_MAIL_UNKNOWN(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
954 /* Unknown weirdness */
955 FlushStrBuf(Mime->Data);
956 StrBufAppendBufPlain(Mime->Data, _("I don't know how to display "), -1, 0);
957 StrBufAppendBuf(Mime->Data, Mime->ContentType, 0);
958 StrBufAppendBufPlain(Mime->Data, HKEY("<br />\n"), 0);
962 HashList *iterate_get_mime_All(StrBuf *Target, WCTemplputParams *TP)
964 message_summary *Msg = (message_summary*) CTX;
965 return Msg->Attachments;
967 HashList *iterate_get_mime_Submessages(StrBuf *Target, WCTemplputParams *TP)
969 message_summary *Msg = (message_summary*) CTX;
970 return Msg->Submessages;
972 HashList *iterate_get_mime_AttachLinks(StrBuf *Target, WCTemplputParams *TP)
974 message_summary *Msg = (message_summary*) CTX;
975 return Msg->AttachLinks;
977 HashList *iterate_get_mime_Attachments(StrBuf *Target, WCTemplputParams *TP)
979 message_summary *Msg = (message_summary*) CTX;
980 return Msg->AllAttach;
983 void tmplput_MIME_Name(StrBuf *Target, WCTemplputParams *TP)
985 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
986 StrBufAppendTemplate(Target, TP, mime->Name, 0);
989 void tmplput_MIME_FileName(StrBuf *Target, WCTemplputParams *TP)
991 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
992 StrBufAppendTemplate(Target, TP, mime->FileName, 0);
995 void tmplput_MIME_PartNum(StrBuf *Target, WCTemplputParams *TP)
997 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
998 StrBufAppendTemplate(Target, TP, mime->PartNum, 0);
1001 void tmplput_MIME_MsgNum(StrBuf *Target, WCTemplputParams *TP)
1003 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1004 StrBufAppendPrintf(Target, "%ld", mime->msgnum);
1007 void tmplput_MIME_Disposition(StrBuf *Target, WCTemplputParams *TP)
1009 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1010 StrBufAppendTemplate(Target, TP, mime->Disposition, 0);
1013 void tmplput_MIME_ContentType(StrBuf *Target, WCTemplputParams *TP)
1015 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1016 StrBufAppendTemplate(Target, TP, mime->ContentType, 0);
1019 void examine_charset(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
1021 Msg->MsgBody->Charset = NewStrBufDup(HdrLine);
1024 void tmplput_MIME_Charset(StrBuf *Target, WCTemplputParams *TP)
1026 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1027 StrBufAppendTemplate(Target, TP, mime->Charset, 0);
1030 void tmplput_MIME_Data(StrBuf *Target, WCTemplputParams *TP)
1032 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1033 if (mime->Renderer != NULL)
1034 mime->Renderer->f(mime, NULL, NULL);
1035 StrBufAppendTemplate(Target, TP, mime->Data, 0);
1036 /* TODO: check whether we need to load it now? */
1039 void tmplput_MIME_LoadData(StrBuf *Target, WCTemplputParams *TP)
1041 wcsession *WCC = WC;
1042 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1043 wc_mime_attachment *att;
1045 if ( (!strcasecmp(ChrPtr(mime->Disposition), "inline"))||
1046 (!strcasecmp(ChrPtr(mime->Disposition), "attachment")) )
1051 /* steal this mime part... */
1052 att = malloc(sizeof(wc_mime_attachment));
1053 memcpy(att, mime, sizeof(wc_mime_attachment));
1054 memset(mime, 0, sizeof(wc_mime_attachment));
1056 if (att->Data == NULL)
1059 if (WCC->attachments == NULL)
1060 WCC->attachments = NewHash(1, NULL);
1061 /* And add it to the list. */
1062 n = snprintf(N, sizeof N, "%d", GetCount(WCC->attachments) + 1);
1063 Put(WCC->attachments, N, n, att, DestroyMime);
1067 void tmplput_MIME_Length(StrBuf *Target, WCTemplputParams *TP)
1069 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1070 StrBufAppendPrintf(Target, "%ld", mime->length);
1073 /* startmsg is an index within the message list.
1074 * starting_from is the Citadel message number to be supplied to a "MSGS GT" operation
1076 long DrawMessageDropdown(StrBuf *Selector, long maxmsgs, long startmsg, int nMessages, long starting_from)
1079 wcsession *WCC = WC;
1089 WCTemplputParams SubTP;
1091 memset(&SubTP, 0, sizeof(WCTemplputParams));
1092 SubTP.Filter.ContextType = CTX_LONGVECTOR;
1093 SubTP.Context = &vector;
1094 TmpBuf = NewStrBufPlain(NULL, SIZ);
1095 At = GetNewHashPos(WCC->summ, nMessages);
1096 nItems = GetCount(WCC->summ);
1100 vector[1] = startmsg;
1102 vector[7] = starting_from;
1105 vector[3] = abs(nMessages);
1106 lo = GetHashPosCounter(At);
1107 if (nMessages > 0) {
1108 if (lo + nMessages >= nItems) {
1110 vector[3] = nItems - lo;
1115 hi = lo + nMessages - 1;
1118 if (lo + nMessages < -1) {
1122 if ((lo % abs(nMessages)) != 0) {
1123 int offset = (lo % abs(nMessages) *
1124 (nMessages / abs(nMessages)));
1126 vector[3] = abs(offset);
1131 hi = lo + nMessages;
1134 done = !GetNextHashPos(WCC->summ, At, &hklen, &key, &vMsg);
1137 * Bump these because although we're thinking in zero base, the user
1138 * is a drooling idiot and is thinking in one base.
1143 FlushStrBuf(TmpBuf);
1144 dbg_print_longvector(vector);
1145 DoTemplate(HKEY("select_messageindex"), TmpBuf, &SubTP);
1146 StrBufAppendBuf(Selector, TmpBuf, 0);
1149 FlushStrBuf(TmpBuf);
1150 if (maxmsgs == 9999999) {
1157 dbg_print_longvector(vector);
1158 DoTemplate(HKEY("select_messageindex_all"), TmpBuf, &SubTP);
1159 StrBufAppendBuf(Selector, TmpBuf, 0);
1160 FreeStrBuf(&TmpBuf);
1165 HashList *iterate_get_registered_Attachments(StrBuf *Target, WCTemplputParams *TP)
1167 return WC->attachments;
1170 void servcmd_do_search(char *buf, long bufsize)
1172 snprintf(buf, bufsize, "MSGS SEARCH|%s", bstr("query"));
1175 void servcmd_headers(char *buf, long bufsize)
1177 snprintf(buf, bufsize, "MSGS ALL");
1180 void servcmd_readfwd(char *buf, long bufsize)
1182 snprintf(buf, bufsize, "MSGS ALL");
1185 void servcmd_readgt(char *buf, long bufsize)
1187 snprintf(buf, bufsize, "MSGS GT|%s", bstr("gt"));
1190 void servcmd_readnew(char *buf, long bufsize)
1192 snprintf(buf, bufsize, "MSGS NEW");
1195 void servcmd_readold(char *buf, long bufsize)
1197 snprintf(buf, bufsize, "MSGS OLD");
1201 readloop_struct rlid[] = {
1202 { {HKEY("do_search")}, servcmd_do_search},
1203 { {HKEY("headers")}, servcmd_headers},
1204 { {HKEY("readfwd")}, servcmd_readfwd},
1205 { {HKEY("readnew")}, servcmd_readnew},
1206 { {HKEY("readold")}, servcmd_readold},
1207 { {HKEY("readgt")}, servcmd_readgt}
1210 /* Spit out the new summary view. This is basically a static page, so clients can cache the layout, all the dirty work is javascript :) */
1211 void new_summary_view(void) {
1212 DoTemplate(HKEY("msg_listview"),NULL,&NoCtx);
1213 DoTemplate(HKEY("trailing"),NULL,&NoCtx);
1217 int mailview_GetParamsGetServerCall(SharedMessageStatus *Stat,
1218 void **ViewSpecific,
1227 Stat->defaultsortorder = 2;
1229 Stat->load_seen = 1;
1230 /* Generally using maxmsgs|startmsg is not required
1231 in mailbox view, but we have a 'safemode' for clients
1232 (*cough* Exploder) that simply can't handle too many */
1233 if (havebstr("maxmsgs")) Stat->maxmsgs = ibstr("maxmsgs");
1234 else Stat->maxmsgs = 9999999;
1235 if (havebstr("startmsg")) Stat->startmsg = lbstr("startmsg");
1236 snprintf(cmd, len, "MSGS %s|%s||1",
1237 (oper == do_search) ? "SEARCH" : "ALL",
1238 (oper == do_search) ? bstr("query") : ""
1244 int mailview_RenderView_or_Tail(SharedMessageStatus *Stat,
1245 void **ViewSpecific,
1248 WCTemplputParams SubTP;
1250 DoTemplate(HKEY("mailsummary_json"),NULL, &SubTP);
1254 int mailview_Cleanup(void **ViewSpecific)
1256 /* Note: wDumpContent() will output one additional </div> tag. */
1257 /* We ought to move this out into template */
1267 typedef struct _bbsview_stuct {
1268 StrBuf *BBViewToolBar;
1269 StrBuf *MessageDropdown;
1270 long *displayed_msgs;
1274 int bbsview_GetParamsGetServerCall(SharedMessageStatus *Stat,
1275 void **ViewSpecific,
1282 VS = (bbsview_struct*) malloc(sizeof(bbsview_struct));
1283 memset(VS, 0, sizeof(bbsview_struct));
1284 *ViewSpecific = (void*)VS;
1285 Stat->defaultsortorder = 1;
1286 Stat->startmsg = -1;
1289 rlid[oper].cmd(cmd, len);
1291 if (havebstr("maxmsgs"))
1292 Stat->maxmsgs = ibstr("maxmsgs");
1293 if (Stat->maxmsgs == 0) Stat->maxmsgs = DEFAULT_MAXMSGS;
1295 if (havebstr("startmsg")) {
1296 Stat->startmsg = lbstr("startmsg");
1298 if (lbstr("SortOrder") == 2) {
1300 Stat->num_displayed = -DEFAULT_MAXMSGS;
1304 Stat->num_displayed = DEFAULT_MAXMSGS;
1310 int bbsview_PrintViewHeader(SharedMessageStatus *Stat, void **ViewSpecific)
1313 WCTemplputParams SubTP;
1315 VS = (bbsview_struct*)*ViewSpecific;
1317 VS->BBViewToolBar = NewStrBufPlain(NULL, SIZ);
1318 VS->MessageDropdown = NewStrBufPlain(NULL, SIZ);
1320 /*** startmsg->maxmsgs = **/DrawMessageDropdown(VS->MessageDropdown,
1323 Stat->num_displayed,
1324 Stat->lowest_found-1);
1325 if (Stat->num_displayed < 0) {
1326 Stat->startmsg += Stat->maxmsgs;
1327 if (Stat->num_displayed != Stat->maxmsgs)
1328 Stat->maxmsgs = abs(Stat->maxmsgs) + 1;
1330 Stat->maxmsgs = abs(Stat->maxmsgs);
1333 if (Stat->nummsgs > 0) {
1334 memset(&SubTP, 0, sizeof(WCTemplputParams));
1335 SubTP.Filter.ContextType = CTX_STRBUF;
1336 SubTP.Context = VS->MessageDropdown;
1337 DoTemplate(HKEY("msg_listselector_top"), VS->BBViewToolBar, &SubTP);
1338 StrBufAppendBuf(WC->WBuf, VS->BBViewToolBar, 0);
1339 FlushStrBuf(VS->BBViewToolBar);
1344 int bbsview_LoadMsgFromServer(SharedMessageStatus *Stat,
1345 void **ViewSpecific,
1346 message_summary* Msg,
1352 VS = (bbsview_struct*)*ViewSpecific;
1353 if (VS->displayed_msgs == NULL) {
1354 VS->displayed_msgs = malloc(sizeof(long) *
1355 ((Stat->maxmsgs < Stat->nummsgs) ?
1357 Stat->nummsgs + 1));
1359 if ((i >= Stat->startmsg) && (i < Stat->startmsg + Stat->maxmsgs)) {
1360 VS->displayed_msgs[Stat->num_displayed] = Msg->msgnum;
1361 Stat->num_displayed++;
1367 int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
1368 void **ViewSpecific,
1371 wcsession *WCC = WC;
1373 WCTemplputParams SubTP;
1376 VS = (bbsview_struct*)*ViewSpecific;
1377 if (Stat->nummsgs == 0) {
1378 wprintf("<div class=\"nomsgs\"><br><em>");
1381 wprintf(_("No new messages."));
1384 wprintf(_("No old messages."));
1387 wprintf(_("No messages here."));
1389 wprintf("</em><br></div>\n");
1393 if (VS->displayed_msgs != NULL) {
1394 /* if we do a split bbview in the future, begin messages div here */
1396 for (a=0; a < Stat->num_displayed; ++a) {
1397 read_message(WCC->WBuf, HKEY("view_message"), VS->displayed_msgs[a], NULL, &Mime);
1400 /* if we do a split bbview in the future, end messages div here */
1402 free(VS->displayed_msgs);
1403 VS->displayed_msgs = NULL;
1405 memset(&SubTP, 0, sizeof(WCTemplputParams));
1406 SubTP.Filter.ContextType = CTX_STRBUF;
1407 SubTP.Context = VS->MessageDropdown;
1408 DoTemplate(HKEY("msg_listselector_bottom"), VS->BBViewToolBar, &SubTP);
1409 StrBufAppendBuf(WCC->WBuf, VS->BBViewToolBar, 0);
1416 int bbsview_Cleanup(void **ViewSpecific)
1420 VS = (bbsview_struct*)*ViewSpecific;
1422 FreeStrBuf(&VS->BBViewToolBar);
1423 FreeStrBuf(&VS->MessageDropdown);
1429 InitModule_MSGRENDERERS
1432 RegisterReadLoopHandlerset(
1434 mailview_GetParamsGetServerCall,
1435 NULL, /// TODO: is this right?
1437 mailview_RenderView_or_Tail,
1440 RegisterReadLoopHandlerset(
1442 bbsview_GetParamsGetServerCall,
1443 bbsview_PrintViewHeader,
1444 bbsview_LoadMsgFromServer,
1445 bbsview_RenderView_or_Tail,
1448 RegisterSortFunc(HKEY("date"),
1454 RegisterSortFunc(HKEY("subject"),
1460 RegisterSortFunc(HKEY("sender"),
1467 RegisterNamespace("SUMM:COUNT", 0, 0, tmplput_SUMM_COUNT, CTX_NONE);
1468 /* iterate over all known mails in WC->summ */
1469 RegisterIterator("MAIL:SUMM:MSGS", 0, NULL, iterate_get_mailsumm_All,
1470 NULL,NULL, CTX_MAILSUM, CTX_NONE, IT_NOFLAG);
1472 RegisterNamespace("MAIL:SUMM:DATEBRIEF", 0, 0, tmplput_MAIL_SUMM_DATE_BRIEF, CTX_MAILSUM);
1473 RegisterNamespace("MAIL:SUMM:DATEFULL", 0, 0, tmplput_MAIL_SUMM_DATE_FULL, CTX_MAILSUM);
1474 RegisterNamespace("MAIL:SUMM:DATENO", 0, 0, tmplput_MAIL_SUMM_DATE_NO, CTX_MAILSUM);
1475 RegisterNamespace("MAIL:SUMM:N", 0, 0, tmplput_MAIL_SUMM_N, CTX_MAILSUM);
1476 RegisterNamespace("MAIL:SUMM:FROM", 0, 2, tmplput_MAIL_SUMM_FROM, CTX_MAILSUM);
1477 RegisterNamespace("MAIL:SUMM:TO", 0, 2, tmplput_MAIL_SUMM_TO, CTX_MAILSUM);
1478 RegisterNamespace("MAIL:SUMM:SUBJECT", 0, 4, tmplput_MAIL_SUMM_SUBJECT, CTX_MAILSUM);
1479 RegisterNamespace("MAIL:SUMM:NTATACH", 0, 0, tmplput_MAIL_SUMM_NATTACH, CTX_MAILSUM);
1480 RegisterNamespace("MAIL:SUMM:CCCC", 0, 2, tmplput_MAIL_SUMM_CCCC, CTX_MAILSUM);
1481 RegisterNamespace("MAIL:SUMM:H_NODE", 0, 2, tmplput_MAIL_SUMM_H_NODE, CTX_MAILSUM);
1482 RegisterNamespace("MAIL:SUMM:ALLRCPT", 0, 2, tmplput_MAIL_SUMM_ALLRCPT, CTX_MAILSUM);
1483 RegisterNamespace("MAIL:SUMM:ORGROOM", 0, 2, tmplput_MAIL_SUMM_ORGROOM, CTX_MAILSUM);
1484 RegisterNamespace("MAIL:SUMM:RFCA", 0, 2, tmplput_MAIL_SUMM_RFCA, CTX_MAILSUM);
1485 RegisterNamespace("MAIL:SUMM:OTHERNODE", 2, 0, tmplput_MAIL_SUMM_OTHERNODE, CTX_MAILSUM);
1486 RegisterNamespace("MAIL:SUMM:REFIDS", 0, 1, tmplput_MAIL_SUMM_REFIDS, CTX_MAILSUM);
1487 RegisterNamespace("MAIL:SUMM:INREPLYTO", 0, 2, tmplput_MAIL_SUMM_INREPLYTO, CTX_MAILSUM);
1488 RegisterNamespace("MAIL:BODY", 0, 2, tmplput_MAIL_BODY, CTX_MAILSUM);
1489 RegisterNamespace("MAIL:QUOTETEXT", 1, 2, tmplput_QUOTED_MAIL_BODY, CTX_NONE);
1490 RegisterNamespace("MAIL:EDITTEXT", 1, 2, tmplput_EDIT_MAIL_BODY, CTX_NONE);
1491 RegisterConditional(HKEY("COND:MAIL:SUMM:RFCA"), 0, Conditional_MAIL_SUMM_RFCA, CTX_MAILSUM);
1492 RegisterConditional(HKEY("COND:MAIL:SUMM:CCCC"), 0, Conditional_MAIL_SUMM_CCCC, CTX_MAILSUM);
1493 RegisterConditional(HKEY("COND:MAIL:SUMM:UNREAD"), 0, Conditional_MAIL_SUMM_UNREAD, CTX_MAILSUM);
1494 RegisterConditional(HKEY("COND:MAIL:SUMM:H_NODE"), 0, Conditional_MAIL_SUMM_H_NODE, CTX_MAILSUM);
1495 RegisterConditional(HKEY("COND:MAIL:SUMM:OTHERNODE"), 0, Conditional_MAIL_SUMM_OTHERNODE, CTX_MAILSUM);
1496 RegisterConditional(HKEY("COND:MAIL:SUMM:SUBJECT"), 0, Conditional_MAIL_SUMM_SUBJECT, CTX_MAILSUM);
1497 RegisterConditional(HKEY("COND:MAIL:ANON"), 0, Conditional_ANONYMOUS_MESSAGE, CTX_MAILSUM);
1498 RegisterConditional(HKEY("COND:MAIL:TO"), 0, Conditional_MAIL_SUMM_TO, CTX_MAILSUM);
1499 RegisterConditional(HKEY("COND:MAIL:SUBJ"), 0, Conditional_MAIL_SUMM_SUBJ, CTX_MAILSUM);
1501 /* do we have mimetypes to iterate over? */
1502 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH"), 0, Conditional_MAIL_MIME_ALL, CTX_MAILSUM);
1503 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:SUBMESSAGES"), 0, Conditional_MAIL_MIME_SUBMESSAGES, CTX_MAILSUM);
1504 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:LINKS"), 0, Conditional_MAIL_MIME_ATTACHLINKS, CTX_MAILSUM);
1505 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:ATT"), 0, Conditional_MAIL_MIME_ATTACH, CTX_MAILSUM);
1506 RegisterIterator("MAIL:MIME:ATTACH", 0, NULL, iterate_get_mime_All,
1507 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1508 RegisterIterator("MAIL:MIME:ATTACH:SUBMESSAGES", 0, NULL, iterate_get_mime_Submessages,
1509 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1510 RegisterIterator("MAIL:MIME:ATTACH:LINKS", 0, NULL, iterate_get_mime_AttachLinks,
1511 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1512 RegisterIterator("MAIL:MIME:ATTACH:ATT", 0, NULL, iterate_get_mime_Attachments,
1513 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1515 /* Parts of a mime attachent */
1516 RegisterNamespace("MAIL:MIME:NAME", 0, 2, tmplput_MIME_Name, CTX_MIME_ATACH);
1517 RegisterNamespace("MAIL:MIME:FILENAME", 0, 2, tmplput_MIME_FileName, CTX_MIME_ATACH);
1518 RegisterNamespace("MAIL:MIME:PARTNUM", 0, 2, tmplput_MIME_PartNum, CTX_MIME_ATACH);
1519 RegisterNamespace("MAIL:MIME:MSGNUM", 0, 2, tmplput_MIME_MsgNum, CTX_MIME_ATACH);
1520 RegisterNamespace("MAIL:MIME:DISPOSITION", 0, 2, tmplput_MIME_Disposition, CTX_MIME_ATACH);
1521 RegisterNamespace("MAIL:MIME:CONTENTTYPE", 0, 2, tmplput_MIME_ContentType, CTX_MIME_ATACH);
1522 RegisterNamespace("MAIL:MIME:CHARSET", 0, 2, tmplput_MIME_Charset, CTX_MIME_ATACH);
1523 RegisterNamespace("MAIL:MIME:LENGTH", 0, 2, tmplput_MIME_Length, CTX_MIME_ATACH);
1524 RegisterNamespace("MAIL:MIME:DATA", 0, 2, tmplput_MIME_Data, CTX_MIME_ATACH);
1525 /* load the actual attachment into WC->attachments; no output!!! */
1526 RegisterNamespace("MAIL:MIME:LOADDATA", 0, 0, tmplput_MIME_LoadData, CTX_MIME_ATACH);
1528 /* iterate the WC->attachments; use the above tokens for their contents */
1529 RegisterIterator("MSG:ATTACHNAMES", 0, NULL, iterate_get_registered_Attachments,
1530 NULL, NULL, CTX_MIME_ATACH, CTX_NONE, IT_NOFLAG);
1532 /* mime renderers translate an attachment into webcit viewable html text */
1533 RegisterMimeRenderer(HKEY("message/rfc822"), render_MAIL);
1534 RegisterMimeRenderer(HKEY("text/vnote"), render_MIME_VNote);
1535 RegisterMimeRenderer(HKEY("text/x-vcard"), render_MIME_VCard);
1536 RegisterMimeRenderer(HKEY("text/vcard"), render_MIME_VCard);
1537 RegisterMimeRenderer(HKEY("text/calendar"), render_MIME_ICS);
1538 RegisterMimeRenderer(HKEY("application/ics"), render_MIME_ICS);
1539 RegisterMimeRenderer(HKEY("text/x-citadel-variformat"), render_MAIL_variformat);
1540 RegisterMimeRenderer(HKEY("text/plain"), render_MAIL_text_plain);
1541 RegisterMimeRenderer(HKEY("text"), render_MAIL_text_plain);
1542 RegisterMimeRenderer(HKEY("text/html"), render_MAIL_html);
1543 RegisterMimeRenderer(HKEY(""), render_MAIL_UNKNOWN);
1545 /* these headers are citserver replies to MSG4 and friends. one evaluator for each */
1546 RegisterMsgHdr(HKEY("nhdr"), examine_nhdr, 0);
1547 RegisterMsgHdr(HKEY("type"), examine_type, 0);
1548 RegisterMsgHdr(HKEY("from"), examine_from, 0);
1549 RegisterMsgHdr(HKEY("subj"), examine_subj, 0);
1550 RegisterMsgHdr(HKEY("msgn"), examine_msgn, 0);
1551 RegisterMsgHdr(HKEY("wefw"), examine_wefw, 0);
1552 RegisterMsgHdr(HKEY("cccc"), examine_cccc, 0);
1553 RegisterMsgHdr(HKEY("hnod"), examine_hnod, 0);
1554 RegisterMsgHdr(HKEY("room"), examine_room, 0);
1555 RegisterMsgHdr(HKEY("rfca"), examine_rfca, 0);
1556 RegisterMsgHdr(HKEY("node"), examine_node, 0);
1557 RegisterMsgHdr(HKEY("rcpt"), examine_rcpt, 0);
1558 RegisterMsgHdr(HKEY("time"), examine_time, 0);
1559 RegisterMsgHdr(HKEY("part"), examine_mime_part, 0);
1560 RegisterMsgHdr(HKEY("text"), examine_text, 1);
1561 /* these are the content-type headers we get infront of a message; put it into the same hash since it doesn't clash. */
1562 RegisterMsgHdr(HKEY("X-Citadel-MSG4-Partnum"), examine_msg4_partnum, 0);
1563 RegisterMsgHdr(HKEY("Content-type"), examine_content_type, 0);
1564 RegisterMsgHdr(HKEY("Content-length"), examine_content_lengh, 0);
1565 RegisterMsgHdr(HKEY("Content-transfer-encoding"), examine_content_encoding, 0); /* do we care? */
1566 RegisterMsgHdr(HKEY("charset"), examine_charset, 0);
1568 /* Don't care about these... */
1569 RegisterMsgHdr(HKEY("pref"), examine_pref, 0);
1570 RegisterMsgHdr(HKEY("suff"), examine_suff, 0);
1571 RegisterMsgHdr(HKEY("path"), examine_path, 0);
1575 ServerStartModule_MSGRENDERERS
1578 MsgHeaderHandler = NewHash(1, NULL);
1579 MimeRenderHandler = NewHash(1, NULL);
1580 ReadLoopHandler = NewHash(1, NULL);
1584 ServerShutdownModule_MSGRENDERERS
1587 DeleteHash(&MsgHeaderHandler);
1588 DeleteHash(&MimeRenderHandler);
1589 DeleteHash(&ReadLoopHandler);
1595 SessionDestroyModule_MSGRENDERERS
1598 DeleteHash(&sess->attachments);