imap-client.h revision 809329fe7be1281bec99dd5d06fd7b8b52752daf
02b32cf39a098edf60981fc228e4b034f11f3b90Timo Sirainen/* Maximum number of CONTEXT=SEARCH UPDATEs. Clients probably won't need more
4eb418849d5c6bf77b2721e4e6aef2e97deaa197Timo Sirainen than a few, so this is mainly to avoid more or less accidental pointless
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen resource usage. */
1ea0aa8e14e843f2776746776a429b0a1aae299dTimo Sirainen /* All keyword names. The array itself exists in mail_index.
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen Keywords are currently only appended, they're never removed. */
68332e3a49dea15013aa8f4daa16b5e07eb3d543Timo Sirainen /* Number of keywords announced to client via FLAGS/PERMANENTFLAGS.
65f9a90ef5ed4c86fb9e44f22e472509126ae9f5Timo Sirainen This relies on keywords not being removed while mailbox is
6e77746e501c2b45850b1c530836058ed75e09eeTimo Sirainen /* Waiting for more input */
6e77746e501c2b45850b1c530836058ed75e09eeTimo Sirainen /* Waiting to be able to send more output */
6e77746e501c2b45850b1c530836058ed75e09eeTimo Sirainen /* Wait for other commands to finish execution */
6e77746e501c2b45850b1c530836058ed75e09eeTimo Sirainen /* Waiting for other commands to finish so we can sync */
6e77746e501c2b45850b1c530836058ed75e09eeTimo Sirainen /* Command is finished */
8c8f7ac580b661aee3d8b8dd37df4a9b41c77000Timo Sirainen unsigned int id;
8c8f7ac580b661aee3d8b8dd37df4a9b41c77000Timo Sirainenextern struct imap_module_register imap_module_register;
48f78a48f2e1cf299026544444666471ae16ad97Timo Sirainen /* IMAP command tag */
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen const char *tag;
48f78a48f2e1cf299026544444666471ae16ad97Timo Sirainen /* Name of this command */
0dc7891233a973829f00371b27810f849b987c66Timo Sirainen /* Parameters for this command. These are generated from parsed IMAP
0dc7891233a973829f00371b27810f849b987c66Timo Sirainen arguments, so they may not be exactly the same as how client sent
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen /* Module-specific contexts. */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen ARRAY_DEFINE(module_contexts, union imap_module_context *);
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen unsigned int cancel:1; /* command is wanted to be cancelled */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen unsigned int search_save_result:1; /* search result is being updated */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen unsigned int temp_executed:1; /* temporary execution state tracking */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen struct mail_storage_service_user *service_user;
d9a7e950a9cd21f2b4a90ec7759fca9e8fcc7995Timo Sirainen unsigned int select_counter; /* increased when mailbox is changed */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen uint32_t messages_count, recent_count, uidvalidity;
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen /* one parser is kept here to be used for new commands */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen /* command_pool is cleared when the command queue gets empty */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen /* New commands are always prepended to the queue */
14cac26dcb71108abfdc95ea524e74be1f95774cPhil Carmody /* SEARCHRES extension: Last saved SEARCH result */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen /* SEARCH=CONTEXT extension: Searches that get updated */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen ARRAY_DEFINE(search_updates, struct imap_search_update);
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen /* client input/output is locked by this command */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen /* command changing the mailbox */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen struct client_command_context *mailbox_change_lock;
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen /* Module-specific contexts. */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen ARRAY_DEFINE(module_contexts, union imap_module_context *);
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen /* syncing marks this TRUE when it sees \Deleted flags. this is by
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen EXPUNGE for Outlook-workaround. */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen unsigned int input_skip_line:1; /* skip all the data until we've
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainen found a new line */
b5ff746939712c6a9bef71405fa786d5471cf177Timo Sirainenextern unsigned int imap_client_count;
4eb418849d5c6bf77b2721e4e6aef2e97deaa197Timo Sirainen/* Create new client with specified input/output handles. socket specifies
4eb418849d5c6bf77b2721e4e6aef2e97deaa197Timo Sirainen if the handle is a socket. */
4eb418849d5c6bf77b2721e4e6aef2e97deaa197Timo Sirainenstruct client *client_create(int fd_in, int fd_out, struct mail_user *user,
4eb418849d5c6bf77b2721e4e6aef2e97deaa197Timo Sirainen struct mail_storage_service_user *service_user,
4eb418849d5c6bf77b2721e4e6aef2e97deaa197Timo Sirainenvoid client_destroy(struct client *client, const char *reason);
a8b37b688ceaa3ed3d40b3ccbdba5bb75cfb64b0Timo Sirainen/* Disconnect client connection */
4eb418849d5c6bf77b2721e4e6aef2e97deaa197Timo Sirainenvoid client_disconnect(struct client *client, const char *reason);
4eb418849d5c6bf77b2721e4e6aef2e97deaa197Timo Sirainenvoid client_disconnect_with_error(struct client *client, const char *msg);
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen/* Send a line of data to client. Returns 1 if ok, 0 if buffer is getting full,
0dc7891233a973829f00371b27810f849b987c66Timo Sirainen -1 if error */
02b32cf39a098edf60981fc228e4b034f11f3b90Timo Sirainenint client_send_line(struct client *client, const char *data);
0dc7891233a973829f00371b27810f849b987c66Timo Sirainen/* Send line of data to client, prefixed with client->tag. You need to prefix
4eb418849d5c6bf77b2721e4e6aef2e97deaa197Timo Sirainen the data with "OK ", "NO " or "BAD ". */
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainenvoid client_send_tagline(struct client_command_context *cmd, const char *data);
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen/* Send a BAD command reply to client via client_send_tagline(). If there have
02b32cf39a098edf60981fc228e4b034f11f3b90Timo Sirainen been too many command errors, the client is disconnected. msg may be NULL,
4a7e04d325db0c03f575f98f045246fceb0de279Timo Sirainen in which case the error is looked up from imap_parser. */
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainenvoid client_send_command_error(struct client_command_context *cmd,
4a7e04d325db0c03f575f98f045246fceb0de279Timo Sirainen const char *msg);
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen/* Read a number of arguments. Returns TRUE if everything was read or
0dc7891233a973829f00371b27810f849b987c66Timo Sirainen FALSE if either needs more data or error occurred. */
0dc7891233a973829f00371b27810f849b987c66Timo Sirainenbool client_read_args(struct client_command_context *cmd, unsigned int count,
0dc7891233a973829f00371b27810f849b987c66Timo Sirainen unsigned int flags, const struct imap_arg **args_r);
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen/* Reads a number of string arguments. ... is a list of pointers where to
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen store the arguments. */
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainenbool client_read_string_args(struct client_command_context *cmd,
0dc7891233a973829f00371b27810f849b987c66Timo Sirainen unsigned int count, ...);
0dc7891233a973829f00371b27810f849b987c66Timo Sirainen/* SEARCHRES extension: Call if $ is being used/updated, returns TRUE if we
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen have to wait for an existing SEARCH SAVE to finish. */
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainenbool client_handle_search_save_ambiguity(struct client_command_context *cmd);
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainenvoid client_enable(struct client *client, enum mailbox_feature features);
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainenclient_search_update_lookup(struct client *client, const char *tag,
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen unsigned int *idx_r);
23bdbb7b1831785c6ba6df190f6369da882d2b9dTimo Sirainenvoid client_search_updates_free(struct client *client);
4a7e04d325db0c03f575f98f045246fceb0de279Timo Sirainenvoid client_command_cancel(struct client_command_context **cmd);
f83fd83f9c6708d198748e714aa947cad9362c02Timo Sirainenvoid client_command_free(struct client_command_context **cmd);
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainenbool client_handle_unfinished_cmd(struct client_command_context *cmd);
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainenvoid client_continue_pending_input(struct client *client);