diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-03 14:02:27 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-03 14:02:27 +0200 |
commit | 55fe06979ceebe67553135b43aa47e70d931304b (patch) | |
tree | 16b10a744879cc1872d6c07624b59ae64469ddbf /examples/imapresource/imapserverproxy.h | |
parent | 56fae95f49a1ca8ca614bd9f89b0ea5f872765e9 (diff) | |
parent | 288946f1694c2abe1d2c5800c87339d1e8780e4b (diff) | |
download | sink-55fe06979ceebe67553135b43aa47e70d931304b.tar.gz sink-55fe06979ceebe67553135b43aa47e70d931304b.zip |
Merge branch 'develop'
Diffstat (limited to 'examples/imapresource/imapserverproxy.h')
-rw-r--r-- | examples/imapresource/imapserverproxy.h | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h index 872f032..82f4f58 100644 --- a/examples/imapresource/imapserverproxy.h +++ b/examples/imapresource/imapserverproxy.h | |||
@@ -31,6 +31,7 @@ namespace Imap { | |||
31 | 31 | ||
32 | enum ErrorCode { | 32 | enum ErrorCode { |
33 | NoError, | 33 | NoError, |
34 | HostNotFoundError, | ||
34 | CouldNotConnectError, | 35 | CouldNotConnectError, |
35 | SslHandshakeError | 36 | SslHandshakeError |
36 | }; | 37 | }; |
@@ -60,6 +61,7 @@ namespace FolderFlags | |||
60 | extern const char* Junk; | 61 | extern const char* Junk; |
61 | extern const char* Flagged; | 62 | extern const char* Flagged; |
62 | extern const char* All; | 63 | extern const char* All; |
64 | extern const char* Drafts; | ||
63 | } | 65 | } |
64 | 66 | ||
65 | namespace Capabilities | 67 | namespace Capabilities |
@@ -78,6 +80,8 @@ struct Message { | |||
78 | bool fullPayload; | 80 | bool fullPayload; |
79 | }; | 81 | }; |
80 | 82 | ||
83 | bool flagsContain(const QByteArray &f, const QByteArrayList &flags); | ||
84 | |||
81 | struct Folder { | 85 | struct Folder { |
82 | Folder() = default; | 86 | Folder() = default; |
83 | Folder(const QString &path, const QString &ns, const QChar &separator, bool noselect_, bool subscribed_, const QByteArrayList &flags_) | 87 | Folder(const QString &path, const QString &ns, const QChar &separator, bool noselect_, bool subscribed_, const QByteArrayList &flags_) |
@@ -114,6 +118,15 @@ struct Folder { | |||
114 | return parentPath; | 118 | return parentPath; |
115 | } | 119 | } |
116 | 120 | ||
121 | Folder parentFolder() const | ||
122 | { | ||
123 | Folder parent; | ||
124 | parent.mPath = parentPath(); | ||
125 | parent.mNamespace = mNamespace; | ||
126 | parent.mSeparator = mSeparator; | ||
127 | return parent; | ||
128 | } | ||
129 | |||
117 | QString name() const | 130 | QString name() const |
118 | { | 131 | { |
119 | auto pathParts = mPath.split(mSeparator); | 132 | auto pathParts = mPath.split(mSeparator); |
@@ -218,18 +231,18 @@ public: | |||
218 | return session; | 231 | return session; |
219 | } | 232 | } |
220 | } | 233 | } |
221 | return CachedSession{}; | 234 | return {}; |
235 | } | ||
236 | |||
237 | bool isEmpty() const | ||
238 | { | ||
239 | return mSessions.isEmpty(); | ||
222 | } | 240 | } |
223 | private: | 241 | private: |
224 | QList<CachedSession> mSessions; | 242 | QList<CachedSession> mSessions; |
225 | }; | 243 | }; |
226 | 244 | ||
227 | class ImapServerProxy { | 245 | class ImapServerProxy { |
228 | KIMAP2::Session *mSession; | ||
229 | QStringList mCapabilities; | ||
230 | Namespaces mNamespaces; | ||
231 | |||
232 | |||
233 | public: | 246 | public: |
234 | ImapServerProxy(const QString &serverUrl, int port, SessionCache *sessionCache = nullptr); | 247 | ImapServerProxy(const QString &serverUrl, int port, SessionCache *sessionCache = nullptr); |
235 | 248 | ||
@@ -279,9 +292,14 @@ public: | |||
279 | KAsync::Job<QVector<qint64>> fetchUids(const Folder &folder); | 292 | KAsync::Job<QVector<qint64>> fetchUids(const Folder &folder); |
280 | 293 | ||
281 | private: | 294 | private: |
295 | bool isGmail() const; | ||
296 | |||
282 | QString getNamespace(const QString &name); | 297 | QString getNamespace(const QString &name); |
283 | QObject mGuard; | 298 | QObject mGuard; |
284 | SessionCache *mSessionCache; | 299 | SessionCache *mSessionCache; |
300 | KIMAP2::Session *mSession; | ||
301 | QStringList mCapabilities; | ||
302 | Namespaces mNamespaces; | ||
285 | }; | 303 | }; |
286 | 304 | ||
287 | } | 305 | } |