summaryrefslogtreecommitdiff
path: root/src/include/mailbox.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/mailbox.h')
-rw-r--r--src/include/mailbox.h136
1 files changed, 136 insertions, 0 deletions
diff --git a/src/include/mailbox.h b/src/include/mailbox.h
new file mode 100644
index 0000000..db98cc0
--- /dev/null
+++ b/src/include/mailbox.h
@@ -0,0 +1,136 @@
+/** --------------------------------------------------------------------
+ * @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 <map>
+#include <string>
+#include <queue>
+#include <vector>
+
+#include <time.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include "imapparser.h"
+
+namespace Binc {
+
+ class Message;
+ class Status;
+ class PendingUpdates;
+ class File;
+
+ //------------------------------------------------------------------------
+ class Mailbox {
+ public:
+
+ //----------------------------------------------------------------------
+ class BaseIterator {
+ public:
+ BaseIterator(int sqn = 0);
+ virtual ~BaseIterator(void);
+
+ virtual Message &operator *(void) = 0;
+ virtual void operator ++(void) = 0;
+ virtual bool operator !=(const BaseIterator &d) const = 0;
+ virtual bool operator ==(const BaseIterator &d) const = 0;
+
+ virtual void erase(void) = 0;
+
+ unsigned int sqnr;
+ };
+
+ //----------------------------------------------------------------------
+ class iterator {
+ public:
+ iterator(BaseIterator &i);
+
+ Message &operator *(void);
+ void operator ++(void);
+ bool operator ==(const iterator &) const;
+ bool operator !=(const iterator &) const;
+
+ unsigned int getSqnr() const;
+
+ void erase(void);
+
+ 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(void) 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(void) const;
+
+ virtual const std::string getTypeName(void) const = 0;
+ const std::string getName(void) const;
+ void setName(const std::string &name);
+
+ virtual unsigned int getMaxUid(void) const = 0;
+ virtual unsigned int getMaxSqnr(void) const = 0;
+ virtual unsigned int getUidNext(void) const = 0;
+ virtual unsigned int getUidValidity(void) const = 0;
+
+ virtual bool getUpdates(bool scan, unsigned int type,
+ PendingUpdates &updates, bool forceScan) = 0;
+
+ virtual void updateFlags(void) = 0;
+ virtual void expungeMailbox(void) = 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(void) = 0;
+
+ virtual Message *createMessage(const std::string &mbox, time_t idate = 0) = 0;
+ virtual bool commitNewMessages(const std::string &mbox) = 0;
+ virtual bool rollBackNewMessages(void) = 0;
+ virtual bool fastCopy(Message &source, Mailbox &desttype, const std::string &destname) = 0;
+
+ const std::string &getLastError(void) const;
+ void setLastError(const std::string &error) const;
+
+ //--
+ Mailbox(void);
+ virtual ~Mailbox(void);
+
+ friend class Mailbox::iterator;
+
+ protected:
+ bool readOnly;
+
+ private:
+ Mailbox(const Mailbox &copy);
+
+ mutable std::string lastError;
+
+ std::string name;
+ };
+}
+
+#endif