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