23DepotFactory::DepotFactory(
void)
30 for (vector<Depot *>::iterator i = depots.begin(); i != depots.end();
38 for (vector<Depot *>::const_iterator i = depots.begin(); i != depots.end();
40 if ((*i)->getName() == name)
49 depots.push_back(depot);
99 for (vector<Mailbox *>::const_iterator i = backends.begin();
100 i != backends.end(); ++i)
103 backends.push_back(m);
109 for (vector<Mailbox *>::const_iterator i = backends.begin();
110 i != backends.end(); ++i)
121 for (vector<Mailbox *>::const_iterator i = backends.begin();
122 i != backends.end(); ++i)
128 setLastError(
"Attempted to select unregistered Mailbox type in Depot");
141 return personalNamespace;
147 return othersNamespace;
153 return sharedNamespace;
171 for (vector<Mailbox *>::const_iterator i = backends.begin();
172 i != backends.end(); ++i)
173 if ((*i)->getTypeName() ==
name) {
185 return selectedmailbox;
197 return defaultmailbox;
204 if (mailboxname ==
"") {
255 if (entry.substr(0, source.length()) == source) {
256 string sourcename, destname;
258 if (entry.length() == source.length()) {
262 }
else if (entry.length() > source.length()
263 && entry[source.length()] ==
'.') {
265 destname = dest + entry.substr(source.length());
268 if (rename(sourcename.c_str(), destname.c_str()) != 0) {
269 bincWarning <<
"error renaming " << sourcename <<
" to "
270 << destname <<
": " << strerror(errno) << endl;
286 +
". Try creating a new mailbox,"
287 " then copy over all messages."
288 " Finally, delete the original mailbox");
330 for (vector<string>::iterator i = subscribed.begin();
331 i != subscribed.end(); ++i) {
336 subscribed.push_back(mailbox);
342 for (vector<string>::iterator i = subscribed.begin();
343 i != subscribed.end(); ++i) {
361 FILE *fp = fopen(
".subscribed",
"r");
362 map<string, bool> addedEntries;
366 while ((c = fgetc(fp)) != EOF) {
369 if (current ==
"INBOX")
372 if (current.substr(0, 5) ==
"INBOX")
373 current = current.substr(5);
375 if (addedEntries.find(current) == addedEntries.end()) {
377 addedEntries[current] =
true;
390 subscribed.push_back(
"INBOX");
399 string tpl =
".subscribed-tmp-XXXXXX";
400 char *ftemplate =
new char[tpl.length() + 1];
402 strcpy(ftemplate, tpl.c_str());
403 int fd = mkstemp(ftemplate);
405 bincWarning <<
"unable to create temporary file \""
406 << tpl <<
"\"" << endl;
411 map<string, bool> addedEntries;
412 for (vector<string>::const_iterator i = subscribed.begin();
413 i != subscribed.end(); ++i) {
414 if (addedEntries.find(*i) == addedEntries.end()) {
415 addedEntries[*i] =
true;
417 if (write(fd, w.c_str(), w.length()) != (ssize_t) w.length()) {
418 bincWarning <<
"failed to write to " << tpl <<
": "
419 << strerror(errno) << endl;
425 if ((fsync(fd) && (errno != EROFS || errno != EINVAL)) || close(fd)) {
427 <<
": " << strerror(errno) << endl;
432 if (rename(ftemplate,
".subscribed") != 0) {
434 <<
" to .subscribed: "
435 << strerror(errno) << endl;
470 direntp = copy.direntp;
489 direntp = copy.direntp;
498 if (*ref != 0 && --(*ref) == 0) {
515 return direntp->d_name;
521 direntp = readdir(dirp);
527 return direntp == i.direntp;
533 return direntp != i.direntp;
541 if ((i.dirp = opendir(path.c_str())) == 0) {
542 bincWarning <<
"opendir on " << path <<
" failed" << endl;
560 privateNamespace =
"INBOX";
572 return privateNamespace;
578 string prefix =
"INBOX"; prefix +=
delimiter;
584 if (tmp !=
"INBOX" && tmp.substr(0, 6) != prefix) {
585 setLastError(
"With a Maildir++ depot, you must create all"
586 " mailboxes under INBOX. Try creating"
587 " " + prefix + mm +
" .");
595 if (mm ==
"INBOX")
return ".";
596 else if (mm.length() <= 6) {
597 setLastError(
"With a Maildir++ depot, you must create all"
598 " mailboxes under INBOX.");
600 }
else if (mm.substr(0, 6) != prefix) {
601 setLastError(
"With a Maildir++ depot, you must create all"
602 " mailboxes under INBOX.");
604 }
else if (mm.find(twodelim) != string::npos) {
606 + twodelim +
" in mailbox name");
608 }
else if (mm !=
"" &&
delimiter !=
'.' && mm.substr(1).find(
'.') != string::npos) {
612 string tmp = mm.substr(6);
613 for (string::iterator i = tmp.begin(); i != tmp.end(); ++i)
623 if (m ==
".")
return "INBOX";
625 else if (m !=
"" && m[0] ==
'.') {
627 for (string::iterator i = tmp.begin(); i != tmp.end(); ++i)
630 return "INBOX" + tmp;
655 if (mm.find(twodelim) != string::npos) {
657 + twodelim +
" in mailbox name");
661 string::const_iterator i = mm.begin();
662 while (i != mm.end()) {
665 }
else if (*i ==
'\\') {
667 }
else if (*i ==
'.') {
689 if (m ==
"." || m ==
"..")
692 string::const_iterator i = m.begin();
693 while (i != m.end()) {
695 if (i != m.begin() && !escape) tmp +=
delimiter;
696 else if (i == m.begin() || escape) tmp +=
'.';
698 }
else if (*i ==
'\\') {
699 if (!escape) escape =
true;
else {
706 if (escape)
return "";
std::string operator*(void) const
iterator & operator=(const iterator ©)
bool operator==(iterator) const
bool operator!=(iterator) const
static DepotFactory & getInstance(void)
Depot * get(const std::string &name) const
virtual Mailbox * get(const std::string &path) const
virtual iterator begin(const std::string &) const
const std::string & getName(void) const
std::map< std::string, Status > mailboxstatuses
virtual void loadSubscribes(void)
virtual const std::string & getOthersNamespace(void) const
void setLastError(const std::string &error) const
virtual bool setSelected(Mailbox *)
virtual bool saveSubscribes(void) const
virtual const iterator & end(void) const
const std::string & getLastError(void) const
virtual void assign(Mailbox *)
Mailbox * getDefault(void) const
virtual void subscribeTo(const std::string mailbox)
virtual bool deleteMailbox(const std::string &m) const
virtual std::string mailboxToFilename(const std::string &m) const =0
virtual bool createMailbox(const std::string &m) const
virtual bool renameMailbox(const std::string &m, const std::string &n) const
virtual const std::string & getPersonalNamespace(void) const
virtual const std::string & getSharedNamespace(void) const
bool getStatus(const std::string &s_in, Status &dest) const
bool setDefaultType(const std::string &n)
virtual Mailbox * getSelected(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 bool unsubscribeTo(const std::string mailbox)
std::string filenameToMailbox(const std::string &m) const
std::string mailboxToFilename(const std::string &m) const
const std::string & getLastError(void) const
virtual bool createMailbox(const std::string &s, mode_t mode, uid_t owner=0, gid_t group=0, bool root=false)=0
virtual bool deleteMailbox(const std::string &s)=0
virtual void bumpUidValidity(const std::string &) const =0
virtual unsigned int getStatusID(const std::string &) const =0
virtual bool getStatus(const std::string &, Status &) const =0
std::string filenameToMailbox(const std::string &m) const
std::string mailboxToFilename(const std::string &m) const
const std::string & getPersonalNamespace(void) const
int getStatusID(void) const
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)
std::string toCanonMailbox(const std::string &s_in)
void uppercase(std::string &input)
void trim(std::string &s_in, const std::string &chars=" \t\r\n")
Declaration of the Status class.