2005-09-10 [colin] 1.9.14cvs16
[claws.git] / src / folder.h
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2
3 /*
4  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
5  * Copyright (C) 1999-2003 Hiroyuki Yamamoto
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21
22 #ifndef __FOLDER_H__
23 #define __FOLDER_H__
24
25 #include <glib.h>
26 #include <time.h>
27
28 typedef struct _Folder          Folder;
29 typedef struct _FolderClass     FolderClass;
30
31 typedef struct _FolderItem      FolderItem;
32 typedef struct _FolderUpdateData        FolderUpdateData;
33 typedef struct _FolderItemUpdateData    FolderItemUpdateData;
34 typedef struct _PersistPrefs            PersistPrefs;
35
36 #define FOLDER(obj)             ((Folder *)obj)
37 #define FOLDER_CLASS(obj)       (FOLDER(obj)->klass)
38 #define FOLDER_TYPE(obj)        (FOLDER(obj)->klass->type)
39
40 #define FOLDER_IS_LOCAL(obj)    (FOLDER_TYPE(obj) == F_MH      || \
41                                  FOLDER_TYPE(obj) == F_MBOX    || \
42                                  FOLDER_TYPE(obj) == F_MAILDIR)
43
44 #define FOLDER_ITEM(obj)        ((FolderItem *)obj)
45
46 #define FOLDER_UPDATE_HOOKLIST "folder_update"
47 #define FOLDER_ITEM_UPDATE_HOOKLIST "folder_item_update"
48
49 typedef enum
50 {
51         F_MH,
52         F_MBOX,
53         F_MAILDIR,
54         F_IMAP,
55         F_NEWS,
56         F_UNKNOWN
57 } FolderType;
58
59 typedef enum
60 {
61         F_NORMAL,
62         F_INBOX,
63         F_OUTBOX,
64         F_DRAFT,
65         F_QUEUE,
66         F_TRASH
67 } SpecialFolderItemType;
68
69 typedef enum
70 {
71         SORT_BY_NONE,
72         SORT_BY_NUMBER,
73         SORT_BY_SIZE,
74         SORT_BY_DATE,
75         SORT_BY_FROM,
76         SORT_BY_SUBJECT,
77         SORT_BY_SCORE,
78         SORT_BY_LABEL,
79         SORT_BY_MARK,
80         SORT_BY_STATUS,
81         SORT_BY_MIME,
82         SORT_BY_TO,
83         SORT_BY_LOCKED
84 } FolderSortKey;
85
86 typedef enum
87 {
88         SORT_ASCENDING,
89         SORT_DESCENDING
90 } FolderSortType;
91
92 typedef enum
93 {
94         F_MOVE_OK = 0,
95         F_MOVE_FAILED_DEST_IS_PARENT = -1,
96         F_MOVE_FAILED_DEST_IS_CHILD = -2,
97         F_MOVE_FAILED_DEST_OUTSIDE_MAILBOX = -3,
98         F_MOVE_FAILED = -4,
99 } FolderItemMoveResult;
100
101 typedef enum
102 {
103         FOLDER_ADD_FOLDER               = 1 << 0,
104         FOLDER_REMOVE_FOLDER            = 1 << 1,
105         FOLDER_TREE_CHANGED             = 1 << 2,
106         FOLDER_ADD_FOLDERITEM           = 1 << 3,
107         FOLDER_REMOVE_FOLDERITEM        = 1 << 4,
108 } FolderUpdateFlags;
109
110 typedef enum
111 {
112         F_ITEM_UPDATE_MSGCNT = 1 << 0,
113         F_ITEM_UPDATE_CONTENT = 1 << 1,
114         F_ITEM_UPDATE_ADDMSG = 1 << 2,
115         F_ITEM_UPDATE_REMOVEMSG = 1 << 3,
116         F_ITEM_UPDATE_NAME = 1 << 4,
117 } FolderItemUpdateFlags;
118
119 typedef void (*FolderUIFunc)            (Folder         *folder,
120                                          FolderItem     *item,
121                                          gpointer        data);
122 typedef void (*FolderDestroyNotify)     (Folder         *folder,
123                                          FolderItem     *item,
124                                          gpointer        data);
125 typedef void (*FolderItemFunc)  (FolderItem     *item,
126                                          gpointer        data);
127
128
129 #include "folder_item_prefs.h"
130
131 #include "procmsg.h"
132 #include "msgcache.h"
133 #include "xml.h"
134 #include "prefs_account.h"
135
136 struct _Folder
137 {
138         FolderClass *klass;
139
140         gchar *name;
141         PrefsAccount *account;
142         guint sort;
143
144         FolderItem *inbox;
145         FolderItem *outbox;
146         FolderItem *draft;
147         FolderItem *queue;
148         FolderItem *trash;
149
150         FolderUIFunc ui_func;
151         gpointer     ui_func_data;
152
153         GNode *node;
154
155         gpointer data;
156
157         GHashTable *newsart;
158 };
159
160 struct _FolderClass
161 {
162         /**
163          * A numeric identifier for the FolderClass. Will be removed in the future
164          */
165         FolderType  type;
166         /**
167          * A string identifier for the FolderClass. Currently used in folderlist.xml.
168          * Should be lowercase.
169          */
170         gchar      *idstr;
171         /**
172          * A string for the User Interface that identifies the FolderClass to the
173          * user. Can be upper and lowercase unlike the idstr.
174          */
175         gchar      *uistr;
176         
177         /* virtual functions */
178
179         /* Folder funtions */
180         /**
181          * Create a new \c Folder of this \c FolderClass.
182          *
183          * \param name The name of the new Folder
184          * \param path The path of the new Folder
185          * \return The new \c Folder, or \c NULL when creating the \c Folder 
186          *         failed
187          */
188         Folder          *(*new_folder)          (const gchar    *name,
189                                                  const gchar    *path);
190         /**
191          * Destroy a \c Folder of this \c FolderClass, frees all resources
192          * allocated by the Folder
193          *
194          * \param folder The \c Folder that should be destroyed.
195          */
196         void            (*destroy_folder)       (Folder         *folder);
197         /**
198          * Set the Folder's internal attributes from an \c XMLTag. Also sets the
199          * parameters of the root-FolderItem of the \c Folder. If \c NULL
200          * the default function of the basic \ยข FolderClass is used, so it
201          * must not be \c NULL if one of the parent \c FolderClasses has a \c set_xml
202          * function. In that case the parent \c FolderClass' \c set_xml function
203          * can be used or it has to be called with the \c folder and \c tag by
204          * the implementation.
205          *
206          * \param folder The \c Folder which's attributes should be updated
207          * \param tag The \c XMLTag containing the \c XMLAttrs for the attributes
208          */
209         void             (*set_xml)             (Folder         *folder,
210                                                  XMLTag         *tag);
211         /**
212          * Get an \c XMLTag for the attributes of the \c Folder and the root-FolderItem
213          * of the \c Folder. If \c NULL the default implementation for the basic
214          * FolderClass will be used, so it must not be \c NULL if one of the
215          * parent \c FolderClasses has it's own implementation for \c get_xml.
216          * In that case the parent FolderClass' \c get_xml function can be
217          * used or the \c XMLTag has to be fetched from the parent's \c get_xml
218          * function and then the \c FolderClass specific attributes can be
219          * added to it.
220          *
221          * \param Folder The \c Folder which's attributes should be set in the
222          *               \c XMLTag's \c XMLAttrs
223          * \return XMLTag An \c XMLTag with \c XMLAttrs containing the \c Folder's
224          *                attributes.
225          */
226         XMLTag          *(*get_xml)             (Folder         *folder);
227         /**
228          * Rebuild the folder tree from the folder's data
229          * \todo New implementations of MH and IMAP are actually syncronizing
230          *       the tree with the folder by reusing the old \c FolderItems.
231          *       Claws still destroys the old tree before calling this function.
232          *
233          * \param folder The folder which's tree should be rebuild
234          * \return 0 on success, a negative number otherwise
235          */
236         gint            (*scan_tree)            (Folder         *folder);
237
238         gint            (*create_tree)          (Folder         *folder);
239
240         /* FolderItem functions */
241         /**
242          * Create a new \c FolderItem structure for the \c FolderClass.
243          * \c FolderClasses can have their own \c FolderItem structure with
244          * extra attributes.
245          *
246          * \param folder The \c Folder for that a \c FolderItem should be
247          *               created
248          * \return The new \c FolderItem or NULL in case of an error
249          */
250         FolderItem      *(*item_new)            (Folder         *folder);
251         /**
252          * Destroy a \c FolderItem from this \c FolderClass. The \c FolderClass
253          * has to free all private resources used by the \c FolderItem.
254          *
255          * \param folder The \c Folder of the \c FolderItem
256          * \param item The \c FolderItem that should be destroyed
257          */
258         void             (*item_destroy)        (Folder         *folder,
259                                                  FolderItem     *item);
260         /**
261          * Set the \c FolderItem's internal attributes from an \c XMLTag. If
262          * \c NULL the default function of the basic \c FolderClass is used, so it
263          * must not be \c NULL if one of the parent \c FolderClasses has a \c item_set_xml
264          * function. In that case the parent \c FolderClass' \c item_set_xml function
265          * can be used or it has to be called with the \c folder, \c item and \c tag by
266          * the implementation.
267          *
268          * \param folder The \c Folder of the \c FolderItem
269          * \param item The \c FolderItems which's attributes should be set
270          * \param tag The \c XMLTag with \c XMLAttrs for the \c FolderItem's
271          *            attributes
272          */
273         void             (*item_set_xml)        (Folder         *folder,
274                                                  FolderItem     *item,
275                                                  XMLTag         *tag);
276         /**
277          * Get an \c XMLTag for the attributes of the \c FolderItem If \c NULL
278          * the default implementation for the basic \c FolderClass will be used,
279          * so it must not be \c NULL if one of the parent \c FolderClasses has
280          * it's own implementation for \c item_get_xml. In that case the parent 
281          * FolderClass' \c item_get_xml function can be used or the \c XMLTag
282          * has to be fetched from the parent's \c item_get_xml function and 
283          * then the \c FolderClass specific attributes can be added to it.
284          *
285          * \param folder The \c Folder of the \c FolderItem
286          * \parem item The \c FolderItem which's attributes should be set in
287          *             the \c XMLTag's \c XMLAttrs
288          * \return An \c XMLTag with \c XMLAttrs containing the \c FolderItem's
289          *         attributes.
290          */
291         XMLTag          *(*item_get_xml)        (Folder         *folder,
292                                                  FolderItem     *item);
293         /**
294          * Get a local path for the \c FolderItem where Sylpheed can save
295          * it's cache data. For local directory based folders this can be the
296          * real path. For other folders it can be the local cache directory.
297          *
298          * \param folder The \c Folder of the \c FolderItem
299          * \param item The \c FolderItem for that a path should be returned
300          * \return A path for the \c FolderItem
301          */
302         gchar           *(*item_get_path)       (Folder         *folder,
303                                                  FolderItem     *item);
304         /**
305          * Create a new \c FolderItem. The function must use folder_item_append
306          * to add the new \c FolderItem to the folder tree
307          *
308          * \param folder The \c Folder in which a new \c FolderItem should be
309          *               created
310          * \param parent \c The parent \c FolderItem for the new \c FolderItem
311          * \parem name The name for the new \c FolderItem
312          * \return The new \c FolderItem
313          */
314         FolderItem      *(*create_folder)       (Folder         *folder,
315                                                  FolderItem     *parent,
316                                                  const gchar    *name);
317         /**
318          * Rename a \c FolderItem
319          *
320          * \param folder The \c Folder of the \c FolderItem that should be
321          *               renamed
322          * \param item The \c FolderItem that should be renamed
323          * \param name The new name of the \c FolderItem
324          * \return 0 on success, a negative number otherwise
325          */
326         gint             (*rename_folder)       (Folder         *folder,
327                                                  FolderItem     *item,
328                                                  const gchar    *name);
329         /**
330          * Remove a \c FolderItem from the \c Folder
331          *
332          * \param folder The \c Folder that contains the \c FolderItem
333          * \param item The \c FolderItem that should be removed
334          * \return 0 on sucess, a negative number otherwise
335          */
336         gint             (*remove_folder)       (Folder         *folder,
337                                                  FolderItem     *item);
338         /**
339          * Close a \c FolderItem. Called when the user deselects a
340          * \c FolderItem.
341          * 
342          * \attention In Sylpheed-Main operations can only be done on the
343          *            \c FolderItem that is opened in the SummaryView. This
344          *            \c FolderItem will be closed when you select a new
345          *            \c FolderItem in the FolderView. In Claws operations can
346          *            be done any time on any folder and you should not expect
347          *            that all \c FolderItems get closed after operations
348          *
349          * \param folder The \c Folder that contains the \c FolderItem
350          * \param item The \c FolderItem that should be closed
351          * \return 0 on success, a negative number otherwise
352          */
353         gint             (*close)               (Folder         *folder,
354                                                  FolderItem     *item);
355         /**
356          * Get the list of message numbers for the messages in the \c FolderItem
357          *
358          * \param folder The \c Folder that contains the \c FolderItem
359          * \param item The \c FolderItem for which the message numbers should
360          *             be fetched
361          * \param list Pointer to a GSList where message numbers have to be
362          *             added. Because of the implementation of the GSList that
363          *             changes the pointer of the GSList itself when the first
364          *             item is added this is a pointer to a pointer to a
365          *             GSList structure. Use *item = g_slist_...(*item, ...)
366          *             operations to modify the list.
367          * \param old_uids_valid In some \c Folders the old UIDs can be invalid.
368          *                       Set this pointer to a gboolean to TRUE if the
369          *                       old UIDs are still valid, otherwise set it to
370          *                       FALSE and the folder system will discard it's
371          *                       cache data of the previously know UIDs
372          * \return The number of message numbers add to the list on success,
373          *         a negative number otherwise.
374          */
375         gint             (*get_num_list)        (Folder         *folder,
376                                                  FolderItem     *item,
377                                                  GSList        **list,
378                                                  gboolean       *old_uids_valid);
379         /**
380          * Tell the folder system if a \c FolderItem should be scanned
381          * (cache data syncronized with the folder content) when it is required
382          * because the \c FolderItem's content changed. If NULL the folder
383          * system will not do automatic scanning of \c FolderItems
384          *
385          * \param folder The \c Folder that contains the \c FolderItem
386          * \param item The \c FolderItem which's content should be checked
387          * \return TRUE if the \c FolderItem should be scanned, FALSE otherwise
388          */
389         gboolean        (*scan_required)        (Folder         *folder,
390                                                  FolderItem     *item);
391
392         /* Message functions */
393         /**
394          * Get a MsgInfo for a message in a \c FolderItem
395          *
396          * \param folder The \c Folder containing the message
397          * \param item The \c FolderItem containing the message
398          * \param num The message number of the message
399          * \return A pointer to a \c MsgInfo decribing the message or \c 
400          *         NULL in case of an error
401          */
402         MsgInfo         *(*get_msginfo)         (Folder         *folder,
403                                                  FolderItem     *item,
404                                                  gint            num);
405         /**
406          * Get \c MsgInfos for a list of message numbers
407          *
408          * \param folder The \c Folder containing the message
409          * \param item The \c FolderItem containing the message
410          * \param msgnum_list A list of message numbers for which the
411          *                    \c MsgInfos should be fetched
412          * \return A list of \c MsgInfos for the messages in the \c msgnum_list
413          *         that really exist. Messages that are not found can simply
414          *         be left out.
415          */
416         MsgInfoList     *(*get_msginfos)        (Folder         *folder,
417                                                  FolderItem     *item,
418                                                  MsgNumberList  *msgnum_list);
419         /**
420          * Get the filename for a message. This can either be the real message
421          * file for local folders or a temporary file for remote folders.
422          *
423          * \param folder The \c Folder containing the message
424          * \param item The \c FolderItem containing the message
425          * \param num The message number of the message
426          * \return A string with the filename of the message file. The returned
427          *         string has to be freed with \c g_free(). If message is not
428          *         available return NULL.
429          */
430         gchar           *(*fetch_msg)           (Folder         *folder,
431                                                  FolderItem     *item,
432                                                  gint            num);
433         gchar           *(*fetch_msg_full)      (Folder         *folder,
434                                                  FolderItem     *item,
435                                                  gint            num,
436                                                  gboolean        headers,
437                                                  gboolean        body);
438         /**
439          * Add a single message file to a folder with the given flags (if
440          * flag handling is supported by the folder)
441          *
442          * \param folder The target \c Folder for the message
443          * \param dest the target \c FolderItem for the message
444          * \param file The file that contains the message
445          * \param flags The flags the new message should have in the folder
446          * \return 0 on success, a negative number otherwise
447          */
448         gint            (*add_msg)              (Folder         *folder,
449                                                  FolderItem     *dest,
450                                                  const gchar    *file,
451                                                  MsgFlags       *flags);
452         /**
453          * Add multiple messages to a \c FolderItem. If NULL the folder
454          * system will add messages with \c add_msg one by one
455          *
456          * \param folder The target \c Folder for the messages
457          * \param dest the target \c FolderItem for the messages
458          * \param file_list A list of \c MsgFileInfos which contain the
459          *                  filenames and flags for the new messages
460          * \param relation Insert tuples of (MsgFileInfo, new message number) to
461          *                 provide feedback for the folder system which new
462          *                 message number a \c MsgFileInfo got in dest. Insert
463          *                 0 if the new message number is unknown.
464          */
465         gint            (*add_msgs)             (Folder         *folder,
466                                                  FolderItem     *dest,
467                                                  GSList         *file_list,
468                                                  GRelation      *relation);
469         /**
470          * Copy a message to a FolderItem
471          *
472          * \param folder The \c Folder of the destination FolderItem
473          * \param dest The destination \c FolderItem for the message
474          * \param msginfo The message that should be copied
475          * \return The message number the copied message got, 0 if it is
476          *         unknown because message numbers are assigned by an external
477          *         system and not available after copying or a negative number
478          *         if an error occuried
479          */
480         gint            (*copy_msg)             (Folder         *folder,
481                                                  FolderItem     *dest,
482                                                  MsgInfo        *msginfo);
483         /**
484          * Copy multiple messages to a \c FolderItem. If \c NULL the folder
485          * system will use \c copy_msg to copy messages one by one.
486          *
487          * \param folder The \c Folder of the destination FolderItem
488          * \param dest The destination \c FolderItem for the message
489          * \param msglist A list of \c MsgInfos which should be copied to dest
490          * \param relation Insert tuples of (MsgInfo, new message number) to
491          *                 provide feedback for the folder system which new
492          *                 message number a \c MsgInfo got in dest. Insert
493          *                 0 if the new message number is unknown.
494          * \return 0 on success, a negative number otherwise
495          */
496         gint            (*copy_msgs)            (Folder         *folder,
497                                                  FolderItem     *dest,
498                                                  MsgInfoList    *msglist,
499                                                  GRelation      *relation);
500         /**
501          * Remove a message from a \c FolderItem.
502          *
503          * \param folder The \c Folder of the message
504          * \param item The \c FolderItem containing the message
505          * \param num The message number of the message
506          * \return 0 on success, a negative number otherwise
507          */
508         gint            (*remove_msg)           (Folder         *folder,
509                                                  FolderItem     *item,
510                                                  gint            num);
511         gint            (*remove_msgs)          (Folder         *folder,
512                                                  FolderItem     *item,
513                                                  MsgInfoList    *msglist,
514                                                  GRelation      *relation);
515         /**
516          * Remove all messages in a \ c FolderItem
517          *
518          * \param folder The \c Folder of the \c FolderItem
519          * \param item The \FolderItem which's messages should be deleted
520          * \return 0 on succes, a negative number otherwise
521          */
522         gint            (*remove_all_msg)       (Folder         *folder,
523                                                  FolderItem     *item);
524         /**
525          * Check if a message has been modified by someone else
526          *
527          * \param folder The \c Folder of the message
528          * \param item The \c FolderItem containing the message
529          * \param msginfo The \c MsgInfo for the message that should be checked
530          * \return \c TRUE if the message was modified, \c FALSE otherwise
531          */
532         gboolean        (*is_msg_changed)       (Folder         *folder,
533                                                  FolderItem     *item,
534                                                  MsgInfo        *msginfo);
535         /**
536          * Update a message's flags in the folder data. If NULL only the
537          * internal flag management will be used. The function has to set
538          * \c msginfo->flags.perm_flags. It does not have to set the flags
539          * that it got as \c newflags. If a flag can not be set in this
540          * \c FolderClass the function can refuse to set it. Flags that are not
541          * supported by the \c FolderClass should not be refused. They will be
542          * managed by the internal cache in this case.
543          *
544          * \param folder The \c Folder of the message
545          * \param item The \c FolderItem of the message
546          * \param msginfo The \c MsgInfo for the message which's flags should be
547          *                updated
548          * \param newflags The flags the message should get
549          */
550         void            (*change_flags)         (Folder         *folder,
551                                                  FolderItem     *item,
552                                                  MsgInfo        *msginfo,
553                                                  MsgPermFlags    newflags);
554         /**
555          * Get the flags for a list of messages. Flags that are not supported
556          * by the folder should be preserved. They can be copied from
557          * \c msginfo->flags.perm_flags
558          *
559          * \param folder The \c Folder of the messages
560          * \param item The \c FolderItem of the messages
561          * \param msglist The list of \c MsgInfos for which the flags should
562          *                   be returned
563          * \param msgflags A \c GRelation for tuples of (MsgInfo, new permanent
564          *        flags for MsgInfo). Add tuples for the messages in msglist
565          * \return 0 on success, a negative number otherwise
566          */
567         gint            (*get_flags)            (Folder         *folder,
568                                                  FolderItem     *item,
569                                                  MsgInfoList    *msglist,
570                                                  GRelation      *msgflags);
571         
572         void            (*set_batch)            (Folder         *folder,
573                                                  FolderItem     *item,
574                                                  gboolean        batch);
575         void            (*synchronise)          (FolderItem     *item);
576 };
577
578 struct _FolderItem
579 {
580         SpecialFolderItemType stype;
581
582         gchar *name; /* UTF-8 */
583         gchar *path; /* UTF-8 */
584
585         time_t mtime;
586
587         gint new_msgs;
588         gint unread_msgs;
589         gint total_msgs;
590         gint unreadmarked_msgs;
591         gint marked_msgs;
592
593         gint last_num;
594
595         MsgCache *cache;
596
597         /* special flags */
598         guint no_sub         : 1; /* no child allowed?    */
599         guint no_select      : 1; /* not selectable?      */
600         guint collapsed      : 1; /* collapsed item       */
601         guint thread_collapsed      : 1; /* collapsed item       */
602         guint threaded       : 1; /* threaded folder view */
603         guint hide_read_msgs : 1; /* hide read messages   */
604         guint ret_rcpt       : 1; /* return receipt       */
605         guint search_match   : 1;
606
607         gint op_count;
608         guint opened         : 1; /* opened by summary view */
609         FolderItemUpdateFlags update_flags; /* folderview for this folder should be updated */
610
611         FolderSortKey sort_key;
612         FolderSortType sort_type;
613
614         GNode *node;
615
616         Folder *folder;
617
618         PrefsAccount *account;
619
620         gboolean apply_sub;
621         
622         GSList *mark_queue;
623
624         gpointer data;
625
626         FolderItemPrefs * prefs;
627         
628         /* for faster search of special parents */
629         SpecialFolderItemType parent_stype;
630 };
631
632 struct _PersistPrefs
633 {
634         FolderSortKey   sort_key;
635         FolderSortType  sort_type;
636         guint           collapsed       : 1;
637         guint           thread_collapsed        : 1;
638         guint           threaded        : 1;
639         guint           hide_read_msgs  : 1; /* CLAWS */
640         guint           ret_rcpt        : 1; /* CLAWS */
641 };
642
643 struct _FolderUpdateData
644 {
645         Folder                  *folder;
646         FolderUpdateFlags        update_flags;
647         FolderItem              *item;
648 };
649
650 struct _FolderItemUpdateData
651 {
652         FolderItem              *item;
653         FolderItemUpdateFlags    update_flags;
654         MsgInfo                 *msg;
655 };
656
657 void        folder_system_init          (void);
658 void        folder_register_class       (FolderClass    *klass);
659 void        folder_unregister_class     (FolderClass    *klass);
660 Folder     *folder_new                  (FolderClass    *type,
661                                          const gchar    *name,
662                                          const gchar    *path);
663 void        folder_init                 (Folder         *folder,
664                                          const gchar    *name);
665
666 void        folder_destroy              (Folder         *folder);
667
668 void        folder_set_xml              (Folder          *folder,
669                                          XMLTag          *tag);
670 XMLTag     *folder_get_xml              (Folder          *folder);
671
672 FolderItem *folder_item_new             (Folder         *folder,
673                                          const gchar    *name,
674                                          const gchar    *path);
675 void        folder_item_append          (FolderItem     *parent,
676                                          FolderItem     *item);
677 void        folder_item_remove          (FolderItem     *item);
678 void        folder_item_remove_children (FolderItem     *item);
679 void        folder_item_destroy         (FolderItem     *item);
680 FolderItem *folder_item_parent          (FolderItem     *item);
681
682 void        folder_item_set_xml         (Folder          *folder,
683                                          FolderItem      *item,
684                                          XMLTag          *tag);
685 XMLTag     *folder_item_get_xml         (Folder          *folder,
686                                          FolderItem      *item);
687
688 void        folder_set_ui_func  (Folder         *folder,
689                                  FolderUIFunc    func,
690                                  gpointer        data);
691 void        folder_set_name     (Folder         *folder,
692                                  const gchar    *name);
693 void        folder_set_sort     (Folder         *folder,
694                                  guint           sort);
695 void        folder_tree_destroy (Folder         *folder);
696
697 void   folder_add               (Folder         *folder);
698 void   folder_remove            (Folder         *folder);
699
700 GList *folder_get_list          (void);
701 gint   folder_read_list         (void);
702 void   folder_write_list        (void);
703 void   folder_scan_tree         (Folder *folder);
704 FolderItem *folder_create_folder(FolderItem     *parent, const gchar *name);
705 gint   folder_item_rename       (FolderItem *item, gchar *newname);
706 void   folder_update_op_count           (void);
707 void   folder_func_to_all_folders       (FolderItemFunc function,
708                                          gpointer data);
709 void folder_count_total_msgs(guint *new_msgs, guint *unread_msgs, 
710                              guint *unreadmarked_msgs, guint *marked_msgs,
711                              guint *total_msgs);
712 gchar *folder_get_status        (GPtrArray      *folders,
713                                  gboolean        full);
714
715 Folder     *folder_find_from_path               (const gchar    *path);
716 Folder     *folder_find_from_name               (const gchar    *name,
717                                                  FolderClass    *klass);
718 FolderItem *folder_find_item_from_path          (const gchar    *path);
719 FolderClass *folder_get_class_from_string       (const gchar    *str);
720 FolderItem *folder_find_child_item_by_name      (FolderItem     *item,
721                                                  const gchar    *name);
722 gchar      *folder_get_identifier               (Folder         *folder);
723 gchar      *folder_item_get_identifier          (FolderItem     *item);
724 FolderItem *folder_find_item_from_identifier    (const gchar    *identifier);
725 gchar      *folder_item_get_name                (FolderItem     *item);
726
727 Folder     *folder_get_default_folder   (void);
728 FolderItem *folder_get_default_inbox    (void);
729 FolderItem *folder_get_default_outbox   (void);
730 FolderItem *folder_get_default_draft    (void);
731 FolderItem *folder_get_default_queue    (void);
732 FolderItem *folder_get_default_trash    (void);
733 FolderItem *folder_get_default_processing (void);
734 void folder_set_missing_folders         (void);
735 void folder_unref_account_all           (PrefsAccount   *account);
736
737 /* return value is locale encoded file name */
738 gchar *folder_item_get_path             (FolderItem     *item);
739
740 gint   folder_item_open                 (FolderItem     *item);
741 gint   folder_item_close                (FolderItem     *item);
742 gint   folder_item_scan                 (FolderItem     *item);
743 gint   folder_item_syncronize_flags     (FolderItem     *item);
744 void   folder_item_scan_foreach         (GHashTable     *table);
745 MsgInfo *folder_item_get_msginfo        (FolderItem     *item,
746                                          gint            num);
747 MsgInfo *folder_item_get_msginfo_by_msgid(FolderItem    *item,
748                                          const gchar    *msgid);
749 GSList *folder_item_get_msg_list        (FolderItem     *item);
750 /* return value is locale charset */
751 gchar *folder_item_fetch_msg            (FolderItem     *item,
752                                          gint            num);
753 gchar *folder_item_fetch_msg_full       (FolderItem     *item,
754                                          gint            num, 
755                                          gboolean        get_headers,
756                                          gboolean        get_body);
757 gint   folder_item_fetch_all_msg        (FolderItem     *item);
758 gint   folder_item_add_msg              (FolderItem     *dest,
759                                          const gchar    *file,
760                                          MsgFlags       *flags,
761                                          gboolean        remove_source);
762 gint   folder_item_add_msgs             (FolderItem     *dest,
763                                          GSList         *file_list,
764                                          gboolean        remove_source);
765 gint   folder_item_move_to              (FolderItem     *src,
766                                          FolderItem     *dest,
767                                          FolderItem    **new_item);
768 gint   folder_item_move_msg             (FolderItem     *dest,
769                                          MsgInfo        *msginfo);
770 gint   folder_item_move_msgs            (FolderItem     *dest,
771                                          GSList         *msglist);
772 gint   folder_item_copy_msg             (FolderItem     *dest,
773                                          MsgInfo        *msginfo);
774 gint   folder_item_copy_msgs            (FolderItem     *dest,
775                                          GSList         *msglist);
776 gint   folder_item_remove_msg           (FolderItem     *item,
777                                          gint            num);
778 gint   folder_item_remove_msgs          (FolderItem     *item,
779                                          GSList         *msglist);
780 gint   folder_item_remove_all_msg       (FolderItem     *item);
781 void    folder_item_change_msg_flags    (FolderItem     *item,
782                                          MsgInfo        *msginfo,
783                                          MsgPermFlags    newflags);
784 gboolean folder_item_is_msg_changed     (FolderItem     *item,
785                                          MsgInfo        *msginfo);
786 /* return value is locale chaset */
787 gchar *folder_item_get_cache_file       (FolderItem     *item);
788 gchar *folder_item_get_mark_file        (FolderItem     *item);
789 gchar * folder_item_get_identifier      (FolderItem * item);
790
791 GHashTable *folder_persist_prefs_new    (Folder *folder);
792 void folder_persist_prefs_free          (GHashTable *pptable);
793 const PersistPrefs *folder_get_persist_prefs
794                                         (GHashTable *pptable, const char *name);
795
796 void folder_item_restore_persist_prefs  (FolderItem *item, GHashTable *pptable);
797 void folder_clean_cache_memory          (void);
798 void folder_clean_cache_memory_force    (void);
799 void folder_item_write_cache            (FolderItem *item);
800 void folder_item_set_default_flags      (FolderItem *dest, MsgFlags *flags);
801
802 void folder_item_apply_processing       (FolderItem *item);
803
804 void folder_item_update                 (FolderItem *item,
805                                          FolderItemUpdateFlags update_flags);
806 void folder_item_update_recursive       (FolderItem *item,
807                                          FolderItemUpdateFlags update_flags);
808 void folder_item_update_freeze          (void);
809 void folder_item_update_thaw            (void);
810 void folder_item_set_batch              (FolderItem *item, gboolean batch);
811 gboolean folder_has_parent_of_type      (FolderItem *item, SpecialFolderItemType type);
812 void folder_synchronise                 (Folder *folder);
813 gboolean folder_want_synchronise        (Folder *folder);
814
815 #endif /* __FOLDER_H__ */