4 * Functions which deal with the fetching and displaying of messages.
12 HashList *MsgHeaderHandler = NULL;
13 HashList *MsgEvaluators = NULL;
14 HashList *MimeRenderHandler = NULL;
16 #define SUBJ_COL_WIDTH_PCT 50 /**< Mailbox view column width */
17 #define SENDER_COL_WIDTH_PCT 30 /**< Mailbox view column width */
18 #define DATE_PLUS_BUTTONS_WIDTH_PCT 20 /**< Mailbox view column width */
20 void display_enter(void);
21 int longcmp_r(const void *s1, const void *s2);
22 int summcmp_subj(const void *s1, const void *s2);
23 int summcmp_rsubj(const void *s1, const void *s2);
24 int summcmp_sender(const void *s1, const void *s2);
25 int summcmp_rsender(const void *s1, const void *s2);
26 int summcmp_date(const void *s1, const void *s2);
27 int summcmp_rdate(const void *s1, const void *s2);
29 /*----------------------------------------------------------------------------*/
32 typedef void (*MsgPartEvaluatorFunc)(message_summary *Sum, StrBuf *Buf);
42 typedef struct _headereval {
43 ExamineMsgHeaderFunc evaluator;
55 const char* SortIcons[3] = {
56 "static/up_pointer.gif",
57 "static/down_pointer.gif",
58 "static/sort_none.gif"
72 /* SortEnum to plain string representation */
73 static const char* SortByStrings[] = {
84 /* SortEnum to sort-Function Table */
85 const CompareFunc SortFuncs[eUnSet] = {
95 /* given a SortEnum, which icon should we choose? */
96 const int SortDateToIcon[eUnSet] = { eUp, eDown, eNone, eNone, eNone, eNone, eNone};
97 const int SortSubjectToIcon[eUnSet] = { eNone, eNone, eUp, eDown, eNone, eNone, eNone};
98 const int SortSenderToIcon[eUnSet] = { eNone, eNone, eNone, eNone, eUp, eDown, eNone};
100 /* given a SortEnum, which would be the "opposite" search option? */
101 const int DateInvertSortString[eUnSet] = { eRDate, eDate, eDate, eDate, eDate, eDate, eDate};
102 const int SubjectInvertSortString[eUnSet] = { eSubject, eSubject, eRSubject, eUnSet, eSubject, eSubject, eSubject};
103 const int SenderInvertSortString[eUnSet] = { eSender, eSender, eSender, eSender, eRSender, eUnSet, eSender};
109 * Address book entry (keep it short and sweet, it's just a quickie lookup
110 * which we can use to get to the real meat and bones later)
113 char ab_name[64]; /**< name string */
114 long ab_msgnum; /**< message number of address book entry */
117 /*----------------------------------------------------------------------------*/
120 * Translates sortoption String to its SortEnum representation
121 * returns the enum matching the string; defaults to RDate
124 int StrToESort (const StrBuf *sortby)
128 if (!IsEmptyStr(ChrPtr(sortby))) while (result < eUnSet){
129 if (!strcasecmp(ChrPtr(sortby),
130 SortByStrings[result]))
138 typedef int (*QSortFunction) (const void*, const void*);
141 * qsort() compatible function to compare two longs in descending order.
143 int longcmp_r(const void *s1, const void *s2) {
147 l1 = *(long *)GetSearchPayload(s1);
148 l2 = *(long *)GetSearchPayload(s2);
150 if (l1 > l2) return(-1);
151 if (l1 < l2) return(+1);
157 * qsort() compatible function to compare two message summary structs by ascending subject.
159 int summcmp_subj(const void *s1, const void *s2) {
160 message_summary *summ1;
161 message_summary *summ2;
163 summ1 = (message_summary *)GetSearchPayload(s1);
164 summ2 = (message_summary *)GetSearchPayload(s2);
165 return strcasecmp(ChrPtr(summ1->subj), ChrPtr(summ2->subj));
169 * qsort() compatible function to compare two message summary structs by descending subject.
171 int summcmp_rsubj(const void *s1, const void *s2) {
172 message_summary *summ1;
173 message_summary *summ2;
175 summ1 = (message_summary *)GetSearchPayload(s1);
176 summ2 = (message_summary *)GetSearchPayload(s2);
177 return strcasecmp(ChrPtr(summ2->subj), ChrPtr(summ1->subj));
181 * qsort() compatible function to compare two message summary structs by ascending sender.
183 int summcmp_sender(const void *s1, const void *s2) {
184 message_summary *summ1;
185 message_summary *summ2;
187 summ1 = (message_summary *)GetSearchPayload(s1);
188 summ2 = (message_summary *)GetSearchPayload(s2);
189 return strcasecmp(ChrPtr(summ1->from), ChrPtr(summ2->from));
193 * qsort() compatible function to compare two message summary structs by descending sender.
195 int summcmp_rsender(const void *s1, const void *s2) {
196 message_summary *summ1;
197 message_summary *summ2;
199 summ1 = (message_summary *)GetSearchPayload(s1);
200 summ2 = (message_summary *)GetSearchPayload(s2);
201 return strcasecmp(ChrPtr(summ2->from), ChrPtr(summ1->from));
205 * qsort() compatible function to compare two message summary structs by ascending date.
207 int summcmp_date(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 * qsort() compatible function to compare two message summary structs by descending date.
222 int summcmp_rdate(const void *s1, const void *s2) {
223 message_summary *summ1;
224 message_summary *summ2;
226 summ1 = (message_summary *)GetSearchPayload(s1);
227 summ2 = (message_summary *)GetSearchPayload(s2);
229 if (summ1->date < summ2->date) return +1;
230 else if (summ1->date > summ2->date) return -1;
238 /*----------------------------------------------------------------------------*/
241 * message index functions
244 void DestroyMimeParts(wc_mime_attachment *Mime)
246 FreeStrBuf(&Mime->Name);
247 FreeStrBuf(&Mime->FileName);
248 FreeStrBuf(&Mime->PartNum);
249 FreeStrBuf(&Mime->Disposition);
250 FreeStrBuf(&Mime->ContentType);
251 FreeStrBuf(&Mime->Charset);
252 FreeStrBuf(&Mime->Data);
255 void DestroyMime(void *vMime)
257 wc_mime_attachment *Mime = (wc_mime_attachment*)vMime;
258 DestroyMimeParts(Mime);
262 void DestroyMessageSummary(void *vMsg)
264 message_summary *Msg = (message_summary*) vMsg;
266 FreeStrBuf(&Msg->from);
267 FreeStrBuf(&Msg->to);
268 FreeStrBuf(&Msg->subj);
269 FreeStrBuf(&Msg->reply_inreplyto);
270 FreeStrBuf(&Msg->reply_references);
271 FreeStrBuf(&Msg->cccc);
272 FreeStrBuf(&Msg->hnod);
273 FreeStrBuf(&Msg->AllRcpt);
274 FreeStrBuf(&Msg->Room);
275 FreeStrBuf(&Msg->Rfca);
276 FreeStrBuf(&Msg->OtherNode);
278 FreeStrBuf(&Msg->reply_to);
280 DeleteHash(&Msg->Attachments); /**< list of Accachments */
281 DeleteHash(&Msg->Submessages);
282 DeleteHash(&Msg->AttachLinks);
283 DeleteHash(&Msg->AllAttach);
285 DestroyMimeParts(&Msg->MsgBody);
292 void RegisterMsgHdr(const char *HeaderName, long HdrNLen, ExamineMsgHeaderFunc evaluator, int type)
295 ev = (headereval*) malloc(sizeof(headereval));
296 ev->evaluator = evaluator;
298 Put(MsgHeaderHandler, HeaderName, HdrNLen, ev, NULL);
301 void RegisterMimeRenderer(const char *HeaderName, long HdrNLen, RenderMimeFunc MimeRenderer)
303 Put(MimeRenderHandler, HeaderName, HdrNLen, MimeRenderer, reference_free_handler);
307 /*----------------------------------------------------------------------------*/
310 void examine_nhdr(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
313 if (!strncasecmp(ChrPtr(HdrLine), "yes", 8))
316 int Conditional_ANONYMOUS_MESSAGE(WCTemplateToken *Tokens, void *Context, int ContextType)
318 message_summary *Msg = (message_summary*) Context;
319 return Msg->nhdr != 0;
323 void examine_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
325 Msg->format_type = StrToi(HdrLine);
329 void examine_from(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
331 FreeStrBuf(&Msg->from);
332 Msg->from = NewStrBufPlain(NULL, StrLength(HdrLine));
333 StrBuf_RFC822_to_Utf8(Msg->from, HdrLine, WC->DefaultCharset, FoundCharset);
335 void tmplput_MAIL_SUMM_FROM(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
337 message_summary *Msg = (message_summary*) Context;
338 StrBufAppendBuf(Target, Msg->from, 0);
339 lprintf(1,"%s", ChrPtr(Msg->from));
344 void examine_subj(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
346 FreeStrBuf(&Msg->subj);
347 Msg->subj = NewStrBufPlain(NULL, StrLength(HdrLine));
348 StrBuf_RFC822_to_Utf8(Msg->subj, HdrLine, WC->DefaultCharset, FoundCharset);
349 lprintf(1,"%s", ChrPtr(Msg->subj));
351 void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
352 {/////TODO: Fwd: and RE: filter!!
353 message_summary *Msg = (message_summary*) Context;
354 StrBufAppendBuf(Target, Msg->subj, 0);
358 void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
360 FreeStrBuf(&Msg->reply_inreplyto);
361 Msg->reply_inreplyto = NewStrBufPlain(NULL, StrLength(HdrLine));
362 StrBuf_RFC822_to_Utf8(Msg->reply_inreplyto, HdrLine, WC->DefaultCharset, FoundCharset);
364 void tmplput_MAIL_SUMM_INREPLYTO(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
366 message_summary *Msg = (message_summary*) Context;
367 StrBufAppendBuf(Target, Msg->reply_inreplyto, 0);
370 int Conditional_MAIL_SUMM_UNREAD(WCTemplateToken *Tokens, void *Context, int ContextType)
372 message_summary *Msg = (message_summary*) Context;
373 return Msg->is_new != 0;
376 void examine_wefw(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
378 FreeStrBuf(&Msg->reply_references);
379 Msg->reply_references = NewStrBufPlain(NULL, StrLength(HdrLine));
380 StrBuf_RFC822_to_Utf8(Msg->reply_references, HdrLine, WC->DefaultCharset, FoundCharset);
382 void tmplput_MAIL_SUMM_REFIDS(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
384 message_summary *Msg = (message_summary*) Context;
385 StrBufAppendBuf(Target, Msg->reply_references, 0);
389 void examine_cccc(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
391 FreeStrBuf(&Msg->cccc);
392 Msg->cccc = NewStrBufPlain(NULL, StrLength(HdrLine));
393 StrBuf_RFC822_to_Utf8(Msg->cccc, HdrLine, WC->DefaultCharset, FoundCharset);
394 if (Msg->AllRcpt == NULL)
395 Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
396 if (StrLength(Msg->AllRcpt) > 0) {
397 StrBufAppendBufPlain(Msg->AllRcpt, HKEY(", "), 0);
399 StrBufAppendBuf(Msg->AllRcpt, Msg->cccc, 0);
401 void tmplput_MAIL_SUMM_CCCC(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
403 message_summary *Msg = (message_summary*) Context;
404 StrBufAppendBuf(Target, Msg->cccc, 0);
410 void examine_room(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
412 if ((StrLength(HdrLine) > 0) &&
413 (strcasecmp(ChrPtr(HdrLine), WC->wc_roomname))) {
414 FreeStrBuf(&Msg->Room);
415 Msg->Room = NewStrBufDup(HdrLine);
418 void tmplput_MAIL_SUMM_ORGROOM(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
420 message_summary *Msg = (message_summary*) Context;
421 StrBufAppendBuf(Target, Msg->Room, 0);
425 void examine_rfca(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
427 FreeStrBuf(&Msg->Rfca);
428 Msg->Rfca = NewStrBufDup(HdrLine);
430 void tmplput_MAIL_SUMM_RFCA(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
432 message_summary *Msg = (message_summary*) Context;
433 StrBufAppendBuf(Target, Msg->Rfca, 0);
437 void examine_node(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
439 if ( (StrLength(HdrLine) > 0) &&
440 ((WC->room_flags & QR_NETWORK)
441 || ((strcasecmp(ChrPtr(HdrLine), serv_info.serv_nodename)
442 && (strcasecmp(ChrPtr(HdrLine), serv_info.serv_fqdn)))))) {
443 FreeStrBuf(&Msg->OtherNode);
444 Msg->OtherNode = NewStrBufDup(HdrLine);
447 void tmplput_MAIL_SUMM_OTHERNODE(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
449 message_summary *Msg = (message_summary*) Context;
450 StrBufAppendBuf(Target, Msg->OtherNode, 0);
452 int Conditional_MAIL_SUMM_OTHERNODE(WCTemplateToken *Tokens, void *Context, int ContextType)
454 message_summary *Msg = (message_summary*) Context;
455 return StrLength(Msg->OtherNode) > 0;
459 void examine_rcpt(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
461 FreeStrBuf(&Msg->to);
462 Msg->to = NewStrBufPlain(NULL, StrLength(HdrLine));
463 StrBuf_RFC822_to_Utf8(Msg->to, HdrLine, WC->DefaultCharset, FoundCharset);
464 if (Msg->AllRcpt == NULL)
465 Msg->AllRcpt = NewStrBufPlain(NULL, StrLength(HdrLine));
466 if (StrLength(Msg->AllRcpt) > 0) {
467 StrBufAppendBufPlain(Msg->AllRcpt, HKEY(", "), 0);
469 StrBufAppendBuf(Msg->AllRcpt, Msg->to, 0);
471 void tmplput_MAIL_SUMM_TO(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
473 message_summary *Msg = (message_summary*) Context;
474 StrBufAppendBuf(Target, Msg->to, 0);
476 void tmplput_MAIL_SUMM_ALLRCPT(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
478 message_summary *Msg = (message_summary*) Context;
479 StrBufAppendBuf(Target, Msg->AllRcpt, 0);
484 void examine_time(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
486 Msg->date = StrTol(HdrLine);
488 void tmplput_MAIL_SUMM_DATE_STR(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
491 message_summary *Msg = (message_summary*) Context;
492 webcit_fmt_date(datebuf, Msg->date, 1);
493 StrBufAppendBufPlain(Target, datebuf, -1, 0);
495 void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
497 message_summary *Msg = (message_summary*) Context;
498 StrBufAppendPrintf(Target, "%ld", Msg->date, 0);
503 void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
505 wc_mime_attachment *mime;
508 mime = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
509 memset(mime, 0, sizeof(wc_mime_attachment));
512 mime->Name = NewStrBuf();
513 StrBufExtract_token(mime->Name, HdrLine, 0, '|');
515 StrBufExtract_token(Buf, HdrLine, 1, '|');
516 mime->FileName = NewStrBuf();
517 StrBuf_RFC822_to_Utf8(mime->FileName, Buf, WC->DefaultCharset, FoundCharset);
519 mime->PartNum = NewStrBuf();
520 StrBufExtract_token(mime->PartNum, HdrLine, 2, '|');
522 mime->Disposition = NewStrBuf();
523 StrBufExtract_token(mime->Disposition, HdrLine, 3, '|');
525 mime->ContentType = NewStrBuf();
526 StrBufExtract_token(mime->ContentType, HdrLine, 4, '|');
528 mime->length = StrBufExtract_int(HdrLine, 5, '|');
530 StrBufTrim(mime->Name);
531 StrBufTrim(mime->FileName);
533 if ( (StrLength(mime->FileName) == 0) && (StrLength(mime->Name) > 0) ) {
534 StrBufAppendBuf(mime->FileName, mime->Name, 0);
537 if (Msg->AllAttach == NULL)
538 Msg->AllAttach = NewHash(1,NULL);
539 Put(Msg->AllAttach, SKEY(mime->PartNum), mime, DestroyMime);
541 if (!strcasecmp(ChrPtr(mime->ContentType), "message/rfc822")) {
542 if (Msg->Submessages == NULL)
543 Msg->Submessages = NewHash(1,NULL);
544 Put(Msg->Submessages, SKEY(mime->PartNum), mime, reference_free_handler);
546 else if ((!strcasecmp(ChrPtr(mime->Disposition), "inline"))
547 && (!strncasecmp(ChrPtr(mime->ContentType), "image/", 6)) ){
548 if (Msg->AttachLinks == NULL)
549 Msg->AttachLinks = NewHash(1,NULL);
550 Put(Msg->AttachLinks, SKEY(mime->PartNum), mime, reference_free_handler);
552 else if ((StrLength(mime->ContentType) > 0) &&
553 ( (!strcasecmp(ChrPtr(mime->Disposition), "attachment"))
554 || (!strcasecmp(ChrPtr(mime->Disposition), "inline"))
555 || (!strcasecmp(ChrPtr(mime->Disposition), ""))))
558 if (Msg->AttachLinks == NULL)
559 Msg->AttachLinks = NewHash(1,NULL);
560 Put(Msg->AttachLinks, SKEY(mime->PartNum), mime, reference_free_handler);
561 if (strcasecmp(ChrPtr(mime->ContentType), "application/octet-stream") == 0) {
562 FlushStrBuf(mime->ContentType);
563 StrBufAppendBufPlain(mime->ContentType,
564 GuessMimeByFilename(SKEY(mime->FileName)),
569 /** begin handler prep ** */
570 if ( (!strcasecmp(ChrPtr(mime->ContentType), "text/x-vcard"))
571 || (!strcasecmp(ChrPtr(mime->ContentType), "text/vcard")) ) {
572 Msg->vcard_partnum_ref = mime;
574 else if ( (!strcasecmp(ChrPtr(mime->ContentType), "text/calendar"))
575 || (!strcasecmp(ChrPtr(mime->ContentType), "application/ics")) ) {
576 Msg->cal_partnum_ref = mime;
578 /** end handler prep ***/
583 void tmplput_MAIL_SUMM_NATTACH(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
585 message_summary *Msg = (message_summary*) Context;
586 StrBufAppendPrintf(Target, "%ld", GetCount(Msg->Attachments));
595 void examine_hnod(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
597 FreeStrBuf(&Msg->hnod);
598 Msg->hnod = NewStrBufPlain(NULL, StrLength(HdrLine));
599 StrBuf_RFC822_to_Utf8(Msg->hnod, HdrLine, WC->DefaultCharset, FoundCharset);
601 void tmplput_MAIL_SUMM_H_NODE(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
603 message_summary *Msg = (message_summary*) Context;
604 StrBufAppendBuf(Target, Msg->hnod, 0);
606 int Conditional_MAIL_SUMM_H_NODE(WCTemplateToken *Tokens, void *Context, int ContextType)
608 message_summary *Msg = (message_summary*) Context;
609 return StrLength(Msg->hnod) > 0;
614 void examine_text(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
615 {////TODO: read messages here
616 Msg->MsgBody.Data = NewStrBuf();
619 void examine_msg4_partnum(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
621 Msg->MsgBody.PartNum = NewStrBufDup(HdrLine);
622 StrBufTrim(Msg->MsgBody.PartNum);/////TODO: striplt == trim?
625 void examine_content_encoding(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
627 ////TODO: do we care?
630 void examine_content_lengh(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
632 Msg->MsgBody.length = StrTol(HdrLine);
633 Msg->MsgBody.size_known = 1;
636 void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
639 Msg->MsgBody.ContentType = NewStrBufDup(HdrLine);
640 StrBufTrim(Msg->MsgBody.ContentType);/////todo==striplt?
641 len = StrLength(Msg->MsgBody.ContentType);
642 for (i=0; i<len; ++i) {
643 if (!strncasecmp(ChrPtr(Msg->MsgBody.ContentType) + i, "charset=", 8)) {/// TODO: WHUT?
644 // safestrncpy(mime_charset, &mime_content_type[i+8],
645 /// sizeof mime_charset);
648 for (i=0; i<len; ++i) {
649 if (mime_content_type[i] == ';') {
650 mime_content_type[i] = 0;
654 len = strlen(mime_charset);
655 for (i=0; i<len; ++i) {
656 if (mime_charset[i] == ';') {
664 void tmplput_MAIL_SUMM_N(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
666 message_summary *Msg = (message_summary*) Context;
667 StrBufAppendPrintf(Target, "%ld", Msg->msgnum);
672 int Conditional_MAIL_MIME_ALL(WCTemplateToken *Tokens, void *Context, int ContextType)
674 message_summary *Msg = (message_summary*) Context;
675 return GetCount(Msg->Attachments) > 0;
678 int Conditional_MAIL_MIME_SUBMESSAGES(WCTemplateToken *Tokens, void *Context, int ContextType)
680 message_summary *Msg = (message_summary*) Context;
681 return GetCount(Msg->Submessages) > 0;
684 int Conditional_MAIL_MIME_ATTACHLINKS(WCTemplateToken *Tokens, void *Context, int ContextType)
686 message_summary *Msg = (message_summary*) Context;
687 return GetCount(Msg->AttachLinks) > 0;
690 int Conditional_MAIL_MIME_ATTACH(WCTemplateToken *Tokens, void *Context, int ContextType)
692 message_summary *Msg = (message_summary*) Context;
693 return GetCount(Msg->AllAttach) > 0;
698 /*----------------------------------------------------------------------------*/
701 void tmplput_MAIL_BODY(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
703 message_summary *Msg = (message_summary*) Context;
704 StrBufAppendBuf(Target, Msg->MsgBody.Data, 0);
708 void render_MAIL_variformat(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
710 /* Messages in legacy Citadel variformat get handled thusly... */
711 StrBuf *Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
712 FmOut(Target, "JUSTIFY", Mime->Data);
713 FreeStrBuf(&Mime->Data);
717 void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
720 const char *ptr, *pte;
721 const char *BufPtr = NULL;
722 StrBuf *Line = NewStrBuf();
723 StrBuf *Line1 = NewStrBuf();
724 StrBuf *Line2 = NewStrBuf();
725 StrBuf *Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
732 iconv_t ic = (iconv_t)(-1) ;
735 /* Boring old 80-column fixed format text gets handled this way... */
736 if ((strcasecmp(ChrPtr(Mime->Charset), "us-ascii") == 0) &&
737 (strcasecmp(ChrPtr(Mime->Charset), "UTF-8") == 0))
742 if (StrLength(Mime->Charset) != 0)
744 else if (StrLength(FoundCharset) > 0)
746 else if (StrLength(WC->DefaultCharset) > 0)
747 cs = WC->DefaultCharset;
752 ctdl_iconv_open("UTF-8", ChrPtr(cs), &ic);
753 if (ic == (iconv_t)(-1) ) {
754 lprintf(5, "%s:%d iconv_open(UTF-8, %s) failed: %s\n",
755 __FILE__, __LINE__, ChrPtr(Mime->Charset), strerror(errno));
761 while ((n = StrBufSipLine(Line, Mime->Data, &BufPtr), n >= 0) && !done)
767 len = StrLength(Line);
770 while ((ptr < pte) &&
779 if (i > 0) StrBufCutLeft(Line, i);
781 if (StrLength(Line) == 0)
784 for (i = bn; i < bq; i++)
785 StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
786 for (i = bq; i < bn; i++)
787 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
789 if (ConvertIt == 1) {
790 StrBufConvert(Line, Line1, &ic);
793 StrBufAppendBufPlain(Target, HKEY("<tt>"), 0);
794 UrlizeText(Line1, Line, Line2);
796 StrEscAppend(Target, Line1, NULL, 0, 0);
797 StrBufAppendBufPlain(Target, HKEY("</tt><br />\n"), 0);
801 for (i = 0; i < bn; i++)
802 StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
804 StrBufAppendBufPlain(Target, HKEY("</i><br />"), 0);
806 if (ic != (iconv_t)(-1) ) {
810 FreeStrBuf(&Mime->Data);
817 void render_MAIL_html(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
820 /* HTML is fun, but we've got to strip it first */
821 Buf = NewStrBufPlain(NULL, StrLength(Mime->Data));
822 output_html(ChrPtr(Mime->Charset),
823 (WC->wc_view == VIEW_WIKI ? 1 : 0),
824 StrToi(Mime->PartNum),
826 FreeStrBuf(&Mime->Data);
830 void render_MAIL_UNKNOWN(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
832 /* Unknown weirdness */
833 FlushStrBuf(Mime->Data);
834 StrBufAppendBufPlain(Mime->Data, _("I don't know how to display "), -1, 0);
835 StrBufAppendBuf(Mime->Data, Mime->ContentType, 0);
836 StrBufAppendBufPlain(Mime->Data, HKEY("<br />\n"), 0);
844 HashList *iterate_get_mime_All(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
846 message_summary *Msg = (message_summary*) Context;
847 return Msg->Attachments;
849 HashList *iterate_get_mime_Submessages(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
851 message_summary *Msg = (message_summary*) Context;
852 return Msg->Submessages;
854 HashList *iterate_get_mime_AttachLinks(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
856 message_summary *Msg = (message_summary*) Context;
857 return Msg->AttachLinks;
859 HashList *iterate_get_mime_Attachments(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
861 message_summary *Msg = (message_summary*) Context;
862 return Msg->AllAttach;
865 void tmplput_MIME_Name(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
867 wc_mime_attachment *mime = (wc_mime_attachment*) Context;
868 StrBufAppendBuf(Target, mime->Name, 0);
871 void tmplput_MIME_FileName(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
873 wc_mime_attachment *mime = (wc_mime_attachment*) Context;
874 StrBufAppendBuf(Target, mime->FileName, 0);
877 void tmplput_MIME_PartNum(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
879 wc_mime_attachment *mime = (wc_mime_attachment*) Context;
880 StrBufAppendBuf(Target, mime->PartNum, 0);
883 void tmplput_MIME_MsgNum(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
885 wc_mime_attachment *mime = (wc_mime_attachment*) Context;
886 StrBufAppendPrintf(Target, "%ld", mime->msgnum);
889 void tmplput_MIME_Disposition(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
891 wc_mime_attachment *mime = (wc_mime_attachment*) Context;
892 StrBufAppendBuf(Target, mime->Disposition, 0);
895 void tmplput_MIME_ContentType(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
897 wc_mime_attachment *mime = (wc_mime_attachment*) Context;
898 StrBufAppendBuf(Target, mime->ContentType, 0);
901 void tmplput_MIME_Charset(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
903 wc_mime_attachment *mime = (wc_mime_attachment*) Context;
904 StrBufAppendBuf(Target, mime->Charset, 0);
907 void tmplput_MIME_Data(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
909 wc_mime_attachment *mime = (wc_mime_attachment*) Context;
910 StrBufAppendBuf(Target, mime->Data, 0); /// TODO: check whether we need to load it now?
913 void tmplput_MIME_Length(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
915 wc_mime_attachment *mime = (wc_mime_attachment*) Context;
916 StrBufAppendPrintf(Target, "%ld", mime->length);
922 * Look for URL's embedded in a buffer and make them linkable. We use a
923 * target window in order to keep the Citadel session in its own window.
925 void UrlizeText(StrBuf* Target, StrBuf *Source, StrBuf *WrkBuf)
927 int len, UrlLen, Offset, TrailerLen;
928 const char *start, *end, *pos;
933 len = StrLength(Source);
934 end = ChrPtr(Source) + len;
935 for (pos = ChrPtr(Source); (pos < end) && (start == NULL); ++pos) {
936 if (!strncasecmp(pos, "http://", 7))
938 if (!strncasecmp(pos, "ftp://", 6))
943 StrBufAppendBuf(Target, Source, 0);
948 for (pos = ChrPtr(Source) + len; pos > start; --pos) {
949 if ( (!isprint(*pos))
968 UrlLen = end - start;
969 StrBufAppendBufPlain(WrkBuf, start, UrlLen, 0);
971 Offset = start - ChrPtr(Source);
973 StrBufAppendBufPlain(Target, ChrPtr(Source), Offset, 0);
974 StrBufAppendPrintf(Target, "%ca href=%c%s%c TARGET=%c%s%c%c%s%c/A%c",
975 LB, QU, ChrPtr(WrkBuf), QU, QU, TARGET,
976 QU, RB, ChrPtr(WrkBuf), LB, RB);
978 TrailerLen = len - (end - start);
980 StrBufAppendBufPlain(Target, end, TrailerLen, 0);
982 void url(char *buf, size_t bufsize)
984 int len, UrlLen, Offset, TrailerLen, outpos;
985 char *start, *end, *pos;
992 lprintf(1, "URL: content longer than buffer!");
996 for (pos = buf; (pos < end) && (start == NULL); ++pos) {
997 if (!strncasecmp(pos, "http://", 7))
999 if (!strncasecmp(pos, "ftp://", 6))
1006 for (pos = buf+len; pos > start; --pos) {
1007 if ( (!isprint(*pos))
1026 UrlLen = end - start;
1027 if (UrlLen > sizeof(urlbuf)){
1028 lprintf(1, "URL: content longer than buffer!");
1031 memcpy(urlbuf, start, UrlLen);
1032 urlbuf[UrlLen] = '\0';
1034 Offset = start - buf;
1035 if ((Offset != 0) && (Offset < sizeof(outbuf)))
1036 memcpy(outbuf, buf, Offset);
1037 outpos = snprintf(&outbuf[Offset], sizeof(outbuf) - Offset,
1038 "%ca href=%c%s%c TARGET=%c%s%c%c%s%c/A%c",
1039 LB, QU, urlbuf, QU, QU, TARGET, QU, RB, urlbuf, LB, RB);
1040 if (outpos >= sizeof(outbuf) - Offset) {
1041 lprintf(1, "URL: content longer than buffer!");
1045 TrailerLen = len - (end - start);
1047 memcpy(outbuf + Offset + outpos, end, TrailerLen);
1048 if (Offset + outpos + TrailerLen > bufsize) {
1049 lprintf(1, "URL: content longer than buffer!");
1052 memcpy (buf, outbuf, Offset + outpos + TrailerLen);
1053 *(buf + Offset + outpos + TrailerLen) = '\0';
1058 * \brief Turn a vCard "n" (name) field into something displayable.
1059 * \param name the name field to convert
1061 void vcard_n_prettyize(char *name)
1063 char *original_name;
1066 original_name = strdup(name);
1067 len = strlen(original_name);
1068 for (i=0; i<5; ++i) {
1070 if (original_name[len-1] == ' ') {
1071 original_name[--len] = 0;
1073 if (original_name[len-1] == ';') {
1074 original_name[--len] = 0;
1080 for (i=0; i<len; ++i) {
1081 if (original_name[i] == ';') {
1086 name[j++] = original_name[i];
1090 free(original_name);
1097 * \brief preparse a vcard name
1098 * display_vcard() calls this after parsing the textual vCard into
1099 * our 'struct vCard' data object.
1100 * This gets called instead of display_parsed_vcard() if we are only looking
1101 * to extract the person's name instead of displaying the card.
1102 * \param v the vcard to retrieve the name from
1103 * \param storename where to put the name at
1105 void fetchname_parsed_vcard(struct vCard *v, char *storename) {
1108 strcpy(storename, "");
1110 name = vcard_get_prop(v, "n", 1, 0, 0);
1112 strcpy(storename, name);
1113 /* vcard_n_prettyize(storename); */
1121 * \brief html print a vcard
1122 * display_vcard() calls this after parsing the textual vCard into
1123 * our 'struct vCard' data object.
1125 * Set 'full' to nonzero to display the full card, otherwise it will only
1126 * show a summary line.
1128 * This code is a bit ugly, so perhaps an explanation is due: we do this
1129 * in two passes through the vCard fields. On the first pass, we process
1130 * fields we understand, and then render them in a pretty fashion at the
1131 * end. Then we make a second pass, outputting all the fields we don't
1132 * understand in a simple two-column name/value format.
1133 * \param v the vCard to display
1134 * \param full display all items of the vcard?
1135 * \param msgnum Citadel message pointer
1137 void display_parsed_vcard(struct vCard *v, int full, long msgnum) {
1143 char *thisname, *thisvalue;
1144 char firsttoken[SIZ];
1153 strcpy(fullname, "");
1161 name = vcard_get_prop(v, "fn", 1, 0, 0);
1165 else if (name = vcard_get_prop(v, "n", 1, 0, 0), name != NULL) {
1166 strcpy(fullname, name);
1167 vcard_n_prettyize(fullname);
1177 wprintf("<div align=center>"
1178 "<table bgcolor=#aaaaaa width=50%%>");
1179 for (pass=1; pass<=2; ++pass) {
1181 if (v->numprops) for (i=0; i<(v->numprops); ++i) {
1183 thisname = strdup(v->prop[i].name);
1184 extract_token(firsttoken, thisname, 0, ';', sizeof firsttoken);
1186 for (j=0; j<num_tokens(thisname, ';'); ++j) {
1187 extract_token(buf, thisname, j, ';', sizeof buf);
1188 if (!strcasecmp(buf, "encoding=quoted-printable")) {
1190 remove_token(thisname, j, ';');
1192 if (!strcasecmp(buf, "encoding=base64")) {
1194 remove_token(thisname, j, ';');
1198 len = strlen(v->prop[i].value);
1199 /* if we have some untagged QP, detect it here. */
1200 if (!is_qp && (strstr(v->prop[i].value, "=?")!=NULL))
1201 utf8ify_rfc822_string(v->prop[i].value);
1204 // %ff can become 6 bytes in utf8
1205 thisvalue = malloc(len * 2 + 3);
1206 j = CtdlDecodeQuotedPrintable(
1207 thisvalue, v->prop[i].value,
1212 // ff will become one byte..
1213 thisvalue = malloc(len + 50);
1215 thisvalue, v->prop[i].value,
1216 strlen(v->prop[i].value) );
1219 thisvalue = strdup(v->prop[i].value);
1222 /** Various fields we may encounter ***/
1224 /** N is name, but only if there's no FN already there */
1225 if (!strcasecmp(firsttoken, "n")) {
1226 if (IsEmptyStr(fullname)) {
1227 strcpy(fullname, thisvalue);
1228 vcard_n_prettyize(fullname);
1232 /** FN (full name) is a true 'display name' field */
1233 else if (!strcasecmp(firsttoken, "fn")) {
1234 strcpy(fullname, thisvalue);
1238 else if (!strcasecmp(firsttoken, "title")) {
1239 strcpy(title, thisvalue);
1243 else if (!strcasecmp(firsttoken, "org")) {
1244 strcpy(org, thisvalue);
1247 else if (!strcasecmp(firsttoken, "email")) {
1249 if (!IsEmptyStr(mailto)) strcat(mailto, "<br />");
1251 "<a href=\"display_enter"
1252 "?force_room=_MAIL_?recp=");
1254 len = strlen(mailto);
1255 urlesc(&mailto[len], SIZ - len, "\"");
1256 len = strlen(mailto);
1257 urlesc(&mailto[len], SIZ - len, fullname);
1258 len = strlen(mailto);
1259 urlesc(&mailto[len], SIZ - len, "\" <");
1260 len = strlen(mailto);
1261 urlesc(&mailto[len], SIZ - len, thisvalue);
1262 len = strlen(mailto);
1263 urlesc(&mailto[len], SIZ - len, ">");
1265 strcat(mailto, "\">");
1266 len = strlen(mailto);
1267 stresc(mailto+len, SIZ - len, thisvalue, 1, 1);
1268 strcat(mailto, "</A>");
1270 else if (!strcasecmp(firsttoken, "tel")) {
1271 if (!IsEmptyStr(phone)) strcat(phone, "<br />");
1272 strcat(phone, thisvalue);
1273 for (j=0; j<num_tokens(thisname, ';'); ++j) {
1274 extract_token(buf, thisname, j, ';', sizeof buf);
1275 if (!strcasecmp(buf, "tel"))
1277 else if (!strcasecmp(buf, "work"))
1278 strcat(phone, _(" (work)"));
1279 else if (!strcasecmp(buf, "home"))
1280 strcat(phone, _(" (home)"));
1281 else if (!strcasecmp(buf, "cell"))
1282 strcat(phone, _(" (cell)"));
1284 strcat(phone, " (");
1290 else if (!strcasecmp(firsttoken, "adr")) {
1292 wprintf("<TR><TD>");
1293 wprintf(_("Address:"));
1294 wprintf("</TD><TD>");
1295 for (j=0; j<num_tokens(thisvalue, ';'); ++j) {
1296 extract_token(buf, thisvalue, j, ';', sizeof buf);
1297 if (!IsEmptyStr(buf)) {
1299 if (j<3) wprintf("<br />");
1303 wprintf("</TD></TR>\n");
1306 /* else if (!strcasecmp(firsttoken, "photo") && full && pass == 2) {
1307 // Only output on second pass
1308 wprintf("<tr><td>");
1309 wprintf(_("Photo:"));
1310 wprintf("</td><td>");
1311 wprintf("<img src=\"/vcardphoto/%ld/\" alt=\"Contact photo\"/>",msgnum);
1312 wprintf("</td></tr>\n");
1314 else if (!strcasecmp(firsttoken, "version")) {
1317 else if (!strcasecmp(firsttoken, "rev")) {
1320 else if (!strcasecmp(firsttoken, "label")) {
1325 /*** Don't show extra fields. They're ugly.
1327 wprintf("<TR><TD>");
1329 wprintf("</TD><TD>");
1331 wprintf("</TD></TR>\n");
1341 wprintf("<TR BGCOLOR=\"#AAAAAA\">"
1342 "<TD COLSPAN=2 BGCOLOR=\"#FFFFFF\">"
1343 "<IMG ALIGN=CENTER src=\"static/viewcontacts_48x.gif\">"
1344 "<FONT SIZE=+1><B>");
1346 wprintf("</B></FONT>");
1347 if (!IsEmptyStr(title)) {
1348 wprintf("<div align=right>");
1352 if (!IsEmptyStr(org)) {
1353 wprintf("<div align=right>");
1357 wprintf("</TD></TR>\n");
1359 if (!IsEmptyStr(phone)) {
1360 wprintf("<tr><td>");
1361 wprintf(_("Telephone:"));
1362 wprintf("</td><td>%s</td></tr>\n", phone);
1364 if (!IsEmptyStr(mailto)) {
1365 wprintf("<tr><td>");
1366 wprintf(_("E-mail:"));
1367 wprintf("</td><td>%s</td></tr>\n", mailto);
1373 wprintf("</table></div>\n");
1379 * \brief Display a textual vCard
1380 * (Converts to a vCard object and then calls the actual display function)
1381 * Set 'full' to nonzero to display the whole card instead of a one-liner.
1382 * Or, if "storename" is non-NULL, just store the person's name in that
1383 * buffer instead of displaying the card at all.
1384 * \param vcard_source the buffer containing the vcard text
1385 * \param alpha what???
1386 * \param full should we usse all lines?
1387 * \param storename where to store???
1388 * \param msgnum Citadel message pointer
1390 void display_vcard(char *vcard_source, char alpha, int full, char *storename,
1395 char this_alpha = 0;
1397 v = vcard_load(vcard_source);
1398 if (v == NULL) return;
1400 name = vcard_get_prop(v, "n", 1, 0, 0);
1402 utf8ify_rfc822_string(name);
1404 this_alpha = buf[0];
1407 if (storename != NULL) {
1408 fetchname_parsed_vcard(v, storename);
1410 else if ( (alpha == 0)
1411 || ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha)) )
1412 || ((!isalpha(alpha)) && (!isalpha(this_alpha)))
1414 display_parsed_vcard(v, full,msgnum);
1432 * I wanna SEE that message!
1434 * msgnum Message number to display
1435 * printable_view Nonzero to display a printable view
1436 * section Optional for encapsulated message/rfc822 submessage
1438 void read_message(long msgnum, int printable_view, char *section) {
1439 struct wcsession *WCC = WC;
1442 StrBuf *FoundCharset;
1443 message_summary *Msg = NULL;
1447 struct attach_link *attach_links = NULL;
1448 int num_attach_links = 0;
1449 // char mime_submessages[256] = "";
1450 char reply_references[1024] = "";
1454 char vcard_partnum[256] = "";
1455 char cal_partnum[256] = "";
1456 char *part_source = NULL;
1457 char msg4_partnum[32] = "";
1459 //// strcpy(mime_submessages, "");
1462 serv_printf("MSG4 %ld|%s", msgnum, section);
1463 StrBuf_ServGetln(Buf);
1464 if (GetServerStatus(Buf, NULL) != 1) {
1465 wprintf("<strong>");
1466 wprintf(_("ERROR:"));
1467 wprintf("</strong> %s<br />\n", &buf[4]);
1471 svputlong("MsgPrintable", printable_view);
1472 /** begin everythingamundo table */
1475 Token = NewStrBuf();
1476 Msg = (message_summary *)malloc(sizeof(message_summary));
1477 memset(Msg, 0, sizeof(message_summary));
1478 Msg->msgnum = msgnum;
1479 FoundCharset = NewStrBuf();
1480 while ((StrBuf_ServGetln(Buf)>=0) && !Done) {
1481 if ( (StrLength(Buf)==3) &&
1482 !strcmp(ChrPtr(Buf), "000"))
1487 wprintf(_("unexpected end of message"));
1488 wprintf(" (1)</i><br /><br />\n");
1489 wprintf("</div>\n");
1492 DestroyMessageSummary(Msg);
1493 FreeStrBuf(&FoundCharset);
1501 case 0:/* Citadel Message Headers */
1502 if (StrLength(Buf) == 0) {
1506 StrBufExtract_token(Token, Buf, 0, '=');
1507 StrBufCutLeft(Buf, StrLength(Token) + 1);
1509 lprintf(1, ":: [%s] = [%s]\n", ChrPtr(Token), ChrPtr(Buf));
1510 if (GetHash(MsgHeaderHandler, SKEY(Token), &vHdr) &&
1512 Hdr = (headereval*)vHdr;
1513 Hdr->evaluator(Msg, Buf, FoundCharset);
1514 if (Hdr->Type == 1) {
1518 else lprintf(1, "don't know how to handle message header[%s]\n", ChrPtr(Token));
1520 case 1:/* Message Mime Header */
1521 if (StrLength(Buf) == 0) {
1523 if (Msg->MsgBody.ContentType == NULL)
1524 /* end of header or no header? */
1525 Msg->MsgBody.ContentType = NewStrBufPlain(HKEY("text/plain"));
1526 /* usual end of mime header */
1530 StrBufExtract_token(Token, Buf, 0, ':');
1531 if (StrLength(Token) > 0) {
1532 StrBufCutLeft(Buf, StrLength(Token) + 1);
1533 lprintf(1, ":: [%s] = [%s]\n", ChrPtr(Token), ChrPtr(Buf));
1534 if (GetHash(MsgHeaderHandler, SKEY(Token), &vHdr) &&
1536 Hdr = (headereval*)vHdr;
1537 Hdr->evaluator(Msg, Buf, FoundCharset);
1542 case 2: /* Message Body */
1544 if (Msg->MsgBody.size_known > 0) {
1545 StrBuf_ServGetBLOB(Msg->MsgBody.Data, Msg->MsgBody.length);
1547 /// todo: check next line, if not 000, append following lines
1550 if (StrLength(Msg->MsgBody.Data) > 0)
1551 StrBufAppendBufPlain(Msg->MsgBody.Data, "\n", 1, 0);
1552 StrBufAppendBuf(Msg->MsgBody.Data, Buf, 0);
1556 StrBufAppendBuf(Msg->MsgBody.Data, Buf, 0);
1561 /* strip the bare contenttype, so we ommit charset etc. */
1562 StrBufExtract_token(Buf, Msg->MsgBody.ContentType, 0, ';');
1564 if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
1566 RenderMimeFunc Render;
1567 Render = (RenderMimeFunc)vHdr;
1568 Render(&Msg->MsgBody, NULL, FoundCharset);
1572 if (StrLength(Msg->reply_references)> 0) {
1573 /* Trim down excessively long lists of thread references. We eliminate the
1574 * second one in the list so that the thread root remains intact.
1576 int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|');
1577 int rrlen = StrLength(Msg->reply_references);
1578 if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
1579 remove_token(reply_references, 1, '|');////todo
1583 /* Generate a reply-to address */
1584 if (StrLength(Msg->Rfca) > 0) {
1585 if (Msg->reply_to == NULL)
1586 Msg->reply_to = NewStrBuf();
1587 if (StrLength(Msg->from) > 0) {
1588 StrBufPrintf(Msg->reply_to, "%s <%s>", ChrPtr(Msg->from), ChrPtr(Msg->Rfca));
1591 FlushStrBuf(Msg->reply_to);
1592 StrBufAppendBuf(Msg->reply_to, Msg->Rfca, 0);
1597 if ((StrLength(Msg->OtherNode)>0) &&
1598 (strcasecmp(ChrPtr(Msg->OtherNode), serv_info.serv_nodename)) &&
1599 (strcasecmp(ChrPtr(Msg->OtherNode), serv_info.serv_humannode)) )
1601 if (Msg->reply_to == NULL)
1602 Msg->reply_to = NewStrBuf();
1603 StrBufPrintf(Msg->reply_to,
1606 ChrPtr(Msg->OtherNode));
1609 if (Msg->reply_to == NULL)
1610 Msg->reply_to = NewStrBuf();
1611 FlushStrBuf(Msg->reply_to);
1612 StrBufAppendBuf(Msg->reply_to, Msg->from, 0);
1615 DoTemplate(HKEY("view_message"), NULL, Msg, CTX_MAILSUM);
1619 //// put message renderer lookup here.
1620 ///ENDBODY: /* If there are attached submessages, display them now... */
1622 /// if ( (!IsEmptyStr(mime_submessages)) && (!section[0]) ) {
1623 /// for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
1624 /// extract_token(buf, mime_submessages, i, '|', sizeof buf);
1625 /// /** use printable_view to suppress buttons */
1626 /// wprintf("<blockquote>");
1627 /// read_message(msgnum, 1, buf);
1628 /// wprintf("</blockquote>");
1633 /* Afterwards, offer links to download attachments 'n' such */
1634 if ( (num_attach_links > 0) && (!section[0]) ) {
1635 for (i=0; i<num_attach_links; ++i) {
1636 if (strcasecmp(attach_links[i].partnum, msg4_partnum)) {
1637 wprintf("%s", attach_links[i].html);
1642 /* Handler for vCard parts */
1643 if (!IsEmptyStr(vcard_partnum)) {
1644 part_source = load_mimepart(msgnum, vcard_partnum);
1645 if (part_source != NULL) {
1647 /** If it's my vCard I can edit it */
1648 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
1649 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
1650 || (WC->wc_view == VIEW_ADDRESSBOOK)
1652 wprintf("<a href=\"edit_vcard?msgnum=%ld&partnum=%s\">",
1653 msgnum, vcard_partnum);
1654 wprintf("[%s]</a>", _("edit"));
1657 /* In all cases, display the full card */
1658 display_vcard(part_source, 0, 1, NULL,msgnum);
1662 /* Handler for calendar parts */
1663 if (!IsEmptyStr(cal_partnum)) {
1664 part_source = load_mimepart(msgnum, cal_partnum);
1665 if (part_source != NULL) {
1666 cal_process_attachment(part_source, msgnum, cal_partnum);
1675 wprintf("</div>\n");
1677 /* end everythingamundo table */
1678 if (!printable_view) {
1679 wprintf("</div>\n");
1682 if (num_attach_links > 0) {
1685 DestroyMessageSummary(Msg);
1686 FreeStrBuf(&FoundCharset);
1694 * Unadorned HTML output of an individual message, suitable
1695 * for placing in a hidden iframe, for printing, or whatever
1697 * msgnum_as_string == Message number, as a string instead of as a long int
1699 void embed_message(void) {
1702 msgnum = StrTol(WC->UrlFragment1);
1703 read_message(msgnum, 0, "");
1708 * Printable view of a message
1710 * msgnum_as_string == Message number, as a string instead of as a long int
1712 void print_message(void) {
1715 msgnum = StrTol(WC->UrlFragment1);
1716 output_headers(0, 0, 0, 0, 0, 0);
1718 hprintf("Content-type: text/html\r\n"
1720 "Connection: close\r\n",
1724 wprintf("\r\n<html>\n<head><title>");
1725 escputs(WC->wc_fullname);
1726 wprintf("</title></head>\n"
1727 "<body onLoad=\" window.print(); window.close(); \">\n"
1730 read_message(msgnum, 1, "");
1732 wprintf("\n</body></html>\n\n");
1737 * Mobile browser view of message
1739 * @param msg_num_as_string Message number as a string instead of as a long int
1741 void mobile_message_view(void) {
1743 msgnum = StrTol(WC->UrlFragment1);
1744 output_headers(1, 0, 0, 0, 0, 1);
1746 do_template("msgcontrols", NULL);
1747 read_message(msgnum,1, "");
1752 * \brief Display a message's headers
1754 * \param msgnum_as_string Message number, as a string instead of as a long int
1756 void display_headers(void) {
1760 msgnum = StrTol(WC->UrlFragment1);
1761 output_headers(0, 0, 0, 0, 0, 0);
1763 hprintf("Content-type: text/plain\r\n"
1765 "Connection: close\r\n",
1769 serv_printf("MSG2 %ld|3", msgnum);
1770 serv_getln(buf, sizeof buf);
1771 if (buf[0] == '1') {
1772 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1773 wprintf("%s\n", buf);
1783 * \brief Read message in simple, JavaScript-embeddable form for 'forward'
1784 * or 'reply quoted' operations.
1786 * NOTE: it is VITALLY IMPORTANT that we output no single-quotes or linebreaks
1787 * in this function. Doing so would throw a JavaScript error in the
1788 * 'supplied text' argument to the editor.
1790 * \param msgnum Message number of the message we want to quote
1791 * \param forward_attachments Nonzero if we want attachments to be forwarded
1793 void pullquote_message(long msgnum, int forward_attachments, int include_headers) {
1795 char mime_partnum[256];
1796 char mime_filename[256];
1797 char mime_content_type[256];
1798 char mime_charset[256];
1799 char mime_disposition[256];
1801 char *attachments = NULL;
1803 int num_attachments = 0;
1804 struct wc_attachment *att, *aptr;
1805 char m_subject[1024];
1812 int format_type = 0;
1817 iconv_t ic = (iconv_t)(-1) ;
1818 char *ibuf; /**< Buffer of characters to be converted */
1819 char *obuf; /**< Buffer for converted characters */
1820 size_t ibuflen; /**< Length of input buffer */
1821 size_t obuflen; /**< Length of output buffer */
1822 char *osav; /**< Saved pointer to output buffer */
1828 strcpy(reply_to, "");
1829 strcpy(mime_content_type, "text/plain");
1830 strcpy(mime_charset, "us-ascii");
1832 serv_printf("MSG4 %ld", msgnum);
1833 serv_getln(buf, sizeof buf);
1834 if (buf[0] != '1') {
1835 wprintf(_("ERROR:"));
1836 wprintf("%s<br />", &buf[4]);
1840 strcpy(m_subject, "");
1842 while (serv_getln(buf, sizeof buf), strcasecmp(buf, "text")) {
1843 if (!strcmp(buf, "000")) {
1844 wprintf("%s (3)", _("unexpected end of message"));
1847 if (include_headers) {
1848 if (!strncasecmp(buf, "nhdr=yes", 8))
1852 if (!strncasecmp(buf, "type=", 5))
1853 format_type = atoi(&buf[5]);
1854 if (!strncasecmp(buf, "from=", 5)) {
1855 strcpy(from, &buf[5]);
1856 wprintf(_("from "));
1857 utf8ify_rfc822_string(from);
1860 if (!strncasecmp(buf, "subj=", 5)) {
1861 strcpy(m_subject, &buf[5]);
1863 if ((!strncasecmp(buf, "hnod=", 5))
1864 && (strcasecmp(&buf[5], serv_info.serv_humannode))) {
1865 wprintf("(%s) ", &buf[5]);
1867 if ((!strncasecmp(buf, "room=", 5))
1868 && (strcasecmp(&buf[5], WC->wc_roomname))
1869 && (!IsEmptyStr(&buf[5])) ) {
1871 wprintf("%s> ", &buf[5]);
1873 if (!strncasecmp(buf, "rfca=", 5)) {
1874 strcpy(rfca, &buf[5]);
1879 if (!strncasecmp(buf, "node=", 5)) {
1880 strcpy(node, &buf[5]);
1881 if ( ((WC->room_flags & QR_NETWORK)
1882 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
1883 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
1884 && (IsEmptyStr(rfca))
1886 wprintf("@%s ", &buf[5]);
1889 if (!strncasecmp(buf, "rcpt=", 5)) {
1891 strcpy(to, &buf[5]);
1892 utf8ify_rfc822_string(to);
1895 if (!strncasecmp(buf, "time=", 5)) {
1896 webcit_fmt_date(now, atol(&buf[5]), 0);
1897 wprintf("%s ", now);
1902 * Save attachment info for later. We can't start downloading them
1903 * yet because we're in the middle of a server transaction.
1905 if (!strncasecmp(buf, "part=", 5)) {
1906 ptr = malloc( (strlen(buf) + ((attachments != NULL) ? strlen(attachments) : 0)) ) ;
1909 sprintf(ptr, "%s%s\n",
1910 ((attachments != NULL) ? attachments : ""),
1915 lprintf(9, "attachments=<%s>\n", attachments);
1921 if (include_headers) {
1924 utf8ify_rfc822_string(m_subject);
1925 if (!IsEmptyStr(m_subject)) {
1926 wprintf(_("Subject:"));
1928 msgescputs(m_subject);
1939 * Learn the content type
1941 strcpy(mime_content_type, "text/plain");
1942 while (serv_getln(buf, sizeof buf), (!IsEmptyStr(buf))) {
1943 if (!strcmp(buf, "000")) {
1944 wprintf("%s (4)", _("unexpected end of message"));
1947 if (!strncasecmp(buf, "Content-type: ", 14)) {
1949 safestrncpy(mime_content_type, &buf[14],
1950 sizeof(mime_content_type));
1951 for (i=0; i<strlen(mime_content_type); ++i) {
1952 if (!strncasecmp(&mime_content_type[i], "charset=", 8)) {
1953 safestrncpy(mime_charset, &mime_content_type[i+8],
1954 sizeof mime_charset);
1957 len = strlen(mime_content_type);
1958 for (i=0; i<len; ++i) {
1959 if (mime_content_type[i] == ';') {
1960 mime_content_type[i] = 0;
1964 len = strlen(mime_charset);
1965 for (i=0; i<len; ++i) {
1966 if (mime_charset[i] == ';') {
1967 mime_charset[i] = 0;
1974 /** Set up a character set conversion if we need to (and if we can) */
1976 if ( (strcasecmp(mime_charset, "us-ascii"))
1977 && (strcasecmp(mime_charset, "UTF-8"))
1978 && (strcasecmp(mime_charset, ""))
1980 ctdl_iconv_open("UTF-8", mime_charset, &ic);
1981 if (ic == (iconv_t)(-1) ) {
1982 lprintf(5, "%s:%d iconv_open(%s, %s) failed: %s\n",
1983 __FILE__, __LINE__, "UTF-8", mime_charset, strerror(errno));
1988 /** Messages in legacy Citadel variformat get handled thusly... */
1989 if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
1993 /* Boring old 80-column fixed format text gets handled this way... */
1994 else if (!strcasecmp(mime_content_type, "text/plain")) {
1995 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1998 if ((len > 0) && (buf[len-1] == '\n')) buf[--len] = 0;
1999 if ((len > 0) && (buf[len-1] == '\r')) buf[--len] = 0;
2002 if (ic != (iconv_t)(-1) ) {
2006 obuf = (char *) malloc(obuflen);
2008 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
2009 osav[SIZ-obuflen] = 0;
2010 safestrncpy(buf, osav, sizeof buf);
2016 while ((!IsEmptyStr(buf)) && (isspace(buf[len - 1])))
2019 ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) )) {
2020 wprintf("<blockquote>");
2022 } else if ((bq == 1) &&
2023 (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) ) {
2024 wprintf("</blockquote>");
2028 url(buf, sizeof(buf));
2030 wprintf("</tt><br />");
2032 wprintf("</i><br />");
2035 /** HTML just gets escaped and stuffed back into the editor */
2036 else if (!strcasecmp(mime_content_type, "text/html")) {
2037 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2041 }//// TODO: charset? utf8?
2043 /** Unknown weirdness ... don't know how to handle this content type */
2045 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { }
2049 /** end of body handler */
2052 * If there were attachments, we have to download them and insert them
2053 * into the attachment chain for the forwarded message we are composing.
2055 if ( (forward_attachments) && (num_attachments) ) {
2056 for (i=0; i<num_attachments; ++i) {
2057 extract_token(buf, attachments, i, '\n', sizeof buf);
2058 extract_token(mime_filename, buf, 1, '|', sizeof mime_filename);
2059 extract_token(mime_partnum, buf, 2, '|', sizeof mime_partnum);
2060 extract_token(mime_disposition, buf, 3, '|', sizeof mime_disposition);
2061 extract_token(mime_content_type, buf, 4, '|', sizeof mime_content_type);
2062 mime_length = extract_int(buf, 5);
2065 * tracing ... uncomment if necessary
2068 lprintf(9, "fwd filename: %s\n", mime_filename);
2069 lprintf(9, "fwd partnum : %s\n", mime_partnum);
2070 lprintf(9, "fwd conttype: %s\n", mime_content_type);
2071 lprintf(9, "fwd dispose : %s\n", mime_disposition);
2072 lprintf(9, "fwd length : %d\n", mime_length);
2074 if ( (!strcasecmp(mime_disposition, "inline"))
2075 || (!strcasecmp(mime_disposition, "attachment")) ) {
2077 /* Create an attachment struct from this mime part... */
2078 att = malloc(sizeof(struct wc_attachment));
2079 memset(att, 0, sizeof(struct wc_attachment));
2080 att->length = mime_length;
2081 strcpy(att->content_type, mime_content_type);
2082 strcpy(att->filename, mime_filename);
2084 att->data = load_mimepart(msgnum, mime_partnum);
2086 /* And add it to the list. */
2087 if (WC->first_attachment == NULL) {
2088 WC->first_attachment = att;
2091 aptr = WC->first_attachment;
2092 while (aptr->next != NULL) aptr = aptr->next;
2101 if (ic != (iconv_t)(-1) ) {
2106 if (attachments != NULL) {
2114 void EvaluateMimePart(message_summary *Sum, StrBuf *Buf)
2117 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
2118 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
2119 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
2120 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
2121 mime_length = extract_int(&buf[5], 5);
2123 if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
2124 || (!strcasecmp(mime_content_type, "text/vcard")) ) {
2125 strcpy(vcard_partnum, mime_partnum);
2130 message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, long MsgNum)
2133 MsgPartEvaluatorFunc Eval;
2134 message_summary *Msg;
2143 serv_printf("MSG0 %ld|1", MsgNum); /* ask for headers only */
2145 StrBuf_ServGetln(Buf);
2146 if (GetServerStatus(Buf, NULL) == 1) {
2151 Msg = (message_summary*)malloc(sizeof(message_summary));
2152 memset(Msg, 0, sizeof(message_summary));
2153 while (len = StrBuf_ServGetln(Buf),
2155 strcmp(ChrPtr(Buf), "000")== 0)){
2157 ebuf = strchr(ChrPtr(Buf), '=');
2159 if (GetHash(MsgEvaluators, buf, nBuf, &vEval) && vEval != NULL) {
2160 Eval = (MsgPartEvaluatorFunc) vEval;
2161 StrBufCutLeft(Buf, nBuf + 1);
2164 else lprintf(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
2171 * \brief display the adressbook overview
2172 * \param msgnum the citadel message number
2173 * \param alpha what????
2175 void display_addressbook(long msgnum, char alpha) {
2177 /* char mime_partnum[SIZ]; */
2178 /* char mime_filename[SIZ]; */
2179 /* char mime_content_type[SIZ]; */
2180 ///char mime_disposition[SIZ];
2182 char vcard_partnum[SIZ];
2183 char *vcard_source = NULL;
2184 message_summary summ;////TODO: this will leak
2186 memset(&summ, 0, sizeof(summ));
2187 ///safestrncpy(summ.subj, _("(no subject)"), sizeof summ.subj);
2188 ///Load Message headers
2190 if (!IsEmptyStr(vcard_partnum)) {
2191 vcard_source = load_mimepart(msgnum, vcard_partnum);
2192 if (vcard_source != NULL) {
2194 /** Display the summary line */
2195 display_vcard(vcard_source, alpha, 0, NULL,msgnum);
2197 /** If it's my vCard I can edit it */
2198 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
2199 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
2200 || (WC->wc_view == VIEW_ADDRESSBOOK)
2202 wprintf("<a href=\"edit_vcard?"
2203 "msgnum=%ld&partnum=%s\">",
2204 msgnum, vcard_partnum);
2205 wprintf("[%s]</a>", _("edit"));
2217 * \brief If it's an old "Firstname Lastname" style record, try to convert it.
2218 * \param namebuf name to analyze, reverse if nescessary
2220 void lastfirst_firstlast(char *namebuf) {
2221 char firstname[SIZ];
2225 if (namebuf == NULL) return;
2226 if (strchr(namebuf, ';') != NULL) return;
2228 i = num_tokens(namebuf, ' ');
2231 extract_token(lastname, namebuf, i-1, ' ', sizeof lastname);
2232 remove_token(namebuf, i-1, ' ');
2233 strcpy(firstname, namebuf);
2234 sprintf(namebuf, "%s; %s", lastname, firstname);
2238 * \brief fetch what??? name
2239 * \param msgnum the citadel message number
2240 * \param namebuf where to put the name in???
2242 void fetch_ab_name(message_summary *Msg, char *namebuf) {
2244 char mime_partnum[SIZ];
2245 char mime_filename[SIZ];
2246 char mime_content_type[SIZ];
2247 char mime_disposition[SIZ];
2249 char vcard_partnum[SIZ];
2250 char *vcard_source = NULL;
2252 message_summary summ;/// TODO this will lak
2254 if (namebuf == NULL) return;
2255 strcpy(namebuf, "");
2257 memset(&summ, 0, sizeof(summ));
2258 //////safestrncpy(summ.subj, "(no subject)", sizeof summ.subj);
2260 sprintf(buf, "MSG0 %ld|0", Msg->msgnum); /** unfortunately we need the mime info now */
2262 serv_getln(buf, sizeof buf);
2263 if (buf[0] != '1') return;
2265 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2266 if (!strncasecmp(buf, "part=", 5)) {
2267 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
2268 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
2269 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
2270 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
2271 mime_length = extract_int(&buf[5], 5);
2273 if ( (!strcasecmp(mime_content_type, "text/x-vcard"))
2274 || (!strcasecmp(mime_content_type, "text/vcard")) ) {
2275 strcpy(vcard_partnum, mime_partnum);
2281 if (!IsEmptyStr(vcard_partnum)) {
2282 vcard_source = load_mimepart(Msg->msgnum, vcard_partnum);
2283 if (vcard_source != NULL) {
2285 /* Grab the name off the card */
2286 display_vcard(vcard_source, 0, 0, namebuf, Msg->msgnum);
2292 lastfirst_firstlast(namebuf);
2294 len = strlen(namebuf);
2295 for (i=0; i<len; ++i) {
2296 if (namebuf[i] != ';') return;
2298 strcpy(namebuf, _("(no name)"));
2304 * \brief Record compare function for sorting address book indices
2305 * \param ab1 adressbook one
2306 * \param ab2 adressbook two
2308 int abcmp(const void *ab1, const void *ab2) {
2310 (((const struct addrbookent *)ab1)->ab_name),
2311 (((const struct addrbookent *)ab2)->ab_name)
2317 * \brief Helper function for do_addrbook_view()
2318 * Converts a name into a three-letter tab label
2319 * \param tabbuf the tabbuffer to add name to
2320 * \param name the name to add to the tabbuffer
2322 void nametab(char *tabbuf, long len, char *name) {
2323 stresc(tabbuf, len, name, 0, 0);
2324 tabbuf[0] = toupper(tabbuf[0]);
2325 tabbuf[1] = tolower(tabbuf[1]);
2326 tabbuf[2] = tolower(tabbuf[2]);
2332 * \brief Render the address book using info we gathered during the scan
2333 * \param addrbook the addressbook to render
2334 * \param num_ab the number of the addressbook
2336 void do_addrbook_view(struct addrbookent *addrbook, int num_ab) {
2340 static int NAMESPERPAGE = 60;
2343 char tabfirst_label[64];
2345 char tablast_label[64];
2346 char this_tablabel[64];
2351 wprintf("<br /><br /><br /><div align=\"center\"><i>");
2352 wprintf(_("This address book is empty."));
2353 wprintf("</i></div>\n");
2358 qsort(addrbook, num_ab, sizeof(struct addrbookent), abcmp);
2361 num_pages = (num_ab / NAMESPERPAGE) + 1;
2363 tablabels = malloc(num_pages * sizeof (char *));
2364 if (tablabels == NULL) {
2365 wprintf("<br /><br /><br /><div align=\"center\"><i>");
2366 wprintf(_("An internal error has occurred."));
2367 wprintf("</i></div>\n");
2371 for (i=0; i<num_pages; ++i) {
2372 tabfirst = i * NAMESPERPAGE;
2373 tablast = tabfirst + NAMESPERPAGE - 1;
2374 if (tablast > (num_ab - 1)) tablast = (num_ab - 1);
2375 nametab(tabfirst_label, 64, addrbook[tabfirst].ab_name);
2376 nametab(tablast_label, 64, addrbook[tablast].ab_name);
2377 sprintf(this_tablabel, "%s - %s", tabfirst_label, tablast_label);
2378 tablabels[i] = strdup(this_tablabel);
2381 tabbed_dialog(num_pages, tablabels);
2384 for (i=0; i<num_ab; ++i) {
2386 if ((i / NAMESPERPAGE) != page) { /* New tab */
2387 page = (i / NAMESPERPAGE);
2389 wprintf("</tr></table>\n");
2390 end_tab(page-1, num_pages);
2392 begin_tab(page, num_pages);
2393 wprintf("<table border=0 cellspacing=0 cellpadding=3 width=100%%>\n");
2397 if ((displayed % 4) == 0) {
2398 if (displayed > 0) {
2402 wprintf("<tr bgcolor=\"#%s\">",
2403 (bg ? "DDDDDD" : "FFFFFF")
2409 wprintf("<a href=\"readfwd?startmsg=%ld?is_singlecard=1",
2410 addrbook[i].ab_msgnum);
2411 wprintf("?maxmsgs=1?is_summary=0?alpha=%s\">", bstr("alpha"));
2412 vcard_n_prettyize(addrbook[i].ab_name);
2413 escputs(addrbook[i].ab_name);
2414 wprintf("</a></td>\n");
2418 /* Placeholders for empty columns at end */
2419 if ((num_ab % 4) != 0) {
2420 for (i=0; i<(4-(num_ab % 4)); ++i) {
2421 wprintf("<td> </td>");
2425 wprintf("</tr></table>\n");
2426 end_tab((num_pages-1), num_pages);
2428 begin_tab(num_pages, num_pages);
2429 /* FIXME there ought to be something here */
2430 end_tab(num_pages, num_pages);
2432 for (i=0; i<num_pages; ++i) {
2441 * load message pointers from the server for a "read messages" operation
2443 * servcmd: the citadel command to send to the citserver
2444 * with_headers: also include some of the headers with the message numbers (more expensive)
2446 int load_msg_ptrs(char *servcmd, int with_headers)
2448 StrBuf* FoundCharset = NULL;
2449 struct wcsession *WCC = WC;
2450 message_summary *Msg;
2453 ///time_t datestamp;
2454 //char fullname[128];
2455 //char nodename[128];
2456 //char inetaddr[128];
2457 //char subject[1024];
2464 ////int num_summ_alloc = 0;
2466 if (WCC->summ != NULL) {
2467 if (WCC->summ != NULL)
2468 DeleteHash(&WCC->summ);
2470 WCC->summ = NewHash(1, Flathash);
2472 maxload = 1000;/// TODO
2476 StrBuf_ServGetln(Buf);
2477 if (GetServerStatus(Buf, NULL) != 1) {
2481 // TODO if (with_headers) { //// TODO: Have Attachments?
2483 while (len = StrBuf_ServGetln(Buf),
2485 strcmp(ChrPtr(Buf), "000")!= 0))
2487 if (nummsgs < maxload) {
2488 Msg = (message_summary*)malloc(sizeof(message_summary));
2489 memset(Msg, 0, sizeof(message_summary));
2491 Msg->msgnum = StrBufExtract_long(Buf, 0, '|');
2492 Msg->date = StrBufExtract_long(Buf, 1, '|');
2494 Msg->from = NewStrBufPlain(NULL, StrLength(Buf));
2495 StrBufExtract_token(Buf2, Buf, 2, '|');
2496 if (StrLength(Buf2) != 0) {
2497 /** Handle senders with RFC2047 encoding */
2498 StrBuf_RFC822_to_Utf8(Msg->from, Buf2, WCC->DefaultCharset, FoundCharset);
2502 StrBufExtract_token(Buf2, Buf, 3, '|');
2503 if ((StrLength(Buf2) !=0 ) &&
2504 ( ((WCC->room_flags & QR_NETWORK)
2505 || ((strcasecmp(ChrPtr(Buf2), serv_info.serv_nodename)
2506 && (strcasecmp(ChrPtr(Buf2), serv_info.serv_fqdn)))))))
2508 StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
2509 StrBufAppendBuf(Msg->from, Buf2, 0);
2513 StrBufExtract_token(Msg->inetaddr, Buf, 4, '|');
2516 Msg->subj = NewStrBufPlain(NULL, StrLength(Buf));
2517 StrBufExtract_token(Buf2, Buf, 5, '|');
2518 if (StrLength(Buf2) == 0)
2519 StrBufAppendBufPlain(Msg->subj, _("(no subj)"), 0, -1);
2521 StrBuf_RFC822_to_Utf8(Msg->subj, Buf2, WCC->DefaultCharset, FoundCharset);
2522 if ((StrLength(Msg->subj) > 75) &&
2523 (StrBuf_Utf8StrLen(Msg->subj) > 75)) {
2524 StrBuf_Utf8StrCut(Msg->subj, 72);
2525 StrBufAppendBufPlain(Msg->subj, HKEY("..."), 0);
2530 if ((StrLength(Msg->from) > 25) &&
2531 (StrBuf_Utf8StrLen(Msg->from) > 25)) {
2532 StrBuf_Utf8StrCut(Msg->from, 23);
2533 StrBufAppendBufPlain(Msg->from, HKEY("..."), 0);
2535 Put(WCC->summ, (const char*)&Msg->msgnum, sizeof(Msg->msgnum), Msg, DestroyMessageSummary);
2550 * command loop for reading messages
2552 * Set oper to "readnew" or "readold" or "readfwd" or "headers"
2554 void readloop(char *oper)
2557 message_summary *Msg;
2566 long *displayed_msgs = NULL;
2567 int num_displayed = 0;
2569 int is_addressbook = 0;
2570 int is_singlecard = 0;
2571 int is_calendar = 0;
2572 struct calview calv;
2577 int lowest_displayed = (-1);
2578 int highest_displayed = 0;
2579 struct addrbookent *addrbook = NULL;
2581 const StrBuf *sortby = NULL;
2583 int SortBy = eRDate;
2584 const StrBuf *sortpref_value;
2585 int bbs_reverse = 0;
2586 struct wcsession *WCC = WC; /* This is done to make it run faster; WC is a function */
2588 const char *HashKey;
2591 if (WCC->wc_view == VIEW_WIKI) {
2592 sprintf(buf, "wiki?room=%s&page=home", WCC->wc_roomname);
2597 startmsg = lbstr("startmsg");
2598 maxmsgs = ibstr("maxmsgs");
2599 is_summary = (ibstr("is_summary") && !WCC->is_mobile);
2600 if (maxmsgs == 0) maxmsgs = DEFAULT_MAXMSGS;
2602 sortpref_value = get_room_pref("sort");
2604 sortby = sbstr("sortby");
2605 if ( (!IsEmptyStr(ChrPtr(sortby))) &&
2606 (strcasecmp(ChrPtr(sortby), ChrPtr(sortpref_value)) != 0)) {
2607 set_room_pref("sort", NewStrBufDup(sortby), 1);
2608 sortpref_value = NULL;
2609 sortpref_value = sortby;
2612 SortBy = StrToESort(sortpref_value);
2613 /* message board sort */
2614 if (SortBy == eReverse) {
2621 output_headers(1, 1, 1, 0, 0, 0);
2624 * When in summary mode, always show ALL messages instead of just
2625 * new or old. Otherwise, show what the user asked for.
2627 if (!strcmp(oper, "readnew")) {
2628 strcpy(cmd, "MSGS NEW");
2630 else if (!strcmp(oper, "readold")) {
2631 strcpy(cmd, "MSGS OLD");
2633 else if (!strcmp(oper, "do_search")) {
2634 snprintf(cmd, sizeof(cmd), "MSGS SEARCH|%s", bstr("query"));
2637 strcpy(cmd, "MSGS ALL");
2640 if ((WCC->wc_view == VIEW_MAILBOX) && (maxmsgs > 1) && !WCC->is_mobile) {
2642 if (!strcmp(oper, "do_search")) {
2643 snprintf(cmd, sizeof(cmd), "MSGS SEARCH|%s", bstr("query"));
2646 strcpy(cmd, "MSGS ALL");
2650 if ((WCC->wc_view == VIEW_ADDRESSBOOK) && (maxmsgs > 1)) {
2652 if (!strcmp(oper, "do_search")) {
2653 snprintf(cmd, sizeof(cmd), "MSGS SEARCH|%s", bstr("query"));
2656 strcpy(cmd, "MSGS ALL");
2661 if (is_summary) { /**< fetch header summary */
2662 snprintf(cmd, sizeof(cmd), "MSGS %s|%s||1",
2663 (!strcmp(oper, "do_search") ? "SEARCH" : "ALL"),
2664 (!strcmp(oper, "do_search") ? bstr("query") : "")
2669 if (WCC->is_mobile) {
2671 snprintf(cmd, sizeof(cmd), "MSGS %s|%s||1",
2672 (!strcmp(oper, "do_search") ? "SEARCH" : "ALL"),
2673 (!strcmp(oper, "do_search") ? bstr("query") : "")
2679 * Are we doing a summary view? If so, we need to know old messages
2680 * and new messages, so we can do that pretty boldface thing for the
2683 strcpy(old_msgs, "");
2684 if ((is_summary) || (WCC->wc_default_view == VIEW_CALENDAR) || WCC->is_mobile){
2686 serv_getln(buf, sizeof buf);
2687 if (buf[0] == '2') {
2688 strcpy(old_msgs, &buf[4]);
2692 is_singlecard = ibstr("is_singlecard");
2694 if (WCC->wc_default_view == VIEW_CALENDAR) { /**< calendar */
2696 strcpy(cmd, "MSGS ALL|||1");
2698 parse_calendar_view_request(&calv);
2700 if (WCC->wc_default_view == VIEW_TASKS) { /**< tasks */
2702 strcpy(cmd, "MSGS ALL");
2705 if (WCC->wc_default_view == VIEW_NOTES) { /**< notes */
2707 strcpy(cmd, "MSGS ALL");
2712 wprintf("<div id=\"new_notes_here\"></div>\n");
2715 nummsgs = load_msg_ptrs(cmd, (is_summary || WCC->is_mobile));
2718 if ((!is_tasks) && (!is_calendar) && (!is_notes) && (!is_addressbook)) {
2719 wprintf("<div align=\"center\"><br /><em>");
2720 if (!strcmp(oper, "readnew")) {
2721 wprintf(_("No new messages."));
2722 } else if (!strcmp(oper, "readold")) {
2723 wprintf(_("No old messages."));
2725 wprintf(_("No messages here."));
2727 wprintf("</em><br /></div>\n");
2733 if ((is_summary) || (WCC->wc_default_view == VIEW_CALENDAR) || WCC->is_mobile){
2735 message_summary *Msg;
2737 at = GetNewHashPos();
2738 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
2739 /** Are you a new message, or an old message? */
2740 Msg = (message_summary*) vMsg;
2742 if (is_msg_in_mset(old_msgs, Msg->msgnum)) {
2753 if (startmsg == 0L) {
2755 startmsg = WCC->msgarr[(nummsgs >= maxmsgs) ? (nummsgs - maxmsgs) : 0];
2758 startmsg = WCC->msgarr[0];
2762 if (is_summary || WCC->is_mobile) {
2763 SortByPayload(WCC->summ, SortFuncs[SortBy]);
2768 wprintf("<script language=\"javascript\" type=\"text/javascript\">"
2769 " document.onkeydown = CtdlMsgListKeyPress; "
2770 " if (document.layers) { "
2771 " document.captureEvents(Event.KEYPRESS); "
2776 /** note that Date and Delete are now in the same column */
2777 wprintf("<div id=\"message_list_hdr\">"
2778 "<div class=\"fix_scrollbar_bug\">"
2779 "<table cellspacing=0 style=\"width:100%%\">"
2782 wprintf("<th width=%d%%>%s <a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=%s\"><img border=\"0\" src=\"%s\" /></a> </th>\n"
2783 "<th width=%d%%>%s <a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=%s\"><img border=\"0\" src=\"%s\" /></a> </th>\n"
2784 "<th width=%d%%>%s <a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=%s\"><img border=\"0\" src=\"%s\" /></a> \n"
2786 "<input type=\"submit\" name=\"delete_button\" id=\"delbutton\" "
2787 " onClick=\"CtdlDeleteSelectedMessages(event)\" "
2794 SortByStrings[SubjectInvertSortString[SortBy]],
2795 SortIcons[SortSubjectToIcon[SortBy]],
2796 SENDER_COL_WIDTH_PCT,
2798 SortByStrings[SenderInvertSortString[SortBy]],
2799 SortIcons[SortSenderToIcon[SortBy]],
2800 DATE_PLUS_BUTTONS_WIDTH_PCT,
2802 SortByStrings[DateInvertSortString[SortBy]],
2803 SortIcons[SortDateToIcon[SortBy]],
2806 wprintf("</table></div></div>\n");
2807 wprintf("<div id=\"message_list\">"
2809 "<div class=\"fix_scrollbar_bug\">\n"
2810 "<table class=\"mailbox_summary\" id=\"summary_headers\" "
2811 "cellspacing=0 style=\"width:100%%;-moz-user-select:none;\">"
2813 } else if (WCC->is_mobile) {
2814 wprintf("<div id=\"message_list\">");
2819 * Set the "is_bbview" variable if it appears that we are looking at
2820 * a classic bulletin board view.
2822 if ((!is_tasks) && (!is_calendar) && (!is_addressbook)
2823 && (!is_notes) && (!is_singlecard) && (!is_summary)) {
2828 * If we're not currently looking at ALL requested
2829 * messages, then display the selector bar
2832 /** begin bbview scroller */
2833 wprintf("<form name=\"msgomatictop\" class=\"selector_top\" > \n <p>");
2834 wprintf(_("Reading #"));//// TODO this isn't used, should it? : , lowest_displayed, highest_displayed);
2836 wprintf("<select name=\"whichones\" size=\"1\" "
2837 "OnChange=\"location.href=msgomatictop.whichones.options"
2838 "[selectedIndex].value\">\n");
2841 for (b=nummsgs-1; b>=0; b = b - maxmsgs) {
2843 lo = b - maxmsgs + 2;
2845 wprintf("<option %s value="
2850 "%d-%d</option> \n",
2851 ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
2860 for (b=0; b<nummsgs; b = b + maxmsgs) {
2862 hi = b + maxmsgs + 1;
2863 if (hi > nummsgs) hi = nummsgs;
2864 wprintf("<option %s value="
2869 "%d-%d</option> \n",
2870 ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
2879 wprintf("<option value=\"%s?startmsg=%ld"
2880 "&maxmsgs=9999999&is_summary=%d\">",
2882 WCC->msgarr[0], is_summary);
2884 wprintf("</option>");
2885 wprintf("</select> ");
2886 wprintf(_("of %d messages."), nummsgs);
2888 /** forward/reverse */
2889 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
2890 "OnChange=\"location.href='%s?sortby=forward'\"",
2891 (bbs_reverse ? "" : "checked"),
2895 wprintf(_("oldest to newest"));
2896 wprintf(" ");
2898 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
2899 "OnChange=\"location.href='%s?sortby=reverse'\"",
2900 (bbs_reverse ? "checked" : ""),
2904 wprintf(_("newest to oldest"));
2907 wprintf("</p></form>\n");
2908 /** end bbview scroller */
2911 at = GetNewHashPos();
2912 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
2913 Msg = (message_summary*) vMsg;
2914 if ((Msg->msgnum >= startmsg) && (num_displayed < maxmsgs)) {
2916 /** Display the message */
2918 DoTemplate(HKEY("section_mailsummary"), NULL, Msg, CTX_MAILSUM);
2920 else if (is_addressbook) {
2921 fetch_ab_name(Msg, buf);
2923 addrbook = realloc(addrbook,
2924 (sizeof(struct addrbookent) * num_ab) );
2925 safestrncpy(addrbook[num_ab-1].ab_name, buf,
2926 sizeof(addrbook[num_ab-1].ab_name));
2927 addrbook[num_ab-1].ab_msgnum = Msg->msgnum;
2929 else if (is_calendar) {
2930 load_calendar_item(Msg, Msg->is_new, &calv);
2932 else if (is_tasks) {
2933 display_task(Msg, Msg->is_new);
2935 else if (is_notes) {
2936 display_note(Msg, Msg->is_new);
2937 } else if (WCC->is_mobile) {
2938 DoTemplate(HKEY("section_mailsummary"), NULL, Msg, CTX_MAILSUM);
2941 if (displayed_msgs == NULL) {
2942 displayed_msgs = malloc(sizeof(long) *
2943 (maxmsgs<nummsgs ? maxmsgs : nummsgs));
2945 displayed_msgs[num_displayed] = Msg->msgnum;
2948 if (lowest_displayed < 0) lowest_displayed = a;
2949 highest_displayed = a;
2957 if (displayed_msgs != NULL) {
2959 qsort(displayed_msgs, num_displayed, sizeof(long), longcmp_r);
2962 /** if we do a split bbview in the future, begin messages div here */
2964 for (a=0; a<num_displayed; ++a) {
2965 read_message(displayed_msgs[a], 0, "");
2968 /** if we do a split bbview in the future, end messages div here */
2970 free(displayed_msgs);
2971 displayed_msgs = NULL;
2976 "</div>\n"); /**< end of 'fix_scrollbar_bug' div */
2977 wprintf("</div>"); /**< end of 'message_list' div */
2979 /** Here's the grab-it-to-resize-the-message-list widget */
2980 wprintf("<div id=\"resize_msglist\" "
2981 "onMouseDown=\"CtdlResizeMsgListMouseDown(event)\">"
2982 "<div class=\"fix_scrollbar_bug\"> <hr>"
2986 wprintf("<div id=\"preview_pane\">"); /**< The preview pane will initially be empty */
2987 } else if (WCC->is_mobile) {
2992 * Bump these because although we're thinking in zero base, the user
2993 * is a drooling idiot and is thinking in one base.
2996 ++highest_displayed;
2999 * If we're not currently looking at ALL requested
3000 * messages, then display the selector bar
3003 /** begin bbview scroller */
3004 wprintf("<form name=\"msgomatic\" class=\"selector_bottom\" > \n <p>");
3005 wprintf(_("Reading #")); /// TODO: this isn't used: , lowest_displayed, highest_displayed);
3007 wprintf("<select name=\"whichones\" size=\"1\" "
3008 "OnChange=\"location.href=msgomatic.whichones.options"
3009 "[selectedIndex].value\">\n");
3012 for (b=nummsgs-1; b>=0; b = b - maxmsgs) {
3014 lo = b - maxmsgs + 2;
3016 wprintf("<option %s value="
3021 "%d-%d</option> \n",
3022 ((WCC->msgarr[lo-1] == startmsg) ? "selected" : ""),
3031 for (b=0; b<nummsgs; b = b + maxmsgs) {
3033 hi = b + maxmsgs + 1;
3034 if (hi > nummsgs) hi = nummsgs;
3035 wprintf("<option %s value="
3040 "%d-%d</option> \n",
3041 ((WCC->msgarr[b] == startmsg) ? "selected" : ""),
3050 wprintf("<option value=\"%s&startmsg=%ld"
3051 "&maxmsgs=9999999&is_summary=%d\">",
3053 WCC->msgarr[0], is_summary);
3055 wprintf("</option>");
3056 wprintf("</select> ");
3057 wprintf(_("of %d messages."), nummsgs);
3059 /** forward/reverse */
3060 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
3061 "OnChange=\"location.href='%s&sortby=forward'\"",
3062 (bbs_reverse ? "" : "checked"),
3066 wprintf(_("oldest to newest"));
3067 wprintf(" ");
3068 wprintf("<input type=\"radio\" %s name=\"direction\" value=\"\""
3069 "OnChange=\"location.href='%s&sortby=reverse'\"",
3070 (bbs_reverse ? "checked" : ""),
3074 wprintf(_("newest to oldest"));
3077 wprintf("</p></form>\n");
3078 /** end bbview scroller */
3083 do_tasks_view(); /** Render the task list */
3087 render_calendar_view(&calv);
3090 if (is_addressbook) {
3091 do_addrbook_view(addrbook, num_ab); /** Render the address book */
3094 /** Note: wDumpContent() will output one additional </div> tag. */
3095 wprintf("</div>\n"); /** end of 'content' div */
3098 /** free the summary */
3099 if (WCC->summ != NULL) {
3100 DeleteHash(&WCC->summ);
3102 if (addrbook != NULL) free(addrbook);
3107 * Back end for post_message()
3108 * ... this is where the actual message gets transmitted to the server.
3110 void post_mime_to_server(void) {
3111 char top_boundary[SIZ];
3112 char alt_boundary[SIZ];
3113 int is_multipart = 0;
3115 struct wc_attachment *att;
3117 size_t encoded_length;
3118 size_t encoded_strlen;
3119 char *txtmail = NULL;
3121 sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x",
3122 serv_info.serv_fqdn,
3126 sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x",
3127 serv_info.serv_fqdn,
3132 /* RFC2045 requires this, and some clients look for it... */
3133 serv_puts("MIME-Version: 1.0");
3134 serv_puts("X-Mailer: " PACKAGE_STRING);
3136 /* If there are attachments, we have to do multipart/mixed */
3137 if (WC->first_attachment != NULL) {
3142 /* Remember, serv_printf() appends an extra newline */
3143 serv_printf("Content-type: multipart/mixed; boundary=\"%s\"\n", top_boundary);
3144 serv_printf("This is a multipart message in MIME format.\n");
3145 serv_printf("--%s", top_boundary);
3148 /* Remember, serv_printf() appends an extra newline */
3149 serv_printf("Content-type: multipart/alternative; "
3150 "boundary=\"%s\"\n", alt_boundary);
3151 serv_printf("This is a multipart message in MIME format.\n");
3152 serv_printf("--%s", alt_boundary);
3154 serv_puts("Content-type: text/plain; charset=utf-8");
3155 serv_puts("Content-Transfer-Encoding: quoted-printable");
3157 txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0);
3158 text_to_server_qp(txtmail); /* Transmit message in quoted-printable encoding */
3161 serv_printf("--%s", alt_boundary);
3163 serv_puts("Content-type: text/html; charset=utf-8");
3164 serv_puts("Content-Transfer-Encoding: quoted-printable");
3166 serv_puts("<html><body>\r\n");
3167 text_to_server_qp(bstr("msgtext")); /* Transmit message in quoted-printable encoding */
3168 serv_puts("</body></html>\r\n");
3170 serv_printf("--%s--", alt_boundary);
3174 /* Add in the attachments */
3175 for (att = WC->first_attachment; att!=NULL; att=att->next) {
3177 encoded_length = ((att->length * 150) / 100);
3178 encoded = malloc(encoded_length);
3179 if (encoded == NULL) break;
3180 encoded_strlen = CtdlEncodeBase64(encoded, att->data, att->length, 1);
3182 serv_printf("--%s", top_boundary);
3183 serv_printf("Content-type: %s", att->content_type);
3184 serv_printf("Content-disposition: attachment; filename=\"%s\"", att->filename);
3185 serv_puts("Content-transfer-encoding: base64");
3187 serv_write(encoded, encoded_strlen);
3192 serv_printf("--%s--", top_boundary);
3200 * Post message (or don't post message)
3202 * Note regarding the "dont_post" variable:
3203 * A random value (actually, it's just a timestamp) is inserted as a hidden
3204 * field called "postseq" when the display_enter page is generated. This
3205 * value is checked when posting, using the static variable dont_post. If a
3206 * user attempts to post twice using the same dont_post value, the message is
3207 * discarded. This prevents the accidental double-saving of the same message
3208 * if the user happens to click the browser "back" button.
3210 void post_message(void)
3213 StrBuf *encoded_subject = NULL;
3214 static long dont_post = (-1L);
3215 struct wc_attachment *att, *aptr;
3216 int is_anonymous = 0;
3217 const StrBuf *display_name = NULL;
3218 struct wcsession *WCC = WC;
3220 if (havebstr("force_room")) {
3221 gotoroom(bstr("force_room"));
3224 if (havebstr("display_name")) {
3225 display_name = sbstr("display_name");
3226 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
3227 display_name = NULL;
3232 if (WCC->upload_length > 0) {
3234 lprintf(9, "%s:%d: we are uploading %d bytes\n", __FILE__, __LINE__, WCC->upload_length);
3235 /** There's an attachment. Save it to this struct... */
3236 att = malloc(sizeof(struct wc_attachment));
3237 memset(att, 0, sizeof(struct wc_attachment));
3238 att->length = WCC->upload_length;
3239 strcpy(att->content_type, WCC->upload_content_type);
3240 strcpy(att->filename, WCC->upload_filename);
3243 /** And add it to the list. */
3244 if (WCC->first_attachment == NULL) {
3245 WCC->first_attachment = att;
3248 aptr = WCC->first_attachment;
3249 while (aptr->next != NULL) aptr = aptr->next;
3254 * Mozilla sends a simple filename, which is what we want,
3255 * but Satan's Browser sends an entire pathname. Reduce
3256 * the path to just a filename if we need to.
3258 while (num_tokens(att->filename, '/') > 1) {
3259 remove_token(att->filename, 0, '/');
3261 while (num_tokens(att->filename, '\\') > 1) {
3262 remove_token(att->filename, 0, '\\');
3266 * Transfer control of this memory from the upload struct
3267 * to the attachment struct.
3269 att->data = WCC->upload;
3270 WCC->upload_length = 0;
3276 if (havebstr("cancel_button")) {
3277 sprintf(WCC->ImportantMessage,
3278 _("Cancelled. Message was not posted."));
3279 } else if (havebstr("attach_button")) {
3282 } else if (lbstr("postseq") == dont_post) {
3283 sprintf(WCC->ImportantMessage,
3284 _("Automatically cancelled because you have already "
3285 "saved this message."));
3287 const char CMD[] = "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s|%s";
3288 const StrBuf *Recp = NULL;
3289 const StrBuf *Cc = NULL;
3290 const StrBuf *Bcc = NULL;
3291 const StrBuf *Wikipage = NULL;
3292 const StrBuf *my_email_addr = NULL;
3293 StrBuf *CmdBuf = NULL;;
3294 StrBuf *references = NULL;
3296 if (havebstr("references"))
3298 const StrBuf *ref = sbstr("references");
3299 references = NewStrBufPlain(ChrPtr(ref), StrLength(ref));
3300 lprintf(9, "Converting: %s\n", ChrPtr(references));
3301 StrBufReplaceChars(references, '|', '!');
3302 lprintf(9, "Converted: %s\n", ChrPtr(references));
3304 if (havebstr("subject")) {
3307 * make enough room for the encoded string;
3308 * plus the QP header
3310 Subj = sbstr("subject");
3312 StrBufRFC2047encode(&encoded_subject, Subj);
3314 Recp = sbstr("recp");
3317 Wikipage = sbstr("wikipage");
3318 my_email_addr = sbstr("my_email_addr");
3320 CmdBuf = NewStrBufPlain(NULL,
3323 StrLength(encoded_subject) +
3326 StrLength(Wikipage) +
3327 StrLength(my_email_addr) +
3328 StrLength(references));
3330 StrBufPrintf(CmdBuf,
3334 ChrPtr(encoded_subject),
3335 ChrPtr(display_name),
3339 ChrPtr(my_email_addr),
3340 ChrPtr(references));
3341 FreeStrBuf(&references);
3343 lprintf(9, "%s\n", CmdBuf);
3344 serv_puts(ChrPtr(CmdBuf));
3345 serv_getln(buf, sizeof buf);
3346 FreeStrBuf(&CmdBuf);
3347 FreeStrBuf(&encoded_subject);
3348 if (buf[0] == '4') {
3349 post_mime_to_server();
3350 if ( (havebstr("recp"))
3351 || (havebstr("cc" ))
3352 || (havebstr("bcc" ))
3354 sprintf(WCC->ImportantMessage, _("Message has been sent.\n"));
3357 sprintf(WC->ImportantMessage, _("Message has been posted.\n"));
3359 dont_post = lbstr("postseq");
3361 lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, buf);
3362 sprintf(WC->ImportantMessage, "%s", &buf[4]);
3368 free_attachments(WCC);
3371 * We may have been supplied with instructions regarding the location
3372 * to which we must return after posting. If found, go there.
3374 if (havebstr("return_to")) {
3375 http_redirect(bstr("return_to"));
3378 * If we were editing a page in a wiki room, go to that page now.
3380 else if (havebstr("wikipage")) {
3381 snprintf(buf, sizeof buf, "wiki?page=%s", bstr("wikipage"));
3385 * Otherwise, just go to the "read messages" loop.
3388 readloop("readnew");
3396 * \brief display the message entry screen
3398 void display_enter(void)
3403 const StrBuf *display_name = NULL;
3404 struct wc_attachment *att;
3405 int recipient_required = 0;
3406 int subject_required = 0;
3407 int recipient_bad = 0;
3408 int is_anonymous = 0;
3409 long existing_page = (-1L);
3410 struct wcsession *WCC = WC;
3414 if (havebstr("force_room")) {
3415 gotoroom(bstr("force_room"));
3418 display_name = sbstr("display_name");
3419 if (!strcmp(ChrPtr(display_name), "__ANONYMOUS__")) {
3420 display_name = NULL;
3424 /** First test to see whether this is a room that requires recipients to be entered */
3425 serv_puts("ENT0 0");
3426 serv_getln(buf, sizeof buf);
3428 if (!strncmp(buf, "570", 3)) { /** 570 means that we need a recipient here */
3429 recipient_required = 1;
3431 else if (buf[0] != '2') { /** Any other error means that we cannot continue */
3432 sprintf(WCC->ImportantMessage, "%s", &buf[4]);
3433 readloop("readnew");
3437 /* Is the server strongly recommending that the user enter a message subject? */
3438 if ((buf[3] != '\0') && (buf[4] != '\0')) {
3439 subject_required = extract_int(&buf[4], 1);
3443 * Are we perhaps in an address book view? If so, then an "enter
3444 * message" command really means "add new entry."
3446 if (WCC->wc_default_view == VIEW_ADDRESSBOOK) {
3447 do_edit_vcard(-1, "", "", WCC->wc_roomname);
3452 * Are we perhaps in a calendar room? If so, then an "enter
3453 * message" command really means "add new calendar item."
3455 if (WCC->wc_default_view == VIEW_CALENDAR) {
3456 display_edit_event();
3461 * Are we perhaps in a tasks view? If so, then an "enter
3462 * message" command really means "add new task."
3464 if (WCC->wc_default_view == VIEW_TASKS) {
3465 display_edit_task();
3470 * Otherwise proceed normally.
3471 * Do a custom room banner with no navbar...
3473 output_headers(1, 1, 2, 0, 0, 0);
3474 wprintf("<div id=\"banner\">\n");
3475 embed_room_banner(NULL, navbar_none);
3476 wprintf("</div>\n");
3477 wprintf("<div id=\"content\">\n"
3478 "<div class=\"fix_scrollbar_bug message \">");
3480 /* Now check our actual recipients if there are any */
3481 if (recipient_required) {
3482 const StrBuf *Recp = NULL;
3483 const StrBuf *Cc = NULL;
3484 const StrBuf *Bcc = NULL;
3485 const StrBuf *Wikipage = NULL;
3486 StrBuf *CmdBuf = NULL;;
3487 const char CMD[] = "ENT0 0|%s|%d|0||%s||%s|%s|%s";
3489 Recp = sbstr("recp");
3492 Wikipage = sbstr("wikipage");
3494 CmdBuf = NewStrBufPlain(NULL,
3497 StrLength(display_name) +
3500 StrLength(Wikipage));
3502 StrBufPrintf(CmdBuf,
3506 ChrPtr(display_name),
3510 serv_puts(ChrPtr(CmdBuf));
3511 serv_getln(buf, sizeof buf);
3512 FreeStrBuf(&CmdBuf);
3514 if (!strncmp(buf, "570", 3)) { /** 570 means we have an invalid recipient listed */
3515 if (havebstr("recp") &&
3521 else if (buf[0] != '2') { /** Any other error means that we cannot continue */
3522 wprintf("<em>%s</em><br />\n", &buf[4]);/// -> important message
3527 /** If we got this far, we can display the message entry screen. */
3529 /* begin message entry screen */
3531 "enctype=\"multipart/form-data\" "
3533 "accept-charset=\"UTF-8\" "
3535 "name=\"enterform\""
3537 wprintf("<input type=\"hidden\" name=\"postseq\" value=\"%ld\">\n", now);
3538 if (WCC->wc_view == VIEW_WIKI) {
3539 wprintf("<input type=\"hidden\" name=\"wikipage\" value=\"%s\">\n", bstr("wikipage"));
3541 wprintf("<input type=\"hidden\" name=\"return_to\" value=\"%s\">\n", bstr("return_to"));
3542 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WCC->nonce);
3543 wprintf("<input type=\"hidden\" name=\"force_room\" value=\"");
3544 escputs(WCC->wc_roomname);
3546 wprintf("<input type=\"hidden\" name=\"references\" value=\"");
3547 escputs(bstr("references"));
3550 /** submit or cancel buttons */
3551 wprintf("<p class=\"send_edit_msg\">");
3552 wprintf("<input type=\"submit\" name=\"send_button\" value=\"");
3553 if (recipient_required) {
3554 wprintf(_("Send message"));
3556 wprintf(_("Post message"));
3559 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n", _("Cancel"));
3564 wprintf("<img src=\"static/newmess3_24x.gif\" class=\"imgedit\">");
3565 wprintf(" "); /** header bar */
3566 webcit_fmt_date(buf, now, 0);
3568 wprintf("\n"); /** header bar */
3570 wprintf("<table width=\"100%%\" class=\"edit_msg_table\">");
3572 wprintf("<th><label for=\"from_id\" > ");
3573 wprintf(_(" <I>from</I> "));
3574 wprintf("</label></th>");
3576 wprintf("<td colspan=\"2\">");
3578 /* Allow the user to select any of his valid screen names */
3580 wprintf("<select name=\"display_name\" size=1 id=\"from_id\">\n");
3583 serv_getln(buf, sizeof buf);
3584 if (buf[0] == '1') {
3585 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3586 wprintf("<option %s value=\"",
3587 ((!strcasecmp(bstr("display_name"), buf)) ? "selected" : "")
3592 wprintf("</option>\n");
3596 if (WCC->room_flags & QR_ANONOPT) {
3597 wprintf("<option %s value=\"__ANONYMOUS__\">%s</option>\n",
3598 ((!strcasecmp(bstr("__ANONYMOUS__"), WCC->wc_fullname)) ? "selected" : ""),
3603 wprintf("</select>\n");
3605 /* If this is an email (not a post), allow the user to select any of his
3606 * valid email addresses.
3608 if (recipient_required) {
3610 serv_getln(buf, sizeof buf);
3611 if (buf[0] == '1') {
3612 wprintf("<select name=\"my_email_addr\" size=1>\n");
3613 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3614 wprintf("<option value=\"");
3618 wprintf("></option>\n");
3620 wprintf("</select>\n");
3624 wprintf(_(" <I>in</I> "));
3625 escputs(WCC->wc_roomname);
3627 wprintf("</td></tr>");
3629 if (recipient_required) {
3633 wprintf("<tr><th><label for=\"recp_id\"> ");
3635 wprintf("</label></th>"
3636 "<td><input autocomplete=\"off\" type=\"text\" name=\"recp\" id=\"recp_id\" value=\"");
3637 ccraw = xbstr("recp", &len);
3638 copy = (char*) malloc(len * 2 + 1);
3639 memcpy(copy, ccraw, len + 1);
3640 utf8ify_rfc822_string(copy);
3643 wprintf("\" size=45 maxlength=1000 />");
3644 wprintf("<div class=\"auto_complete\" id=\"recp_name_choices\"></div>");
3645 wprintf("</td><td rowspan=\"3\" align=\"left\" valign=\"top\">");
3647 /** Pop open an address book -- begin **/
3649 "<a href=\"javascript:PopOpenAddressBook('recp_id|%s|cc_id|%s|bcc_id|%s');\" "
3651 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
3653 _("To:"), _("CC:"), _("BCC:"),
3654 _("Contacts"), _("Contacts")
3656 /** Pop open an address book -- end **/
3658 wprintf("</td></tr>");
3660 wprintf("<tr><th><label for=\"cc_id\"> ");
3662 wprintf("</label></th>"
3663 "<td><input autocomplete=\"off\" type=\"text\" name=\"cc\" id=\"cc_id\" value=\"");
3664 ccraw = xbstr("cc", &len);
3665 copy = (char*) malloc(len * 2 + 1);
3666 memcpy(copy, ccraw, len + 1);
3667 utf8ify_rfc822_string(copy);
3670 wprintf("\" size=45 maxlength=1000 />");
3671 wprintf("<div class=\"auto_complete\" id=\"cc_name_choices\"></div>");
3672 wprintf("</td></tr>");
3674 wprintf("<tr><th><label for=\"bcc_id\"> ");
3676 wprintf("</label></th>"
3677 "<td><input autocomplete=\"off\" type=\"text\" name=\"bcc\" id=\"bcc_id\" value=\"");
3678 ccraw = xbstr("bcc", &len);
3679 copy = (char*) malloc(len * 2 + 1);
3680 memcpy(copy, ccraw, len + 1);
3681 utf8ify_rfc822_string(copy);
3684 wprintf("\" size=45 maxlength=1000 />");
3685 wprintf("<div class=\"auto_complete\" id=\"bcc_name_choices\"></div>");
3686 wprintf("</td></tr>");
3688 /** Initialize the autocomplete ajax helpers (found in wclib.js) */
3689 wprintf("<script type=\"text/javascript\"> \n"
3690 " activate_entmsg_autocompleters(); \n"
3696 wprintf("<tr><th><label for=\"subject_id\" > ");
3697 if (recipient_required || subject_required) {
3698 wprintf(_("Subject:"));
3701 wprintf(_("Subject (optional):"));
3703 wprintf("</label></th>"
3704 "<td colspan=\"2\">"
3705 "<input type=\"text\" name=\"subject\" id=\"subject_id\" value=\"");
3706 escputs(bstr("subject"));
3707 wprintf("\" size=45 maxlength=70>\n");
3708 wprintf("</td></tr>");
3710 wprintf("<tr><td colspan=\"3\">\n");
3712 wprintf("<textarea name=\"msgtext\" cols=\"80\" rows=\"15\">");
3714 /** If we're continuing from a previous edit, put our partially-composed message back... */
3715 msgescputs(bstr("msgtext"));
3717 /* If we're forwarding a message, insert it here... */
3718 if (lbstr("fwdquote") > 0L) {
3719 wprintf("<br><div align=center><i>");
3720 wprintf(_("--- forwarded message ---"));
3721 wprintf("</i></div><br>");
3722 pullquote_message(lbstr("fwdquote"), 1, 1);
3725 /** If we're replying quoted, insert the quote here... */
3726 else if (lbstr("replyquote") > 0L) {
3729 pullquote_message(lbstr("replyquote"), 0, 1);
3730 wprintf("</blockquote><br>");
3733 /** If we're editing a wiki page, insert the existing page here... */
3734 else if (WCC->wc_view == VIEW_WIKI) {
3735 safestrncpy(buf, bstr("wikipage"), sizeof buf);
3736 str_wiki_index(buf);
3737 existing_page = locate_message_by_uid(buf);
3738 if (existing_page >= 0L) {
3739 pullquote_message(existing_page, 1, 0);
3743 /** Insert our signature if appropriate... */
3744 if ( (WCC->is_mailbox) && !yesbstr("sig_inserted") ) {
3746 get_pref_yesno("use_sig", &UseSig, 0);
3749 const char *sig, *esig;
3751 get_preference("signature", &ebuf);
3753 StrBufEUid_unescapize(Sig, ebuf);
3755 esig = sig + StrLength(Sig);
3756 wprintf("<br>--<br>");
3757 while (sig <= esig) {
3761 else if (*sig == '<') {
3764 else if (*sig == '>') {
3767 else if (*sig == '&') {
3770 else if (*sig == '\"') {
3773 else if (*sig == '\'') {
3776 else /* since we're utf 8, is this a good idea? if (isprint(*sig))*/ {
3777 wprintf("%c", *sig);
3785 wprintf("</textarea>\n");
3787 /** Make sure we only insert our signature once */
3788 /** We don't care if it was there or not before, it needs to be there now. */
3789 wprintf("<input type=\"hidden\" name=\"sig_inserted\" value=\"yes\">\n");
3792 * The following template embeds the TinyMCE richedit control, and automatically
3793 * transforms the textarea into a richedit textarea.
3795 do_template("richedit", NULL);
3797 /** Enumerate any attachments which are already in place... */
3798 wprintf("<div class=\"attachment buttons\"><img src=\"static/diskette_24x.gif\" class=\"imgedit\" > ");
3799 wprintf(_("Attachments:"));
3801 wprintf("<select name=\"which_attachment\" size=1>");
3802 for (att = WCC->first_attachment; att != NULL; att = att->next) {
3803 wprintf("<option value=\"");
3804 urlescputs(att->filename);
3806 escputs(att->filename);
3807 /* wprintf(" (%s, %d bytes)",att->content_type,att->length); */
3808 wprintf("</option>\n");
3810 wprintf("</select>");
3812 /** Now offer the ability to attach additional files... */
3813 wprintf(" ");
3814 wprintf(_("Attach file:"));
3815 wprintf(" <input name=\"attachfile\" class=\"attachfile\" "
3816 "size=16 type=\"file\">\n "
3817 "<input type=\"submit\" name=\"attach_button\" value=\"%s\">\n", _("Add"));
3818 wprintf("</div>"); /* End of "attachment buttons" div */
3821 wprintf("</td></tr></table>");
3823 wprintf("</form>\n");
3824 wprintf("</div>\n"); /* end of "fix_scrollbar_bug" div */
3826 /* NOTE: address_book_popup() will close the "content" div. Don't close it here. */
3827 DONE: address_book_popup();
3833 * \brief delete a message
3835 void delete_msg(void)
3840 msgid = lbstr("msgid");
3842 if (WC->wc_is_trash) { /** Delete from Trash is a real delete */
3843 serv_printf("DELE %ld", msgid);
3845 else { /** Otherwise move it to Trash */
3846 serv_printf("MOVE %ld|_TRASH_|0", msgid);
3849 serv_getln(buf, sizeof buf);
3850 sprintf(WC->ImportantMessage, "%s", &buf[4]);
3852 readloop("readnew");
3857 * \brief move a message to another folder
3864 msgid = lbstr("msgid");
3866 if (havebstr("move_button")) {
3867 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
3869 serv_getln(buf, sizeof buf);
3870 sprintf(WC->ImportantMessage, "%s", &buf[4]);
3872 sprintf(WC->ImportantMessage, (_("The message was not moved.")));
3875 readloop("readnew");
3883 * Confirm move of a message
3885 void confirm_move_msg(void)
3891 msgid = lbstr("msgid");
3894 output_headers(1, 1, 2, 0, 0, 0);
3895 wprintf("<div id=\"banner\">\n");
3897 wprintf(_("Confirm move of message"));
3899 wprintf("</div>\n");
3901 wprintf("<div id=\"content\" class=\"service\">\n");
3903 wprintf("<CENTER>");
3905 wprintf(_("Move this message to:"));
3906 wprintf("<br />\n");
3908 wprintf("<form METHOD=\"POST\" action=\"move_msg\">\n");
3909 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
3910 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
3912 wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
3914 serv_getln(buf, sizeof buf);
3915 if (buf[0] == '1') {
3916 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3917 extract_token(targ, buf, 0, '|', sizeof targ);
3918 wprintf("<OPTION>");
3923 wprintf("</SELECT>\n");
3924 wprintf("<br />\n");
3926 wprintf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
3928 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
3929 wprintf("</form></CENTER>\n");
3931 wprintf("</CENTER>\n");
3935 void readnew(void) { readloop("readnew");}
3936 void readold(void) { readloop("readold");}
3937 void readfwd(void) { readloop("readfwd");}
3938 void headers(void) { readloop("headers");}
3939 void do_search(void) { readloop("do_search");}
3950 WebcitAddUrlHandler(HKEY("readnew"), readnew, 0);
3951 WebcitAddUrlHandler(HKEY("readold"), readold, 0);
3952 WebcitAddUrlHandler(HKEY("readfwd"), readfwd, 0);
3953 WebcitAddUrlHandler(HKEY("headers"), headers, 0);
3954 WebcitAddUrlHandler(HKEY("do_search"), do_search, 0);
3955 WebcitAddUrlHandler(HKEY("display_enter"), display_enter, 0);
3956 WebcitAddUrlHandler(HKEY("post"), post_message, 0);
3957 WebcitAddUrlHandler(HKEY("move_msg"), move_msg, 0);
3958 WebcitAddUrlHandler(HKEY("delete_msg"), delete_msg, 0);
3959 WebcitAddUrlHandler(HKEY("confirm_move_msg"), confirm_move_msg, 0);
3960 WebcitAddUrlHandler(HKEY("msg"), embed_message, NEED_URL|AJAX);
3961 WebcitAddUrlHandler(HKEY("printmsg"), print_message, NEED_URL);
3962 WebcitAddUrlHandler(HKEY("mobilemsg"), mobile_message_view, NEED_URL);
3963 WebcitAddUrlHandler(HKEY("msgheaders"), display_headers, NEED_URL);
3965 RegisterNamespace("MAIL:SUMM:DATESTR", 0, 0, tmplput_MAIL_SUMM_DATE_STR, CTX_MAILSUM);
3966 RegisterNamespace("MAIL:SUMM:DATENO", 0, 0, tmplput_MAIL_SUMM_DATE_NO, CTX_MAILSUM);
3967 RegisterNamespace("MAIL:SUMM:N", 0, 0, tmplput_MAIL_SUMM_N, CTX_MAILSUM);
3968 RegisterNamespace("MAIL:SUMM:FROM", 0, 2, tmplput_MAIL_SUMM_FROM, CTX_MAILSUM);
3969 RegisterNamespace("MAIL:SUMM:TO", 0, 2, tmplput_MAIL_SUMM_TO, CTX_MAILSUM);
3970 RegisterNamespace("MAIL:SUMM:SUBJECT", 0, 4, tmplput_MAIL_SUMM_SUBJECT, CTX_MAILSUM);
3971 RegisterNamespace("MAIL:SUMM:NTATACH", 0, 0, tmplput_MAIL_SUMM_NATTACH, CTX_MAILSUM);
3972 RegisterNamespace("MAIL:SUMM:CCCC", 0, 2, tmplput_MAIL_SUMM_CCCC, CTX_MAILSUM);
3973 RegisterNamespace("MAIL:SUMM:H_NODE", 0, 2, tmplput_MAIL_SUMM_H_NODE, CTX_MAILSUM);
3974 RegisterNamespace("MAIL:SUMM:ALLRCPT", 0, 2, tmplput_MAIL_SUMM_ALLRCPT, CTX_MAILSUM);
3975 RegisterNamespace("MAIL:SUMM:ORGROOM", 0, 2, tmplput_MAIL_SUMM_ORGROOM, CTX_MAILSUM);
3976 RegisterNamespace("MAIL:SUMM:RFCA", 0, 2, tmplput_MAIL_SUMM_RFCA, CTX_MAILSUM);
3977 RegisterNamespace("MAIL:SUMM:OTHERNODE", 2, 0, tmplput_MAIL_SUMM_OTHERNODE, CTX_MAILSUM);
3978 RegisterNamespace("MAIL:SUMM:REFIDS", 0, 0, tmplput_MAIL_SUMM_REFIDS, CTX_MAILSUM);
3979 RegisterNamespace("MAIL:SUMM:INREPLYTO", 0, 2, tmplput_MAIL_SUMM_INREPLYTO, CTX_MAILSUM);
3980 RegisterNamespace("MAIL:BODY", 0, 2, tmplput_MAIL_BODY, CTX_MAILSUM);
3983 RegisterConditional(HKEY("COND:MAIL:SUMM:UNREAD"), 0, Conditional_MAIL_SUMM_UNREAD, CTX_MAILSUM);
3984 RegisterConditional(HKEY("COND:MAIL:SUMM:H_NODE"), 0, Conditional_MAIL_SUMM_H_NODE, CTX_MAILSUM);
3985 RegisterConditional(HKEY("COND:MAIL:SUMM:OTHERNODE"), 0, Conditional_MAIL_SUMM_OTHERNODE, CTX_MAILSUM);
3986 RegisterConditional(HKEY("COND:MAIL:ANON"), 0, Conditional_ANONYMOUS_MESSAGE, CTX_MAILSUM);
3988 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH"), 0, Conditional_MAIL_MIME_ALL, CTX_MAILSUM);
3989 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:SUBMESSAGES"), 0, Conditional_MAIL_MIME_SUBMESSAGES, CTX_MAILSUM);
3990 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:LINKS"), 0, Conditional_MAIL_MIME_ATTACHLINKS, CTX_MAILSUM);
3991 RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:ATT"), 0, Conditional_MAIL_MIME_ATTACH, CTX_MAILSUM);
3993 RegisterIterator("MAIL:MIME:ATTACH", 0, NULL, iterate_get_mime_All,
3994 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM);
3995 RegisterIterator("MAIL:MIME:ATTACH:SUBMESSAGES", 0, NULL, iterate_get_mime_Submessages,
3996 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM);
3997 RegisterIterator("MAIL:MIME:ATTACH:LINKS", 0, NULL, iterate_get_mime_AttachLinks,
3998 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM);
3999 RegisterIterator("MAIL:MIME:ATTACH:ATT", 0, NULL, iterate_get_mime_Attachments,
4000 NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM);
4002 RegisterNamespace("MAIL:MIME:NAME", 0, 2, tmplput_MIME_Name, CTX_MIME_ATACH);
4003 RegisterNamespace("MAIL:MIME:FILENAME", 0, 2, tmplput_MIME_FileName, CTX_MIME_ATACH);
4004 RegisterNamespace("MAIL:MIME:PARTNUM", 0, 2, tmplput_MIME_PartNum, CTX_MIME_ATACH);
4005 RegisterNamespace("MAIL:MIME:MSGNUM", 0, 2, tmplput_MIME_MsgNum, CTX_MIME_ATACH);
4006 RegisterNamespace("MAIL:MIME:DISPOSITION", 0, 2, tmplput_MIME_Disposition, CTX_MIME_ATACH);
4007 RegisterNamespace("MAIL:MIME:CONTENTTYPE", 0, 2, tmplput_MIME_ContentType, CTX_MIME_ATACH);
4008 RegisterNamespace("MAIL:MIME:CHARSET", 0, 2, tmplput_MIME_Charset, CTX_MIME_ATACH);
4009 RegisterNamespace("MAIL:MIME:LENGTH", 0, 2, tmplput_MIME_Length, CTX_MIME_ATACH);
4010 RegisterNamespace("MAIL:MIME:DATA", 0, 2, tmplput_MIME_Data, CTX_MIME_ATACH);
4014 RegisterMimeRenderer(HKEY("text/x-citadel-variformat"), render_MAIL_variformat);
4015 RegisterMimeRenderer(HKEY("text/plain"), render_MAIL_text_plain);
4016 RegisterMimeRenderer(HKEY("text"), render_MAIL_text_plain);
4017 RegisterMimeRenderer(HKEY("text/html"), render_MAIL_html);
4018 RegisterMimeRenderer(HKEY(""), render_MAIL_UNKNOWN);
4020 RegisterMsgHdr(HKEY("nhdr"), examine_nhdr, 0);
4021 RegisterMsgHdr(HKEY("type"), examine_type, 0);
4022 RegisterMsgHdr(HKEY("from"), examine_from, 0);
4023 RegisterMsgHdr(HKEY("subj"), examine_subj, 0);
4024 RegisterMsgHdr(HKEY("msgn"), examine_msgn, 0);
4025 RegisterMsgHdr(HKEY("wefw"), examine_wefw, 0);
4026 RegisterMsgHdr(HKEY("cccc"), examine_cccc, 0);
4027 RegisterMsgHdr(HKEY("hnod"), examine_hnod, 0);
4028 RegisterMsgHdr(HKEY("room"), examine_room, 0);
4029 RegisterMsgHdr(HKEY("rfca"), examine_rfca, 0);
4030 RegisterMsgHdr(HKEY("node"), examine_node, 0);
4031 RegisterMsgHdr(HKEY("rcpt"), examine_rcpt, 0);
4032 RegisterMsgHdr(HKEY("time"), examine_time, 0);
4033 RegisterMsgHdr(HKEY("part"), examine_mime_part, 0);
4034 RegisterMsgHdr(HKEY("text"), examine_text, 1);
4035 RegisterMsgHdr(HKEY("X-Citadel-MSG4-Partnum"), examine_msg4_partnum, 0);
4036 RegisterMsgHdr(HKEY("Content-type"), examine_content_type, 0);
4037 RegisterMsgHdr(HKEY("Content-length"), examine_content_lengh, 0);
4038 RegisterMsgHdr(HKEY("Content-transfer-encoding"), examine_content_encoding, 0);