Statistics
| Revision:

root / src / folder.h @ 1

History | View | Annotate | Download (9.56 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2003 Hiroyuki Yamamoto
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 */
19

    
20
#ifndef __FOLDER_H__
21
#define __FOLDER_H__
22

    
23
#include <glib.h>
24
#include <time.h>
25

    
26
typedef struct _Folder                Folder;
27
typedef struct _FolderClass        FolderClass;
28

    
29
typedef struct _LocalFolder        LocalFolder;
30
typedef struct _RemoteFolder        RemoteFolder;
31
#if 0
32
typedef struct _MboxFolder        MboxFolder;
33
typedef struct _MaildirFolder        MaildirFolder;
34
#endif
35

    
36
typedef struct _FolderItem        FolderItem;
37

    
38
#define FOLDER(obj)                ((Folder *)obj)
39
#define FOLDER_CLASS(obj)        (FOLDER(obj)->klass)
40
#define FOLDER_TYPE(obj)        (FOLDER(obj)->klass->type)
41

    
42
#define LOCAL_FOLDER(obj)        ((LocalFolder *)obj)
43
#define REMOTE_FOLDER(obj)        ((RemoteFolder *)obj)
44

    
45
#define FOLDER_IS_LOCAL(obj)        (FOLDER_TYPE(obj) == F_MH      || \
46
                                 FOLDER_TYPE(obj) == F_MBOX    || \
47
                                 FOLDER_TYPE(obj) == F_MAILDIR)
48

    
49
#if 0
50
#define MBOX_FOLDER(obj)        ((MboxFolder *)obj)
51
#define MAILDIR_FOLDER(obj)        ((MaildirFolder *)obj)
52
#endif
53

    
54
#define FOLDER_ITEM(obj)        ((FolderItem *)obj)
55

    
56
#define FOLDER_ITEM_CAN_ADD(obj)                                        \
57
                ((obj) && FOLDER_ITEM(obj)->folder &&                        \
58
                 FOLDER_ITEM(obj)->path &&                                \
59
                 (FOLDER_IS_LOCAL(FOLDER_ITEM(obj)->folder) ||                \
60
                  FOLDER_TYPE(FOLDER_ITEM(obj)->folder) == F_IMAP) &&        \
61
                 !FOLDER_ITEM(obj)->no_select)
62

    
63
typedef enum
64
{
65
        F_MH,
66
        F_MBOX,
67
        F_MAILDIR,
68
        F_IMAP,
69
        F_NEWS,
70
        F_UNKNOWN
71
} FolderType;
72

    
73
typedef enum
74
{
75
        F_NORMAL,
76
        F_INBOX,
77
        F_OUTBOX,
78
        F_DRAFT,
79
        F_QUEUE,
80
        F_TRASH
81
} SpecialFolderItemType;
82

    
83
typedef enum
84
{
85
        SORT_BY_NONE,
86
        SORT_BY_NUMBER,
87
        SORT_BY_SIZE,
88
        SORT_BY_DATE,
89
        SORT_BY_FROM,
90
        SORT_BY_SUBJECT,
91
        SORT_BY_SCORE,
92
        SORT_BY_LABEL,
93
        SORT_BY_MARK,
94
        SORT_BY_UNREAD,
95
        SORT_BY_MIME,
96
        SORT_BY_TO
97
} FolderSortKey;
98

    
99
typedef enum
100
{
101
        SORT_ASCENDING,
102
        SORT_DESCENDING
103
} FolderSortType;
104

    
105
typedef void (*FolderUIFunc)                (Folder                *folder,
106
                                         FolderItem        *item,
107
                                         gpointer         data);
108
typedef void (*FolderDestroyNotify)        (Folder                *folder,
109
                                         FolderItem        *item,
110
                                         gpointer         data);
