/** * @file operator-namespace.cc * @brief Operator for the NAMESPACE command. * @author Andreas Aardal Hanssen * @date 2002-2005 */ #include "depot.h" #include "iodevice.h" #include "iofactory.h" #include "operators.h" #include "recursivedescent.h" #include "session.h" #include #include using namespace Binc; NamespaceOperator::NamespaceOperator() {} NamespaceOperator::~NamespaceOperator() {} const std::string NamespaceOperator::getName() const { return "NAMESPACE"; } Session::State NamespaceOperator::getState() const { return Session::State(Session::AUTHENTICATED | Session::SELECTED); } Operator::ProcessResult NamespaceOperator::process(Depot &depot, Request &command) { bincClient << "* NAMESPACE "; bincClient << "(("; // personal namespace bincClient << toImapString(depot.getPersonalNamespace()); bincClient << " "; char c = depot.getDelimiter(); bincClient << toImapString(std::string(&c, 1)); bincClient << "))"; bincClient << " NIL"; // others' namespaces bincClient << " NIL"; // shared namespaces bincClient << std::endl; return Operator::ProcessResult::OK; } Parser::ParseResult NamespaceOperator::parse(Request &c_in, Parser &p) { Session &session = Session::getInstance(); if (c_in.getUidMode()) return Parser::ParseResult::REJECT; Parser::ParseResult res; if ((res = p.expectCRLF()) != Parser::ParseResult::ACCEPT) { session.setLastError("Expected CRLF after NAMESPACE"); return res; } c_in.setName("NAMESPACE"); return Parser::ParseResult::ACCEPT; }