diff options
Diffstat (limited to 'src/operator-store.cc')
-rw-r--r-- | src/operator-store.cc | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/src/operator-store.cc b/src/operator-store.cc index b6e1b99..160002a 100644 --- a/src/operator-store.cc +++ b/src/operator-store.cc @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file operator-store.cc * @brief Implementation of the STORE command * @author Andreas Aardal Hanssen * @date 2002-2005 - * ------------------------------------------------------------------ **/ + */ + #include "depot.h" #include "imapparser.h" #include "mailbox.h" @@ -15,28 +16,24 @@ #include <iostream> #include <string> -using namespace ::std; using namespace Binc; +using std::string; +using std::vector; -//---------------------------------------------------------------------- StoreOperator::StoreOperator(void) {} -//---------------------------------------------------------------------- StoreOperator::~StoreOperator(void) {} -//---------------------------------------------------------------------- const string StoreOperator::getName(void) const { return "STORE"; } -//---------------------------------------------------------------------- int StoreOperator::getState(void) const { return Session::SELECTED; } -//------------------------------------------------------------------------ Operator::ProcessResult StoreOperator::process(Depot &depot, Request &command) { Mailbox *mailbox = depot.getSelected(); @@ -44,22 +41,19 @@ Operator::ProcessResult StoreOperator::process(Depot &depot, Request &command) // mask all passed flags together unsigned int newflags = (unsigned int)Message::F_NONE; vector<string> newCustomFlags; - vector<string>::const_iterator f_i = command.flags.begin(); - while (f_i != command.flags.end()) { - if (*f_i == "\\Deleted") + for (const auto &f_i : command.flags) { + if (f_i == "\\Deleted") newflags |= Message::F_DELETED; - else if (*f_i == "\\Answered") + else if (f_i == "\\Answered") newflags |= Message::F_ANSWERED; - else if (*f_i == "\\Seen") + else if (f_i == "\\Seen") newflags |= Message::F_SEEN; - else if (*f_i == "\\Draft") + else if (f_i == "\\Draft") newflags |= Message::F_DRAFT; - else if (*f_i == "\\Flagged") + else if (f_i == "\\Flagged") newflags |= Message::F_FLAGGED; else - newCustomFlags.push_back(*f_i); - - ++f_i; + newCustomFlags.push_back(f_i); } // pass through all messages @@ -80,19 +74,19 @@ Operator::ProcessResult StoreOperator::process(Depot &depot, Request &command) switch (command.getMode()[0]) { case '+': flags |= newflags; - for (vector<string>::const_iterator it = newCustomFlags.begin(); it != newCustomFlags.end(); ++it) - message.setCustomFlag(*it); + for (const auto &it : newCustomFlags) + message.setCustomFlag(it); break; case '-': flags &= ~newflags; - for (vector<string>::const_iterator it = newCustomFlags.begin(); it != newCustomFlags.end(); ++it) - message.removeCustomFlag(*it); + for (const auto &it : newCustomFlags) + message.removeCustomFlag(it); break; default: flags = newflags; message.resetCustomFlags(); - for (vector<string>::const_iterator it = newCustomFlags.begin(); it != newCustomFlags.end(); ++it) - message.setCustomFlag(*it); + for (const auto &it : newCustomFlags) + message.setCustomFlag(it); break; }; @@ -106,14 +100,14 @@ Operator::ProcessResult StoreOperator::process(Depot &depot, Request &command) mailbox->updateFlags(); // check mailbox for updates, and report them - if (command.getMode().find(".SILENT") != string::npos) + if (command.getMode().find(".SILENT") != string::npos) { pendingUpdates(mailbox, PendingUpdates::EXISTS | PendingUpdates::RECENT, false, false, false, command.getUidMode()); - else + } else { pendingUpdates(mailbox, PendingUpdates::EXISTS | PendingUpdates::RECENT | PendingUpdates::EXPUNGE | PendingUpdates::FLAGS, @@ -121,11 +115,11 @@ Operator::ProcessResult StoreOperator::process(Depot &depot, Request &command) false, false, command.getUidMode()); + } return OK; } -//---------------------------------------------------------------------- Operator::ParseResult StoreOperator::parse(Request &c_in) const { Session &session = Session::getInstance(); @@ -155,8 +149,9 @@ Operator::ParseResult StoreOperator::parse(Request &c_in) const if ((res = expectThisString("FLAGS")) != ACCEPT) { session.setLastError("Expected FLAGS"); return res; - } else + } else { mode += "FLAGS"; + } if ((res = expectThisString(".SILENT")) == ACCEPT) mode += ".SILENT"; @@ -170,7 +165,7 @@ Operator::ParseResult StoreOperator::parse(Request &c_in) const bool paren = false; if ((res = expectThisString("(")) == ACCEPT) paren = true; - if ((res = expectFlag(c_in.getFlags())) == ACCEPT) + if ((res = expectFlag(c_in.getFlags())) == ACCEPT) { while (1) { if ((res = expectSPACE()) != ACCEPT) break; @@ -179,12 +174,14 @@ Operator::ParseResult StoreOperator::parse(Request &c_in) const return res; } } + } - if (paren) + if (paren) { if ((res = expectThisString(")")) != ACCEPT) { session.setLastError("Expected )"); return res; } + } if ((res = expectCRLF()) != ACCEPT) { session.setLastError("Expected CRLF"); |