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 StrBuf *reply_references;
64 const StrBuf *PartNum;
66 HashList *Attachments; /* list of attachments */
67 HashList *Submessages;
68 HashList *AttachLinks;
75 /* The mime part of the message */
76 wc_mime_attachment *MsgBody;
78 void DestroyMessageSummary(void *vMsg);
82 static inline message_summary* GetMessagePtrAt(int n, HashList *Summ)
90 GetHashAt(Summ, n, &HKLen, &Key, &vMsg);
91 return (message_summary*) vMsg;
94 typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
96 void evaluate_mime_part(StrBuf *Target, WCTemplputParams *TP);
99 typedef enum _eCustomRoomRenderer {
100 eUseDefault = VIEW_JOURNAL + 100,
102 }eCustomRoomRenderer;
115 * @brief function to parse the | separated message headers list
116 * @param Line the raw line with your message data
117 * @param Msg put your parser results here...
118 * @param ConversionBuffer if you need some workbuffer, don't free me!
119 * @returns 0: failure, trash this message. 1: all right, store it
121 typedef int (*load_msg_ptrs_detailheaders) (StrBuf *Line,
123 message_summary *Msg,
124 StrBuf *ConversionBuffer);
126 typedef void (*readloop_servcmd)(char *buf, long bufsize);
128 typedef struct _readloopstruct {
130 readloop_servcmd cmd;
133 extern readloop_struct rlid[];
135 void readloop(long oper, eCustomRoomRenderer ForceRenderer);
136 int read_message(StrBuf *Target,
137 const char *tmpl, long tmpllen,
139 const StrBuf *section,
140 const StrBuf **OutMime);
141 int load_message(message_summary *Msg,
142 StrBuf *FoundCharset,
148 typedef struct _SharedMessageStatus {
149 long load_seen; /* should read information be loaded */
150 long sortit; /* should we sort it using the standard sort API? */
151 long defaultsortorder; /* if we should sort it, which direction should be the default? */
153 long maxload; /* how many headers should we accept from the server? defaults to 10k */
154 long maxmsgs; /* how many message bodies do you want to load at most?*/
156 long startmsg; /* which is the start message? */
157 long nummsgs; /* How many messages are available to your view? */
158 long numNewmsgs; /* if you load the seen-status, this is the count of them. */
159 long num_displayed; /* counted up for LoadMsgFromServer */ /* TODO: unclear who should access this and why */
161 long lowest_found; /* smallest Message ID found; */
162 long highest_found; /* highest Message ID found; */
164 } SharedMessageStatus;
166 int load_msg_ptrs(const char *servcmd,
168 SharedMessageStatus *Stat,
169 load_msg_ptrs_detailheaders LH);
171 typedef int (*GetParamsGetServerCall_func)(SharedMessageStatus *Stat,
179 typedef int (*PrintViewHeader_func)(SharedMessageStatus *Stat, void **ViewSpecific);
181 typedef int (*LoadMsgFromServer_func)(SharedMessageStatus *Stat,
183 message_summary* Msg,
187 typedef int (*RenderView_or_Tail_func)(SharedMessageStatus *Stat,
190 typedef int (*View_Cleanup_func)(void **ViewSpecific);
192 void RegisterReadLoopHandlerset(
194 * RoomType: which View definition are you going to be called for
199 * GetParamsGetServerCall should do the following:
200 * * allocate your private context structure
201 * * evaluate your commandline arguments, put results to your private struct.
202 * * fill cmd with the command to load the message pointer list:
203 * * might depend on bstr/oper depending on your needs
204 * * might stay empty if no list should loaded and LoadMsgFromServer
206 * * influence the behaviour by presetting values on SharedMessageStatus
208 GetParamsGetServerCall_func GetParamsGetServerCall,
211 * PrintpageHeader prints the surrounding information like iconbar, header etc.
212 * by default, output_headers() is called.
215 PrintViewHeader_func PrintPageHeader,
218 * PrintViewHeader is here to print informations infront of your messages.
219 * The message list is already loaded & sorted (if) so you can evaluate
220 * its result on the SharedMessageStatus struct.
222 PrintViewHeader_func PrintViewHeader,
225 * LH is the function, you specify if you want to load more than just message
226 * numbers from the server during the listing fetch operation.
228 load_msg_ptrs_detailheaders LH,
231 * LoadMsgFromServer is called for every message in the message list:
234 * * up to 'maxmsgs' after your 'startmsg'
235 * * it should load and parse messages from citserer.
236 * * depending on your needs you might want to print your message here...
237 * * if cmd was empty, its skipped alltogether.
239 LoadMsgFromServer_func LoadMsgFromServer,
242 * RenderView_or_Tail is called last;
243 * * if you used PrintViewHeader to print messages, you might want to print
244 * trailing information here
245 * * if you just pre-loaded your messages, put your render code here.
247 RenderView_or_Tail_func RenderView_or_Tail,
250 * ViewCleanup should just clear your private data so all your mem can go back to
252 * it also should release the content for delivery via end_burst() or wDumpContent(1);
254 View_Cleanup_func ViewCleanup
257 GetParamsGetServerCall
267 int ParseMessageListHeaders_Detail(StrBuf *Line,
269 message_summary *Msg,
270 StrBuf *ConversionBuffer);
275 * @brief function to register the availability to render a specific message
276 * @param HeaderName Mimetype we know howto display
277 * @param HdrNLen length...
278 * @param InlineRenderable Should we announce to citserver that we want to receive these mimeparts immediately?
279 * @param Priority if multipart/alternative; which mimepart/Renderer should be prefered? (only applies if InlineRenderable)
281 void RegisterMimeRenderer(const char *HeaderName, long HdrNLen,
282 RenderMimeFunc MimeRenderer,
283 int InlineRenderable,