111

    
112
#include "prefs_account.h"
113
#include "session.h"
114
#include "procmsg.h"
115

    
116
struct _Folder
117
{
118
        FolderClass *klass;
119

    
120
        gchar *name;
121
        PrefsAccount *account;
122

    
123
        FolderItem *inbox;
124
        FolderItem *outbox;
125
        FolderItem *draft;
126
        FolderItem *queue;
127
        FolderItem *trash;
128

    
129
        FolderUIFunc ui_func;
130
        gpointer     ui_func_data;
131

    
132
        GNode *node;
133

    
134
        gpointer data;
135
};
136

    
137
struct _FolderClass
138
{
139
        FolderType type;
140

    
141
        /* virtual functions */
142
        Folder * (*folder_new)                (const gchar        *name,
143
                                         const gchar        *path);
144
        void     (*destroy)                (Folder                *folder);
145

    
146
        gint     (*scan_tree)                (Folder                *folder);
147
        gint     (*create_tree)                (Folder                *folder);
148

    
149
        GSList * (*get_msg_list)        (Folder                *folder,
150
                                         FolderItem        *item,
151
                                         gboolean         use_cache);
152
        /* return value is locale charset */
153
        gchar *  (*fetch_msg)                (Folder                *folder,
154
                                         FolderItem        *item,
155
                                         gint                 num);
156
        MsgInfo * (*get_msginfo)        (Folder                *folder,
157
                                         FolderItem        *item,
158
                                         gint                 num);
159
        gint     (*add_msg)                (Folder                *folder,
160
                                         FolderItem        *dest,
161
                                         const gchar        *file,
162
                                         MsgFlags        *flags,
163
                                         gboolean         remove_source);
164
        gint     (*add_msgs)                (Folder                *folder,
165
                                         FolderItem        *dest,
166
                                         GSList                *file_list,
167
                                         gboolean         remove_source,
168
                                         gint                *first);
169
        gint     (*move_msg)                (Folder                *folder,
170
                                         FolderItem        *dest,
171
                                         MsgInfo        *msginfo);
172
        gint     (*move_msgs)                (Folder                *folder,
173
                                         FolderItem        *dest,
174
                                         GSList                *msglist);
175
        gint     (*copy_msg)                (Folder                *folder,
176
                                         FolderItem        *dest,
177
                                         MsgInfo        *msginfo);
178
        gint     (*copy_msgs)                (Folder                *folder,
179
                                         FolderItem        *dest,
180
                                         GSList                *msglist);
181
        gint     (*remove_msg)                (Folder                *folder,
182
                                         FolderItem        *item,
183
                                         MsgInfo        *msginfo);
184
        gint     (*remove_msgs)                (Folder                *folder,
185
                                         FolderItem        *item,
186
                                         GSList                *msglist);
187
        gint     (*remove_all_msg)        (Folder                *folder,
188
                                         FolderItem        *item);
189
        gboolean (*is_msg_changed)        (Folder                *folder,
190
                                         FolderItem        *item,
191
                                         MsgInfo        *msginfo);
192
        gint     (*close)                (Folder                *folder,
193
                                         FolderItem        *item);
194
        gint     (*scan)                (Folder                *folder,
195
                                         FolderItem        *item);
196

    
197
        FolderItem * (*create_folder)        (Folder                *folder,
198
                                         FolderItem        *parent,
199
                                         const gchar        *name);
200
        gint     (*rename_folder)        (Folder                *folder,
201
                                         FolderItem        *item,
202
                                         const gchar        *name);
203
        gint     (*remove_folder)        (Folder                *folder,
204
                                         FolderItem        *item);
205
};
206

    
207
struct _LocalFolder
208
{
209
        Folder folder;
210

    
211
        gchar *rootpath;
212
};
213

    
214
struct _RemoteFolder
215
{
216
        Folder folder;
217

    
218
        Session *session;
219
};
220

    
221
#if 0
222
struct _MboxFolder
223
{
224
        LocalFolder lfolder;
225
};
226

227
struct _MaildirFolder
228
{
229
        LocalFolder lfolder;
230
};
231
#endif
232

    
233
struct _FolderItem
234
{
235
        SpecialFolderItemType stype;
236

    
237
        gchar *name; /* UTF-8 */
238
        gchar *path; /* UTF-8 */
239

    
240
        time_t mtime;
241

    
242
        gint new;
243
        gint unread;
244
        gint total;
245
        gint unmarked_num;
246

    
247
        gint last_num;
248

    
249
        /* special flags */
250
        guint no_sub    : 1; /* no child allowed?    */
251
        guint no_select : 1; /* not selectable?      */
252
        guint collapsed : 1; /* collapsed item       */
253
        guint threaded  : 1; /* threaded folder view */
254

    
255
        guint opened    : 1; /* opened by summary view */
256
        guint updated   : 1; /* folderview should be updated */
257

    
258
        FolderSortKey sort_key;
259
        FolderSortType sort_type;
260

    
261
        GNode *node;
262

    
263
        FolderItem *parent;
264

    
265
        Folder *folder;
266

    
267
        PrefsAccount *account;
268

    
269
        gboolean ac_apply_sub;
270

    
271
        gchar *auto_to;
272
        gboolean use_auto_to_on_reply;
273
        gchar *auto_cc;
274
        gchar *auto_bcc;
275
        gchar *auto_replyto;
276

    
277
        gboolean trim_summary_subject;
278
        gboolean trim_compose_subject;
279

    
280
        GSList *mark_queue;
281

    
282
        gpointer data;
283
};
284

    
285
Folder     *folder_new                        (FolderType         type,
286
                                         const gchar        *name,
287
                                         const gchar        *path);
