client.h revision 17da42c31202b1b3e7e308121ea17d922c24da1b
#ifndef CLIENT_H
#define CLIENT_H
#include "commands.h"
#define CLIENT_COMMAND_QUEUE_MAX_SIZE 4
/* Maximum number of CONTEXT=SEARCH UPDATEs. Clients probably won't need more
than a few, so this is mainly to avoid more or less accidental pointless
resource usage. */
#define CLIENT_MAX_SEARCH_UPDATES 10
struct client;
struct mail_storage;
struct imap_parser;
struct imap_arg;
struct mailbox_keywords {
/* All keyword names. The array itself exists in mail_index.
Keywords are currently only appended, they're never removed. */
/* Number of keywords announced to client via FLAGS/PERMANENTFLAGS.
This relies on keywords not being removed while mailbox is
selected. */
unsigned int announce_count;
};
struct imap_search_update {
char *tag;
struct mail_search_result *result;
bool return_uids;
};
enum client_command_state {
/* Waiting for more input */
/* Waiting to be able to send more output */
/* Wait for other commands to finish execution */
/* Waiting for other commands to finish so we can sync */
/* Command is finished */
};
struct client_command_context {
const char *tag;
const char *name;
enum command_flags cmd_flags;
void *context;
struct imap_parser *parser;
enum client_command_state state;
struct client_sync_context *sync;
unsigned int param_error:1;
};
struct client {
struct mail_namespace *namespaces;
struct mailbox_keywords keywords;
unsigned int select_counter; /* increased when mailbox is changed */
unsigned int sync_counter;
unsigned int bad_counter;
/* one parser is kept here to be used for new commands */
struct imap_parser *free_parser;
/* command_pool is cleared when the command queue gets empty */
/* New commands are always prepended to the queue */
struct client_command_context *command_queue;
unsigned int command_queue_size;
/* SEARCHRES extension: Last saved SEARCH result */
/* SEARCH=CONTEXT extension: Searches that get updated */
struct client_command_context *input_lock;
struct client_command_context *output_lock;
/* syncing marks this TRUE when it sees \Deleted flags. this is by
EXPUNGE for Outlook-workaround. */
unsigned int sync_seen_deletes:1;
unsigned int sync_seen_expunges:1;
unsigned int disconnected:1;
unsigned int destroyed:1;
unsigned int handling_input:1;
unsigned int syncing:1;
unsigned int changing_mailbox:1;
found a new line */
unsigned int modseqs_sent_since_sync:1;
};
if the handle is a socket. */
struct mail_namespace *namespaces);
/* Disconnect client connection */
/* Send a line of data to client. Returns 1 if ok, 0 if buffer is getting full,
-1 if error */
/* Send line of data to client, prefixed with client->tag */
/* Send BAD command error to client. msg can be NULL. */
const char *msg);
/* Read a number of arguments. Returns TRUE if everything was read or
FALSE if either needs more data or error occurred. */
/* Reads a number of string arguments. ... is a list of pointers where to
store the arguments. */
unsigned int count, ...);
have to wait for an existing SEARCH SAVE to finish. */
struct imap_search_update *
unsigned int *idx_r);
void clients_init(void);
void clients_deinit(void);
#endif