]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: client: Add init() client vfunc.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Fri, 4 Jan 2019 12:57:36 +0000 (13:57 +0100)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 25 Jun 2019 13:13:00 +0000 (16:13 +0300)
This is called when client creation is finished completely, including namespace
initialization. The normal create hook is executed before namespace
initialization, which is a problem when a plugin needs to access the mail
storage immediately.

src/imap/imap-client.c
src/imap/imap-client.h

index e6a4ca3439ebe4f8882d7b4ac615db35be0c52c4..1ac2e66ce7686a086f2619a6d35f7ff60fa43308 100644 (file)
@@ -231,9 +231,16 @@ int client_create_finish(struct client *client, const char **error_r)
                return -1;
        mail_namespaces_set_storage_callbacks(client->user->namespaces,
                                              &mail_storage_callbacks, client);
+
+       client->v.init(client);
        return 0;
 }
 
+static void client_default_init(struct client *client ATTR_UNUSED)
+{
+       /* nothing */
+}
+
 void client_command_cancel(struct client_command_context **_cmd)
 {
        struct client_command_context *cmd = *_cmd;
@@ -1595,6 +1602,7 @@ void clients_destroy_all(void)
 }
 
 struct imap_client_vfuncs imap_client_vfuncs = {
+       .init = client_default_init,
        .destroy = client_default_destroy,
 
        .send_tagline = client_default_send_tagline,
index 1f234f994399532fb9ca17892d09df0e125049aa..c4e4b04309301cd8105438c792a1c92c7bbac2e9 100644 (file)
@@ -119,6 +119,11 @@ struct client_command_context {
 };
 
 struct imap_client_vfuncs {
+       /* Perform client initialization. This is called when client creation is
+          finished completely. Particulary, at this point the namespaces are
+          fully initialized, which is not the case for the client create hook.
+        */
+       void (*init)(struct client *client);
        /* Destroy the client.*/
        void (*destroy)(struct client *client, const char *reason);