diff options
Diffstat (limited to 'examples/maildirresource/maildirresource.h')
-rw-r--r-- | examples/maildirresource/maildirresource.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/examples/maildirresource/maildirresource.h b/examples/maildirresource/maildirresource.h new file mode 100644 index 0000000..a3e12d3 --- /dev/null +++ b/examples/maildirresource/maildirresource.h | |||
@@ -0,0 +1,61 @@ | |||
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.maildir" | ||
30 | |||
31 | class MaildirResource : public Akonadi2::GenericResource | ||
32 | { | ||
33 | public: | ||
34 | MaildirResource(const QByteArray &instanceIdentifier, const QSharedPointer<Akonadi2::Pipeline> &pipeline = QSharedPointer<Akonadi2::Pipeline>()); | ||
35 | KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE; | ||
36 | static void removeFromDisk(const QByteArray &instanceIdentifier); | ||
37 | private: | ||
38 | KAsync::Job<void> replay(const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE; | ||
39 | QString resolveRemoteId(const QByteArray &type, const QString &remoteId, Akonadi2::Storage::Transaction &transaction); | ||
40 | // void createMail(const QByteArray &rid, const QMap<QString, QVariant> &data, flatbuffers::FlatBufferBuilder &entityFbb, Akonadi2::Storage::Transaction &); | ||
41 | // void createFolder(const QByteArray &rid, const QMap<QString, QVariant> &data, flatbuffers::FlatBufferBuilder &entityFbb, Akonadi2::Storage::Transaction &); | ||
42 | // void synchronize(const QString &bufferType, const QMap<QString, QMap<QString, QVariant> > &data, Akonadi2::Storage::Transaction &transaction, std::function<void(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, flatbuffers::FlatBufferBuilder &entityFbb, Akonadi2::Storage::Transaction &)> createEntity); | ||
43 | void synchronizeFolders(Akonadi2::Storage::Transaction &transaction); | ||
44 | void synchronizeMails(Akonadi2::Storage::Transaction &transaction, const QString &folder); | ||
45 | QStringList listAvailableFolders(); | ||
46 | QString mMaildirPath; | ||
47 | }; | ||
48 | |||
49 | class MaildirResourceFactory : public Akonadi2::ResourceFactory | ||
50 | { | ||
51 | Q_OBJECT | ||
52 | Q_PLUGIN_METADATA(IID "org.kde.maildir") | ||
53 | Q_INTERFACES(Akonadi2::ResourceFactory) | ||
54 | |||
55 | public: | ||
56 | MaildirResourceFactory(QObject *parent = 0); | ||
57 | |||
58 | Akonadi2::Resource *createResource(const QByteArray &instanceIdentifier) Q_DECL_OVERRIDE; | ||
59 | void registerFacades(Akonadi2::FacadeFactory &factory) Q_DECL_OVERRIDE; | ||
60 | }; | ||
61 | |||