0.9.9claws37
[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_NEW_FOLDER               = 1 << 0,
104         FOLDER_DESTROY_FOLDER           = 1 << 1,
105         FOLDER_TREE_CHANGED             = 1 << 2,
106         FOLDER_NEW_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 } FolderItemUpdateFlags;
115
116 typedef void (*FolderUIFunc)            (Folder         *folder,
117                                          FolderItem     *item,
118                                          gpointer        data);
119 typedef void (*FolderDestroyNotify)     (Folder         *folder,
120                                          FolderItem     *item,
121                                          gpointer        data);
122 typedef void (*FolderItemFunc)          (FolderItem     *item,
123                                          gpointer        data);
124
125
126 #include "folder_item_prefs.h"
127
128 #include "procmsg.h"
129 #include "msgcache.h"
130 #include "xml.h"
131 #include "prefs_account.h"
132
133 struct _Folder
134 {
135         FolderClass *klass;
136
137         gchar *name;
138         PrefsAccount *account;
139
140         FolderItem *inbox;
141         FolderItem *outbox;
142         FolderItem *draft;
143         FolderItem *queue;
144         FolderItem *trash;
145
146         FolderUIFunc ui_func;
147         gpointer     ui_func_data;
148
149         GNode *node;
150
151         gpointer data;
152
153         GHashTable *newsart;
154 };
155
156 struct _FolderClass
157 {
158         /**
159          * A numeric identifier for the FolderClass. Will be removed in the future
160          */
161         FolderType  type;
162         /**
163          * A string identifier for the FolderClass. Currently used in folderlist.xml.
164          * Should be lowercase.
165          */
166         gchar      *idstr;
167         /**
168          * A string for the User Interface that identifies the FolderClass to the
169          * user. Can be upper and lowercase unlike the idstr.
170          */
171         gchar      *uistr;
172
173         /* virtual functions */
174
175         /* Folder funtions */
176         /**
177          * Create a new \c Folder of this \c FolderClass.
178          *
179          * \param name The name of the new Folder
180          * \param path The path of the new Folder
181          * \return The new \c Folder, or \c NULL when creating the \c Folder 
182          *         failed
183          */
184         Folder          *(*new_folder)          (const gchar    *name,
185                                                  const gchar    *path);
186         /**
187          * Destroy a \c Folder of this \c FolderClass, frees all resources
188          * allocated by the Folder
189          *
190          * \param folder The \c Folder that should be destroyed.
191          */
192         void            (*destroy_folder)       (Folder         *folder);
193         /**
194          * Set the Folder's internal attributes from an \c XMLTag. Also sets the
195          * parameters of the root-FolderItem of the \c Folder. If \c NULL
196          * the default function of the basic \ยข FolderClass is used, so it
197          * must not be \c NULL if one of the parent \c FolderClasses has a \c set_xml
198          * function. In that case the parent \c FolderClass' \c set_xml function
199          * can be used or it has to be called with the \c folder and \c tag by
200          * the implementation.
201          *
202          * \param folder The \c Folder which's attributes should be updated
203          * \param tag The \c XMLTag containing the \c XMLAttrs for the attributes
204          */
205         void             (*set_xml)             (Folder         *folder,
206                                                  XMLTag         *tag);
207         /**
208          * Get an \c XMLTag for the attributes of the \c Folder and the root-FolderItem
209          * of the \c Folder. If \c NULL the default implementation for the basic
210          * FolderClass will be used, so it must not be \c NULL if one of the
211          * parent \c FolderClasses has it's own implementation for \c get_xml.
212          * In that case the parent FolderClass' \c get_xml function can be
213          * used or the \c XMLTag has to be fetched from the parent's \c get_xml
214          * function and then the \c FolderClass specific attributes can be
215          * added to it.
216          *
217          * \param Folder The \c Folder which's attributes should be set in the
218          *               \c XMLTag's \c XMLAttrs
219          * \return XMLTag An \c XMLTag with \c XMLAttrs containing the \c Folder's
220          *                attributes.
221          */
222         XMLTag          *(*get_xml)             (Folder         *folder);
223         /**
224          * Rebuild the folder tree from the folder's data
225          * \todo New implementations of MH and IMAP are actually syncronizing
226          *       the tree with the folder by reusing the old \c FolderItems.
227          *       Claws still destroys the old tree before calling this function.
228          *
229          * \param folder The folder which's tree should be rebuild
230          * \return 0 on success, a negative number otherwise
231          */
232         gint            (*scan_tree)            (Folder         *folder);
233
234         gint            (*create_tree)          (Folder         *folder);
235
236         /* FolderItem functions */
237         /**
238          * Create a new \c FolderItem structure for the \c FolderClass.
239          * \c FolderClasses can have their own \c FolderItem structure with
240          * extra attributes.
241          *
242          * \param folder The \c Folder for that a \c FolderItem should be
243          *               created
244          * \return The new \c FolderItem or NULL in case of an error
245          */
246         FolderItem      *(*item_new)            (Folder         *folder);
247         /**
248          * Destroy a \c FolderItem from this \c FolderClass. The \c FolderClass
249          * has to free all private resources used by the \c FolderItem.
250          *
251          * \param folder The \c Folder of the \c FolderItem
252          * \param item The \c FolderItem that should be destroyed
253          */
254         void             (*item_destroy)        (Folder         *folder,
255                                                  FolderItem     *item);
256         /**
257          * Set the \c FolderItem's internal attributes from an \c XMLTag. If
258          * \c NULL the default function of the basic \c FolderClass is used, so it
259          * must not be \c NULL if one of the parent \c FolderClasses has a \c item_set_xml
260          * function. In that case the parent \c FolderClass' \c item_set_xml function
261          * can be used or it has to be called with the \c folder, \c item and \c tag by
262          * the implementation.
263          *
264          * \param folder The \c Folder of the \c FolderItem
265          * \param item The \c FolderItems which's attributes should be set
266          * \param tag The \c XMLTag with \c XMLAttrs for the \c FolderItem's
267          *            attributes
268          */
269         void             (*item_set_xml)        (Folder         *folder,
270                                                  FolderItem     *item,
271                                                  XMLTag         *tag);
272         /**
273          * Get an \c XMLTag for the attributes of the \c FolderItem If \c NULL
274          * the default implementation for the basic \c FolderClass will be used,
275          * so it must not be \c NULL if one of the parent \c FolderClasses has
276          * it's own implementation for \c item_get_xml. In that case the parent 
277          * FolderClass' \c item_get_xml function can be used or the \c XMLTag
278          * has to be fetched from the parent's \c item_get_xml function and 
279          * then the \c FolderClass specific attributes can be added to it.
280          *
281          * \param folder The \c Folder of the \c FolderItem
282          * \parem item The \c FolderItem which's attributes should be set in
283          *             the \c XMLTag's \c XMLAttrs
284          * \return An \c XMLTag with \c XMLAttrs containing the \c FolderItem's
285          *         attributes.
286          */
287         XMLTag          *(*item_get_xml)        (Folder         *folder,
288                                                  FolderItem     *item);
289         /**
290          * Get a local path for the \c FolderItem where Sylpheed can save
291          * it's cache data. For local directory based folders this can be the
292          * real path. For other folders it can be the local cache directory.
293          *
294          * \param folder The \c Folder of the \c FolderItem
295          * \param item The \c FolderItem for that a path should be returned
296          * \return A path for the \c FolderItem
297          */
298         gchar           *(*item_get_path)       (Folder         *folder,
299                                                  FolderItem     *item);
300         /**
301          * Create a new \c FolderItem. The function must use folder_item_append
302          * to add the new \c FolderItem to the folder tree
303          *
304          * \param folder The \c Folder in which a new \c FolderItem should be
305          *               created
306          * \param parent \c The parent \c FolderItem for the new \c FolderItem
307          * \parem name The name for the new \c FolderItem
308          * \return The new \c FolderItem
309          */
310         FolderItem      *(*create_folder)       (Folder         *folder,
311                                                  FolderItem     *parent,
312                                                  const gchar    *name);
313         /**
314          * Rename a \c FolderItem
315          *
316          * \param folder The \c Folder of the \c FolderItem that should be
317          *               renamed
318          * \param item The \c FolderItem that should be renamed
319          * \param name The new name of the \c FolderItem
320          * \return 0 on success, a negative number otherwise
321          */
322         gint             (*rename_folder)       (Folder         *folder,
323                                                  FolderItem     *item,
324                                                  const gchar    *name);
325         /**
326          * Remove a \c FolderItem from the \c Folder
327          *
328          * \param folder The \c Folder that contains the \c FolderItem
329          * \param item The \c FolderItem that should be removed
330          * \return 0 on sucess, a negative number otherwise
331          */
332         gint             (*remove_folder)       (Folder         *folder,
333                                                  FolderItem     *item);
334         /**
335          * Close a \c FolderItem. Called when the user deselects a
336          * \c FolderItem.
337          * 
338          * \attention In Sylpheed-Main operations can only be done on the
339          *            \c FolderItem that is opened in the SummaryView. This
340          *            \c FolderItem will be closed when you select a new
341          *            \c FolderItem in the FolderView. In Claws operations can
342          *            be done any time on any folder and you should not expect
343          *            that all \c FolderItems get closed after operations
344          *
345          * \param folder The \c Folder that contains the \c FolderItem
346          * \param item The \c FolderItem that should be closed
347          * \return 0 on success, a negative number otherwise
348          */
349         gint             (*close)               (Folder         *folder,
350                                                  FolderItem     *item);
351         /**
352          * Get the list of message numbers for the messages in the \c FolderItem
353          *
354          * \param folder The \c Folder that contains the \c FolderItem
355          * \param item The \c FolderItem for which the message numbers should
356          *             be fetched
357          * \param list Pointer to a GSList where message numbers have to be
358          *             added. Because of the implementation of the GSList that
359          *             changes the pointer of the GSList itself when the first
360          *             item is added this is a pointer to a pointer to a
361          *             GSList structure. Use *item = g_slist_...(*item, ...)
362          *             operations to modify the list.
363          * \param old_uids_valid In some \c Folders the old UIDs can be invalid.
364          *                       Set this pointer to a gboolean to TRUE if the
365          *                       old UIDs are still valid, otherwise set it to
366          *                       FALSE and the folder system will discard it's
367          *                       cache data of the previously know UIDs
368          * \return The number of message numbers add to the list on success,
369          *         a negative number otherwise.
370          */
371         gint             (*get_num_list)        (Folder         *folder,
372                                                  FolderItem     *item,
373                                                  GSList        **list,
374                                                  gboolean       *old_uids_valid);
375         /**
376          * Tell the folder system if a \c FolderItem should be scanned
377          * (cache data syncronized with the folder content) when it is required
378          * because the \c FolderItem's content changed. If NULL the folder
379          * system will not do automatic scanning of \c FolderItems
380          *
381          * \param folder The \c Folder that contains the \c FolderItem
382          * \param item The \c FolderItem which's content should be checked
383          * \return TRUE if the \c FolderItem should be scanned, FALSE otherwise
384          */
385         gboolean        (*scan_required)        (Folder         *folder,
386                                                  FolderItem     *item);
387
388         /* Message functions */
389         /**
390          * Get a MsgInfo for a message in a \c FolderItem
391          *
392          * \param folder The \c Folder containing the message
393          * \param item The \c FolderItem containing the message
394          * \param num The message number of the message
395          * \return A pointer to a \c MsgInfo decribing the message or \c 
396          *         NULL in case of an error
397          */
398         MsgInfo         *(*get_msginfo)         (Folder         *folder,
399                                                  FolderItem     *item,
400                                                  gint            num);
401         /**
402          * Get \c MsgInfos for a list of message numbers
403          *
404          * \param folder The \c Folder containing the message
405          * \param item The \c FolderItem containing the message
406          * \param msgnum_list A list of message numbers for which the
407          *                    \c MsgInfos should be fetched
408          * \return A list of \c MsgInfos for the messages in the \c msgnum_list
409          *         that really exist. Messages that are not found can simply
410          *         be left out.
411          */
412         MsgInfoList     *(*get_msginfos)        (Folder         *folder,
413                                                  FolderItem     *item,
414                                                  MsgNumberList  *msgnum_list);
415         /**
416          * Get the filename for a message. This can either be the real message
417          * file for local folders or a temporary file for remote folders.
418          *
419          * \param folder The \c Folder containing the message
420          * \param item The \c FolderItem containing the message
421          * \param num The message number of the message
422          * \return A string with the filename of the message file. The returned
423          *         string has to be freed with \c g_free(). If message is not
424          *         available return NULL.
425          */
426         gchar           *(*fetch_msg)           (Folder         *folder,
427                                                  FolderItem     *item,
428                                                  gint            num);
429         /**
430          * Add a single message file to a folder with the given flags (if
431          * flag handling is supported by the folder)
432          *
433          * \param folder The target \c Folder for the message
434          * \param dest the target \c FolderItem for the message
435          * \param file The file that contains the message
436          * \param flags The flags the new message should have in the folder
437          * \return 0 on success, a negative number otherwise
438          */
439         gint            (*add_msg)              (Folder         *folder,
440                                                  FolderItem     *dest,
441                                                  const gchar    *file,
442                                                  MsgFlags       *flags);
443         /**
444          * Add multiple messages to a \c FolderItem. If NULL the folder
445          * system will add messages with \c add_msg one by one
446          *
447          * \param folder The target \c Folder for the messages
448          * \param dest the target \c FolderItem for the messages
449          * \param file_list A list of \c MsgFileInfos which contain the
450          *                  filenames and flags for the new messages
451          * \param relation Insert tuples of (MsgFileInfo, new message number) to
452          *                 provide feedback for the folder system which new
453          *                 message number a \c MsgFileInfo got in dest. Insert
454          *                 0 if the new message number is unknown.
455          */
456         gint            (*add_msgs)             (Folder         *folder,
457                                                  FolderItem     *dest,
458                                                  GSList         *file_list,
459                                                  GRelation      *relation);
460         /**
461          * Copy a message to a FolderItem
462          *
463          * \param folder The \c Folder of the destination FolderItem
464          * \param dest The destination \c FolderItem for the message
465          * \param msginfo The message that should be copied
466          * \return The message number the copied message got, 0 if it is
467          *         unknown because message numbers are assigned by an external
468          *         system and not available after copying or a negative number
469          *         if an error occuried
470          */
471         gint            (*copy_msg)             (Folder         *folder,
472                                                  FolderItem     *dest,
473                                                  MsgInfo        *msginfo);
474         /**
475          * Copy multiple messages to a \c FolderItem. If \c NULL the folder
476          * system will use \c copy_msg to copy messages one by one.
477          *
478          * \param folder The \c Folder of the destination FolderItem
479          * \param dest The destination \c FolderItem for the message
480          * \param msglist A list of \c MsgInfos which should be copied to dest
481          * \param relation Insert tuples of (MsgInfo, new message number) to
482          *                 provide feedback for the folder system which new
483          *                 message number a \c MsgInfo got in dest. Insert
484          *                 0 if the new message number is unknown.
485          * \return 0 on success, a negative number otherwise
486          */
487         gint            (*copy_msgs)            (Folder         *folder,
488                                                  FolderItem     *dest,
489                                                  MsgInfoList    *msglist,
490                                                  GRelation      *relation);
491         /**
492          * Remove a message from a \c FolderItem.
493          *
494          * \param folder The \c Folder of the message
495          * \param item The \c FolderItem containing the message
496          * \param num The message number of the message
497          * \return 0 on success, a negative number otherwise
498          */
499         gint            (*remove_msg)           (Folder         *folder,
500                                                  FolderItem     *item,
501                                                  gint            num);
502         /**
503          * Remove all messages in a \ c FolderItem
504          *
505          * \param folder The \c Folder of the \c FolderItem
506          * \param item The \FolderItem which's messages should be deleted
507          * \return 0 on succes, a negative number otherwise
508          */
509         gint            (*remove_all_msg)       (Folder         *folder,
510                                                  FolderItem     *item);
511         /**
512          * Check if a message has been modified by someone else
513          *
514          * \param folder The \c Folder of the message
515          * \param item The \c FolderItem containing the message
516          * \param msginfo The \c MsgInfo for the message that should be checked
517          * \return \c TRUE if the message was modified, \c FALSE otherwise
518          */
519         gboolean        (*is_msg_changed)       (Folder         *folder,
520                                                  FolderItem     *item,
521                                                  MsgInfo        *msginfo);
522         /**
523          * Update a message's flags in the folder data. If NULL only the
524          * internal flag management will be used. The function has to set
525          * \c msginfo->flags.perm_flags. It does not have to set the flags
526          * that it got as \c newflags. If a flag can not be set in this
527          * \c FolderClass the function can refuse to set it. Flags that are not
528          * supported by the \c FolderClass should not be refused. They will be
529          * managed by the internal cache in this case.
530          *
531          * \param folder The \c Folder of the message
532          * \param item The \c FolderItem of the message
533          * \param msginfo The \c MsgInfo for the message which's flags should be
534          *                updated
535          * \param newflags The flags the message should get
536          */
537         void            (*change_flags)         (Folder         *folder,
538                                                  FolderItem     *item,
539                                                  MsgInfo        *msginfo,
540                                                  MsgPermFlags    newflags);
541 };
542
543 struct _FolderItem
544 {
545         SpecialFolderItemType stype;
546
547         gchar *name;
548         gchar *path;
549
550         time_t mtime;
551
552         gint new_msgs;
553         gint unread_msgs;
554         gint total_msgs;
555         gint unreadmarked_msgs;
556
557         gint last_num;
558
559         MsgCache *cache;
560
561         /* special flags */
562         guint no_sub         : 1; /* no child allowed?    */
563         guint no_select      : 1; /* not selectable?      */
564         guint collapsed      : 1; /* collapsed item       */
565         guint thread_collapsed      : 1; /* collapsed item       */
566         guint threaded       : 1; /* threaded folder view */
567         guint hide_read_msgs : 1; /* hide read messages   */
568         guint ret_rcpt       : 1; /* return receipt       */
569
570         gint op_count;
571         guint opened         : 1; /* opened by summary view */
572         FolderItemUpdateFlags update_flags; /* folderview for this folder should be updated */
573
574         FolderSortKey sort_key;
575         FolderSortType sort_type;
576
577         GNode *node;
578
579         Folder *folder;
580
581         PrefsAccount *account;
582
583         gboolean apply_sub;
584         
585         GSList *mark_queue;
586
587         gpointer data;
588
589         FolderItemPrefs * prefs;
590 };
591
592 struct _PersistPrefs
593 {
594         FolderSortKey   sort_key;
595         FolderSortType  sort_type;
596         guint           collapsed       : 1;
597         guint           thread_collapsed        : 1;
598         guint           threaded        : 1;
599         guint           hide_read_msgs  : 1; /* CLAWS */
600         guint           ret_rcpt        : 1; /* CLAWS */
601 };
602
603 struct _FolderUpdateData
604 {
605         Folder                  *folder;
606         FolderUpdateFlags        update_flags;
607         FolderItem              *item;
608 };
609
610 struct _FolderItemUpdateData
611 {
612         FolderItem              *item;
613         FolderItemUpdateFlags    update_flags;
614 };
615
616 void        folder_system_init          (void);
617 void        folder_register_class       (FolderClass    *klass);
618 void        folder_unregister_class     (FolderClass    *klass);
619 Folder     *folder_new                  (FolderClass    *type,
620                                          const gchar    *name,
621                                          const gchar    *path);
622 void        folder_init                 (Folder         *folder,
623                                          const gchar    *name);
624
625 void        folder_destroy              (Folder         *folder);
626
627 void        folder_set_xml              (Folder          *folder,
628                                          XMLTag          *tag);
629 XMLTag     *folder_get_xml              (Folder          *folder);
630
631 FolderItem *folder_item_new             (Folder         *folder,
632                                          const gchar    *name,
633                                          const gchar    *path);
634 void        folder_item_append          (FolderItem     *parent,
635                                          FolderItem     *item);
636 void        folder_item_remove          (FolderItem     *item);
637 void        folder_item_remove_children (FolderItem     *item);
638 void        folder_item_destroy         (FolderItem     *item);
639 FolderItem *folder_item_parent          (FolderItem     *item);
640
641 void        folder_item_set_xml         (Folder          *folder,
642                                          FolderItem      *item,
643                                          XMLTag          *tag);
644 XMLTag     *folder_item_get_xml         (Folder          *folder,
645                                          FolderItem      *item);
646
647 void        folder_set_ui_func  (Folder         *folder,
648                                  FolderUIFunc    func,
649                                  gpointer        data);
650 void        folder_set_name     (Folder         *folder,
651                                  const gchar    *name);
652 void        folder_tree_destroy (Folder         *folder);
653
654 void   folder_add               (Folder         *folder);
655
656 GList *folder_get_list          (void);
657 gint   folder_read_list         (void);
658 void   folder_write_list        (void);
659 void   folder_scan_tree         (Folder *folder);
660 FolderItem *folder_create_folder(FolderItem     *parent, const gchar *name);
661 void   folder_update_op_count           (void);
662 void   folder_func_to_all_folders       (FolderItemFunc function,
663                                          gpointer data);
664 void   folder_count_total_msgs  (guint          *new_msgs,
665                                  guint          *unread_msgs,
666                                  guint          *unreadmarked_msgs,
667                                  guint          *total_msgs);
668 gchar *folder_get_status        (GPtrArray      *folders,
669                                  gboolean        full);
670
671 Folder     *folder_find_from_path               (const gchar    *path);
672 Folder     *folder_find_from_name               (const gchar    *name,
673                                                  FolderClass    *klass);
674 FolderItem *folder_find_item_from_path          (const gchar    *path);
675 FolderClass *folder_get_class_from_string       (const gchar    *str);
676 FolderItem *folder_find_child_item_by_name      (FolderItem     *item,
677                                                  const gchar    *name);
678 gchar      *folder_get_identifier               (Folder         *folder);
679 gchar      *folder_item_get_identifier          (FolderItem     *item);
680 FolderItem *folder_find_item_from_identifier    (const gchar    *identifier);
681 gchar      *folder_item_get_name                (FolderItem     *item);
682
683 Folder     *folder_get_default_folder   (void);
684 FolderItem *folder_get_default_inbox    (void);
685 FolderItem *folder_get_default_outbox   (void);
686 FolderItem *folder_get_default_draft    (void);
687 FolderItem *folder_get_default_queue    (void);
688 FolderItem *folder_get_default_trash    (void);
689 FolderItem *folder_get_default_processing (void);
690 void folder_set_missing_folders         (void);
691 void folder_unref_account_all           (PrefsAccount   *account);
692
693 gchar *folder_item_get_path             (FolderItem     *item);
694
695 gint   folder_item_open                 (FolderItem     *item);
696 gint   folder_item_close                (FolderItem     *item);
697 gint   folder_item_scan                 (FolderItem     *item);
698 void   folder_item_scan_foreach         (GHashTable     *table);
699 MsgInfo *folder_item_get_msginfo        (FolderItem     *item,
700                                          gint            num);
701 MsgInfo *folder_item_get_msginfo_by_msgid(FolderItem    *item,
702                                          const gchar    *msgid);
703 GSList *folder_item_get_msg_list        (FolderItem     *item);
704 gchar *folder_item_fetch_msg            (FolderItem     *item,
705                                          gint            num);
706 gint   folder_item_fetch_all_msg        (FolderItem     *item);
707 gint   folder_item_add_msg              (FolderItem     *dest,
708                                          const gchar    *file,
709                                          MsgFlags       *flags,
710                                          gboolean        remove_source);
711 gint   folder_item_add_msgs             (FolderItem     *dest,
712                                          GSList         *file_list,
713                                          gboolean        remove_source);
714 gint   folder_item_move_to              (FolderItem     *src,
715                                          FolderItem     *dest,
716                                          FolderItem    **new_item);
717 gint   folder_item_move_msg             (FolderItem     *dest,
718                                          MsgInfo        *msginfo);
719 gint   folder_item_move_msgs            (FolderItem     *dest,
720                                          GSList         *msglist);
721 gint   folder_item_copy_msg             (FolderItem     *dest,
722                                          MsgInfo        *msginfo);
723 gint   folder_item_copy_msgs            (FolderItem     *dest,
724                                          GSList         *msglist);
725 gint   folder_item_remove_msg           (FolderItem     *item,
726                                          gint            num);
727 gint   folder_item_remove_msgs          (FolderItem     *item,
728                                          GSList         *msglist);
729 gint   folder_item_remove_all_msg       (FolderItem     *item);
730 void    folder_item_change_msg_flags    (FolderItem     *item,
731                                          MsgInfo        *msginfo,
732                                          MsgPermFlags    newflags);
733 gboolean folder_item_is_msg_changed     (FolderItem     *item,
734                                          MsgInfo        *msginfo);
735 gchar *folder_item_get_cache_file       (FolderItem     *item);
736 gchar *folder_item_get_mark_file        (FolderItem     *item);
737 gchar * folder_item_get_identifier      (FolderItem * item);
738
739 GHashTable *folder_persist_prefs_new    (Folder *folder);
740 void folder_persist_prefs_free          (GHashTable *pptable);
741 const PersistPrefs *folder_get_persist_prefs
742                                         (GHashTable *pptable, const char *name);
743
744 void folder_item_restore_persist_prefs  (FolderItem *item, GHashTable *pptable);
745 void folder_clean_cache_memory          (void);
746 void folder_item_write_cache            (FolderItem *item);
747 void folder_item_set_default_flags      (FolderItem *dest, MsgFlags *flags);
748
749 void folder_item_apply_processing       (FolderItem *item);
750
751 void folder_item_update                 (FolderItem *item,
752                                          FolderItemUpdateFlags update_flags);
753 void folder_item_update_recursive       (FolderItem *item,
754                                          FolderItemUpdateFlags update_flags);
755 void folder_item_update_freeze          (void);
756 void folder_item_update_thaw            (void);
757
758 #endif /* __FOLDER_H__ */