f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch#ifndef IMAP_URLAUTH_CLIENT_H
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch#define IMAP_URLAUTH_CLIENT_H
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschstruct client;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschstruct mail_storage;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschenum imap_urlauth_worker_state {
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch IMAP_URLAUTH_WORKER_STATE_INACTIVE = 0,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch IMAP_URLAUTH_WORKER_STATE_CONNECTED,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch IMAP_URLAUTH_WORKER_STATE_ACTIVE,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch};
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschstruct client {
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch struct client *prev, *next;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch int fd_in, fd_out, fd_ctrl;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch struct io *ctrl_io;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch struct ostream *output, *ctrl_output;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch struct istream *ctrl_input;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch struct timeout *to_idle;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f1edf7f20661ef9627acbf4054acddcba4d2eb3fStephan Bosch char *username, *service;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch ARRAY_TYPE(const_string) access_apps;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch /* settings: */
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch const struct imap_urlauth_settings *set;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch enum imap_urlauth_worker_state worker_state;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool disconnected:1;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch};
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschextern struct client *imap_urlauth_clients;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschextern unsigned int imap_urlauth_client_count;
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f1edf7f20661ef9627acbf4054acddcba4d2eb3fStephan Boschint client_create(const char *service, const char *username,
f1edf7f20661ef9627acbf4054acddcba4d2eb3fStephan Bosch int fd_in, int fd_out, const struct imap_urlauth_settings *set,
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch struct client **client_r);
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschvoid client_destroy(struct client *client, const char *reason);
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschvoid client_send_line(struct client *client, const char *fmt, ...)
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch ATTR_FORMAT(2, 3);
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschvoid client_disconnect(struct client *client, const char *reason);
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Boschvoid clients_destroy_all(void);
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch
f9511e684858bf5f6ac77ab12254b85b737beae8Stephan Bosch#endif