本文整理汇总了C++中mail::callback类的典型用法代码示例。如果您正苦于以下问题:C++ callback类的具体用法?C++ callback怎么用?C++ callback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了callback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
void mail::addressbook::getEntry( string uid,
vector<T> &addrListArg,
mail::callback &callback)
{
size_t n=index.size();
size_t i;
for (i=0; i<n; i++)
if (server->getFolderIndexInfo(i).uid == uid)
{
GetAddressList<T> *get=
new GetAddressList<T>(this, i,
addrListArg,
callback);
if (!get)
{
callback.fail(strerror(errno));
return;
}
try {
get->go();
} catch (...) {
delete get;
LIBMAIL_THROW(LIBMAIL_THROW_EMPTY);
}
return;
}
callback.success("NOT FOUND.");
}
示例2: catch
void mail::maildir::folder::destroy(mail::callback &callback,
bool destroyDir) const
{
if (isDestroyed(callback))
return;
if (!destroyDir) // Folder directories are imaginary, cannot be nuked
{
string s;
char *d=maildir_name2dir(maildirAccount->path.c_str(),
path.c_str());
if (!d)
{
callback.fail(strerror(errno));
return;
}
try {
s=d;
free(d);
} catch (...) {
free(d);
LIBMAIL_THROW(LIBMAIL_THROW_EMPTY);
}
if (!mail::maildir::maildirdestroy(s))
{
callback.fail(strerror(errno));
return;
}
}
callback.success("Mail folder deleted");
}
示例3: DOFLAG
void mail::maildir::saveFolderIndexInfo(size_t msgNum,
const mail::messageInfo &info,
mail::callback &callback)
{
if (msgNum >= index.size())
{
callback.success("OK");
return;
}
mail::messageInfo &newFlags=index[msgNum];
#define DOFLAG(dummy, field, dummy2) \
newFlags.field=info.field;
LIBMAIL_MSGFLAGS;
#undef DOFLAG
string errmsg="Message updated";
if (!updateFlags(msgNum))
errmsg="Folder opened in read-only mode.";
callback.success(errmsg);
}
示例4:
void mail::maildir::folder::readFolderInfo( mail::callback::folderInfo
&callback1,
mail::callback &callback2) const
{
if (isDestroyed(callback2))
return;
callback1.messageCount=0;
callback1.unreadCount=0;
vector<maildirMessageInfo> dummyIndex;
if (!maildirAccount->scan(path, dummyIndex, true))
{
callback1.success();
callback2.fail("Invalid folder");
return;
}
vector<maildirMessageInfo>::iterator b=dummyIndex.begin(),
e=dummyIndex.end();
while (b != e)
{
callback1.messageCount++;
if ( b->unread)
callback1.unreadCount++;
b++;
}
callback1.success();
callback2.success("OK");
}
示例5: smapCREATE
void mail::imapFolder::createSubFolder(string name, bool isDirectory,
mail::callback::folderList &callback1,
mail::callback &callback2) const
{
if (isDestroyed(callback2))
return;
if (!imapAccount.ready(callback2))
return;
if (imapAccount.smap)
{
mail::smapCREATE *h=
new mail::smapCREATE(path, name, isDirectory,
callback1, callback2);
if (!h)
{
callback2.fail(strerror(errno));
return;
}
try {
imapAccount.installForegroundTask(h);
} catch (...) {
delete h;
throw;
}
return;
}
mail::imapCREATE *h=new mail::imapCREATE(path + hiersep,
name,
!isDirectory,
isDirectory,
callback1,
callback2);
if (!h)
{
callback2.fail(strerror(errno));
return;
}
try {
imapAccount.installForegroundTask(h);
} catch (...) {
delete h;
throw;
}
}
示例6: closeCallback
void mail::mbox::folder::open(mail::callback &openCallback,
snapshot *restoreSnapshot,
mail::callback::folder &folderCallback) const
{
if (mboxAccount.currentFolder.size() == 0 &&
mboxAccount.folderDirty)
{
closeCallback *cc=new closeCallback(&mboxAccount,
openCallback,
folderCallback,
path);
if (!cc)
{
openCallback.fail("Out of memory.");
return;
}
try {
mboxAccount
.installTask(new mail::mbox
::ExpungeTask(mboxAccount, *cc,
false, NULL));
} catch (...) {
delete cc;
LIBMAIL_THROW(LIBMAIL_THROW_EMPTY);
}
return;
}
mboxAccount.installTask(new mail::mbox::OpenTask(mboxAccount, path, openCallback,
&folderCallback));
}
示例7: getFolderIndexInfo
void mail::addressbook::searchNickname( string nickname,
vector<T> &addrListArg,
mail::callback &callback)
{
Search<T> *s=new Search<T>(this, addrListArg, callback);
if (!s)
{
callback.fail(strerror(errno));
return;
}
try {
size_t n=index.size();
size_t i;
for (i=0; i<n; i++)
if (index[i].nickname == nickname)
s->uidList.push_back(server->
getFolderIndexInfo(i)
.uid);
s->go();
} catch (...) {
delete s;
LIBMAIL_THROW(LIBMAIL_THROW_EMPTY);
}
}
示例8: f
void mail::imap::findFolder(string folder,
mail::callback::folderList &callback1,
mail::callback &callback2)
{
if (!ready(callback2))
return;
if (folder.size() == 0) // Top level hierarchy
{
mail::imapFolder f(*this, "", "", "", -1);
f.hasMessages(false);
f.hasSubFolders(true);
vector<const mail::folder *> list;
list.push_back(&f);
callback1.success(list);
callback2.success("OK");
return;
}
installForegroundTask( smap ?
(imapHandler *)
new mail::smapLISToneFolder(folder,
callback1,
callback2)
: new mail::imapListHandler(callback1,
callback2,
folder_chset(),
folder,
true));
}
示例9: Add
void mail::addressbook::addEntry(Entry &newEntry, string olduid,
mail::callback &callback)
{
vector<Index>::iterator b=index.begin(), e=index.end();
while (b != e)
{
Index &i= *b++;
if (olduid.size() > 0 && i.uid == olduid)
continue;
if (newEntry.nickname == i.nickname)
{
callback.fail("Address book entry with the same name already exists.");
return;
}
}
Add *add=new Add(this, newEntry, olduid, callback);
try {
add->go();
} catch (...) {
delete add;
}
}
示例10: smapDELETE
void mail::imapFolder::destroy(mail::callback &callback, bool subdirs) const
{
if (isDestroyed(callback))
return;
if (!imapAccount.ready(callback))
return;
imapHandler *h=imapAccount.smap ? (imapHandler *)
new mail::smapDELETE(path, subdirs, callback)
: new mail::imapDELETE(callback,
path + (subdirs ? hiersep:""));
if (!h)
{
callback.fail(strerror(errno));
return;
}
try {
imapAccount.installForegroundTask(h);
} catch (...) {
delete h;
throw;
}
}
示例11:
mail::maildir::maildir(mail::callback::disconnect &disconnect_callback,
mail::callback &callback,
string pathArg)
: mail::account(disconnect_callback), CONSTRUCTOR
{
if (init(callback, pathArg))
callback.success("Mail folders opened");
}
示例12: newFolder
void mail::mbox::folder::createSubFolder(string name,
bool isDirectory,
mail::callback::folderList &callback1,
mail::callback &callback2) const
{
string fpath;
char *p=libmail_u_convert_tobuf(name.c_str(), unicode_default_chset(),
unicode_x_imap_modutf7 " ./~:", NULL);
if (!p)
LIBMAIL_THROW("Out of memory.");
try {
fpath=path + "/" + p;
free(p);
} catch (...) {
free(p);
LIBMAIL_THROW(LIBMAIL_THROW_EMPTY);
}
if (isDirectory) {
if (mkdir(fpath.c_str(), 0700) < 0)
{
callback2.fail(fpath + ": " + strerror(errno));
return;
}
} else {
int fd= ::open(fpath.c_str(), O_RDWR|O_CREAT|O_EXCL, 0600);
if (fd < 0)
{
callback2.fail(fpath + ": " + strerror(errno));
return;
}
close(fd);
}
folder newFolder(fpath, mboxAccount);
vector<const mail::folder *> folderList;
folderList.push_back(&newFolder);
callback1.success(folderList);
callback2.success("OK");
}
示例13: tempFolder
void mail::maildir::findFolder(string folder,
mail::callback::folderList &callback1,
mail::callback &callback2)
{
mail::maildir::folder tempFolder(this, folder);
vector<const mail::folder *> folderList;
folderList.push_back(&tempFolder);
callback1.success(folderList);
callback2.success("OK");
}
示例14: strerror
void mail::mbox::folder::create(bool isDirectory,
mail::callback &callback) const
{
if (isDirectory) {
if (mkdir(path.c_str(), 0700) < 0)
{
callback.fail(path + ": " + strerror(errno));
return;
}
} else {
int fd= ::open(path.c_str(), O_RDWR|O_CREAT|O_EXCL, 0600);
if (fd < 0)
{
callback.fail(path + ": " + strerror(errno));
return;
}
close(fd);
}
callback.success("OK");
}
示例15:
void mail::imapFolder::readFolderInfo(mail::callback::folderInfo &callback1,
mail::callback &callback2) const
{
if (isDestroyed(callback2))
return;
if (imapAccount.currentFolder &&
imapAccount.currentFolder->path == path)
{
imapFOLDERinfo *f=imapAccount.currentFolder;
vector<imapFOLDERinfo::indexInfo>::iterator b, e;
b=f->index.begin();
e=f->index.end();
callback1.messageCount=f->index.size();
callback1.unreadCount=0;
while (b != e)
{
if (b->unread)
++callback1.unreadCount;
b++;
}
callback1.success();
callback2.success("OK");
return;
}
if (!imapAccount.smap && callback1.fastInfo &&
!imapAccount.hasCapability(LIBMAIL_CHEAPSTATUS))
{
callback2.success("OK");
return;
}
imapAccount.folderStatus(path, callback1, callback2);
}