summaryrefslogtreecommitdiff
path: root/src/operator-lsub.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/operator-lsub.cc')
-rw-r--r--src/operator-lsub.cc39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/operator-lsub.cc b/src/operator-lsub.cc
index e2bd07d..35c4d7d 100644
--- a/src/operator-lsub.cc
+++ b/src/operator-lsub.cc
@@ -1,9 +1,10 @@
-/** --------------------------------------------------------------------
+/**
* @file operator-lsub.cc
* @brief Implementation of the LSUB command.
* @author Andreas Aardal Hanssen
* @date 2002-2005
- * ----------------------------------------------------------------- **/
+ */
+
#include "convert.h"
#include "depot.h"
#include "iodevice.h"
@@ -26,28 +27,24 @@ namespace {
const int DIR_LEAF = 0x08;
}
-using namespace ::std;
using namespace Binc;
+using std::multimap;
+using std::string;
-//----------------------------------------------------------------------
LsubOperator::LsubOperator(void) {}
-//----------------------------------------------------------------------
LsubOperator::~LsubOperator(void) {}
-//----------------------------------------------------------------------
const string LsubOperator::getName(void) const
{
return "LSUB";
}
-//----------------------------------------------------------------------
int LsubOperator::getState(void) const
{
return Session::AUTHENTICATED | Session::SELECTED;
}
-//------------------------------------------------------------------------
Operator::ProcessResult LsubOperator::process(Depot &depot, Request &command)
{
const char delim = depot.getDelimiter();
@@ -69,27 +66,29 @@ Operator::ProcessResult LsubOperator::process(Depot &depot, Request &command)
lowercase(wildcardLower);
if (wildcardLower.substr(0, 5) == "inbox"
&& (wildcardLower.length() == 5 || wildcardLower[5] == delim))
+ {
ref = "INBOX" + ref.substr(5);
+ }
// a multimap from mailbox name to flags
multimap<string, int> mailboxes;
// read through all entries in depository.
- for (Depot::iterator i = depot.begin("."); i != depot.end(); ++i) {
+ for (auto i = depot.begin("."); i != depot.end(); ++i) {
const string path = *i;
const string mpath = depot.filenameToMailbox(path);
- Mailbox *m = 0;
+ Mailbox *m = nullptr;
// skip entries that are not identified as mailboxes
- if ((m = depot.get(mpath)) == 0) continue;
+ if ((m = depot.get(mpath)) == nullptr) continue;
// convert file name to mailbox name. skip it if there is no
// corresponding mailbox name.
string tmp = toCanonMailbox(depot.filenameToMailbox(path));
trim(tmp, string(&delim, 1));
- if (tmp == "")
+ if (tmp == "") {
continue;
- else {
+ } else {
int flags = DIR_SELECT;
multimap<string, int>::iterator mi = mailboxes.find(tmp);
if (mi != mailboxes.end()) {
@@ -139,16 +138,16 @@ Operator::ProcessResult LsubOperator::process(Depot &depot, Request &command)
depot.loadSubscribes();
- vector<string> subscribed = depot.getSubscriptions();
+ std::vector<string> subscribed = depot.getSubscriptions();
sort(subscribed.begin(), subscribed.end());
// finally, print all mailbox entries with flags.
- for (vector<string>::const_iterator j = subscribed.begin(); j != subscribed.end(); ++j) {
- if (ref == "" || (ref.length() <= (*j).length() && ref == (*j).substr(0, ref.length())))
- if (regexMatch((*j).substr(ref.length()), regex) == 0) {
+ for (const auto &j : subscribed) {
+ if (ref == "" || (ref.length() <= j.length() && ref == j.substr(0, ref.length()))) {
+ if (regexMatch(j.substr(ref.length()), regex) == 0) {
int flags = 0;
for (i = mailboxes.begin(); i != mailboxes.end(); ++i) {
- if (i->first == *j) {
+ if (i->first == j) {
flags = i->second;
break;
}
@@ -174,14 +173,14 @@ Operator::ProcessResult LsubOperator::process(Depot &depot, Request &command)
bincClient << sep << "\\HasChildren";
sep = " ";
if (flags & DIR_NOINFERIORS) bincClient << sep << "\\Noinferiors";
- bincClient << ") \"" << depot.getDelimiter() << "\" " << toImapString(*j) << endl;
+ bincClient << ") \"" << depot.getDelimiter() << "\" " << toImapString(j) << std::endl;
}
+ }
}
return OK;
}
-//----------------------------------------------------------------------
Operator::ParseResult LsubOperator::parse(Request &c_in) const
{
Session &session = Session::getInstance();