5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen#ifndef IMAP_CLIENT_H
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen#define IMAP_CLIENT_H
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen#include "net.h"
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenstruct imap_client_state {
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen /* required: */
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen const char *username, *mail_log_prefix;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen /* optional: */
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen const char *session_id, *userdb_fields, *stats;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen struct ip_addr local_ip, remote_ip;
1e2b3bd82f2d4fbae0963f4a220df30b7b5ae628Timo Sirainen time_t session_created;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen uid_t uid;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen gid_t gid;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
2bc963ea051ddacefe0fa5e26280e8ef853fd6c6Timo Sirainen dev_t peer_dev;
2bc963ea051ddacefe0fa5e26280e8ef853fd6c6Timo Sirainen ino_t peer_ino;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
f24edebe360d3effe584a884aa7d119daf3fd371Aki Tuomi char *tag;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen const unsigned char *state;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen size_t state_size;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen unsigned int imap_idle_notify_interval;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen bool idle_cmd;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen bool have_notify_fd;
ce35092786b51fa7fe1f91ca06c2eec6ee447534manuel bool anvil_sent;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen};
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenstruct imap_client *
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenimap_client_create(int fd, const struct imap_client_state *state);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenvoid imap_client_add_notify_fd(struct imap_client *client, int fd);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenvoid imap_client_create_finish(struct imap_client *client);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenvoid imap_client_destroy(struct imap_client **_client, const char *reason);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
17062405030a3fa095e43d5b8b71afc5536f0a22Timo Sirainenvoid imap_clients_init(void);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenvoid imap_clients_deinit(void);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen#endif