void mail::imapCREATE::installed(mail::imap &imapAccount) { // First things first, get the hier separator. imapAccount.imapcmd("CREATE", "LIST " + imapAccount.quoteSimple(parentPath + "tree") + " \"\"\r\n"); }
void mail::imapListHandler::installed(mail::imap &imapAccount) { const char *sep="%"; if (oneFolderOnly) sep=""; imapAccount.imapcmd("LIST", "LIST \"\" " + imapAccount.quoteSimple(hier + sep) + "\r\n"); }
bool mail::imapListHandler::taggedMessage(mail::imap &imapAccount, string name, string message, bool okfail, string errmsg) { if (name != "LIST") return false; if (okfail && oneFolderOnly && !fallbackOneFolderOnly && folders.size() == 0) { fallbackOneFolderOnly=true; imapAccount.imapcmd("LIST", "LIST " + imapAccount.quoteSimple(hier) + " \"\"\r\n"); return true; } if (okfail) { vector<const mail::folder *> folderPtrs; vector<mail::imapFolder>::iterator b, e; b=folders.begin(); e=folders.end(); while (b != e) { if (fallbackOneFolderOnly) { b->path=hier; } folderPtrs.push_back( &*b); b++; } callback1.success(folderPtrs); callback2.success("OK"); } else callback2.fail(errmsg); imapAccount.uninstallHandler(this); return true; }
void mail::imapAPPEND::installed(mail::imap &imapAccount) { myPusher=new Pusher(); if (!myPusher) LIBMAIL_THROW("Out of memory."); try { imapAccount.imapcmd("APPEND", appendcmd); imapAccount.socketWrite(myPusher); myPusher->myappend=this; } catch (...) { delete myPusher; myPusher=NULL; } }
void mail::imapDELETE::installed(mail::imap &imapAccount) { imapAccount.imapcmd("DELETE", "DELETE " + imapAccount.quoteSimple(path) + "\r\n"); }
bool mail::imapCREATE::taggedMessage(mail::imap &imapAccount, string msgname, string message, bool okfail, string errmsg) { if (msgname != "CREATE") return false; if (!okfail) { callback2.fail(errmsg); imapAccount.uninstallHandler(this); return true; } if (!listHierSent) { if (hiersep.size() == 0) { callback2.fail("IMAP server failed to process the LIST command."); imapAccount.uninstallHandler(this); return true; } listHierSent=true; encodedname=name; // The folder name should be utf7-encoded { char *p=libmail_u_convert_toutf8(encodedname.c_str(), unicode_default_chset(), NULL); if (!p && strchr(p, *hiersep[0].getHierSep().c_str()) != NULL) { if (p) free(p); callback2.fail("Folder name contains an invalid character."); imapAccount.uninstallHandler(this); return true; } free(p); p=libmail_u_convert_tobuf(encodedname.c_str(), unicode_default_chset(), unicode_x_imap_modutf7, NULL); if (p) { try { encodedname=p; free(p); } catch (...) { free(p); LIBMAIL_THROW(LIBMAIL_THROW_EMPTY); } } } imapAccount.imapcmd("CREATE", (renamePath.size() > 0 ? string("RENAME ") + imapAccount.quoteSimple(renamePath) + " ": string("CREATE ")) + imapAccount .quoteSimple(parentPath + encodedname + (!hasMessages ? hiersep[0].getHierSep() :"")) + "\r\n"); return true; } mail::imapFolder new_folder(imapAccount, parentPath + encodedname, hiersep[0].getHierSep(), name, -1); new_folder.hasMessages(hasMessages); new_folder.hasSubFolders(hasSubfolders); vector<const mail::folder *> dummy_list; dummy_list.push_back(&new_folder); callback1.success(dummy_list); callback2.success(errmsg); imapAccount.uninstallHandler(this); return true; }