1 #ifndef CLIENT_H 2 #define CLIENT_H 3 4 #include "net.h" 5 #include "client-common.h" 6 7 /* maximum length for managesieve command line. */ 8 #define MAX_MANAGESIEVE_LINE 8192 9 10 enum managesieve_proxy_state { 11 MSIEVE_PROXY_STATE_NONE, 12 MSIEVE_PROXY_STATE_TLS_START, 13 MSIEVE_PROXY_STATE_TLS_READY, 14 MSIEVE_PROXY_STATE_XCLIENT, 15 MSIEVE_PROXY_STATE_AUTH, 16 17 MSIEVE_PROXY_STATE_COUNT 18 }; 19 struct managesieve_command; 20 21 struct managesieve_client { 22 struct client common; 23 24 const struct managesieve_login_settings *set; 25 struct managesieve_parser *parser; 26 27 enum managesieve_proxy_state proxy_state; 28 29 const char *cmd_name; 30 struct managesieve_command *cmd; 31 32 struct istream *auth_response_input; 33 34 bool cmd_finished:1; 35 bool cmd_parsed_args:1; 36 bool skip_line:1; 37 bool auth_mech_name_parsed:1; 38 39 bool proxy_starttls:1; 40 bool proxy_sasl:1; 41 bool proxy_xclient:1; 42 }; 43 44 bool client_skip_line(struct managesieve_client *client); 45 46 enum managesieve_cmd_reply { 47 MANAGESIEVE_CMD_REPLY_OK, 48 MANAGESIEVE_CMD_REPLY_NO, 49 MANAGESIEVE_CMD_REPLY_BYE 50 }; 51 52 void client_send_reply(struct client *client, 53 enum managesieve_cmd_reply reply, const char *text); 54 55 void client_send_reply_code(struct client *client, 56 enum managesieve_cmd_reply reply, const char *resp_code, 57 const char *text); 58 59 #define client_send_ok(client, text) \ 60 client_send_reply(client, MANAGESIEVE_CMD_REPLY_OK, text) 61 #define client_send_no(client, text) \ 62 client_send_reply(client, MANAGESIEVE_CMD_REPLY_NO, text) 63 #define client_send_bye(client, text) \ 64 client_send_reply(client, MANAGESIEVE_CMD_REPLY_BYE, text) 65 66 #define client_send_okresp(client, resp_code, text) \ 67 client_send_reply_code(client, MANAGESIEVE_CMD_REPLY_OK, resp_code, text) 68 #define client_send_noresp(client, resp_code, text) \ 69 client_send_reply_code(client, MANAGESIEVE_CMD_REPLY_NO, resp_code, text) 70 #define client_send_byeresp(client, resp_code, text) \ 71 client_send_reply_code(client, MANAGESIEVE_CMD_REPLY_BYE, resp_code, text) 72 73 74 #endif 75