#include "safe-memset.h"
#include "str.h"
#include "str-sanitize.h"
+#include "imap-resp-code.h"
#include "imap-parser.h"
#include "auth-client.h"
#include "client.h"
#include <stdlib.h>
#define IMAP_SERVICE_NAME "imap"
-#define IMAP_AUTH_FAILED_MSG "[AUTHENTICATIONFAILED] "AUTH_FAILED_MSG
+#define IMAP_AUTH_FAILED_MSG "["IMAP_RESP_CODE_AUTHFAILED"] "AUTH_FAILED_MSG
const char *client_authenticate_get_capabilities(bool secured)
{
if (reason != NULL)
str_printfa(reply, "NO %s", reason);
else if (temp || proxy_self) {
- str_append(reply, "NO [UNAVAILABLE] "
+ str_append(reply, "NO ["IMAP_RESP_CODE_UNAVAILABLE"] "
AUTH_TEMP_FAILED_MSG);
} else {
str_append(reply, "NO "IMAP_AUTH_FAILED_MSG);
"* BAD [ALERT] Plaintext authentication is disabled, "
"but your client sent password in plaintext anyway. "
"If anyone was listening, the password was exposed.");
- client_send_tagline(client, "NO [CLIENTBUG] "
+ client_send_tagline(client, "NO ["IMAP_RESP_CODE_CLIENTBUG"] "
AUTH_PLAINTEXT_DISABLED_MSG);
return 1;
}
#include "istream.h"
#include "ostream.h"
#include "var-expand.h"
-#include "commands.h"
+#include "imap-resp-code.h"
#include "mail-namespace.h"
+#include "commands.h"
#include <stdlib.h>
#include <unistd.h>
}
if (broken_client) {
- client_send_line(cmd->client, "* BAD [CLIENTBUG] "
+ client_send_line(cmd->client,
+ "* BAD ["IMAP_RESP_CODE_CLIENTBUG"] "
"Command pipelining results in ambiguity.");
}
#include "common.h"
#include "str.h"
#include "ostream.h"
+#include "imap-resp-code.h"
#include "commands.h"
#include "imap-search.h"
return cmd_sync(cmd, sync_flags, imap_flags, msg);
else if (ret == 0) {
/* some messages were expunged, sync them */
- return cmd_sync(cmd, 0, 0, "NO [EXPUNGEISSUED] "
+ return cmd_sync(cmd, 0, 0,
+ "NO ["IMAP_RESP_CODE_EXPUNGEISSUED"] "
"Some of the requested messages no longer exist.");
} else {
client_send_storage_error(cmd, storage);
#include "common.h"
#include "ostream.h"
+#include "imap-resp-code.h"
#include "commands.h"
#include "imap-fetch.h"
#include "imap-search.h"
static const char *ok_message = "OK Fetch completed.";
if (ctx->partial_fetch) {
- ok_message = "OK [EXPUNGEISSUED] "
+ ok_message = "OK ["IMAP_RESP_CODE_EXPUNGEISSUED"] "
"Some messages were already expunged.";
}
#include "ostream.h"
#include "str.h"
#include "seq-range-array.h"
-#include "commands.h"
-#include "mail-search-build.h"
+#include "imap-resp-code.h"
#include "imap-quote.h"
#include "imap-seqset.h"
#include "imap-util.h"
+#include "mail-search-build.h"
+#include "commands.h"
#include "imap-search.h"
enum search_return_options {
const struct seq_range *range;
unsigned int count;
uint32_t id, id_min, id_max;
+ const char *ok_reply;
bool tryagain, minmax, lost_data;
if (cmd->cancel) {
sync_flags = MAILBOX_SYNC_FLAG_FAST;
if (!cmd->uid || ctx->have_seqsets)
sync_flags |= MAILBOX_SYNC_FLAG_NO_EXPUNGES;
- return cmd_sync(cmd, sync_flags, 0,
- t_strdup_printf("OK %sSearch completed (%d.%03d secs).",
- lost_data ? "[EXPUNGEISSUED] " : "",
- (int)end_time.tv_sec,
- (int)(end_time.tv_usec/1000)));
+ ok_reply = t_strdup_printf("OK %sSearch completed (%d.%03d secs).",
+ lost_data ? "["IMAP_RESP_CODE_EXPUNGEISSUED"] " : "",
+ (int)end_time.tv_sec, (int)(end_time.tv_usec/1000));
+ return cmd_sync(cmd, sync_flags, 0, ok_reply);
}
static void cmd_search_more_callback(struct client_command_context *cmd)
/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
+#include "imap-resp-code.h"
#include "commands.h"
#include "imap-sync.h"
#include "imap-status.h"
if (!selected_mailbox)
client_send_tagline(cmd, "OK Status completed.");
else {
- client_send_tagline(cmd, "OK [CLIENTBUG] "
+ client_send_tagline(cmd, "OK ["IMAP_RESP_CODE_CLIENTBUG"] "
"Status on selected mailbox completed.");
}
return TRUE;
#include "buffer.h"
#include "str.h"
#include "str-sanitize.h"
-#include "mail-storage.h"
-#include "commands-util.h"
+#include "imap-resp-code.h"
#include "imap-parser.h"
#include "imap-sync.h"
#include "imap-util.h"
+#include "mail-storage.h"
#include "mail-namespace.h"
+#include "commands-util.h"
/* Maximum length for mailbox name, including it's path. This isn't fully
exact since the user can create folder hierarchy with small names, then
case MAIL_ERROR_NONE:
break;
case MAIL_ERROR_TEMP:
- resp_code = "SERVERBUG";
+ resp_code = IMAP_RESP_CODE_SERVERBUG;
break;
case MAIL_ERROR_NOTPOSSIBLE:
case MAIL_ERROR_PARAMS:
- resp_code = "CANNOT";
+ resp_code = IMAP_RESP_CODE_CANNOT;
break;
case MAIL_ERROR_PERM:
- resp_code = "ACL";
+ resp_code = IMAP_RESP_CODE_ACL;
break;
case MAIL_ERROR_NOSPACE:
- resp_code = "OVERQUOTA";
+ resp_code = IMAP_RESP_CODE_OVERQUOTA;
break;
case MAIL_ERROR_NOTFOUND:
- resp_code = "NONEXISTENT";
+ resp_code = IMAP_RESP_CODE_NONEXISTENT;
break;
case MAIL_ERROR_EXISTS:
- resp_code = "ALREADYEXISTS";
+ resp_code = IMAP_RESP_CODE_ALREADYEXISTS;
break;
case MAIL_ERROR_EXPUNGED:
- resp_code = "EXPUNGEISSUED";
+ resp_code = IMAP_RESP_CODE_EXPUNGEISSUED;
break;
case MAIL_ERROR_INUSE:
- resp_code = "INUSE";
+ resp_code = IMAP_RESP_CODE_INUSE;
break;
}
if (resp_code == NULL || *error_string == '[')
imap-id.h \
imap-match.h \
imap-parser.h \
+ imap-resp-code.h \
imap-quote.h \
imap-seqset.h \
imap-utf7.h \
--- /dev/null
+#ifndef IMAP_RESP_CODE_H
+#define IMAP_RESP_CODE_H
+
+/* IMAP response codes (from draft-gulbrandsen-imap-response-codes-04) */
+#define IMAP_RESP_CODE_UNAVAILABLE "UNAVAILABLE"
+#define IMAP_RESP_CODE_AUTHFAILED "AUTHENTICATIONFAILED"
+#define IMAP_RESP_CODE_AUTHZFAILED "AUTHORIZATIONFAILED"
+#define IMAP_RESP_CODE_EXPIRED "EXPIRED"
+#define IMAP_RESP_CODE_CONTACTADMIN "CONTACTADMIN"
+#define IMAP_RESP_CODE_ACL "ACL"
+#define IMAP_RESP_CODE_INUSE "INUSE"
+#define IMAP_RESP_CODE_EXPUNGEISSUED "EXPUNGEISSUED"
+#define IMAP_RESP_CODE_CORRUPTION "CORRUPTION"
+#define IMAP_RESP_CODE_SERVERBUG "SERVERBUG"
+#define IMAP_RESP_CODE_CLIENTBUG "CLIENTBUG"
+#define IMAP_RESP_CODE_CANNOT "CANNOT"
+#define IMAP_RESP_CODE_LIMIT "LIMIT"
+#define IMAP_RESP_CODE_OVERQUOTA "OVERQUOTA"
+#define IMAP_RESP_CODE_ALREADYEXISTS "ALREADYEXISTS"
+#define IMAP_RESP_CODE_NONEXISTENT "NONEXISTENT"
+
+#endif