summaryrefslogtreecommitdiffstats
path: root/common/sourcewriteback.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/sourcewriteback.h')
-rw-r--r--common/sourcewriteback.h71
1 files changed, 0 insertions, 71 deletions
diff --git a/common/sourcewriteback.h b/common/sourcewriteback.h
deleted file mode 100644
index cf393e4..0000000
--- a/common/sourcewriteback.h
+++ /dev/null
@@ -1,71 +0,0 @@
1/*
2 * Copyright (C) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) version 3, or any
8 * later version accepted by the membership of KDE e.V. (or its
9 * successor approved by the membership of KDE e.V.), which shall
10 * act as a proxy defined in Section 6 of version 3 of the license.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20#pragma once
21
22#include "sink_export.h"
23
24#include "changereplay.h"
25#include "storage.h"
26#include "storage/entitystore.h"
27#include "remoteidmap.h"
28#include "metadata_generated.h"
29
30namespace Sink {
31
32/**
33 * Replay changes to the source
34 */
35class SINK_EXPORT SourceWriteBack : public ChangeReplay
36{
37public:
38 SourceWriteBack(const ResourceContext &resourceContext);
39
40protected:
41 ///Base implementation calls the replay$Type calls
42 virtual KAsync::Job<void> replay(const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE;
43 virtual bool canReplay(const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE;
44
45protected:
46 ///Implement to write back changes to the server
47 virtual KAsync::Job<QByteArray> replay(const Sink::ApplicationDomain::Mail &, Sink::Operation, const QByteArray &oldRemoteId, const QList<QByteArray> &);
48 virtual KAsync::Job<QByteArray> replay(const Sink::ApplicationDomain::Folder &, Sink::Operation, const QByteArray &oldRemoteId, const QList<QByteArray> &);
49
50 //Read/Write access to sync storage
51 RemoteIdMap &syncStore();
52
53 template <typename T>
54 T getPrevious(const T &entity)
55 {
56 return store().readPrevious<T>(entity.identifier(), entity.revision());
57 }
58
59private:
60 //Read only access to main storage
61 Storage::EntityStore &store();
62 ResourceContext mResourceContext;
63 Sink::Storage::DataStore mSyncStorage;
64 QSharedPointer<RemoteIdMap> mSyncStore;
65 QSharedPointer<Storage::EntityStore> mEntityStore;
66 Sink::Storage::DataStore::Transaction mSyncTransaction;
67 QByteArray mResourceType;
68 QByteArray mResourceInstanceIdentifier;
69};
70
71}