* src/compose.c
[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         gchar *selected_folder;
52         
53         /* list of IMAPNameSpace */
54         GList *ns_personal;
55         GList *ns_others;
56         GList *ns_shared;
57 };
58
59 struct _IMAPSession
60 {
61         Session session;
62
63         gchar *mbox;
64         time_t last_access_time;
65 };
66
67 struct _IMAPNameSpace
68 {
69         gchar *name;
70         gchar separator;
71 };
72
73 struct _IMAPFolderItem
74 {
75         FolderItem item;
76
77         guint lastuid;
78         GSList *uid_list;
79 };
80
81 #define IMAP_SUCCESS    0
82 #define IMAP_SOCKET     2
83 #define IMAP_AUTHFAIL   3
84 #define IMAP_PROTOCOL   4
85 #define IMAP_SYNTAX     5
86 #define IMAP_IOERR      6
87 #define IMAP_ERROR      7
88
89 #define IMAPBUFSIZE     8192
90
91 typedef enum
92 {
93         IMAP_FLAG_SEEN          = 1 << 0,
94         IMAP_FLAG_ANSWERED      = 1 << 1,
95         IMAP_FLAG_FLAGGED       = 1 << 2,
96         IMAP_FLAG_DELETED       = 1 << 3,
97         IMAP_FLAG_DRAFT         = 1 << 4
98 } IMAPFlags;
99
100 #define IMAP_IS_SEEN(flags)     ((flags & IMAP_FLAG_SEEN) != 0)
101 #define IMAP_IS_ANSWERED(flags) ((flags & IMAP_FLAG_ANSWERED) != 0)
102 #define IMAP_IS_FLAGGED(flags)  ((flags & IMAP_FLAG_FLAGGED) != 0)
103 #define IMAP_IS_DELETED(flags)  ((flags & IMAP_FLAG_DELETED) != 0)
104 #define IMAP_IS_DRAFT(flags)    ((flags & IMAP_FLAG_DRAFT) != 0)
105
106 Folder  *imap_folder_new                (const gchar    *name,
107                                          const gchar    *path);
108 void     imap_folder_destroy            (Folder         *folder);
109
110 FolderItem *imap_folder_item_new        ();
111 void imap_folder_item_destroy           (FolderItem *item);
112
113 Session *imap_session_new               (const PrefsAccount *account);
114 void imap_session_destroy               (Session        *session);
115 void imap_session_destroy_all           (void);
116
117 GSList *imap_get_msg_list               (Folder         *folder,
118                                          FolderItem     *item,
119                                          gboolean        use_cache);
120 gchar *imap_fetch_msg                   (Folder         *folder,
121                                          FolderItem     *item,
122                                          gint            uid);
123 gint imap_add_msg                       (Folder         *folder,
124                                          FolderItem     *dest,
125                                          const gchar    *file,
126                                          gboolean        remove_source);
127
128 gint imap_move_msg                      (Folder         *folder,
129                                          FolderItem     *dest,
130                                          MsgInfo        *msginfo);
131 gint imap_move_msgs_with_dest           (Folder         *folder,
132                                          FolderItem     *dest,
133                                          GSList         *msglist);
134 gint imap_copy_msg                      (Folder         *folder,
135                                          FolderItem     *dest,
136                                          MsgInfo        *msginfo);
137 gint imap_copy_msgs_with_dest           (Folder         *folder,
138                                          FolderItem     *dest,
139                                          GSList         *msglist);
140
141 gint imap_remove_msg                    (Folder         *folder,
142                                          FolderItem     *item,
143                                          gint            uid);
144 gint imap_remove_all_msg                (Folder         *folder,
145                                          FolderItem     *item);
146 gboolean imap_is_msg_changed            (Folder         *folder,
147                                          FolderItem     *item,
148                                          MsgInfo        *msginfo);
149
150 gint imap_scan_folder                   (Folder         *folder,
151                                          FolderItem     *item);
152 void imap_scan_tree                     (Folder         *folder);
153
154 gint imap_create_tree                   (Folder         *folder);
155
156 FolderItem *imap_create_folder          (Folder         *folder,
157                                          FolderItem     *parent,
158                                          const gchar    *name);
159 gint imap_rename_folder                 (Folder         *folder,
160                                          FolderItem     *item,
161                                          const gchar    *name);
162 gint imap_remove_folder                 (Folder         *folder,
163                                          FolderItem     *item);
164
165 gint imap_msg_set_perm_flags            (MsgInfo        *msginfo,
166                                          MsgPermFlags    flags);
167 gint imap_msg_unset_perm_flags          (MsgInfo        *msginfo,
168                                          MsgPermFlags    flags);
169
170 #endif /* __IMAP_H__ */