2004-12-14 [colin] 0.9.13cvs17
[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         /**
434          * Add a single message file to a folder with the given flags (if
435          * flag handling is supported by the folder)
436          *
437          * \param folder The target \c Folder for the message
438          * \param dest the target \c FolderItem for the message
439          * \param file The file that contains the message
440          * \param flags The flags the new message should have in the folder
441          * \return 0 on success, a negative number otherwise
442          */
443         gint            (*add_msg)              (Folder         *folder,
444                                                  FolderItem     *dest,
445                                                  const gchar    *file,
446                                                  MsgFlags       *flags);
447         /**
448          * Add multiple messages to a \c FolderItem. If NULL the folder
449          * system will add messages with \c add_msg one by one
450          *
451          * \param folder The target \c Folder for the messages
452          * \param dest the target \c FolderItem for the messages
453          * \param file_list A list of \c MsgFileInfos which contain the
454          *                  filenames and flags for the new messages
455          * \param relation Insert tuples of (MsgFileInfo, new message number) to
456          *                 provide feedback for the folder system which new
457          *                 message number a \c MsgFileInfo got in dest. Insert
458          *                 0 if the new message number is unknown.
459          */
460         gint            (*add_msgs)             (Folder         *folder,
461                                                  FolderItem     *dest,
462                                                  GSList         *file_list,
463                                                  GRelation      *relation);
464         /**
465          * Copy a message to a FolderItem
466          *
467          * \param folder The \c Folder of the destination FolderItem
468          * \param dest The destination \c FolderItem for the message
469          * \param msginfo The message that should be copied
470          * \return The message number the copied message got, 0 if it is
471          *         unknown because message numbers are assigned by an external
472          *         system and not available after copying or a negative number
473          *         if an error occuried
474          */
475         gint            (*copy_msg)             (Folder         *folder,
476                                                  FolderItem     *dest,
477                                                  MsgInfo        *msginfo);
478         /**
479          * Copy multiple messages to a \c FolderItem. If \c NULL the folder
480          * system will use \c copy_msg to copy messages one by one.
481          *
482          * \param folder The \c Folder of the destination FolderItem
483          * \param dest The destination \c FolderItem for the message
484          * \param msglist A list of \c MsgInfos which should be copied to dest
485          * \param relation Insert tuples of (MsgInfo, new message number) to
486          *                 provide feedback for the folder system which new
487          *                 message number a \c MsgInfo got in dest. Insert
488          *                 0 if the new message number is unknown.
489          * \return 0 on success, a negative number otherwise
490          */
491         gint            (*copy_msgs)            (Folder         *folder,
492                                                  FolderItem     *dest,
493                                                  MsgInfoList    *msglist,
494                                                  GRelation      *relation);
495         /**
496          * Remove a message from a \c FolderItem.
497          *
498          * \param folder The \c Folder of the message
499          * \param item The \c FolderItem containing the message
500          * \param num The message number of the message
501          * \return 0 on success, a negative number otherwise
502          */
503         gint            (*remove_msg)           (Folder         *folder,
504                                                  FolderItem     *item,
505                                                  gint            num);
506         /**
507          * Remove all messages in a \ c FolderItem
508          *
509          * \param folder The \c Folder of the \c FolderItem
510          * \param item The \FolderItem which's messages should be deleted
511          * \return 0 on succes, a negative number otherwise
512          */
513         gint            (*remove_all_msg)       (Folder         *folder,
514                                                  FolderItem     *item);
515         /**
516          * Check if a message has been modified by someone else
517          *
518          * \param folder The \c Folder of the message
519          * \param item The \c FolderItem containing the message
520          * \param msginfo The \c MsgInfo for the message that should be checked
521          * \return \c TRUE if the message was modified, \c FALSE otherwise
522          */
523         gboolean        (*is_msg_changed)       (Folder         *folder,
524                                                  FolderItem     *item,
525                                                  MsgInfo        *msginfo);
526         /**
527          * Update a message's flags in the folder data. If NULL only the
528          * internal flag management will be used. The function has to set
529          * \c msginfo->flags.perm_flags. It does not have to set the flags
530          * that it got as \c newflags. If a flag can not be set in this
531          * \c FolderClass the function can refuse to set it. Flags that are not
532          * supported by the \c FolderClass should not be refused. They will be
533          * managed by the internal cache in this case.
534          *
535          * \param folder The \c Folder of the message
536          * \param item The \c FolderItem of the message
537          * \param msginfo The \c MsgInfo for the message which's flags should be
538          *                updated
539          * \param newflags The flags the message should get
540          */
541         void            (*change_flags)         (Folder         *folder,
542                                                  FolderItem     *item,
543                                                  MsgInfo        *msginfo,
544                                                  MsgPermFlags    newflags);
545         /**
546          * Get the flags for a list of messages. Flags that are not supported
547          * by the folder should be preserved. They can be copied from
548          * \c msginfo->flags.perm_flags
549          *
550          * \param folder The \c Folder of the messages
551          * \param item The \c FolderItem of the messages
552          * \param msglist The list of \c MsgInfos for which the flags should
553          *                   be returned
554          * \param msgflags A \c GRelation for tuples of (MsgInfo, new permanent
555          *        flags for MsgInfo). Add tuples for the messages in msglist
556          * \return 0 on success, a negative number otherwise
557          */
558         gint            (*get_flags)            (Folder         *folder,
559                                                  FolderItem     *item,
560                                                  MsgInfoList    *msglist,
561                                                  GRelation      *msgflags);
562 };
563
564 struct _FolderItem
565 {
566         SpecialFolderItemType stype;
567
568         gchar *name;
569         gchar *path;
570
571         time_t mtime;
572
573         gint new_msgs;
574         gint unread_msgs;
575         gint total_msgs;
576         gint unreadmarked_msgs;
577
578         gint last_num;
579
580         MsgCache *cache;
581
582         /* special flags */
583         guint no_sub         : 1; /* no child allowed?    */
584         guint no_select      : 1; /* not selectable?      */
585         guint collapsed      : 1; /* collapsed item       */
586         guint thread_collapsed      : 1; /* collapsed item       */
587         guint threaded       : 1; /* threaded folder view */
588         guint hide_read_msgs : 1; /* hide read messages   */
589         guint ret_rcpt       : 1; /* return receipt       */
590
591         gint op_count;
592         guint opened         : 1; /* opened by summary view */
593         FolderItemUpdateFlags update_flags; /* folderview for this folder should be updated */
594
595         FolderSortKey sort_key;
596         FolderSortType sort_type;
597
598         GNode *node;
599
600         Folder *folder;
601
602         PrefsAccount *account;
603
604         gboolean apply_sub;
605         
606         GSList *mark_queue;
607
608         gpointer data;
609
610         FolderItemPrefs * prefs;
611 };
612
613 struct _PersistPrefs
614 {
615         FolderSortKey   sort_key;
616         FolderSortType  sort_type;
617         guint           collapsed       : 1;
618         guint           thread_collapsed        : 1;
619         guint           threaded        : 1;
620         guint           hide_read_msgs  : 1; /* CLAWS */
621         guint           ret_rcpt        : 1; /* CLAWS */
622 };
623
624 struct _FolderUpdateData
625 {
626         Folder                  *folder;
627         FolderUpdateFlags        update_flags;
628         FolderItem              *item;
629 };
630
631 struct _FolderItemUpdateData
632 {
633         FolderItem              *item;
634         FolderItemUpdateFlags    update_flags;
635         MsgInfo                 *msg;
636 };
637
638 void        folder_system_init          (void);
639 void        folder_register_class       (FolderClass    *klass);
640 void        folder_unregister_class     (FolderClass    *klass);
641 Folder     *folder_new                  (FolderClass    *type,
642                                          const gchar    *name,
643                                          const gchar    *path);
644 void        folder_init                 (Folder         *folder,
645                                          const gchar    *name);
646
647 void        folder_destroy              (Folder         *folder);
648
649 void        folder_set_xml              (Folder          *folder,
650                                          XMLTag          *tag);
651 XMLTag     *folder_get_xml              (Folder          *folder);
652
653 FolderItem *folder_item_new             (Folder         *folder,
654                                          const gchar    *name,
655                                          const gchar    *path);
656 void        folder_item_append          (FolderItem     *parent,
657                                          FolderItem     *item);
658 void        folder_item_remove          (FolderItem     *item);
659 void        folder_item_remove_children (FolderItem     *item);
660 void        folder_item_destroy         (FolderItem     *item);
661 FolderItem *folder_item_parent          (FolderItem     *item);
662
663 void        folder_item_set_xml         (Folder          *folder,
664                                          FolderItem      *item,
665                                          XMLTag          *tag);
666 XMLTag     *folder_item_get_xml         (Folder          *folder,
667                                          FolderItem      *item);
668
669 void        folder_set_ui_func  (Folder         *folder,
670                                  FolderUIFunc    func,
671                                  gpointer        data);
672 void        folder_set_name     (Folder         *folder,
673                                  const gchar    *name);
674 void        folder_set_sort     (Folder         *folder,
675                                  guint           sort);
676 void        folder_tree_destroy (Folder         *folder);
677
678 void   folder_add               (Folder         *folder);
679 void   folder_remove            (Folder         *folder);
680
681 GList *folder_get_list          (void);
682 gint   folder_read_list         (void);
683 void   folder_write_list        (void);
684 void   folder_scan_tree         (Folder *folder);
685 FolderItem *folder_create_folder(FolderItem     *parent, const gchar *name);
686 gint   folder_item_rename       (FolderItem *item, gchar *newname);
687 void   folder_update_op_count           (void);
688 void   folder_func_to_all_folders       (FolderItemFunc function,
689                                          gpointer data);
690 void   folder_count_total_msgs  (guint          *new_msgs,
691                                  guint          *unread_msgs,
692                                  guint          *unreadmarked_msgs,
693                                  guint          *total_msgs);
694 gchar *folder_get_status        (GPtrArray      *folders,
695                                  gboolean        full);
696
697 Folder     *folder_find_from_path               (const gchar    *path);
698 Folder     *folder_find_from_name               (const gchar    *name,
699                                                  FolderClass    *klass);
700 FolderItem *folder_find_item_from_path          (const gchar    *path);
701 FolderClass *folder_get_class_from_string       (const gchar    *str);
702 FolderItem *folder_find_child_item_by_name      (FolderItem     *item,
703                                                  const gchar    *name);
704 gchar      *folder_get_identifier               (Folder         *folder);
705 gchar      *folder_item_get_identifier          (FolderItem     *item);
706 FolderItem *folder_find_item_from_identifier    (const gchar    *identifier);
707 gchar      *folder_item_get_name                (FolderItem     *item);
708
709 Folder     *folder_get_default_folder   (void);
710 FolderItem *folder_get_default_inbox    (void);
711 FolderItem *folder_get_default_outbox   (void);
712 FolderItem *folder_get_default_draft    (void);
713 FolderItem *folder_get_default_queue    (void);
714 FolderItem *folder_get_default_trash    (void);
715 FolderItem *folder_get_default_processing (void);
716 void folder_set_missing_folders         (void);
717 void folder_unref_account_all           (PrefsAccount   *account);
718
719 gchar *folder_item_get_path             (FolderItem     *item);
720
721 gint   folder_item_open                 (FolderItem     *item);
722 gint   folder_item_close                (FolderItem     *item);
723 gint   folder_item_scan                 (FolderItem     *item);
724 gint   folder_item_syncronize_flags     (FolderItem     *item);
725 void   folder_item_scan_foreach         (GHashTable     *table);
726 MsgInfo *folder_item_get_msginfo        (FolderItem     *item,
727                                          gint            num);
728 MsgInfo *folder_item_get_msginfo_by_msgid(FolderItem    *item,
729                                          const gchar    *msgid);
730 GSList *folder_item_get_msg_list        (FolderItem     *item);
731 gchar *folder_item_fetch_msg            (FolderItem     *item,
732                                          gint            num);
733 gint   folder_item_fetch_all_msg        (FolderItem     *item);
734 gint   folder_item_add_msg              (FolderItem     *dest,
735                                          const gchar    *file,
736                                          MsgFlags       *flags,
737                                          gboolean        remove_source);
738 gint   folder_item_add_msgs             (FolderItem     *dest,
739                                          GSList         *file_list,
740                                          gboolean        remove_source);
741 gint   folder_item_move_to              (FolderItem     *src,
742                                          FolderItem     *dest,
743                                          FolderItem    **new_item);
744 gint   folder_item_move_msg             (FolderItem     *dest,
745                                          MsgInfo        *msginfo);
746 gint   folder_item_move_msgs            (FolderItem     *dest,
747                                          GSList         *msglist);
748 gint   folder_item_copy_msg             (FolderItem     *dest,
749                                          MsgInfo        *msginfo);
750 gint   folder_item_copy_msgs            (FolderItem     *dest,
751                                          GSList         *msglist);
752 gint   folder_item_remove_msg           (FolderItem     *item,
753                                          gint            num);
754 gint   folder_item_remove_msgs          (FolderItem     *item,
755                                          GSList         *msglist);
756 gint   folder_item_remove_all_msg       (FolderItem     *item);
757 void    folder_item_change_msg_flags    (FolderItem     *item,
758                                          MsgInfo        *msginfo,
759                                          MsgPermFlags    newflags);
760 gboolean folder_item_is_msg_changed     (FolderItem     *item,
761                                          MsgInfo        *msginfo);
762 gchar *folder_item_get_cache_file       (FolderItem     *item);
763 gchar *folder_item_get_mark_file        (FolderItem     *item);
764 gchar * folder_item_get_identifier      (FolderItem * item);
765
766 GHashTable *folder_persist_prefs_new    (Folder *folder);
767 void folder_persist_prefs_free          (GHashTable *pptable);
768 const PersistPrefs *folder_get_persist_prefs
769                                         (GHashTable *pptable, const char *name);
770
771 void folder_item_restore_persist_prefs  (FolderItem *item, GHashTable *pptable);
772 void folder_clean_cache_memory          (void);
773 void folder_item_write_cache            (FolderItem *item);
774 void folder_item_set_default_flags      (FolderItem *dest, MsgFlags *flags);
775
776 void folder_item_apply_processing       (FolderItem *item);
777
778 void folder_item_update                 (FolderItem *item,
779                                          FolderItemUpdateFlags update_flags);
780 void folder_item_update_recursive       (FolderItem *item,
781                                          FolderItemUpdateFlags update_flags);
782 void folder_item_update_freeze          (void);
783 void folder_item_update_thaw            (void);
784
785 #endif /* __FOLDER_H__ */