From: Stephan Bosch Date: Fri, 4 Jan 2019 12:57:36 +0000 (+0100) Subject: imap: client: Add init() client vfunc. X-Git-Tag: 2.3.7~137 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=09ea2a786ec4bfc0596dde7b55c0698893a8af86;p=thirdparty%2Fdovecot%2Fcore.git imap: client: Add init() client vfunc. 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. --- diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index e6a4ca3439..1ac2e66ce7 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -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, diff --git a/src/imap/imap-client.h b/src/imap/imap-client.h index 1f234f9943..c4e4b04309 100644 --- a/src/imap/imap-client.h +++ b/src/imap/imap-client.h @@ -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);