2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-9 Brandon Long <blong@fiction.net>
4 * Copyright (C) 1999-2001 Brendan Cully <brendan@kublai.com>
6 * This file is part of mutt-ng, see http://www.muttng.org/.
7 * It's licensed under the GNU General Public License,
8 * please see the file GPL in the top level source directory.
11 #ifndef _IMAP_PRIVATE_H
12 #define _IMAP_PRIVATE_H 1
16 #include <lib-ui/curses.h>
19 #include <lib-sys/mutt_socket.h>
23 #define IMAP_SSL_PORT 993
26 #define IMAP_LOG_CMD 2
27 #define IMAP_LOG_LTRL 4
28 #define IMAP_LOG_PASS 5
30 /* IMAP command responses. Used in IMAP_COMMAND.state too */
32 #define IMAP_CMD_OK (0)
34 #define IMAP_CMD_BAD (-1)
36 #define IMAP_CMD_NO (-2)
38 #define IMAP_CMD_CONTINUE (1)
40 #define IMAP_CMD_RESPOND (2)
42 /* number of entries in the hash table */
43 #define IMAP_CACHE_LEN 10
47 #define IMAP_REOPEN_ALLOW (1<<0)
48 #define IMAP_EXPUNGE_EXPECTED (1<<1)
49 #define IMAP_EXPUNGE_PENDING (1<<2)
50 #define IMAP_NEWMAIL_PENDING (1<<3)
51 #define IMAP_FLAGS_PENDING (1<<4)
53 /* imap_exec flags (see imap_exec) */
54 #define IMAP_CMD_FAIL_OK (1<<0)
55 #define IMAP_CMD_PASS (1<<1)
65 IMAP_DISCONNECTED = 0,
78 /* ACL Rights are moved to ../mx.h */
80 /* Capabilities we are interested in */
85 ACL, /* RFC 2086: IMAP4 ACL extension */
86 NAMESPACE, /* RFC 2342: IMAP4 Namespace */
87 ACRAM_MD5, /* RFC 2195: CRAM-MD5 authentication */
88 AGSSAPI, /* RFC 1731: GSSAPI authentication */
89 AUTH_ANON, /* AUTH=ANONYMOUS */
90 STARTTLS, /* RFC 2595: STARTTLS */
91 LOGINDISABLED, /* LOGINDISABLED */
96 /* imap_conn_find flags */
97 #define M_IMAP_CONN_NONEW (1<<0)
98 #define M_IMAP_CONN_NOSELECT (1<<1)
100 /* -- data structures -- */
112 /* We get these when we check if namespace exists - cache them */
115 } IMAP_NAMESPACE_INFO;
117 /* IMAP command structure */
119 char seq[SEQLEN + 1];
126 /* This data is specific to a CONNECTION to an IMAP server */
129 unsigned char status;
130 /* let me explain capstr: SASL needs the capability string (not bits).
132 * 1. rerun CAPABILITY inside SASL function.
133 * 2. build appropriate CAPABILITY string by reverse-engineering from bits.
134 * 3. keep a copy until after authentication.
135 * I've chosen (3) for now. (2) might not be too bad, but it involves
136 * tracking all possible capabilities. bah. (1) I don't like because
137 * it's just no fun to get the same information twice */
139 unsigned char capabilities[(CAPMAX + 7) / 8];
141 time_t lastread; /* last time we read a command for the server */
142 /* who knows, one day we may run multiple commands in parallel */
145 /* The following data is all specific to the currently SELECTED mbox */
149 unsigned short check_status;
150 unsigned char reopen;
151 unsigned char rights[(RIGHTSMAX + 7) / 8];
152 unsigned int newMailCount;
153 IMAP_CACHE cache[IMAP_CACHE_LEN];
155 unsigned long uid_validity;
158 /* all folder flags - system flags AND keywords */
159 string_list_t *flags;
162 /* I wish that were called IMAP_CONTEXT :( */
165 #define CTX_DATA ((IMAP_DATA *) ctx->data)
167 /* -- private IMAP functions -- */
169 int imap_create_mailbox (IMAP_DATA * idata, char *mailbox);
170 int imap_rename_mailbox (IMAP_DATA * idata, IMAP_MBOX * mx,
171 const char *newname);
172 int imap_make_msg_set (IMAP_DATA * idata, BUFFER * buf, int flag,
174 int imap_open_connection (IMAP_DATA * idata);
175 IMAP_DATA *imap_conn_find (const ACCOUNT * account, int flags);
176 int imap_parse_list_response (IMAP_DATA * idata, char **name, int *noselect,
177 int *noinferiors, char *delim);
178 int imap_read_literal (FILE * fp, IMAP_DATA * idata, long bytes, progress_t*);
179 void imap_expunge_mailbox (IMAP_DATA * idata);
180 int imap_reconnect (CONTEXT * ctx);
181 void imap_logout (IMAP_DATA * idata);
182 int imap_sync_message (IMAP_DATA*, HEADER*, BUFFER*, int*);
185 int imap_authenticate (IMAP_DATA * idata);
188 int imap_cmd_start (IMAP_DATA * idata, const char *cmd);
189 int imap_cmd_step (IMAP_DATA * idata);
190 void imap_cmd_finish (IMAP_DATA * idata);
191 int imap_code (const char *s);
192 int imap_exec (IMAP_DATA * idata, const char *cmd, int flags);
195 void imap_add_keywords (char *s, HEADER * keywords, string_list_t * mailbox_flags,
197 void imap_free_header_data (void **data);
198 int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend);
199 char *imap_set_flags (IMAP_DATA * idata, HEADER * h, char *s);
202 int imap_continue (const char *msg, const char *resp);
203 void imap_error (const char *where, const char *msg);
204 IMAP_DATA *imap_new_idata (void);
205 void imap_free_idata (IMAP_DATA ** idata);
206 char *imap_fix_path (IMAP_DATA * idata, char *mailbox, char *path,
208 int imap_get_literal_count (const char *buf, long *bytes);
209 char *imap_get_qualifier (char *buf);
210 char *imap_next_word (char *s);
211 time_t imap_parse_date (char *s);
212 void imap_qualify_path (char *dest, size_t len, IMAP_MBOX * mx, char *path);
213 void imap_quote_string (char *dest, size_t slen, const char *src);
214 void imap_unquote_string (char *s);
215 void imap_munge_mbox_name (char *dest, size_t dlen, const char *src);
216 void imap_unmunge_mbox_name (char *s);
217 int imap_wordcasecmp (const char *a, const char *b);
220 void imap_utf7_encode (char **s);
221 void imap_utf7_decode (char **s);