26 const time_t LIST_CACHE_TIMEOUT = 10;
63 bincClient <<
"* LIST (\\Noselect) \"" << delim <<
"\" \"\"" << endl;
68 trim(wildcard,
string(&delim, 1));
72 string wildcardLower = regex;
74 if (wildcardLower.substr(0, 6) ==
"^inbox")
75 regex =
"^[iI][nN][bB][oO][xX]" + regex.substr(6);
79 trim(ref,
string(&delim, 1));
82 if (wildcardLower.substr(0, 6) ==
"^inbox")
83 ref =
"^[iI][nN][bB][oO][xX]" + ref.substr(6);
84 if (wildcardLower.substr(0, 5) ==
"inbox"
85 && (wildcardLower.length() == 5 || wildcardLower[5] == delim))
86 ref =
"INBOX" + ref.substr(5);
89 map<string, unsigned int> mailboxes;
97 const string path = *i;
102 if ((m = depot.
get(mpath)) == 0)
108 trim(tmp,
string(&delim, 1));
109 if (tmp ==
"")
continue;
114 if (mailboxes.find(tmp) != mailboxes.end()) flags |= mailboxes[tmp];
115 mailboxes[tmp] = flags;
120 string::size_type pos = tmp.rfind(delim);
121 while (pos != string::npos) {
122 tmp = tmp.substr(0, pos);
123 trim(tmp,
string(&delim, 1));
125 if (mailboxes.find(tmp) == mailboxes.end())
128 pos = tmp.rfind(delim);
133 map<string, unsigned int>::iterator i;
134 for (i = mailboxes.begin(); i != mailboxes.end(); ++i) {
135 string mailbox = i->first;
139 map<string, unsigned int>::const_iterator j = mailboxes.begin();
140 for (; j != mailboxes.end(); ++j) {
141 string::size_type pos = j->first.rfind(delim);
142 if (pos == string::npos)
continue;
144 string base = j->first.substr(0, pos + 1);
146 if (mailbox == base) {
153 unsigned int flags = i->second;
167 map<string, unsigned int>::iterator i = mailboxes.begin();
169 for (; i != mailboxes.end(); ++i) {
170 if (ref ==
"" || (ref.length() <= i->first.length()
171 && ref == i->first.substr(0, ref.length())))
172 if (
regexMatch(i->first.substr(ref.length()), regex) == 0) {
176 int flags = i->second;
177 bool noselect =
false;
225 session.
setLastError(
"Expected mailbox after LIST SPACE");
232 session.
setLastError(
"Expected SPACE after LIST SPACE mailbox");
238 session.
setLastError(
"Expected list_mailbox after LIST SPACE"
244 session.
setLastError(
"Expected CRLF after LIST SPACE mailbox"
245 " SPACE list_mailbox");
virtual Mailbox * get(const std::string &path) const
virtual iterator begin(const std::string &) const
virtual const iterator & end(void) const
const char getDelimiter(void) const
virtual std::string filenameToMailbox(const std::string &m) const =0
virtual ParseResult parse(Request &) const
std::map< std::string, unsigned int > cache
ProcessResult process(Depot &, Request &)
const std::string getName(void) const
virtual bool isMarked(const std::string &) const =0
void setMailbox(const std::string &s_in)
void setName(const std::string &s_in)
const std::string & getListMailbox(void) const
const std::string & getMailbox(void) const
bool getUidMode(void) const
void setListMailbox(const std::string &s_in)
void setLastError(const std::string &error) const
static Session & getInstance(void)
Declaration of miscellaneous convertion functions.
Declaration of the IODevice class.
Declaration of the IOFactory class.
Declaration of the Mailbox class (Mailbox is logical container)
std::string toImapString(const std::string &s_in)
Operator::ParseResult expectSPACE(void)
std::string toCanonMailbox(const std::string &s_in)
std::string toRegex(const std::string &s_in, char delimiter)
int regexMatch(const std::string &data_in, const std::string &p_in)
Operator::ParseResult expectListMailbox(std::string &s_in)
void lowercase(std::string &input)
void trim(std::string &s_in, const std::string &chars=" \t\r\n")
Operator::ParseResult expectCRLF(void)
Operator::ParseResult expectMailbox(std::string &s_in)
Declaration of all operators.
Declaration of a recursive descent IMAP command parser.