Statistics
| Revision:

root / libsylph / folder.h @ 3019

History | View | Annotate | Download (11.6 kB)

1 1 hiro
/*
2 578 hiro
 * LibSylph -- E-Mail client library
3 2881 hiro
 * Copyright (C) 1999-2011 Hiroyuki Yamamoto
4 1 hiro
 *
5 578 hiro
 * This library is free software; you can redistribute it and/or
6 578 hiro
 * modify it under the terms of the GNU Lesser General Public
7 578 hiro
 * License as published by the Free Software Foundation; either
8 578 hiro
 * version 2.1 of the License, or (at your option) any later version.
9 1 hiro
 *
10 578 hiro
 * This library is distributed in the hope that it will be useful,
11 1 hiro
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 578 hiro
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 578 hiro
 * Lesser General Public License for more details.
14 1 hiro
 *
15 578 hiro
 * You should have received a copy of the GNU Lesser General Public
16 578 hiro
 * License along with this library; if not, write to the Free Software
17 578 hiro
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 1 hiro
 */
19 1 hiro
20 1 hiro
#ifndef __FOLDER_H__
21 1 hiro
#define __FOLDER_H__
22 1 hiro
23 1 hiro
#include <glib.h>
24 1 hiro
#include <time.h>
25 1 hiro
26 1 hiro
typedef struct _Folder                Folder;
27 1 hiro
typedef struct _FolderClass        FolderClass;
28 1 hiro
29 1 hiro
typedef struct _LocalFolder        LocalFolder;
30 1 hiro
typedef struct _RemoteFolder        RemoteFolder;
31 1 hiro
#if 0
32 1 hiro
typedef struct _MboxFolder        MboxFolder;
33 1 hiro
typedef struct _MaildirFolder        MaildirFolder;
34 1 hiro
#endif
35 1 hiro
36 1 hiro
typedef struct _FolderItem        FolderItem;
37 1 hiro
38 1 hiro
#define FOLDER(obj)                ((Folder *)obj)
39 1 hiro
#define FOLDER_CLASS(obj)        (FOLDER(obj)->klass)
40 1 hiro
#define FOLDER_TYPE(obj)        (FOLDER(obj)->klass->type)
41 1 hiro
42 1 hiro
#define LOCAL_FOLDER(obj)        ((LocalFolder *)obj)
43 1 hiro
#define REMOTE_FOLDER(obj)        ((RemoteFolder *)obj)
44 1 hiro
45 1 hiro
#define FOLDER_IS_LOCAL(obj)        (FOLDER_TYPE(obj) == F_MH      || \
46 1 hiro
                                 FOLDER_TYPE(obj) == F_MBOX    || \
47 1 hiro
                                 FOLDER_TYPE(obj) == F_MAILDIR)
48 641 hiro
#define FOLDER_IS_REMOTE(obj)        (FOLDER_TYPE(obj) == F_IMAP || \
49 641 hiro
                                 FOLDER_TYPE(obj) == F_NEWS)
50 1 hiro
51 1 hiro
#if 0
52 1 hiro
#define MBOX_FOLDER(obj)        ((MboxFolder *)obj)
53 1 hiro
#define MAILDIR_FOLDER(obj)        ((MaildirFolder *)obj)
54 1 hiro
#endif
55 1 hiro
56 1 hiro
#define FOLDER_ITEM(obj)        ((FolderItem *)obj)
57 1 hiro
58 1 hiro
#define FOLDER_ITEM_CAN_ADD(obj)                                        \
59 1 hiro
                ((obj) && FOLDER_ITEM(obj)->folder &&                        \
60 1 hiro
                 FOLDER_ITEM(obj)->path &&                                \
61 1 hiro
                 (FOLDER_IS_LOCAL(FOLDER_ITEM(obj)->folder) ||                \
62 1 hiro
                  FOLDER_TYPE(FOLDER_ITEM(obj)->folder) == F_IMAP) &&        \
63 1 hiro
                 !FOLDER_ITEM(obj)->no_select)
