2 * Copyright (c) 1996-2013 by the citadel.org team
4 * This program is open source software. You can redistribute it and/or
5 * modify it under the terms of the GNU General Public License, version 3.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
15 extern CtxType CTX_MAILSUM;
16 extern CtxType CTX_MIME_ATACH;
17 extern HashList *MsgHeaderHandler;
18 extern HashList *MimeRenderHandler;
19 extern HashList *ReadLoopHandler;
20 typedef struct wc_mime_attachment wc_mime_attachment;
21 typedef void (*RenderMimeFunc)(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset);
22 typedef struct _RenderMimeFuncStruct {
24 } RenderMimeFuncStruct;
26 struct wc_mime_attachment {
35 size_t length; /* length of the mimeattachment */
37 long lvalue; /* if we put a long... */
38 long msgnum; /* the message number on the citadel server derived from message_summary */
39 const RenderMimeFuncStruct *Renderer;
41 void DestroyMime(void *vMime);
43 #define MSGFLAG_READ (1<<0)
45 typedef struct _message_summary {
46 long msgnum; /* the message number on the citadel server */
49 time_t date; /* its creation date */
53 StrBuf *from; /* the author */
54 StrBuf *to; /* the recipient */
55 StrBuf *subj; /* the title / subject */
56 StrBuf *reply_inreplyto;
57 long reply_inreplyto_hash;
58 StrBuf *reply_references;
59 long reply_references_hash;
68 const StrBuf *PartNum;
70 HashList *Attachments; /* list of attachments */
71 HashList *Submessages;
72 HashList *AttachLinks;
79 /* The mime part of the message */
80 wc_mime_attachment *MsgBody;
82 void DestroyMessageSummary(void *vMsg);
86 static inline message_summary* GetMessagePtrAt(int n, HashList *Summ)
94 GetHashAt(Summ, n, &HKLen, &Key, &vMsg);
95 return (message_summary*) vMsg;
98 typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
100 void evaluate_mime_part(StrBuf *Target, WCTemplputParams *TP);
103 typedef enum _eCustomRoomRenderer {
104 eUseDefault = VIEW_JOURNAL + 100,
106 }eCustomRoomRenderer;
119 * @brief function to parse the | separated message headers list
120 * @param Line the raw line with your message data
121 * @param Msg put your parser results here...
122 * @param ConversionBuffer if you need some workbuffer, don't free me!
123 * @returns 0: failure, trash this message. 1: all right, store it
125 typedef int (*load_msg_ptrs_detailheaders) (StrBuf *Line,
127 message_summary *Msg,
128 StrBuf *ConversionBuffer);
130 typedef void (*readloop_servcmd)(char *buf, long bufsize);
132 typedef struct _readloopstruct {
134 readloop_servcmd cmd;
137 extern readloop_struct rlid[];
139 void readloop(long oper, eCustomRoomRenderer ForceRenderer);
140 int read_message(StrBuf *Target,
141 const char *tmpl, long tmpllen,
143 const StrBuf *section,
144 const StrBuf **OutMime,
145 WCTemplputParams *TP);
146 int load_message(message_summary *Msg,
147 StrBuf *FoundCharset,
153 typedef struct _SharedMessageStatus {
154 long load_seen; /* should read information be loaded */
155 long sortit; /* should we sort it using the standard sort API? */
156 long defaultsortorder; /* if we should sort it, which direction should be the default? */
158 long maxload; /* how many headers should we accept from the server? defaults to 10k */
159 long maxmsgs; /* how many message bodies do you want to load at most?*/
161 long startmsg; /* which is the start message? */
162 long nummsgs; /* How many messages are available to your view? */
163 long numNewmsgs; /* if you load the seen-status, this is the count of them. */
164 long num_displayed; /* counted up for LoadMsgFromServer */ /* TODO: unclear who should access this and why */
166 long lowest_found; /* smallest Message ID found; */
167 long highest_found; /* highest Message ID found; */
169 } SharedMessageStatus;
171 int load_msg_ptrs(const char *servcmd,
173 SharedMessageStatus *Stat,
174 load_msg_ptrs_detailheaders LH);
176 typedef int (*GetParamsGetServerCall_func)(SharedMessageStatus *Stat,
184 typedef int (*PrintViewHeader_func)(SharedMessageStatus *Stat, void **ViewSpecific);
186 typedef int (*LoadMsgFromServer_func)(SharedMessageStatus *Stat,
188 message_summary* Msg,
192 typedef int (*RenderView_or_Tail_func)(SharedMessageStatus *Stat,
195 typedef int (*View_Cleanup_func)(void **ViewSpecific);
197 void RegisterReadLoopHandlerset(
199 * RoomType: which View definition are you going to be called for
204 * GetParamsGetServerCall should do the following:
205 * * allocate your private context structure
206 * * evaluate your commandline arguments, put results to your private struct.
207 * * fill cmd with the command to load the message pointer list:
208 * * might depend on bstr/oper depending on your needs
209 * * might stay empty if no list should loaded and LoadMsgFromServer
211 * * influence the behaviour by presetting values on SharedMessageStatus
213 GetParamsGetServerCall_func GetParamsGetServerCall,
216 * PrintpageHeader prints the surrounding information like iconbar, header etc.
217 * by default, output_headers() is called.
220 PrintViewHeader_func PrintPageHeader,
223 * PrintViewHeader is here to print informations infront of your messages.
224 * The message list is already loaded & sorted (if) so you can evaluate
225 * its result on the SharedMessageStatus struct.
227 PrintViewHeader_func PrintViewHeader,
230 * LH is the function, you specify if you want to load more than just message
231 * numbers from the server during the listing fetch operation.
233 load_msg_ptrs_detailheaders LH,
236 * LoadMsgFromServer is called for every message in the message list:
239 * * up to 'maxmsgs' after your 'startmsg'
240 * * it should load and parse messages from citserer.
241 * * depending on your needs you might want to print your message here...
242 * * if cmd was empty, its skipped alltogether.
244 LoadMsgFromServer_func LoadMsgFromServer,
247 * RenderView_or_Tail is called last;
248 * * if you used PrintViewHeader to print messages, you might want to print
249 * trailing information here
250 * * if you just pre-loaded your messages, put your render code here.
252 RenderView_or_Tail_func RenderView_or_Tail,
255 * ViewCleanup should just clear your private data so all your mem can go back to
257 * it also should release the content for delivery via end_burst() or wDumpContent(1);
259 View_Cleanup_func ViewCleanup
262 GetParamsGetServerCall
272 int ParseMessageListHeaders_Detail(StrBuf *Line,
274 message_summary *Msg,
275 StrBuf *ConversionBuffer);
280 * @brief function to register the availability to render a specific message
281 * @param HeaderName Mimetype we know howto display
282 * @param HdrNLen length...
283 * @param InlineRenderable Should we announce to citserver that we want to receive these mimeparts immediately?
284 * @param Priority if multipart/alternative; which mimepart/Renderer should be prefered? (only applies if InlineRenderable)
286 void RegisterMimeRenderer(const char *HeaderName, long HdrNLen,
287 RenderMimeFunc MimeRenderer,
288 int InlineRenderable,
293 * @brief fill the header parts of Msg with the headers loaded by MSG0
294 * @param Msg empty message struct, only preinitialized with the msgid
295 * @param FoundCharset buffer with the prefered charset of the headers
296 * @param buf linebuffer used to buffer citserver replies
298 int ReadOneMessageSummary(message_summary *Msg, StrBuf *FoundCharset, StrBuf *Buf);