23 const int DIR_SELECT = 0x01;
24 const int DIR_MARKED = 0x02;
25 const int DIR_NOINFERIORS = 0x04;
26 const int DIR_LEAF = 0x08;
62 trim(wildcard,
string(&delim, 1));
66 string wildcardLower = regex;
68 if (wildcardLower.substr(0, 6) ==
"^inbox")
69 regex =
"^[iI][nN][bB][oO][xX]" + regex.substr(6);
73 trim(ref,
string(&delim, 1));
76 if (wildcardLower.substr(0, 5) ==
"inbox"
77 && (wildcardLower.length() == 5 || wildcardLower[5] == delim))
78 ref =
"INBOX" + ref.substr(5);
81 multimap<string, int> mailboxes;
85 const string path = *i;
90 if ((m = depot.
get(mpath)) == 0)
96 trim(tmp,
string(&delim, 1));
100 int flags = DIR_SELECT;
101 multimap<string, int>::iterator mi = mailboxes.find(tmp);
102 if (mi != mailboxes.end()) {
106 mailboxes.insert(make_pair(tmp, flags));
111 string::size_type pos = tmp.rfind(delim);
112 while (pos != string::npos) {
113 tmp = tmp.substr(0, pos);
114 trim(tmp,
string(&delim, 1));
116 multimap<string, int>::iterator mi = mailboxes.find(tmp);
117 if (mi == mailboxes.end()) mailboxes.insert(make_pair(tmp, 0));
119 pos = tmp.rfind(delim);
124 multimap<string, int>::iterator i;
125 for (i = mailboxes.begin(); i != mailboxes.end(); ++i) {
126 string mailbox = i->first;
130 multimap<string, int>::const_iterator j;
131 for (j = mailboxes.begin(); j != mailboxes.end(); ++j) {
132 string::size_type pos = j->first.rfind(delim);
133 if (pos == string::npos)
continue;
134 string base = j->first.substr(0, pos + 1);
135 if (mailbox == base) {
141 unsigned int flags = i->second;
150 sort(subscribed.begin(), subscribed.end());
153 for (vector<string>::const_iterator j = subscribed.begin();
154 j != subscribed.end(); ++j) {
155 if (ref ==
"" || (ref.length() <= (*j).length() && ref == (*j).substr(0, ref.length())))
156 if (
regexMatch((*j).substr(ref.length()), regex) == 0) {
158 for (i = mailboxes.begin(); i != mailboxes.end(); ++i) {
159 if (i->first == *j) {
166 bool noselect =
false;
167 if (!(flags & DIR_SELECT)) {
173 if (flags & DIR_MARKED)
179 if (flags & DIR_LEAF)
184 if (flags & DIR_NOINFERIORS)
210 session.
setLastError(
"Expected mailbox after LSUB SPACE");
217 session.
setLastError(
"Expected SPACE after LSUB SPACE mailbox");
223 session.
setLastError(
"Expected list_mailbox after LSUB SPACE"
230 " mailbox SPACE list_mailbox");
virtual Mailbox * get(const std::string &path) const
virtual iterator begin(const std::string &) const
virtual void loadSubscribes(void)
virtual const iterator & end(void) const
const char getDelimiter(void) const
virtual std::string filenameToMailbox(const std::string &m) const =0
virtual std::vector< std::string > getSubscriptions(void) const
virtual ParseResult parse(Request &) const
ProcessResult process(Depot &, Request &)
const std::string getName(void) const
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.