16968N/A#ifndef POP3C_CLIENT_H
16968N/A#define POP3C_CLIENT_H
16968N/A
16968N/A#include "net.h"
16968N/A#include "pop3c-settings.h"
16968N/A
16968N/Aenum pop3c_capability {
16968N/A POP3C_CAPABILITY_PIPELINING = 0x01,
16968N/A POP3C_CAPABILITY_TOP = 0x02,
16968N/A POP3C_CAPABILITY_UIDL = 0x04
16968N/A};
16968N/A
16968N/Aenum pop3c_command_state {
16968N/A POP3C_COMMAND_STATE_OK,
16968N/A POP3C_COMMAND_STATE_ERR,
16968N/A POP3C_COMMAND_STATE_DISCONNECTED
16855N/A};
16855N/A
16855N/Aenum pop3c_client_ssl_mode {
16793N/A POP3C_CLIENT_SSL_MODE_NONE,
16793N/A POP3C_CLIENT_SSL_MODE_IMMEDIATE,
16793N/A POP3C_CLIENT_SSL_MODE_STARTTLS
16793N/A};
16793N/A
16793N/Astruct pop3c_client_settings {
16855N/A const char *host;
16855N/A in_port_t port;
16855N/A
16855N/A const char *master_user;
13796N/A const char *username;
13796N/A const char *password;
12961N/A
13796N/A const char *dns_client_socket_path;
12961N/A const char *temp_path_prefix;
12961N/A
15558N/A enum pop3c_client_ssl_mode ssl_mode;
12961N/A enum pop3c_features parsed_features;
12961N/A const char *ssl_ca_dir, *ssl_ca_file;
12961N/A bool ssl_verify;
12961N/A
16855N/A const char *rawlog_dir;
12961N/A const char *ssl_crypto_device;
12961N/A bool debug;
12961N/A};
12961N/A
12961N/Atypedef void pop3c_login_callback_t(enum pop3c_command_state state,
12961N/A const char *reply, void *context);
12961N/Atypedef void pop3c_cmd_callback_t(enum pop3c_command_state state,
12961N/A const char *reply, void *context);
15558N/A
16793N/Astruct pop3c_client *
16793N/Apop3c_client_init(const struct pop3c_client_settings *set);
16793N/Avoid pop3c_client_deinit(struct pop3c_client **client);
16793N/A
16793N/Avoid pop3c_client_login(struct pop3c_client *client,
16793N/A pop3c_login_callback_t *callback, void *context);
16793N/A
16793N/Abool pop3c_client_is_connected(struct pop3c_client *client);
16793N/Aenum pop3c_capability
16855N/Apop3c_client_get_capabilities(struct pop3c_client *client);
12961N/A
12961N/A/* Returns 0 if received +OK reply, reply contains the text without the +OK.
12961N/A Returns -1 if received -ERR reply or disconnected. */
12961N/Aint pop3c_client_cmd_line(struct pop3c_client *client, const char *cmdline,
12961N/A const char **reply_r);
12961N/A/* Start the command asynchronously. Call the callback when finished. */
12961N/Astruct pop3c_client_cmd *
12961N/Apop3c_client_cmd_line_async(struct pop3c_client *client, const char *cmdline,
12961N/A pop3c_cmd_callback_t *callback, void *context);
12961N/A/* Send a command, don't care if it succeeds or not. */
12961N/Avoid pop3c_client_cmd_line_async_nocb(struct pop3c_client *client,
12961N/A const char *cmdline);
15558N/A/* Returns 0 and stream if succeeded, -1 and error if received -ERR reply or
16855N/A disconnected. */
16793N/Aint pop3c_client_cmd_stream(struct pop3c_client *client, const char *cmdline,
16793N/A struct istream **input_r, const char **error_r);
16793N/A/* Start the command asynchronously. Call the callback when finished. */
16793N/Astruct istream *
16793N/Apop3c_client_cmd_stream_async(struct pop3c_client *client, const char *cmdline,
16793N/A pop3c_cmd_callback_t *callback, void *context);
16793N/A/* Wait for the next async command to finish. It's an error to call this when
16793N/A there are no pending async commands. */
16793N/Avoid pop3c_client_wait_one(struct pop3c_client *client);
16793N/A
16793N/A#endif
16793N/A