# HG changeset patch # User Timo Sirainen # Date 1226776217 -7200 # Node ID 6e9100795d8961b73c59e65077d05d252c8cb75c # Parent abd0ef855a33daa7eef9d16d2424b7a8457dd879 Moved imap-resp-codes to macros. diff -r abd0ef855a33 -r 6e9100795d89 src/imap-login/client-authenticate.c --- a/src/imap-login/client-authenticate.c Sat Nov 15 20:59:54 2008 +0200 +++ b/src/imap-login/client-authenticate.c Sat Nov 15 21:10:17 2008 +0200 @@ -9,6 +9,7 @@ #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" @@ -18,7 +19,7 @@ #include #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) { @@ -180,7 +181,7 @@ 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); @@ -337,7 +338,7 @@ "* 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; } diff -r abd0ef855a33 -r 6e9100795d89 src/imap/client.c --- a/src/imap/client.c Sat Nov 15 20:59:54 2008 +0200 +++ b/src/imap/client.c Sat Nov 15 21:10:17 2008 +0200 @@ -8,8 +8,9 @@ #include "istream.h" #include "ostream.h" #include "var-expand.h" +#include "imap-resp-code.h" +#include "mail-namespace.h" #include "commands.h" -#include "mail-namespace.h" #include #include @@ -409,7 +410,8 @@ } 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."); } diff -r abd0ef855a33 -r 6e9100795d89 src/imap/cmd-copy.c --- a/src/imap/cmd-copy.c Sat Nov 15 20:59:54 2008 +0200 +++ b/src/imap/cmd-copy.c Sat Nov 15 21:10:17 2008 +0200 @@ -3,6 +3,7 @@ #include "common.h" #include "str.h" #include "ostream.h" +#include "imap-resp-code.h" #include "commands.h" #include "imap-search.h" @@ -171,7 +172,8 @@ 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); diff -r abd0ef855a33 -r 6e9100795d89 src/imap/cmd-fetch.c --- a/src/imap/cmd-fetch.c Sat Nov 15 20:59:54 2008 +0200 +++ b/src/imap/cmd-fetch.c Sat Nov 15 21:10:17 2008 +0200 @@ -2,6 +2,7 @@ #include "common.h" #include "ostream.h" +#include "imap-resp-code.h" #include "commands.h" #include "imap-fetch.h" #include "imap-search.h" @@ -132,7 +133,7 @@ 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."; } diff -r abd0ef855a33 -r 6e9100795d89 src/imap/cmd-search.c --- a/src/imap/cmd-search.c Sat Nov 15 20:59:54 2008 +0200 +++ b/src/imap/cmd-search.c Sat Nov 15 21:10:17 2008 +0200 @@ -4,11 +4,12 @@ #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 { @@ -366,6 +367,7 @@ 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) { @@ -459,11 +461,10 @@ 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) diff -r abd0ef855a33 -r 6e9100795d89 src/imap/cmd-status.c --- a/src/imap/cmd-status.c Sat Nov 15 20:59:54 2008 +0200 +++ b/src/imap/cmd-status.c Sat Nov 15 21:10:17 2008 +0200 @@ -1,6 +1,7 @@ /* 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" @@ -45,7 +46,7 @@ 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; diff -r abd0ef855a33 -r 6e9100795d89 src/imap/commands-util.c --- a/src/imap/commands-util.c Sat Nov 15 20:59:54 2008 +0200 +++ b/src/imap/commands-util.c Sat Nov 15 21:10:17 2008 +0200 @@ -5,12 +5,13 @@ #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 @@ -152,29 +153,29 @@ 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 == '[') diff -r abd0ef855a33 -r 6e9100795d89 src/lib-imap/Makefile.am --- a/src/lib-imap/Makefile.am Sat Nov 15 20:59:54 2008 +0200 +++ b/src/lib-imap/Makefile.am Sat Nov 15 21:10:17 2008 +0200 @@ -26,6 +26,7 @@ imap-id.h \ imap-match.h \ imap-parser.h \ + imap-resp-code.h \ imap-quote.h \ imap-seqset.h \ imap-utf7.h \ diff -r abd0ef855a33 -r 6e9100795d89 src/lib-imap/imap-resp-code.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-imap/imap-resp-code.h Sat Nov 15 21:10:17 2008 +0200 @@ -0,0 +1,22 @@ +#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