summaryrefslogtreecommitdiffstats
path: root/examples/imapresource/imapserverproxy.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-22 13:10:39 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-22 13:10:39 +0200
commit6864e4accaafa4fa90332719bff5a85a0e92b242 (patch)
tree31c0d6df98112674e55ea5ad636c2ad780add49c /examples/imapresource/imapserverproxy.h
parentde52c17a7a08e72affc4c182fb1650d18d8b3b2b (diff)
downloadsink-6864e4accaafa4fa90332719bff5a85a0e92b242.tar.gz
sink-6864e4accaafa4fa90332719bff5a85a0e92b242.zip
ImapResource prototype
Diffstat (limited to 'examples/imapresource/imapserverproxy.h')
-rw-r--r--examples/imapresource/imapserverproxy.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h
new file mode 100644
index 0000000..2beb28c
--- /dev/null
+++ b/examples/imapresource/imapserverproxy.h
@@ -0,0 +1,62 @@
1/*
2 * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#pragma once
21
22#include <Async/Async>
23
24#include <KMime/KMime/KMimeMessage>
25#include <KIMAP/KIMAP/ListJob>
26#include <KIMAP/KIMAP/Session>
27#include <KIMAP/KIMAP/FetchJob>
28
29struct Message {
30 qint64 uid;
31 qint64 size;
32 QPair<QByteArray, QVariant> attributes;
33 QList<QByteArray> flags;
34 KMime::Message::Ptr msg;
35};
36
37class ImapServerProxy {
38 KIMAP::Session *mSession;
39public:
40 ImapServerProxy(const QString &serverUrl, int port);
41
42 //Standard IMAP calls
43 KAsync::Job<void> login(const QString &username, const QString &password);
44 KAsync::Job<void> select(const QString &mailbox);
45 KAsync::Job<void> append(const QString &mailbox, const QByteArray &content, const QList<QByteArray> &flags = QList<QByteArray>(), const QDateTime &internalDate = QDateTime());
46
47 typedef std::function<void(const QString &,
48 const QMap<qint64,qint64> &,
49 const QMap<qint64,qint64> &,
50 const QMap<qint64,KIMAP::MessageAttribute> &,
51 const QMap<qint64,KIMAP::MessageFlags> &,
52 const QMap<qint64,KIMAP::MessagePtr> &)> FetchCallback;
53
54 KAsync::Job<void> fetch(const KIMAP::ImapSet &set, KIMAP::FetchJob::FetchScope scope, FetchCallback callback);
55 KAsync::Job<void> list(KIMAP::ListJob::Option option, const std::function<void(const QList<KIMAP::MailBoxDescriptor> &mailboxes,const QList<QList<QByteArray> > &flags)> &callback);
56
57 //Composed calls that do login etc.
58 KAsync::Job<QList<qint64>> fetchHeaders(const QString &mailbox);
59
60 KAsync::Future<void> fetchFolders(std::function<void(const QStringList &)> callback);
61 KAsync::Future<void> fetchMessages(const QString &folder, std::function<void(const QVector<Message> &)> callback);
62};