From 3ea7edf8c9bf7583c426178d4aaff4fb5b736bd2 Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Wed, 11 Oct 2023 19:28:50 +0200 Subject: use some enum classes move ParseResult to recursivedescent.h --- src/operator-login.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/operator-login.cc') diff --git a/src/operator-login.cc b/src/operator-login.cc index db091aa..cef8acb 100644 --- a/src/operator-login.cc +++ b/src/operator-login.cc @@ -34,7 +34,7 @@ const std::string LoginOperator::getName() const return "LOGIN"; } -int LoginOperator::getState() const +Session::State LoginOperator::getState() const { return Session::NONAUTHENTICATED; } @@ -46,7 +46,7 @@ Operator::ProcessResult LoginOperator::process(Depot &depot, Request &command) if (!session.command.ssl && !session.hasEnv("ALLOW_NONSSL_PLAINTEXT_LOGINS")) { session.setLastError("Plain text password authentication is disallowd. " "Please enable StartTLS or TLS in your mail client."); - return NO; + return Operator::ProcessResult::NO; } session.setEnv("BINCIMAP_LOGIN", "LOGIN+" + command.getTag()); @@ -57,13 +57,13 @@ Operator::ProcessResult LoginOperator::process(Depot &depot, Request &command) session.setLastError("An internal error occurred when you attempted " "to log in to the IMAP server. Please contact " "your system administrator."); - return NO; + return Operator::ProcessResult::NO; case 2: session.setLastError("Login failed. Either your user name " "or your password was wrong. Please try again, " "and if the problem persists, please contact " "your system administrator."); - return NO; + return Operator::ProcessResult::NO; case 3: bincClient << "* BYE Timeout after " << IDLE_TIMEOUT << " seconds of inactivity." << std::endl; @@ -78,16 +78,18 @@ Operator::ProcessResult LoginOperator::process(Depot &depot, Request &command) // go to logout session.setState(Session::LOGOUT); - return NOTHING; + return Operator::ProcessResult::NOTHING; } -Operator::ParseResult LoginOperator::parse(Request &c_in) const +Parser::ParseResult LoginOperator::parse(Request &c_in) { + constexpr auto ACCEPT = Parser::ParseResult::ACCEPT; + Session &session = Session::getInstance(); - if (c_in.getUidMode()) return REJECT; + if (c_in.getUidMode()) return Parser::ParseResult::REJECT; - Operator::ParseResult res; + Parser::ParseResult res; if ((res = expectSPACE()) != ACCEPT) { session.setLastError("Expected single SPACE after LOGIN"); return res; -- cgit v1.2.3