Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
mailbox.h
Go to the documentation of this file.
1
7#ifndef mailbox_h_included
8#define mailbox_h_included
9
10#include <map>
11#include <string>
12#include <queue>
13#include <vector>
14
15#include <time.h>
16#include <stdio.h>
17#include <string.h>
18#include <sys/types.h>
19
20#include "imapparser.h"
21
22namespace Binc {
23
24 class Message;
25 class Status;
26 class PendingUpdates;
27 class File;
28
29 //------------------------------------------------------------------------
30 class Mailbox {
31 public:
32
33 //----------------------------------------------------------------------
35 public:
36 BaseIterator(int sqn = 0);
37 virtual ~BaseIterator(void);
38
39 virtual Message &operator *(void) = 0;
40 virtual void operator ++(void) = 0;
41 virtual bool operator !=(const BaseIterator &d) const = 0;
42 virtual bool operator ==(const BaseIterator &d) const = 0;
43
44 virtual void erase(void) = 0;
45
46 unsigned int sqnr;
47 };
48
49 //----------------------------------------------------------------------
50 class iterator {
51 public:
53
54 Message &operator *(void);
55 void operator ++(void);
56 bool operator ==(const iterator &) const;
57 bool operator !=(const iterator &) const;
58
59 unsigned int getSqnr() const;
60
61 void erase(void);
62
63 protected:
65 };
66
67 enum Iterator {
70 };
71
72 enum Mode {
74 SQNR_MODE = 8
75 };
76
77 virtual iterator begin(const SequenceSet &bset, unsigned int mod = INCLUDE_EXPUNGED | SQNR_MODE) const = 0;
78 virtual iterator end(void) const = 0;
79
80 //-- Generic for one mailbox type
81 virtual bool getStatus(const std::string &, Status &) const = 0;
82 virtual bool isMailbox(const std::string &) const = 0;
83 virtual bool isMarked(const std::string &) const = 0;
84 virtual unsigned int getStatusID(const std::string &) const = 0;
85 virtual void bumpUidValidity(const std::string &) const = 0;
86
87 //-- Specific for one mailbox
88 void setReadOnly(bool readOnly);
89 bool isReadOnly(void) const;
90
91 virtual const std::string getTypeName(void) const = 0;
92 const std::string getName(void) const;
93 void setName(const std::string &name);
94
95 virtual unsigned int getMaxUid(void) const = 0;
96 virtual unsigned int getMaxSqnr(void) const = 0;
97 virtual unsigned int getUidNext(void) const = 0;
98 virtual unsigned int getUidValidity(void) const = 0;
99
100 virtual bool getUpdates(bool scan, unsigned int type,
101 PendingUpdates &updates, bool forceScan) = 0;
102
103 virtual void updateFlags(void) = 0;
104 virtual void expungeMailbox(void) = 0;
105 virtual bool selectMailbox(const std::string &name, const std::string &s_in) = 0;
106 virtual bool createMailbox(const std::string &s, mode_t mode, uid_t owner = 0, gid_t group = 0, bool root = false) = 0;
107 virtual bool deleteMailbox(const std::string &s) = 0;
108 virtual void closeMailbox(void) = 0;
109
110 virtual Message *createMessage(const std::string &mbox, time_t idate = 0) = 0;
111 virtual bool commitNewMessages(const std::string &mbox) = 0;
112 virtual bool rollBackNewMessages(void) = 0;
113 virtual bool fastCopy(Message &source, Mailbox &desttype, const std::string &destname) = 0;
114
115 const std::string &getLastError(void) const;
116 void setLastError(const std::string &error) const;
117
118 //--
119 Mailbox(void);
120 virtual ~Mailbox(void);
121
122 friend class Mailbox::iterator;
123
124 protected:
126
127 private:
128 Mailbox(const Mailbox &copy);
129
130 mutable std::string lastError;
131
132 std::string name;
133 };
134}
135
136#endif
virtual bool operator!=(const BaseIterator &d) const =0
virtual bool operator==(const BaseIterator &d) const =0
virtual void operator++(void)=0
virtual void erase(void)=0
virtual Message & operator*(void)=0
virtual ~BaseIterator(void)
Definition: mailbox.cc:22
void operator++(void)
Definition: mailbox.cc:61
bool operator!=(const iterator &) const
Definition: mailbox.cc:73
unsigned int getSqnr() const
Definition: mailbox.cc:85
Message & operator*(void)
Definition: mailbox.cc:55
BaseIterator & realIterator
Definition: mailbox.h:64
bool operator==(const iterator &) const
Definition: mailbox.cc:67
virtual bool isMailbox(const std::string &) const =0
virtual const std::string getTypeName(void) const =0
virtual bool rollBackNewMessages(void)=0
virtual ~Mailbox(void)
Definition: mailbox.cc:32
void setLastError(const std::string &error) const
Definition: mailbox.cc:109
bool readOnly
Definition: mailbox.h:125
virtual bool isMarked(const std::string &) const =0
virtual bool selectMailbox(const std::string &name, const std::string &s_in)=0
const std::string & getLastError(void) const
Definition: mailbox.cc:103
virtual bool createMailbox(const std::string &s, mode_t mode, uid_t owner=0, gid_t group=0, bool root=false)=0
virtual void closeMailbox(void)=0
Mailbox(void)
Definition: mailbox.cc:27
virtual bool deleteMailbox(const std::string &s)=0
virtual unsigned int getMaxSqnr(void) const =0
virtual void bumpUidValidity(const std::string &) const =0
virtual void updateFlags(void)=0
virtual unsigned int getStatusID(const std::string &) const =0
bool isReadOnly(void) const
Definition: mailbox.cc:37
virtual iterator begin(const SequenceSet &bset, unsigned int mod=INCLUDE_EXPUNGED|SQNR_MODE) const =0
virtual bool commitNewMessages(const std::string &mbox)=0
void setName(const std::string &name)
Definition: mailbox.cc:91
virtual unsigned int getUidValidity(void) const =0
virtual iterator end(void) const =0
@ SKIP_EXPUNGED
Definition: mailbox.h:69
@ INCLUDE_EXPUNGED
Definition: mailbox.h:68
virtual bool getUpdates(bool scan, unsigned int type, PendingUpdates &updates, bool forceScan)=0
virtual unsigned int getMaxUid(void) const =0
virtual unsigned int getUidNext(void) const =0
virtual bool fastCopy(Message &source, Mailbox &desttype, const std::string &destname)=0
virtual bool getStatus(const std::string &, Status &) const =0
virtual Message * createMessage(const std::string &mbox, time_t idate=0)=0
void setReadOnly(bool readOnly)
Definition: mailbox.cc:43
const std::string getName(void) const
Definition: mailbox.cc:97
virtual void expungeMailbox(void)=0
The Message class provides an interface for IMAP messages.
Definition: message.h:31
Declaration of the common items for parsing IMAP input.
Definition: bincimapd.cc:9