Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
operator-subscribe.cc
Go to the documentation of this file.
1
7#include <string>
8#include <iostream>
9#include "convert.h"
10#include <sys/stat.h>
11
12#include "recursivedescent.h"
13
14#include "session.h"
15#include "depot.h"
16#include "operators.h"
17
18using namespace ::std;
19using namespace Binc;
20
21//----------------------------------------------------------------------
23{
24}
25
26//----------------------------------------------------------------------
28{
29}
30
31//----------------------------------------------------------------------
32const string SubscribeOperator::getName(void) const
33{
34 return "SUBSCRIBE";
35}
36
37//----------------------------------------------------------------------
39{
41}
42
43//------------------------------------------------------------------------
45 Request &command)
46{
47 const string &srcmailbox = command.getMailbox();
48 const string &canonmailbox = toCanonMailbox(srcmailbox);
49
50 depot.loadSubscribes();
51 depot.subscribeTo(canonmailbox);
52 depot.saveSubscribes();
53
54 return OK;
55}
56
57//----------------------------------------------------------------------
59{
60 Session &session = Session::getInstance();
61
62 if (c_in.getUidMode())
63 return REJECT;
64
66 if ((res = expectSPACE()) != ACCEPT) {
67 session.setLastError("Expected SPACE");
68 return res;
69 }
70
71 string mailbox;
72 if ((res = expectMailbox(mailbox)) != ACCEPT) {
73 session.setLastError("Expected mailbox");
74 return res;
75 }
76 c_in.setMailbox(mailbox);
77
78 if ((res = expectCRLF()) != ACCEPT) {
79 session.setLastError("Expected CRLF");
80 return res;
81 }
82
83 return ACCEPT;
84}
virtual void loadSubscribes(void)
Definition: depot.cc:354
virtual bool saveSubscribes(void) const
Definition: depot.cc:396
virtual void subscribeTo(const std::string mailbox)
Definition: depot.cc:328
void setMailbox(const std::string &s_in)
Definition: imapparser.cc:155
const std::string & getMailbox(void) const
Definition: imapparser.cc:161
bool getUidMode(void) const
Definition: imapparser.cc:40
void setLastError(const std::string &error) const
Definition: session.cc:185
@ AUTHENTICATED
Definition: session.h:37
static Session & getInstance(void)
Definition: session.cc:33
virtual ParseResult parse(Request &) const
ProcessResult process(Depot &, Request &)
const std::string getName(void) const
Declaration of miscellaneous convertion functions.
Definition: bincimapd.cc:9
Operator::ParseResult expectSPACE(void)
std::string toCanonMailbox(const std::string &s_in)
Definition: convert.h:216
Operator::ParseResult expectCRLF(void)
Operator::ParseResult expectMailbox(std::string &s_in)
Declaration of all operators.
Declaration of a recursive descent IMAP command parser.