#ifndef ____POP3_QUIT_h__ # define ____POP3_QUIT_h__ # include "POP3Command.h" namespace mail { class __POP3_QUIT : public POP3Command { // RFC 1939 6: the UPDATE state - QUIT is what actually commits // every DELE mark made this session (unlinking those messages), // not DELE itself. Only happens if the session ever authenticated // (a QUIT sent before USER/PASS in the AUTHORIZATION state has no // maildrop to touch). int processCommand(coreutils::ZString request, POP3Session &session, POP3Server &server) override { if (session.authenticated) { // Resolve every marked message number to its UID FIRST, all // at once, before deleting any of them - deleteMessage() // mutates the mailbox's message list, which would shift // every LATER message number's meaning if resolved one at a // time interleaved with deletion. UIDs, unlike message // numbers, are stable across that mutation. std::vector uidsToDelete; for (int msgNum : session.deletedMarks) { uint32_t uid = session.mailbox.uidForSeq(msgNum); if (uid != 0) uidsToDelete.push_back(uid); } for (uint32_t uid : uidsToDelete) session.mailbox.deleteMessage(uid); } session.out << "+OK BARANTMail POP3 server signing off" << CRLF; session.terminate(); return 1; } }; } #endif