client.h revision e95dba8921087afebb8a92c592af3b8ca22ae796
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#ifndef CLIENT_H
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen#define CLIENT_H
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
80c1d98d3638b71e57a39cafa88b9122bf8169c6Timo Sirainen#include "network.h"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#include "client-common.h"
94a8cb0ee1d85569ad1a2acacd92d3ce22f8a1cbTimo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Disconnect client after idling this many milliseconds */
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen#define CLIENT_LOGIN_IDLE_TIMEOUT_MSECS (3*60*1000)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstruct imap_client {
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen struct client common;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen time_t created;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int refcount;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen struct io *io;
31ddc75584c5cde53d2e78a737587f2e7fdcb0d2Timo Sirainen struct ostream *output;
8887bf3757d51d73887dd20b1db3334d867d3817Timo Sirainen struct imap_parser *parser;
8887bf3757d51d73887dd20b1db3334d867d3817Timo Sirainen struct timeout *to_idle_disconnect, *to_auth_waiting;
369a1084c500a9df7448ffa9409ce32e42060bc2Timo Sirainen struct timeout *to_authfail_delay;
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen struct login_proxy *proxy;
51b979b6414b940f04677a7e2d064be119345954Timo Sirainen char *proxy_user, *proxy_master_user, *proxy_password;
a53cb86b4d733d9c48ee4d285bed477c80825804Timo Sirainen char *proxy_backend_capability;
a53cb86b4d733d9c48ee4d285bed477c80825804Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int bad_counter;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char *cmd_tag, *cmd_name;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int login_success:1;
b7b81543899e306c71e6152516d8698416162bcbTimo Sirainen unsigned int cmd_finished:1;
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen unsigned int proxy_sasl_ir:1;
6ec7cf71ccd0eed1f9cc1b0bda8960796b04160bTimo Sirainen unsigned int proxy_seen_banner:1;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int skip_line:1;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int input_blocked:1;
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen unsigned int destroyed:1;
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen unsigned int greeting_sent:1;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int id_logged:1;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int auth_initializing:1;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int capability_command_used:1;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen};
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid client_destroy(struct imap_client *client, const char *reason);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid client_destroy_success(struct imap_client *client, const char *reason);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid client_destroy_internal_failure(struct imap_client *client);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid client_send_line(struct imap_client *client, const char *line);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid client_send_tagline(struct imap_client *client, const char *line);
8e7da21696c9f8a6d5e601243fb6172ec85d47b2Timo Sirainen
024815ea2ffdda9ea79919f18e865663977f73eaTimo Sirainenbool client_read(struct imap_client *client);
024815ea2ffdda9ea79919f18e865663977f73eaTimo Sirainenbool client_skip_line(struct imap_client *client);
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainenvoid client_input(struct imap_client *client);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
811f2e26d9782d9cb99fdf82e18ffa0a77564fe2Timo Sirainenvoid client_ref(struct imap_client *client);
811f2e26d9782d9cb99fdf82e18ffa0a77564fe2Timo Sirainenbool client_unref(struct imap_client *client);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid client_set_auth_waiting(struct imap_client *client);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid client_auth_failed(struct imap_client *client, bool nodelay);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#endif
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen