blob: 0d3cfae380de4850e7d6cd9d91cfc932d862c332 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/**
* @filec depot.h
* @file Declaration of the Depot class (the mail storage)
* @author Andreas Aardal Hanssen
* @date 2002-2005
*/
#ifndef depot_h_included
#define depot_h_included
#include <map>
#include <string>
#include <vector>
#include <dirent.h>
namespace Binc {
class Mailbox;
class Depot;
class Status;
class DepotFactory {
private:
std::vector<Depot *> depots;
DepotFactory();
public:
void assign(Depot *);
Depot *get(const std::string &name) const;
static DepotFactory &getInstance();
~DepotFactory();
};
class Depot {
public:
class iterator {
public:
iterator();
iterator(const iterator ©);
iterator(DIR *, struct dirent *);
~iterator();
iterator &operator=(const iterator ©);
std::string operator*() const;
void operator++();
bool operator!=(iterator) const;
bool operator==(iterator) const;
void deref();
friend class Depot;
private:
DIR *dirp;
struct dirent *direntp;
int *ref;
};
private:
iterator enditerator;
std::vector<Mailbox *> backends;
Mailbox *defaultmailbox;
Mailbox *selectedmailbox;
std::vector<std::string> subscribed;
std::string personalNamespace;
std::string othersNamespace;
std::string sharedNamespace;
protected:
mutable std::string lastError;
std::string name;
char delimiter;
mutable std::map<std::string, Status> mailboxstatuses;
public:
Depot();
Depot(const std::string &name);
virtual ~Depot() = default;
virtual iterator begin(const std::string &) const;
virtual const iterator &end() const;
void setDelimiter(char);
char getDelimiter() const;
virtual void assign(Mailbox *);
bool setDefaultType(const std::string &n);
Mailbox *getDefault() const;
virtual Mailbox *get(const std::string &path) const;
virtual bool setSelected(Mailbox *);
virtual Mailbox *getSelected() const;
void resetSelected();
bool getStatus(const std::string &s_in, Status &dest) const;
const std::string &getName() const;
virtual const std::string &getPersonalNamespace() const;
virtual const std::string &getOthersNamespace() const;
virtual const std::string &getSharedNamespace() const;
virtual std::string mailboxToFilename(const std::string &m) const = 0;
virtual std::string filenameToMailbox(const std::string &m) const = 0;
virtual bool createMailbox(const std::string &m) const;
virtual bool deleteMailbox(const std::string &m) const;
virtual bool renameMailbox(const std::string &m, const std::string &n) const;
const std::string &getLastError() const;
void setLastError(const std::string &error) const;
virtual std::vector<std::string> getSubscriptions() const;
virtual void subscribeTo(const std::string mailbox);
virtual bool unsubscribeTo(const std::string mailbox);
virtual void loadSubscribes();
virtual bool saveSubscribes() const;
};
class MaildirPPDepot : public Depot {
public:
std::string mailboxToFilename(const std::string &m) const;
std::string filenameToMailbox(const std::string &m) const;
const std::string &getPersonalNamespace() const;
MaildirPPDepot();
~MaildirPPDepot();
private:
std::string privateNamespace;
};
class IMAPdirDepot : public Depot {
public:
std::string mailboxToFilename(const std::string &m) const;
std::string filenameToMailbox(const std::string &m) const;
IMAPdirDepot();
~IMAPdirDepot();
};
}
#endif
|