/*
- * Copyright (c) 1996-2013 by the citadel.org team
+ * Copyright (c) 1996-2020 by the citadel.org team
*
* This program is open source software. You can redistribute it and/or
* modify it under the terms of the GNU General Public License, version 3.
#define MSGFLAG_READ (1<<0)
typedef struct _message_summary {
- long msgnum; /* the message number on the citadel server */
+ long msgnum; // the message number on the citadel server
int Flags;
-
- time_t date; /* its creation date */
+ time_t date; // its creation date
int nhdr;
int format_type;
StrBuf *euid;
- StrBuf *from; /* the author */
- StrBuf *to; /* the recipient */
- StrBuf *subj; /* the title / subject */
+ StrBuf *from; // display name of message author
+ StrBuf *to; // the recipient
+ StrBuf *subj; // title / subject
StrBuf *reply_inreplyto;
- long reply_inreplyto_hash;
+ long reply_inreplyto_hash;
StrBuf *reply_references;
- long reply_references_hash;
+ long reply_references_hash;
StrBuf *ReplyTo;
StrBuf *cccc;
StrBuf *AllRcpt;
StrBuf *Room;
- StrBuf *Rfca;
+ StrBuf *Rfca; // UPN or email address of message author
StrBuf *EnvTo;
const StrBuf *PartNum;
- HashList *Attachments; /* list of attachments */
+ HashList *Attachments; // list of attachments
HashList *Submessages;
HashList *AttachLinks;
HashList *AllAttach;
int hasattachments;
-
- /* The mime part of the message */
- wc_mime_attachment *MsgBody;
+ wc_mime_attachment *MsgBody; // the MIME part of the message
} message_summary;
+
void DestroyMessageSummary(void *vMsg);
/* Maps to msgkeys[] in msgbase.c: */
ePevious,
eSubFolder,
eLastHeader
-}eMessageField;
+} eMessageField;
extern const char* fieldMnemonics[];
int GetFieldFromMnemonic(eMessageField *f, const char* c);
-
int EvaluateMsgHdr(const char *HeaderName, long HdrNLen, message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
int EvaluateMsgHdrEnum(eMessageField f, message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
-
-static inline message_summary* GetMessagePtrAt(int n, HashList *Summ)
-{
+static inline message_summary* GetMessagePtrAt(int n, HashList *Summ) {
const char *Key;
long HKLen;
void *vMsg;
- if (Summ == NULL)
+ if (Summ == NULL) {
return NULL;
+ }
GetHashAt(Summ, n, &HKLen, &Key, &vMsg);
return (message_summary*) vMsg;
}
-typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
+typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
void evaluate_mime_part(StrBuf *Target, WCTemplputParams *TP);
-
typedef enum _eCustomRoomRenderer {
eUseDefault = VIEW_JOURNAL + 100,
eReadEUIDS
-}eCustomRoomRenderer;
+} eCustomRoomRenderer;
enum {
do_search,
}
StrBufAppendTemplate(Target, TP, Msg->subj, 0);
}
-int Conditional_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
-{
+
+/*
+ * Conditional returns true if the message has a Subject and it is nonzero in length
+ */
+int Conditional_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP) {
message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+ return StrLength(Msg->subj) > 0;
+}
- return StrLength(Msg->subj) > 0;
+/*
+ * Conditional returns true if the message originated on the local system
+ */
+int Conditional_MAIL_LOCAL(StrBuf *Target, WCTemplputParams *TP) {
+ message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+
+ char *at = strchr(ChrPtr(Msg->Rfca), '@');
+ if (at == NULL) {
+ return 1; // If there is no "@" in the address, it's got to be local.
+ }
+ ++at;
+
+ if (!strcasecmp(at, ChrPtr(WC->serv_info->serv_fqdn))) { // is this from our local domain?
+ return 1; // if yes, then the message originated locally.
+ }
+ else {
+ return 0; // otherwise it probably didn't.
+ }
}
-void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
wcsession *WCC = WC;
long Offset = 0;
const char *pOffset;
};
HashList *msgKeyLookup = NULL;
-int GetFieldFromMnemonic(eMessageField *f, const char* c)
-{
+
+int GetFieldFromMnemonic(eMessageField *f, const char *c) {
void *v = NULL;
if (GetHash(msgKeyLookup, c, 4, &v)) {
*f = (eMessageField) v;
return 0;
}
-void FillMsgKeyLookupTable(void)
-{
+
+void FillMsgKeyLookupTable(void) {
long i = 0;
msgKeyLookup = NewHash (1, FourHash);
}
-
void
InitModule_MSGRENDERERS
(void)
CTX_MAILSUM);
RegisterNamespace("SUMM:COUNT", 0, 0, tmplput_SUMM_COUNT, NULL, CTX_NONE);
+
/* iterate over all known mails in WC->summ */
- RegisterIterator("MAIL:SUMM:MSGS", 0, NULL, iterate_get_mailsumm_All,
- NULL,NULL, CTX_MAILSUM, CTX_NONE, IT_NOFLAG);
+ RegisterIterator("MAIL:SUMM:MSGS", 0, NULL, iterate_get_mailsumm_All, NULL,NULL, CTX_MAILSUM, CTX_NONE, IT_NOFLAG);
RegisterNamespace("MAIL:SUMM:EUID", 0, 1, tmplput_MAIL_SUMM_EUID, NULL, CTX_MAILSUM);
RegisterNamespace("MAIL:SUMM:DATEBRIEF", 0, 0, tmplput_MAIL_SUMM_DATE_BRIEF, NULL, CTX_MAILSUM);
RegisterConditional("COND:MAIL:SUMM:UNREAD", 0, Conditional_MAIL_SUMM_UNREAD, CTX_MAILSUM);
RegisterConditional("COND:MAIL:SUMM:SUBJECT", 0, Conditional_MAIL_SUMM_SUBJECT, CTX_MAILSUM);
RegisterConditional("COND:MAIL:ANON", 0, Conditional_ANONYMOUS_MESSAGE, CTX_MAILSUM);
- RegisterConditional("COND:MAIL:TO", 0, Conditional_MAIL_SUMM_TO, CTX_MAILSUM);
- RegisterConditional("COND:MAIL:SUBJ", 0, Conditional_MAIL_SUMM_SUBJ, CTX_MAILSUM);
+ RegisterConditional("COND:MAIL:TO", 0, Conditional_MAIL_SUMM_TO, CTX_MAILSUM);
+ RegisterConditional("COND:MAIL:SUBJ", 0, Conditional_MAIL_SUMM_SUBJ, CTX_MAILSUM);
+ RegisterConditional("COND:MAIL:LOCAL", 0, Conditional_MAIL_LOCAL, CTX_MAILSUM);
/* do we have mimetypes to iterate over? */
RegisterConditional("COND:MAIL:MIME:ATTACH", 0, Conditional_MAIL_MIME_ALL, CTX_MAILSUM);
RegisterConditional("COND:MAIL:MIME:ATTACH:SUBMESSAGES", 0, Conditional_MAIL_MIME_SUBMESSAGES, CTX_MAILSUM);
RegisterConditional("COND:MAIL:MIME:ATTACH:LINKS", 0, Conditional_MAIL_MIME_ATTACHLINKS, CTX_MAILSUM);
RegisterConditional("COND:MAIL:MIME:ATTACH:ATT", 0, Conditional_MAIL_MIME_ATTACH, CTX_MAILSUM);
- RegisterIterator("MAIL:MIME:ATTACH", 0, NULL, iterate_get_mime_All,
- NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
- RegisterIterator("MAIL:MIME:ATTACH:SUBMESSAGES", 0, NULL, iterate_get_mime_Submessages,
- NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
- RegisterIterator("MAIL:MIME:ATTACH:LINKS", 0, NULL, iterate_get_mime_AttachLinks,
- NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
- RegisterIterator("MAIL:MIME:ATTACH:ATT", 0, NULL, iterate_get_mime_Attachments,
- NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
+ RegisterIterator("MAIL:MIME:ATTACH", 0, NULL, iterate_get_mime_All, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
+ RegisterIterator("MAIL:MIME:ATTACH:SUBMESSAGES", 0, NULL, iterate_get_mime_Submessages, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
+ RegisterIterator("MAIL:MIME:ATTACH:LINKS", 0, NULL, iterate_get_mime_AttachLinks, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
+ RegisterIterator("MAIL:MIME:ATTACH:ATT", 0, NULL, iterate_get_mime_Attachments, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
/* Parts of a mime attachent */
RegisterNamespace("MAIL:MIME:NAME", 0, 2, tmplput_MIME_Name, NULL, CTX_MIME_ATACH);
RegisterNamespace("MAIL:MIME:CHARSET", 0, 2, tmplput_MIME_Charset, NULL, CTX_MIME_ATACH);
RegisterNamespace("MAIL:MIME:LENGTH", 0, 2, tmplput_MIME_Length, NULL, CTX_MIME_ATACH);
RegisterNamespace("MAIL:MIME:DATA", 0, 2, tmplput_MIME_Data, NULL, CTX_MIME_ATACH);
+
/* load the actual attachment into WC->attachments; no output!!! */
RegisterNamespace("MAIL:MIME:LOADDATA", 0, 0, tmplput_MIME_LoadData, NULL, CTX_MIME_ATACH);
/* iterate the WC->attachments; use the above tokens for their contents */
- RegisterIterator("MSG:ATTACHNAMES", 0, NULL, iterate_get_registered_Attachments,
- NULL, NULL, CTX_MIME_ATACH, CTX_NONE, IT_NOFLAG);
-
+ RegisterIterator("MSG:ATTACHNAMES", 0, NULL, iterate_get_registered_Attachments, NULL, NULL, CTX_MIME_ATACH, CTX_NONE, IT_NOFLAG);
RegisterNamespace("MSG:NATTACH", 0, 0, get_registered_Attachments_Count, NULL, CTX_NONE);
/* mime renderers translate an attachment into webcit viewable html text */
RegisterMsgHdr(HKEY("time"), examine_time, 0);
RegisterMsgHdr(HKEY("part"), examine_mime_part, 0);
RegisterMsgHdr(HKEY("text"), examine_text, 1);
- /* these are the content-type headers we get infront of a message; put it into the same hash since it doesn't clash. */
+
+ /* these are the content-type headers we get in front of a message; put it into the same hash since it doesn't clash. */
RegisterMsgHdr(HKEY("X-Citadel-MSG4-Partnum"), examine_msg4_partnum, 0);
RegisterMsgHdr(HKEY("Content-type"), examine_content_type, 0);
RegisterMsgHdr(HKEY("Content-length"), examine_content_lengh, 0);