Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
operator-capability.cc
Go to the documentation of this file.
1
7#include <string>
8
9#include "depot.h"
10#include "iodevice.h"
11#include "iofactory.h"
12#include "operators.h"
13#include "recursivedescent.h"
14#include "session.h"
15#include "globals.h"
16
17using namespace ::std;
18using namespace Binc;
19
20//----------------------------------------------------------------------
22{
23}
24
25//----------------------------------------------------------------------
27{
28}
29
30//----------------------------------------------------------------------
31const string CapabilityOperator::getName(void) const
32{
33 return "CAPABILITY";
34}
35
36//----------------------------------------------------------------------
38{
42}
43
44//----------------------------------------------------------------------
45void CapabilityOperator::addCapability(const string &cap)
46{
47 capabilities.push_back(cap);
48}
49
50//----------------------------------------------------------------------
52 Request &command)
53{
54 Session &session = Session::getInstance();
55
56 bincClient << "* CAPABILITY " << IMAP_VERSION ;
57
58 if (session.getState() == Session::NONAUTHENTICATED) {
59 if (getenv("UCSPITLS"))
60 if (!session.command.ssl) bincClient << " STARTTLS";
61
62 const string authmethods = session.getEnv("BINCIMAP_LOGIN");
63 auto cram = authmethods.find("+CRAM-MD5");
64
65 if (session.command.ssl || session.hasEnv("ALLOW_NONSSL_PLAINTEXT_LOGINS")) {
66 if (cram != string::npos) bincClient << " AUTH=LOGIN AUTH=PLAIN AUTH=CRAM-MD5";
67 else bincClient << " AUTH=LOGIN AUTH=PLAIN";
68 } else
69 bincClient << " LOGINDISABLED";
70 }
71
72 bincClient << " IDLE LITERAL+ NAMESPACE CHILDREN";
73
74 vector<string>::const_iterator i = capabilities.begin();
75 while (i != capabilities.end()) {
76 bincClient << " " << *i;
77 ++i;
78 }
79 bincClient << endl;
80
81 return OK;
82}
83
84//----------------------------------------------------------------------
86{
87 Session &session = Session::getInstance();
88
89 if (c_in.getUidMode()) return REJECT;
90
92 if ((res = expectCRLF()) != ACCEPT) {
93 session.setLastError("Expected CRLF after CAPABILITY");
94 return res;
95 }
96
97 c_in.setName("CAPABILITY");
98
99 return ACCEPT;
100}
virtual ParseResult parse(Request &) const
void addCapability(const std::string &cap)
ProcessResult process(Depot &, Request &)
const std::string getName(void) const
void setName(const std::string &s_in)
Definition: imapparser.cc:70
bool getUidMode(void) const
Definition: imapparser.cc:40
const int getState(void) const
Definition: session.cc:40
void setLastError(const std::string &error) const
Definition: session.cc:185
@ NONAUTHENTICATED
Definition: session.h:36
@ AUTHENTICATED
Definition: session.h:37
bool ssl
Definition: session.h:30
struct Binc::Session::@3 command
static Session & getInstance(void)
Definition: session.cc:33
std::string getEnv(const std::string &key)
Definition: session.cc:230
bool hasEnv(const std::string &key) const
Definition: session.cc:224
Global constants.
#define IMAP_VERSION
Definition: globals.h:11
Declaration of the IODevice class.
Declaration of the IOFactory class.
#define bincClient
Definition: iofactory.h:31
Definition: bincimapd.cc:9
Operator::ParseResult expectCRLF(void)
Declaration of all operators.
Declaration of a recursive descent IMAP command parser.