0.8.6claws60
[claws.git] / src / imap.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2002 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 #if USE_SSL
31 #  include "ssl.h"
32 #endif
33 #include "folder.h"
34 #include "session.h"
35 #include "procmsg.h"
36
37 typedef struct _IMAPFolder      IMAPFolder;
38 typedef struct _IMAPSession     IMAPSession;
39 typedef struct _IMAPNameSpace   IMAPNameSpace;
40 typedef struct _IMAPFolderItem  IMAPFolderItem;
41
42 #include "prefs_account.h"
43
44 #define IMAP_FOLDER(obj)        ((IMAPFolder *)obj)
45 #define IMAP_SESSION(obj)       ((IMAPSession *)obj)
46
47 struct _IMAPFolder
48 {
49         RemoteFolder rfolder;
50
51         /* list of IMAPNameSpace */
52         GList *ns_personal;
53         GList *ns_others;
54         GList *ns_shared;
55 };
56
57 struct _IMAPSession
58 {
59         Session session;
60
61         gchar *mbox;
62         time_t last_access_time;
63         gboolean authenticated;
64 };
65
66 struct _IMAPNameSpace
67 {
68         gchar *name;
69         gchar separator;
70 };
71
72 #define IMAP_SUCCESS    0
73 #define IMAP_SOCKET     2
74 #define IMAP_AUTHFAIL   3
75 #define IMAP_PROTOCOL   4
76 #define IMAP_SYNTAX     5
77 #define IMAP_IOERR      6
78 #define IMAP_ERROR      7
79
80 #define IMAPBUFSIZE     8192
81
82 typedef enum
83 {
84         IMAP_FLAG_SEEN          = 1 << 0,
85         IMAP_FLAG_ANSWERED      = 1 << 1,
86         IMAP_FLAG_FLAGGED       = 1 << 2,
87         IMAP_FLAG_DELETED       = 1 << 3,
88         IMAP_FLAG_DRAFT         = 1 << 4
89 } IMAPFlags;
90
91 #define IMAP_IS_SEEN(flags)     ((flags & IMAP_FLAG_SEEN) != 0)
92 #define IMAP_IS_ANSWERED(flags) ((flags & IMAP_FLAG_ANSWERED) != 0)
93 #define IMAP_IS_FLAGGED(flags)  ((flags & IMAP_FLAG_FLAGGED) != 0)
94 #define IMAP_IS_DELETED(flags)  ((flags & IMAP_FLAG_DELETED) != 0)
95 #define IMAP_IS_DRAFT(flags)    ((flags & IMAP_FLAG_DRAFT) != 0)
96
97 Folder  *imap_folder_new                (const gchar    *name,
98                                          const gchar    *path);
99 void     imap_folder_destroy            (Folder         *folder);
100
101 Session *imap_session_new               (const PrefsAccount *account);
102 void imap_session_authenticate          (IMAPSession        *session,
103                                          const PrefsAccount *account);
104 void imap_session_destroy               (Session        *session);
105 void imap_session_destroy_all           (void);
106
107 GSList *imap_get_msg_list               (Folder         *folder,
108                                          FolderItem     *item,
109                                          gboolean        use_cache);
110 gchar *imap_fetch_msg                   (Folder         *folder,
111                                          FolderItem     *item,
112                                          gint            uid);
113 gint imap_add_msg                       (Folder         *folder,
114                                          FolderItem     *dest,
115                                          const gchar    *file,
116                                          gboolean        remove_source);
117
118 gint imap_move_msg                      (Folder         *folder,
119                                          FolderItem     *dest,
120                                          MsgInfo        *msginfo);
121 gint imap_move_msgs_with_dest           (Folder         *folder,
122                                          FolderItem     *dest,
123                                          GSList         *msglist);
124 gint imap_copy_msg                      (Folder         *folder,
125                                          FolderItem     *dest,
126                                          MsgInfo        *msginfo);
127 gint imap_copy_msgs_with_dest           (Folder         *folder,
128                                          FolderItem     *dest,
129                                          GSList         *msglist);
130
131 gint imap_remove_msg                    (Folder         *folder,
132                                          FolderItem     *item,
133                                          gint            uid);
134 gint imap_remove_msgs                   (Folder         *folder,
135                                          FolderItem     *item,
136                                          GSList         *msglist);
137 gint imap_remove_all_msg                (Folder         *folder,
138                                          FolderItem     *item);
139
140 gboolean imap_is_msg_changed            (Folder         *folder,
141                                          FolderItem     *item,
142                                          MsgInfo        *msginfo);
143
144 gint imap_scan_folder                   (Folder         *folder,
145                                          FolderItem     *item);
146 void imap_scan_tree                     (Folder         *folder);
147
148 gint imap_create_tree                   (Folder         *folder);
149
150 FolderItem *imap_create_folder          (Folder         *folder,
151                                          FolderItem     *parent,
152                                          const gchar    *name);
153 gint imap_rename_folder                 (Folder         *folder,
154                                          FolderItem     *item,
155                                          const gchar    *name);
156 gint imap_remove_folder                 (Folder         *folder,
157                                          FolderItem     *item);
158
159 gint imap_msg_set_perm_flags            (MsgInfo        *msginfo,
160                                          MsgPermFlags    flags);
161 gint imap_msg_unset_perm_flags          (MsgInfo        *msginfo,
162                                          MsgPermFlags    flags);
163
164 #endif /* __IMAP_H__ */