64 1 hiro
65 1894 hiro
#define FOLDER_ITEM_IS_SENT_FOLDER(obj)        ((obj) &&                        \
66 1894 hiro
                                         ((obj)->stype == F_OUTBOX ||        \
67 1894 hiro
                                          (obj)->stype == F_DRAFT ||        \
68 1894 hiro
                                          (obj)->stype == F_QUEUE))
69 1894 hiro
70 1 hiro
typedef enum
71 1 hiro
{
72 1 hiro
        F_MH,
73 1 hiro
        F_MBOX,
74 1 hiro
        F_MAILDIR,
75 1 hiro
        F_IMAP,
76 1 hiro
        F_NEWS,
77 1 hiro
        F_UNKNOWN
78 1 hiro
} FolderType;
79 1 hiro
80 1 hiro
typedef enum
81 1 hiro
{
82 1 hiro
        F_NORMAL,
83 1 hiro
        F_INBOX,
84 1 hiro
        F_OUTBOX,
85 1 hiro
        F_DRAFT,
86 1 hiro
        F_QUEUE,
87 836 hiro
        F_TRASH,
88 836 hiro
        F_JUNK,
89 836 hiro
        F_VIRTUAL
90 1 hiro
} SpecialFolderItemType;
91 1 hiro
92 1 hiro
typedef enum
93 1 hiro
{
94 1 hiro
        SORT_BY_NONE,
95 1 hiro
        SORT_BY_NUMBER,
96 1 hiro
        SORT_BY_SIZE,
97 1 hiro
        SORT_BY_DATE,
98 574 hiro
        SORT_BY_TDATE,
99 1 hiro
        SORT_BY_FROM,
100 1 hiro
        SORT_BY_SUBJECT,
101 1 hiro
        SORT_BY_SCORE,
102 1 hiro
        SORT_BY_LABEL,
103 1 hiro
        SORT_BY_MARK,
104 1 hiro
        SORT_BY_UNREAD,
105 1 hiro
        SORT_BY_MIME,
106 1 hiro
        SORT_BY_TO
107 1 hiro
} FolderSortKey;
108 1 hiro
109 1 hiro
typedef enum
110 1 hiro
{
111 1 hiro
        SORT_ASCENDING,
112 1 hiro
        SORT_DESCENDING
113 1 hiro
} FolderSortType;
114 1 hiro
115 1 hiro
typedef void (*FolderUIFunc)                (Folder                *folder,
116 1 hiro
                                         FolderItem        *item,
117 1 hiro
                                         gpointer         data);
118 1 hiro
typedef void (*FolderDestroyNotify)        (Folder                *folder,
119 1 hiro
                                         FolderItem        *item,
120 1 hiro
                                         gpointer         data);
