diff options
Diffstat (limited to 'src/operator-idle.cc')
-rw-r--r-- | src/operator-idle.cc | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/operator-idle.cc b/src/operator-idle.cc index 369bcd9..ff95dbf 100644 --- a/src/operator-idle.cc +++ b/src/operator-idle.cc @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file operator-idle.cc * @brief Operator for the IDLE command. Described in RFC2177 / June 1997. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ------------------------------------------------------------------ **/ + */ + #include "convert.h" #include "depot.h" #include "globals.h" @@ -36,8 +37,8 @@ void fnotifyEventHandler(int sig) } #endif -using namespace ::std; using namespace Binc; +using std::endl; // Seconds between each poll. With FNOTIFY support, we can idle for 30 // minutes before timing out. @@ -47,29 +48,24 @@ static const int POLLTIMEOUT = 30 * 60; static const int POLLTIMEOUT = 30; #endif -//---------------------------------------------------------------------- IdleOperator::IdleOperator(void) {} -//---------------------------------------------------------------------- IdleOperator::~IdleOperator(void) {} -//---------------------------------------------------------------------- -const string IdleOperator::getName(void) const +const std::string IdleOperator::getName(void) const { return "IDLE"; } -//---------------------------------------------------------------------- int IdleOperator::getState(void) const { return Session::SELECTED; } -//---------------------------------------------------------------------- Operator::ProcessResult IdleOperator::process(Depot &depot, Request &command) { Mailbox *mailbox = depot.getSelected(); - string mailboxDir = depot.mailboxToFilename(mailbox->getName()); + std::string mailboxDir = depot.mailboxToFilename(mailbox->getName()); #ifdef HAVE_FNOTIFY // Check for FNOTIFY support. @@ -93,7 +89,7 @@ Operator::ProcessResult IdleOperator::process(Depot &depot, Request &command) #endif // when not using FNOTIFY, we need to check the session timeout. - time_t startTime = time(0); + time_t startTime = time(nullptr); #ifdef HAVE_FNOTIFY (void)startTime; // removes a compile warning #endif @@ -110,9 +106,9 @@ Operator::ProcessResult IdleOperator::process(Depot &depot, Request &command) // check for data from stdin. with FNOTIFY enabled, this select // will be interrupted by the notification signal. - string input; + std::string input; struct timeval tv = {POLLTIMEOUT, 0}; - int ret = select(maxfd + 1, &readfds, 0, 0, &tv); + int ret = select(maxfd + 1, &readfds, nullptr, nullptr, &tv); // check if the select timed out. if (ret == 0) { @@ -126,7 +122,7 @@ Operator::ProcessResult IdleOperator::process(Depot &depot, Request &command) return NOTHING; } else #endif - if (time(0) > startTime + IDLE_TIMEOUT) + if (time(nullptr) > startTime + IDLE_TIMEOUT) { bincClient << "* BYE Timeout after " << IDLE_TIMEOUT << " seconds of inactivity." << endl; session.setState(Session::LOGOUT); @@ -136,7 +132,7 @@ Operator::ProcessResult IdleOperator::process(Depot &depot, Request &command) // unless the select failed, attempt to read client input. if (ret > 0 && FD_ISSET(0, &readfds)) { - if (bincClient.readStr(&input) == 0) { + if (bincClient.readStr(&input) == false) { break; } else { uppercase(input); @@ -170,11 +166,10 @@ Operator::ProcessResult IdleOperator::process(Depot &depot, Request &command) } // scan for changes in the mailbox and report to the client. - if (pendingUpdates(mailbox, - PendingUpdates::EXPUNGE | PendingUpdates::EXISTS | PendingUpdates::RECENT - | PendingUpdates::FLAGS, - true) - == false) + if (!pendingUpdates(mailbox, + PendingUpdates::EXPUNGE | PendingUpdates::EXISTS | PendingUpdates::RECENT + | PendingUpdates::FLAGS, + true)) { Session &session = Session::getInstance(); bincClient << "* NO " << session.getLastError() << endl; @@ -217,7 +212,6 @@ Operator::ProcessResult IdleOperator::process(Depot &depot, Request &command) return OK; } -//---------------------------------------------------------------------- Operator::ParseResult IdleOperator::parse(Request &c_in) const { Session &session = Session::getInstance(); |