diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-11 13:06:27 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-11-11 15:26:32 +0100 |
commit | 4e6b3ce7d1ce97c3e1fb9ae53c5b2be1787acc6b (patch) | |
tree | 08d80bbe1cc890f949110a760cba18e8f2b5249b /common/synchronizer.h | |
parent | e5bec3abfe2f2463244d65386dbd1088bf56f5f3 (diff) | |
download | sink-4e6b3ce7d1ce97c3e1fb9ae53c5b2be1787acc6b.tar.gz sink-4e6b3ce7d1ce97c3e1fb9ae53c5b2be1787acc6b.zip |
Prepared new query based synchronization API
Diffstat (limited to 'common/synchronizer.h')
-rw-r--r-- | common/synchronizer.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/common/synchronizer.h b/common/synchronizer.h index c03c425..47518ee 100644 --- a/common/synchronizer.h +++ b/common/synchronizer.h | |||
@@ -90,11 +90,42 @@ protected: | |||
90 | void modify(const DomainType &entity); | 90 | void modify(const DomainType &entity); |
91 | // template <typename DomainType> | 91 | // template <typename DomainType> |
92 | // void remove(const DomainType &entity); | 92 | // void remove(const DomainType &entity); |
93 | QByteArrayList resolveFilter(const QueryBase::Comparator &filter); | ||
93 | 94 | ||
94 | virtual KAsync::Job<void> synchronizeWithSource(const Sink::QueryBase &query) = 0; | 95 | virtual KAsync::Job<void> synchronizeWithSource(const Sink::QueryBase &query) = 0; |
95 | 96 | ||
97 | struct SyncRequest { | ||
98 | SyncRequest(const Sink::QueryBase &q) | ||
99 | : flushQueue(false), | ||
100 | query(q) | ||
101 | { | ||
102 | } | ||
103 | |||
104 | bool flushQueue; | ||
105 | Sink::QueryBase query; | ||
106 | }; | ||
107 | |||
108 | /** | ||
109 | * This allows the synchronizer to turn a single query into multiple synchronization requests. | ||
110 | * | ||
111 | * The idea is the following; | ||
112 | * The input query is a specification by the application of what data needs to be made available. | ||
113 | * Requests could be: | ||
114 | * * Give me everything (signified by the default constructed/empty query) | ||
115 | * * Give me all mails of folder X | ||
116 | * * Give me all mails of folders matching some constraints | ||
117 | * | ||
118 | * getSyncRequests allows the resource implementation to apply it's own defaults to that request; | ||
119 | * * While a maildir resource might give you always all emails of a folder, an IMAP resource might have a date limit, to i.e. only retrieve the last 14 days worth of data. | ||
120 | * * A resource get's to define what "give me everything" means. For email that may be turned into first a requests for folders, and then a request for all emails in those folders. | ||
121 | * | ||
122 | * This will allow synchronizeWithSource to focus on just getting to the content. | ||
123 | */ | ||
124 | virtual QList<Synchronizer::SyncRequest> getSyncRequests(const Sink::QueryBase &query); | ||
125 | |||
96 | private: | 126 | private: |
97 | void modifyIfChanged(Storage::EntityStore &store, const QByteArray &bufferType, const QByteArray &sinkId, const Sink::ApplicationDomain::ApplicationDomainType &entity); | 127 | void modifyIfChanged(Storage::EntityStore &store, const QByteArray &bufferType, const QByteArray &sinkId, const Sink::ApplicationDomain::ApplicationDomainType &entity); |
128 | KAsync::Job<void> processSyncQueue(); | ||
98 | 129 | ||
99 | Sink::ResourceContext mResourceContext; | 130 | Sink::ResourceContext mResourceContext; |
100 | Sink::Storage::EntityStore::Ptr mEntityStore; | 131 | Sink::Storage::EntityStore::Ptr mEntityStore; |
@@ -102,6 +133,7 @@ private: | |||
102 | Sink::Storage::DataStore mSyncStorage; | 133 | Sink::Storage::DataStore mSyncStorage; |
103 | Sink::Storage::DataStore::Transaction mSyncTransaction; | 134 | Sink::Storage::DataStore::Transaction mSyncTransaction; |
104 | std::function<void(int commandId, const QByteArray &data)> mEnqueue; | 135 | std::function<void(int commandId, const QByteArray &data)> mEnqueue; |
136 | QList<SyncRequest> mSyncRequestQueue; | ||
105 | MessageQueue *mMessageQueue; | 137 | MessageQueue *mMessageQueue; |
106 | bool mSyncInProgress; | 138 | bool mSyncInProgress; |
107 | }; | 139 | }; |