121 1 hiro
122 1 hiro
#include "prefs_account.h"
123 1 hiro
#include "session.h"
124 1 hiro
#include "procmsg.h"
125 1 hiro
126 1 hiro
struct _Folder
127 1 hiro
{
128 1 hiro
        FolderClass *klass;
129 1 hiro
130 1 hiro
        gchar *name;
131 1 hiro
        PrefsAccount *account;
132 1 hiro
133 1 hiro
        FolderItem *inbox;
134 1 hiro
        FolderItem *outbox;
135 1 hiro
        FolderItem *draft;
136 1 hiro
        FolderItem *queue;
137 1 hiro
        FolderItem *trash;
138 1 hiro
139 1 hiro
        FolderUIFunc ui_func;
140 1 hiro
        gpointer     ui_func_data;
141 1 hiro
142 1 hiro
        GNode *node;
143 1 hiro
144 1 hiro
        gpointer data;
145 1 hiro
};
146 1 hiro
147 1 hiro
struct _FolderClass
148 1 hiro
{
149 1 hiro
        FolderType type;
150 1 hiro
151 1 hiro
        /* virtual functions */
152 1 hiro
        Folder * (*folder_new)                (const gchar        *name,
153 1 hiro
                                         const gchar        *path);
154 1 hiro
        void     (*destroy)                (Folder                *folder);
155 1 hiro
156 1 hiro
        gint     (*scan_tree)                (Folder                *folder);
157 1 hiro
        gint     (*create_tree)                (Folder                *folder);
158 1 hiro
159 1 hiro
        GSList * (*get_msg_list)        (Folder                *folder,
160 1 hiro
                                         FolderItem        *item,
161 1 hiro
                                         gboolean         use_cache);
162 1491 hiro
        GSList * (*get_uncached_msg_list)
163 1491 hiro
                                        (Folder                *folder,
164 1491 hiro
                                         FolderItem        *item);
165 1008 hiro
        /* return value is filename encoding */
166 1 hiro
        gchar *  (*fetch_msg)                (Folder                *folder,
167 1 hiro
                                         FolderItem        *item,
168 1 hiro
                                         gint                 num);
169 1 hiro
        MsgInfo * (*get_msginfo)        (Folder                *folder,
170 1 hiro
                                         FolderItem        *item,
171 1 hiro
                                         gint                 num);
172 1 hiro
        gint     (*add_msg)                (Folder                *folder,
173 1 hiro
                                         FolderItem        *dest,
174 1 hiro
                                         const gchar        *file,
175 1 hiro
                                         MsgFlags        *flags,
176 1 hiro
                                         gboolean         remove_source);
177 1 hiro
        gint     (*add_msgs)                (Folder                *folder,
178 1 hiro
                                         FolderItem        *dest,
179 1 hiro
                                         GSList                *file_list,
180 1 hiro
                                         gboolean         remove_source,
181 1 hiro
                                         gint                *first);
182 2247 hiro
        gint     (*add_msg_msginfo)        (Folder                *folder,
183 2247 hiro
                                         FolderItem        *dest,
184 2247 hiro
                                         MsgInfo        *msginfo,
185 2247 hiro
                                         gboolean         remove_source);
186 2247 hiro
        gint     (*add_msgs_msginfo)        (Folder                *folder,
187 2247 hiro
                                         FolderItem        *dest,
188 2247 hiro
                                         GSList                *msginfo_list,
189 2247 hiro
                                         gboolean         remove_source,
190 2247 hiro
                                         gint                *first);
191 1 hiro
        gint     (*move_msg)                (Folder                *folder,
192 1 hiro
                                         FolderItem        *dest,
193 1 hiro
                                         MsgInfo        *msginfo);
194 1 hiro
        gint     (*move_msgs)                (Folder                *folder,
195 1 hiro
                                         FolderItem        *dest,
196 1 hiro
                                         GSList                *msglist);
197 1 hiro
        gint     (*copy_msg)                (Folder                *folder,
198 1 hiro
                                         FolderItem        *dest,
199 1 hiro
                                         MsgInfo        *msginfo);
200 1 hiro
        gint     (*copy_msgs)                (Folder                *folder,
201 1 hiro
                                         FolderItem        *dest,
202 1 hiro
                                         GSList                *msglist);
203 1 hiro
        gint     (*remove_msg)                (Folder                *folder,
204 1 hiro
                                         FolderItem        *item,
205 1 hiro
                                         MsgInfo        *msginfo);
206 1 hiro
        gint     (*remove_msgs)                (Folder                *folder,
207 1 hiro
                                         FolderItem        *item,
208 1 hiro
                                         GSList                *msglist);
209 1 hiro
        gint     (*remove_all_msg)        (Folder                *folder,
210 1 hiro
                                         FolderItem        *item);
211 1 hiro
        gboolean (*is_msg_changed)        (Folder                *folder,
212 1 hiro
                                         FolderItem        *item,
213 1 hiro
                                         MsgInfo        *msginfo);
214 1 hiro
        gint     (*close)                (Folder                *folder,
215 1 hiro
                                         FolderItem        *item);
216 1 hiro
        gint     (*scan)                (Folder                *folder,
217 1 hiro
                                         FolderItem        *item);
218 1 hiro
219 1 hiro
        FolderItem * (*create_folder)        (Folder                *folder,
220 1 hiro
                                         FolderItem        *parent,
221 1 hiro
                                         const gchar        *name);
222 1 hiro
        gint     (*rename_folder)        (Folder                *folder,
223 1 hiro
                                         FolderItem        *item,
224 1 hiro
                                         const gchar        *name);
225 389 hiro
        gint     (*move_folder)                (Folder                *folder,
226 389 hiro
                                         FolderItem        *item,
227 389 hiro
                                         FolderItem        *new_parent);
228 1 hiro
        gint     (*remove_folder)        (Folder                *folder,
229 1 hiro
                                         FolderItem        *item);
230 1 hiro
};
231 1 hiro
232 1 hiro
struct _LocalFolder
233 1 hiro
{
234 1 hiro
        Folder folder;
235 1 hiro
236 1 hiro
        gchar *rootpath;
237 1 hiro
};
238 1 hiro
239 1 hiro
struct _RemoteFolder
240 1 hiro
{
241 1 hiro
        Folder folder;
242 1 hiro
243 1 hiro
        Session *session;
244 2334 hiro
245 2334 hiro
        guint remove_cache_on_destroy : 1;
246 2334 hiro
        guint dummy1 : 1;
247 2334 hiro
        guint dummy2 : 1;
248 2334 hiro
        guint dummy3 : 1;
249 1 hiro
};
250 1 hiro
251 1 hiro
#if 0
252 1 hiro
struct _MboxFolder
253 1 hiro
{
254 1 hiro
        LocalFolder lfolder;
255 1 hiro
};
256 1 hiro
257 1 hiro
struct _MaildirFolder
258 1 hiro
{
259 1 hiro
        LocalFolder lfolder;
260 1 hiro
};
261 1 hiro
#endif
262 1 hiro
263 1 hiro
struct _FolderItem
264 1 hiro
{
265 1 hiro
        SpecialFolderItemType stype;
266 1 hiro
267 1 hiro
        gchar *name; /* UTF-8 */
268 1 hiro
        gchar *path; /* UTF-8 */
269 1 hiro
270 1 hiro
        time_t mtime;
271 1 hiro
272 1 hiro
        gint new;
273 1 hiro
        gint unread;
274 1 hiro
        gint total;
275 1 hiro
        gint unmarked_num;
276 1 hiro
277 1 hiro
        gint last_num;
278 1 hiro
279 1 hiro
        /* special flags */
280 1 hiro
        guint no_sub    : 1; /* no child allowed?    */
281 1 hiro
        guint no_select : 1; /* not selectable?      */
282 1 hiro
        guint collapsed : 1; /* collapsed item       */
283 1 hiro
        guint threaded  : 1; /* threaded folder view */
284 1 hiro
285 1 hiro
        guint opened    : 1; /* opened by summary view */
286 1 hiro
        guint updated   : 1; /* folderview should be updated */
287 1 hiro
288 285 hiro
        guint cache_dirty : 1; /* cache file needs to be updated */
289 293 hiro
        guint mark_dirty  : 1; /* mark file needs to be updated */
290 285 hiro
291 1 hiro
        FolderSortKey sort_key;
292 1 hiro
        FolderSortType sort_type;
293 1 hiro
294 1 hiro
        GNode *node;
295 1 hiro
296 1 hiro
        FolderItem *parent;
297 1 hiro
298 1 hiro
        Folder *folder;
299 1 hiro
300 1 hiro
        PrefsAccount *account;
301 1 hiro
302 1 hiro
        gboolean ac_apply_sub;
303 1 hiro
304 1 hiro
        gchar *auto_to;
305 1 hiro
        gboolean use_auto_to_on_reply;
306 1 hiro
        gchar *auto_cc;
307 1 hiro
        gchar *auto_bcc;
308 1 hiro
        gchar *auto_replyto;
309 1 hiro
310 1 hiro
        gboolean trim_summary_subject;
311 1 hiro
        gboolean trim_compose_subject;
312 1 hiro
313 2247 hiro
        GSList *cache_queue;
314 1 hiro
        GSList *mark_queue;
315 1 hiro
316 1262 hiro
        guint last_selected;
317 1688 hiro
        gint qsearch_cond_type;
318 1262 hiro
319 1 hiro
        gpointer data;
320 1 hiro
};
321 1 hiro
322 1 hiro
Folder     *folder_new                        (FolderType         type,
323 1 hiro
                                         const gchar        *name,
324 1 hiro
                                         const gchar        *path);
