From: Marco Bettini Date: Mon, 7 Apr 2025 14:28:41 +0000 (+0000) Subject: lib-storage: mail_storage_callbacks - Add notify_bad() X-Git-Tag: 2.4.2~842 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=358f5bbcfe63941656b9c0058a1dc13dd248fdba;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: mail_storage_callbacks - Add notify_bad() --- diff --git a/src/imap/imap-storage-callbacks.c b/src/imap/imap-storage-callbacks.c index ad741fb83c..fd78eccd5a 100644 --- a/src/imap/imap-storage-callbacks.c +++ b/src/imap/imap-storage-callbacks.c @@ -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 }; diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index 1501c39199..e99694eb4e 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -466,6 +466,9 @@ struct mail_storage_callbacks { /* "* NO " */ void (*notify_no)(struct mailbox *mailbox, const char *text, void *context); + /* "* BAD " */ + void (*notify_bad)(struct mailbox *mailbox, const char *text, + void *context); /* "* OK [INPROGRESS (...)] " */ void (*notify_progress)(struct mailbox *mailbox, const struct mail_storage_progress_details *dtl,