]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
CONTEXT=SEARCH: ADDTO and REMOVEFROM can be sent in same ESEARCH reply.
authorTimo Sirainen <tss@iki.fi>
Thu, 5 Jun 2008 02:16:31 +0000 (05:16 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 5 Jun 2008 02:16:31 +0000 (05:16 +0300)
--HG--
branch : HEAD

src/imap/imap-sync.c

index 8f387ffb4f73473862876f553e3f023d250c1ca8..1c664534cb4e57bfccebdac8a269f11b5456f427 100644 (file)
@@ -73,7 +73,6 @@ imap_sync_send_search_update(struct imap_sync_context *ctx,
                             const struct imap_search_update *update)
 {
        string_t *cmd;
-       unsigned int pos;
 
        mailbox_search_result_sync(update->result, &ctx->search_removes,
                                   &ctx->search_adds);
@@ -84,29 +83,27 @@ imap_sync_send_search_update(struct imap_sync_context *ctx,
        cmd = t_str_new(256);
        str_append(cmd, "* ESEARCH (TAG ");
        imap_quote_append_string(cmd, update->tag, FALSE);
-       str_append(cmd, ") ");
+       str_append_c(cmd, ')');
        if (update->return_uids)
-               str_append(cmd, "UID ");
+               str_append(cmd, " UID");
        else {
                /* convert to sequences */
                uids_to_seqs(ctx->client->mailbox, &ctx->search_removes);
                uids_to_seqs(ctx->client->mailbox, &ctx->search_adds);
        }
-       pos = str_len(cmd);
 
        if (array_count(&ctx->search_removes) != 0) {
-               str_printfa(cmd, "REMOVEFROM (0 ");
+               str_printfa(cmd, " REMOVEFROM (0 ");
                imap_write_seq_range(cmd, &ctx->search_removes);
-               str_append(cmd, ")\r\n");
-               o_stream_send(ctx->client->output, str_data(cmd), str_len(cmd));
-               str_truncate(cmd, pos);
+               str_append_c(cmd, ')');
        }
        if (array_count(&ctx->search_adds) != 0) {
-               str_printfa(cmd, "ADDTO (0 ");
+               str_printfa(cmd, " ADDTO (0 ");
                imap_write_seq_range(cmd, &ctx->search_adds);
-               str_append(cmd, ")\r\n");
-               o_stream_send(ctx->client->output, str_data(cmd), str_len(cmd));
+               str_append_c(cmd, ')');
        }
+       str_append(cmd, ")\r\n");
+       o_stream_send(ctx->client->output, str_data(cmd), str_len(cmd));
 }
 
 static void imap_sync_send_search_updates(struct imap_sync_context *ctx)