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