7 inline void CheckConvertBufs(struct wcsession *WCC)
9 if (WCC->ConvertBuf1 == NULL)
10 WCC->ConvertBuf1 = NewStrBuf();
11 if (WCC->ConvertBuf2 == NULL)
12 WCC->ConvertBuf2 = NewStrBuf();
16 * message index functions
20 void DestroyMimeParts(wc_mime_attachment *Mime)
22 FreeStrBuf(&Mime->Name);
23 FreeStrBuf(&Mime->FileName);
24 FreeStrBuf(&Mime->PartNum);
25 FreeStrBuf(&Mime->Disposition);
26 FreeStrBuf(&Mime->ContentType);
27 FreeStrBuf(&Mime->Charset);
28 FreeStrBuf(&Mime->Data);
31 void DestroyMime(void *vMime)
33 wc_mime_attachment *Mime = (wc_mime_attachment*)vMime;
34 DestroyMimeParts(Mime);
38 void DestroyMessageSummary(void *vMsg)
40 message_summary *Msg = (message_summary*) vMsg;
42 FreeStrBuf(&Msg->from);
44 FreeStrBuf(&Msg->subj);
45 FreeStrBuf(&Msg->reply_inreplyto);
46 FreeStrBuf(&Msg->reply_references);
47 FreeStrBuf(&Msg->cccc);
48 FreeStrBuf(&Msg->hnod);
49 FreeStrBuf(&Msg->AllRcpt);
50 FreeStrBuf(&Msg->Room);
51 FreeStrBuf(&Msg->Rfca);
52 FreeStrBuf(&Msg->OtherNode);
54 DeleteHash(&Msg->Attachments); /* list of Attachments */
55 DeleteHash(&Msg->Submessages);
56 DeleteHash(&Msg->AttachLinks);
57 DeleteHash(&Msg->AllAttach);
63 void RegisterMsgHdr(const char *HeaderName, long HdrNLen, ExamineMsgHeaderFunc evaluator, int type)
66 ev = (headereval*) malloc(sizeof(headereval));
67 ev->evaluator = evaluator;
69 Put(MsgHeaderHandler, HeaderName, HdrNLen, ev, NULL);
72 void RegisterMimeRenderer(const char *HeaderName, long HdrNLen,
73 RenderMimeFunc MimeRenderer,
77 RenderMimeFuncStruct *f;
79 f = (RenderMimeFuncStruct*) malloc(sizeof(RenderMimeFuncStruct));
81 Put(MimeRenderHandler, HeaderName, HdrNLen, f, NULL);
83 RegisterEmbeddableMimeType(HeaderName, HdrNLen, 10000 - Priority);
86 /*----------------------------------------------------------------------------*/
89 * comparator for two longs in descending order.
91 int longcmp_r(const void *s1, const void *s2) {
95 l1 = *(long *)GetSearchPayload(s1);
96 l2 = *(long *)GetSearchPayload(s2);
98 if (l1 > l2) return(-1);
99 if (l1 < l2) return(+1);
104 * comparator for longs; descending order.
106 int qlongcmp_r(const void *s1, const void *s2) {
110 if (l1 > l2) return(-1);
111 if (l1 < l2) return(+1);
117 * comparator for message summary structs by ascending subject.
119 int summcmp_subj(const void *s1, const void *s2) {
120 message_summary *summ1;
121 message_summary *summ2;
123 summ1 = (message_summary *)GetSearchPayload(s1);
124 summ2 = (message_summary *)GetSearchPayload(s2);
125 return strcasecmp(ChrPtr(summ1->subj), ChrPtr(summ2->subj));
129 * comparator for message summary structs by descending subject.
131 int summcmp_rsubj(const void *s1, const void *s2) {
132 message_summary *summ1;
133 message_summary *summ2;
135 summ1 = (message_summary *)GetSearchPayload(s1);
136 summ2 = (message_summary *)GetSearchPayload(s2);
137 return strcasecmp(ChrPtr(summ2->subj), ChrPtr(summ1->subj));
140 * comparator for message summary structs by descending subject.
142 int groupchange_subj(const void *s1, const void *s2) {
143 message_summary *summ1;
144 message_summary *summ2;
146 summ1 = (message_summary *)s1;
147 summ2 = (message_summary *)s2;
148 return ChrPtr(summ2->subj)[0] != ChrPtr(summ1->subj)[0];
152 * comparator for message summary structs by ascending sender.
154 int summcmp_sender(const void *s1, const void *s2) {
155 message_summary *summ1;
156 message_summary *summ2;
158 summ1 = (message_summary *)GetSearchPayload(s1);
159 summ2 = (message_summary *)GetSearchPayload(s2);
160 return strcasecmp(ChrPtr(summ1->from), ChrPtr(summ2->from));
164 * comparator for message summary structs by descending sender.
166 int summcmp_rsender(const void *s1, const void *s2) {
167 message_summary *summ1;
168 message_summary *summ2;
170 summ1 = (message_summary *)GetSearchPayload(s1);
171 summ2 = (message_summary *)GetSearchPayload(s2);
172 return strcasecmp(ChrPtr(summ2->from), ChrPtr(summ1->from));
175 * comparator for message summary structs by descending sender.
177 int groupchange_sender(const void *s1, const void *s2) {
178 message_summary *summ1;
179 message_summary *summ2;
181 summ1 = (message_summary *)s1;
182 summ2 = (message_summary *)s2;
183 return strcasecmp(ChrPtr(summ2->from), ChrPtr(summ1->from)) != 0;
188 * comparator for message summary structs by ascending date.
190 int summcmp_date(const void *s1, const void *s2) {
191 message_summary *summ1;
192 message_summary *summ2;
194 summ1 = (message_summary *)GetSearchPayload(s1);
195 summ2 = (message_summary *)GetSearchPayload(s2);
197 if (summ1->date < summ2->date) return -1;
198 else if (summ1->date > summ2->date) return +1;
203 * comparator for message summary structs by descending date.
205 int summcmp_rdate(const void *s1, const void *s2) {
206 message_summary *summ1;
207 message_summary *summ2;
209 summ1 = (message_summary *)GetSearchPayload(s1);
210 summ2 = (message_summary *)GetSearchPayload(s2);
212 if (summ1->date < summ2->date) return +1;
213 else if (summ1->date > summ2->date) return -1;
218 * comparator for message summary structs by descending date.
220 const long DAYSECONDS = 24 * 60 * 60;
221 int groupchange_date(const void *s1, const void *s2) {
222 message_summary *summ1;
223 message_summary *summ2;
225 summ1 = (message_summary *)s1;
226 summ2 = (message_summary *)s2;
228 return (summ1->date % DAYSECONDS) != (summ2->date %DAYSECONDS);
232 /*----------------------------------------------------------------------------*/
233 /* Don't wanna know... or? */
234 void examine_pref(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
235 void examine_suff(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
236 void examine_path(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
237 void examine_content_encoding(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
239 /* TODO: do we care? */
242 void examine_nhdr(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
245 if (!strncasecmp(ChrPtr(HdrLine), "yes", 8))
248 int Conditional_ANONYMOUS_MESSAGE(StrBuf *Target, WCTemplputParams *TP)
250 message_summary *Msg = (message_summary*) CTX;
251 return Msg->nhdr != 0;
254 void examine_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
256 Msg->format_type = StrToi(HdrLine);
260 void examine_from(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
264 CheckConvertBufs(WCC);
265 FreeStrBuf(&Msg->from);
266 Msg->from = NewStrBufPlain(NULL, StrLength(HdrLine));
267 StrBuf_RFC822_2_Utf8(Msg->from,
274 void tmplput_MAIL_SUMM_FROM(StrBuf *Target, WCTemplputParams *TP)
276 message_summary *Msg = (message_summary*) CTX;
277 StrBufAppendTemplate(Target, TP, Msg->from, 0);
280 void examine_subj(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
284 CheckConvertBufs(WCC);
285 FreeStrBuf(&Msg->subj);
286 Msg->subj = NewStrBufPlain(NULL, StrLength(HdrLine));
287 StrBuf_RFC822_2_Utf8(Msg->subj,
294 void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
296 message_summary *Msg = (message_summary*) CTX;
298 if (TP->Tokens->nParameters == 4)
303 GetTemplateTokenString(Target, TP, 3, &pch, &len);
305 (strstr(ChrPtr(Msg->subj), pch) == NULL))
307 GetTemplateTokenString(Target, TP, 2, &pch, &len);
308 StrBufAppendBufPlain(Target, pch, len, 0);
311 StrBufAppendTemplate(Target, TP, Msg->subj, 0);
313 int Conditional_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
315 message_summary *Msg = (message_summary*) CTX;
318 return StrLength(Msg->subj) > 0;
322 void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
326 CheckConvertBufs(WCC);
327 FreeStrBuf(&Msg->reply_inreplyto);
328 Msg->reply_inreplyto = NewStrBufPlain(NULL, StrLength(HdrLine));
329 StrBuf_RFC822_2_Utf8(Msg->reply_inreplyto,
336 void tmplput_MAIL_SUMM_INREPLYTO(StrBuf *Target, WCTemplputParams *TP)
338 message_summary *Msg = (message_summary*) CTX;
339 StrBufAppendTemplate(Target, TP, Msg->reply_inreplyto, 0);
342 int Conditional_MAIL_SUMM_UNREAD(StrBuf *Target, WCTemplputParams *TP)
344 message_summary *Msg = (message_summary*) CTX;
345 return (Msg->Flags & MSGFLAG_READ) != 0;
348 void examine_wefw(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
352 CheckConvertBufs(WCC);
353 FreeStrBuf(&Msg->reply_references);
354 Msg->reply_references = NewStrBufPlain(NULL, StrLength(HdrLine));
355 StrBuf_RFC822_2_Utf8(Msg->reply_references,
362 void tmplput_MAIL_SUMM_REFIDS(StrBuf *Target, WCTemplputParams *TP)
364 message_summary *Msg = (message_summary*) CTX;
365 StrBufAppendTemplate(Target, TP, Msg->reply_references, 0);
369 void examine_cccc(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
373 CheckConvertBufs(WCC);
374 FreeStrBuf(&Msg->cccc);
375 Msg->cccc = NewStrBufPlain(NULL, StrLength(HdrLine));
376 StrBuf_RFC822_2_Utf8(Msg->cccc,
382 if (Msg->AllRcpt == NULL)
383 Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
384 if (StrLength(Msg->AllRcpt) > 0) {
385 StrBufAppendBufPlain(Msg->AllRcpt, HKEY(", "), 0);
387 StrBufAppendBuf(Msg->AllRcpt, Msg->cccc, 0);
389 void tmplput_MAIL_SUMM_CCCC(StrBuf *Target, WCTemplputParams *TP)
391 message_summary *Msg = (message_summary*) CTX;
392 StrBufAppendTemplate(Target, TP, Msg->cccc, 0);
396 void examine_room(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
398 if ((StrLength(HdrLine) > 0) &&
399 (strcasecmp(ChrPtr(HdrLine), ChrPtr(WC->CurRoom.name)))) {
400 FreeStrBuf(&Msg->Room);
401 Msg->Room = NewStrBufDup(HdrLine);
404 void tmplput_MAIL_SUMM_ORGROOM(StrBuf *Target, WCTemplputParams *TP)
406 message_summary *Msg = (message_summary*) CTX;
407 StrBufAppendTemplate(Target, TP, Msg->Room, 0);
411 void examine_rfca(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
413 FreeStrBuf(&Msg->Rfca);
414 Msg->Rfca = NewStrBufDup(HdrLine);
416 void tmplput_MAIL_SUMM_RFCA(StrBuf *Target, WCTemplputParams *TP)
418 message_summary *Msg = (message_summary*) CTX;
419 StrBufAppendTemplate(Target, TP, Msg->Rfca, 0);
421 int Conditional_MAIL_SUMM_RFCA(StrBuf *Target, WCTemplputParams *TP)
423 message_summary *Msg = (message_summary*) CTX;
424 return StrLength(Msg->Rfca) > 0;
426 int Conditional_MAIL_SUMM_CCCC(StrBuf *Target, WCTemplputParams *TP)
428 message_summary *Msg = (message_summary*) CTX;
429 return StrLength(Msg->cccc) > 0;
432 void examine_node(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
436 if ( (StrLength(HdrLine) > 0) &&
437 ((WC->CurRoom.QRFlags & QR_NETWORK)
438 || ((strcasecmp(ChrPtr(HdrLine), ChrPtr(WCC->serv_info->serv_nodename))
439 && (strcasecmp(ChrPtr(HdrLine), ChrPtr(WCC->serv_info->serv_fqdn))))))) {
440 FreeStrBuf(&Msg->OtherNode);
441 Msg->OtherNode = NewStrBufDup(HdrLine);
444 void tmplput_MAIL_SUMM_OTHERNODE(StrBuf *Target, WCTemplputParams *TP)
446 message_summary *Msg = (message_summary*) CTX;
447 StrBufAppendTemplate(Target, TP, Msg->OtherNode, 0);
449 int Conditional_MAIL_SUMM_OTHERNODE(StrBuf *Target, WCTemplputParams *TP)
451 message_summary *Msg = (message_summary*) CTX;
452 return StrLength(Msg->OtherNode) > 0;
456 void examine_rcpt(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
460 CheckConvertBufs(WCC);
461 FreeStrBuf(&Msg->to);
462 Msg->to = NewStrBufPlain(NULL, StrLength(HdrLine));
463 StrBuf_RFC822_2_Utf8(Msg->to,
469 if (Msg->AllRcpt == NULL)
470 Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
471 if (StrLength(Msg->AllRcpt) > 0) {
472 StrBufAppendBufPlain(Msg->AllRcpt, HKEY(", "), 0);
474 StrBufAppendBuf(Msg->AllRcpt, Msg->to, 0);
476 void tmplput_MAIL_SUMM_TO(StrBuf *Target, WCTemplputParams *TP)
478 message_summary *Msg = (message_summary*) CTX;
479 StrBufAppendTemplate(Target, TP, Msg->to, 0);
481 int Conditional_MAIL_SUMM_TO(StrBuf *Target, WCTemplputParams *TP)
483 message_summary *Msg = (message_summary*) CTX;
484 return StrLength(Msg->to) != 0;
486 int Conditional_MAIL_SUMM_SUBJ(StrBuf *Target, WCTemplputParams *TP)
488 message_summary *Msg = (message_summary*) CTX;
489 return StrLength(Msg->subj) != 0;
491 void tmplput_MAIL_SUMM_ALLRCPT(StrBuf *Target, WCTemplputParams *TP)
493 message_summary *Msg = (message_summary*) CTX;
494 StrBufAppendTemplate(Target, TP, Msg->AllRcpt, 0);
499 void tmplput_SUMM_COUNT(StrBuf *Target, WCTemplputParams *TP)
501 StrBufAppendPrintf(Target, "%d", GetCount( WC->summ));
504 HashList *iterate_get_mailsumm_All(StrBuf *Target, WCTemplputParams *TP)
508 void examine_time(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
510 Msg->date = StrTol(HdrLine);
513 void tmplput_MAIL_SUMM_DATE_BRIEF(StrBuf *Target, WCTemplputParams *TP)
516 message_summary *Msg = (message_summary*) CTX;
517 webcit_fmt_date(datebuf, 64, Msg->date, DATEFMT_BRIEF);
518 StrBufAppendBufPlain(Target, datebuf, -1, 0);
521 void tmplput_MAIL_SUMM_EUID(StrBuf *Target, WCTemplputParams *TP)
523 message_summary *Msg = (message_summary*) CTX;
524 StrBufAppendTemplate(Target, TP, Msg->euid, 0);
527 void tmplput_MAIL_SUMM_DATE_FULL(StrBuf *Target, WCTemplputParams *TP)
530 message_summary *Msg = (message_summary*) CTX;
531 webcit_fmt_date(datebuf, 64, Msg->date, DATEFMT_FULL);
532 StrBufAppendBufPlain(Target, datebuf, -1, 0);
534 void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, WCTemplputParams *TP)
536 message_summary *Msg = (message_summary*) CTX;
537 StrBufAppendPrintf(Target, "%ld", Msg->date, 0);
542 void render_MAIL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
544 const StrBuf *TemplateMime;
546 if (Mime->Data == NULL)
547 Mime->Data = NewStrBufPlain(NULL, Mime->length);
549 FlushStrBuf(Mime->Data);
550 read_message(Mime->Data, HKEY("view_submessage"), Mime->msgnum, Mime->PartNum, &TemplateMime);
552 if ( (!IsEmptyStr(mime_submessages)) && (!section[0]) ) {
553 for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
554 extract_token(buf, mime_submessages, i, '|', sizeof buf);
555 / ** use printable_view to suppress buttons * /
556 wc_printf("<blockquote>");
557 read_message(Mime->msgnum, 1, ChrPtr(Mime->Section));
558 wc_printf("</blockquote>");
564 void render_MIME_VCard(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
567 if (StrLength(Mime->Data) == 0)
569 if (StrLength(Mime->Data) > 0) {
572 /** If it's my vCard I can edit it */
573 if ( (!strcasecmp(ChrPtr(WCC->CurRoom.name), USERCONFIGROOM))
574 || (!strcasecmp(&(ChrPtr(WCC->CurRoom.name)[11]), USERCONFIGROOM))
575 || (WC->CurRoom.view == VIEW_ADDRESSBOOK)
577 StrBufAppendPrintf(Buf, "<a href=\"edit_vcard?msgnum=%ld?partnum=%s\">",
578 Mime->msgnum, ChrPtr(Mime->PartNum));
579 StrBufAppendPrintf(Buf, "[%s]</a>", _("edit"));
582 /* In all cases, display the full card */
583 display_vcard(Buf, Mime, 0, 1, NULL, -1);
584 FreeStrBuf(&Mime->Data);
590 void render_MIME_VNote(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
592 if (StrLength(Mime->Data) == 0)
594 if (StrLength(Mime->Data) > 0) {
600 vcard = SmashStrBuf(&Mime->Data);
601 v = vnote_new_from_str(vcard);
606 memset(&TP, 0, sizeof(WCTemplputParams));
607 TP.Filter.ContextType = CTX_VNOTE;
609 DoTemplate(HKEY("mail_vnoteitem"),
616 if (Mime->Data == NULL)
617 Mime->Data = NewStrBuf();
619 FlushStrBuf(Mime->Data);
624 void render_MIME_ICS(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
626 if (StrLength(Mime->Data) == 0) {
629 if (StrLength(Mime->Data) > 0) {
630 cal_process_attachment(Mime);
636 void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
638 const char *Ptr = NULL;
639 wc_mime_attachment *Mime;
643 CheckConvertBufs(WCC);
644 Mime = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
645 memset(Mime, 0, sizeof(wc_mime_attachment));
646 Mime->msgnum = Msg->msgnum;
649 Mime->Name = NewStrBuf();
650 StrBufExtract_NextToken(Buf, HdrLine, &Ptr, '|');
651 StrBuf_RFC822_2_Utf8(Mime->Name,
657 StrBufTrim(Mime->Name);
659 StrBufExtract_NextToken(Buf, HdrLine, &Ptr, '|');
660 Mime->FileName = NewStrBuf();
661 StrBuf_RFC822_2_Utf8(Mime->FileName,
667 StrBufTrim(Mime->FileName);
669 Mime->PartNum = NewStrBuf();
670 StrBufExtract_NextToken(Mime->PartNum, HdrLine, &Ptr, '|');
671 StrBufTrim(Mime->PartNum);
672 if (strchr(ChrPtr(Mime->PartNum), '.') != NULL)
677 Mime->Disposition = NewStrBuf();
678 StrBufExtract_NextToken(Mime->Disposition, HdrLine, &Ptr, '|');
680 Mime->ContentType = NewStrBuf();
681 StrBufExtract_NextToken(Mime->ContentType, HdrLine, &Ptr, '|');
682 StrBufTrim(Mime->ContentType);
683 StrBufLowerCase(Mime->ContentType);
684 if (!strcmp(ChrPtr(Mime->ContentType), "application/octet-stream")) {
685 StrBufPlain(Mime->ContentType,
686 GuessMimeByFilename(SKEY(Mime->FileName)), -1);
689 Mime->length = StrBufExtractNext_int(HdrLine, &Ptr, '|');
691 StrBufSkip_NTokenS(HdrLine, &Ptr, '|', 1); /* cbid?? */
693 Mime->Charset = NewStrBuf();
694 StrBufExtract_NextToken(Mime->Charset, HdrLine, &Ptr, '|');
697 if ( (StrLength(Mime->FileName) == 0) && (StrLength(Mime->Name) > 0) ) {
698 StrBufAppendBuf(Mime->FileName, Mime->Name, 0);
701 if (StrLength(Msg->PartNum) > 0) {
703 StrBufPrintf(Buf, "%s.%s", ChrPtr(Msg->PartNum), ChrPtr(Mime->PartNum));
709 if (Msg->AllAttach == NULL)
710 Msg->AllAttach = NewHash(1,NULL);
711 Put(Msg->AllAttach, SKEY(Mime->PartNum), Mime, DestroyMime);
716 void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime)
720 /* just print the root-node */
721 if ((Mime->level >= 1) &&
722 GetHash(MimeRenderHandler, SKEY(Mime->ContentType), &vMimeRenderer) &&
723 vMimeRenderer != NULL)
725 Mime->Renderer = (RenderMimeFuncStruct*) vMimeRenderer;
726 if (Msg->Submessages == NULL)
727 Msg->Submessages = NewHash(1,NULL);
728 Put(Msg->Submessages, SKEY(Mime->PartNum), Mime, reference_free_handler);
730 else if ((Mime->level >= 1) &&
731 (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
732 && (!strncasecmp(ChrPtr(Mime->ContentType), "image/", 6)) ){
733 if (Msg->AttachLinks == NULL)
734 Msg->AttachLinks = NewHash(1,NULL);
735 Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
737 else if ((Mime->level >= 1) &&
738 (StrLength(Mime->ContentType) > 0) &&
739 ( (!strcasecmp(ChrPtr(Mime->Disposition), "attachment"))
740 || (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
741 || (!strcasecmp(ChrPtr(Mime->Disposition), ""))))
743 if (Msg->AttachLinks == NULL)
744 Msg->AttachLinks = NewHash(1,NULL);
745 Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
746 if ((strcasecmp(ChrPtr(Mime->ContentType), "application/octet-stream") == 0) &&
747 (StrLength(Mime->FileName) > 0)) {
748 FlushStrBuf(Mime->ContentType);
749 StrBufAppendBufPlain(Mime->ContentType,
750 GuessMimeByFilename(SKEY(Mime->FileName)),
756 void tmplput_MAIL_SUMM_NATTACH(StrBuf *Target, WCTemplputParams *TP)
758 message_summary *Msg = (message_summary*) CTX;
759 StrBufAppendPrintf(Target, "%ld", GetCount(Msg->Attachments));
763 void examine_hnod(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
767 CheckConvertBufs(WCC);
768 FreeStrBuf(&Msg->hnod);
769 Msg->hnod = NewStrBufPlain(NULL, StrLength(HdrLine));
770 StrBuf_RFC822_2_Utf8(Msg->hnod,
777 void tmplput_MAIL_SUMM_H_NODE(StrBuf *Target, WCTemplputParams *TP)
779 message_summary *Msg = (message_summary*) CTX;
780 StrBufAppendTemplate(Target, TP, Msg->hnod, 0);
782 int Conditional_MAIL_SUMM_H_NODE(StrBuf *Target, WCTemplputParams *TP)
784 message_summary *Msg = (message_summary*) CTX;
785 return StrLength(Msg->hnod) > 0;
790 void examine_text(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
792 if (Msg->MsgBody->Data == NULL)
793 Msg->MsgBody->Data = NewStrBufPlain(NULL, SIZ);
795 FlushStrBuf(Msg->MsgBody->Data);
798 void examine_msg4_partnum(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
800 Msg->MsgBody->PartNum = NewStrBufDup(HdrLine);
801 StrBufTrim(Msg->MsgBody->PartNum);
804 void examine_content_lengh(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
806 Msg->MsgBody->length = StrTol(HdrLine);
807 Msg->MsgBody->size_known = 1;
810 void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
820 Msg->MsgBody->ContentType = NewStrBufDup(HdrLine);
821 sem = strchr(ChrPtr(HdrLine), ';');
824 Token = NewStrBufPlain(NULL, StrLength(HdrLine));
825 Value = NewStrBufPlain(NULL, StrLength(HdrLine));
826 len = sem - ChrPtr(HdrLine);
827 StrBufCutAt(Msg->MsgBody->ContentType, len, NULL);
828 while (sem != NULL) {
829 while (isspace(*(sem + 1)))
831 StrBufCutLeft(HdrLine, sem - ChrPtr(HdrLine));
832 sem = strchr(ChrPtr(HdrLine), ';');
834 len = sem - ChrPtr(HdrLine);
836 len = StrLength(HdrLine);
839 StrBufAppendBufPlain(Token, ChrPtr(HdrLine), len, 0);
840 eq = strchr(ChrPtr(Token), '=');
842 len = eq - ChrPtr(Token);
843 StrBufAppendBufPlain(Value, eq + 1, StrLength(Token) - len - 1, 0);
844 StrBufCutAt(Token, len, NULL);
849 if (GetHash(MsgHeaderHandler, SKEY(Token), &vHdr) &&
851 Hdr = (headereval*)vHdr;
852 Hdr->evaluator(Msg, Value, FoundCharset);
854 else syslog(1, "don't know how to handle content type sub-header[%s]\n", ChrPtr(Token));
861 void tmplput_MAIL_SUMM_N(StrBuf *Target, WCTemplputParams *TP)
863 message_summary *Msg = (message_summary*) CTX;
864 StrBufAppendPrintf(Target, "%ld", Msg->msgnum);
869 int Conditional_MAIL_MIME_ALL(StrBuf *Target, WCTemplputParams *TP)
871 message_summary *Msg = (message_summary*) CTX;
872 return GetCount(Msg->Attachments) > 0;
875 int Conditional_MAIL_MIME_SUBMESSAGES(StrBuf *Target, WCTemplputParams *TP)
877 message_summary *Msg = (message_summary*) CTX;
878 return GetCount(Msg->Submessages) > 0;
881 int Conditional_MAIL_MIME_ATTACHLINKS(StrBuf *Target, WCTemplputParams *TP)
883 message_summary *Msg = (message_summary*) CTX;
884 return GetCount(Msg->AttachLinks) > 0;
887 int Conditional_MAIL_MIME_ATTACH(StrBuf *Target, WCTemplputParams *TP)
889 message_summary *Msg = (message_summary*) CTX;
890 return GetCount(Msg->AllAttach) > 0;
893 void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
899 MsgNum = LBstr(TKEY(0));
901 read_message(Buf, HKEY("view_message_replyquote"), MsgNum, NULL, &Mime);
902 StrBufAppendTemplate(Target, TP, Buf, 1);
906 void tmplput_EDIT_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
912 MsgNum = LBstr(TKEY(0));
914 read_message(Buf, HKEY("view_message_edit"), MsgNum, NULL, &Mime);
915 StrBufAppendTemplate(Target, TP, Buf, 1);
919 void tmplput_EDIT_WIKI_BODY(StrBuf *Target, WCTemplputParams *TP)
925 /* Insert the existing content of the wiki page into the editor. But we only want
926 * to do this the first time -- if the user is uploading an attachment we don't want
929 if (!havebstr("attach_button")) {
930 msgnum = locate_message_by_uid(BSTR("page"));
933 read_message(Buf, HKEY("view_message_wikiedit"), msgnum, NULL, &Mime);
934 StrBufAppendTemplate(Target, TP, Buf, 1);
940 void tmplput_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
942 message_summary *Msg = (message_summary*) CTX;
943 StrBufAppendTemplate(Target, TP, Msg->MsgBody->Data, 0);
947 void render_MAIL_variformat(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
949 /* Messages in legacy Citadel variformat get handled thusly... */
950 StrBuf *Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
951 FmOut(Target, "JUSTIFY", Mime->Data);
952 FreeStrBuf(&Mime->Data);
956 void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
958 const char *ptr, *pte;
959 const char *BufPtr = NULL;
973 iconv_t ic = (iconv_t)(-1) ;
976 if ((StrLength(Mime->Data) == 0) && (Mime->length > 0)) {
977 FreeStrBuf(&Mime->Data);
983 if (StrLength(Mime->Charset) != 0)
985 else if (StrLength(FoundCharset) > 0)
987 else if (StrLength(WC->DefaultCharset) > 0)
988 cs = WC->DefaultCharset;
992 else if (!strcasecmp(ChrPtr(cs), "utf-8")) {
995 else if (!strcasecmp(ChrPtr(cs), "us-ascii")) {
999 ctdl_iconv_open("UTF-8", ChrPtr(cs), &ic);
1000 if (ic == (iconv_t)(-1) ) {
1001 syslog(5, "%s:%d iconv_open(UTF-8, %s) failed: %s\n",
1002 __FILE__, __LINE__, ChrPtr(Mime->Charset), strerror(errno));
1007 Line = NewStrBufPlain(NULL, SIZ);
1008 Line1 = NewStrBufPlain(NULL, SIZ);
1009 Line2 = NewStrBufPlain(NULL, SIZ);
1010 Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
1013 if (StrLength(Mime->Data) > 0)
1016 StrBufSipLine(Line, Mime->Data, &BufPtr);
1020 len = StrLength(Line);
1023 while ((ptr < pte) &&
1032 if (i > 0) StrBufCutLeft(Line, i);
1034 if (StrLength(Line) == 0) {
1037 StrBufAppendBufPlain(Target, HKEY("<tt></tt><br>\n"), 0);
1043 for (i = bn; i < bq; i++)
1044 StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
1045 for (i = bq; i < bn; i++)
1046 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
1049 StrBufConvert(Line, Line1, &ic);
1052 StrBufAppendBufPlain(Target, HKEY("<tt>"), 0);
1053 UrlizeText(Line1, Line, Line2);
1055 StrEscAppend(Target, Line1, NULL, 0, 0);
1056 StrBufAppendBufPlain(Target, HKEY("</tt><br>\n"), 0);
1060 while ((BufPtr != StrBufNOTNULL) &&
1063 if (nEmptyLines > 0)
1064 StrBufCutRight(Target, nEmptyLines * (sizeof ("<tt></tt><br>\n") - 1));
1065 for (i = 0; i < bn; i++)
1066 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
1068 StrBufAppendBufPlain(Target, HKEY("</i><br>"), 0);
1070 if (ic != (iconv_t)(-1) ) {
1075 FreeStrBuf(&Mime->Data);
1076 Mime->Data = Target;
1077 FlushStrBuf(Mime->ContentType);
1078 StrBufAppendBufPlain(Mime->ContentType, HKEY("text/html"), 0);
1079 FlushStrBuf(Mime->Charset);
1080 StrBufAppendBufPlain(Mime->Charset, HKEY("UTF-8"), 0);
1086 void render_MAIL_html(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
1090 if (StrLength(Mime->Data) == 0)
1093 Buf = NewStrBufPlain(NULL, StrLength(Mime->Data));
1095 /* HTML is fun, but we've got to strip it first */
1096 output_html(ChrPtr(Mime->Charset),
1097 (WC->CurRoom.view == VIEW_WIKI ? 1 : 0),
1100 FreeStrBuf(&Mime->Data);
1104 void render_MAIL_UNKNOWN(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
1106 /* Unknown weirdness */
1107 FlushStrBuf(Mime->Data);
1108 StrBufAppendBufPlain(Mime->Data, _("I don't know how to display "), -1, 0);
1109 StrBufAppendBuf(Mime->Data, Mime->ContentType, 0);
1110 StrBufAppendBufPlain(Mime->Data, HKEY("<br>\n"), 0);
1114 HashList *iterate_get_mime_All(StrBuf *Target, WCTemplputParams *TP)
1116 message_summary *Msg = (message_summary*) CTX;
1117 return Msg->Attachments;
1119 HashList *iterate_get_mime_Submessages(StrBuf *Target, WCTemplputParams *TP)
1121 message_summary *Msg = (message_summary*) CTX;
1122 return Msg->Submessages;
1124 HashList *iterate_get_mime_AttachLinks(StrBuf *Target, WCTemplputParams *TP)
1126 message_summary *Msg = (message_summary*) CTX;
1127 return Msg->AttachLinks;
1129 HashList *iterate_get_mime_Attachments(StrBuf *Target, WCTemplputParams *TP)
1131 message_summary *Msg = (message_summary*) CTX;
1132 return Msg->AllAttach;
1135 void tmplput_MIME_Name(StrBuf *Target, WCTemplputParams *TP)
1137 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1138 StrBufAppendTemplate(Target, TP, mime->Name, 0);
1141 void tmplput_MIME_FileName(StrBuf *Target, WCTemplputParams *TP)
1143 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1144 StrBufAppendTemplate(Target, TP, mime->FileName, 0);
1147 void tmplput_MIME_PartNum(StrBuf *Target, WCTemplputParams *TP)
1149 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1150 StrBufAppendTemplate(Target, TP, mime->PartNum, 0);
1153 void tmplput_MIME_MsgNum(StrBuf *Target, WCTemplputParams *TP)
1155 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1156 StrBufAppendPrintf(Target, "%ld", mime->msgnum);
1159 void tmplput_MIME_Disposition(StrBuf *Target, WCTemplputParams *TP)
1161 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1162 StrBufAppendTemplate(Target, TP, mime->Disposition, 0);
1165 void tmplput_MIME_ContentType(StrBuf *Target, WCTemplputParams *TP)
1167 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1168 StrBufAppendTemplate(Target, TP, mime->ContentType, 0);
1171 void examine_charset(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
1173 Msg->MsgBody->Charset = NewStrBufDup(HdrLine);
1176 void tmplput_MIME_Charset(StrBuf *Target, WCTemplputParams *TP)
1178 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1179 StrBufAppendTemplate(Target, TP, mime->Charset, 0);
1182 void tmplput_MIME_Data(StrBuf *Target, WCTemplputParams *TP)
1184 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1185 if (mime->Renderer != NULL)
1186 mime->Renderer->f(mime, NULL, NULL);
1187 StrBufAppendTemplate(Target, TP, mime->Data, 0);
1188 /* TODO: check whether we need to load it now? */
1191 void tmplput_MIME_LoadData(StrBuf *Target, WCTemplputParams *TP)
1193 wcsession *WCC = WC;
1194 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1195 wc_mime_attachment *att;
1197 if (( (!strcasecmp(ChrPtr(mime->Disposition), "inline"))||
1198 (!strcasecmp(ChrPtr(mime->Disposition), "attachment"))) &&
1199 (strcasecmp(ChrPtr(mime->ContentType), "application/ms-tnef")!=0))
1204 /* steal this mime part... */
1205 att = malloc(sizeof(wc_mime_attachment));
1206 memcpy(att, mime, sizeof(wc_mime_attachment));
1207 memset(mime, 0, sizeof(wc_mime_attachment));
1209 if (att->Data == NULL)
1212 if (WCC->attachments == NULL)
1213 WCC->attachments = NewHash(1, NULL);
1214 /* And add it to the list. */
1215 n = snprintf(N, sizeof N, "%d", GetCount(WCC->attachments) + 1);
1216 Put(WCC->attachments, N, n, att, DestroyMime);
1220 void tmplput_MIME_Length(StrBuf *Target, WCTemplputParams *TP)
1222 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1223 StrBufAppendPrintf(Target, "%ld", mime->length);
1226 HashList *iterate_get_registered_Attachments(StrBuf *Target, WCTemplputParams *TP)
1228 return WC->attachments;
1231 void get_registered_Attachments_Count(StrBuf *Target, WCTemplputParams *TP)
1233 StrBufAppendPrintf(Target, "%ld", GetCount (WC->attachments));
1236 void servcmd_do_search(char *buf, long bufsize)
1238 snprintf(buf, bufsize, "MSGS SEARCH|%s", bstr("query"));
1241 void servcmd_headers(char *buf, long bufsize)
1243 snprintf(buf, bufsize, "MSGS ALL");
1246 void servcmd_readfwd(char *buf, long bufsize)
1248 snprintf(buf, bufsize, "MSGS ALL");
1251 void servcmd_readgt(char *buf, long bufsize)
1253 snprintf(buf, bufsize, "MSGS GT|%s", bstr("gt"));
1256 void servcmd_readlt(char *buf, long bufsize)
1258 snprintf(buf, bufsize, "MSGS LT|%s", bstr("lt"));
1261 void servcmd_readnew(char *buf, long bufsize)
1263 snprintf(buf, bufsize, "MSGS NEW");
1266 void servcmd_readold(char *buf, long bufsize)
1268 snprintf(buf, bufsize, "MSGS OLD");
1272 /* DO NOT REORDER OR REMOVE ANY OF THESE */
1273 readloop_struct rlid[] = {
1274 { {HKEY("do_search")}, servcmd_do_search },
1275 { {HKEY("headers")}, servcmd_headers },
1276 { {HKEY("readfwd")}, servcmd_readfwd },
1277 { {HKEY("readnew")}, servcmd_readnew },
1278 { {HKEY("readold")}, servcmd_readold },
1279 { {HKEY("readgt")}, servcmd_readgt },
1280 { {HKEY("readlt")}, servcmd_readlt }
1284 int ParseMessageListHeaders_Detail(StrBuf *Line,
1286 message_summary *Msg,
1287 StrBuf *ConversionBuffer)
1289 wcsession *WCC = WC;
1293 CheckConvertBufs(WCC);
1295 totallen = StrLength(Line);
1296 Msg->from = NewStrBufPlain(NULL, totallen);
1297 len = StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
1299 /* Handle senders with RFC2047 encoding */
1300 StrBuf_RFC822_2_Utf8(Msg->from,
1302 WCC->DefaultCharset,
1309 len = StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
1311 ( ((WCC->CurRoom.QRFlags & QR_NETWORK)
1312 || ((strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_nodename))
1313 && (strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_fqdn))))))))
1315 StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
1316 StrBufAppendBuf(Msg->from, ConversionBuffer, 0);
1319 /* Internet address (not used)
1320 * StrBufExtract_token(Msg->inetaddr, Line, 4, '|');
1322 StrBufSkip_NTokenS(Line, pos, '|', 1);
1323 Msg->subj = NewStrBufPlain(NULL, totallen);
1325 FlushStrBuf(ConversionBuffer);
1326 /* we assume the subject is the last parameter inside of the list;
1327 * thus we don't use the tokenizer to fetch it, since it will hick up
1328 * on tokenizer chars inside of the subjects
1329 StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
1332 if (*pos != StrBufNOTNULL) {
1333 len = totallen - (*pos - ChrPtr(Line));
1334 StrBufPlain(ConversionBuffer, *pos, len);
1335 *pos = StrBufNOTNULL;
1337 (*(ChrPtr(ConversionBuffer) + len - 1) == '|'))
1338 StrBufCutRight(ConversionBuffer, 1);
1342 StrBufAppendBufPlain(Msg->subj, _("(no subject)"), -1,0);
1344 StrBuf_RFC822_2_Utf8(Msg->subj,
1346 WCC->DefaultCharset,
1355 /* Spit out the new summary view. This is basically a static page, so clients can cache the layout, all the dirty work is javascript :) */
1356 void new_summary_view(void) {
1357 DoTemplate(HKEY("msg_listview"),NULL,&NoCtx);
1361 int mailview_GetParamsGetServerCall(SharedMessageStatus *Stat,
1362 void **ViewSpecific,
1371 Stat->defaultsortorder = 2;
1373 Stat->load_seen = 1;
1374 /* Generally using maxmsgs|startmsg is not required
1375 in mailbox view, but we have a 'safemode' for clients
1376 (*cough* Exploder) that simply can't handle too many */
1377 if (havebstr("maxmsgs")) Stat->maxmsgs = ibstr("maxmsgs");
1378 else Stat->maxmsgs = 9999999;
1379 if (havebstr("startmsg")) Stat->startmsg = lbstr("startmsg");
1380 snprintf(cmd, len, "MSGS %s|%s||1",
1381 (oper == do_search) ? "SEARCH" : "ALL",
1382 (oper == do_search) ? bstr("query") : ""
1388 int mailview_RenderView_or_Tail(SharedMessageStatus *Stat,
1389 void **ViewSpecific,
1392 WCTemplputParams SubTP;
1395 DoTemplate(HKEY("mailsummary_json"),NULL, &SubTP);
1400 int mailview_Cleanup(void **ViewSpecific)
1402 /* Note: wDumpContent() will output one additional </div> tag. */
1403 /* We ought to move this out into template */
1415 InitModule_MSGRENDERERS
1418 RegisterReadLoopHandlerset(
1420 mailview_GetParamsGetServerCall,
1421 NULL, /* TODO: is this right? */
1422 ParseMessageListHeaders_Detail,
1424 mailview_RenderView_or_Tail,
1427 RegisterSortFunc(HKEY("date"),
1433 RegisterSortFunc(HKEY("subject"),
1439 RegisterSortFunc(HKEY("sender"),
1446 RegisterNamespace("SUMM:COUNT", 0, 0, tmplput_SUMM_COUNT, NULL, CTX_NONE);
1447 /* iterate over all known mails in WC->summ */
1448 RegisterIterator("MAIL:SUMM:MSGS", 0, NULL, iterate_get_mailsumm_All,
1449 NULL,NULL, CTX_MAILSUM, CTX_NONE, IT_NOFLAG);
1451 RegisterNamespace("MAIL:SUMM:EUID", 0, 1, tmplput_MAIL_SUMM_EUID, NULL, CTX_MAILSUM);
1452 RegisterNamespace("MAIL:SUMM:DATEBRIEF", 0, 0, tmplput_MAIL_SUMM_DATE_BRIEF, NULL, CTX_MAILSUM);
1453 RegisterNamespace("MAIL:SUMM:DATEFULL", 0, 0, tmplput_MAIL_SUMM_DATE_FULL, NULL, CTX_MAILSUM);
1454 RegisterNamespace("MAIL:SUMM:DATENO", 0, 0, tmplput_MAIL_SUMM_DATE_NO, NULL, CTX_MAILSUM);
1455 RegisterNamespace("MAIL:SUMM:N", 0, 0, tmplput_MAIL_SUMM_N, NULL, CTX_MAILSUM);
1456 RegisterNamespace("MAIL:SUMM:FROM", 0, 2, tmplput_MAIL_SUMM_FROM, NULL, CTX_MAILSUM);
1457 RegisterNamespace("MAIL:SUMM:TO", 0, 2, tmplput_MAIL_SUMM_TO, NULL, CTX_MAILSUM);
1458 RegisterNamespace("MAIL:SUMM:SUBJECT", 0, 4, tmplput_MAIL_SUMM_SUBJECT, NULL, CTX_MAILSUM);
1459 RegisterNamespace("MAIL:SUMM:NTATACH", 0, 0, tmplput_MAIL_SUMM_NATTACH, NULL, CTX_MAILSUM);
1460 RegisterNamespace("MAIL:SUMM:CCCC", 0, 2, tmplput_MAIL_SUMM_CCCC, NULL, CTX_MAILSUM);
1461 RegisterNamespace("MAIL:SUMM:H_NODE", 0, 2, tmplput_MAIL_SUMM_H_NODE, NULL, CTX_MAILSUM);
1462 RegisterNamespace("MAIL:SUMM:ALLRCPT", 0, 2, tmplput_MAIL_SUMM_ALLRCPT, NULL, CTX_MAILSUM);
1463 RegisterNamespace("MAIL:SUMM:ORGROOM", 0, 2, tmplput_MAIL_SUMM_ORGROOM, NULL, CTX_MAILSUM);
1464 RegisterNamespace("MAIL:SUMM:RFCA", 0, 2, tmplput_MAIL_SUMM_RFCA, NULL, CTX_MAILSUM);
1465 RegisterNamespace("MAIL:SUMM:OTHERNODE", 2, 0, tmplput_MAIL_SUMM_OTHERNODE, NULL, CTX_MAILSUM);
1466 RegisterNamespace("MAIL:SUMM:REFIDS", 0, 1, tmplput_MAIL_SUMM_REFIDS, NULL, CTX_MAILSUM);
1467 RegisterNamespace("MAIL:SUMM:INREPLYTO", 0, 2, tmplput_MAIL_SUMM_INREPLYTO, NULL, CTX_MAILSUM);
1468 RegisterNamespace("MAIL:BODY", 0, 2, tmplput_MAIL_BODY, NULL, CTX_MAILSUM);
1469 RegisterNamespace("MAIL:QUOTETEXT", 1, 2, tmplput_QUOTED_MAIL_BODY, NULL, CTX_NONE);
1470 RegisterNamespace("MAIL:EDITTEXT", 1, 2, tmplput_EDIT_MAIL_BODY, NULL, CTX_NONE);
1471 RegisterNamespace("MAIL:EDITWIKI", 1, 2, tmplput_EDIT_WIKI_BODY, NULL, CTX_NONE);
1472 RegisterConditional(HKEY("COND:MAIL:SUMM:RFCA"), 0, Conditional_MAIL_SUMM_RFCA, CTX_MAILSUM);
1473 RegisterConditional(HKEY("COND:MAIL:SUMM:CCCC"), 0, Conditional_MAIL_SUMM_CCCC, CTX_MAILSUM);
1474 RegisterConditional(HKEY("COND:MAIL:SUMM:UNREAD"), 0, Conditional_MAIL_SUMM_UNREAD, CTX_MAILSUM);
1475 RegisterConditional(HKEY("COND:MAIL:SUMM:H_NODE"), 0, Conditional_MAIL_SUMM_H_NODE, CTX_MAILSUM);
1476 RegisterConditional(HKEY("COND:MAIL:SUMM:OTHERNODE"), 0, Conditional_MAIL_SUMM_OTHERNODE, CTX_MAILSUM);
1477 RegisterConditional(HKEY("COND:MAIL:SUMM:SUBJECT"), 0, Conditional_MAIL_SUMM_SUBJECT, CTX_MAILSUM);
1478 RegisterConditional(HKEY("COND:MAIL:ANON"), 0, Conditional_ANONYMOUS_MESSAGE, CTX_MAILSUM);
1479 RegisterConditional(HKEY("COND:MAIL:TO"), 0, Conditional_MAIL_SUMM_TO, CTX_MAILSUM);
1480 RegisterConditional(HKEY("COND:MAIL:SUBJ"), 0, Conditional_MAIL_SUMM_SUBJ, CTX_MAILSUM);
1482 /* do we have mimetypes to iterate over? */
1483 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH"), 0, Conditional_MAIL_MIME_ALL, CTX_MAILSUM);
1484 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:SUBMESSAGES"), 0, Conditional_MAIL_MIME_SUBMESSAGES, CTX_MAILSUM);
1485 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:LINKS"), 0, Conditional_MAIL_MIME_ATTACHLINKS, CTX_MAILSUM);
1486 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:ATT"), 0, Conditional_MAIL_MIME_ATTACH, CTX_MAILSUM);
1487 RegisterIterator("MAIL:MIME:ATTACH", 0, NULL, iterate_get_mime_All,
1488 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1489 RegisterIterator("MAIL:MIME:ATTACH:SUBMESSAGES", 0, NULL, iterate_get_mime_Submessages,
1490 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1491 RegisterIterator("MAIL:MIME:ATTACH:LINKS", 0, NULL, iterate_get_mime_AttachLinks,
1492 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1493 RegisterIterator("MAIL:MIME:ATTACH:ATT", 0, NULL, iterate_get_mime_Attachments,
1494 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1496 /* Parts of a mime attachent */
1497 RegisterNamespace("MAIL:MIME:NAME", 0, 2, tmplput_MIME_Name, NULL, CTX_MIME_ATACH);
1498 RegisterNamespace("MAIL:MIME:FILENAME", 0, 2, tmplput_MIME_FileName, NULL, CTX_MIME_ATACH);
1499 RegisterNamespace("MAIL:MIME:PARTNUM", 0, 2, tmplput_MIME_PartNum, NULL, CTX_MIME_ATACH);
1500 RegisterNamespace("MAIL:MIME:MSGNUM", 0, 2, tmplput_MIME_MsgNum, NULL, CTX_MIME_ATACH);
1501 RegisterNamespace("MAIL:MIME:DISPOSITION", 0, 2, tmplput_MIME_Disposition, NULL, CTX_MIME_ATACH);
1502 RegisterNamespace("MAIL:MIME:CONTENTTYPE", 0, 2, tmplput_MIME_ContentType, NULL, CTX_MIME_ATACH);
1503 RegisterNamespace("MAIL:MIME:CHARSET", 0, 2, tmplput_MIME_Charset, NULL, CTX_MIME_ATACH);
1504 RegisterNamespace("MAIL:MIME:LENGTH", 0, 2, tmplput_MIME_Length, NULL, CTX_MIME_ATACH);
1505 RegisterNamespace("MAIL:MIME:DATA", 0, 2, tmplput_MIME_Data, NULL, CTX_MIME_ATACH);
1506 /* load the actual attachment into WC->attachments; no output!!! */
1507 RegisterNamespace("MAIL:MIME:LOADDATA", 0, 0, tmplput_MIME_LoadData, NULL, CTX_MIME_ATACH);
1509 /* iterate the WC->attachments; use the above tokens for their contents */
1510 RegisterIterator("MSG:ATTACHNAMES", 0, NULL, iterate_get_registered_Attachments,
1511 NULL, NULL, CTX_MIME_ATACH, CTX_NONE, IT_NOFLAG);
1513 RegisterNamespace("MSG:NATTACH", 0, 0, get_registered_Attachments_Count, NULL, CTX_NONE);
1515 /* mime renderers translate an attachment into webcit viewable html text */
1516 RegisterMimeRenderer(HKEY("message/rfc822"), render_MAIL, 0, 150);
1517 RegisterMimeRenderer(HKEY("text/vnote"), render_MIME_VNote, 1, 300);
1518 RegisterMimeRenderer(HKEY("text/x-vcard"), render_MIME_VCard, 1, 201);
1519 RegisterMimeRenderer(HKEY("text/vcard"), render_MIME_VCard, 1, 200);
1520 RegisterMimeRenderer(HKEY("text/calendar"), render_MIME_ICS, 1, 501);
1521 RegisterMimeRenderer(HKEY("application/ics"), render_MIME_ICS, 1, 500);
1522 RegisterMimeRenderer(HKEY("text/x-citadel-variformat"), render_MAIL_variformat, 1, 2);
1523 RegisterMimeRenderer(HKEY("text/plain"), render_MAIL_text_plain, 1, 3);
1524 RegisterMimeRenderer(HKEY("text"), render_MAIL_text_plain, 1, 1);
1525 RegisterMimeRenderer(HKEY("text/html"), render_MAIL_html, 1, 100);
1526 RegisterMimeRenderer(HKEY(""), render_MAIL_UNKNOWN, 0, 0);
1527 /* and finalize the anouncement to the server... */
1530 /* these headers are citserver replies to MSG4 and friends. one evaluator for each */
1531 RegisterMsgHdr(HKEY("nhdr"), examine_nhdr, 0);
1532 RegisterMsgHdr(HKEY("type"), examine_type, 0);
1533 RegisterMsgHdr(HKEY("from"), examine_from, 0);
1534 RegisterMsgHdr(HKEY("subj"), examine_subj, 0);
1535 RegisterMsgHdr(HKEY("msgn"), examine_msgn, 0);
1536 RegisterMsgHdr(HKEY("wefw"), examine_wefw, 0);
1537 RegisterMsgHdr(HKEY("cccc"), examine_cccc, 0);
1538 RegisterMsgHdr(HKEY("hnod"), examine_hnod, 0);
1539 RegisterMsgHdr(HKEY("room"), examine_room, 0);
1540 RegisterMsgHdr(HKEY("rfca"), examine_rfca, 0);
1541 RegisterMsgHdr(HKEY("node"), examine_node, 0);
1542 RegisterMsgHdr(HKEY("rcpt"), examine_rcpt, 0);
1543 RegisterMsgHdr(HKEY("time"), examine_time, 0);
1544 RegisterMsgHdr(HKEY("part"), examine_mime_part, 0);
1545 RegisterMsgHdr(HKEY("text"), examine_text, 1);
1546 /* these are the content-type headers we get infront of a message; put it into the same hash since it doesn't clash. */
1547 RegisterMsgHdr(HKEY("X-Citadel-MSG4-Partnum"), examine_msg4_partnum, 0);
1548 RegisterMsgHdr(HKEY("Content-type"), examine_content_type, 0);
1549 RegisterMsgHdr(HKEY("Content-length"), examine_content_lengh, 0);
1550 RegisterMsgHdr(HKEY("Content-transfer-encoding"), examine_content_encoding, 0); /* do we care? */
1551 RegisterMsgHdr(HKEY("charset"), examine_charset, 0);
1553 /* Don't care about these... */
1554 RegisterMsgHdr(HKEY("pref"), examine_pref, 0);
1555 RegisterMsgHdr(HKEY("suff"), examine_suff, 0);
1556 RegisterMsgHdr(HKEY("path"), examine_path, 0);
1560 ServerStartModule_MSGRENDERERS
1563 MsgHeaderHandler = NewHash(1, NULL);
1564 MimeRenderHandler = NewHash(1, NULL);
1565 ReadLoopHandler = NewHash(1, NULL);
1569 ServerShutdownModule_MSGRENDERERS
1572 DeleteHash(&MsgHeaderHandler);
1573 DeleteHash(&MimeRenderHandler);
1574 DeleteHash(&ReadLoopHandler);
1580 SessionDestroyModule_MSGRENDERERS
1583 DeleteHash(&sess->attachments);
1584 FreeStrBuf(&sess->ConvertBuf1);
1585 FreeStrBuf(&sess->ConvertBuf2);