/** * @file mailbox.h * @brief Declaration of the Mailbox class (Mailbox is logical container) * @author Andreas Aardal Hanssen * @date 2002-2005 */ #ifndef mailbox_h_included #define mailbox_h_included #include "imapparser.h" #include #include #include #include #include #include #include #include namespace Binc { class Message; class Status; class PendingUpdates; class File; class Mailbox { public: class BaseIterator { public: BaseIterator(int sqn = 0); virtual ~BaseIterator(); virtual Message &operator*() = 0; virtual void operator++() = 0; virtual bool operator!=(const BaseIterator &d) const = 0; virtual bool operator==(const BaseIterator &d) const = 0; virtual void erase() = 0; unsigned int sqnr; }; class iterator { public: iterator(BaseIterator &i); Message &operator*(); void operator++(); bool operator==(const iterator &) const; bool operator!=(const iterator &) const; unsigned int getSqnr() const; void erase(); protected: BaseIterator &realIterator; }; enum Iterator { INCLUDE_EXPUNGED = 1, SKIP_EXPUNGED = 2 }; enum Mode { UID_MODE = 4, SQNR_MODE = 8 }; virtual iterator begin(const SequenceSet &bset, unsigned int mod = INCLUDE_EXPUNGED | SQNR_MODE) const = 0; virtual iterator end() const = 0; //-- Generic for one mailbox type virtual bool getStatus(const std::string &, Status &) const = 0; virtual bool isMailbox(const std::string &) const = 0; virtual bool isMarked(const std::string &) const = 0; virtual unsigned int getStatusID(const std::string &) const = 0; virtual void bumpUidValidity(const std::string &) const = 0; //-- Specific for one mailbox void setReadOnly(bool readOnly); bool isReadOnly() const; virtual const std::string getTypeName() const = 0; const std::string getName() const; void setName(const std::string &name); virtual unsigned int getMaxUid() const = 0; virtual unsigned int getMaxSqnr() const = 0; virtual unsigned int getUidNext() const = 0; virtual unsigned int getUidValidity() const = 0; virtual bool getUpdates(bool scan, unsigned int type, PendingUpdates &updates, bool forceScan) = 0; virtual void updateFlags() = 0; virtual void expungeMailbox() = 0; virtual bool selectMailbox(const std::string &name, const std::string &s_in) = 0; 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 closeMailbox() = 0; virtual Message *createMessage(const std::string &mbox, time_t idate = 0) = 0; virtual bool commitNewMessages(const std::string &mbox) = 0; virtual bool rollBackNewMessages() = 0; virtual bool fastCopy(Message &source, Mailbox &desttype, const std::string &destname) = 0; const std::string &getLastError() const; void setLastError(const std::string &error) const; //-- Mailbox(); virtual ~Mailbox(); Mailbox &operator=(const Mailbox &m) = delete; friend class Mailbox::iterator; protected: bool readOnly; private: Mailbox(const Mailbox ©); mutable std::string lastError; std::string name; }; } #endif