15
15
#include "imap-commands-util.h"
17
17
struct mail_namespace *
18
client_find_namespace(struct client_command_context *cmd, const char **mailbox)
18
client_find_namespace_full(struct client *client,
19
const char **mailbox, const char **error_r)
20
struct mail_namespace *namespaces = cmd->client->user->namespaces;
21
struct mail_namespace *namespaces = client->user->namespaces;
21
22
struct mail_namespace *ns;
22
23
string_t *utf8_name;
24
25
utf8_name = t_str_new(64);
25
26
if (imap_utf7_to_utf8(*mailbox, utf8_name) < 0) {
26
client_send_tagline(cmd, "NO Mailbox name is not valid mUTF-7");
27
*error_r = "NO Mailbox name is not valid mUTF-7";
30
31
ns = mail_namespace_find(namespaces, str_c(utf8_name));
32
client_send_tagline(cmd, t_strdup_printf(
32
if ((ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0 &&
33
ns->prefix_len == 0) {
34
/* this matched only the autocreated prefix="" namespace.
35
give a nice human-readable error message */
36
*error_r = t_strdup_printf(
33
37
"NO Client tried to access nonexistent namespace. "
34
38
"(Mailbox name should probably be prefixed with: %s)",
35
mail_namespace_find_inbox(namespaces)->prefix));
39
mail_namespace_find_inbox(namespaces)->prefix);
39
if ((cmd->client->set->parsed_workarounds &
43
if ((client->set->parsed_workarounds &
40
44
WORKAROUND_TB_EXTRA_MAILBOX_SEP) != 0 &&
41
45
str_len(utf8_name) > 0 &&
42
46
str_c(utf8_name)[str_len(utf8_name)-1] == mail_namespace_get_sep(ns)) {
55
struct mail_namespace *
56
client_find_namespace(struct client_command_context *cmd, const char **mailbox)
58
struct mail_namespace *ns;
61
ns = client_find_namespace_full(cmd->client, mailbox, &error);
63
client_send_tagline(cmd, error);
51
67
bool client_verify_open_mailbox(struct client_command_context *cmd)
53
69
if (cmd->client->mailbox != NULL)
133
149
case MAIL_ERROR_INUSE:
134
150
resp_code = IMAP_RESP_CODE_INUSE;
152
case MAIL_ERROR_CONVERSION:
153
case MAIL_ERROR_INVALIDDATA:
137
156
if (resp_code == NULL || *error_string == '[')
138
157
return t_strconcat("NO ", error_string, NULL);
215
234
if (flag != 0 && flag != MAIL_RECENT)
216
235
*flags_r |= flag;
218
client_send_tagline(cmd, t_strconcat(
219
"BAD Invalid system flag ",
237
client_send_command_error(cmd, t_strconcat(
238
"Invalid system flag ", atom, NULL));
231
249
if (array_count(&keywords) == 0)
232
250
*keywords_r = NULL;
234
(void)array_append_space(&keywords); /* NULL-terminate */
252
array_append_zero(&keywords); /* NULL-terminate */
235
253
*keywords_r = array_idx(&keywords, 0);
308
326
array_append(dest, &all_names[kw_index], 1);
311
(void)array_append_space(dest);
329
array_append_zero(dest);
312
330
return array_idx(dest, 0);
315
bool mailbox_equals(const struct mailbox *box1,
316
const struct mail_namespace *ns2, const char *name2)
318
struct mail_namespace *ns1 = mailbox_get_namespace(box1);
324
name1 = mailbox_get_vname(box1);
325
if (strcmp(name1, name2) == 0)
328
return strcasecmp(name1, "INBOX") == 0 &&
329
strcasecmp(name2, "INBOX") == 0;
332
333
void msgset_generator_init(struct msgset_generator_context *ctx, string_t *str)
334
335
memset(ctx, 0, sizeof(*ctx));
339
340
void msgset_generator_next(struct msgset_generator_context *ctx, uint32_t uid)
341
if (uid != ctx->last_uid+1) {
344
if (uid-1 != ctx->last_uid) {
342
345
if (ctx->first_uid == 0)
344
347
else if (ctx->first_uid == ctx->last_uid)