diff options
Diffstat (limited to 'src/operator-copy.cc')
-rw-r--r-- | src/operator-copy.cc | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/operator-copy.cc b/src/operator-copy.cc index 50afe77..77e1b9d 100644 --- a/src/operator-copy.cc +++ b/src/operator-copy.cc @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file operator-copy.cc * @brief Implementation of the COPY command. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #include "convert.h" #include "depot.h" #include "iodevice.h" @@ -15,28 +16,23 @@ #include <string> -using namespace ::std; using namespace Binc; +using std::string; -//---------------------------------------------------------------------- CopyOperator::CopyOperator(void) {} -//---------------------------------------------------------------------- CopyOperator::~CopyOperator(void) {} -//---------------------------------------------------------------------- const string CopyOperator::getName(void) const { return "COPY"; } -//---------------------------------------------------------------------- int CopyOperator::getState(void) const { return Session::SELECTED; } -//------------------------------------------------------------------------ Operator::ProcessResult CopyOperator::process(Depot &depot, Request &command) { Session &session = Session::getInstance(); @@ -47,7 +43,7 @@ Operator::ProcessResult CopyOperator::process(Depot &depot, Request &command) // Get the destination mailbox string dmailbox = command.getMailbox(); Mailbox *destMailbox = depot.get(toCanonMailbox(dmailbox)); - if (destMailbox == 0) { + if (destMailbox == nullptr) { session.setResponseCode("TRYCREATE"); session.setLastError("invalid mailbox " + toImapString(dmailbox)); return NO; @@ -84,14 +80,14 @@ Operator::ProcessResult CopyOperator::process(Depot &depot, Request &command) do { int readSize = source.readChunk(chunk); - if (readSize == 0) + if (readSize == 0) { break; - else if (readSize == -1) { + } else if (readSize == -1) { bincWarning << "when reading from message " << i.getSqnr() << "/" << source.getUID() << " in \"" - << srcMailbox->getName() << "\": " << source.getLastError() << endl; + << srcMailbox->getName() << "\": " << source.getLastError() << std::endl; success = false; } else if (!dest->appendChunk(chunk)) { - bincWarning << "when writing to \"" << dmailbox << "\": " << dest->getLastError() << endl; + bincWarning << "when writing to \"" << dmailbox << "\": " << dest->getLastError() << std::endl; success = false; } } while (success); @@ -104,21 +100,22 @@ Operator::ProcessResult CopyOperator::process(Depot &depot, Request &command) return NO; } - if (success) + if (success) { if (!destMailbox->commitNewMessages(depot.mailboxToFilename(toCanonMailbox(dmailbox)))) { session.setLastError("Failed to commit after successful copy: " + destMailbox->getLastError()); return NO; } + } - if (!success) + if (!success) { session.setLastError("The transaction was unrolled. Please " "contant your system administrator for " "more information."); + } return success ? OK : NO; } -//------------------------------------------------------------------------ Operator::ParseResult CopyOperator::parse(Request &c_in) const { Session &session = Session::getInstance(); |