]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Add client_add_capability()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 24 Apr 2017 15:12:55 +0000 (18:12 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 24 Apr 2017 15:55:14 +0000 (18:55 +0300)
src/imap/imap-client.c
src/imap/imap-client.h

index 91dbddd3d4e009249c9f8ac46b712694853e52d1..26fc621041b4809a54b41e4e6ff856b597873e8f 100644 (file)
@@ -509,6 +509,20 @@ void client_disconnect_with_error(struct client *client, const char *msg)
        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);
index 8177c4db1c741f811f446681e643969eb1f09d2b..c72304526524ab31e365b7bcffd315b56409a7fb 100644 (file)
@@ -254,6 +254,10 @@ void client_destroy(struct client *client, const char *reason) ATTR_NULL(2);
 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,