Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/imap/cmd-create.c @ 6298:f5782901930b HEAD
CREATE ns_prefix/box/ didn't work right when namespace prefix existed.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 14 Aug 2007 22:46:29 +0300 |
parents | 4862cb37106c |
children | 65c69a53a7be |
rev | line source |
---|---|
0 | 1 /* Copyright (C) 2002 Timo Sirainen */ |
2 | |
3 #include "common.h" | |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5299
diff
changeset
|
4 #include "mail-namespace.h" |
0 | 5 #include "commands.h" |
6 | |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3332
diff
changeset
|
7 bool cmd_create(struct client_command_context *cmd) |
0 | 8 { |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
5299
diff
changeset
|
9 struct mail_namespace *ns; |
2560
8319dd235b7b
CREATE was broken if namespace prefixes were set. Patch by Andreas Fuchs.
Timo Sirainen <tss@iki.fi>
parents:
2350
diff
changeset
|
10 const char *mailbox, *full_mailbox; |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3332
diff
changeset
|
11 bool directory; |
1290
9562ba6af1f1
mbox: CREATE mailbox/ now mkdir()s it.
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
12 size_t len; |
0 | 13 |
14 /* <mailbox> */ | |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2959
diff
changeset
|
15 if (!client_read_string_args(cmd, 1, &mailbox)) |
0 | 16 return FALSE; |
2560
8319dd235b7b
CREATE was broken if namespace prefixes were set. Patch by Andreas Fuchs.
Timo Sirainen <tss@iki.fi>
parents:
2350
diff
changeset
|
17 full_mailbox = mailbox; |
0 | 18 |
5299
937afbbf61b2
If trying to create <mailbox><real separator>, give an error instead of
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
19 ns = client_find_namespace(cmd, &mailbox); |
937afbbf61b2
If trying to create <mailbox><real separator>, give an error instead of
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
20 if (ns == NULL) |
1654
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
1290
diff
changeset
|
21 return TRUE; |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
1290
diff
changeset
|
22 |
5299
937afbbf61b2
If trying to create <mailbox><real separator>, give an error instead of
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
23 len = strlen(full_mailbox); |
937afbbf61b2
If trying to create <mailbox><real separator>, give an error instead of
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
24 if (len == 0 || full_mailbox[len-1] != ns->sep) |
1775
99cf3e9393a6
CREATE mailbox/ with maildir now creates the mailbox instead of ignoring it.
Timo Sirainen <tss@iki.fi>
parents:
1654
diff
changeset
|
25 directory = FALSE; |
1290
9562ba6af1f1
mbox: CREATE mailbox/ now mkdir()s it.
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
26 else { |
888
986e89b61520
CREATE mailbox<hierarchy separator> failed always.
Timo Sirainen <tss@iki.fi>
parents:
302
diff
changeset
|
27 /* name ends with hierarchy separator - client is just |
1775
99cf3e9393a6
CREATE mailbox/ with maildir now creates the mailbox instead of ignoring it.
Timo Sirainen <tss@iki.fi>
parents:
1654
diff
changeset
|
28 informing us that it wants to create children under this |
99cf3e9393a6
CREATE mailbox/ with maildir now creates the mailbox instead of ignoring it.
Timo Sirainen <tss@iki.fi>
parents:
1654
diff
changeset
|
29 mailbox. */ |
99cf3e9393a6
CREATE mailbox/ with maildir now creates the mailbox instead of ignoring it.
Timo Sirainen <tss@iki.fi>
parents:
1654
diff
changeset
|
30 directory = TRUE; |
6298
f5782901930b
CREATE ns_prefix/box/ didn't work right when namespace prefix existed.
Timo Sirainen <tss@iki.fi>
parents:
5500
diff
changeset
|
31 mailbox = t_strndup(mailbox, strlen(mailbox)-1); |
f5782901930b
CREATE ns_prefix/box/ didn't work right when namespace prefix existed.
Timo Sirainen <tss@iki.fi>
parents:
5500
diff
changeset
|
32 full_mailbox = t_strndup(full_mailbox, len-1); |
888
986e89b61520
CREATE mailbox<hierarchy separator> failed always.
Timo Sirainen <tss@iki.fi>
parents:
302
diff
changeset
|
33 } |
986e89b61520
CREATE mailbox<hierarchy separator> failed always.
Timo Sirainen <tss@iki.fi>
parents:
302
diff
changeset
|
34 |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2959
diff
changeset
|
35 if (!client_verify_mailbox_name(cmd, full_mailbox, FALSE, TRUE)) |
0 | 36 return TRUE; |
37 | |
5299
937afbbf61b2
If trying to create <mailbox><real separator>, give an error instead of
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
38 if (mail_storage_mailbox_create(ns->storage, mailbox, directory) < 0) |
937afbbf61b2
If trying to create <mailbox><real separator>, give an error instead of
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
39 client_send_storage_error(cmd, ns->storage); |
1915
79790750c349
importing new index code. mbox still broken.
Timo Sirainen <tss@iki.fi>
parents:
1775
diff
changeset
|
40 else |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2959
diff
changeset
|
41 client_send_tagline(cmd, "OK Create completed."); |
0 | 42 return TRUE; |
43 } |