Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
operator-create.cc
Go to the documentation of this file.
1
7#include <string>
8
9#include "depot.h"
10#include "mailbox.h"
11#include "operators.h"
12#include "imapparser.h"
13#include "recursivedescent.h"
14#include "session.h"
15#include "convert.h"
16
17using namespace ::std;
18using namespace Binc;
19
20//----------------------------------------------------------------------
22{
23}
24
25//----------------------------------------------------------------------
27{
28}
29
30//----------------------------------------------------------------------
31const string CreateOperator::getName(void) const
32{
33 return "CREATE";
34}
35
36//----------------------------------------------------------------------
38{
40}
41
42//------------------------------------------------------------------------
44 Request &command)
45{
46 if (depot.createMailbox(command.getMailbox()))
47 return OK;
48 else {
49 Session &session = Session::getInstance();
50 session.setLastError(depot.getLastError());
51 return NO;
52 }
53}
54
55//----------------------------------------------------------------------
57{
58 Session &session = Session::getInstance();
59
60 if (c_in.getUidMode()) return REJECT;
61
63 if ((res = expectSPACE()) != ACCEPT) {
64 session.setLastError("Expected SPACE after CREATE");
65 return res;
66 }
67
68 string mailbox;
69 if ((res = expectMailbox(mailbox)) != ACCEPT) {
70 session.setLastError("Expected mailbox after CREATE SPACE");
71 return res;
72 }
73
74 if ((res = expectCRLF()) != ACCEPT) {
75 session.setLastError("Expected CRLF after CREATE SPACE CRLF");
76 return res;
77 }
78
79 session.mailboxchanges = true;
80
81 c_in.setName("CREATE");
82 c_in.setMailbox(mailbox);
83 return ACCEPT;
84}
virtual ParseResult parse(Request &) const
int getState(void) const
ProcessResult process(Depot &, Request &)
const std::string getName(void) const
const std::string & getLastError(void) const
Definition: depot.cc:85
virtual bool createMailbox(const std::string &m) const
Definition: depot.cc:201
void setMailbox(const std::string &s_in)
Definition: imapparser.cc:155
void setName(const std::string &s_in)
Definition: imapparser.cc:70
const std::string & getMailbox(void) const
Definition: imapparser.cc:161
bool getUidMode(void) const
Definition: imapparser.cc:40
bool mailboxchanges
Definition: session.h:33
void setLastError(const std::string &error) const
Definition: session.cc:185
@ AUTHENTICATED
Definition: session.h:37
static Session & getInstance(void)
Definition: session.cc:33
Declaration of miscellaneous convertion functions.
Declaration of the common items for parsing IMAP input.
Declaration of the Mailbox class (Mailbox is logical container)
Definition: bincimapd.cc:9
Operator::ParseResult expectSPACE(void)
Operator::ParseResult expectCRLF(void)
Operator::ParseResult expectMailbox(std::string &s_in)
Declaration of all operators.
Declaration of a recursive descent IMAP command parser.