]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mail_storage_callbacks - Add notify_bad()
authorMarco Bettini <marco.bettini@open-xchange.com>
Mon, 7 Apr 2025 14:28:41 +0000 (14:28 +0000)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 16 Apr 2025 07:55:24 +0000 (07:55 +0000)
src/imap/imap-storage-callbacks.c
src/lib-storage/mail-storage.h

index ad741fb83cd47c9193a9ad6bff5c81502baa37f2..fd78eccd5a3b7a90eca19751b34cfc2c466c3381 100644 (file)
@@ -8,8 +8,9 @@
 #include "ostream.h"
 #include "imap-storage-callbacks.h"
 
-static void notify_ok(struct mailbox *mailbox ATTR_UNUSED,
-                     const char *text, void *context)
+static void notify_status(struct mailbox *mailbox ATTR_UNUSED,
+                         const char *status,
+                         const char *text, void *context)
 {
        struct client *client = context;
 
@@ -17,29 +18,28 @@ static void notify_ok(struct mailbox *mailbox ATTR_UNUSED,
                return;
 
        T_BEGIN {
-               const char *str;
-
-               str = t_strconcat("* OK ", text, "\r\n", NULL);
+               const char *str = t_strdup_printf("* %s %s\r\n", status, text);
                o_stream_nsend_str(client->output, str);
                (void)o_stream_flush(client->output);
        } T_END;
 }
 
-static void notify_no(struct mailbox *mailbox ATTR_UNUSED,
+static void notify_ok(struct mailbox *mailbox ATTR_UNUSED,
                      const char *text, void *context)
 {
-       struct client *client = context;
-
-       if (o_stream_get_buffer_used_size(client->output) != 0)
-               return;
+       notify_status(mailbox, "OK", text, context);
+}
 
-       T_BEGIN {
-               const char *str;
+static void notify_no(struct mailbox *mailbox ATTR_UNUSED,
+                     const char *text, void *context)
+{
+       notify_status(mailbox, "NO", text, context);
+}
 
-               str = t_strconcat("* NO ", text, "\r\n", NULL);
-               o_stream_nsend_str(client->output, str);
-               (void)o_stream_flush(client->output);
-       } T_END;
+static void notify_bad(struct mailbox *mailbox ATTR_UNUSED,
+                     const char *text, void *context)
+{
+       notify_status(mailbox, "BAD", text, context);
 }
 
 static const char *find_cmd_tag(struct event *event)
@@ -142,5 +142,6 @@ static void notify_progress(struct mailbox *mailbox ATTR_UNUSED,
 struct mail_storage_callbacks imap_storage_callbacks = {
        .notify_ok = notify_ok,
        .notify_no = notify_no,
+       .notify_bad = notify_bad,
        .notify_progress = notify_progress
 };
index 1501c39199178d318fa7e9917f1e7c0aa472b06f..e99694eb4e7892c08d04ba24498386ebdbbd94a9 100644 (file)
@@ -466,6 +466,9 @@ struct mail_storage_callbacks {
        /* "* NO <text>" */
        void (*notify_no)(struct mailbox *mailbox, const char *text,
                          void *context);
+       /* "* BAD <text>" */
+       void (*notify_bad)(struct mailbox *mailbox, const char *text,
+                          void *context);
        /* "* OK [INPROGRESS (...)] <text>" */
        void (*notify_progress)(struct mailbox *mailbox,
                                const struct mail_storage_progress_details *dtl,