* split tasks view into its own file
[citadel.git] / webcit / messages.h
1
2 extern HashList *MsgHeaderHandler;
3 extern HashList *MimeRenderHandler;
4 extern HashList *ReadLoopHandler;
5 typedef struct wc_mime_attachment wc_mime_attachment;
6 typedef void (*RenderMimeFunc)(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset);
7 typedef struct _RenderMimeFuncStruct {
8         RenderMimeFunc f;
9 } RenderMimeFuncStruct;
10
11 struct wc_mime_attachment {
12         int level;
13         StrBuf *Name;
14         StrBuf *FileName;
15         StrBuf *PartNum;
16         StrBuf *Disposition;
17         StrBuf *ContentType;
18         StrBuf *Charset;
19         StrBuf *Data;
20         size_t length;          /* length of the mimeattachment */
21         long size_known;
22         long lvalue;            /* if we put a long... */
23         long msgnum;            /* the message number on the citadel server derived from message_summary */
24         const RenderMimeFuncStruct *Renderer;
25 };
26 void DestroyMime(void *vMime);
27
28
29 typedef struct _message_summary {
30         time_t date;            /* its creation date */
31         long msgnum;            /* the message number on the citadel server */
32         int nhdr;
33         int format_type;
34         StrBuf *from;           /* the author */
35         StrBuf *to;             /* the recipient */
36         StrBuf *subj;           /* the title / subject */
37         StrBuf *reply_inreplyto;
38         StrBuf *reply_references;
39         StrBuf *reply_to;
40         StrBuf *cccc;
41         StrBuf *hnod;
42         StrBuf *AllRcpt;
43         StrBuf *Room;
44         StrBuf *Rfca;
45         StrBuf *OtherNode;
46         const StrBuf *PartNum;
47
48         HashList *Attachments;  /* list of attachments */
49         HashList *Submessages;
50         HashList *AttachLinks;
51
52         HashList *AllAttach;
53
54         int is_new;
55         int hasattachments;
56
57
58         /* The mime part of the message */
59         wc_mime_attachment *MsgBody;
60 } message_summary;
61 void DestroyMessageSummary(void *vMsg);
62 inline message_summary* GetMessagePtrAt(int n, HashList *Summ);
63
64 typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
65
66 void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime);
67
68 enum {
69         do_search,
70         headers,
71         readfwd,
72         readnew,
73         readold,
74         readgt
75 };
76
77 typedef void (*readloop_servcmd)(char *buf, long bufsize);
78
79 typedef struct _readloopstruct {
80         ConstStr name;
81         readloop_servcmd cmd;
82 } readloop_struct;
83
84
85 void readloop(long oper);
86 int read_message(StrBuf *Target, 
87                  const char *tmpl, long tmpllen, 
88                  long msgnum, 
89                  const StrBuf *section, 
90                  const StrBuf **OutMime);
91 int load_message(message_summary *Msg, 
92                  StrBuf *FoundCharset,
93                  StrBuf **Error);
94
95
96
97
98 typedef struct _SharedMessageStatus{
99         long load_seen;        /** should read information be loaded */
100         long sortit;           /** should we sort it using the standard sort API? */
101         long defaultsortorder; /** if we should sort it, which direction should be the default? */
102
103         long maxload;          /** how many headers should we accept from the server? defaults to 10k */
104         long maxmsgs;          /** how many message bodies do you want to load at most?*/
105         long reverse;          /** should the load-range be reversed? */
106
107         long startmsg;         /** which is the start message ????? */
108         long nummsgs;          /** How many messages are available to your view? */
109         long num_displayed;    /** counted up for LoadMsgFromServer */ /* TODO: unclear who should access this and why */
110
111         long lowest_found;     /** smallest Message ID found;  */
112         long highest_found;    /** highest Message ID found;  */
113
114 }SharedMessageStatus;
115
116 int load_msg_ptrs(const char *servcmd, SharedMessageStatus *Stat);
117
118 typedef int (*GetParamsGetServerCall_func)(SharedMessageStatus *Stat, 
119                                            void **ViewSpecific, 
120                                            long oper, 
121                                            char *cmd, 
122                                            long len);
123
124 typedef int (*PrintViewHeader_func)(SharedMessageStatus *Stat, void **ViewSpecific);
125
126 typedef int (*LoadMsgFromServer_func)(SharedMessageStatus *Stat, 
127                                       void **ViewSpecific, 
128                                       message_summary* Msg, 
129                                       int is_new, 
130                                       int i);
131
132 typedef int (*RenderView_or_Tail_func)(SharedMessageStatus *Stat, 
133                                        void **ViewSpecific, 
134                                        long oper);
135 typedef int (*View_Cleanup_func)(void **ViewSpecific);
136
137 void RegisterReadLoopHandlerset(
138         /**
139          * RoomType: which View definition are you going to be called for
140          */
141         int RoomType,
142
143         /**
144          * GetParamsGetServerCall should do the following:
145          *  * allocate your private context structure
146          *  * evaluate your commandline arguments, put results to your private struct.
147          *  * fill cmd with the command to load the message pointer list:
148          *    * might depend on bstr/oper depending on your needs
149          *    * might stay empty if no list should loaded and LoadMsgFromServer 
150          *      is skipped.
151          *  * influence the behaviour by presetting values on SharedMessageStatus
152          */
153         GetParamsGetServerCall_func GetParamsGetServerCall,
154
155         /**
156          * PrintViewHeader is here to print informations infront of your messages.
157          * The message list is already loaded & sorted (if) so you can evaluate 
158          * its result on the SharedMessageStatus struct.
159          */
160         PrintViewHeader_func PrintViewHeader,
161
162         /**
163          * LoadMsgFromServer is called for every message in the message list:
164          *  * which is 
165          *    * after 'startmsg'  
166          *    * up to 'maxmsgs' after your 'startmsg'
167          *  * it should load and parse messages from citserer.
168          *  * depending on your needs you might want to print your message here...
169          *  * if cmd was empty, its skipped alltogether.
170          */
171         LoadMsgFromServer_func LoadMsgFromServer,
172
173         /**
174          * RenderView_or_Tail is called last; 
175          *  * if you used PrintViewHeader to print messages, you might want to print 
176          *    trailing information here
177          *  * if you just pre-loaded your messages, put your render code here.
178          */
179         RenderView_or_Tail_func RenderView_or_Tail,
180
181         /**
182          * ViewCleanup should just clear your private data so all your mem can go back to 
183          * VALgrindHALLA.
184          * it also should release the content for delivery via end_burst() or wDumpContent(1);
185          */
186         View_Cleanup_func ViewCleanup
187         );
188 /*
189 GetParamsGetServerCall
190
191 PrintViewHeader
192
193 LoadMsgFromServer
194
195 RenderView_or_Tail
196 */