325 1 hiro
void        folder_local_folder_init        (Folder                *folder,
326 1 hiro
                                         const gchar        *name,
327 1 hiro
                                         const gchar        *path);
328 1 hiro
void        folder_remote_folder_init        (Folder                *folder,
329 1 hiro
                                         const gchar        *name,
330 1 hiro
                                         const gchar        *path);
331 1 hiro
332 1 hiro
void        folder_destroy                (Folder                *folder);
333 1 hiro
void        folder_local_folder_destroy        (LocalFolder        *lfolder);
334 1 hiro
void        folder_remote_folder_destroy(RemoteFolder        *rfolder);
335 1 hiro
336 2754 hiro
gint        folder_remote_folder_destroy_all_sessions        (void);
337 2754 hiro
338 2881 hiro
gboolean    folder_remote_folder_is_session_active
339 2881 hiro
                                        (RemoteFolder        *rfolder);
340 2881 hiro
gboolean folder_remote_folder_active_session_exist        (void);
341 2881 hiro
342 1329 hiro
gint        folder_scan_tree                (Folder                *folder);
343 1329 hiro
gint        folder_create_tree                (Folder                *folder);
344 1329 hiro
345 1 hiro
FolderItem *folder_item_new                (const gchar        *name,
346 1 hiro
                                         const gchar        *path);
