Mercurial > dovecot > core-2.2
changeset 21984:855908f469d8
imap: Add client_add_capability()
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 24 Apr 2017 18:12:55 +0300 |
parents | 33dbc4cdd0c5 |
children | fcf49c0c6614 |
files | src/imap/imap-client.c src/imap/imap-client.h |
diffstat | 2 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/imap-client.c Mon Apr 24 13:29:13 2017 +0300 +++ b/src/imap/imap-client.c Mon Apr 24 18:12:55 2017 +0300 @@ -514,6 +514,20 @@ client_disconnect(client, msg); } +void client_add_capability(struct client *client, const char *capability) +{ + /* require a single capability at a time (feels cleaner) */ + i_assert(strchr(capability, ' ') == NULL); + + if (client->set->imap_capability[0] != '\0' && + client->set->imap_capability[0] != '+') { + /* explicit capability - don't change it */ + return; + } + str_append_c(client->capability_string, ' '); + str_append(client->capability_string, capability); +} + void client_send_line(struct client *client, const char *data) { (void)client_send_line_next(client, data);
--- a/src/imap/imap-client.h Mon Apr 24 13:29:13 2017 +0300 +++ b/src/imap/imap-client.h Mon Apr 24 18:12:55 2017 +0300 @@ -254,6 +254,10 @@ void client_disconnect(struct client *client, const char *reason); void client_disconnect_with_error(struct client *client, const char *msg); +/* Add the given capability to the CAPABILITY reply. If imap_capability setting + has an explicit capability, nothing is changed. */ +void client_add_capability(struct client *client, const char *capability); + /* Send a line of data to client. */ void client_send_line(struct client *client, const char *data); /* Send a line of data to client. Returns 1 if ok, 0 if buffer is getting full,