annotate src/imap/cmd-namespace.c @ 1773:9547667cfa19 HEAD

Added hidden-option to namespaces to hide them from NAMESPACE reply.
author Timo Sirainen <tss@iki.fi>
date Mon, 15 Sep 2003 17:02:07 +0300
parents 31c4bb26a1e9
children 1371d41c375f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 #include "namespace.h"
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9 static void list_namespaces(struct namespace *ns, enum namespace_type type,
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10 string_t *str)
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11 {
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12 int found = FALSE;
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, " \"");
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
23 if (ns->hierarchy_sep == '"' ||
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
24 ns->hierarchy_sep == '\\')
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
25 str_append_c(str, '\\');
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
26 str_append_c(str, ns->hierarchy_sep);
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
27 str_append(str, "\")");
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 ns = ns->next;
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
31 }
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
32
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
33 if (found)
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
34 str_append_c(str, ')');
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
35 else
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
36 str_append(str, "NIL");
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 }
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
38
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39 int cmd_namespace(struct client *client)
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 string_t *str;
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
42
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
43 str = t_str_new(256);
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
44 str_append(str, "* NAMESPACE ");
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45
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_PRIVATE, 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_SHARED, str);
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
49 str_append_c(str, ' ');
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50 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
51
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
52 client_send_line(client, str_c(str));
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
53 client_send_tagline(client, "OK Namespace completed.");
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
54 return TRUE;
31c4bb26a1e9 Getting ready for namespaces. LIST is still broken with them.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
55 }