347 1 hiro
void        folder_item_append                (FolderItem        *parent,
348 1 hiro
                                         FolderItem        *item);
349 1900 hiro
FolderItem *folder_item_copy                (FolderItem        *item);
350 1 hiro
void        folder_item_remove                (FolderItem        *item);
351 1 hiro
void        folder_item_remove_children        (FolderItem        *item);
352 1 hiro
void        folder_item_destroy                (FolderItem        *item);
353 1 hiro
354 202 hiro
gint        folder_item_compare                (FolderItem        *item_a,
355 202 hiro
                                         FolderItem        *item_b);
356 202 hiro
357 1 hiro
void        folder_set_ui_func        (Folder                *folder,
358 1 hiro
                                 FolderUIFunc         func,
359 1 hiro
                                 gpointer         data);
360 1 hiro
void        folder_set_name        (Folder                *folder,
361 1 hiro
                                 const gchar        *name);
362 1 hiro
void        folder_tree_destroy        (Folder                *folder);
363 1 hiro
364 1 hiro
void   folder_add                (Folder                *folder);
365 1 hiro
366 1 hiro
GList *folder_get_list                (void);
367 1 hiro
gint   folder_read_list                (void);
368 1 hiro
void   folder_write_list        (void);
369 1 hiro
370 1 hiro
gchar *folder_get_status        (GPtrArray        *folders,
371 1 hiro
                                 gboolean         full);
372 1 hiro
373 1 hiro
Folder     *folder_find_from_path                (const gchar        *path);
374 1 hiro
Folder     *folder_find_from_name                (const gchar        *name,
375 1 hiro
                                                 FolderType         type);
376 1 hiro
FolderItem *folder_find_item_from_path                (const gchar        *path);
377 1 hiro
FolderItem *folder_find_child_item_by_name        (FolderItem        *item,
378 1 hiro
                                                 const gchar        *name);
379 1 hiro
gchar      *folder_get_identifier                (Folder                *folder);
380 1 hiro
gchar      *folder_item_get_identifier                (FolderItem        *item);
381 1 hiro
FolderItem *folder_find_item_from_identifier        (const gchar        *identifier);
382 1854 hiro
FolderItem *folder_find_item_and_num_from_id        (const gchar        *identifier,
383 1854 hiro
                                                 gint                *num);
384 1 hiro
385 1 hiro
Folder     *folder_get_default_folder        (void);
386 1 hiro
FolderItem *folder_get_default_inbox        (void);
387 1 hiro
FolderItem *folder_get_default_outbox        (void);
388 1 hiro
FolderItem *folder_get_default_draft        (void);
389 1 hiro
FolderItem *folder_get_default_queue        (void);
390 1 hiro
FolderItem *folder_get_default_trash        (void);
391 2638 hiro
FolderItem *folder_get_default_junk        (void);
392 1 hiro
393 2931 hiro
gboolean folder_item_is_trash                (FolderItem        *item);
394 2931 hiro
395 2638 hiro
FolderItem *folder_get_junk                (Folder                *folder);
396 2638 hiro
void folder_set_junk                        (Folder                *folder,
397 2638 hiro
                                         FolderItem        *item);
