]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Add imap_client_command_get_reason()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 4 Apr 2017 12:38:00 +0000 (15:38 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 6 Apr 2017 17:22:41 +0000 (20:22 +0300)
All the command -> reason string conversions now go through this function.

src/imap/cmd-fetch.c
src/imap/imap-commands-util.c
src/imap/imap-commands-util.h

index 96c2d70e59e4470e601a727ccca2ec1fc4846385..085ddb82a95f12609c291c2e12fbddaf9abec670 100644 (file)
@@ -310,7 +310,7 @@ bool cmd_fetch(struct client_command_context *cmd)
                return ret < 0;
 
        ctx = imap_fetch_alloc(client, cmd->pool,
-                              t_strdup_printf("%s %s", cmd->name, cmd->args));
+                              imap_client_command_get_reason(cmd));
 
        if (!fetch_parse_args(ctx, cmd, &args[1], &next_arg) ||
            (imap_arg_get_list(next_arg, &list_arg) &&
index 0c525115512195daf9feec34f61f2c0928842121..81044ae60298813f19d5cac171565393342f8174 100644 (file)
@@ -132,11 +132,16 @@ int client_open_save_dest_box(struct client_command_context *cmd,
        return 0;
 }
 
+const char *imap_client_command_get_reason(struct client_command_context *cmd)
+{
+       return cmd->args[0] == '\0' ? cmd->name :
+               t_strdup_printf("%s %s", cmd->name, cmd->args);
+}
+
 void imap_transaction_set_cmd_reason(struct mailbox_transaction_context *trans,
                                     struct client_command_context *cmd)
 {
-       mailbox_transaction_set_reason(trans, cmd->args[0] == '\0' ? cmd->name :
-               t_strdup_printf("%s %s", cmd->name, cmd->args));
+       mailbox_transaction_set_reason(trans, imap_client_command_get_reason(cmd));
 }
 
 const char *
index 6ebd65bd8bde5f3e5e1228a5d4dae7dd2c6623f7..48f4f6be33a1ee11e07596afa86455fd262d885f 100644 (file)
@@ -27,6 +27,8 @@ void imap_client_close_mailbox(struct client *client);
 int client_open_save_dest_box(struct client_command_context *cmd,
                              const char *name, struct mailbox **destbox_r);
 
+/* Returns string based in IMAP command name and parameters. */
+const char *imap_client_command_get_reason(struct client_command_context *cmd);
 /* Set transaction's reason to the IMAP command name and parameters. */
 void imap_transaction_set_cmd_reason(struct mailbox_transaction_context *trans,
                                     struct client_command_context *cmd);