blob: 9fc4ff5a3daa315f7862d776c6bdece8786c82c8 [file] [log] [blame]
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -07001#ifndef HEADER_CURL_IMAP_H
2#define HEADER_CURL_IMAP_H
Kristian Monsen5ab50182010-05-14 18:53:44 +01003/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
Alex Deymo486467e2017-12-19 19:04:07 +010010 * Copyright (C) 2009 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
Kristian Monsen5ab50182010-05-14 18:53:44 +010011 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
Alex Deymod15eaac2016-06-28 14:49:26 -070014 * are also available at https://curl.haxx.se/docs/copyright.html.
Kristian Monsen5ab50182010-05-14 18:53:44 +010015 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 ***************************************************************************/
24
25#include "pingpong.h"
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070026#include "curl_sasl.h"
Kristian Monsen5ab50182010-05-14 18:53:44 +010027
28/****************************************************************************
29 * IMAP unique setup
30 ***************************************************************************/
31typedef enum {
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070032 IMAP_STOP, /* do nothing state, stops the state machine */
33 IMAP_SERVERGREET, /* waiting for the initial greeting immediately after
34 a connect */
35 IMAP_CAPABILITY,
Kristian Monsen5ab50182010-05-14 18:53:44 +010036 IMAP_STARTTLS,
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070037 IMAP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS
38 (multi mode only) */
39 IMAP_AUTHENTICATE,
40 IMAP_LOGIN,
41 IMAP_LIST,
Kristian Monsen5ab50182010-05-14 18:53:44 +010042 IMAP_SELECT,
43 IMAP_FETCH,
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070044 IMAP_FETCH_FINAL,
45 IMAP_APPEND,
46 IMAP_APPEND_FINAL,
47 IMAP_SEARCH,
Kristian Monsen5ab50182010-05-14 18:53:44 +010048 IMAP_LOGOUT,
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070049 IMAP_LAST /* never used */
Kristian Monsen5ab50182010-05-14 18:53:44 +010050} imapstate;
51
Alex Deymoe3149cc2016-10-05 11:18:42 -070052/* This IMAP struct is used in the Curl_easy. All IMAP data that is
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070053 connection-oriented must be in imap_conn to properly deal with the fact that
Alex Deymoe3149cc2016-10-05 11:18:42 -070054 perhaps the Curl_easy is changed between the times the connection is
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070055 used. */
56struct IMAP {
57 curl_pp_transfer transfer;
58 char *mailbox; /* Mailbox to select */
59 char *uidvalidity; /* UIDVALIDITY to check in select */
60 char *uid; /* Message UID to fetch */
61 char *section; /* Message SECTION to fetch */
62 char *partial; /* Message PARTIAL to fetch */
63 char *query; /* Query to search for */
64 char *custom; /* Custom request */
65 char *custom_params; /* Parameters for the custom request */
66};
67
Kristian Monsen5ab50182010-05-14 18:53:44 +010068/* imap_conn is used for struct connection-oriented data in the connectdata
69 struct */
70struct imap_conn {
71 struct pingpong pp;
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070072 imapstate state; /* Always use imap.c:state() to change state! */
73 bool ssldone; /* Is connect() over SSL done? */
Alex Deymo486467e2017-12-19 19:04:07 +010074 bool preauth; /* Is this connection PREAUTH? */
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070075 struct SASL sasl; /* SASL-related parameters */
76 unsigned int preftype; /* Preferred authentication type */
77 int cmdid; /* Last used command ID */
78 char resptag[5]; /* Response tag to wait for */
79 bool tls_supported; /* StartTLS capability supported by server */
80 bool login_disabled; /* LOGIN command disabled by server */
81 bool ir_supported; /* Initial response supported by server */
82 char *mailbox; /* The last selected mailbox */
83 char *mailbox_uidvalidity; /* UIDVALIDITY parsed from select response */
Kristian Monsen5ab50182010-05-14 18:53:44 +010084};
85
86extern const struct Curl_handler Curl_handler_imap;
87extern const struct Curl_handler Curl_handler_imaps;
88
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070089/* Authentication type flags */
90#define IMAP_TYPE_CLEARTEXT (1 << 0)
91#define IMAP_TYPE_SASL (1 << 1)
92
93/* Authentication type values */
94#define IMAP_TYPE_NONE 0
95#define IMAP_TYPE_ANY ~0U
96
97#endif /* HEADER_CURL_IMAP_H */