398 2638 hiro
399 1 hiro
void folder_set_missing_folders                (void);
400 1 hiro
void folder_unref_account_all                (PrefsAccount        *account);
401 1 hiro
402 1008 hiro
/* return value is filename encoding */
403 1 hiro
gchar *folder_get_path                        (Folder                *folder);
404 1 hiro
gchar *folder_item_get_path                (FolderItem        *item);
405 1 hiro
406 1 hiro
gint   folder_item_scan                        (FolderItem        *item);
407 1 hiro
void   folder_item_scan_foreach                (GHashTable        *table);
408 1 hiro
GSList *folder_item_get_msg_list        (FolderItem        *item,
409 1 hiro
                                         gboolean         use_cache);
410 1491 hiro
GSList *folder_item_get_uncached_msg_list
411 1491 hiro
                                        (FolderItem        *item);
412 1008 hiro
/* return value is filename encoding */
413 1 hiro
gchar *folder_item_fetch_msg                (FolderItem        *item,
414 1 hiro
                                         gint                 num);
415 1 hiro
gint   folder_item_fetch_all_msg        (FolderItem        *item);
416 1 hiro
MsgInfo *folder_item_get_msginfo        (FolderItem        *item,
417 1 hiro
                                         gint                 num);
418 1 hiro
gint   folder_item_add_msg                (FolderItem        *dest,
419 1 hiro
                                         const gchar        *file,
420 1 hiro
                                         MsgFlags        *flags,
421 1 hiro
                                         gboolean         remove_source);
422 1 hiro
gint   folder_item_add_msgs                (FolderItem        *dest,
423 1 hiro
                                         GSList                *file_list,
424 1 hiro
                                         gboolean         remove_source,
425 1 hiro
                                         gint                *first);
426 2247 hiro
gint   folder_item_add_msg_msginfo        (FolderItem        *dest,
427 2247 hiro
                                         MsgInfo        *msginfo,
428 2247 hiro
                                         gboolean         remove_source);
429 2247 hiro
gint   folder_item_add_msgs_msginfo        (FolderItem        *dest,
430 2247 hiro
                                         GSList                *msginfo_list,
431 2247 hiro
                                         gboolean         remove_source,
432 2247 hiro
                                         gint                *first);
433 1 hiro
gint   folder_item_move_msg                (FolderItem        *dest,
434 1 hiro
                                         MsgInfo        *msginfo);
435 1 hiro
gint   folder_item_move_msgs                (FolderItem        *dest,
436 1 hiro
                                         GSList                *msglist);
437 1 hiro
gint   folder_item_copy_msg                (FolderItem        *dest,
438 1 hiro
                                         MsgInfo        *msginfo);
439 1 hiro
gint   folder_item_copy_msgs                (FolderItem        *dest,
440 1 hiro
                                         GSList                *msglist);
441 1 hiro
gint   folder_item_remove_msg                (FolderItem        *item,
442 1 hiro
                                         MsgInfo        *msginfo);
443 1 hiro
gint   folder_item_remove_msgs                (FolderItem        *item,
444 1 hiro
                                         GSList                *msglist);
445 1 hiro
gint   folder_item_remove_all_msg        (FolderItem        *item);
446 1008 hiro
447 1 hiro
gboolean folder_item_is_msg_changed        (FolderItem        *item,
448 1 hiro
                                         MsgInfo        *msginfo);
449 1008 hiro
450 1008 hiro
/* return value is filename encoding */
451 1 hiro
gchar *folder_item_get_cache_file        (FolderItem        *item);
452 1 hiro
gchar *folder_item_get_mark_file        (FolderItem        *item);
453 1 hiro
454 1 hiro
gint   folder_item_close                (FolderItem        *item);
455 1 hiro
456 1 hiro
#endif /* __FOLDER_H__ */