diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-22 13:10:39 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-22 13:10:39 +0200 |
commit | 6864e4accaafa4fa90332719bff5a85a0e92b242 (patch) | |
tree | 31c0d6df98112674e55ea5ad636c2ad780add49c /examples/imapresource/imapresource.h | |
parent | de52c17a7a08e72affc4c182fb1650d18d8b3b2b (diff) | |
download | sink-6864e4accaafa4fa90332719bff5a85a0e92b242.tar.gz sink-6864e4accaafa4fa90332719bff5a85a0e92b242.zip |
ImapResource prototype
Diffstat (limited to 'examples/imapresource/imapresource.h')
-rw-r--r-- | examples/imapresource/imapresource.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/examples/imapresource/imapresource.h b/examples/imapresource/imapresource.h new file mode 100644 index 0000000..6fe15dd --- /dev/null +++ b/examples/imapresource/imapresource.h | |||
@@ -0,0 +1,71 @@ | |||
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 "common/genericresource.h" | ||
23 | |||
24 | #include <Async/Async> | ||
25 | |||
26 | #include <flatbuffers/flatbuffers.h> | ||
27 | |||
28 | //TODO: a little ugly to have this in two places, once here and once in Q_PLUGIN_METADATA | ||
29 | #define PLUGIN_NAME "org.kde.imap" | ||
30 | |||
31 | class ImapMailAdaptorFactory; | ||
32 | class ImapFolderAdaptorFactory; | ||
33 | struct Message; | ||
34 | |||
35 | /** | ||
36 | * An imap resource. | ||
37 | */ | ||
38 | class ImapResource : public Sink::GenericResource | ||
39 | { | ||
40 | public: | ||
41 | ImapResource(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::Pipeline> &pipeline = QSharedPointer<Sink::Pipeline>()); | ||
42 | KAsync::Job<void> synchronizeWithSource(Sink::Storage &mainStore, Sink::Storage &synchronizationStore) Q_DECL_OVERRIDE; | ||
43 | KAsync::Job<void> inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) Q_DECL_OVERRIDE; | ||
44 | static void removeFromDisk(const QByteArray &instanceIdentifier); | ||
45 | private: | ||
46 | KAsync::Job<void> replay(Sink::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE; | ||
47 | |||
48 | QByteArray createFolder(const QString &folderPath, const QByteArray &icon, Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction); | ||
49 | void synchronizeFolders(const QStringList &folderList, Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction); | ||
50 | void synchronizeMails(Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction, const QString &path, const QVector<Message> &messages); | ||
51 | |||
52 | QSharedPointer<ImapMailAdaptorFactory> mMailAdaptorFactory; | ||
53 | QSharedPointer<ImapFolderAdaptorFactory> mFolderAdaptorFactory; | ||
54 | private: | ||
55 | QString mServer; | ||
56 | int mPort; | ||
57 | }; | ||
58 | |||
59 | class ImapResourceFactory : public Sink::ResourceFactory | ||
60 | { | ||
61 | Q_OBJECT | ||
62 | Q_PLUGIN_METADATA(IID "org.kde.imap") | ||
63 | Q_INTERFACES(Sink::ResourceFactory) | ||
64 | |||
65 | public: | ||
66 | ImapResourceFactory(QObject *parent = 0); | ||
67 | |||
68 | Sink::Resource *createResource(const QByteArray &instanceIdentifier) Q_DECL_OVERRIDE; | ||
69 | void registerFacades(Sink::FacadeFactory &factory) Q_DECL_OVERRIDE; | ||
70 | }; | ||
71 | |||