bc0a83d48dac0385cfa38ee229c7393f090e5905
[platform/upstream/curl.git] / lib / imap.h
1 #ifndef HEADER_CURL_IMAP_H
2 #define HEADER_CURL_IMAP_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 2009 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
11  *
12  * This software is licensed as described in the file COPYING, which
13  * you should have received as part of this distribution. The terms
14  * are also available at http://curl.haxx.se/docs/copyright.html.
15  *
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"
26
27 /****************************************************************************
28  * IMAP unique setup
29  ***************************************************************************/
30 typedef enum {
31   IMAP_STOP,         /* do nothing state, stops the state machine */
32   IMAP_SERVERGREET,  /* waiting for the initial greeting immediately after
33                         a connect */
34   IMAP_CAPABILITY,
35   IMAP_STARTTLS,
36   IMAP_UPGRADETLS,   /* asynchronously upgrade the connection to SSL/TLS
37                        (multi mode only) */
38   IMAP_AUTHENTICATE_PLAIN,
39   IMAP_AUTHENTICATE_LOGIN,
40   IMAP_AUTHENTICATE_LOGIN_PASSWD,
41   IMAP_AUTHENTICATE_CRAMMD5,
42   IMAP_AUTHENTICATE_DIGESTMD5,
43   IMAP_AUTHENTICATE_DIGESTMD5_RESP,
44   IMAP_AUTHENTICATE_NTLM,
45   IMAP_AUTHENTICATE_NTLM_TYPE2MSG,
46   IMAP_AUTHENTICATE_FINAL,
47   IMAP_LOGIN,
48   IMAP_LIST,
49   IMAP_SELECT,
50   IMAP_FETCH,
51   IMAP_FETCH_FINAL,
52   IMAP_APPEND,
53   IMAP_APPEND_FINAL,
54   IMAP_LOGOUT,
55   IMAP_LAST          /* never used */
56 } imapstate;
57
58 /* This IMAP struct is used in the SessionHandle. All IMAP data that is
59    connection-oriented must be in imap_conn to properly deal with the fact that
60    perhaps the SessionHandle is changed between the times the connection is
61    used. */
62 struct IMAP {
63   curl_pp_transfer transfer;
64   char *mailbox;          /* Mailbox to select */
65   char *uidvalidity;      /* UIDVALIDITY to check in select */
66   char *uid;              /* Message UID to fetch */
67   char *section;          /* Message SECTION to fetch */
68   char *custom;           /* Custom request */
69   char *custom_params;    /* Parameters for the custom request */
70 };
71
72 /* imap_conn is used for struct connection-oriented data in the connectdata
73    struct */
74 struct imap_conn {
75   struct pingpong pp;
76   imapstate state;            /* Always use imap.c:state() to change state! */
77   bool ssldone;               /* Is connect() over SSL done? */
78   unsigned int authmechs;     /* Accepted authentication mechanisms */
79   unsigned int prefmech;      /* Preferred authentication mechanism */
80   unsigned int authused;      /* Auth mechanism used for the connection */
81   int cmdid;                  /* Last used command ID */
82   char resptag[5];            /* Response tag to wait for */
83   bool tls_supported;         /* StartTLS capability supported by server */
84   bool login_disabled;        /* LOGIN command disabled by server */
85   bool ir_supported;          /* Initial response supported by server */
86   char *mailbox;              /* The last selected mailbox */
87   char *mailbox_uidvalidity;  /* UIDVALIDITY parsed from select response */
88 };
89
90 extern const struct Curl_handler Curl_handler_imap;
91 extern const struct Curl_handler Curl_handler_imaps;
92
93 #endif /* HEADER_CURL_IMAP_H */