annotate src/imap/cmd-append.c @ 3439:6beadbe3fc0d HEAD

Yet another APPEND fix.
author Timo Sirainen <tss@iki.fi>
date Tue, 28 Jun 2005 02:32:14 +0300
parents 2cb42efa44f6
children 877fa3d04313
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
1 /* Copyright (C) 2002 Timo Sirainen */
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "common.h"
117
97d0b9fcc18a APPEND was broken.
Timo Sirainen <tss@iki.fi>
parents: 0
diff changeset
4 #include "ioloop.h"
1015
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
5 #include "istream.h"
764
f57c52738f90 Renamed IBuffer and OBuffer to IStream and OStream which describes their
Timo Sirainen <tss@iki.fi>
parents: 546
diff changeset
6 #include "ostream.h"
2190
755ec9442a58 mailbox_save() and mailbox_copy() functions can now return the saved mail so
Timo Sirainen <tss@iki.fi>
parents: 1958
diff changeset
7 #include "str.h"
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 #include "commands.h"
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9 #include "imap-parser.h"
119
2f67de235489 Whops, we were using RFC822 dates everywhere instead of IMAP dates.
Timo Sirainen <tss@iki.fi>
parents: 117
diff changeset
10 #include "imap-date.h"
1041
47ecd950a702 some header file cleanups
Timo Sirainen <tss@iki.fi>
parents: 1023
diff changeset
11 #include "mail-storage.h"
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12
492
efa46e28a0d7 Fixes to timezone handling which were handling quite badly. added
Timo Sirainen <tss@iki.fi>
parents: 450
diff changeset
13 #include <sys/time.h>
efa46e28a0d7 Fixes to timezone handling which were handling quite badly. added
Timo Sirainen <tss@iki.fi>
parents: 450
diff changeset
14
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
15 struct cmd_append_context {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
16 struct client *client;
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
17 struct client_command_context *cmd;
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
18 struct mail_storage *storage;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
19 struct mailbox *box;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
20 struct mailbox_transaction_context *t;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
21
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
22 struct istream *input;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
23 uoff_t msg_size;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
24
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
25 struct imap_parser *save_parser;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
26 struct mail_save_context *save_ctx;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
27 };
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
28
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
29 static int cmd_append_continue_message(struct client_command_context *cmd);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
30
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
31 static void client_input(void *context)
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
32 {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
33 struct client *client = context;
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
34 struct client_command_context *cmd = &client->cmd;
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
35
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
36 client->last_input = ioloop_time;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
37
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
38 switch (i_stream_read(client->input)) {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
39 case -1:
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
40 /* disconnected */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
41 client_destroy(client);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
42 return;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
43 case -2:
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
44 if (client->command_pending) {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
45 /* message data, this is handled internally by
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
46 mailbox_save_continue() */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
47 break;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
48 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
49
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
50 /* parameter word is longer than max. input buffer size.
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
51 this is most likely an error, so skip the new data
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
52 until newline is found. */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
53 client->input_skip_line = TRUE;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
54
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
55 client_send_command_error(cmd, "Too long argument.");
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
56 _client_reset_command(client);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
57 break;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
58 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
59
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
60 if (cmd->func(cmd)) {
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
61 /* command execution was finished */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
62 client->bad_counter = 0;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
63 _client_reset_command(client);
2878
904c31d74acc APPEND was using all CPU.
Timo Sirainen <tss@iki.fi>
parents: 2731
diff changeset
64 o_stream_set_flush_callback(client->output,
904c31d74acc APPEND was using all CPU.
Timo Sirainen <tss@iki.fi>
parents: 2731
diff changeset
65 _client_output, client);
2460
3accbeb04383 crashfixes
Timo Sirainen <tss@iki.fi>
parents: 2455
diff changeset
66
3accbeb04383 crashfixes
Timo Sirainen <tss@iki.fi>
parents: 2455
diff changeset
67 if (client->input_pending)
3accbeb04383 crashfixes
Timo Sirainen <tss@iki.fi>
parents: 2455
diff changeset
68 _client_input(client);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
69 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
70 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
71
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
72 /* Returns -1 = error, 0 = need more data, 1 = successful. flags and
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
73 internal_date may be NULL as a result, but mailbox and msg_size are always
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
74 set when successful. */
1015
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
75 static int validate_args(struct imap_arg *args, struct imap_arg_list **flags,
1022
09bac2875ed8 Support for LITERAL+ extension.
Timo Sirainen <tss@iki.fi>
parents: 1015
diff changeset
76 const char **internal_date, uoff_t *msg_size,
09bac2875ed8 Support for LITERAL+ extension.
Timo Sirainen <tss@iki.fi>
parents: 1015
diff changeset
77 int *nonsync)
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
78 {
1015
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
79 /* [<flags>] */
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
80 if (args->type != IMAP_ARG_LIST)
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
81 *flags = NULL;
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
82 else {
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
83 *flags = IMAP_ARG_LIST(args);
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
84 args++;
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
85 }
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
86
1015
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
87 /* [<internal date>] */
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
88 if (args->type != IMAP_ARG_STRING)
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
89 *internal_date = NULL;
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
90 else {
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
91 *internal_date = IMAP_ARG_STR(args);
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
92 args++;
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
93 }
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
94
1022
09bac2875ed8 Support for LITERAL+ extension.
Timo Sirainen <tss@iki.fi>
parents: 1015
diff changeset
95 if (args->type != IMAP_ARG_LITERAL_SIZE &&
2731
b63b4080c6b2 Handle failures without crashing
Timo Sirainen <tss@iki.fi>
parents: 2670
diff changeset
96 args->type != IMAP_ARG_LITERAL_SIZE_NONSYNC) {
b63b4080c6b2 Handle failures without crashing
Timo Sirainen <tss@iki.fi>
parents: 2670
diff changeset
97 *nonsync = FALSE;
1015
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
98 return FALSE;
2731
b63b4080c6b2 Handle failures without crashing
Timo Sirainen <tss@iki.fi>
parents: 2670
diff changeset
99 }
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
100
1022
09bac2875ed8 Support for LITERAL+ extension.
Timo Sirainen <tss@iki.fi>
parents: 1015
diff changeset
101 *nonsync = args->type == IMAP_ARG_LITERAL_SIZE_NONSYNC;
1015
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
102 *msg_size = IMAP_ARG_LITERAL_SIZE(args);
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
103 return TRUE;
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
104 }
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
105
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
106 static void cmd_append_finish(struct cmd_append_context *ctx)
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
107 {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
108 size_t size;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
109
3219
b9e8420d979a Eat away the finishing empty line if APPEND failed so we don't send "* BAD"
Timo Sirainen <tss@iki.fi>
parents: 3210
diff changeset
110 ctx->client->input_skip_line = TRUE;
b9e8420d979a Eat away the finishing empty line if APPEND failed so we don't send "* BAD"
Timo Sirainen <tss@iki.fi>
parents: 3210
diff changeset
111
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
112 io_remove(ctx->client->io);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
113 ctx->client->io = NULL;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
114
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
115 imap_parser_destroy(ctx->save_parser);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
116
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
117 if (ctx->input != NULL)
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
118 i_stream_unref(ctx->input);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
119
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
120 if (ctx->save_ctx != NULL)
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
121 mailbox_save_cancel(ctx->save_ctx);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
122
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
123 if (ctx->t != NULL)
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
124 mailbox_transaction_rollback(ctx->t);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
125
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
126 if (ctx->box != ctx->cmd->client->mailbox && ctx->box != NULL)
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
127 mailbox_close(ctx->box);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
128
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
129 (void)i_stream_get_data(ctx->client->input, &size);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
130 ctx->client->input_pending = size != 0;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
131 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
132
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
133 static int cmd_append_continue_cancel(struct client_command_context *cmd)
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
134 {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
135 struct cmd_append_context *ctx = cmd->context;
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
136 size_t size;
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
137
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
138 (void)i_stream_read(ctx->input);
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
139 (void)i_stream_get_data(ctx->input, &size);
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
140 i_stream_skip(ctx->input, size);
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
141
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
142 if (ctx->input->v_offset == ctx->msg_size || ctx->input->closed) {
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
143 cmd_append_finish(ctx);
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
144 return TRUE;
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
145 }
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
146 return FALSE;
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
147 }
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
148
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
149 static int cmd_append_cancel(struct cmd_append_context *ctx, int nonsync)
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
150 {
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
151 if (!nonsync) {
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
152 cmd_append_finish(ctx);
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
153 return TRUE;
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
154 }
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
155
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
156 /* we have to read the nonsynced literal so we don't treat the message
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
157 data as commands. */
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
158 ctx->input = i_stream_create_limit(default_pool, ctx->client->input,
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
159 ctx->client->input->v_offset,
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
160 ctx->msg_size);
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
161
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
162 ctx->client->command_pending = TRUE;
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
163 ctx->cmd->func = cmd_append_continue_cancel;
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
164 ctx->cmd->context = ctx;
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
165 return cmd_append_continue_cancel(ctx->cmd);
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
166 }
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
167
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
168 static int cmd_append_continue_parsing(struct client_command_context *cmd)
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
169 {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
170 struct client *client = cmd->client;
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
171 struct cmd_append_context *ctx = cmd->context;
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
172 struct imap_arg *args;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
173 struct imap_arg_list *flags_list;
3016
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2878
diff changeset
174 enum mail_flags flags;
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2878
diff changeset
175 const char *const *keywords_list;
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2878
diff changeset
176 struct mail_keywords *keywords;
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
177 const char *internal_date_str;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
178 time_t internal_date;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
179 int ret, timezone_offset, nonsync;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
180
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
181 /* if error occurs, the CRLF is already read. */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
182 client->input_skip_line = FALSE;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
183
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
184 /* [<flags>] [<internal date>] <message literal> */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
185 ret = imap_parser_read_args(ctx->save_parser, 0,
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
186 IMAP_PARSE_FLAG_LITERAL_SIZE, &args);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
187 if (ret == -1) {
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
188 if (ctx->box != NULL)
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
189 client_send_command_error(cmd, NULL);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
190 cmd_append_finish(ctx);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
191 return TRUE;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
192 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
193 if (ret < 0) {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
194 /* need more data */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
195 return FALSE;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
196 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
197
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
198 if (args->type == IMAP_ARG_EOL) {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
199 /* last message */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
200 enum mailbox_sync_flags sync_flags;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
201
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
202 if (ctx->box == NULL) {
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
203 /* we failed earlier, error message is sent */
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
204 cmd_append_finish(ctx);
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
205 return TRUE;
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
206 }
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
207
2518
f8be7a5e273a Added sync flags parameter to mailbox_transaction_commit(), so EXPUNGE can
Timo Sirainen <tss@iki.fi>
parents: 2501
diff changeset
208 ret = mailbox_transaction_commit(ctx->t, 0);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
209 ctx->t = NULL;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
210 if (ret < 0) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
211 client_send_storage_error(cmd, ctx->storage);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
212 cmd_append_finish(ctx);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
213 return TRUE;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
214 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
215
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
216 sync_flags = ctx->box == cmd->client->mailbox ?
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
217 0 : MAILBOX_SYNC_FLAG_FAST;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
218
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
219 cmd_append_finish(ctx);
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
220 return cmd_sync(cmd, sync_flags, "OK Append completed.");
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
221 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
222
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
223 if (!validate_args(args, &flags_list, &internal_date_str,
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
224 &ctx->msg_size, &nonsync)) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
225 client_send_command_error(cmd, "Invalid arguments.");
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
226 return cmd_append_cancel(ctx, nonsync);
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
227 }
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
228
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
229 if (ctx->box == NULL) {
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
230 /* we failed earlier, make sure we just eat nonsync-literal
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
231 if it's given. */
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
232 return cmd_append_cancel(ctx, nonsync);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
233 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
234
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
235 if (flags_list != NULL) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
236 if (!client_parse_mail_flags(cmd, flags_list->args,
3016
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2878
diff changeset
237 &flags, &keywords_list))
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
238 return cmd_append_cancel(ctx, nonsync);
3016
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2878
diff changeset
239 keywords = keywords_list == NULL ? NULL :
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2878
diff changeset
240 mailbox_keywords_create(ctx->t, keywords_list);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
241 } else {
3016
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2878
diff changeset
242 flags = 0;
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2878
diff changeset
243 keywords = NULL;
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
244 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
245
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
246 if (internal_date_str == NULL) {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
247 /* no time given, default to now. */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
248 internal_date = (time_t)-1;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
249 timezone_offset = 0;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
250 } else if (!imap_parse_datetime(internal_date_str,
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
251 &internal_date, &timezone_offset)) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
252 client_send_tagline(cmd, "BAD Invalid internal date.");
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
253 return cmd_append_cancel(ctx, nonsync);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
254 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
255
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
256 if (ctx->msg_size == 0) {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
257 /* no message data, abort */
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
258 client_send_tagline(cmd, "NO Append aborted.");
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
259 cmd_append_finish(ctx);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
260 return TRUE;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
261 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
262
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
263 if (!nonsync) {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
264 o_stream_send(client->output, "+ OK\r\n", 6);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
265 o_stream_flush(client->output);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
266 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
267
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
268 /* after literal comes CRLF, if we fail make sure we eat it away */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
269 client->input_skip_line = TRUE;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
270
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
271 /* save the mail */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
272 ctx->input = i_stream_create_limit(default_pool, client->input,
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
273 client->input->v_offset,
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
274 ctx->msg_size);
3016
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2878
diff changeset
275 ctx->save_ctx = mailbox_save_init(ctx->t, flags, keywords,
61c8d205d887 Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Timo Sirainen <tss@iki.fi>
parents: 2878
diff changeset
276 internal_date, timezone_offset, NULL,
2455
d38f3876f3ad Forgot want_mail=TRUE parameter from debugging.
Timo Sirainen <tss@iki.fi>
parents: 2446
diff changeset
277 ctx->input, FALSE);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
278
3138
fbe844061fe2 Internal changes in how keywords are handled. struct mail_keywords isn't
Timo Sirainen <tss@iki.fi>
parents: 3131
diff changeset
279 if (keywords != NULL)
fbe844061fe2 Internal changes in how keywords are handled. struct mail_keywords isn't
Timo Sirainen <tss@iki.fi>
parents: 3131
diff changeset
280 mailbox_keywords_free(ctx->t, keywords);
fbe844061fe2 Internal changes in how keywords are handled. struct mail_keywords isn't
Timo Sirainen <tss@iki.fi>
parents: 3131
diff changeset
281
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
282 client->command_pending = TRUE;
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
283 cmd->func = cmd_append_continue_message;
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
284 return cmd_append_continue_message(cmd);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
285 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
286
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
287 static int cmd_append_continue_message(struct client_command_context *cmd)
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
288 {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
289 struct client *client = cmd->client;
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
290 struct cmd_append_context *ctx = cmd->context;
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
291 size_t size;
3439
6beadbe3fc0d Yet another APPEND fix.
Timo Sirainen <tss@iki.fi>
parents: 3437
diff changeset
292 int ret, failed;
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
293
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
294 if (ctx->save_ctx != NULL) {
3439
6beadbe3fc0d Yet another APPEND fix.
Timo Sirainen <tss@iki.fi>
parents: 3437
diff changeset
295 ret = mailbox_save_continue(ctx->save_ctx);
6beadbe3fc0d Yet another APPEND fix.
Timo Sirainen <tss@iki.fi>
parents: 3437
diff changeset
296 if (ret < 0 || client->input->closed) {
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
297 /* we still have to finish reading the message
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
298 from client */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
299 mailbox_save_cancel(ctx->save_ctx);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
300 ctx->save_ctx = NULL;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
301 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
302 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
303
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
304 if (ctx->save_ctx == NULL) {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
305 (void)i_stream_read(ctx->input);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
306 (void)i_stream_get_data(ctx->input, &size);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
307 i_stream_skip(ctx->input, size);
3439
6beadbe3fc0d Yet another APPEND fix.
Timo Sirainen <tss@iki.fi>
parents: 3437
diff changeset
308 ret = size == 0 ? 0 : 1;
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
309 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
310
3439
6beadbe3fc0d Yet another APPEND fix.
Timo Sirainen <tss@iki.fi>
parents: 3437
diff changeset
311 if (ret == 0 || client->input->closed) {
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
312 /* finished */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
313 i_stream_unref(ctx->input);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
314 ctx->input = NULL;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
315
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
316 if (ctx->save_ctx == NULL) {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
317 /* failed above */
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
318 client_send_storage_error(cmd, ctx->storage);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
319 failed = TRUE;
3439
6beadbe3fc0d Yet another APPEND fix.
Timo Sirainen <tss@iki.fi>
parents: 3437
diff changeset
320 } else if (ret != 0) {
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
321 /* client disconnected */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
322 failed = TRUE;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
323 mailbox_save_cancel(ctx->save_ctx);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
324 } else if (mailbox_save_finish(ctx->save_ctx, NULL) < 0) {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
325 failed = TRUE;
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
326 client_send_storage_error(cmd, ctx->storage);
3157
7eb1995f5a27 Don't crash if client disconnects in the middle of APPEND. The last fix
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
327 } else {
7eb1995f5a27 Don't crash if client disconnects in the middle of APPEND. The last fix
Timo Sirainen <tss@iki.fi>
parents: 3141
diff changeset
328 failed = client->input->closed;
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
329 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
330 ctx->save_ctx = NULL;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
331
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
332 if (failed) {
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
333 cmd_append_finish(ctx);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
334 return TRUE;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
335 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
336
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
337 /* prepare for next message */
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
338 client->command_pending = FALSE;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
339 imap_parser_reset(ctx->save_parser);
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
340 cmd->func = cmd_append_continue_parsing;
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
341 return cmd_append_continue_parsing(cmd);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
342 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
343
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
344 return FALSE;
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
345 }
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
346
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
347 static struct mailbox *
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
348 get_mailbox(struct client_command_context *cmd, const char *name)
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
349 {
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
350 struct mail_storage *storage;
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
351 struct mailbox *box;
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
352
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
353 if (!client_verify_mailbox_name(cmd, name, TRUE, FALSE))
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
354 return NULL;
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
355
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
356 storage = client_find_storage(cmd, &name);
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
357 if (storage == NULL)
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
358 return NULL;
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
359
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
360 if (cmd->client->mailbox != NULL &&
3210
2715077f9c3e mailbox_name_equals() renamed to mailbox_equals(), which also now checks
Timo Sirainen <tss@iki.fi>
parents: 3209
diff changeset
361 mailbox_equals(cmd->client->mailbox, storage, name))
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
362 return cmd->client->mailbox;
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
363
3245
6491dab63e54 Added input stream parameter to mailbox_open(). With mbox it now allows
Timo Sirainen <tss@iki.fi>
parents: 3219
diff changeset
364 box = mailbox_open(storage, name, NULL, MAILBOX_OPEN_FAST |
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
365 MAILBOX_OPEN_KEEP_RECENT);
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
366 if (box == NULL) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
367 client_send_storage_error(cmd, storage);
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
368 return NULL;
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
369 }
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
370 return box;
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
371 }
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
372
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
373 int cmd_append(struct client_command_context *cmd)
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
374 {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
375 struct client *client = cmd->client;
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
376 struct cmd_append_context *ctx;
1168
03f1455664d7 Added setting to limit length of custom flag names.
Timo Sirainen <tss@iki.fi>
parents: 1041
diff changeset
377 struct mailbox_status status;
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
378 const char *mailbox;
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
379
1015
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
380 /* <mailbox> */
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
381 if (!client_read_string_args(cmd, 1, &mailbox))
1015
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
382 return FALSE;
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
383
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
384 ctx = p_new(cmd->pool, struct cmd_append_context, 1);
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
385 ctx->cmd = cmd;
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
386 ctx->client = client;
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
387 ctx->box = get_mailbox(cmd, mailbox);
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
388 if (ctx->box != NULL) {
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
389 ctx->storage = mailbox_get_storage(ctx->box);
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
390
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
391 if (mailbox_get_status(ctx->box, STATUS_KEYWORDS,
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
392 &status) < 0) {
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
393 client_send_storage_error(cmd, ctx->storage);
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
394 mailbox_close(ctx->box);
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
395 ctx->box = NULL;
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
396 } else {
3254
a2943c050571 Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents: 3245
diff changeset
397 client_save_keywords(&client->keywords,
a2943c050571 Keywords are now stored in X-Keywords headers in mbox. Did several related
Timo Sirainen <tss@iki.fi>
parents: 3245
diff changeset
398 status.keywords);
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
399 }
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
400 ctx->t = ctx->box == NULL ? NULL :
3209
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3157
diff changeset
401 mailbox_transaction_begin(ctx->box,
923ff19873d4 Major mail-storage API changes. It's now a bit cleaner and much more plugin
Timo Sirainen <tss@iki.fi>
parents: 3157
diff changeset
402 MAILBOX_TRANSACTION_FLAG_EXTERNAL);
2670
e24c801dbc09 If message was APPENDed with LITERALPLUS and it failed for some reason (eg.
Timo Sirainen <tss@iki.fi>
parents: 2518
diff changeset
403 }
1168
03f1455664d7 Added setting to limit length of custom flag names.
Timo Sirainen <tss@iki.fi>
parents: 1041
diff changeset
404
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
405 io_remove(client->io);
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
406 client->io = io_add(i_stream_get_fd(client->input), IO_READ,
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
407 client_input, client);
2878
904c31d74acc APPEND was using all CPU.
Timo Sirainen <tss@iki.fi>
parents: 2731
diff changeset
408 /* append is special because we're only waiting on client input, not
904c31d74acc APPEND was using all CPU.
Timo Sirainen <tss@iki.fi>
parents: 2731
diff changeset
409 client output, so disable the standard output handler until we're
904c31d74acc APPEND was using all CPU.
Timo Sirainen <tss@iki.fi>
parents: 2731
diff changeset
410 finished */
904c31d74acc APPEND was using all CPU.
Timo Sirainen <tss@iki.fi>
parents: 2731
diff changeset
411 o_stream_set_flush_callback(client->output, NULL, NULL);
1015
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
412
2446
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
413 ctx->save_parser = imap_parser_create(client->input, client->output,
47e1e05cede0 Changed mail saving API to be nonblocking.
Timo Sirainen <tss@iki.fi>
parents: 2427
diff changeset
414 imap_max_line_length);
1015
40a327d356de Support for MULTIAPPEND extension. COPY now behaves like spec says - if it
Timo Sirainen <tss@iki.fi>
parents: 988
diff changeset
415
3141
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
416 cmd->func = cmd_append_continue_parsing;
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
417 cmd->context = ctx;
61abed5f7864 Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents: 3138
diff changeset
418 return cmd_append_continue_parsing(cmd);
0
3b1985cbc908 Initial revision
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
419 }