summaryrefslogtreecommitdiffstats
path: root/common/genericresource.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-30 10:34:57 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-30 10:34:57 +0100
commit84957496800a862aa88bb2e88da0a9b2c4e19dc2 (patch)
tree88ca1be0f86d32653b18c01892a633d5015ccf32 /common/genericresource.h
parent02c311e38b8b9b80814a4e8e582d5c5a56a51056 (diff)
downloadsink-84957496800a862aa88bb2e88da0a9b2c4e19dc2.tar.gz
sink-84957496800a862aa88bb2e88da0a9b2c4e19dc2.zip
Moved all generic synchronization code to the base class.
Diffstat (limited to 'common/genericresource.h')
-rw-r--r--common/genericresource.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/common/genericresource.h b/common/genericresource.h
index ea68a25..c12c631 100644
--- a/common/genericresource.h
+++ b/common/genericresource.h
@@ -63,6 +63,50 @@ protected:
63 virtual KAsync::Job<void> replay(const QByteArray &type, const QByteArray &key, const QByteArray &value); 63 virtual KAsync::Job<void> replay(const QByteArray &type, const QByteArray &key, const QByteArray &value);
64 void onProcessorError(int errorCode, const QString &errorMessage); 64 void onProcessorError(int errorCode, const QString &errorMessage);
65 void enqueueCommand(MessageQueue &mq, int commandId, const QByteArray &data); 65 void enqueueCommand(MessageQueue &mq, int commandId, const QByteArray &data);
66
67 static void createEntity(const QByteArray &localId, const QByteArray &bufferType, const Akonadi2::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback);
68 static void modifyEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType, const Akonadi2::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback);
69 static void deleteEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType, std::function<void(const QByteArray &)> callback);
70
71 /**
72 * Records a localId to remoteId mapping
73 */
74 void recordRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId, Akonadi2::Storage::Transaction &transaction);
75 void removeRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId, Akonadi2::Storage::Transaction &transaction);
76
77 /**
78 * Tries to find a local id for the remote id, and creates a new local id otherwise.
79 *
80 * The new local id is recorded in the local to remote id mapping.
81 */
82 QByteArray resolveRemoteId(const QByteArray &type, const QByteArray &remoteId, Akonadi2::Storage::Transaction &transaction);
83
84 /**
85 * Tries to find a remote id for a local id.
86 *
87 * This can fail if the entity hasn't been written back to the server yet.
88 */
89 QByteArray resolveLocalId(const QByteArray &bufferType, const QByteArray &localId, Akonadi2::Storage::Transaction &transaction);
90
91 /**
92 * A synchronous algorithm to remove entities that are no longer existing.
93 *
94 * A list of entities is generated by @param entryGenerator.
95 * The entiry Generator typically iterates over an index to produce all existing entries.
96 * This algorithm calls @param exists for every entity of type @param type, with its remoteId. For every entity where @param exists returns false,
97 * an entity delete command is enqueued.
98 *
99 * All functions are called synchronously, and both @param entryGenerator and @param exists need to be synchronous.
100 */
101 void scanForRemovals(Akonadi2::Storage::Transaction &transaction, Akonadi2::Storage::Transaction &synchronizationTransaction, const QByteArray &bufferType, const std::function<void(const std::function<void(const QByteArray &key)> &callback)> &entryGenerator, std::function<bool(const QByteArray &remoteId)> exists);
102
103 /**
104 * An algorithm to create or modify the entity.
105 *
106 * Depending on whether the entity is locally available, or has changed.
107 */
108 void createOrModify(Akonadi2::Storage::Transaction &transaction, Akonadi2::Storage::Transaction &synchronizationTransaction, DomainTypeAdaptorFactoryInterface &adaptorFactory, const QByteArray &bufferType, const QByteArray &remoteId, const Akonadi2::ApplicationDomain::ApplicationDomainType &entity);
109
66 MessageQueue mUserQueue; 110 MessageQueue mUserQueue;
67 MessageQueue mSynchronizerQueue; 111 MessageQueue mSynchronizerQueue;
68 QByteArray mResourceInstanceIdentifier; 112 QByteArray mResourceInstanceIdentifier;