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