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.
13 extern CtxType CTX_MAILSUM;
14 extern CtxType CTX_MIME_ATACH;
15 extern HashList *MsgHeaderHandler;
16 extern HashList *MimeRenderHandler;
17 extern HashList *ReadLoopHandler;
18 typedef struct wc_mime_attachment wc_mime_attachment;
19 typedef void (*RenderMimeFunc)(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset);
20 typedef struct _RenderMimeFuncStruct {
22 } RenderMimeFuncStruct;
24 struct wc_mime_attachment {
33 size_t length; /* length of the mimeattachment */
35 long lvalue; /* if we put a long... */
36 long msgnum; /* the message number on the citadel server derived from message_summary */
37 const RenderMimeFuncStruct *Renderer;
39 void DestroyMime(void *vMime);
41 #define MSGFLAG_READ (1<<0)
43 typedef struct _message_summary {
44 long msgnum; /* the message number on the citadel server */
47 time_t date; /* its creation date */
51 StrBuf *from; /* the author */
52 StrBuf *to; /* the recipient */
53 StrBuf *subj; /* the title / subject */
54 StrBuf *reply_inreplyto;
55 long reply_inreplyto_hash;
56 StrBuf *reply_references;
57 long reply_references_hash;
66 const StrBuf *PartNum;
68 HashList *Attachments; /* list of attachments */
69 HashList *Submessages;
70 HashList *AttachLinks;
77 /* The mime part of the message */
78 wc_mime_attachment *MsgBody;
80 void DestroyMessageSummary(void *vMsg);
84 static inline message_summary* GetMessagePtrAt(int n, HashList *Summ)
92 GetHashAt(Summ, n, &HKLen, &Key, &vMsg);
93 return (message_summary*) vMsg;
96 typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
98 void evaluate_mime_part(StrBuf *Target, WCTemplputParams *TP);
101 typedef enum _eCustomRoomRenderer {
102 eUseDefault = VIEW_JOURNAL + 100,
104 }eCustomRoomRenderer;
117 * @brief function to parse the | separated message headers list
118 * @param Line the raw line with your message data
119 * @param Msg put your parser results here...
120 * @param ConversionBuffer if you need some workbuffer, don't free me!
121 * @returns 0: failure, trash this message. 1: all right, store it
123 typedef int (*load_msg_ptrs_detailheaders) (StrBuf *Line,
125 message_summary *Msg,
126 StrBuf *ConversionBuffer);
128 typedef void (*readloop_servcmd)(char *buf, long bufsize);
130 typedef struct _readloopstruct {
132 readloop_servcmd cmd;
135 extern readloop_struct rlid[];
137 void readloop(long oper, eCustomRoomRenderer ForceRenderer);
138 int read_message(StrBuf *Target,
139 const char *tmpl, long tmpllen,
141 const StrBuf *section,
142 const StrBuf **OutMime);
143 int load_message(message_summary *Msg,
144 StrBuf *FoundCharset,
150 typedef struct _SharedMessageStatus {
151 long load_seen; /* should read information be loaded */
152 long sortit; /* should we sort it using the standard sort API? */
153 long defaultsortorder; /* if we should sort it, which direction should be the default? */
155 long maxload; /* how many headers should we accept from the server? defaults to 10k */
156 long maxmsgs; /* how many message bodies do you want to load at most?*/
158 long startmsg; /* which is the start message? */
159 long nummsgs; /* How many messages are available to your view? */
160 long numNewmsgs; /* if you load the seen-status, this is the count of them. */
161 long num_displayed; /* counted up for LoadMsgFromServer */ /* TODO: unclear who should access this and why */
163 long lowest_found; /* smallest Message ID found; */
164 long highest_found; /* highest Message ID found; */
166 } SharedMessageStatus;
168 int load_msg_ptrs(const char *servcmd,
170 SharedMessageStatus *Stat,
171 load_msg_ptrs_detailheaders LH);
173 typedef int (*GetParamsGetServerCall_func)(SharedMessageStatus *Stat,
181 typedef int (*PrintViewHeader_func)(SharedMessageStatus *Stat, void **ViewSpecific);
183 typedef int (*LoadMsgFromServer_func)(SharedMessageStatus *Stat,
185 message_summary* Msg,
189 typedef int (*RenderView_or_Tail_func)(SharedMessageStatus *Stat,
192 typedef int (*View_Cleanup_func)(void **ViewSpecific);
194 void RegisterReadLoopHandlerset(
196 * RoomType: which View definition are you going to be called for
201 * GetParamsGetServerCall should do the following:
202 * * allocate your private context structure
203 * * evaluate your commandline arguments, put results to your private struct.
204 * * fill cmd with the command to load the message pointer list:
205 * * might depend on bstr/oper depending on your needs
206 * * might stay empty if no list should loaded and LoadMsgFromServer
208 * * influence the behaviour by presetting values on SharedMessageStatus
210 GetParamsGetServerCall_func GetParamsGetServerCall,
213 * PrintpageHeader prints the surrounding information like iconbar, header etc.
214 * by default, output_headers() is called.
217 PrintViewHeader_func PrintPageHeader,
220 * PrintViewHeader is here to print informations infront of your messages.
221 * The message list is already loaded & sorted (if) so you can evaluate
222 * its result on the SharedMessageStatus struct.
224 PrintViewHeader_func PrintViewHeader,
227 * LH is the function, you specify if you want to load more than just message
228 * numbers from the server during the listing fetch operation.
230 load_msg_ptrs_detailheaders LH,
233 * LoadMsgFromServer is called for every message in the message list:
236 * * up to 'maxmsgs' after your 'startmsg'
237 * * it should load and parse messages from citserer.
238 * * depending on your needs you might want to print your message here...
239 * * if cmd was empty, its skipped alltogether.
241 LoadMsgFromServer_func LoadMsgFromServer,
244 * RenderView_or_Tail is called last;
245 * * if you used PrintViewHeader to print messages, you might want to print
246 * trailing information here
247 * * if you just pre-loaded your messages, put your render code here.
249 RenderView_or_Tail_func RenderView_or_Tail,
252 * ViewCleanup should just clear your private data so all your mem can go back to
254 * it also should release the content for delivery via end_burst() or wDumpContent(1);
256 View_Cleanup_func ViewCleanup
259 GetParamsGetServerCall
269 int ParseMessageListHeaders_Detail(StrBuf *Line,
271 message_summary *Msg,
272 StrBuf *ConversionBuffer);
277 * @brief function to register the availability to render a specific message
278 * @param HeaderName Mimetype we know howto display
279 * @param HdrNLen length...
280 * @param InlineRenderable Should we announce to citserver that we want to receive these mimeparts immediately?
281 * @param Priority if multipart/alternative; which mimepart/Renderer should be prefered? (only applies if InlineRenderable)
283 void RegisterMimeRenderer(const char *HeaderName, long HdrNLen,
284 RenderMimeFunc MimeRenderer,
285 int InlineRenderable,
290 * @brief fill the header parts of Msg with the headers loaded by MSG0
291 * @param Msg empty message struct, only preinitialized with the msgid
292 * @param FoundCharset buffer with the prefered charset of the headers
293 * @param buf linebuffer used to buffer citserver replies
295 int ReadOneMessageSummary(message_summary *Msg, StrBuf *FoundCharset, StrBuf *Buf);