]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
RFC draft has changed from SNIPPET to PREVIEW
authorMichael M Slusarz <michael.slusarz@open-xchange.com>
Wed, 31 Oct 2018 00:28:04 +0000 (18:28 -0600)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 2 Apr 2019 15:00:23 +0000 (15:00 +0000)
The older SNIPPET command will remain for now - it is mostly the same
as the new PREVIEW code, so it's essentially an alias (the only
difference between the two versions is the SNIPPET/PREVIEW identifier
text).

configure.ac
src/imap/imap-fetch-body.c
src/imap/imap-fetch.c
src/imap/imap-fetch.h

index 2092bb69599b7aed2cf22d9a71af796a5166f9ae..4bb3aadaa4b9128ba0ca11ebaeb9c9c06c93d791 100644 (file)
@@ -782,7 +782,7 @@ dnl **
 dnl IDLE doesn't really belong to banner. It's there just to make Blackberries
 dnl happy, because otherwise BIS server disables push email.
 capability_banner="IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE"
-capability="$capability_banner SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY"
+capability="$capability_banner SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY"
 AC_DEFINE_UNQUOTED(CAPABILITY_STRING, "$capability", [IMAP capabilities])
 AC_DEFINE_UNQUOTED(CAPABILITY_BANNER_STRING, "$capability_banner", [IMAP capabilities advertised in banner])
 
index e9b40e68ef426d2b98f168dce8dccf09e3c31e02..d1fd1a37432b53a6cf85557a807c385989dd1279 100644 (file)
@@ -596,13 +596,15 @@ fetch_snippet(struct imap_fetch_context *ctx, struct mail *mail,
        const bool lazy = context != NULL;
        enum mail_lookup_abort temp_lookup_abort = lazy ? MAIL_LOOKUP_ABORT_NOT_IN_CACHE : mail->lookup_abort;
        enum mail_lookup_abort orig_lookup_abort = mail->lookup_abort;
-       const char *snippet;
+       const char *resp, *snippet;
        int ret;
 
        mail->lookup_abort = temp_lookup_abort;
        ret = mail_get_special(mail, MAIL_FETCH_BODY_SNIPPET, &snippet);
        mail->lookup_abort = orig_lookup_abort;
 
+       resp = ctx->preview_command ? "PREVIEW" : "SNIPPET";
+
        if (ret == 0) {
                /* got it => nothing to do */
                snippet++; /* skip over snippet version byte */
@@ -611,7 +613,8 @@ fetch_snippet(struct imap_fetch_context *ctx, struct mail *mail,
                return -1;
        } else if (lazy) {
                /* not in cache && lazy => give up */
-               str_append(ctx->state.cur_str, "SNIPPET (FUZZY NIL)");
+               str_append(ctx->state.cur_str, resp);
+               str_append(ctx->state.cur_str, " (FUZZY NIL)");
                return 1;
        } else {
                /*
@@ -623,17 +626,25 @@ fetch_snippet(struct imap_fetch_context *ctx, struct mail *mail,
                 * sufficiently convoluted this else branch serves to
                 * document it.
                 */
-               str_append(ctx->state.cur_str, "SNIPPET (FUZZY NIL)");
+               str_append(ctx->state.cur_str, resp);
+               str_append(ctx->state.cur_str, " (FUZZY NIL)");
                return 1;
        }
 
-       str_append(ctx->state.cur_str, "SNIPPET (FUZZY ");
+       str_append(ctx->state.cur_str, resp);
+       str_append(ctx->state.cur_str, " (FUZZY ");
        imap_append_string(ctx->state.cur_str, snippet);
        str_append(ctx->state.cur_str, ") ");
 
        return 1;
 }
 
+bool imap_fetch_preview_init(struct imap_fetch_init_context *ctx)
+{
+       ctx->fetch_ctx->preview_command = TRUE;
+       return imap_fetch_snippet_init(ctx);
+}
+
 bool imap_fetch_snippet_init(struct imap_fetch_init_context *ctx)
 {
        const struct imap_arg *list_args;
@@ -649,7 +660,7 @@ bool imap_fetch_snippet_init(struct imap_fetch_init_context *ctx)
                        const char *str;
 
                        if (!imap_arg_get_atom(&list_args[i], &str)) {
-                               ctx->error = "Invalid SNIPPET algorithm/modifier";
+                               ctx->error = "Invalid PREVIEW algorithm/modifier";
                                return FALSE;
                        }
 
@@ -660,7 +671,7 @@ bool imap_fetch_snippet_init(struct imap_fetch_init_context *ctx)
                                /* nothing to do */
                        } else {
                                ctx->error = t_strdup_printf("'%s' is not a "
-                                                            "supported SNIPPET algorithm/modifier",
+                                                            "supported PREVIEW algorithm/modifier",
                                                             str);
                                return FALSE;
                        }
index 1e45770d1ab86ab27baec93c1092611248299c2d..e9b3b9f84ae323da64010917f693f6665242190f 100644 (file)
@@ -989,6 +989,7 @@ imap_fetch_default_handlers[] = {
        { "FLAGS", imap_fetch_flags_init },
        { "INTERNALDATE", fetch_internaldate_init },
        { "MODSEQ", imap_fetch_modseq_init },
+       { "PREVIEW", imap_fetch_preview_init },
        { "RFC822", imap_fetch_rfc822_init },
        { "SNIPPET", imap_fetch_snippet_init },
        { "UID", imap_fetch_uid_init },
index 1ed49f8bffdf0712f6484b6d19d535d8e535a076..7f394fd12911ccf7a5ce8951460093e1862f5d20 100644 (file)
@@ -100,6 +100,7 @@ struct imap_fetch_context {
        bool flags_have_handler:1;
        bool flags_update_seen:1;
        bool flags_show_only_seen_changes:1;
+       bool preview_command:1;
 };
 
 void imap_fetch_handlers_register(const struct imap_fetch_handler *handlers,
@@ -155,6 +156,7 @@ bool imap_fetch_uid_init(struct imap_fetch_init_context *ctx);
 bool imap_fetch_body_section_init(struct imap_fetch_init_context *ctx);
 bool imap_fetch_rfc822_init(struct imap_fetch_init_context *ctx);
 bool imap_fetch_binary_init(struct imap_fetch_init_context *ctx);
+bool imap_fetch_preview_init(struct imap_fetch_init_context *ctx);
 bool imap_fetch_snippet_init(struct imap_fetch_init_context *ctx);
 
 void imap_fetch_handlers_init(void);