diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/CMakeLists.txt | 2 | ||||
-rw-r--r-- | common/inspector.h | 1 | ||||
-rw-r--r-- | common/synchronizer.cpp | 6 | ||||
-rw-r--r-- | common/synchronizer.h | 8 | ||||
-rw-r--r-- | common/synchronizerstore.cpp (renamed from common/remoteidmap.cpp) | 22 | ||||
-rw-r--r-- | common/synchronizerstore.h (renamed from common/remoteidmap.h) | 4 |
6 files changed, 22 insertions, 21 deletions
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index df44ce5..e8bb055 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt | |||
@@ -69,7 +69,7 @@ set(command_SRCS | |||
69 | changereplay.cpp | 69 | changereplay.cpp |
70 | adaptorfactoryregistry.cpp | 70 | adaptorfactoryregistry.cpp |
71 | synchronizer.cpp | 71 | synchronizer.cpp |
72 | remoteidmap.cpp | 72 | synchronizerstore.cpp |
73 | mailpreprocessor.cpp | 73 | mailpreprocessor.cpp |
74 | specialpurposepreprocessor.cpp | 74 | specialpurposepreprocessor.cpp |
75 | datastorequery.cpp | 75 | datastorequery.cpp |
diff --git a/common/inspector.h b/common/inspector.h index ff167b1..a746f03 100644 --- a/common/inspector.h +++ b/common/inspector.h | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include "notification.h" | 26 | #include "notification.h" |
27 | #include "resourcecontext.h" | 27 | #include "resourcecontext.h" |
28 | #include "synchronizerstore.h" | ||
28 | 29 | ||
29 | namespace Sink { | 30 | namespace Sink { |
30 | 31 | ||
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index f7dd816..11c7caf 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp | |||
@@ -22,7 +22,7 @@ | |||
22 | #include "definitions.h" | 22 | #include "definitions.h" |
23 | #include "commands.h" | 23 | #include "commands.h" |
24 | #include "bufferutils.h" | 24 | #include "bufferutils.h" |
25 | #include "remoteidmap.h" | 25 | #include "synchronizerstore.h" |
26 | #include "datastorequery.h" | 26 | #include "datastorequery.h" |
27 | #include "createentity_generated.h" | 27 | #include "createentity_generated.h" |
28 | #include "modifyentity_generated.h" | 28 | #include "modifyentity_generated.h" |
@@ -66,10 +66,10 @@ Storage::EntityStore &Synchronizer::store() | |||
66 | return *mEntityStore; | 66 | return *mEntityStore; |
67 | } | 67 | } |
68 | 68 | ||
69 | RemoteIdMap &Synchronizer::syncStore() | 69 | SynchronizerStore &Synchronizer::syncStore() |
70 | { | 70 | { |
71 | if (!mSyncStore) { | 71 | if (!mSyncStore) { |
72 | mSyncStore = QSharedPointer<RemoteIdMap>::create(syncTransaction()); | 72 | mSyncStore = QSharedPointer<SynchronizerStore>::create(syncTransaction()); |
73 | } | 73 | } |
74 | return *mSyncStore; | 74 | return *mSyncStore; |
75 | } | 75 | } |
diff --git a/common/synchronizer.h b/common/synchronizer.h index ae597bd..989f902 100644 --- a/common/synchronizer.h +++ b/common/synchronizer.h | |||
@@ -28,10 +28,10 @@ | |||
28 | #include <storage.h> | 28 | #include <storage.h> |
29 | #include <storage/entitystore.h> | 29 | #include <storage/entitystore.h> |
30 | #include "changereplay.h" | 30 | #include "changereplay.h" |
31 | #include "remoteidmap.h" | 31 | #include "synchronizerstore.h" |
32 | 32 | ||
33 | namespace Sink { | 33 | namespace Sink { |
34 | class RemoteIdMap; | 34 | class SynchronizerStore; |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Synchronize and add what we don't already have to local queue | 37 | * Synchronize and add what we don't already have to local queue |
@@ -51,7 +51,7 @@ public: | |||
51 | Storage::EntityStore &store(); | 51 | Storage::EntityStore &store(); |
52 | 52 | ||
53 | //Read/Write access to sync storage | 53 | //Read/Write access to sync storage |
54 | RemoteIdMap &syncStore(); | 54 | SynchronizerStore &syncStore(); |
55 | 55 | ||
56 | void commit(); | 56 | void commit(); |
57 | Sink::Storage::DataStore::Transaction &syncTransaction(); | 57 | Sink::Storage::DataStore::Transaction &syncTransaction(); |
@@ -171,7 +171,7 @@ private: | |||
171 | 171 | ||
172 | Sink::ResourceContext mResourceContext; | 172 | Sink::ResourceContext mResourceContext; |
173 | Sink::Storage::EntityStore::Ptr mEntityStore; | 173 | Sink::Storage::EntityStore::Ptr mEntityStore; |
174 | QSharedPointer<RemoteIdMap> mSyncStore; | 174 | QSharedPointer<SynchronizerStore> mSyncStore; |
175 | Sink::Storage::DataStore mSyncStorage; | 175 | Sink::Storage::DataStore mSyncStorage; |
176 | Sink::Storage::DataStore::Transaction mSyncTransaction; | 176 | Sink::Storage::DataStore::Transaction mSyncTransaction; |
177 | std::function<void(int commandId, const QByteArray &data)> mEnqueue; | 177 | std::function<void(int commandId, const QByteArray &data)> mEnqueue; |
diff --git a/common/remoteidmap.cpp b/common/synchronizerstore.cpp index a16473d..fcb3ed0 100644 --- a/common/remoteidmap.cpp +++ b/common/synchronizerstore.cpp | |||
@@ -17,7 +17,7 @@ | |||
17 | * You should have received a copy of the GNU Lesser General Public | 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/>. | 18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
19 | */ | 19 | */ |
20 | #include "remoteidmap.h" | 20 | #include "synchronizerstore.h" |
21 | 21 | ||
22 | #include <QUuid> | 22 | #include <QUuid> |
23 | #include "index.h" | 23 | #include "index.h" |
@@ -25,34 +25,34 @@ | |||
25 | 25 | ||
26 | using namespace Sink; | 26 | using namespace Sink; |
27 | 27 | ||
28 | SINK_DEBUG_AREA("remoteidmap") | 28 | SINK_DEBUG_AREA("synchronizerstore") |
29 | 29 | ||
30 | RemoteIdMap::RemoteIdMap(Sink::Storage::DataStore::Transaction &transaction) | 30 | SynchronizerStore::SynchronizerStore(Sink::Storage::DataStore::Transaction &transaction) |
31 | : mTransaction(transaction) | 31 | : mTransaction(transaction) |
32 | { | 32 | { |
33 | 33 | ||
34 | } | 34 | } |
35 | 35 | ||
36 | void RemoteIdMap::recordRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId) | 36 | void SynchronizerStore::recordRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId) |
37 | { | 37 | { |
38 | Index("rid.mapping." + bufferType, mTransaction).add(remoteId, localId); | 38 | Index("rid.mapping." + bufferType, mTransaction).add(remoteId, localId); |
39 | Index("localid.mapping." + bufferType, mTransaction).add(localId, remoteId); | 39 | Index("localid.mapping." + bufferType, mTransaction).add(localId, remoteId); |
40 | } | 40 | } |
41 | 41 | ||
42 | void RemoteIdMap::removeRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId) | 42 | void SynchronizerStore::removeRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId) |
43 | { | 43 | { |
44 | Index("rid.mapping." + bufferType, mTransaction).remove(remoteId, localId); | 44 | Index("rid.mapping." + bufferType, mTransaction).remove(remoteId, localId); |
45 | Index("localid.mapping." + bufferType, mTransaction).remove(localId, remoteId); | 45 | Index("localid.mapping." + bufferType, mTransaction).remove(localId, remoteId); |
46 | } | 46 | } |
47 | 47 | ||
48 | void RemoteIdMap::updateRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId) | 48 | void SynchronizerStore::updateRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId) |
49 | { | 49 | { |
50 | const auto oldRemoteId = Index("localid.mapping." + bufferType, mTransaction).lookup(localId); | 50 | const auto oldRemoteId = Index("localid.mapping." + bufferType, mTransaction).lookup(localId); |
51 | removeRemoteId(bufferType, localId, oldRemoteId); | 51 | removeRemoteId(bufferType, localId, oldRemoteId); |
52 | recordRemoteId(bufferType, localId, remoteId); | 52 | recordRemoteId(bufferType, localId, remoteId); |
53 | } | 53 | } |
54 | 54 | ||
55 | QByteArray RemoteIdMap::resolveRemoteId(const QByteArray &bufferType, const QByteArray &remoteId) | 55 | QByteArray SynchronizerStore::resolveRemoteId(const QByteArray &bufferType, const QByteArray &remoteId) |
56 | { | 56 | { |
57 | // Lookup local id for remote id, or insert a new pair otherwise | 57 | // Lookup local id for remote id, or insert a new pair otherwise |
58 | Index index("rid.mapping." + bufferType, mTransaction); | 58 | Index index("rid.mapping." + bufferType, mTransaction); |
@@ -65,7 +65,7 @@ QByteArray RemoteIdMap::resolveRemoteId(const QByteArray &bufferType, const QByt | |||
65 | return sinkId; | 65 | return sinkId; |
66 | } | 66 | } |
67 | 67 | ||
68 | QByteArray RemoteIdMap::resolveLocalId(const QByteArray &bufferType, const QByteArray &localId) | 68 | QByteArray SynchronizerStore::resolveLocalId(const QByteArray &bufferType, const QByteArray &localId) |
69 | { | 69 | { |
70 | QByteArray remoteId = Index("localid.mapping." + bufferType, mTransaction).lookup(localId); | 70 | QByteArray remoteId = Index("localid.mapping." + bufferType, mTransaction).lookup(localId); |
71 | if (remoteId.isEmpty()) { | 71 | if (remoteId.isEmpty()) { |
@@ -75,7 +75,7 @@ QByteArray RemoteIdMap::resolveLocalId(const QByteArray &bufferType, const QByte | |||
75 | return remoteId; | 75 | return remoteId; |
76 | } | 76 | } |
77 | 77 | ||
78 | QByteArrayList RemoteIdMap::resolveLocalIds(const QByteArray &bufferType, const QByteArrayList &localIds) | 78 | QByteArrayList SynchronizerStore::resolveLocalIds(const QByteArray &bufferType, const QByteArrayList &localIds) |
79 | { | 79 | { |
80 | QByteArrayList result; | 80 | QByteArrayList result; |
81 | for (const auto &l : localIds) { | 81 | for (const auto &l : localIds) { |
@@ -84,7 +84,7 @@ QByteArrayList RemoteIdMap::resolveLocalIds(const QByteArray &bufferType, const | |||
84 | return result; | 84 | return result; |
85 | } | 85 | } |
86 | 86 | ||
87 | QByteArray RemoteIdMap::readValue(const QByteArray &key) | 87 | QByteArray SynchronizerStore::readValue(const QByteArray &key) |
88 | { | 88 | { |
89 | QByteArray value; | 89 | QByteArray value; |
90 | mTransaction.openDatabase("values").scan(key, [&value](const QByteArray &, const QByteArray &v) { | 90 | mTransaction.openDatabase("values").scan(key, [&value](const QByteArray &, const QByteArray &v) { |
@@ -96,7 +96,7 @@ QByteArray RemoteIdMap::readValue(const QByteArray &key) | |||
96 | return value; | 96 | return value; |
97 | } | 97 | } |
98 | 98 | ||
99 | void RemoteIdMap::writeValue(const QByteArray &key, const QByteArray &value) | 99 | void SynchronizerStore::writeValue(const QByteArray &key, const QByteArray &value) |
100 | { | 100 | { |
101 | mTransaction.openDatabase("values").write(key, value); | 101 | mTransaction.openDatabase("values").write(key, value); |
102 | } | 102 | } |
diff --git a/common/remoteidmap.h b/common/synchronizerstore.h index 52e05d7..be33562 100644 --- a/common/remoteidmap.h +++ b/common/synchronizerstore.h | |||
@@ -29,10 +29,10 @@ namespace Sink { | |||
29 | /** | 29 | /** |
30 | * A remoteId mapping | 30 | * A remoteId mapping |
31 | */ | 31 | */ |
32 | class SINK_EXPORT RemoteIdMap | 32 | class SINK_EXPORT SynchronizerStore |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | RemoteIdMap(Sink::Storage::DataStore::Transaction &); | 35 | SynchronizerStore(Sink::Storage::DataStore::Transaction &); |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * Records a localId to remoteId mapping | 38 | * Records a localId to remoteId mapping |