client.h revision 00fa8dcbc66f56daa737487c9dec7166c37de79e
5a580c3a38ced62d4bcc95b8ac7c4f2935b5d294Timo Sirainen#ifndef CLIENT_H
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define CLIENT_H
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#include "network.h"
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#include "client-common.h"
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen/* Disconnect client after idling this many milliseconds */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define CLIENT_LOGIN_IDLE_TIMEOUT_MSECS (3*60*1000)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct imap_client {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct client common;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen time_t created;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen int refcount;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct io *io;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct ostream *output;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct imap_parser *parser;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct timeout *to_idle_disconnect, *to_auth_waiting;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct timeout *to_authfail_delay;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct login_proxy *proxy;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen char *proxy_user, *proxy_master_user, *proxy_password;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen char *proxy_backend_capability;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen unsigned int bad_counter;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen const char *cmd_tag, *cmd_name;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen unsigned int starttls:1;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen unsigned int login_success:1;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen unsigned int cmd_finished:1;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen unsigned int proxy_sasl_ir:1;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen unsigned int proxy_seen_banner:1;
0001f76bf725c5cf403bade8556f142dd43144eeTimo Sirainen unsigned int skip_line:1;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen unsigned int input_blocked:1;
c18ff860dc22960fd37c272d929f889c7939a2c8Timo Sirainen unsigned int destroyed:1;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen unsigned int greeting_sent:1;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen unsigned int id_logged:1;
08a8b3de61139ba02371afc8240ac85be0e8b17cTimo Sirainen unsigned int auth_initializing:1;
c18ff860dc22960fd37c272d929f889c7939a2c8Timo Sirainen unsigned int client_ignores_capability_resp_code:1;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenvoid client_destroy(struct imap_client *client, const char *reason);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenvoid client_destroy_success(struct imap_client *client, const char *reason);
e237ebeb97f42950eef3efd0d3db85590160d5fbTimo Sirainenvoid client_destroy_internal_failure(struct imap_client *client);
e237ebeb97f42950eef3efd0d3db85590160d5fbTimo Sirainen
e237ebeb97f42950eef3efd0d3db85590160d5fbTimo Sirainenbool client_read(struct imap_client *client);
e237ebeb97f42950eef3efd0d3db85590160d5fbTimo Sirainenbool client_skip_line(struct imap_client *client);
e237ebeb97f42950eef3efd0d3db85590160d5fbTimo Sirainenvoid client_input(struct imap_client *client);
e237ebeb97f42950eef3efd0d3db85590160d5fbTimo Sirainen
e237ebeb97f42950eef3efd0d3db85590160d5fbTimo Sirainenvoid client_send_raw(struct imap_client *client, const char *data);
e237ebeb97f42950eef3efd0d3db85590160d5fbTimo Sirainenvoid client_ref(struct imap_client *client);
e237ebeb97f42950eef3efd0d3db85590160d5fbTimo Sirainenbool client_unref(struct imap_client *client);
e237ebeb97f42950eef3efd0d3db85590160d5fbTimo Sirainen
03010dbaa74ec70f062994dfe3cd39bedc99a28bTimo Sirainenvoid client_set_auth_waiting(struct imap_client *client);
e237ebeb97f42950eef3efd0d3db85590160d5fbTimo Sirainenvoid client_auth_failed(struct imap_client *client, bool nodelay);
e237ebeb97f42950eef3efd0d3db85590160d5fbTimo Sirainen
c18ff860dc22960fd37c272d929f889c7939a2c8Timo Sirainen#endif
714c6a150480112eb1a5f309d0cc39b60613a719Timo Sirainen