cmd-subscribe.c revision 80863ea81a6d6975c8b0d97657d850e8ac64e12e
a8c5a86d183db25a57bf193c06b41e092ec2e151Timo Sirainen/* Copyright (c) 2002-2007 Dovecot authors, see the included COPYING file */
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainenbool cmd_subscribe_full(struct client_command_context *cmd, bool subscribe)
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen /* <mailbox> */
91e2dc36b9c0c91f0af716be81dc2aa6cbbed6c2Timo Sirainen if (!client_read_string_args(cmd, 1, &mailbox))
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen ns = mail_namespace_find_subscribable(cmd->client->namespaces,
3313a51ef9b245248d672c20f930c52a577a42f7Timo Sirainen client_send_tagline(cmd, "NO Unknown namespace.");
3313a51ef9b245248d672c20f930c52a577a42f7Timo Sirainen if ((client_workarounds & WORKAROUND_TB_EXTRA_MAILBOX_SEP) != 0 &&
0f39a57760d93cddbce3ca43096d78e0fe2f42fdTimo Sirainen *mailbox != '\0' && mailbox[strlen(mailbox)-1] ==
3313a51ef9b245248d672c20f930c52a577a42f7Timo Sirainen /* verify the validity without the trailing '/' */
0f39a57760d93cddbce3ca43096d78e0fe2f42fdTimo Sirainen verify_name = t_strndup(verify_name, strlen(verify_name)-1);
0f39a57760d93cddbce3ca43096d78e0fe2f42fdTimo Sirainen ns2 = mail_namespace_find_prefix_nosep(cmd->client->namespaces,
3313a51ef9b245248d672c20f930c52a577a42f7Timo Sirainen if (ns2 != NULL && (ns2->flags & NAMESPACE_FLAG_LIST) != 0) {
3313a51ef9b245248d672c20f930c52a577a42f7Timo Sirainen /* subscribing to a listable namespace prefix, allow it. */
5c253723e8ef84cb71a80ced19efe597e8a90ea6Timo Sirainen if (!client_verify_mailbox_name(cmd, verify_name,
c2f24d55319fad0b6c03425f402f0cb0cb1a318bTimo Sirainen if (mailbox_list_set_subscribed(list, mailbox, subscribe) < 0)
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen "OK Subscribe completed." :
2e29e4797a48d78d669821722bdb54fd0a1d3b94Timo Sirainen "OK Unsubscribe completed.");