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 FreeStrBuf(&Msg->reply_to);
56 DeleteHash(&Msg->Attachments); /**< list of Accachments */
57 DeleteHash(&Msg->Submessages);
58 DeleteHash(&Msg->AttachLinks);
59 DeleteHash(&Msg->AllAttach);
65 void RegisterMsgHdr(const char *HeaderName, long HdrNLen, ExamineMsgHeaderFunc evaluator, int type)
68 ev = (headereval*) malloc(sizeof(headereval));
69 ev->evaluator = evaluator;
71 Put(MsgHeaderHandler, HeaderName, HdrNLen, ev, NULL);
74 void RegisterMimeRenderer(const char *HeaderName, long HdrNLen,
75 RenderMimeFunc MimeRenderer,
79 RenderMimeFuncStruct *f;
81 f = (RenderMimeFuncStruct*) malloc(sizeof(RenderMimeFuncStruct));
83 Put(MimeRenderHandler, HeaderName, HdrNLen, f, NULL);
85 RegisterEmbeddableMimeType(HeaderName, HdrNLen, 10000 - Priority);
88 /*----------------------------------------------------------------------------*/
91 * comparator for two longs in descending order.
93 int longcmp_r(const void *s1, const void *s2) {
97 l1 = *(long *)GetSearchPayload(s1);
98 l2 = *(long *)GetSearchPayload(s2);
100 if (l1 > l2) return(-1);
101 if (l1 < l2) return(+1);
106 * comparator for longs; descending order.
108 int qlongcmp_r(const void *s1, const void *s2) {
112 if (l1 > l2) return(-1);
113 if (l1 < l2) return(+1);
119 * comparator for message summary structs by ascending subject.
121 int summcmp_subj(const void *s1, const void *s2) {
122 message_summary *summ1;
123 message_summary *summ2;
125 summ1 = (message_summary *)GetSearchPayload(s1);
126 summ2 = (message_summary *)GetSearchPayload(s2);
127 return strcasecmp(ChrPtr(summ1->subj), ChrPtr(summ2->subj));
131 * comparator for message summary structs by descending subject.
133 int summcmp_rsubj(const void *s1, const void *s2) {
134 message_summary *summ1;
135 message_summary *summ2;
137 summ1 = (message_summary *)GetSearchPayload(s1);
138 summ2 = (message_summary *)GetSearchPayload(s2);
139 return strcasecmp(ChrPtr(summ2->subj), ChrPtr(summ1->subj));
142 * comparator for message summary structs by descending subject.
144 int groupchange_subj(const void *s1, const void *s2) {
145 message_summary *summ1;
146 message_summary *summ2;
148 summ1 = (message_summary *)s1;
149 summ2 = (message_summary *)s2;
150 return ChrPtr(summ2->subj)[0] != ChrPtr(summ1->subj)[0];
154 * comparator for message summary structs by ascending sender.
156 int summcmp_sender(const void *s1, const void *s2) {
157 message_summary *summ1;
158 message_summary *summ2;
160 summ1 = (message_summary *)GetSearchPayload(s1);
161 summ2 = (message_summary *)GetSearchPayload(s2);
162 return strcasecmp(ChrPtr(summ1->from), ChrPtr(summ2->from));
166 * comparator for message summary structs by descending sender.
168 int summcmp_rsender(const void *s1, const void *s2) {
169 message_summary *summ1;
170 message_summary *summ2;
172 summ1 = (message_summary *)GetSearchPayload(s1);
173 summ2 = (message_summary *)GetSearchPayload(s2);
174 return strcasecmp(ChrPtr(summ2->from), ChrPtr(summ1->from));
177 * comparator for message summary structs by descending sender.
179 int groupchange_sender(const void *s1, const void *s2) {
180 message_summary *summ1;
181 message_summary *summ2;
183 summ1 = (message_summary *)s1;
184 summ2 = (message_summary *)s2;
185 return strcasecmp(ChrPtr(summ2->from), ChrPtr(summ1->from)) != 0;
190 * comparator for message summary structs by ascending date.
192 int summcmp_date(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 int summcmp_rdate(const void *s1, const void *s2) {
208 message_summary *summ1;
209 message_summary *summ2;
211 summ1 = (message_summary *)GetSearchPayload(s1);
212 summ2 = (message_summary *)GetSearchPayload(s2);
214 if (summ1->date < summ2->date) return +1;
215 else if (summ1->date > summ2->date) return -1;
220 * comparator for message summary structs by descending date.
222 const long DAYSECONDS = 24 * 60 * 60;
223 int groupchange_date(const void *s1, const void *s2) {
224 message_summary *summ1;
225 message_summary *summ2;
227 summ1 = (message_summary *)s1;
228 summ2 = (message_summary *)s2;
230 return (summ1->date % DAYSECONDS) != (summ2->date %DAYSECONDS);
234 /*----------------------------------------------------------------------------*/
235 /* Don't wanna know... or? */
236 void examine_pref(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
237 void examine_suff(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
238 void examine_path(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
239 void examine_content_encoding(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
241 /* TODO: do we care? */
244 void examine_nhdr(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
247 if (!strncasecmp(ChrPtr(HdrLine), "yes", 8))
250 int Conditional_ANONYMOUS_MESSAGE(StrBuf *Target, WCTemplputParams *TP)
252 message_summary *Msg = (message_summary*) CTX;
253 return Msg->nhdr != 0;
256 void examine_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
258 Msg->format_type = StrToi(HdrLine);
262 void examine_from(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
266 CheckConvertBufs(WCC);
267 FreeStrBuf(&Msg->from);
268 Msg->from = NewStrBufPlain(NULL, StrLength(HdrLine));
269 StrBuf_RFC822_2_Utf8(Msg->from,
276 void tmplput_MAIL_SUMM_FROM(StrBuf *Target, WCTemplputParams *TP)
278 message_summary *Msg = (message_summary*) CTX;
279 StrBufAppendTemplate(Target, TP, Msg->from, 0);
282 void examine_subj(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
286 CheckConvertBufs(WCC);
287 FreeStrBuf(&Msg->subj);
288 Msg->subj = NewStrBufPlain(NULL, StrLength(HdrLine));
289 StrBuf_RFC822_2_Utf8(Msg->subj,
296 void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
298 message_summary *Msg = (message_summary*) CTX;
300 if (TP->Tokens->nParameters == 4)
305 GetTemplateTokenString(Target, TP, 3, &pch, &len);
307 (strstr(ChrPtr(Msg->subj), pch) == NULL))
309 GetTemplateTokenString(Target, TP, 2, &pch, &len);
310 StrBufAppendBufPlain(Target, pch, len, 0);
313 StrBufAppendTemplate(Target, TP, Msg->subj, 0);
315 int Conditional_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
317 message_summary *Msg = (message_summary*) CTX;
320 return StrLength(Msg->subj) > 0;
324 void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
328 CheckConvertBufs(WCC);
329 FreeStrBuf(&Msg->reply_inreplyto);
330 Msg->reply_inreplyto = NewStrBufPlain(NULL, StrLength(HdrLine));
331 StrBuf_RFC822_2_Utf8(Msg->reply_inreplyto,
338 void tmplput_MAIL_SUMM_INREPLYTO(StrBuf *Target, WCTemplputParams *TP)
340 message_summary *Msg = (message_summary*) CTX;
341 StrBufAppendTemplate(Target, TP, Msg->reply_inreplyto, 0);
344 int Conditional_MAIL_SUMM_UNREAD(StrBuf *Target, WCTemplputParams *TP)
346 message_summary *Msg = (message_summary*) CTX;
347 return (Msg->Flags & MSGFLAG_READ) != 0;
350 void examine_wefw(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
354 CheckConvertBufs(WCC);
355 FreeStrBuf(&Msg->reply_references);
356 Msg->reply_references = NewStrBufPlain(NULL, StrLength(HdrLine));
357 StrBuf_RFC822_2_Utf8(Msg->reply_references,
364 void tmplput_MAIL_SUMM_REFIDS(StrBuf *Target, WCTemplputParams *TP)
366 message_summary *Msg = (message_summary*) CTX;
367 StrBufAppendTemplate(Target, TP, Msg->reply_references, 0);
371 void examine_cccc(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
375 CheckConvertBufs(WCC);
376 FreeStrBuf(&Msg->cccc);
377 Msg->cccc = NewStrBufPlain(NULL, StrLength(HdrLine));
378 StrBuf_RFC822_2_Utf8(Msg->cccc,
384 if (Msg->AllRcpt == NULL)
385 Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
386 if (StrLength(Msg->AllRcpt) > 0) {
387 StrBufAppendBufPlain(Msg->AllRcpt, HKEY(", "), 0);
389 StrBufAppendBuf(Msg->AllRcpt, Msg->cccc, 0);
391 void tmplput_MAIL_SUMM_CCCC(StrBuf *Target, WCTemplputParams *TP)
393 message_summary *Msg = (message_summary*) CTX;
394 StrBufAppendTemplate(Target, TP, Msg->cccc, 0);
398 void examine_room(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
400 if ((StrLength(HdrLine) > 0) &&
401 (strcasecmp(ChrPtr(HdrLine), ChrPtr(WC->CurRoom.name)))) {
402 FreeStrBuf(&Msg->Room);
403 Msg->Room = NewStrBufDup(HdrLine);
406 void tmplput_MAIL_SUMM_ORGROOM(StrBuf *Target, WCTemplputParams *TP)
408 message_summary *Msg = (message_summary*) CTX;
409 StrBufAppendTemplate(Target, TP, Msg->Room, 0);
413 void examine_rfca(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
415 FreeStrBuf(&Msg->Rfca);
416 Msg->Rfca = NewStrBufDup(HdrLine);
418 void tmplput_MAIL_SUMM_RFCA(StrBuf *Target, WCTemplputParams *TP)
420 message_summary *Msg = (message_summary*) CTX;
421 StrBufAppendTemplate(Target, TP, Msg->Rfca, 0);
423 int Conditional_MAIL_SUMM_RFCA(StrBuf *Target, WCTemplputParams *TP)
425 message_summary *Msg = (message_summary*) CTX;
426 return StrLength(Msg->Rfca) > 0;
428 int Conditional_MAIL_SUMM_CCCC(StrBuf *Target, WCTemplputParams *TP)
430 message_summary *Msg = (message_summary*) CTX;
431 return StrLength(Msg->cccc) > 0;
434 void examine_node(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
438 if ( (StrLength(HdrLine) > 0) &&
439 ((WC->CurRoom.QRFlags & QR_NETWORK)
440 || ((strcasecmp(ChrPtr(HdrLine), ChrPtr(WCC->serv_info->serv_nodename))
441 && (strcasecmp(ChrPtr(HdrLine), ChrPtr(WCC->serv_info->serv_fqdn))))))) {
442 FreeStrBuf(&Msg->OtherNode);
443 Msg->OtherNode = NewStrBufDup(HdrLine);
446 void tmplput_MAIL_SUMM_OTHERNODE(StrBuf *Target, WCTemplputParams *TP)
448 message_summary *Msg = (message_summary*) CTX;
449 StrBufAppendTemplate(Target, TP, Msg->OtherNode, 0);
451 int Conditional_MAIL_SUMM_OTHERNODE(StrBuf *Target, WCTemplputParams *TP)
453 message_summary *Msg = (message_summary*) CTX;
454 return StrLength(Msg->OtherNode) > 0;
458 void examine_rcpt(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
462 CheckConvertBufs(WCC);
463 FreeStrBuf(&Msg->to);
464 Msg->to = NewStrBufPlain(NULL, StrLength(HdrLine));
465 StrBuf_RFC822_2_Utf8(Msg->to,
471 if (Msg->AllRcpt == NULL)
472 Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
473 if (StrLength(Msg->AllRcpt) > 0) {
474 StrBufAppendBufPlain(Msg->AllRcpt, HKEY(", "), 0);
476 StrBufAppendBuf(Msg->AllRcpt, Msg->to, 0);
478 void tmplput_MAIL_SUMM_TO(StrBuf *Target, WCTemplputParams *TP)
480 message_summary *Msg = (message_summary*) CTX;
481 StrBufAppendTemplate(Target, TP, Msg->to, 0);
483 int Conditional_MAIL_SUMM_TO(StrBuf *Target, WCTemplputParams *TP)
485 message_summary *Msg = (message_summary*) CTX;
486 return StrLength(Msg->to) != 0;
488 int Conditional_MAIL_SUMM_SUBJ(StrBuf *Target, WCTemplputParams *TP)
490 message_summary *Msg = (message_summary*) CTX;
491 return StrLength(Msg->subj) != 0;
493 void tmplput_MAIL_SUMM_ALLRCPT(StrBuf *Target, WCTemplputParams *TP)
495 message_summary *Msg = (message_summary*) CTX;
496 StrBufAppendTemplate(Target, TP, Msg->AllRcpt, 0);
501 void tmplput_SUMM_COUNT(StrBuf *Target, WCTemplputParams *TP)
503 StrBufAppendPrintf(Target, "%d", GetCount( WC->summ));
506 HashList *iterate_get_mailsumm_All(StrBuf *Target, WCTemplputParams *TP)
510 void examine_time(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
512 Msg->date = StrTol(HdrLine);
515 void tmplput_MAIL_SUMM_DATE_BRIEF(StrBuf *Target, WCTemplputParams *TP)
518 message_summary *Msg = (message_summary*) CTX;
519 webcit_fmt_date(datebuf, 64, Msg->date, DATEFMT_BRIEF);
520 StrBufAppendBufPlain(Target, datebuf, -1, 0);
523 void tmplput_MAIL_SUMM_EUID(StrBuf *Target, WCTemplputParams *TP)
525 message_summary *Msg = (message_summary*) CTX;
526 StrBufAppendTemplate(Target, TP, Msg->euid, 0);
529 void tmplput_MAIL_SUMM_DATE_FULL(StrBuf *Target, WCTemplputParams *TP)
532 message_summary *Msg = (message_summary*) CTX;
533 webcit_fmt_date(datebuf, 64, Msg->date, DATEFMT_FULL);
534 StrBufAppendBufPlain(Target, datebuf, -1, 0);
536 void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, WCTemplputParams *TP)
538 message_summary *Msg = (message_summary*) CTX;
539 StrBufAppendPrintf(Target, "%ld", Msg->date, 0);
544 void render_MAIL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
546 const StrBuf *TemplateMime;
548 if (Mime->Data == NULL)
549 Mime->Data = NewStrBufPlain(NULL, Mime->length);
551 FlushStrBuf(Mime->Data);
552 read_message(Mime->Data, HKEY("view_submessage"), Mime->msgnum, Mime->PartNum, &TemplateMime);
554 if ( (!IsEmptyStr(mime_submessages)) && (!section[0]) ) {
555 for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
556 extract_token(buf, mime_submessages, i, '|', sizeof buf);
557 / ** use printable_view to suppress buttons * /
558 wc_printf("<blockquote>");
559 read_message(Mime->msgnum, 1, ChrPtr(Mime->Section));
560 wc_printf("</blockquote>");
566 void render_MIME_VCard(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
569 if (StrLength(Mime->Data) == 0)
571 if (StrLength(Mime->Data) > 0) {
574 /** If it's my vCard I can edit it */
575 if ( (!strcasecmp(ChrPtr(WCC->CurRoom.name), USERCONFIGROOM))
576 || (!strcasecmp(&(ChrPtr(WCC->CurRoom.name)[11]), USERCONFIGROOM))
577 || (WC->CurRoom.view == VIEW_ADDRESSBOOK)
579 StrBufAppendPrintf(Buf, "<a href=\"edit_vcard?msgnum=%ld?partnum=%s\">",
580 Mime->msgnum, ChrPtr(Mime->PartNum));
581 StrBufAppendPrintf(Buf, "[%s]</a>", _("edit"));
584 /* In all cases, display the full card */
585 display_vcard(Buf, Mime, 0, 1, NULL, -1);
586 FreeStrBuf(&Mime->Data);
592 void render_MIME_VNote(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
594 if (StrLength(Mime->Data) == 0)
596 if (StrLength(Mime->Data) > 0) {
602 vcard = SmashStrBuf(&Mime->Data);
603 v = vnote_new_from_str(vcard);
608 memset(&TP, 0, sizeof(WCTemplputParams));
609 TP.Filter.ContextType = CTX_VNOTE;
611 DoTemplate(HKEY("mail_vnoteitem"),
618 if (Mime->Data == NULL)
619 Mime->Data = NewStrBuf();
621 FlushStrBuf(Mime->Data);
626 void render_MIME_ICS(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
628 if (StrLength(Mime->Data) == 0) {
631 if (StrLength(Mime->Data) > 0) {
632 cal_process_attachment(Mime);
638 void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
640 const char *Ptr = NULL;
641 wc_mime_attachment *Mime;
645 CheckConvertBufs(WCC);
646 Mime = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
647 memset(Mime, 0, sizeof(wc_mime_attachment));
648 Mime->msgnum = Msg->msgnum;
651 Mime->Name = NewStrBuf();
652 StrBufExtract_NextToken(Buf, HdrLine, &Ptr, '|');
653 StrBuf_RFC822_2_Utf8(Mime->Name,
659 StrBufTrim(Mime->Name);
661 StrBufExtract_NextToken(Buf, HdrLine, &Ptr, '|');
662 Mime->FileName = NewStrBuf();
663 StrBuf_RFC822_2_Utf8(Mime->FileName,
669 StrBufTrim(Mime->FileName);
671 Mime->PartNum = NewStrBuf();
672 StrBufExtract_NextToken(Mime->PartNum, HdrLine, &Ptr, '|');
673 StrBufTrim(Mime->PartNum);
674 if (strchr(ChrPtr(Mime->PartNum), '.') != NULL)
679 Mime->Disposition = NewStrBuf();
680 StrBufExtract_NextToken(Mime->Disposition, HdrLine, &Ptr, '|');
682 Mime->ContentType = NewStrBuf();
683 StrBufExtract_NextToken(Mime->ContentType, HdrLine, &Ptr, '|');
684 StrBufTrim(Mime->ContentType);
685 StrBufLowerCase(Mime->ContentType);
686 if (!strcmp(ChrPtr(Mime->ContentType), "application/octet-stream")) {
687 StrBufPlain(Mime->ContentType,
688 GuessMimeByFilename(SKEY(Mime->FileName)), -1);
691 Mime->length = StrBufExtractNext_int(HdrLine, &Ptr, '|');
693 StrBufSkip_NTokenS(HdrLine, &Ptr, '|', 1); /* cbid?? */
695 Mime->Charset = NewStrBuf();
696 StrBufExtract_NextToken(Mime->Charset, HdrLine, &Ptr, '|');
699 if ( (StrLength(Mime->FileName) == 0) && (StrLength(Mime->Name) > 0) ) {
700 StrBufAppendBuf(Mime->FileName, Mime->Name, 0);
703 if (StrLength(Msg->PartNum) > 0) {
705 StrBufPrintf(Buf, "%s.%s", ChrPtr(Msg->PartNum), ChrPtr(Mime->PartNum));
711 if (Msg->AllAttach == NULL)
712 Msg->AllAttach = NewHash(1,NULL);
713 Put(Msg->AllAttach, SKEY(Mime->PartNum), Mime, DestroyMime);
718 void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime)
722 /* just print the root-node */
723 if ((Mime->level >= 1) &&
724 GetHash(MimeRenderHandler, SKEY(Mime->ContentType), &vMimeRenderer) &&
725 vMimeRenderer != NULL)
727 Mime->Renderer = (RenderMimeFuncStruct*) vMimeRenderer;
728 if (Msg->Submessages == NULL)
729 Msg->Submessages = NewHash(1,NULL);
730 Put(Msg->Submessages, SKEY(Mime->PartNum), Mime, reference_free_handler);
732 else if ((Mime->level >= 1) &&
733 (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
734 && (!strncasecmp(ChrPtr(Mime->ContentType), "image/", 6)) ){
735 if (Msg->AttachLinks == NULL)
736 Msg->AttachLinks = NewHash(1,NULL);
737 Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
739 else if ((Mime->level >= 1) &&
740 (StrLength(Mime->ContentType) > 0) &&
741 ( (!strcasecmp(ChrPtr(Mime->Disposition), "attachment"))
742 || (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
743 || (!strcasecmp(ChrPtr(Mime->Disposition), ""))))
745 if (Msg->AttachLinks == NULL)
746 Msg->AttachLinks = NewHash(1,NULL);
747 Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
748 if ((strcasecmp(ChrPtr(Mime->ContentType), "application/octet-stream") == 0) &&
749 (StrLength(Mime->FileName) > 0)) {
750 FlushStrBuf(Mime->ContentType);
751 StrBufAppendBufPlain(Mime->ContentType,
752 GuessMimeByFilename(SKEY(Mime->FileName)),
758 void tmplput_MAIL_SUMM_NATTACH(StrBuf *Target, WCTemplputParams *TP)
760 message_summary *Msg = (message_summary*) CTX;
761 StrBufAppendPrintf(Target, "%ld", GetCount(Msg->Attachments));
765 void examine_hnod(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
769 CheckConvertBufs(WCC);
770 FreeStrBuf(&Msg->hnod);
771 Msg->hnod = NewStrBufPlain(NULL, StrLength(HdrLine));
772 StrBuf_RFC822_2_Utf8(Msg->hnod,
779 void tmplput_MAIL_SUMM_H_NODE(StrBuf *Target, WCTemplputParams *TP)
781 message_summary *Msg = (message_summary*) CTX;
782 StrBufAppendTemplate(Target, TP, Msg->hnod, 0);
784 int Conditional_MAIL_SUMM_H_NODE(StrBuf *Target, WCTemplputParams *TP)
786 message_summary *Msg = (message_summary*) CTX;
787 return StrLength(Msg->hnod) > 0;
792 void examine_text(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
794 if (Msg->MsgBody->Data == NULL)
795 Msg->MsgBody->Data = NewStrBufPlain(NULL, SIZ);
797 FlushStrBuf(Msg->MsgBody->Data);
800 void examine_msg4_partnum(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
802 Msg->MsgBody->PartNum = NewStrBufDup(HdrLine);
803 StrBufTrim(Msg->MsgBody->PartNum);
806 void examine_content_lengh(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
808 Msg->MsgBody->length = StrTol(HdrLine);
809 Msg->MsgBody->size_known = 1;
812 void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
822 Msg->MsgBody->ContentType = NewStrBufDup(HdrLine);
823 sem = strchr(ChrPtr(HdrLine), ';');
826 Token = NewStrBufPlain(NULL, StrLength(HdrLine));
827 Value = NewStrBufPlain(NULL, StrLength(HdrLine));
828 len = sem - ChrPtr(HdrLine);
829 StrBufCutAt(Msg->MsgBody->ContentType, len, NULL);
830 while (sem != NULL) {
831 while (isspace(*(sem + 1)))
833 StrBufCutLeft(HdrLine, sem - ChrPtr(HdrLine));
834 sem = strchr(ChrPtr(HdrLine), ';');
836 len = sem - ChrPtr(HdrLine);
838 len = StrLength(HdrLine);
841 StrBufAppendBufPlain(Token, ChrPtr(HdrLine), len, 0);
842 eq = strchr(ChrPtr(Token), '=');
844 len = eq - ChrPtr(Token);
845 StrBufAppendBufPlain(Value, eq + 1, StrLength(Token) - len - 1, 0);
846 StrBufCutAt(Token, len, NULL);
851 if (GetHash(MsgHeaderHandler, SKEY(Token), &vHdr) &&
853 Hdr = (headereval*)vHdr;
854 Hdr->evaluator(Msg, Value, FoundCharset);
856 else syslog(1, "don't know how to handle content type sub-header[%s]\n", ChrPtr(Token));
863 void tmplput_MAIL_SUMM_N(StrBuf *Target, WCTemplputParams *TP)
865 message_summary *Msg = (message_summary*) CTX;
866 StrBufAppendPrintf(Target, "%ld", Msg->msgnum);
871 int Conditional_MAIL_MIME_ALL(StrBuf *Target, WCTemplputParams *TP)
873 message_summary *Msg = (message_summary*) CTX;
874 return GetCount(Msg->Attachments) > 0;
877 int Conditional_MAIL_MIME_SUBMESSAGES(StrBuf *Target, WCTemplputParams *TP)
879 message_summary *Msg = (message_summary*) CTX;
880 return GetCount(Msg->Submessages) > 0;
883 int Conditional_MAIL_MIME_ATTACHLINKS(StrBuf *Target, WCTemplputParams *TP)
885 message_summary *Msg = (message_summary*) CTX;
886 return GetCount(Msg->AttachLinks) > 0;
889 int Conditional_MAIL_MIME_ATTACH(StrBuf *Target, WCTemplputParams *TP)
891 message_summary *Msg = (message_summary*) CTX;
892 return GetCount(Msg->AllAttach) > 0;
895 void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
901 MsgNum = LBstr(TKEY(0));
903 read_message(Buf, HKEY("view_message_replyquote"), MsgNum, NULL, &Mime);
904 StrBufAppendTemplate(Target, TP, Buf, 1);
908 void tmplput_EDIT_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
914 MsgNum = LBstr(TKEY(0));
916 read_message(Buf, HKEY("view_message_edit"), MsgNum, NULL, &Mime);
917 StrBufAppendTemplate(Target, TP, Buf, 1);
921 void tmplput_EDIT_WIKI_BODY(StrBuf *Target, WCTemplputParams *TP)
927 /* Insert the existing content of the wiki page into the editor. But we only want
928 * to do this the first time -- if the user is uploading an attachment we don't want
931 if (!havebstr("attach_button")) {
932 msgnum = locate_message_by_uid(BSTR("page"));
935 read_message(Buf, HKEY("view_message_wikiedit"), msgnum, NULL, &Mime);
936 StrBufAppendTemplate(Target, TP, Buf, 1);
942 void tmplput_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
944 message_summary *Msg = (message_summary*) CTX;
945 StrBufAppendTemplate(Target, TP, Msg->MsgBody->Data, 0);
949 void render_MAIL_variformat(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
951 /* Messages in legacy Citadel variformat get handled thusly... */
952 StrBuf *Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
953 FmOut(Target, "JUSTIFY", Mime->Data);
954 FreeStrBuf(&Mime->Data);
958 void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
960 const char *ptr, *pte;
961 const char *BufPtr = NULL;
974 iconv_t ic = (iconv_t)(-1) ;
977 if ((StrLength(Mime->Data) == 0) && (Mime->length > 0)) {
978 FreeStrBuf(&Mime->Data);
984 if (StrLength(Mime->Charset) != 0)
986 else if (StrLength(FoundCharset) > 0)
988 else if (StrLength(WC->DefaultCharset) > 0)
989 cs = WC->DefaultCharset;
993 else if (!strcasecmp(ChrPtr(cs), "utf-8")) {
996 else if (!strcasecmp(ChrPtr(cs), "us-ascii")) {
1000 ctdl_iconv_open("UTF-8", ChrPtr(cs), &ic);
1001 if (ic == (iconv_t)(-1) ) {
1002 syslog(5, "%s:%d iconv_open(UTF-8, %s) failed: %s\n",
1003 __FILE__, __LINE__, ChrPtr(Mime->Charset), strerror(errno));
1008 Line = NewStrBufPlain(NULL, SIZ);
1009 Line1 = NewStrBufPlain(NULL, SIZ);
1010 Line2 = NewStrBufPlain(NULL, SIZ);
1011 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) {
1035 StrBufAppendBufPlain(Target, HKEY("<tt></tt><br>\n"), 0);
1039 for (i = bn; i < bq; i++)
1040 StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
1041 for (i = bq; i < bn; i++)
1042 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
1045 StrBufConvert(Line, Line1, &ic);
1048 StrBufAppendBufPlain(Target, HKEY("<tt>"), 0);
1049 UrlizeText(Line1, Line, Line2);
1051 StrEscAppend(Target, Line1, NULL, 0, 0);
1052 StrBufAppendBufPlain(Target, HKEY("</tt><br>\n"), 0);
1055 while ((BufPtr != StrBufNOTNULL) &&
1058 for (i = 0; i < bn; i++)
1059 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
1061 StrBufAppendBufPlain(Target, HKEY("</i><br>"), 0);
1063 if (ic != (iconv_t)(-1) ) {
1068 FreeStrBuf(&Mime->Data);
1069 Mime->Data = Target;
1070 FlushStrBuf(Mime->ContentType);
1071 StrBufAppendBufPlain(Mime->ContentType, HKEY("text/html"), 0);
1072 FlushStrBuf(Mime->Charset);
1073 StrBufAppendBufPlain(Mime->Charset, HKEY("UTF-8"), 0);
1079 void render_MAIL_html(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
1083 if (StrLength(Mime->Data) == 0)
1086 Buf = NewStrBufPlain(NULL, StrLength(Mime->Data));
1088 /* HTML is fun, but we've got to strip it first */
1089 output_html(ChrPtr(Mime->Charset),
1090 (WC->CurRoom.view == VIEW_WIKI ? 1 : 0),
1093 FreeStrBuf(&Mime->Data);
1097 void render_MAIL_UNKNOWN(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
1099 /* Unknown weirdness */
1100 FlushStrBuf(Mime->Data);
1101 StrBufAppendBufPlain(Mime->Data, _("I don't know how to display "), -1, 0);
1102 StrBufAppendBuf(Mime->Data, Mime->ContentType, 0);
1103 StrBufAppendBufPlain(Mime->Data, HKEY("<br>\n"), 0);
1107 HashList *iterate_get_mime_All(StrBuf *Target, WCTemplputParams *TP)
1109 message_summary *Msg = (message_summary*) CTX;
1110 return Msg->Attachments;
1112 HashList *iterate_get_mime_Submessages(StrBuf *Target, WCTemplputParams *TP)
1114 message_summary *Msg = (message_summary*) CTX;
1115 return Msg->Submessages;
1117 HashList *iterate_get_mime_AttachLinks(StrBuf *Target, WCTemplputParams *TP)
1119 message_summary *Msg = (message_summary*) CTX;
1120 return Msg->AttachLinks;
1122 HashList *iterate_get_mime_Attachments(StrBuf *Target, WCTemplputParams *TP)
1124 message_summary *Msg = (message_summary*) CTX;
1125 return Msg->AllAttach;
1128 void tmplput_MIME_Name(StrBuf *Target, WCTemplputParams *TP)
1130 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1131 StrBufAppendTemplate(Target, TP, mime->Name, 0);
1134 void tmplput_MIME_FileName(StrBuf *Target, WCTemplputParams *TP)
1136 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1137 StrBufAppendTemplate(Target, TP, mime->FileName, 0);
1140 void tmplput_MIME_PartNum(StrBuf *Target, WCTemplputParams *TP)
1142 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1143 StrBufAppendTemplate(Target, TP, mime->PartNum, 0);
1146 void tmplput_MIME_MsgNum(StrBuf *Target, WCTemplputParams *TP)
1148 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1149 StrBufAppendPrintf(Target, "%ld", mime->msgnum);
1152 void tmplput_MIME_Disposition(StrBuf *Target, WCTemplputParams *TP)
1154 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1155 StrBufAppendTemplate(Target, TP, mime->Disposition, 0);
1158 void tmplput_MIME_ContentType(StrBuf *Target, WCTemplputParams *TP)
1160 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1161 StrBufAppendTemplate(Target, TP, mime->ContentType, 0);
1164 void examine_charset(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
1166 Msg->MsgBody->Charset = NewStrBufDup(HdrLine);
1169 void tmplput_MIME_Charset(StrBuf *Target, WCTemplputParams *TP)
1171 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1172 StrBufAppendTemplate(Target, TP, mime->Charset, 0);
1175 void tmplput_MIME_Data(StrBuf *Target, WCTemplputParams *TP)
1177 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1178 if (mime->Renderer != NULL)
1179 mime->Renderer->f(mime, NULL, NULL);
1180 StrBufAppendTemplate(Target, TP, mime->Data, 0);
1181 /* TODO: check whether we need to load it now? */
1184 void tmplput_MIME_LoadData(StrBuf *Target, WCTemplputParams *TP)
1186 wcsession *WCC = WC;
1187 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1188 wc_mime_attachment *att;
1190 if (( (!strcasecmp(ChrPtr(mime->Disposition), "inline"))||
1191 (!strcasecmp(ChrPtr(mime->Disposition), "attachment"))) &&
1192 (strcasecmp(ChrPtr(mime->ContentType), "application/ms-tnef")!=0))
1197 /* steal this mime part... */
1198 att = malloc(sizeof(wc_mime_attachment));
1199 memcpy(att, mime, sizeof(wc_mime_attachment));
1200 memset(mime, 0, sizeof(wc_mime_attachment));
1202 if (att->Data == NULL)
1205 if (WCC->attachments == NULL)
1206 WCC->attachments = NewHash(1, NULL);
1207 /* And add it to the list. */
1208 n = snprintf(N, sizeof N, "%d", GetCount(WCC->attachments) + 1);
1209 Put(WCC->attachments, N, n, att, DestroyMime);
1213 void tmplput_MIME_Length(StrBuf *Target, WCTemplputParams *TP)
1215 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1216 StrBufAppendPrintf(Target, "%ld", mime->length);
1219 HashList *iterate_get_registered_Attachments(StrBuf *Target, WCTemplputParams *TP)
1221 return WC->attachments;
1224 void get_registered_Attachments_Count(StrBuf *Target, WCTemplputParams *TP)
1226 StrBufAppendPrintf(Target, "%ld", GetCount (WC->attachments));
1229 void servcmd_do_search(char *buf, long bufsize)
1231 snprintf(buf, bufsize, "MSGS SEARCH|%s", bstr("query"));
1234 void servcmd_headers(char *buf, long bufsize)
1236 snprintf(buf, bufsize, "MSGS ALL");
1239 void servcmd_readfwd(char *buf, long bufsize)
1241 snprintf(buf, bufsize, "MSGS ALL");
1244 void servcmd_readgt(char *buf, long bufsize)
1246 snprintf(buf, bufsize, "MSGS GT|%s", bstr("gt"));
1249 void servcmd_readlt(char *buf, long bufsize)
1251 snprintf(buf, bufsize, "MSGS LT|%s", bstr("lt"));
1254 void servcmd_readnew(char *buf, long bufsize)
1256 snprintf(buf, bufsize, "MSGS NEW");
1259 void servcmd_readold(char *buf, long bufsize)
1261 snprintf(buf, bufsize, "MSGS OLD");
1265 /* DO NOT REORDER OR REMOVE ANY OF THESE */
1266 readloop_struct rlid[] = {
1267 { {HKEY("do_search")}, servcmd_do_search },
1268 { {HKEY("headers")}, servcmd_headers },
1269 { {HKEY("readfwd")}, servcmd_readfwd },
1270 { {HKEY("readnew")}, servcmd_readnew },
1271 { {HKEY("readold")}, servcmd_readold },
1272 { {HKEY("readgt")}, servcmd_readgt },
1273 { {HKEY("readlt")}, servcmd_readlt }
1277 int ParseMessageListHeaders_Detail(StrBuf *Line,
1279 message_summary *Msg,
1280 StrBuf *ConversionBuffer)
1282 wcsession *WCC = WC;
1286 CheckConvertBufs(WCC);
1288 totallen = StrLength(Line);
1289 Msg->from = NewStrBufPlain(NULL, totallen);
1290 len = StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
1292 /* Handle senders with RFC2047 encoding */
1293 StrBuf_RFC822_2_Utf8(Msg->from,
1295 WCC->DefaultCharset,
1302 len = StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
1304 ( ((WCC->CurRoom.QRFlags & QR_NETWORK)
1305 || ((strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_nodename))
1306 && (strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_fqdn))))))))
1308 StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
1309 StrBufAppendBuf(Msg->from, ConversionBuffer, 0);
1312 /* Internet address (not used)
1313 * StrBufExtract_token(Msg->inetaddr, Line, 4, '|');
1315 StrBufSkip_NTokenS(Line, pos, '|', 1);
1316 Msg->subj = NewStrBufPlain(NULL, totallen);
1318 FlushStrBuf(ConversionBuffer);
1319 /* we assume the subject is the last parameter inside of the list;
1320 * thus we don't use the tokenizer to fetch it, since it will hick up
1321 * on tokenizer chars inside of the subjects
1322 StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
1325 if (*pos != StrBufNOTNULL) {
1326 len = totallen - (*pos - ChrPtr(Line));
1327 StrBufPlain(ConversionBuffer, *pos, len);
1328 *pos = StrBufNOTNULL;
1330 (*(ChrPtr(ConversionBuffer) + len - 1) == '|'))
1331 StrBufCutRight(ConversionBuffer, 1);
1335 StrBufAppendBufPlain(Msg->subj, _("(no subject)"), -1,0);
1337 StrBuf_RFC822_2_Utf8(Msg->subj,
1339 WCC->DefaultCharset,
1348 /* Spit out the new summary view. This is basically a static page, so clients can cache the layout, all the dirty work is javascript :) */
1349 void new_summary_view(void) {
1350 DoTemplate(HKEY("msg_listview"),NULL,&NoCtx);
1354 int mailview_GetParamsGetServerCall(SharedMessageStatus *Stat,
1355 void **ViewSpecific,
1364 Stat->defaultsortorder = 2;
1366 Stat->load_seen = 1;
1367 /* Generally using maxmsgs|startmsg is not required
1368 in mailbox view, but we have a 'safemode' for clients
1369 (*cough* Exploder) that simply can't handle too many */
1370 if (havebstr("maxmsgs")) Stat->maxmsgs = ibstr("maxmsgs");
1371 else Stat->maxmsgs = 9999999;
1372 if (havebstr("startmsg")) Stat->startmsg = lbstr("startmsg");
1373 snprintf(cmd, len, "MSGS %s|%s||1",
1374 (oper == do_search) ? "SEARCH" : "ALL",
1375 (oper == do_search) ? bstr("query") : ""
1381 int mailview_RenderView_or_Tail(SharedMessageStatus *Stat,
1382 void **ViewSpecific,
1385 WCTemplputParams SubTP;
1388 DoTemplate(HKEY("mailsummary_json"),NULL, &SubTP);
1393 int mailview_Cleanup(void **ViewSpecific)
1395 /* Note: wDumpContent() will output one additional </div> tag. */
1396 /* We ought to move this out into template */
1408 InitModule_MSGRENDERERS
1411 RegisterReadLoopHandlerset(
1413 mailview_GetParamsGetServerCall,
1414 NULL, /// TODO: is this right?
1415 ParseMessageListHeaders_Detail,
1417 mailview_RenderView_or_Tail,
1420 RegisterSortFunc(HKEY("date"),
1426 RegisterSortFunc(HKEY("subject"),
1432 RegisterSortFunc(HKEY("sender"),
1439 RegisterNamespace("SUMM:COUNT", 0, 0, tmplput_SUMM_COUNT, NULL, CTX_NONE);
1440 /* iterate over all known mails in WC->summ */
1441 RegisterIterator("MAIL:SUMM:MSGS", 0, NULL, iterate_get_mailsumm_All,
1442 NULL,NULL, CTX_MAILSUM, CTX_NONE, IT_NOFLAG);
1444 RegisterNamespace("MAIL:SUMM:EUID", 0, 1, tmplput_MAIL_SUMM_EUID, NULL, CTX_MAILSUM);
1445 RegisterNamespace("MAIL:SUMM:DATEBRIEF", 0, 0, tmplput_MAIL_SUMM_DATE_BRIEF, NULL, CTX_MAILSUM);
1446 RegisterNamespace("MAIL:SUMM:DATEFULL", 0, 0, tmplput_MAIL_SUMM_DATE_FULL, NULL, CTX_MAILSUM);
1447 RegisterNamespace("MAIL:SUMM:DATENO", 0, 0, tmplput_MAIL_SUMM_DATE_NO, NULL, CTX_MAILSUM);
1448 RegisterNamespace("MAIL:SUMM:N", 0, 0, tmplput_MAIL_SUMM_N, NULL, CTX_MAILSUM);
1449 RegisterNamespace("MAIL:SUMM:FROM", 0, 2, tmplput_MAIL_SUMM_FROM, NULL, CTX_MAILSUM);
1450 RegisterNamespace("MAIL:SUMM:TO", 0, 2, tmplput_MAIL_SUMM_TO, NULL, CTX_MAILSUM);
1451 RegisterNamespace("MAIL:SUMM:SUBJECT", 0, 4, tmplput_MAIL_SUMM_SUBJECT, NULL, CTX_MAILSUM);
1452 RegisterNamespace("MAIL:SUMM:NTATACH", 0, 0, tmplput_MAIL_SUMM_NATTACH, NULL, CTX_MAILSUM);
1453 RegisterNamespace("MAIL:SUMM:CCCC", 0, 2, tmplput_MAIL_SUMM_CCCC, NULL, CTX_MAILSUM);
1454 RegisterNamespace("MAIL:SUMM:H_NODE", 0, 2, tmplput_MAIL_SUMM_H_NODE, NULL, CTX_MAILSUM);
1455 RegisterNamespace("MAIL:SUMM:ALLRCPT", 0, 2, tmplput_MAIL_SUMM_ALLRCPT, NULL, CTX_MAILSUM);
1456 RegisterNamespace("MAIL:SUMM:ORGROOM", 0, 2, tmplput_MAIL_SUMM_ORGROOM, NULL, CTX_MAILSUM);
1457 RegisterNamespace("MAIL:SUMM:RFCA", 0, 2, tmplput_MAIL_SUMM_RFCA, NULL, CTX_MAILSUM);
1458 RegisterNamespace("MAIL:SUMM:OTHERNODE", 2, 0, tmplput_MAIL_SUMM_OTHERNODE, NULL, CTX_MAILSUM);
1459 RegisterNamespace("MAIL:SUMM:REFIDS", 0, 1, tmplput_MAIL_SUMM_REFIDS, NULL, CTX_MAILSUM);
1460 RegisterNamespace("MAIL:SUMM:INREPLYTO", 0, 2, tmplput_MAIL_SUMM_INREPLYTO, NULL, CTX_MAILSUM);
1461 RegisterNamespace("MAIL:BODY", 0, 2, tmplput_MAIL_BODY, NULL, CTX_MAILSUM);
1462 RegisterNamespace("MAIL:QUOTETEXT", 1, 2, tmplput_QUOTED_MAIL_BODY, NULL, CTX_NONE);
1463 RegisterNamespace("MAIL:EDITTEXT", 1, 2, tmplput_EDIT_MAIL_BODY, NULL, CTX_NONE);
1464 RegisterNamespace("MAIL:EDITWIKI", 1, 2, tmplput_EDIT_WIKI_BODY, NULL, CTX_NONE);
1465 RegisterConditional(HKEY("COND:MAIL:SUMM:RFCA"), 0, Conditional_MAIL_SUMM_RFCA, CTX_MAILSUM);
1466 RegisterConditional(HKEY("COND:MAIL:SUMM:CCCC"), 0, Conditional_MAIL_SUMM_CCCC, CTX_MAILSUM);
1467 RegisterConditional(HKEY("COND:MAIL:SUMM:UNREAD"), 0, Conditional_MAIL_SUMM_UNREAD, CTX_MAILSUM);
1468 RegisterConditional(HKEY("COND:MAIL:SUMM:H_NODE"), 0, Conditional_MAIL_SUMM_H_NODE, CTX_MAILSUM);
1469 RegisterConditional(HKEY("COND:MAIL:SUMM:OTHERNODE"), 0, Conditional_MAIL_SUMM_OTHERNODE, CTX_MAILSUM);
1470 RegisterConditional(HKEY("COND:MAIL:SUMM:SUBJECT"), 0, Conditional_MAIL_SUMM_SUBJECT, CTX_MAILSUM);
1471 RegisterConditional(HKEY("COND:MAIL:ANON"), 0, Conditional_ANONYMOUS_MESSAGE, CTX_MAILSUM);
1472 RegisterConditional(HKEY("COND:MAIL:TO"), 0, Conditional_MAIL_SUMM_TO, CTX_MAILSUM);
1473 RegisterConditional(HKEY("COND:MAIL:SUBJ"), 0, Conditional_MAIL_SUMM_SUBJ, CTX_MAILSUM);
1475 /* do we have mimetypes to iterate over? */
1476 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH"), 0, Conditional_MAIL_MIME_ALL, CTX_MAILSUM);
1477 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:SUBMESSAGES"), 0, Conditional_MAIL_MIME_SUBMESSAGES, CTX_MAILSUM);
1478 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:LINKS"), 0, Conditional_MAIL_MIME_ATTACHLINKS, CTX_MAILSUM);
1479 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:ATT"), 0, Conditional_MAIL_MIME_ATTACH, CTX_MAILSUM);
1480 RegisterIterator("MAIL:MIME:ATTACH", 0, NULL, iterate_get_mime_All,
1481 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1482 RegisterIterator("MAIL:MIME:ATTACH:SUBMESSAGES", 0, NULL, iterate_get_mime_Submessages,
1483 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1484 RegisterIterator("MAIL:MIME:ATTACH:LINKS", 0, NULL, iterate_get_mime_AttachLinks,
1485 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1486 RegisterIterator("MAIL:MIME:ATTACH:ATT", 0, NULL, iterate_get_mime_Attachments,
1487 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1489 /* Parts of a mime attachent */
1490 RegisterNamespace("MAIL:MIME:NAME", 0, 2, tmplput_MIME_Name, NULL, CTX_MIME_ATACH);
1491 RegisterNamespace("MAIL:MIME:FILENAME", 0, 2, tmplput_MIME_FileName, NULL, CTX_MIME_ATACH);
1492 RegisterNamespace("MAIL:MIME:PARTNUM", 0, 2, tmplput_MIME_PartNum, NULL, CTX_MIME_ATACH);
1493 RegisterNamespace("MAIL:MIME:MSGNUM", 0, 2, tmplput_MIME_MsgNum, NULL, CTX_MIME_ATACH);
1494 RegisterNamespace("MAIL:MIME:DISPOSITION", 0, 2, tmplput_MIME_Disposition, NULL, CTX_MIME_ATACH);
1495 RegisterNamespace("MAIL:MIME:CONTENTTYPE", 0, 2, tmplput_MIME_ContentType, NULL, CTX_MIME_ATACH);
1496 RegisterNamespace("MAIL:MIME:CHARSET", 0, 2, tmplput_MIME_Charset, NULL, CTX_MIME_ATACH);
1497 RegisterNamespace("MAIL:MIME:LENGTH", 0, 2, tmplput_MIME_Length, NULL, CTX_MIME_ATACH);
1498 RegisterNamespace("MAIL:MIME:DATA", 0, 2, tmplput_MIME_Data, NULL, CTX_MIME_ATACH);
1499 /* load the actual attachment into WC->attachments; no output!!! */
1500 RegisterNamespace("MAIL:MIME:LOADDATA", 0, 0, tmplput_MIME_LoadData, NULL, CTX_MIME_ATACH);
1502 /* iterate the WC->attachments; use the above tokens for their contents */
1503 RegisterIterator("MSG:ATTACHNAMES", 0, NULL, iterate_get_registered_Attachments,
1504 NULL, NULL, CTX_MIME_ATACH, CTX_NONE, IT_NOFLAG);
1506 RegisterNamespace("MSG:NATTACH", 0, 0, get_registered_Attachments_Count, NULL, CTX_NONE);
1508 /* mime renderers translate an attachment into webcit viewable html text */
1509 RegisterMimeRenderer(HKEY("message/rfc822"), render_MAIL, 0, 150);
1510 RegisterMimeRenderer(HKEY("text/vnote"), render_MIME_VNote, 1, 300);
1511 RegisterMimeRenderer(HKEY("text/x-vcard"), render_MIME_VCard, 1, 201);
1512 RegisterMimeRenderer(HKEY("text/vcard"), render_MIME_VCard, 1, 200);
1513 RegisterMimeRenderer(HKEY("text/calendar"), render_MIME_ICS, 1, 501);
1514 RegisterMimeRenderer(HKEY("application/ics"), render_MIME_ICS, 1, 500);
1515 RegisterMimeRenderer(HKEY("text/x-citadel-variformat"), render_MAIL_variformat, 1, 2);
1516 RegisterMimeRenderer(HKEY("text/plain"), render_MAIL_text_plain, 1, 3);
1517 RegisterMimeRenderer(HKEY("text"), render_MAIL_text_plain, 1, 1);
1518 RegisterMimeRenderer(HKEY("text/html"), render_MAIL_html, 1, 100);
1519 RegisterMimeRenderer(HKEY(""), render_MAIL_UNKNOWN, 0, 0);
1520 /* and finalize the anouncement to the server... */
1523 /* these headers are citserver replies to MSG4 and friends. one evaluator for each */
1524 RegisterMsgHdr(HKEY("nhdr"), examine_nhdr, 0);
1525 RegisterMsgHdr(HKEY("type"), examine_type, 0);
1526 RegisterMsgHdr(HKEY("from"), examine_from, 0);
1527 RegisterMsgHdr(HKEY("subj"), examine_subj, 0);
1528 RegisterMsgHdr(HKEY("msgn"), examine_msgn, 0);
1529 RegisterMsgHdr(HKEY("wefw"), examine_wefw, 0);
1530 RegisterMsgHdr(HKEY("cccc"), examine_cccc, 0);
1531 RegisterMsgHdr(HKEY("hnod"), examine_hnod, 0);
1532 RegisterMsgHdr(HKEY("room"), examine_room, 0);
1533 RegisterMsgHdr(HKEY("rfca"), examine_rfca, 0);
1534 RegisterMsgHdr(HKEY("node"), examine_node, 0);
1535 RegisterMsgHdr(HKEY("rcpt"), examine_rcpt, 0);
1536 RegisterMsgHdr(HKEY("time"), examine_time, 0);
1537 RegisterMsgHdr(HKEY("part"), examine_mime_part, 0);
1538 RegisterMsgHdr(HKEY("text"), examine_text, 1);
1539 /* these are the content-type headers we get infront of a message; put it into the same hash since it doesn't clash. */
1540 RegisterMsgHdr(HKEY("X-Citadel-MSG4-Partnum"), examine_msg4_partnum, 0);
1541 RegisterMsgHdr(HKEY("Content-type"), examine_content_type, 0);
1542 RegisterMsgHdr(HKEY("Content-length"), examine_content_lengh, 0);
1543 RegisterMsgHdr(HKEY("Content-transfer-encoding"), examine_content_encoding, 0); /* do we care? */
1544 RegisterMsgHdr(HKEY("charset"), examine_charset, 0);
1546 /* Don't care about these... */
1547 RegisterMsgHdr(HKEY("pref"), examine_pref, 0);
1548 RegisterMsgHdr(HKEY("suff"), examine_suff, 0);
1549 RegisterMsgHdr(HKEY("path"), examine_path, 0);
1553 ServerStartModule_MSGRENDERERS
1556 MsgHeaderHandler = NewHash(1, NULL);
1557 MimeRenderHandler = NewHash(1, NULL);
1558 ReadLoopHandler = NewHash(1, NULL);
1562 ServerShutdownModule_MSGRENDERERS
1565 DeleteHash(&MsgHeaderHandler);
1566 DeleteHash(&MimeRenderHandler);
1567 DeleteHash(&ReadLoopHandler);
1573 SessionDestroyModule_MSGRENDERERS
1576 DeleteHash(&sess->attachments);
1577 FreeStrBuf(&sess->ConvertBuf1);
1578 FreeStrBuf(&sess->ConvertBuf2);