c7d78fe4858b4687164fb3338f8958a98811b252
[claws.git] / src / imap.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2001 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 __IMAP_H__
21 #define __IMAP_H__
22
23 #ifdef HAVE_CONFIG_H
24 #  include "config.h"
25 #endif
26
27 #include <glib.h>
28 #include <time.h>
29
30 #include "folder.h"
31 #include "session.h"
32
33 typedef struct _IMAPSession     IMAPSession;
34 typedef struct _IMAPNameSpace   IMAPNameSpace;
35
36 #include "prefs_account.h"
37
38 #define IMAP_SESSION(obj)       ((IMAPSession *)obj)
39
40 struct _IMAPSession
41 {
42         Session session;
43
44         gchar *mbox;
45         time_t last_access_time;
46 };
47
48 struct _IMAPNameSpace
49 {
50         gchar *name;
51         gchar separator;
52 };
53
54 #define IMAP_SUCCESS    0
55 #define IMAP_SOCKET     2
56 #define IMAP_AUTHFAIL   3
57 #define IMAP_PROTOCOL   4
58 #define IMAP_SYNTAX     5
59 #define IMAP_IOERR      6
60 #define IMAP_ERROR      7
61
62 #define IMAPBUFSIZE     8192
63
64 typedef enum
65 {
66         IMAP_FLAG_SEEN          = 1 << 0,
67         IMAP_FLAG_ANSWERED      = 1 << 1,
68         IMAP_FLAG_FLAGGED       = 1 << 2,
69         IMAP_FLAG_DELETED       = 1 << 3,
70         IMAP_FLAG_DRAFT         = 1 << 4
71 } IMAPFlags;
72
73 #define IMAP_IS_SEEN(flags)     ((flags & IMAP_FLAG_SEEN) != 0)
74 #define IMAP_IS_ANSWERED(flags) ((flags & IMAP_FLAG_ANSWERED) != 0)
75 #define IMAP_IS_FLAGGED(flags)  ((flags & IMAP_FLAG_FLAGGED) != 0)
76 #define IMAP_IS_DELETED(flags)  ((flags & IMAP_FLAG_DELETED) != 0)
77 #define IMAP_IS_DRAFT(flags)    ((flags & IMAP_FLAG_DRAFT) != 0)
78
79 #if USE_SSL
80 Session *imap_session_new               (const gchar    *server,
81                                          gushort         port,
82                                          const gchar    *user,
83                                          const gchar    *pass,
84                                          gboolean        use_ssl);
85 #else
86 Session *imap_session_new               (const gchar    *server,
87                                          gushort         port,
88                                          const gchar    *user,
89                                          const gchar    *pass);
90 #endif
91 void imap_session_destroy               (IMAPSession    *session);
92 void imap_session_destroy_all           (void);
93
94 GSList *imap_get_msg_list               (Folder         *folder,
95                                          FolderItem     *item,
96                                          gboolean        use_cache);
97 gchar *imap_fetch_msg                   (Folder         *folder,
98                                          FolderItem     *item,
99                                          gint            uid);
100 gint imap_add_msg                       (Folder         *folder,
101                                          FolderItem     *dest,
102                                          const gchar    *file,
103                                          gboolean        remove_source);
104
105 gint imap_move_msg                      (Folder         *folder,
106                                          FolderItem     *dest,
107                                          MsgInfo        *msginfo);
108 gint imap_move_msgs_with_dest           (Folder         *folder,
109                                          FolderItem     *dest,
110                                          GSList         *msglist);
111 gint imap_copy_msg                      (Folder         *folder,
112                                          FolderItem     *dest,
113                                          MsgInfo        *msginfo);
114 gint imap_copy_msgs_with_dest           (Folder         *folder,
115                                          FolderItem     *dest,
116                                          GSList         *msglist);
117
118 gint imap_remove_msg                    (Folder         *folder,
119                                          FolderItem     *item,
120                                          gint            uid);
121 gint imap_remove_all_msg                (Folder         *folder,
122                                          FolderItem     *item);
123
124 void imap_scan_folder                   (Folder         *folder,
125                                          FolderItem     *item);
126 void imap_scan_tree                     (Folder         *folder);
127
128 gint imap_create_tree                   (Folder         *folder);
129
130 FolderItem *imap_create_folder          (Folder         *folder,
131                                          FolderItem     *parent,
132                                          const gchar    *name);
133 gint imap_remove_folder                 (Folder         *folder,
134                                          FolderItem     *item);
135
136 #endif /* __IMAP_H__ */