6 * message index functions
10 void DestroyMimeParts(wc_mime_attachment *Mime)
12 FreeStrBuf(&Mime->Name);
13 FreeStrBuf(&Mime->FileName);
14 FreeStrBuf(&Mime->PartNum);
15 FreeStrBuf(&Mime->Disposition);
16 FreeStrBuf(&Mime->ContentType);
17 FreeStrBuf(&Mime->Charset);
18 FreeStrBuf(&Mime->Data);
21 void DestroyMime(void *vMime)
23 wc_mime_attachment *Mime = (wc_mime_attachment*)vMime;
24 DestroyMimeParts(Mime);
28 void DestroyMessageSummary(void *vMsg)
30 message_summary *Msg = (message_summary*) vMsg;
32 FreeStrBuf(&Msg->from);
34 FreeStrBuf(&Msg->subj);
35 FreeStrBuf(&Msg->reply_inreplyto);
36 FreeStrBuf(&Msg->reply_references);
37 FreeStrBuf(&Msg->cccc);
38 FreeStrBuf(&Msg->hnod);
39 FreeStrBuf(&Msg->AllRcpt);
40 FreeStrBuf(&Msg->Room);
41 FreeStrBuf(&Msg->Rfca);
42 FreeStrBuf(&Msg->OtherNode);
44 FreeStrBuf(&Msg->reply_to);
46 DeleteHash(&Msg->Attachments); /**< list of Accachments */
47 DeleteHash(&Msg->Submessages);
48 DeleteHash(&Msg->AttachLinks);
49 DeleteHash(&Msg->AllAttach);
55 void RegisterMsgHdr(const char *HeaderName, long HdrNLen, ExamineMsgHeaderFunc evaluator, int type)
58 ev = (headereval*) malloc(sizeof(headereval));
59 ev->evaluator = evaluator;
61 Put(MsgHeaderHandler, HeaderName, HdrNLen, ev, NULL);
64 void RegisterMimeRenderer(const char *HeaderName, long HdrNLen,
65 RenderMimeFunc MimeRenderer,
69 RenderMimeFuncStruct *f;
71 f = (RenderMimeFuncStruct*) malloc(sizeof(RenderMimeFuncStruct));
73 Put(MimeRenderHandler, HeaderName, HdrNLen, f, NULL);
75 RegisterEmbeddableMimeType(HeaderName, HdrNLen, 10000 - Priority);
78 /*----------------------------------------------------------------------------*/
81 * comparator for two longs in descending order.
83 int longcmp_r(const void *s1, const void *s2) {
87 l1 = *(long *)GetSearchPayload(s1);
88 l2 = *(long *)GetSearchPayload(s2);
90 if (l1 > l2) return(-1);
91 if (l1 < l2) return(+1);
96 * comparator for longs; descending order.
98 int qlongcmp_r(const void *s1, const void *s2) {
102 if (l1 > l2) return(-1);
103 if (l1 < l2) return(+1);
109 * comparator for message summary structs by ascending subject.
111 int summcmp_subj(const void *s1, const void *s2) {
112 message_summary *summ1;
113 message_summary *summ2;
115 summ1 = (message_summary *)GetSearchPayload(s1);
116 summ2 = (message_summary *)GetSearchPayload(s2);
117 return strcasecmp(ChrPtr(summ1->subj), ChrPtr(summ2->subj));
121 * comparator for message summary structs by descending subject.
123 int summcmp_rsubj(const void *s1, const void *s2) {
124 message_summary *summ1;
125 message_summary *summ2;
127 summ1 = (message_summary *)GetSearchPayload(s1);
128 summ2 = (message_summary *)GetSearchPayload(s2);
129 return strcasecmp(ChrPtr(summ2->subj), ChrPtr(summ1->subj));
132 * comparator for message summary structs by descending subject.
134 int groupchange_subj(const void *s1, const void *s2) {
135 message_summary *summ1;
136 message_summary *summ2;
138 summ1 = (message_summary *)s1;
139 summ2 = (message_summary *)s2;
140 return ChrPtr(summ2->subj)[0] != ChrPtr(summ1->subj)[0];
144 * comparator for message summary structs by ascending sender.
146 int summcmp_sender(const void *s1, const void *s2) {
147 message_summary *summ1;
148 message_summary *summ2;
150 summ1 = (message_summary *)GetSearchPayload(s1);
151 summ2 = (message_summary *)GetSearchPayload(s2);
152 return strcasecmp(ChrPtr(summ1->from), ChrPtr(summ2->from));
156 * comparator for message summary structs by descending sender.
158 int summcmp_rsender(const void *s1, const void *s2) {
159 message_summary *summ1;
160 message_summary *summ2;
162 summ1 = (message_summary *)GetSearchPayload(s1);
163 summ2 = (message_summary *)GetSearchPayload(s2);
164 return strcasecmp(ChrPtr(summ2->from), ChrPtr(summ1->from));
167 * comparator for message summary structs by descending sender.
169 int groupchange_sender(const void *s1, const void *s2) {
170 message_summary *summ1;
171 message_summary *summ2;
173 summ1 = (message_summary *)s1;
174 summ2 = (message_summary *)s2;
175 return strcasecmp(ChrPtr(summ2->from), ChrPtr(summ1->from)) != 0;
180 * comparator for message summary structs by ascending date.
182 int summcmp_date(const void *s1, const void *s2) {
183 message_summary *summ1;
184 message_summary *summ2;
186 summ1 = (message_summary *)GetSearchPayload(s1);
187 summ2 = (message_summary *)GetSearchPayload(s2);
189 if (summ1->date < summ2->date) return -1;
190 else if (summ1->date > summ2->date) return +1;
195 * comparator for message summary structs by descending date.
197 int summcmp_rdate(const void *s1, const void *s2) {
198 message_summary *summ1;
199 message_summary *summ2;
201 summ1 = (message_summary *)GetSearchPayload(s1);
202 summ2 = (message_summary *)GetSearchPayload(s2);
204 if (summ1->date < summ2->date) return +1;
205 else if (summ1->date > summ2->date) return -1;
210 * comparator for message summary structs by descending date.
212 const long DAYSECONDS = 24 * 60 * 60;
213 int groupchange_date(const void *s1, const void *s2) {
214 message_summary *summ1;
215 message_summary *summ2;
217 summ1 = (message_summary *)s1;
218 summ2 = (message_summary *)s2;
220 return (summ1->date % DAYSECONDS) != (summ2->date %DAYSECONDS);
224 /*----------------------------------------------------------------------------*/
225 /* Don't wanna know... or? */
226 void examine_pref(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
227 void examine_suff(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
228 void examine_path(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
229 void examine_content_encoding(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
231 /* TODO: do we care? */
234 void examine_nhdr(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
237 if (!strncasecmp(ChrPtr(HdrLine), "yes", 8))
240 int Conditional_ANONYMOUS_MESSAGE(StrBuf *Target, WCTemplputParams *TP)
242 message_summary *Msg = (message_summary*) CTX;
243 return Msg->nhdr != 0;
246 void examine_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
248 Msg->format_type = StrToi(HdrLine);
252 void examine_from(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
254 FreeStrBuf(&Msg->from);
255 Msg->from = NewStrBufPlain(NULL, StrLength(HdrLine));
256 StrBuf_RFC822_to_Utf8(Msg->from, HdrLine, WC->DefaultCharset, FoundCharset);
258 void tmplput_MAIL_SUMM_FROM(StrBuf *Target, WCTemplputParams *TP)
260 message_summary *Msg = (message_summary*) CTX;
261 StrBufAppendTemplate(Target, TP, Msg->from, 0);
266 void examine_subj(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
268 FreeStrBuf(&Msg->subj);
269 Msg->subj = NewStrBufPlain(NULL, StrLength(HdrLine));
270 StrBuf_RFC822_to_Utf8(Msg->subj, HdrLine, WC->DefaultCharset, FoundCharset);
272 void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
273 {/*////TODO: Fwd: and RE: filter!!*/
275 message_summary *Msg = (message_summary*) CTX;
276 StrBufAppendTemplate(Target, TP, Msg->subj, 0);
278 int Conditional_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
280 message_summary *Msg = (message_summary*) CTX;
281 return StrLength(Msg->subj) > 0;
285 void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
287 FreeStrBuf(&Msg->reply_inreplyto);
288 Msg->reply_inreplyto = NewStrBufPlain(NULL, StrLength(HdrLine));
289 StrBuf_RFC822_to_Utf8(Msg->reply_inreplyto, HdrLine, WC->DefaultCharset, FoundCharset);
291 void tmplput_MAIL_SUMM_INREPLYTO(StrBuf *Target, WCTemplputParams *TP)
293 message_summary *Msg = (message_summary*) CTX;
294 StrBufAppendTemplate(Target, TP, Msg->reply_inreplyto, 0);
297 int Conditional_MAIL_SUMM_UNREAD(StrBuf *Target, WCTemplputParams *TP)
299 message_summary *Msg = (message_summary*) CTX;
300 return Msg->is_new != 0;
303 void examine_wefw(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
305 FreeStrBuf(&Msg->reply_references);
306 Msg->reply_references = NewStrBufPlain(NULL, StrLength(HdrLine));
307 StrBuf_RFC822_to_Utf8(Msg->reply_references, HdrLine, WC->DefaultCharset, FoundCharset);
309 void tmplput_MAIL_SUMM_REFIDS(StrBuf *Target, WCTemplputParams *TP)
311 message_summary *Msg = (message_summary*) CTX;
312 StrBufAppendTemplate(Target, TP, Msg->reply_references, 0);
316 void examine_cccc(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
318 FreeStrBuf(&Msg->cccc);
319 Msg->cccc = NewStrBufPlain(NULL, StrLength(HdrLine));
320 StrBuf_RFC822_to_Utf8(Msg->cccc, HdrLine, WC->DefaultCharset, FoundCharset);
321 if (Msg->AllRcpt == NULL)
322 Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
323 if (StrLength(Msg->AllRcpt) > 0) {
324 StrBufAppendBufPlain(Msg->AllRcpt, HKEY(", "), 0);
326 StrBufAppendBuf(Msg->AllRcpt, Msg->cccc, 0);
328 void tmplput_MAIL_SUMM_CCCC(StrBuf *Target, WCTemplputParams *TP)
330 message_summary *Msg = (message_summary*) CTX;
331 StrBufAppendTemplate(Target, TP, Msg->cccc, 0);
335 void examine_room(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
337 if ((StrLength(HdrLine) > 0) &&
338 (strcasecmp(ChrPtr(HdrLine), ChrPtr(WC->CurRoom.name)))) {
339 FreeStrBuf(&Msg->Room);
340 Msg->Room = NewStrBufDup(HdrLine);
343 void tmplput_MAIL_SUMM_ORGROOM(StrBuf *Target, WCTemplputParams *TP)
345 message_summary *Msg = (message_summary*) CTX;
346 StrBufAppendTemplate(Target, TP, Msg->Room, 0);
350 void examine_rfca(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
352 FreeStrBuf(&Msg->Rfca);
353 Msg->Rfca = NewStrBufDup(HdrLine);
355 void tmplput_MAIL_SUMM_RFCA(StrBuf *Target, WCTemplputParams *TP)
357 message_summary *Msg = (message_summary*) CTX;
358 StrBufAppendTemplate(Target, TP, Msg->Rfca, 0);
360 int Conditional_MAIL_SUMM_RFCA(StrBuf *Target, WCTemplputParams *TP)
362 message_summary *Msg = (message_summary*) CTX;
363 return StrLength(Msg->Rfca) > 0;
365 int Conditional_MAIL_SUMM_CCCC(StrBuf *Target, WCTemplputParams *TP)
367 message_summary *Msg = (message_summary*) CTX;
368 return StrLength(Msg->cccc) > 0;
371 void examine_node(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
375 if ( (StrLength(HdrLine) > 0) &&
376 ((WC->CurRoom.QRFlags & QR_NETWORK)
377 || ((strcasecmp(ChrPtr(HdrLine), ChrPtr(WCC->serv_info->serv_nodename))
378 && (strcasecmp(ChrPtr(HdrLine), ChrPtr(WCC->serv_info->serv_fqdn))))))) {
379 FreeStrBuf(&Msg->OtherNode);
380 Msg->OtherNode = NewStrBufDup(HdrLine);
383 void tmplput_MAIL_SUMM_OTHERNODE(StrBuf *Target, WCTemplputParams *TP)
385 message_summary *Msg = (message_summary*) CTX;
386 StrBufAppendTemplate(Target, TP, Msg->OtherNode, 0);
388 int Conditional_MAIL_SUMM_OTHERNODE(StrBuf *Target, WCTemplputParams *TP)
390 message_summary *Msg = (message_summary*) CTX;
391 return StrLength(Msg->OtherNode) > 0;
395 void examine_rcpt(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
397 FreeStrBuf(&Msg->to);
398 Msg->to = NewStrBufPlain(NULL, StrLength(HdrLine));
399 StrBuf_RFC822_to_Utf8(Msg->to, HdrLine, WC->DefaultCharset, FoundCharset);
400 if (Msg->AllRcpt == NULL)
401 Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
402 if (StrLength(Msg->AllRcpt) > 0) {
403 StrBufAppendBufPlain(Msg->AllRcpt, HKEY(", "), 0);
405 StrBufAppendBuf(Msg->AllRcpt, Msg->to, 0);
407 void tmplput_MAIL_SUMM_TO(StrBuf *Target, WCTemplputParams *TP)
409 message_summary *Msg = (message_summary*) CTX;
410 StrBufAppendTemplate(Target, TP, Msg->to, 0);
412 int Conditional_MAIL_SUMM_TO(StrBuf *Target, WCTemplputParams *TP)
414 message_summary *Msg = (message_summary*) CTX;
415 return StrLength(Msg->to) != 0;
417 int Conditional_MAIL_SUMM_SUBJ(StrBuf *Target, WCTemplputParams *TP)
419 message_summary *Msg = (message_summary*) CTX;
420 return StrLength(Msg->subj) != 0;
422 void tmplput_MAIL_SUMM_ALLRCPT(StrBuf *Target, WCTemplputParams *TP)
424 message_summary *Msg = (message_summary*) CTX;
425 StrBufAppendTemplate(Target, TP, Msg->AllRcpt, 0);
430 void tmplput_SUMM_COUNT(StrBuf *Target, WCTemplputParams *TP)
432 StrBufAppendPrintf(Target, "%d", GetCount( WC->summ));
435 HashList *iterate_get_mailsumm_All(StrBuf *Target, WCTemplputParams *TP)
439 void examine_time(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
441 Msg->date = StrTol(HdrLine);
444 void tmplput_MAIL_SUMM_DATE_BRIEF(StrBuf *Target, WCTemplputParams *TP)
447 message_summary *Msg = (message_summary*) CTX;
448 webcit_fmt_date(datebuf, 64, Msg->date, DATEFMT_BRIEF);
449 StrBufAppendBufPlain(Target, datebuf, -1, 0);
452 void tmplput_MAIL_SUMM_EUID(StrBuf *Target, WCTemplputParams *TP)
454 message_summary *Msg = (message_summary*) CTX;
455 StrBufAppendTemplate(Target, TP, Msg->euid, 0);
458 void tmplput_MAIL_SUMM_DATE_FULL(StrBuf *Target, WCTemplputParams *TP)
461 message_summary *Msg = (message_summary*) CTX;
462 webcit_fmt_date(datebuf, 64, Msg->date, DATEFMT_FULL);
463 StrBufAppendBufPlain(Target, datebuf, -1, 0);
465 void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, WCTemplputParams *TP)
467 message_summary *Msg = (message_summary*) CTX;
468 StrBufAppendPrintf(Target, "%ld", Msg->date, 0);
473 void render_MAIL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
475 const StrBuf *TemplateMime;
477 if (Mime->Data == NULL)
478 Mime->Data = NewStrBufPlain(NULL, Mime->length);
480 FlushStrBuf(Mime->Data);
481 read_message(Mime->Data, HKEY("view_submessage"), Mime->msgnum, Mime->PartNum, &TemplateMime);
483 if ( (!IsEmptyStr(mime_submessages)) && (!section[0]) ) {
484 for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
485 extract_token(buf, mime_submessages, i, '|', sizeof buf);
486 / ** use printable_view to suppress buttons * /
487 wc_printf("<blockquote>");
488 read_message(Mime->msgnum, 1, ChrPtr(Mime->Section));
489 wc_printf("</blockquote>");
495 void render_MIME_VCard(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
498 if (StrLength(Mime->Data) == 0)
500 if (StrLength(Mime->Data) > 0) {
503 /** If it's my vCard I can edit it */
504 if ( (!strcasecmp(ChrPtr(WCC->CurRoom.name), USERCONFIGROOM))
505 || (!strcasecmp(&(ChrPtr(WCC->CurRoom.name)[11]), USERCONFIGROOM))
506 || (WC->CurRoom.view == VIEW_ADDRESSBOOK)
508 StrBufAppendPrintf(Buf, "<a href=\"edit_vcard?msgnum=%ld?partnum=%s\">",
509 Mime->msgnum, ChrPtr(Mime->PartNum));
510 StrBufAppendPrintf(Buf, "[%s]</a>", _("edit"));
513 /* In all cases, display the full card */
514 display_vcard(Buf, Mime, 0, 1, NULL, -1);
515 FreeStrBuf(&Mime->Data);
521 void render_MIME_VNote(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
523 if (StrLength(Mime->Data) == 0)
525 if (StrLength(Mime->Data) > 0) {
531 vcard = SmashStrBuf(&Mime->Data);
532 v = vnote_new_from_str(vcard);
537 memset(&TP, 0, sizeof(WCTemplputParams));
538 TP.Filter.ContextType = CTX_VNOTE;
540 DoTemplate(HKEY("mail_vnoteitem"),
547 if (Mime->Data == NULL)
548 Mime->Data = NewStrBuf();
550 FlushStrBuf(Mime->Data);
555 void render_MIME_ICS(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
557 if (StrLength(Mime->Data) == 0) {
560 if (StrLength(Mime->Data) > 0) {
561 cal_process_attachment(Mime);
567 void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
569 const char *Ptr = NULL;
570 wc_mime_attachment *Mime;
573 Mime = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
574 memset(Mime, 0, sizeof(wc_mime_attachment));
575 Mime->msgnum = Msg->msgnum;
578 Mime->Name = NewStrBuf();
579 StrBufExtract_NextToken(Buf, HdrLine, &Ptr, '|');
580 StrBuf_RFC822_to_Utf8(Mime->Name, Buf, WC->DefaultCharset, FoundCharset);
581 StrBufTrim(Mime->Name);
583 StrBufExtract_NextToken(Buf, HdrLine, &Ptr, '|');
584 Mime->FileName = NewStrBuf();
585 StrBuf_RFC822_to_Utf8(Mime->FileName, Buf, WC->DefaultCharset, FoundCharset);
586 StrBufTrim(Mime->FileName);
588 Mime->PartNum = NewStrBuf();
589 StrBufExtract_NextToken(Mime->PartNum, HdrLine, &Ptr, '|');
590 StrBufTrim(Mime->PartNum);
591 if (strchr(ChrPtr(Mime->PartNum), '.') != NULL)
596 Mime->Disposition = NewStrBuf();
597 StrBufExtract_NextToken(Mime->Disposition, HdrLine, &Ptr, '|');
599 Mime->ContentType = NewStrBuf();
600 StrBufExtract_NextToken(Mime->ContentType, HdrLine, &Ptr, '|');
601 StrBufTrim(Mime->ContentType);
602 StrBufLowerCase(Mime->ContentType);
603 if (!strcmp(ChrPtr(Mime->ContentType), "application/octet-stream")) {
604 StrBufPlain(Mime->ContentType,
605 GuessMimeByFilename(SKEY(Mime->FileName)), -1);
608 Mime->length = StrBufExtractNext_int(HdrLine, &Ptr, '|');
610 StrBufSkip_NTokenS(HdrLine, &Ptr, '|', 1); /* cbid?? */
612 Mime->Charset = NewStrBuf();
613 StrBufExtract_NextToken(Mime->Charset, HdrLine, &Ptr, '|');
616 if ( (StrLength(Mime->FileName) == 0) && (StrLength(Mime->Name) > 0) ) {
617 StrBufAppendBuf(Mime->FileName, Mime->Name, 0);
620 if (StrLength(Msg->PartNum) > 0) {
622 StrBufPrintf(Buf, "%s.%s", ChrPtr(Msg->PartNum), ChrPtr(Mime->PartNum));
628 if (Msg->AllAttach == NULL)
629 Msg->AllAttach = NewHash(1,NULL);
630 Put(Msg->AllAttach, SKEY(Mime->PartNum), Mime, DestroyMime);
635 void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime)
639 /* just print the root-node */
640 if ((Mime->level == 1) &&
641 GetHash(MimeRenderHandler, SKEY(Mime->ContentType), &vMimeRenderer) &&
642 vMimeRenderer != NULL)
644 Mime->Renderer = (RenderMimeFuncStruct*) vMimeRenderer;
645 if (Msg->Submessages == NULL)
646 Msg->Submessages = NewHash(1,NULL);
647 Put(Msg->Submessages, SKEY(Mime->PartNum), Mime, reference_free_handler);
649 else if ((Mime->level == 1) &&
650 (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
651 && (!strncasecmp(ChrPtr(Mime->ContentType), "image/", 6)) ){
652 if (Msg->AttachLinks == NULL)
653 Msg->AttachLinks = NewHash(1,NULL);
654 Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
656 else if ((Mime->level == 1) &&
657 (StrLength(Mime->ContentType) > 0) &&
658 ( (!strcasecmp(ChrPtr(Mime->Disposition), "attachment"))
659 || (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
660 || (!strcasecmp(ChrPtr(Mime->Disposition), ""))))
662 if (Msg->AttachLinks == NULL)
663 Msg->AttachLinks = NewHash(1,NULL);
664 Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
665 if ((strcasecmp(ChrPtr(Mime->ContentType), "application/octet-stream") == 0) &&
666 (StrLength(Mime->FileName) > 0)) {
667 FlushStrBuf(Mime->ContentType);
668 StrBufAppendBufPlain(Mime->ContentType,
669 GuessMimeByFilename(SKEY(Mime->FileName)),
675 void tmplput_MAIL_SUMM_NATTACH(StrBuf *Target, WCTemplputParams *TP)
677 message_summary *Msg = (message_summary*) CTX;
678 StrBufAppendPrintf(Target, "%ld", GetCount(Msg->Attachments));
682 void examine_hnod(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
684 FreeStrBuf(&Msg->hnod);
685 Msg->hnod = NewStrBufPlain(NULL, StrLength(HdrLine));
686 StrBuf_RFC822_to_Utf8(Msg->hnod, HdrLine, WC->DefaultCharset, FoundCharset);
688 void tmplput_MAIL_SUMM_H_NODE(StrBuf *Target, WCTemplputParams *TP)
690 message_summary *Msg = (message_summary*) CTX;
691 StrBufAppendTemplate(Target, TP, Msg->hnod, 0);
693 int Conditional_MAIL_SUMM_H_NODE(StrBuf *Target, WCTemplputParams *TP)
695 message_summary *Msg = (message_summary*) CTX;
696 return StrLength(Msg->hnod) > 0;
701 void examine_text(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
703 if (Msg->MsgBody->Data == NULL)
704 Msg->MsgBody->Data = NewStrBufPlain(NULL, SIZ);
706 FlushStrBuf(Msg->MsgBody->Data);
709 void examine_msg4_partnum(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
711 Msg->MsgBody->PartNum = NewStrBufDup(HdrLine);
712 StrBufTrim(Msg->MsgBody->PartNum);
715 void examine_content_lengh(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
717 Msg->MsgBody->length = StrTol(HdrLine);
718 Msg->MsgBody->size_known = 1;
721 void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
731 Msg->MsgBody->ContentType = NewStrBufDup(HdrLine);
732 sem = strchr(ChrPtr(HdrLine), ';');
735 Token = NewStrBufPlain(NULL, StrLength(HdrLine));
736 Value = NewStrBufPlain(NULL, StrLength(HdrLine));
737 len = sem - ChrPtr(HdrLine);
738 StrBufCutAt(Msg->MsgBody->ContentType, len, NULL);
739 while (sem != NULL) {
740 while (isspace(*(sem + 1)))
742 StrBufCutLeft(HdrLine, sem - ChrPtr(HdrLine));
743 sem = strchr(ChrPtr(HdrLine), ';');
745 len = sem - ChrPtr(HdrLine);
747 len = StrLength(HdrLine);
750 StrBufAppendBufPlain(Token, ChrPtr(HdrLine), len, 0);
751 eq = strchr(ChrPtr(Token), '=');
753 len = eq - ChrPtr(Token);
754 StrBufAppendBufPlain(Value, eq + 1, StrLength(Token) - len - 1, 0);
755 StrBufCutAt(Token, len, NULL);
760 if (GetHash(MsgHeaderHandler, SKEY(Token), &vHdr) &&
762 Hdr = (headereval*)vHdr;
763 Hdr->evaluator(Msg, Value, FoundCharset);
765 else lprintf(1, "don't know how to handle content type sub-header[%s]\n", ChrPtr(Token));
772 void tmplput_MAIL_SUMM_N(StrBuf *Target, WCTemplputParams *TP)
774 message_summary *Msg = (message_summary*) CTX;
775 StrBufAppendPrintf(Target, "%ld", Msg->msgnum);
780 int Conditional_MAIL_MIME_ALL(StrBuf *Target, WCTemplputParams *TP)
782 message_summary *Msg = (message_summary*) CTX;
783 return GetCount(Msg->Attachments) > 0;
786 int Conditional_MAIL_MIME_SUBMESSAGES(StrBuf *Target, WCTemplputParams *TP)
788 message_summary *Msg = (message_summary*) CTX;
789 return GetCount(Msg->Submessages) > 0;
792 int Conditional_MAIL_MIME_ATTACHLINKS(StrBuf *Target, WCTemplputParams *TP)
794 message_summary *Msg = (message_summary*) CTX;
795 return GetCount(Msg->AttachLinks) > 0;
798 int Conditional_MAIL_MIME_ATTACH(StrBuf *Target, WCTemplputParams *TP)
800 message_summary *Msg = (message_summary*) CTX;
801 return GetCount(Msg->AllAttach) > 0;
804 void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
810 MsgNum = LBstr(TKEY(0));
812 read_message(Buf, HKEY("view_message_replyquote"), MsgNum, NULL, &Mime);
813 StrBufAppendTemplate(Target, TP, Buf, 1);
817 void tmplput_EDIT_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
823 MsgNum = LBstr(TKEY(0));
825 read_message(Buf, HKEY("view_message_edit"), MsgNum, NULL, &Mime);
826 StrBufAppendTemplate(Target, TP, Buf, 1);
830 void tmplput_EDIT_WIKI_BODY(StrBuf *Target, WCTemplputParams *TP)
836 /* Insert the existing content of the wiki page into the editor. But we only want
837 * to do this the first time -- if the user is uploading an attachment we don't want
840 if (!havebstr("attach_button")) {
841 msgnum = locate_message_by_uid(BSTR("page"));
844 read_message(Buf, HKEY("view_message_wikiedit"), msgnum, NULL, &Mime);
845 StrBufAppendTemplate(Target, TP, Buf, 1);
851 void tmplput_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
853 message_summary *Msg = (message_summary*) CTX;
854 StrBufAppendTemplate(Target, TP, Msg->MsgBody->Data, 0);
858 void render_MAIL_variformat(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
860 /* Messages in legacy Citadel variformat get handled thusly... */
861 StrBuf *Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
862 FmOut(Target, "JUSTIFY", Mime->Data);
863 FreeStrBuf(&Mime->Data);
867 void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
869 const char *ptr, *pte;
870 const char *BufPtr = NULL;
883 iconv_t ic = (iconv_t)(-1) ;
886 if ((StrLength(Mime->Data) == 0) && (Mime->length > 0)) {
887 FreeStrBuf(&Mime->Data);
893 if (StrLength(Mime->Charset) != 0)
895 else if (StrLength(FoundCharset) > 0)
897 else if (StrLength(WC->DefaultCharset) > 0)
898 cs = WC->DefaultCharset;
902 else if (!strcasecmp(ChrPtr(cs), "utf-8")) {
905 else if (!strcasecmp(ChrPtr(cs), "us-ascii")) {
909 ctdl_iconv_open("UTF-8", ChrPtr(cs), &ic);
910 if (ic == (iconv_t)(-1) ) {
911 lprintf(5, "%s:%d iconv_open(UTF-8, %s) failed: %s\n",
912 __FILE__, __LINE__, ChrPtr(Mime->Charset), strerror(errno));
917 Line = NewStrBufPlain(NULL, SIZ);
918 Line1 = NewStrBufPlain(NULL, SIZ);
919 Line2 = NewStrBufPlain(NULL, SIZ);
920 Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
922 if (StrLength(Mime->Data) > 0)
925 StrBufSipLine(Line, Mime->Data, &BufPtr);
929 len = StrLength(Line);
932 while ((ptr < pte) &&
941 if (i > 0) StrBufCutLeft(Line, i);
943 if (StrLength(Line) == 0) {
944 StrBufAppendBufPlain(Target, HKEY("<tt></tt><br />\n"), 0);
948 for (i = bn; i < bq; i++)
949 StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
950 for (i = bq; i < bn; i++)
951 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
954 StrBufConvert(Line, Line1, &ic);
957 StrBufAppendBufPlain(Target, HKEY("<tt>"), 0);
958 UrlizeText(Line1, Line, Line2);
960 StrEscAppend(Target, Line1, NULL, 0, 0);
961 StrBufAppendBufPlain(Target, HKEY("</tt><br />\n"), 0);
964 while ((BufPtr != StrBufNOTNULL) &&
967 for (i = 0; i < bn; i++)
968 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
970 StrBufAppendBufPlain(Target, HKEY("</i><br />"), 0);
972 if (ic != (iconv_t)(-1) ) {
977 FreeStrBuf(&Mime->Data);
979 FlushStrBuf(Mime->ContentType);
980 StrBufAppendBufPlain(Mime->ContentType, HKEY("text/html"), 0);
981 FlushStrBuf(Mime->Charset);
982 StrBufAppendBufPlain(Mime->Charset, HKEY("UTF-8"), 0);
988 void render_MAIL_html(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
992 if (StrLength(Mime->Data) == 0)
995 Buf = NewStrBufPlain(NULL, StrLength(Mime->Data));
997 /* HTML is fun, but we've got to strip it first */
998 output_html(ChrPtr(Mime->Charset),
999 (WC->CurRoom.view == VIEW_WIKI ? 1 : 0),
1002 FreeStrBuf(&Mime->Data);
1006 void render_MAIL_UNKNOWN(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
1008 /* Unknown weirdness */
1009 FlushStrBuf(Mime->Data);
1010 StrBufAppendBufPlain(Mime->Data, _("I don't know how to display "), -1, 0);
1011 StrBufAppendBuf(Mime->Data, Mime->ContentType, 0);
1012 StrBufAppendBufPlain(Mime->Data, HKEY("<br />\n"), 0);
1016 HashList *iterate_get_mime_All(StrBuf *Target, WCTemplputParams *TP)
1018 message_summary *Msg = (message_summary*) CTX;
1019 return Msg->Attachments;
1021 HashList *iterate_get_mime_Submessages(StrBuf *Target, WCTemplputParams *TP)
1023 message_summary *Msg = (message_summary*) CTX;
1024 return Msg->Submessages;
1026 HashList *iterate_get_mime_AttachLinks(StrBuf *Target, WCTemplputParams *TP)
1028 message_summary *Msg = (message_summary*) CTX;
1029 return Msg->AttachLinks;
1031 HashList *iterate_get_mime_Attachments(StrBuf *Target, WCTemplputParams *TP)
1033 message_summary *Msg = (message_summary*) CTX;
1034 return Msg->AllAttach;
1037 void tmplput_MIME_Name(StrBuf *Target, WCTemplputParams *TP)
1039 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1040 StrBufAppendTemplate(Target, TP, mime->Name, 0);
1043 void tmplput_MIME_FileName(StrBuf *Target, WCTemplputParams *TP)
1045 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1046 StrBufAppendTemplate(Target, TP, mime->FileName, 0);
1049 void tmplput_MIME_PartNum(StrBuf *Target, WCTemplputParams *TP)
1051 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1052 StrBufAppendTemplate(Target, TP, mime->PartNum, 0);
1055 void tmplput_MIME_MsgNum(StrBuf *Target, WCTemplputParams *TP)
1057 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1058 StrBufAppendPrintf(Target, "%ld", mime->msgnum);
1061 void tmplput_MIME_Disposition(StrBuf *Target, WCTemplputParams *TP)
1063 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1064 StrBufAppendTemplate(Target, TP, mime->Disposition, 0);
1067 void tmplput_MIME_ContentType(StrBuf *Target, WCTemplputParams *TP)
1069 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1070 StrBufAppendTemplate(Target, TP, mime->ContentType, 0);
1073 void examine_charset(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
1075 Msg->MsgBody->Charset = NewStrBufDup(HdrLine);
1078 void tmplput_MIME_Charset(StrBuf *Target, WCTemplputParams *TP)
1080 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1081 StrBufAppendTemplate(Target, TP, mime->Charset, 0);
1084 void tmplput_MIME_Data(StrBuf *Target, WCTemplputParams *TP)
1086 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1087 if (mime->Renderer != NULL)
1088 mime->Renderer->f(mime, NULL, NULL);
1089 StrBufAppendTemplate(Target, TP, mime->Data, 0);
1090 /* TODO: check whether we need to load it now? */
1093 void tmplput_MIME_LoadData(StrBuf *Target, WCTemplputParams *TP)
1095 wcsession *WCC = WC;
1096 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1097 wc_mime_attachment *att;
1099 if (( (!strcasecmp(ChrPtr(mime->Disposition), "inline"))||
1100 (!strcasecmp(ChrPtr(mime->Disposition), "attachment"))) &&
1101 (strcasecmp(ChrPtr(mime->ContentType), "application/ms-tnef")!=0))
1106 /* steal this mime part... */
1107 att = malloc(sizeof(wc_mime_attachment));
1108 memcpy(att, mime, sizeof(wc_mime_attachment));
1109 memset(mime, 0, sizeof(wc_mime_attachment));
1111 if (att->Data == NULL)
1114 if (WCC->attachments == NULL)
1115 WCC->attachments = NewHash(1, NULL);
1116 /* And add it to the list. */
1117 n = snprintf(N, sizeof N, "%d", GetCount(WCC->attachments) + 1);
1118 Put(WCC->attachments, N, n, att, DestroyMime);
1122 void tmplput_MIME_Length(StrBuf *Target, WCTemplputParams *TP)
1124 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1125 StrBufAppendPrintf(Target, "%ld", mime->length);
1128 HashList *iterate_get_registered_Attachments(StrBuf *Target, WCTemplputParams *TP)
1130 return WC->attachments;
1133 void servcmd_do_search(char *buf, long bufsize)
1135 snprintf(buf, bufsize, "MSGS SEARCH|%s", bstr("query"));
1138 void servcmd_headers(char *buf, long bufsize)
1140 snprintf(buf, bufsize, "MSGS ALL");
1143 void servcmd_readfwd(char *buf, long bufsize)
1145 snprintf(buf, bufsize, "MSGS ALL");
1148 void servcmd_readgt(char *buf, long bufsize)
1150 snprintf(buf, bufsize, "MSGS GT|%s", bstr("gt"));
1153 void servcmd_readlt(char *buf, long bufsize)
1155 snprintf(buf, bufsize, "MSGS LT|%s", bstr("lt"));
1158 void servcmd_readnew(char *buf, long bufsize)
1160 snprintf(buf, bufsize, "MSGS NEW");
1163 void servcmd_readold(char *buf, long bufsize)
1165 snprintf(buf, bufsize, "MSGS OLD");
1169 /* DO NOT REORDER OR REMOVE ANY OF THESE */
1170 readloop_struct rlid[] = {
1171 { {HKEY("do_search")}, servcmd_do_search },
1172 { {HKEY("headers")}, servcmd_headers },
1173 { {HKEY("readfwd")}, servcmd_readfwd },
1174 { {HKEY("readnew")}, servcmd_readnew },
1175 { {HKEY("readold")}, servcmd_readold },
1176 { {HKEY("readgt")}, servcmd_readgt },
1177 { {HKEY("readlt")}, servcmd_readlt }
1181 int ParseMessageListHeaders_Detail(StrBuf *Line,
1183 message_summary *Msg,
1184 StrBuf *ConversionBuffer)
1186 wcsession *WCC = WC;
1188 Msg->from = NewStrBufPlain(NULL, StrLength(Line));
1189 StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
1190 if (StrLength(ConversionBuffer) != 0) {
1191 /* Handle senders with RFC2047 encoding */
1192 StrBuf_RFC822_to_Utf8(Msg->from, ConversionBuffer, WCC->DefaultCharset, NULL);
1196 StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
1197 if ((StrLength(ConversionBuffer) !=0 ) &&
1198 ( ((WCC->CurRoom.QRFlags & QR_NETWORK)
1199 || ((strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_nodename))
1200 && (strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_fqdn))))))))
1202 StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
1203 StrBufAppendBuf(Msg->from, ConversionBuffer, 0);
1206 /* Internet address (not used)
1207 * StrBufExtract_token(Msg->inetaddr, Line, 4, '|');
1209 StrBufSkip_NTokenS(Line, pos, '|', 1);
1210 Msg->subj = NewStrBufPlain(NULL, StrLength(Line));
1212 FlushStrBuf(ConversionBuffer);
1213 /* we assume the subject is the last parameter inside of the list;
1214 * thus we don't use the tokenizer to fetch it, since it will hick up
1215 * on tokenizer chars inside of the subjects
1216 StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
1218 if (*pos != StrBufNOTNULL) {
1219 StrBufPlain(ConversionBuffer, *pos,
1220 StrLength(Line) - (*pos - ChrPtr(Line)));
1221 *pos = StrBufNOTNULL;
1222 if ((StrLength(ConversionBuffer) > 0) &&
1223 (*(ChrPtr(ConversionBuffer) +
1224 StrLength(ConversionBuffer) - 1) == '|'))
1225 StrBufCutRight(ConversionBuffer, 1);
1228 if (StrLength(ConversionBuffer) == 0)
1229 StrBufAppendBufPlain(Msg->subj, _("(no subject)"), -1,0);
1231 StrBuf_RFC822_to_Utf8(Msg->subj, ConversionBuffer, WCC->DefaultCharset, NULL);
1232 if ((StrLength(Msg->subj) > 75) &&
1233 (StrBuf_Utf8StrLen(Msg->subj) > 75)) {
1234 StrBuf_Utf8StrCut(Msg->subj, 72);
1235 StrBufAppendBufPlain(Msg->subj, HKEY("..."), 0);
1239 if ((StrLength(Msg->from) > 25) &&
1240 (StrBuf_Utf8StrLen(Msg->from) > 25)) {
1241 StrBuf_Utf8StrCut(Msg->from, 23);
1242 StrBufAppendBufPlain(Msg->from, HKEY("..."), 0);
1247 /* Spit out the new summary view. This is basically a static page, so clients can cache the layout, all the dirty work is javascript :) */
1248 void new_summary_view(void) {
1249 DoTemplate(HKEY("msg_listview"),NULL,&NoCtx);
1253 int mailview_GetParamsGetServerCall(SharedMessageStatus *Stat,
1254 void **ViewSpecific,
1263 Stat->defaultsortorder = 2;
1265 Stat->load_seen = 1;
1266 /* Generally using maxmsgs|startmsg is not required
1267 in mailbox view, but we have a 'safemode' for clients
1268 (*cough* Exploder) that simply can't handle too many */
1269 if (havebstr("maxmsgs")) Stat->maxmsgs = ibstr("maxmsgs");
1270 else Stat->maxmsgs = 9999999;
1271 if (havebstr("startmsg")) Stat->startmsg = lbstr("startmsg");
1272 snprintf(cmd, len, "MSGS %s|%s||1",
1273 (oper == do_search) ? "SEARCH" : "ALL",
1274 (oper == do_search) ? bstr("query") : ""
1280 int mailview_RenderView_or_Tail(SharedMessageStatus *Stat,
1281 void **ViewSpecific,
1284 WCTemplputParams SubTP;
1287 DoTemplate(HKEY("mailsummary_json"),NULL, &SubTP);
1292 int mailview_Cleanup(void **ViewSpecific)
1294 /* Note: wDumpContent() will output one additional </div> tag. */
1295 /* We ought to move this out into template */
1307 InitModule_MSGRENDERERS
1310 RegisterReadLoopHandlerset(
1312 mailview_GetParamsGetServerCall,
1313 NULL, /// TODO: is this right?
1314 ParseMessageListHeaders_Detail,
1316 mailview_RenderView_or_Tail,
1319 RegisterSortFunc(HKEY("date"),
1325 RegisterSortFunc(HKEY("subject"),
1331 RegisterSortFunc(HKEY("sender"),
1338 RegisterNamespace("SUMM:COUNT", 0, 0, tmplput_SUMM_COUNT, NULL, CTX_NONE);
1339 /* iterate over all known mails in WC->summ */
1340 RegisterIterator("MAIL:SUMM:MSGS", 0, NULL, iterate_get_mailsumm_All,
1341 NULL,NULL, CTX_MAILSUM, CTX_NONE, IT_NOFLAG);
1343 RegisterNamespace("MAIL:SUMM:EUID", 0, 1, tmplput_MAIL_SUMM_EUID, NULL, CTX_MAILSUM);
1344 RegisterNamespace("MAIL:SUMM:DATEBRIEF", 0, 0, tmplput_MAIL_SUMM_DATE_BRIEF, NULL, CTX_MAILSUM);
1345 RegisterNamespace("MAIL:SUMM:DATEFULL", 0, 0, tmplput_MAIL_SUMM_DATE_FULL, NULL, CTX_MAILSUM);
1346 RegisterNamespace("MAIL:SUMM:DATENO", 0, 0, tmplput_MAIL_SUMM_DATE_NO, NULL, CTX_MAILSUM);
1347 RegisterNamespace("MAIL:SUMM:N", 0, 0, tmplput_MAIL_SUMM_N, NULL, CTX_MAILSUM);
1348 RegisterNamespace("MAIL:SUMM:FROM", 0, 2, tmplput_MAIL_SUMM_FROM, NULL, CTX_MAILSUM);
1349 RegisterNamespace("MAIL:SUMM:TO", 0, 2, tmplput_MAIL_SUMM_TO, NULL, CTX_MAILSUM);
1350 RegisterNamespace("MAIL:SUMM:SUBJECT", 0, 4, tmplput_MAIL_SUMM_SUBJECT, NULL, CTX_MAILSUM);
1351 RegisterNamespace("MAIL:SUMM:NTATACH", 0, 0, tmplput_MAIL_SUMM_NATTACH, NULL, CTX_MAILSUM);
1352 RegisterNamespace("MAIL:SUMM:CCCC", 0, 2, tmplput_MAIL_SUMM_CCCC, NULL, CTX_MAILSUM);
1353 RegisterNamespace("MAIL:SUMM:H_NODE", 0, 2, tmplput_MAIL_SUMM_H_NODE, NULL, CTX_MAILSUM);
1354 RegisterNamespace("MAIL:SUMM:ALLRCPT", 0, 2, tmplput_MAIL_SUMM_ALLRCPT, NULL, CTX_MAILSUM);
1355 RegisterNamespace("MAIL:SUMM:ORGROOM", 0, 2, tmplput_MAIL_SUMM_ORGROOM, NULL, CTX_MAILSUM);
1356 RegisterNamespace("MAIL:SUMM:RFCA", 0, 2, tmplput_MAIL_SUMM_RFCA, NULL, CTX_MAILSUM);
1357 RegisterNamespace("MAIL:SUMM:OTHERNODE", 2, 0, tmplput_MAIL_SUMM_OTHERNODE, NULL, CTX_MAILSUM);
1358 RegisterNamespace("MAIL:SUMM:REFIDS", 0, 1, tmplput_MAIL_SUMM_REFIDS, NULL, CTX_MAILSUM);
1359 RegisterNamespace("MAIL:SUMM:INREPLYTO", 0, 2, tmplput_MAIL_SUMM_INREPLYTO, NULL, CTX_MAILSUM);
1360 RegisterNamespace("MAIL:BODY", 0, 2, tmplput_MAIL_BODY, NULL, CTX_MAILSUM);
1361 RegisterNamespace("MAIL:QUOTETEXT", 1, 2, tmplput_QUOTED_MAIL_BODY, NULL, CTX_NONE);
1362 RegisterNamespace("MAIL:EDITTEXT", 1, 2, tmplput_EDIT_MAIL_BODY, NULL, CTX_NONE);
1363 RegisterNamespace("MAIL:EDITWIKI", 1, 2, tmplput_EDIT_WIKI_BODY, NULL, CTX_NONE);
1364 RegisterConditional(HKEY("COND:MAIL:SUMM:RFCA"), 0, Conditional_MAIL_SUMM_RFCA, CTX_MAILSUM);
1365 RegisterConditional(HKEY("COND:MAIL:SUMM:CCCC"), 0, Conditional_MAIL_SUMM_CCCC, CTX_MAILSUM);
1366 RegisterConditional(HKEY("COND:MAIL:SUMM:UNREAD"), 0, Conditional_MAIL_SUMM_UNREAD, CTX_MAILSUM);
1367 RegisterConditional(HKEY("COND:MAIL:SUMM:H_NODE"), 0, Conditional_MAIL_SUMM_H_NODE, CTX_MAILSUM);
1368 RegisterConditional(HKEY("COND:MAIL:SUMM:OTHERNODE"), 0, Conditional_MAIL_SUMM_OTHERNODE, CTX_MAILSUM);
1369 RegisterConditional(HKEY("COND:MAIL:SUMM:SUBJECT"), 0, Conditional_MAIL_SUMM_SUBJECT, CTX_MAILSUM);
1370 RegisterConditional(HKEY("COND:MAIL:ANON"), 0, Conditional_ANONYMOUS_MESSAGE, CTX_MAILSUM);
1371 RegisterConditional(HKEY("COND:MAIL:TO"), 0, Conditional_MAIL_SUMM_TO, CTX_MAILSUM);
1372 RegisterConditional(HKEY("COND:MAIL:SUBJ"), 0, Conditional_MAIL_SUMM_SUBJ, CTX_MAILSUM);
1374 /* do we have mimetypes to iterate over? */
1375 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH"), 0, Conditional_MAIL_MIME_ALL, CTX_MAILSUM);
1376 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:SUBMESSAGES"), 0, Conditional_MAIL_MIME_SUBMESSAGES, CTX_MAILSUM);
1377 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:LINKS"), 0, Conditional_MAIL_MIME_ATTACHLINKS, CTX_MAILSUM);
1378 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:ATT"), 0, Conditional_MAIL_MIME_ATTACH, CTX_MAILSUM);
1379 RegisterIterator("MAIL:MIME:ATTACH", 0, NULL, iterate_get_mime_All,
1380 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1381 RegisterIterator("MAIL:MIME:ATTACH:SUBMESSAGES", 0, NULL, iterate_get_mime_Submessages,
1382 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1383 RegisterIterator("MAIL:MIME:ATTACH:LINKS", 0, NULL, iterate_get_mime_AttachLinks,
1384 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1385 RegisterIterator("MAIL:MIME:ATTACH:ATT", 0, NULL, iterate_get_mime_Attachments,
1386 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1388 /* Parts of a mime attachent */
1389 RegisterNamespace("MAIL:MIME:NAME", 0, 2, tmplput_MIME_Name, NULL, CTX_MIME_ATACH);
1390 RegisterNamespace("MAIL:MIME:FILENAME", 0, 2, tmplput_MIME_FileName, NULL, CTX_MIME_ATACH);
1391 RegisterNamespace("MAIL:MIME:PARTNUM", 0, 2, tmplput_MIME_PartNum, NULL, CTX_MIME_ATACH);
1392 RegisterNamespace("MAIL:MIME:MSGNUM", 0, 2, tmplput_MIME_MsgNum, NULL, CTX_MIME_ATACH);
1393 RegisterNamespace("MAIL:MIME:DISPOSITION", 0, 2, tmplput_MIME_Disposition, NULL, CTX_MIME_ATACH);
1394 RegisterNamespace("MAIL:MIME:CONTENTTYPE", 0, 2, tmplput_MIME_ContentType, NULL, CTX_MIME_ATACH);
1395 RegisterNamespace("MAIL:MIME:CHARSET", 0, 2, tmplput_MIME_Charset, NULL, CTX_MIME_ATACH);
1396 RegisterNamespace("MAIL:MIME:LENGTH", 0, 2, tmplput_MIME_Length, NULL, CTX_MIME_ATACH);
1397 RegisterNamespace("MAIL:MIME:DATA", 0, 2, tmplput_MIME_Data, NULL, CTX_MIME_ATACH);
1398 /* load the actual attachment into WC->attachments; no output!!! */
1399 RegisterNamespace("MAIL:MIME:LOADDATA", 0, 0, tmplput_MIME_LoadData, NULL, CTX_MIME_ATACH);
1401 /* iterate the WC->attachments; use the above tokens for their contents */
1402 RegisterIterator("MSG:ATTACHNAMES", 0, NULL, iterate_get_registered_Attachments,
1403 NULL, NULL, CTX_MIME_ATACH, CTX_NONE, IT_NOFLAG);
1405 /* mime renderers translate an attachment into webcit viewable html text */
1406 RegisterMimeRenderer(HKEY("message/rfc822"), render_MAIL, 1, 150);
1407 RegisterMimeRenderer(HKEY("text/vnote"), render_MIME_VNote, 1, 300);
1408 RegisterMimeRenderer(HKEY("text/x-vcard"), render_MIME_VCard, 1, 201);
1409 RegisterMimeRenderer(HKEY("text/vcard"), render_MIME_VCard, 1, 200);
1410 RegisterMimeRenderer(HKEY("text/calendar"), render_MIME_ICS, 1, 501);
1411 RegisterMimeRenderer(HKEY("application/ics"), render_MIME_ICS, 1, 500);
1412 RegisterMimeRenderer(HKEY("text/x-citadel-variformat"), render_MAIL_variformat, 1, 2);
1413 RegisterMimeRenderer(HKEY("text/plain"), render_MAIL_text_plain, 1, 3);
1414 RegisterMimeRenderer(HKEY("text"), render_MAIL_text_plain, 1, 1);
1415 RegisterMimeRenderer(HKEY("text/html"), render_MAIL_html, 1, 100);
1416 RegisterMimeRenderer(HKEY(""), render_MAIL_UNKNOWN, 0, 0);
1417 /* and finalize the anouncement to the server... */
1420 /* these headers are citserver replies to MSG4 and friends. one evaluator for each */
1421 RegisterMsgHdr(HKEY("nhdr"), examine_nhdr, 0);
1422 RegisterMsgHdr(HKEY("type"), examine_type, 0);
1423 RegisterMsgHdr(HKEY("from"), examine_from, 0);
1424 RegisterMsgHdr(HKEY("subj"), examine_subj, 0);
1425 RegisterMsgHdr(HKEY("msgn"), examine_msgn, 0);
1426 RegisterMsgHdr(HKEY("wefw"), examine_wefw, 0);
1427 RegisterMsgHdr(HKEY("cccc"), examine_cccc, 0);
1428 RegisterMsgHdr(HKEY("hnod"), examine_hnod, 0);
1429 RegisterMsgHdr(HKEY("room"), examine_room, 0);
1430 RegisterMsgHdr(HKEY("rfca"), examine_rfca, 0);
1431 RegisterMsgHdr(HKEY("node"), examine_node, 0);
1432 RegisterMsgHdr(HKEY("rcpt"), examine_rcpt, 0);
1433 RegisterMsgHdr(HKEY("time"), examine_time, 0);
1434 RegisterMsgHdr(HKEY("part"), examine_mime_part, 0);
1435 RegisterMsgHdr(HKEY("text"), examine_text, 1);
1436 /* these are the content-type headers we get infront of a message; put it into the same hash since it doesn't clash. */
1437 RegisterMsgHdr(HKEY("X-Citadel-MSG4-Partnum"), examine_msg4_partnum, 0);
1438 RegisterMsgHdr(HKEY("Content-type"), examine_content_type, 0);
1439 RegisterMsgHdr(HKEY("Content-length"), examine_content_lengh, 0);
1440 RegisterMsgHdr(HKEY("Content-transfer-encoding"), examine_content_encoding, 0); /* do we care? */
1441 RegisterMsgHdr(HKEY("charset"), examine_charset, 0);
1443 /* Don't care about these... */
1444 RegisterMsgHdr(HKEY("pref"), examine_pref, 0);
1445 RegisterMsgHdr(HKEY("suff"), examine_suff, 0);
1446 RegisterMsgHdr(HKEY("path"), examine_path, 0);
1450 ServerStartModule_MSGRENDERERS
1453 MsgHeaderHandler = NewHash(1, NULL);
1454 MimeRenderHandler = NewHash(1, NULL);
1455 ReadLoopHandler = NewHash(1, NULL);
1459 ServerShutdownModule_MSGRENDERERS
1462 DeleteHash(&MsgHeaderHandler);
1463 DeleteHash(&MimeRenderHandler);
1464 DeleteHash(&ReadLoopHandler);
1470 SessionDestroyModule_MSGRENDERERS
1473 DeleteHash(&sess->attachments);