00001 #ifndef HEADER_CURL_IMAP_H 00002 #define HEADER_CURL_IMAP_H 00003 /*************************************************************************** 00004 * _ _ ____ _ 00005 * Project ___| | | | _ \| | 00006 * / __| | | | |_) | | 00007 * | (__| |_| | _ <| |___ 00008 * \___|\___/|_| \_\_____| 00009 * 00010 * Copyright (C) 2009 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. 00011 * 00012 * This software is licensed as described in the file COPYING, which 00013 * you should have received as part of this distribution. The terms 00014 * are also available at https://curl.haxx.se/docs/copyright.html. 00015 * 00016 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 00017 * copies of the Software, and permit persons to whom the Software is 00018 * furnished to do so, under the terms of the COPYING file. 00019 * 00020 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 00021 * KIND, either express or implied. 00022 * 00023 ***************************************************************************/ 00024 00025 #include "pingpong.h" 00026 #include "curl_sasl.h" 00027 00028 /**************************************************************************** 00029 * IMAP unique setup 00030 ***************************************************************************/ 00031 typedef enum { 00032 IMAP_STOP, /* do nothing state, stops the state machine */ 00033 IMAP_SERVERGREET, /* waiting for the initial greeting immediately after 00034 a connect */ 00035 IMAP_CAPABILITY, 00036 IMAP_STARTTLS, 00037 IMAP_UPGRADETLS, /* asynchronously upgrade the connection to SSL/TLS 00038 (multi mode only) */ 00039 IMAP_AUTHENTICATE, 00040 IMAP_LOGIN, 00041 IMAP_LIST, 00042 IMAP_SELECT, 00043 IMAP_FETCH, 00044 IMAP_FETCH_FINAL, 00045 IMAP_APPEND, 00046 IMAP_APPEND_FINAL, 00047 IMAP_SEARCH, 00048 IMAP_LOGOUT, 00049 IMAP_LAST /* never used */ 00050 } imapstate; 00051 00052 /* This IMAP struct is used in the Curl_easy. All IMAP data that is 00053 connection-oriented must be in imap_conn to properly deal with the fact that 00054 perhaps the Curl_easy is changed between the times the connection is 00055 used. */ 00056 struct IMAP { 00057 curl_pp_transfer transfer; 00058 char *mailbox; /* Mailbox to select */ 00059 char *uidvalidity; /* UIDVALIDITY to check in select */ 00060 char *uid; /* Message UID to fetch */ 00061 char *section; /* Message SECTION to fetch */ 00062 char *partial; /* Message PARTIAL to fetch */ 00063 char *query; /* Query to search for */ 00064 char *custom; /* Custom request */ 00065 char *custom_params; /* Parameters for the custom request */ 00066 }; 00067 00068 /* imap_conn is used for struct connection-oriented data in the connectdata 00069 struct */ 00070 struct imap_conn { 00071 struct pingpong pp; 00072 imapstate state; /* Always use imap.c:state() to change state! */ 00073 bool ssldone; /* Is connect() over SSL done? */ 00074 struct SASL sasl; /* SASL-related parameters */ 00075 unsigned int preftype; /* Preferred authentication type */ 00076 int cmdid; /* Last used command ID */ 00077 char resptag[5]; /* Response tag to wait for */ 00078 bool tls_supported; /* StartTLS capability supported by server */ 00079 bool login_disabled; /* LOGIN command disabled by server */ 00080 bool ir_supported; /* Initial response supported by server */ 00081 char *mailbox; /* The last selected mailbox */ 00082 char *mailbox_uidvalidity; /* UIDVALIDITY parsed from select response */ 00083 }; 00084 00085 extern const struct Curl_handler Curl_handler_imap; 00086 extern const struct Curl_handler Curl_handler_imaps; 00087 00088 /* Authentication type flags */ 00089 #define IMAP_TYPE_CLEARTEXT (1 << 0) 00090 #define IMAP_TYPE_SASL (1 << 1) 00091 00092 /* Authentication type values */ 00093 #define IMAP_TYPE_NONE 0 00094 #define IMAP_TYPE_ANY ~0U 00095 00096 #endif /* HEADER_CURL_IMAP_H */