288
void        folder_local_folder_init        (Folder                *folder,
289
                                         const gchar        *name,
290
                                         const gchar        *path);
291
void        folder_remote_folder_init        (Folder                *folder,
292
                                         const gchar        *name,
293
                                         const gchar        *path);
294

    
295
void        folder_destroy                (Folder                *folder);
296
void        folder_local_folder_destroy        (LocalFolder        *lfolder);
297
void        folder_remote_folder_destroy(RemoteFolder        *rfolder);
298

    
299
FolderItem *folder_item_new                (const gchar        *name,
300
                                         const gchar        *path);
301
void        folder_item_append                (FolderItem        *parent,
302
                                         FolderItem        *item);
303
void        folder_item_remove                (FolderItem        *item);
304
void        folder_item_remove_children        (FolderItem        *item);
305
void        folder_item_destroy                (FolderItem        *item);
306

    
307
void        folder_set_ui_func        (Folder                *folder,
308
                                 FolderUIFunc         func,
309
                                 gpointer         data);
310
void        folder_set_name        (Folder                *folder,
311
                                 const gchar        *name);
312
void        folder_tree_destroy        (Folder                *folder);
313

    
314
void   folder_add                (Folder                *folder);
315

    
316
GList *folder_get_list                (void);
317
gint   folder_read_list                (void);
318
void   folder_write_list        (void);
319

    
320
gchar *folder_get_status        (GPtrArray        *folders,
321
                                 gboolean         full);
322

    
323
Folder     *folder_find_from_path                (const gchar        *path);
324
Folder     *folder_find_from_name                (const gchar        *name,
325
                                                 FolderType         type);
326
FolderItem *folder_find_item_from_path                (const gchar        *path);
327
FolderItem *folder_find_child_item_by_name        (FolderItem        *item,
328
                                                 const gchar        *name);
329
gchar      *folder_get_identifier                (Folder                *folder);
330
gchar      *folder_item_get_identifier                (FolderItem        *item);
331
FolderItem *folder_find_item_from_identifier        (const gchar        *identifier);
332

    
333
Folder     *folder_get_default_folder        (void);
334
FolderItem *folder_get_default_inbox        (void);
335
FolderItem *folder_get_default_outbox        (void);
336
FolderItem *folder_get_default_draft        (void);
337
FolderItem *folder_get_default_queue        (void);
338
FolderItem *folder_get_default_trash        (void);
339

    
340
void folder_set_missing_folders                (void);
341
void folder_unref_account_all                (PrefsAccount        *account);
342

    
343
/* return value is locale encoded file name */
344
gchar *folder_get_path                        (Folder                *folder);
345
gchar *folder_item_get_path                (FolderItem        *item);
346

    
347
gint   folder_item_scan                        (FolderItem        *item);
348
void   folder_item_scan_foreach                (GHashTable        *table);
349
GSList *folder_item_get_msg_list        (FolderItem        *item,
350
                                         gboolean         use_cache);
351
/* return value is locale charset */
352
gchar *folder_item_fetch_msg                (FolderItem        *item,
353
                                         gint                 num);
354
gint   folder_item_fetch_all_msg        (FolderItem        *item);
355
MsgInfo *folder_item_get_msginfo        (FolderItem        *item,
356
                                         gint                 num);
357
gint   folder_item_add_msg                (FolderItem        *dest,
358
                                         const gchar        *file,
359
                                         MsgFlags        *flags,
360
                                         gboolean         remove_source);
361
gint   folder_item_add_msgs                (FolderItem        *dest,
362
                                         GSList                *file_list,
363
                                         gboolean         remove_source,
364
                                         gint                *first);
365
gint   folder_item_move_msg                (FolderItem        *dest,
366
                                         MsgInfo        *msginfo);
367
gint   folder_item_move_msgs                (FolderItem        *dest,
368
                                         GSList                *msglist);
369
gint   folder_item_copy_msg                (FolderItem        *dest,
370
                                         MsgInfo        *msginfo);
371
gint   folder_item_copy_msgs                (FolderItem        *dest,
372
                                         GSList                *msglist);
373
gint   folder_item_remove_msg                (FolderItem        *item,
374
                                         MsgInfo        *msginfo);
375
gint   folder_item_remove_msgs                (FolderItem        *item,
376
                                         GSList                *msglist);
377
gint   folder_item_remove_all_msg        (FolderItem        *item);
378
gboolean folder_item_is_msg_changed        (FolderItem        *item,
379
                                         MsgInfo        *msginfo);
380
/* return value is locale chaset */
381
gchar *folder_item_get_cache_file        (FolderItem        *item);
382
gchar *folder_item_get_mark_file        (FolderItem        *item);
383

    
384
gint   folder_item_close                (FolderItem        *item);
385

    
386
#endif /* __FOLDER_H__ */