nntp_list(): return real error code instead of hardcoded NN_ERROR
[claws.git] / src / imap.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999,2000 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
30 #include "prefs_account.h"
31
32 #define IMAP_SESSION(obj)       ((IMAPSession *)obj)
33
34 struct _IMAPSession
35 {
36         Session session;
37
38         gchar *mbox;
39 };
40
41 #define IMAP_SUCCESS    0
42 #define IMAP_SOCKET     2
43 #define IMAP_AUTHFAIL   3
44 #define IMAP_PROTOCOL   4
45 #define IMAP_SYNTAX     5
46 #define IMAP_IOERR      6
47 #define IMAP_ERROR      7
48
49 #define IMAPBUFSIZE     8192
50
51 typedef enum
52 {
53         IMAP_FLAG_SEEN          = 1 << 0,
54         IMAP_FLAG_ANSWERED      = 1 << 1,
55         IMAP_FLAG_FLAGGED       = 1 << 2,
56         IMAP_FLAG_DELETED       = 1 << 3,
57         IMAP_FLAG_DRAFT         = 1 << 4
58 } IMAPFlags;
59
60 #define IMAP_IS_SEEN(flags)     ((flags & IMAP_FLAG_SEEN) != 0)
61 #define IMAP_IS_ANSWERED(flags) ((flags & IMAP_FLAG_ANSWERED) != 0)
62 #define IMAP_IS_FLAGGED(flags)  ((flags & IMAP_FLAG_FLAGGED) != 0)
63 #define IMAP_IS_DELETED(flags)  ((flags & IMAP_FLAG_DELETED) != 0)
64 #define IMAP_IS_DRAFT(flags)    ((flags & IMAP_FLAG_DRAFT) != 0)
65
66 Session *imap_session_new               (const gchar    *server,
67                                          gushort         port,
68                                          const gchar    *user,
69                                          const gchar    *pass);
70 void imap_session_destroy               (IMAPSession    *session);
71 void imap_session_destroy_all           (void);
72
73 GSList *imap_get_msg_list               (Folder         *folder,
74                                          FolderItem     *item,
75                                          gboolean        use_cache);
76 gchar *imap_fetch_msg                   (Folder         *folder,
77                                          FolderItem     *item,
78                                          gint            num);
79
80 gint imap_move_msg                      (Folder         *folder,
81                                          FolderItem     *dest,
82                                          MsgInfo        *msginfo);
83
84 gint imap_move_msgs_with_dest           (Folder         *folder,
85                                          FolderItem     *dest,
86                                          GSList         *msglist);
87 gint imap_remove_msg                    (Folder         *folder,
88                                          FolderItem     *item,
89                                          gint            num);
90 gint imap_remove_all_msg                (Folder         *folder,
91                                          FolderItem     *item);
92
93 void imap_scan_folder                   (Folder         *folder,
94                                          FolderItem     *item);
95
96 FolderItem *imap_create_folder          (Folder         *folder,
97                                          FolderItem     *parent,
98                                          const gchar    *name);
99
100 #endif /* __IMAP_H__ */