1
/* Copyright (c) 2003-2012 Dovecot authors, see the included COPYING file */
3
#include "imap-common.h"
5
#include "imap-quote.h"
6
#include "imap-commands.h"
7
#include "mail-namespace.h"
9
static void list_namespaces(struct mail_namespace *ns,
10
enum namespace_type type, string_t *str)
16
if (ns->type == type &&
17
(ns->flags & NAMESPACE_FLAG_HIDDEN) == 0) {
19
str_append_c(str, '(');
22
ns_sep = mail_namespace_get_sep(ns);
23
str_append_c(str, '(');
24
imap_quote_append_string(str, ns->prefix, FALSE);
25
str_append(str, " \"");
27
str_append_c(str, '\\');
28
str_append_c(str, ns_sep);
29
str_append(str, "\")");
36
str_append_c(str, ')');
38
str_append(str, "NIL");
41
bool cmd_namespace(struct client_command_context *cmd)
43
struct client *client = cmd->client;
47
str_append(str, "* NAMESPACE ");
49
list_namespaces(client->user->namespaces, NAMESPACE_PRIVATE, str);
50
str_append_c(str, ' ');
51
list_namespaces(client->user->namespaces, NAMESPACE_SHARED, str);
52
str_append_c(str, ' ');
53
list_namespaces(client->user->namespaces, NAMESPACE_PUBLIC, str);
55
client_send_line(client, str_c(str));
56
client_send_tagline(cmd, "OK Namespace completed.");