]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Allow plugins to hook into syncing.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 26 Apr 2017 12:04:23 +0000 (15:04 +0300)
committerGitLab <gitlab@git.dovecot.net>
Thu, 27 Apr 2017 07:00:37 +0000 (10:00 +0300)
Ideally all of the existing pieces in the syncing code would start using
this at some point, so their code could be moved to a more logical location.

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

index 4131abea13d4a9e845e27d062cdeca45bbeacf41..cfd7e9791b6b695f6b77bc69e53a65820d2d08a2 100644 (file)
@@ -610,6 +610,12 @@ client_default_send_tagline(struct client_command_context *cmd, const char *data
        client->last_output = ioloop_time;
 }
 
+static int
+client_default_sync_notify_more(struct imap_sync_context *ctx ATTR_UNUSED)
+{
+       return 1;
+}
+
 void client_send_command_error(struct client_command_context *cmd,
                               const char *msg)
 {
@@ -1432,4 +1438,5 @@ struct imap_client_vfuncs imap_client_vfuncs = {
        imap_state_import_base,
        client_default_destroy,
        client_default_send_tagline,
+       client_default_sync_notify_more,
 };
index c72304526524ab31e365b7bcffd315b56409a7fb..5aa1bc967a799d7d0671f95727b29af50f800f5e 100644 (file)
@@ -133,6 +133,10 @@ struct imap_client_vfuncs {
 
        void (*send_tagline)(struct client_command_context *cmd,
                             const char *data);
+       /* Run "mailbox syncing". This can send any unsolicited untagged
+          replies. Returns 1 = done, 0 = wait for more space in output buffer,
+          -1 = failed. */
+       int (*sync_notify_more)(struct imap_sync_context *ctx);
 };
 
 struct client {
index 21d4a1ee28f9e91ab1c9f3902f7b405f5d138021..8d1c4d838d7e3b1eab8d5fc0b727a7295dc574f8 100644 (file)
@@ -25,6 +25,9 @@ struct imap_sync_context {
 
        unsigned int messages_count;
 
+       /* Module-specific contexts. */
+       ARRAY(union imap_module_context *) module_contexts;
+
        bool failed:1;
        bool finished:1;
        bool no_newmail:1;
index 83a320f3715883a6393be54b6d2e7b031e846eac..23140e8245a85edd453421aa5a3bfb49ebf50776 100644 (file)
@@ -192,6 +192,7 @@ imap_sync_init(struct client *client, struct mailbox *box,
        ctx->client = client;
        ctx->box = box;
        ctx->imap_flags = imap_flags;
+       i_array_init(&ctx->module_contexts, 5);
 
        /* make sure user can't DoS the system by causing Dovecot to create
           tons of useless namespaces. */
@@ -341,6 +342,9 @@ static int imap_sync_notify_more(struct imap_sync_context *ctx)
           now it contains added/removed messages. */
        if ((ret = imap_sync_send_search_updates(ctx, FALSE)) < 0)
                ctx->failed = TRUE;
+
+       if (ret > 0)
+               ret = ctx->client->v.sync_notify_more(ctx);
        return ret;
 }
 
@@ -362,6 +366,7 @@ int imap_sync_deinit(struct imap_sync_context *ctx,
        }
 
        array_free(&ctx->tmp_keywords);
+       array_free(&ctx->module_contexts);
        i_free(ctx);
        return ret;
 }