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)
499 if (StrLength(Mime->Data) > 0) {
502 /** If it's my vCard I can edit it */
503 if ( (!strcasecmp(ChrPtr(WCC->CurRoom.name), USERCONFIGROOM))
504 || (!strcasecmp(&(ChrPtr(WCC->CurRoom.name)[11]), USERCONFIGROOM))
505 || (WC->CurRoom.view == VIEW_ADDRESSBOOK)
507 StrBufAppendPrintf(Buf, "<a href=\"edit_vcard?msgnum=%ld?partnum=%s\">",
508 Mime->msgnum, ChrPtr(Mime->PartNum));
509 StrBufAppendPrintf(Buf, "[%s]</a>", _("edit"));
512 /* In all cases, display the full card */
513 display_vcard(Buf, Mime->Data, 0, 1, NULL, Mime->msgnum);
514 FreeStrBuf(&Mime->Data);
520 void render_MIME_VNote(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
523 if (StrLength(Mime->Data) > 0) {
529 vcard = SmashStrBuf(&Mime->Data);
530 v = vnote_new_from_str(vcard);
535 memset(&TP, 0, sizeof(WCTemplputParams));
536 TP.Filter.ContextType = CTX_VNOTE;
538 DoTemplate(HKEY("mail_vnoteitem"),
545 if (Mime->Data == NULL)
546 Mime->Data = NewStrBuf();
548 FlushStrBuf(Mime->Data);
553 void render_MIME_ICS(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
555 if (StrLength(Mime->Data) == 0) {
558 if (StrLength(Mime->Data) > 0) {
559 cal_process_attachment(Mime);
565 void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
567 wc_mime_attachment *Mime;
570 Mime = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
571 memset(Mime, 0, sizeof(wc_mime_attachment));
572 Mime->msgnum = Msg->msgnum;
575 Mime->Name = NewStrBuf();
576 StrBufExtract_token(Buf, HdrLine, 0, '|');
577 StrBuf_RFC822_to_Utf8(Mime->Name, Buf, WC->DefaultCharset, FoundCharset);
578 StrBufTrim(Mime->Name);
580 StrBufExtract_token(Buf, HdrLine, 1, '|');
581 Mime->FileName = NewStrBuf();
582 StrBuf_RFC822_to_Utf8(Mime->FileName, Buf, WC->DefaultCharset, FoundCharset);
583 StrBufTrim(Mime->FileName);
585 Mime->PartNum = NewStrBuf();
586 StrBufExtract_token(Mime->PartNum, HdrLine, 2, '|');
587 StrBufTrim(Mime->PartNum);
588 if (strchr(ChrPtr(Mime->PartNum), '.') != NULL)
593 Mime->Disposition = NewStrBuf();
594 StrBufExtract_token(Mime->Disposition, HdrLine, 3, '|');
596 Mime->ContentType = NewStrBuf();
597 StrBufExtract_token(Mime->ContentType, HdrLine, 4, '|');
598 StrBufTrim(Mime->ContentType);
599 StrBufLowerCase(Mime->ContentType);
601 if (!strcmp(ChrPtr(Mime->ContentType), "application/octet-stream")) {
602 StrBufPlain(Mime->ContentType,
603 GuessMimeByFilename(SKEY(Mime->FileName)), -1);
605 Mime->length = StrBufExtract_int(HdrLine, 5, '|');
607 if ( (StrLength(Mime->FileName) == 0) && (StrLength(Mime->Name) > 0) ) {
608 StrBufAppendBuf(Mime->FileName, Mime->Name, 0);
611 if (StrLength(Msg->PartNum) > 0) {
613 StrBufPrintf(Buf, "%s.%s", ChrPtr(Msg->PartNum), ChrPtr(Mime->PartNum));
619 if (Msg->AllAttach == NULL)
620 Msg->AllAttach = NewHash(1,NULL);
621 Put(Msg->AllAttach, SKEY(Mime->PartNum), Mime, DestroyMime);
626 void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime)
630 /* just print the root-node */
631 if ((Mime->level == 1) &&
632 GetHash(MimeRenderHandler, SKEY(Mime->ContentType), &vMimeRenderer) &&
633 vMimeRenderer != NULL)
635 Mime->Renderer = (RenderMimeFuncStruct*) vMimeRenderer;
636 if (Msg->Submessages == NULL)
637 Msg->Submessages = NewHash(1,NULL);
638 Put(Msg->Submessages, SKEY(Mime->PartNum), Mime, reference_free_handler);
640 else if ((Mime->level == 1) &&
641 (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
642 && (!strncasecmp(ChrPtr(Mime->ContentType), "image/", 6)) ){
643 if (Msg->AttachLinks == NULL)
644 Msg->AttachLinks = NewHash(1,NULL);
645 Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
647 else if ((Mime->level == 1) &&
648 (StrLength(Mime->ContentType) > 0) &&
649 ( (!strcasecmp(ChrPtr(Mime->Disposition), "attachment"))
650 || (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
651 || (!strcasecmp(ChrPtr(Mime->Disposition), ""))))
653 if (Msg->AttachLinks == NULL)
654 Msg->AttachLinks = NewHash(1,NULL);
655 Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
656 if ((strcasecmp(ChrPtr(Mime->ContentType), "application/octet-stream") == 0) &&
657 (StrLength(Mime->FileName) > 0)) {
658 FlushStrBuf(Mime->ContentType);
659 StrBufAppendBufPlain(Mime->ContentType,
660 GuessMimeByFilename(SKEY(Mime->FileName)),
666 void tmplput_MAIL_SUMM_NATTACH(StrBuf *Target, WCTemplputParams *TP)
668 message_summary *Msg = (message_summary*) CTX;
669 StrBufAppendPrintf(Target, "%ld", GetCount(Msg->Attachments));
673 void examine_hnod(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
675 FreeStrBuf(&Msg->hnod);
676 Msg->hnod = NewStrBufPlain(NULL, StrLength(HdrLine));
677 StrBuf_RFC822_to_Utf8(Msg->hnod, HdrLine, WC->DefaultCharset, FoundCharset);
679 void tmplput_MAIL_SUMM_H_NODE(StrBuf *Target, WCTemplputParams *TP)
681 message_summary *Msg = (message_summary*) CTX;
682 StrBufAppendTemplate(Target, TP, Msg->hnod, 0);
684 int Conditional_MAIL_SUMM_H_NODE(StrBuf *Target, WCTemplputParams *TP)
686 message_summary *Msg = (message_summary*) CTX;
687 return StrLength(Msg->hnod) > 0;
692 void examine_text(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
694 if (Msg->MsgBody->Data == NULL)
695 Msg->MsgBody->Data = NewStrBufPlain(NULL, SIZ);
697 FlushStrBuf(Msg->MsgBody->Data);
700 void examine_msg4_partnum(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
702 Msg->MsgBody->PartNum = NewStrBufDup(HdrLine);
703 StrBufTrim(Msg->MsgBody->PartNum);
706 void examine_content_lengh(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
708 Msg->MsgBody->length = StrTol(HdrLine);
709 Msg->MsgBody->size_known = 1;
712 void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
722 Msg->MsgBody->ContentType = NewStrBufDup(HdrLine);
723 sem = strchr(ChrPtr(HdrLine), ';');
726 Token = NewStrBufPlain(NULL, StrLength(HdrLine));
727 Value = NewStrBufPlain(NULL, StrLength(HdrLine));
728 len = sem - ChrPtr(HdrLine);
729 StrBufCutAt(Msg->MsgBody->ContentType, len, NULL);
730 while (sem != NULL) {
731 while (isspace(*(sem + 1)))
733 StrBufCutLeft(HdrLine, sem - ChrPtr(HdrLine));
734 sem = strchr(ChrPtr(HdrLine), ';');
736 len = sem - ChrPtr(HdrLine);
738 len = StrLength(HdrLine);
741 StrBufAppendBufPlain(Token, ChrPtr(HdrLine), len, 0);
742 eq = strchr(ChrPtr(Token), '=');
744 len = eq - ChrPtr(Token);
745 StrBufAppendBufPlain(Value, eq + 1, StrLength(Token) - len - 1, 0);
746 StrBufCutAt(Token, len, NULL);
751 if (GetHash(MsgHeaderHandler, SKEY(Token), &vHdr) &&
753 Hdr = (headereval*)vHdr;
754 Hdr->evaluator(Msg, Value, FoundCharset);
756 else lprintf(1, "don't know how to handle content type sub-header[%s]\n", ChrPtr(Token));
763 void tmplput_MAIL_SUMM_N(StrBuf *Target, WCTemplputParams *TP)
765 message_summary *Msg = (message_summary*) CTX;
766 StrBufAppendPrintf(Target, "%ld", Msg->msgnum);
771 int Conditional_MAIL_MIME_ALL(StrBuf *Target, WCTemplputParams *TP)
773 message_summary *Msg = (message_summary*) CTX;
774 return GetCount(Msg->Attachments) > 0;
777 int Conditional_MAIL_MIME_SUBMESSAGES(StrBuf *Target, WCTemplputParams *TP)
779 message_summary *Msg = (message_summary*) CTX;
780 return GetCount(Msg->Submessages) > 0;
783 int Conditional_MAIL_MIME_ATTACHLINKS(StrBuf *Target, WCTemplputParams *TP)
785 message_summary *Msg = (message_summary*) CTX;
786 return GetCount(Msg->AttachLinks) > 0;
789 int Conditional_MAIL_MIME_ATTACH(StrBuf *Target, WCTemplputParams *TP)
791 message_summary *Msg = (message_summary*) CTX;
792 return GetCount(Msg->AllAttach) > 0;
795 void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
801 MsgNum = LBstr(TKEY(0));
803 read_message(Buf, HKEY("view_message_replyquote"), MsgNum, NULL, &Mime);
804 StrBufAppendTemplate(Target, TP, Buf, 1);
808 void tmplput_EDIT_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
814 MsgNum = LBstr(TKEY(0));
816 read_message(Buf, HKEY("view_message_edit"), MsgNum, NULL, &Mime);
817 StrBufAppendTemplate(Target, TP, Buf, 1);
821 void tmplput_EDIT_WIKI_BODY(StrBuf *Target, WCTemplputParams *TP)
827 msgnum = locate_message_by_uid(BSTR("page"));
830 read_message(Buf, HKEY("view_message_wikiedit"), msgnum, NULL, &Mime);
831 StrBufAppendTemplate(Target, TP, Buf, 1);
836 void tmplput_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
838 message_summary *Msg = (message_summary*) CTX;
839 StrBufAppendTemplate(Target, TP, Msg->MsgBody->Data, 0);
843 void render_MAIL_variformat(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
845 /* Messages in legacy Citadel variformat get handled thusly... */
846 StrBuf *Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
847 FmOut(Target, "JUSTIFY", Mime->Data);
848 FreeStrBuf(&Mime->Data);
852 void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
854 const char *ptr, *pte;
855 const char *BufPtr = NULL;
868 iconv_t ic = (iconv_t)(-1) ;
871 if ((StrLength(Mime->Data) == 0) && (Mime->length > 0)) {
872 FreeStrBuf(&Mime->Data);
878 if (StrLength(Mime->Charset) != 0)
880 else if (StrLength(FoundCharset) > 0)
882 else if (StrLength(WC->DefaultCharset) > 0)
883 cs = WC->DefaultCharset;
887 else if (!strcasecmp(ChrPtr(cs), "utf-8")) {
890 else if (!strcasecmp(ChrPtr(cs), "us-ascii")) {
894 ctdl_iconv_open("UTF-8", ChrPtr(cs), &ic);
895 if (ic == (iconv_t)(-1) ) {
896 lprintf(5, "%s:%d iconv_open(UTF-8, %s) failed: %s\n",
897 __FILE__, __LINE__, ChrPtr(Mime->Charset), strerror(errno));
902 Line = NewStrBufPlain(NULL, SIZ);
903 Line1 = NewStrBufPlain(NULL, SIZ);
904 Line2 = NewStrBufPlain(NULL, SIZ);
905 Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
907 if (StrLength(Mime->Data) > 0)
910 StrBufSipLine(Line, Mime->Data, &BufPtr);
914 len = StrLength(Line);
917 while ((ptr < pte) &&
926 if (i > 0) StrBufCutLeft(Line, i);
928 if (StrLength(Line) == 0) {
929 StrBufAppendBufPlain(Target, HKEY("<tt></tt><br />\n"), 0);
933 for (i = bn; i < bq; i++)
934 StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
935 for (i = bq; i < bn; i++)
936 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
939 StrBufConvert(Line, Line1, &ic);
942 StrBufAppendBufPlain(Target, HKEY("<tt>"), 0);
943 UrlizeText(Line1, Line, Line2);
945 StrEscAppend(Target, Line1, NULL, 0, 0);
946 StrBufAppendBufPlain(Target, HKEY("</tt><br />\n"), 0);
949 while ((BufPtr != StrBufNOTNULL) &&
952 for (i = 0; i < bn; i++)
953 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
955 StrBufAppendBufPlain(Target, HKEY("</i><br />"), 0);
957 if (ic != (iconv_t)(-1) ) {
962 FreeStrBuf(&Mime->Data);
964 FlushStrBuf(Mime->ContentType);
965 StrBufAppendBufPlain(Mime->ContentType, HKEY("text/html"), 0);
966 FlushStrBuf(Mime->Charset);
967 StrBufAppendBufPlain(Mime->Charset, HKEY("UTF-8"), 0);
973 void render_MAIL_html(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
977 if (StrLength(Mime->Data) == 0)
980 Buf = NewStrBufPlain(NULL, StrLength(Mime->Data));
982 /* HTML is fun, but we've got to strip it first */
983 output_html(ChrPtr(Mime->Charset),
984 (WC->CurRoom.view == VIEW_WIKI ? 1 : 0),
987 FreeStrBuf(&Mime->Data);
991 void render_MAIL_UNKNOWN(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
993 /* Unknown weirdness */
994 FlushStrBuf(Mime->Data);
995 StrBufAppendBufPlain(Mime->Data, _("I don't know how to display "), -1, 0);
996 StrBufAppendBuf(Mime->Data, Mime->ContentType, 0);
997 StrBufAppendBufPlain(Mime->Data, HKEY("<br />\n"), 0);
1001 HashList *iterate_get_mime_All(StrBuf *Target, WCTemplputParams *TP)
1003 message_summary *Msg = (message_summary*) CTX;
1004 return Msg->Attachments;
1006 HashList *iterate_get_mime_Submessages(StrBuf *Target, WCTemplputParams *TP)
1008 message_summary *Msg = (message_summary*) CTX;
1009 return Msg->Submessages;
1011 HashList *iterate_get_mime_AttachLinks(StrBuf *Target, WCTemplputParams *TP)
1013 message_summary *Msg = (message_summary*) CTX;
1014 return Msg->AttachLinks;
1016 HashList *iterate_get_mime_Attachments(StrBuf *Target, WCTemplputParams *TP)
1018 message_summary *Msg = (message_summary*) CTX;
1019 return Msg->AllAttach;
1022 void tmplput_MIME_Name(StrBuf *Target, WCTemplputParams *TP)
1024 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1025 StrBufAppendTemplate(Target, TP, mime->Name, 0);
1028 void tmplput_MIME_FileName(StrBuf *Target, WCTemplputParams *TP)
1030 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1031 StrBufAppendTemplate(Target, TP, mime->FileName, 0);
1034 void tmplput_MIME_PartNum(StrBuf *Target, WCTemplputParams *TP)
1036 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1037 StrBufAppendTemplate(Target, TP, mime->PartNum, 0);
1040 void tmplput_MIME_MsgNum(StrBuf *Target, WCTemplputParams *TP)
1042 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1043 StrBufAppendPrintf(Target, "%ld", mime->msgnum);
1046 void tmplput_MIME_Disposition(StrBuf *Target, WCTemplputParams *TP)
1048 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1049 StrBufAppendTemplate(Target, TP, mime->Disposition, 0);
1052 void tmplput_MIME_ContentType(StrBuf *Target, WCTemplputParams *TP)
1054 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1055 StrBufAppendTemplate(Target, TP, mime->ContentType, 0);
1058 void examine_charset(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
1060 Msg->MsgBody->Charset = NewStrBufDup(HdrLine);
1063 void tmplput_MIME_Charset(StrBuf *Target, WCTemplputParams *TP)
1065 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1066 StrBufAppendTemplate(Target, TP, mime->Charset, 0);
1069 void tmplput_MIME_Data(StrBuf *Target, WCTemplputParams *TP)
1071 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1072 if (mime->Renderer != NULL)
1073 mime->Renderer->f(mime, NULL, NULL);
1074 StrBufAppendTemplate(Target, TP, mime->Data, 0);
1075 /* TODO: check whether we need to load it now? */
1078 void tmplput_MIME_LoadData(StrBuf *Target, WCTemplputParams *TP)
1080 wcsession *WCC = WC;
1081 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1082 wc_mime_attachment *att;
1084 if (( (!strcasecmp(ChrPtr(mime->Disposition), "inline"))||
1085 (!strcasecmp(ChrPtr(mime->Disposition), "attachment"))) &&
1086 (strcasecmp(ChrPtr(mime->ContentType), "application/ms-tnef")!=0))
1091 /* steal this mime part... */
1092 att = malloc(sizeof(wc_mime_attachment));
1093 memcpy(att, mime, sizeof(wc_mime_attachment));
1094 memset(mime, 0, sizeof(wc_mime_attachment));
1096 if (att->Data == NULL)
1099 if (WCC->attachments == NULL)
1100 WCC->attachments = NewHash(1, NULL);
1101 /* And add it to the list. */
1102 n = snprintf(N, sizeof N, "%d", GetCount(WCC->attachments) + 1);
1103 Put(WCC->attachments, N, n, att, DestroyMime);
1107 void tmplput_MIME_Length(StrBuf *Target, WCTemplputParams *TP)
1109 wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
1110 StrBufAppendPrintf(Target, "%ld", mime->length);
1113 HashList *iterate_get_registered_Attachments(StrBuf *Target, WCTemplputParams *TP)
1115 return WC->attachments;
1118 void servcmd_do_search(char *buf, long bufsize)
1120 snprintf(buf, bufsize, "MSGS SEARCH|%s", bstr("query"));
1123 void servcmd_headers(char *buf, long bufsize)
1125 snprintf(buf, bufsize, "MSGS ALL");
1128 void servcmd_readfwd(char *buf, long bufsize)
1130 snprintf(buf, bufsize, "MSGS ALL");
1133 void servcmd_readgt(char *buf, long bufsize)
1135 snprintf(buf, bufsize, "MSGS GT|%s", bstr("gt"));
1138 void servcmd_readlt(char *buf, long bufsize)
1140 snprintf(buf, bufsize, "MSGS LT|%s", bstr("lt"));
1143 void servcmd_readnew(char *buf, long bufsize)
1145 snprintf(buf, bufsize, "MSGS NEW");
1148 void servcmd_readold(char *buf, long bufsize)
1150 snprintf(buf, bufsize, "MSGS OLD");
1154 readloop_struct rlid[] = {
1155 { {HKEY("do_search")}, servcmd_do_search },
1156 { {HKEY("headers")}, servcmd_headers },
1157 { {HKEY("readfwd")}, servcmd_readfwd },
1158 { {HKEY("readnew")}, servcmd_readnew },
1159 { {HKEY("readold")}, servcmd_readold },
1160 { {HKEY("readgt")}, servcmd_readgt },
1161 { {HKEY("readlt")}, servcmd_readlt }
1165 int ParseMessageListHeaders_Detail(StrBuf *Line,
1167 message_summary *Msg,
1168 StrBuf *ConversionBuffer)
1170 wcsession *WCC = WC;
1172 Msg->from = NewStrBufPlain(NULL, StrLength(Line));
1173 StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
1174 if (StrLength(ConversionBuffer) != 0) {
1175 /* Handle senders with RFC2047 encoding */
1176 StrBuf_RFC822_to_Utf8(Msg->from, ConversionBuffer, WCC->DefaultCharset, NULL);
1180 StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
1181 if ((StrLength(ConversionBuffer) !=0 ) &&
1182 ( ((WCC->CurRoom.QRFlags & QR_NETWORK)
1183 || ((strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_nodename))
1184 && (strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_fqdn))))))))
1186 StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
1187 StrBufAppendBuf(Msg->from, ConversionBuffer, 0);
1190 /* Internet address (not used)
1191 * StrBufExtract_token(Msg->inetaddr, Line, 4, '|');
1193 StrBufSkip_NTokenS(Line, pos, '|', 1);
1194 Msg->subj = NewStrBufPlain(NULL, StrLength(Line));
1195 StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
1196 if (StrLength(ConversionBuffer) == 0)
1197 StrBufAppendBufPlain(Msg->subj, _("(no subject)"), -1,0);
1199 StrBuf_RFC822_to_Utf8(Msg->subj, ConversionBuffer, WCC->DefaultCharset, NULL);
1200 if ((StrLength(Msg->subj) > 75) &&
1201 (StrBuf_Utf8StrLen(Msg->subj) > 75)) {
1202 StrBuf_Utf8StrCut(Msg->subj, 72);
1203 StrBufAppendBufPlain(Msg->subj, HKEY("..."), 0);
1207 if ((StrLength(Msg->from) > 25) &&
1208 (StrBuf_Utf8StrLen(Msg->from) > 25)) {
1209 StrBuf_Utf8StrCut(Msg->from, 23);
1210 StrBufAppendBufPlain(Msg->from, HKEY("..."), 0);
1215 /* Spit out the new summary view. This is basically a static page, so clients can cache the layout, all the dirty work is javascript :) */
1216 void new_summary_view(void) {
1217 DoTemplate(HKEY("msg_listview"),NULL,&NoCtx);
1221 int mailview_GetParamsGetServerCall(SharedMessageStatus *Stat,
1222 void **ViewSpecific,
1231 Stat->defaultsortorder = 2;
1233 Stat->load_seen = 1;
1234 /* Generally using maxmsgs|startmsg is not required
1235 in mailbox view, but we have a 'safemode' for clients
1236 (*cough* Exploder) that simply can't handle too many */
1237 if (havebstr("maxmsgs")) Stat->maxmsgs = ibstr("maxmsgs");
1238 else Stat->maxmsgs = 9999999;
1239 if (havebstr("startmsg")) Stat->startmsg = lbstr("startmsg");
1240 snprintf(cmd, len, "MSGS %s|%s||1",
1241 (oper == do_search) ? "SEARCH" : "ALL",
1242 (oper == do_search) ? bstr("query") : ""
1248 int mailview_RenderView_or_Tail(SharedMessageStatus *Stat,
1249 void **ViewSpecific,
1252 WCTemplputParams SubTP;
1255 DoTemplate(HKEY("mailsummary_json"),NULL, &SubTP);
1260 int mailview_Cleanup(void **ViewSpecific)
1262 /* Note: wDumpContent() will output one additional </div> tag. */
1263 /* We ought to move this out into template */
1275 InitModule_MSGRENDERERS
1278 RegisterReadLoopHandlerset(
1280 mailview_GetParamsGetServerCall,
1281 NULL, /// TODO: is this right?
1282 ParseMessageListHeaders_Detail,
1284 mailview_RenderView_or_Tail,
1287 RegisterSortFunc(HKEY("date"),
1293 RegisterSortFunc(HKEY("subject"),
1299 RegisterSortFunc(HKEY("sender"),
1306 RegisterNamespace("SUMM:COUNT", 0, 0, tmplput_SUMM_COUNT, NULL, CTX_NONE);
1307 /* iterate over all known mails in WC->summ */
1308 RegisterIterator("MAIL:SUMM:MSGS", 0, NULL, iterate_get_mailsumm_All,
1309 NULL,NULL, CTX_MAILSUM, CTX_NONE, IT_NOFLAG);
1311 RegisterNamespace("MAIL:SUMM:EUID", 0, 1, tmplput_MAIL_SUMM_EUID, NULL, CTX_MAILSUM);
1312 RegisterNamespace("MAIL:SUMM:DATEBRIEF", 0, 0, tmplput_MAIL_SUMM_DATE_BRIEF, NULL, CTX_MAILSUM);
1313 RegisterNamespace("MAIL:SUMM:DATEFULL", 0, 0, tmplput_MAIL_SUMM_DATE_FULL, NULL, CTX_MAILSUM);
1314 RegisterNamespace("MAIL:SUMM:DATENO", 0, 0, tmplput_MAIL_SUMM_DATE_NO, NULL, CTX_MAILSUM);
1315 RegisterNamespace("MAIL:SUMM:N", 0, 0, tmplput_MAIL_SUMM_N, NULL, CTX_MAILSUM);
1316 RegisterNamespace("MAIL:SUMM:FROM", 0, 2, tmplput_MAIL_SUMM_FROM, NULL, CTX_MAILSUM);
1317 RegisterNamespace("MAIL:SUMM:TO", 0, 2, tmplput_MAIL_SUMM_TO, NULL, CTX_MAILSUM);
1318 RegisterNamespace("MAIL:SUMM:SUBJECT", 0, 4, tmplput_MAIL_SUMM_SUBJECT, NULL, CTX_MAILSUM);
1319 RegisterNamespace("MAIL:SUMM:NTATACH", 0, 0, tmplput_MAIL_SUMM_NATTACH, NULL, CTX_MAILSUM);
1320 RegisterNamespace("MAIL:SUMM:CCCC", 0, 2, tmplput_MAIL_SUMM_CCCC, NULL, CTX_MAILSUM);
1321 RegisterNamespace("MAIL:SUMM:H_NODE", 0, 2, tmplput_MAIL_SUMM_H_NODE, NULL, CTX_MAILSUM);
1322 RegisterNamespace("MAIL:SUMM:ALLRCPT", 0, 2, tmplput_MAIL_SUMM_ALLRCPT, NULL, CTX_MAILSUM);
1323 RegisterNamespace("MAIL:SUMM:ORGROOM", 0, 2, tmplput_MAIL_SUMM_ORGROOM, NULL, CTX_MAILSUM);
1324 RegisterNamespace("MAIL:SUMM:RFCA", 0, 2, tmplput_MAIL_SUMM_RFCA, NULL, CTX_MAILSUM);
1325 RegisterNamespace("MAIL:SUMM:OTHERNODE", 2, 0, tmplput_MAIL_SUMM_OTHERNODE, NULL, CTX_MAILSUM);
1326 RegisterNamespace("MAIL:SUMM:REFIDS", 0, 1, tmplput_MAIL_SUMM_REFIDS, NULL, CTX_MAILSUM);
1327 RegisterNamespace("MAIL:SUMM:INREPLYTO", 0, 2, tmplput_MAIL_SUMM_INREPLYTO, NULL, CTX_MAILSUM);
1328 RegisterNamespace("MAIL:BODY", 0, 2, tmplput_MAIL_BODY, NULL, CTX_MAILSUM);
1329 RegisterNamespace("MAIL:QUOTETEXT", 1, 2, tmplput_QUOTED_MAIL_BODY, NULL, CTX_NONE);
1330 RegisterNamespace("MAIL:EDITTEXT", 1, 2, tmplput_EDIT_MAIL_BODY, NULL, CTX_NONE);
1331 RegisterNamespace("MAIL:EDITWIKI", 1, 2, tmplput_EDIT_WIKI_BODY, NULL, CTX_NONE);
1332 RegisterConditional(HKEY("COND:MAIL:SUMM:RFCA"), 0, Conditional_MAIL_SUMM_RFCA, CTX_MAILSUM);
1333 RegisterConditional(HKEY("COND:MAIL:SUMM:CCCC"), 0, Conditional_MAIL_SUMM_CCCC, CTX_MAILSUM);
1334 RegisterConditional(HKEY("COND:MAIL:SUMM:UNREAD"), 0, Conditional_MAIL_SUMM_UNREAD, CTX_MAILSUM);
1335 RegisterConditional(HKEY("COND:MAIL:SUMM:H_NODE"), 0, Conditional_MAIL_SUMM_H_NODE, CTX_MAILSUM);
1336 RegisterConditional(HKEY("COND:MAIL:SUMM:OTHERNODE"), 0, Conditional_MAIL_SUMM_OTHERNODE, CTX_MAILSUM);
1337 RegisterConditional(HKEY("COND:MAIL:SUMM:SUBJECT"), 0, Conditional_MAIL_SUMM_SUBJECT, CTX_MAILSUM);
1338 RegisterConditional(HKEY("COND:MAIL:ANON"), 0, Conditional_ANONYMOUS_MESSAGE, CTX_MAILSUM);
1339 RegisterConditional(HKEY("COND:MAIL:TO"), 0, Conditional_MAIL_SUMM_TO, CTX_MAILSUM);
1340 RegisterConditional(HKEY("COND:MAIL:SUBJ"), 0, Conditional_MAIL_SUMM_SUBJ, CTX_MAILSUM);
1342 /* do we have mimetypes to iterate over? */
1343 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH"), 0, Conditional_MAIL_MIME_ALL, CTX_MAILSUM);
1344 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:SUBMESSAGES"), 0, Conditional_MAIL_MIME_SUBMESSAGES, CTX_MAILSUM);
1345 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:LINKS"), 0, Conditional_MAIL_MIME_ATTACHLINKS, CTX_MAILSUM);
1346 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:ATT"), 0, Conditional_MAIL_MIME_ATTACH, CTX_MAILSUM);
1347 RegisterIterator("MAIL:MIME:ATTACH", 0, NULL, iterate_get_mime_All,
1348 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1349 RegisterIterator("MAIL:MIME:ATTACH:SUBMESSAGES", 0, NULL, iterate_get_mime_Submessages,
1350 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1351 RegisterIterator("MAIL:MIME:ATTACH:LINKS", 0, NULL, iterate_get_mime_AttachLinks,
1352 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1353 RegisterIterator("MAIL:MIME:ATTACH:ATT", 0, NULL, iterate_get_mime_Attachments,
1354 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
1356 /* Parts of a mime attachent */
1357 RegisterNamespace("MAIL:MIME:NAME", 0, 2, tmplput_MIME_Name, NULL, CTX_MIME_ATACH);
1358 RegisterNamespace("MAIL:MIME:FILENAME", 0, 2, tmplput_MIME_FileName, NULL, CTX_MIME_ATACH);
1359 RegisterNamespace("MAIL:MIME:PARTNUM", 0, 2, tmplput_MIME_PartNum, NULL, CTX_MIME_ATACH);
1360 RegisterNamespace("MAIL:MIME:MSGNUM", 0, 2, tmplput_MIME_MsgNum, NULL, CTX_MIME_ATACH);
1361 RegisterNamespace("MAIL:MIME:DISPOSITION", 0, 2, tmplput_MIME_Disposition, NULL, CTX_MIME_ATACH);
1362 RegisterNamespace("MAIL:MIME:CONTENTTYPE", 0, 2, tmplput_MIME_ContentType, NULL, CTX_MIME_ATACH);
1363 RegisterNamespace("MAIL:MIME:CHARSET", 0, 2, tmplput_MIME_Charset, NULL, CTX_MIME_ATACH);
1364 RegisterNamespace("MAIL:MIME:LENGTH", 0, 2, tmplput_MIME_Length, NULL, CTX_MIME_ATACH);
1365 RegisterNamespace("MAIL:MIME:DATA", 0, 2, tmplput_MIME_Data, NULL, CTX_MIME_ATACH);
1366 /* load the actual attachment into WC->attachments; no output!!! */
1367 RegisterNamespace("MAIL:MIME:LOADDATA", 0, 0, tmplput_MIME_LoadData, NULL, CTX_MIME_ATACH);
1369 /* iterate the WC->attachments; use the above tokens for their contents */
1370 RegisterIterator("MSG:ATTACHNAMES", 0, NULL, iterate_get_registered_Attachments,
1371 NULL, NULL, CTX_MIME_ATACH, CTX_NONE, IT_NOFLAG);
1373 /* mime renderers translate an attachment into webcit viewable html text */
1374 RegisterMimeRenderer(HKEY("message/rfc822"), render_MAIL, 1, 150);
1375 RegisterMimeRenderer(HKEY("text/vnote"), render_MIME_VNote, 1, 300);
1376 RegisterMimeRenderer(HKEY("text/x-vcard"), render_MIME_VCard, 1, 201);
1377 RegisterMimeRenderer(HKEY("text/vcard"), render_MIME_VCard, 1, 200);
1378 RegisterMimeRenderer(HKEY("text/calendar"), render_MIME_ICS, 1, 501);
1379 RegisterMimeRenderer(HKEY("application/ics"), render_MIME_ICS, 1, 500);
1380 RegisterMimeRenderer(HKEY("text/x-citadel-variformat"), render_MAIL_variformat, 1, 2);
1381 RegisterMimeRenderer(HKEY("text/plain"), render_MAIL_text_plain, 1, 3);
1382 RegisterMimeRenderer(HKEY("text"), render_MAIL_text_plain, 1, 1);
1383 RegisterMimeRenderer(HKEY("text/html"), render_MAIL_html, 1, 100);
1384 RegisterMimeRenderer(HKEY(""), render_MAIL_UNKNOWN, 0, 0);
1385 /* and finalize the anouncement to the server... */
1388 /* these headers are citserver replies to MSG4 and friends. one evaluator for each */
1389 RegisterMsgHdr(HKEY("nhdr"), examine_nhdr, 0);
1390 RegisterMsgHdr(HKEY("type"), examine_type, 0);
1391 RegisterMsgHdr(HKEY("from"), examine_from, 0);
1392 RegisterMsgHdr(HKEY("subj"), examine_subj, 0);
1393 RegisterMsgHdr(HKEY("msgn"), examine_msgn, 0);
1394 RegisterMsgHdr(HKEY("wefw"), examine_wefw, 0);
1395 RegisterMsgHdr(HKEY("cccc"), examine_cccc, 0);
1396 RegisterMsgHdr(HKEY("hnod"), examine_hnod, 0);
1397 RegisterMsgHdr(HKEY("room"), examine_room, 0);
1398 RegisterMsgHdr(HKEY("rfca"), examine_rfca, 0);
1399 RegisterMsgHdr(HKEY("node"), examine_node, 0);
1400 RegisterMsgHdr(HKEY("rcpt"), examine_rcpt, 0);
1401 RegisterMsgHdr(HKEY("time"), examine_time, 0);
1402 RegisterMsgHdr(HKEY("part"), examine_mime_part, 0);
1403 RegisterMsgHdr(HKEY("text"), examine_text, 1);
1404 /* these are the content-type headers we get infront of a message; put it into the same hash since it doesn't clash. */
1405 RegisterMsgHdr(HKEY("X-Citadel-MSG4-Partnum"), examine_msg4_partnum, 0);
1406 RegisterMsgHdr(HKEY("Content-type"), examine_content_type, 0);
1407 RegisterMsgHdr(HKEY("Content-length"), examine_content_lengh, 0);
1408 RegisterMsgHdr(HKEY("Content-transfer-encoding"), examine_content_encoding, 0); /* do we care? */
1409 RegisterMsgHdr(HKEY("charset"), examine_charset, 0);
1411 /* Don't care about these... */
1412 RegisterMsgHdr(HKEY("pref"), examine_pref, 0);
1413 RegisterMsgHdr(HKEY("suff"), examine_suff, 0);
1414 RegisterMsgHdr(HKEY("path"), examine_path, 0);
1418 ServerStartModule_MSGRENDERERS
1421 MsgHeaderHandler = NewHash(1, NULL);
1422 MimeRenderHandler = NewHash(1, NULL);
1423 ReadLoopHandler = NewHash(1, NULL);
1427 ServerShutdownModule_MSGRENDERERS
1430 DeleteHash(&MsgHeaderHandler);
1431 DeleteHash(&MimeRenderHandler);
1432 DeleteHash(&ReadLoopHandler);
1438 SessionDestroyModule_MSGRENDERERS
1441 DeleteHash(&sess->attachments);