Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/imap/cmd-namespace.c @ 5500:4862cb37106c HEAD
Moved namespace handling to lib-storage. Beginnings of namespace support for
non-IMAP parts of Dovecot.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 03 Apr 2007 11:34:27 +0300 |
parents | 55df57c028d4 |
children | 45735dd11f17 |
rev | line source |
---|---|
1654
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
1 /* Copyright (C) 2003 Timo Sirainen */ |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 #include "common.h" |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 #include "str.h" |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
5 #include "imap-quote.h" |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 #include "commands.h" |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
7 #include "mail-namespace.h" |
1654
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 |
5500
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
9 static void list_namespaces(struct mail_namespace *ns, |
4862cb37106c
Moved namespace handling to lib-storage. Beginnings of namespace support for
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
10 enum namespace_type type, string_t *str) |
1654
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 { |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
12 bool found = FALSE; |
1654
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 while (ns != NULL) { |
1773
9547667cfa19
Added hidden-option to namespaces to hide them from NAMESPACE reply.
Timo Sirainen <tss@iki.fi>
parents:
1654
diff
changeset
|
15 if (ns->type == type && !ns->hidden) { |
1654
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
16 if (!found) { |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 str_append_c(str, '('); |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
18 found = TRUE; |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 } |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 str_append_c(str, '('); |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
21 imap_quote_append_string(str, ns->prefix, FALSE); |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 str_append(str, " \""); |
2350
1371d41c375f
Moved namespace and hierarchy separator handling to imap-specific code. LIST
Timo Sirainen <tss@iki.fi>
parents:
1773
diff
changeset
|
23 str_append(str, ns->sep_str); |
1654
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
24 str_append(str, "\")"); |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
25 } |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
26 |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
27 ns = ns->next; |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
28 } |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
29 |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
30 if (found) |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
31 str_append_c(str, ')'); |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
32 else |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
33 str_append(str, "NIL"); |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
34 } |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
35 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3141
diff
changeset
|
36 bool cmd_namespace(struct client_command_context *cmd) |
1654
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
37 { |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2350
diff
changeset
|
38 struct client *client = cmd->client; |
1654
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
39 string_t *str; |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
40 |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
41 str = t_str_new(256); |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
42 str_append(str, "* NAMESPACE "); |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
43 |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
44 list_namespaces(client->namespaces, NAMESPACE_PRIVATE, str); |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 str_append_c(str, ' '); |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
46 list_namespaces(client->namespaces, NAMESPACE_SHARED, str); |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
47 str_append_c(str, ' '); |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
48 list_namespaces(client->namespaces, NAMESPACE_PUBLIC, str); |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
49 |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
50 client_send_line(client, str_c(str)); |
3141
61abed5f7864
Moved command-specific variables from struct client to struct
Timo Sirainen <tss@iki.fi>
parents:
2350
diff
changeset
|
51 client_send_tagline(cmd, "OK Namespace completed."); |
1654
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
52 return TRUE; |
31c4bb26a1e9
Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
53 } |