2011-02-16 [paul] 3.7.8cvs57
[claws.git] / src / etpan / imap-thread.h
1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2005-2011 DINH Viet Hoa and the Claws Mail team
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 3 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, see <http://www.gnu.org/licenses/>.
17  * 
18  */
19
20 #ifndef IMAP_THREAD_H
21
22 #define IMAP_THREAD_H
23
24 #include <libetpan/libetpan.h>
25 #include "folder.h"
26
27 #define IMAP_SET_MAX_COUNT 500
28
29 typedef enum
30 {
31         IMAP_FLAG_SEEN          = 1 << 0,
32         IMAP_FLAG_ANSWERED      = 1 << 1,
33         IMAP_FLAG_FLAGGED       = 1 << 2,
34         IMAP_FLAG_DELETED       = 1 << 3,
35         IMAP_FLAG_DRAFT         = 1 << 4,
36         IMAP_FLAG_FORWARDED     = 1 << 5,
37         IMAP_FLAG_SPAM          = 1 << 6,
38         IMAP_FLAG_HAM           = 1 << 7
39 } IMAPFlags;
40
41 void imap_main_set_timeout(int sec);
42 void imap_main_init(gboolean skip_ssl_cert_check);
43 void imap_main_done(gboolean have_connectivity);
44
45 void imap_init(Folder * folder);
46 void imap_done(Folder * folder);
47
48 int imap_threaded_connect(Folder * folder, const char * server, int port);
49 int imap_threaded_connect_ssl(Folder * folder, const char * server, int port);
50 struct mailimap_capability_data * imap_threaded_capability(Folder *folder, int *ok);
51
52 #ifndef G_OS_WIN32
53 int imap_threaded_connect_cmd(Folder * folder, const char * command,
54                               const char * server, int port);
55 #endif
56 void imap_threaded_disconnect(Folder * folder);
57
58 int imap_threaded_list(Folder * folder, const char * base,
59                        const char * wildcard,
60                        clist ** p_result);
61 int imap_threaded_lsub(Folder * folder, const char * base,
62                        const char * wildcard,
63                        clist ** p_result);
64 int imap_threaded_login(Folder * folder,
65                         const char * login, const char * password,
66                         const char * type);
67 int imap_threaded_status(Folder * folder, const char * mb,
68                 struct mailimap_mailbox_data_status ** data_status,
69                 guint mask);
70 int imap_threaded_close(Folder * folder);
71
72 int imap_threaded_noop(Folder * folder, unsigned int * p_exists, 
73                        unsigned int *p_recent, 
74                        unsigned int *p_expunge,
75                        unsigned int *p_unseen,
76                        unsigned int *p_uidnext,
77                        unsigned int *p_uidval);
78 int imap_threaded_starttls(Folder * folder, const gchar *host, int port);
79 int imap_threaded_create(Folder * folder, const char * mb);
80 int imap_threaded_rename(Folder * folder,
81                          const char * mb, const char * new_name);
82 int imap_threaded_delete(Folder * folder, const char * mb);
83 int imap_threaded_select(Folder * folder, const char * mb,
84                          gint * exists, gint * recent, gint * unseen,
85                          guint32 * uid_validity, gint * can_create_flags,
86                          GSList **ok_flags);
87 int imap_threaded_examine(Folder * folder, const char * mb,
88                           gint * exists, gint * recent, gint * unseen,
89                           guint32 * uid_validity);
90 int imap_threaded_subscribe(Folder * folder, const char * mb,
91                        gboolean subscribe);
92
93 enum {
94         IMAP_SEARCH_TYPE_SIMPLE,
95         IMAP_SEARCH_TYPE_SEEN,
96         IMAP_SEARCH_TYPE_UNSEEN,
97         IMAP_SEARCH_TYPE_ANSWERED,
98         IMAP_SEARCH_TYPE_FLAGGED,
99         IMAP_SEARCH_TYPE_DELETED,
100         IMAP_SEARCH_TYPE_FORWARDED,
101         IMAP_SEARCH_TYPE_SPAM,
102 };
103
104 int imap_threaded_search(Folder * folder, int search_type,
105                          struct mailimap_set * set, clist ** result);
106
107 int imap_threaded_fetch_uid(Folder * folder, uint32_t first_index,
108                             carray ** result);
109
110 void imap_fetch_uid_list_free(carray * uid_list);
111
112 int imap_threaded_fetch_uid_flags(Folder * folder, uint32_t first_index,
113                                   carray ** fetch_result);
114
115 void imap_fetch_uid_flags_list_free(carray * uid_flags_list);
116
117 int imap_threaded_fetch_content(Folder * folder, uint32_t msg_index,
118                                 int with_body,
119                                 const char * filename);
120
121 struct imap_fetch_env_info {
122         uint32_t uid;
123         char * headers;
124         uint32_t size;
125         int flags;
126 };
127
128 int imap_threaded_fetch_env(Folder * folder, struct mailimap_set * set,
129                             carray ** p_env_list);
130
131 void imap_fetch_env_free(carray * env_list);
132
133 int imap_threaded_append(Folder * folder, const char * mailbox,
134                          const char * filename,
135                          struct mailimap_flag_list * flag_list,
136                          int *uid);
137
138 int imap_threaded_expunge(Folder * folder);
139
140 int imap_threaded_copy(Folder * folder, struct mailimap_set * set,
141                        const char * mb, struct mailimap_set **source,
142                        struct mailimap_set **dest);
143
144 int imap_threaded_store(Folder * folder, struct mailimap_set * set,
145                         struct mailimap_store_att_flags * store_att_flags);
146
147 void imap_threaded_cancel(Folder * folder);
148
149 #endif