bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen
08d6658a4e2ec8104cd1307f6baa75fdb07a24f8Mark Washenberger#include "imap-common.h"
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen#include "ostream.h"
fb8e400512210d49339775747a520411987d4353Timo Sirainen#include "mail-storage.h"
08d6658a4e2ec8104cd1307f6baa75fdb07a24f8Mark Washenberger#include "imap-commands-util.h"
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen
43d32cbe60fdaef2699d99f1ca259053e9350411Timo Sirainenstatic void notify_ok(struct mailbox *mailbox ATTR_UNUSED,
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen const char *text, void *context)
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen{
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen struct client *client = context;
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen if (o_stream_get_buffer_used_size(client->output) != 0)
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen return;
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen
19e8adccba16ff419f5675b1575358c2956dce83Timo Sirainen T_BEGIN {
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen const char *str;
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen str = t_strconcat("* OK ", text, "\r\n", NULL);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen o_stream_nsend_str(client->output, str);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen (void)o_stream_flush(client->output);
19e8adccba16ff419f5675b1575358c2956dce83Timo Sirainen } T_END;
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen}
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen
43d32cbe60fdaef2699d99f1ca259053e9350411Timo Sirainenstatic void notify_no(struct mailbox *mailbox ATTR_UNUSED,
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen const char *text, void *context)
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen{
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen struct client *client = context;
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen if (o_stream_get_buffer_used_size(client->output) != 0)
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen return;
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen
19e8adccba16ff419f5675b1575358c2956dce83Timo Sirainen T_BEGIN {
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen const char *str;
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen str = t_strconcat("* NO ", text, "\r\n", NULL);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen o_stream_nsend_str(client->output, str);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen (void)o_stream_flush(client->output);
19e8adccba16ff419f5675b1575358c2956dce83Timo Sirainen } T_END;
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen}
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainenstruct mail_storage_callbacks mail_storage_callbacks = {
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen notify_ok,
d756ebcfa96bd7cff02097c8f26df9df368b81b1Timo Sirainen notify_no
c2bb1764c359ce85a7f7f789ead11dd613ff9769Timo Sirainen};