void mail::mbox::readMessageContent(const vector<size_t> &messages, bool peek, enum mail::readMode readType, mail::callback::message &callback) { MultiLockRelease *mlock=new MultiLockRelease(*this, callback); if (!mlock) { callback.fail(strerror(errno)); return; } try { MultiLockGenericMessageRead *mr= new MultiLockGenericMessageRead(*this, messages, peek, readType, *mlock); if (!mr) LIBMAIL_THROW((strerror(errno))); try { installTask(new MultiLock( *this, *mr )); } catch (...) { delete mr; } } catch (...) { delete mlock; LIBMAIL_THROW(LIBMAIL_THROW_EMPTY); } }
void mail::maildir::genericMessageRead(string uid, size_t messageNumber, bool peek, mail::readMode readType, mail::callback::message &callback) { if (!fixMessageNumber(this, uid, messageNumber)) { callback.success("OK"); return; } MONITOR(mail::maildir); string messageFn=getfilename(messageNumber); if (messageFn.size() == 0) { callback.success("OK"); return; } int fd=maildir_safeopen(messageFn.c_str(), O_RDONLY, 0); if (fd < 0) { callback.success("OK"); return; } try { mail::file f(fd, "r"); f.genericMessageRead(this, messageNumber, readType, callback); if (ferror(f)) { callback.fail(strerror(errno)); close(fd); return; } } catch (...) { close(fd); LIBMAIL_THROW(LIBMAIL_THROW_EMPTY); } close(fd); if (!peek && index[messageNumber].unread) { index[messageNumber].unread=false; saveFolderIndexInfo(messageNumber, index[messageNumber], callback); return; } callback.success("OK"); }
void mail::mbox::readMessageAttributes(const vector<size_t> &messages, MessageAttributes attributes, mail::callback::message &callback) { vector<size_t> messageCpy=messages; // ARRIVALDATE can be handled here, for everything else use the // generic methods. if (attributes & mail::account::ARRIVALDATE) { attributes &= ~mail::account::ARRIVALDATE; vector<size_t>::iterator b=messageCpy.begin(), e=messageCpy.end(); MONITOR(mail::mbox); while (b != e && !DESTROYED()) { size_t n= *b++; if (n >= index.size()) continue; string uid=index[n].uid; callback .messageArrivalDateCallback(n, uidmap.count(uid) == 0 ? 0: folderMessageIndex [ uidmap.find(uid) ->second] .internalDate); } if (DESTROYED() || attributes == 0) { callback.success("OK"); return; } } MultiLockRelease *mlock=new MultiLockRelease(*this, callback); if (!mlock) { callback.fail(strerror(errno)); return; } try { MultiLockGenericAttributes *mr= new MultiLockGenericAttributes(*this, messageCpy, attributes, *mlock); if (!mr) LIBMAIL_THROW((strerror(errno))); try { installTask(new MultiLock( *this, *mr )); } catch (...) { delete mr; } } catch (...) { delete mlock; LIBMAIL_THROW(LIBMAIL_THROW_EMPTY); } }