Mercurial > dovecot > original-hg > dovecot-1.2
diff src/imap/cmd-namespace.c @ 1654:31c4bb26a1e9 HEAD
Getting ready for namespaces. LIST is still broken with them.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 27 Jul 2003 07:48:32 +0300 |
parents | |
children | 9547667cfa19 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/imap/cmd-namespace.c Sun Jul 27 07:48:32 2003 +0300 @@ -0,0 +1,55 @@ +/* Copyright (C) 2003 Timo Sirainen */ + +#include "common.h" +#include "str.h" +#include "imap-quote.h" +#include "commands.h" +#include "namespace.h" + +static void list_namespaces(struct namespace *ns, enum namespace_type type, + string_t *str) +{ + int found = FALSE; + + while (ns != NULL) { + if (ns->type == type) { + if (!found) { + str_append_c(str, '('); + found = TRUE; + } + str_append_c(str, '('); + imap_quote_append_string(str, ns->prefix, FALSE); + str_append(str, " \""); + if (ns->hierarchy_sep == '"' || + ns->hierarchy_sep == '\\') + str_append_c(str, '\\'); + str_append_c(str, ns->hierarchy_sep); + str_append(str, "\")"); + } + + ns = ns->next; + } + + if (found) + str_append_c(str, ')'); + else + str_append(str, "NIL"); +} + +int cmd_namespace(struct client *client) +{ + string_t *str; + + str = t_str_new(256); + str_append(str, "* NAMESPACE "); + + list_namespaces(client->namespaces, NAMESPACE_PRIVATE, str); + str_append_c(str, ' '); + list_namespaces(client->namespaces, NAMESPACE_SHARED, str); + str_append_c(str, ' '); + list_namespaces(client->namespaces, NAMESPACE_PUBLIC, str); + + client_send_line(client, str_c(str)); + client_send_tagline(client, "OK Namespace completed."); + return TRUE; +}