]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Moved imap-resp-codes to macros.
authorTimo Sirainen <tss@iki.fi>
Sat, 15 Nov 2008 19:10:17 +0000 (21:10 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 15 Nov 2008 19:10:17 +0000 (21:10 +0200)
--HG--
branch : HEAD

src/imap-login/client-authenticate.c
src/imap/client.c
src/imap/cmd-copy.c
src/imap/cmd-fetch.c
src/imap/cmd-search.c
src/imap/cmd-status.c
src/imap/commands-util.c
src/lib-imap/Makefile.am
src/lib-imap/imap-resp-code.h [new file with mode: 0644]

index 3348942adfdfa54a710b63da9b871aea4f6617ff..f1a2c379c84c1e1abb0804d992d8709538516d8d 100644 (file)
@@ -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 <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)
 {
@@ -180,7 +181,7 @@ static bool client_handle_args(struct imap_client *client,
                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 @@ int cmd_login(struct imap_client *client, const struct imap_arg *args)
                        "* 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;
        }
index e2faa1719e0d8e2a80039e73e8e970a35972bb1e..8a7c141f03b4e11082b5bf86b930276b4f0dfc6e 100644 (file)
@@ -8,8 +8,9 @@
 #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>
@@ -409,7 +410,8 @@ static bool client_command_check_ambiguity(struct client_command_context *cmd)
        }
 
        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.");
        }
 
index 7b0148b7aaf61f1dd294be6846f01fad6cf16525..75ab657683586c50d9258885b9f1ee09aa819154 100644 (file)
@@ -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 @@ bool cmd_copy(struct client_command_context *cmd)
                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);
index 44f4a783184eca6f238ee803d75c58cdc020abf3..eeb02f870a16369e5c200308b1b80f5d2e7fe147 100644 (file)
@@ -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 bool cmd_fetch_finish(struct imap_fetch_context *ctx)
        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.";
        }
 
index e696f1926944f71c6d458924309e717ab8041a33..e77d521df0ea0508b1d5553f716d5a9e2ae2b8ec 100644 (file)
@@ -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 @@ static bool cmd_search_more(struct client_command_context *cmd)
        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 @@ static bool cmd_search_more(struct client_command_context *cmd)
        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)
index 94581910e70f72a367666b6bda760efbcf490356..d0ac319a12831f46c2cb561f8c58596a312d4aba 100644 (file)
@@ -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 @@ bool cmd_status(struct client_command_context *cmd)
        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;
index 535a7654c6fbde3297590c07271f743ad9cb4553..2a947dd84a256e14ce0d3ab7539585116cb6e2bd 100644 (file)
@@ -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 @@ get_error_string(const char *error_string, enum mail_error error)
        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 == '[')
index 459f468d7fd9aa80876a7655151e83a9249c982e..61d66638e5e87d91d7e929000a7593c1cb314218 100644 (file)
@@ -26,6 +26,7 @@ headers = \
        imap-id.h \
        imap-match.h \
        imap-parser.h \
+       imap-resp-code.h \
        imap-quote.h \
        imap-seqset.h \
        imap-utf7.h \
diff --git a/src/lib-imap/imap-resp-code.h b/src/lib-imap/imap-resp-code.h
new file mode 100644 (file)
index 0000000..9cf8ccc
--- /dev/null
@@ -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