summaryrefslogtreecommitdiffstats
path: root/common/facade.h
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2015-05-15 16:22:03 +0200
committerDan Vrátil <dvratil@redhat.com>2015-05-15 16:22:31 +0200
commitb43c0cf97615957e097daef29ff8febc1ec884c8 (patch)
tree445479bf66df161e8554844a478d99d03ba43061 /common/facade.h
parent9270185becb48401bf3b2337d248763df0873107 (diff)
downloadsink-b43c0cf97615957e097daef29ff8febc1ec884c8.tar.gz
sink-b43c0cf97615957e097daef29ff8febc1ec884c8.zip
Adapt to KAsync namespace change
Diffstat (limited to 'common/facade.h')
-rw-r--r--common/facade.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/common/facade.h b/common/facade.h
index 8c6578f..dcb30b6 100644
--- a/common/facade.h
+++ b/common/facade.h
@@ -44,13 +44,13 @@ class QueryRunner : public QObject
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46public: 46public:
47 typedef std::function<Async::Job<qint64>(qint64 oldRevision, qint64 newRevision)> QueryFunction; 47 typedef std::function<KAsync::Job<qint64>(qint64 oldRevision, qint64 newRevision)> QueryFunction;
48 48
49 QueryRunner(const Akonadi2::Query &query) : mLatestRevision(0) {}; 49 QueryRunner(const Akonadi2::Query &query) : mLatestRevision(0) {};
50 /** 50 /**
51 * Starts query 51 * Starts query
52 */ 52 */
53 Async::Job<void> run(qint64 newRevision = 0) 53 KAsync::Job<void> run(qint64 newRevision = 0)
54 { 54 {
55 //TODO: JOBAPI: that last empty .then should not be necessary 55 //TODO: JOBAPI: that last empty .then should not be necessary
56 return queryFunction(mLatestRevision, newRevision).then<void, qint64>([this](qint64 revision) { 56 return queryFunction(mLatestRevision, newRevision).then<void, qint64>([this](qint64 revision) {
@@ -120,7 +120,7 @@ public:
120 return Akonadi2::ApplicationDomain::getTypeName<DomainType>(); 120 return Akonadi2::ApplicationDomain::getTypeName<DomainType>();
121 } 121 }
122 122
123 Async::Job<void> create(const Akonadi2::ApplicationDomain::Event &domainObject) Q_DECL_OVERRIDE 123 KAsync::Job<void> create(const Akonadi2::ApplicationDomain::Event &domainObject) Q_DECL_OVERRIDE
124 { 124 {
125 if (!mDomainTypeAdaptorFactory) { 125 if (!mDomainTypeAdaptorFactory) {
126 Warning() << "No domain type adaptor factory available"; 126 Warning() << "No domain type adaptor factory available";
@@ -130,25 +130,25 @@ public:
130 return sendCreateCommand(bufferTypeForDomainType(), QByteArray::fromRawData(reinterpret_cast<const char*>(entityFbb.GetBufferPointer()), entityFbb.GetSize())); 130 return sendCreateCommand(bufferTypeForDomainType(), QByteArray::fromRawData(reinterpret_cast<const char*>(entityFbb.GetBufferPointer()), entityFbb.GetSize()));
131 } 131 }
132 132
133 Async::Job<void> modify(const Akonadi2::ApplicationDomain::Event &domainObject) Q_DECL_OVERRIDE 133 KAsync::Job<void> modify(const Akonadi2::ApplicationDomain::Event &domainObject) Q_DECL_OVERRIDE
134 { 134 {
135 //TODO 135 //TODO
136 return Async::null<void>(); 136 return KAsync::null<void>();
137 } 137 }
138 138
139 Async::Job<void> remove(const Akonadi2::ApplicationDomain::Event &domainObject) Q_DECL_OVERRIDE 139 KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::Event &domainObject) Q_DECL_OVERRIDE
140 { 140 {
141 //TODO 141 //TODO
142 return Async::null<void>(); 142 return KAsync::null<void>();
143 } 143 }
144 144
145 //TODO JOBAPI return job from sync continuation to execute it as subjob? 145 //TODO JOBAPI return job from sync continuation to execute it as subjob?
146 Async::Job<void> load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > &resultProvider) Q_DECL_OVERRIDE 146 KAsync::Job<void> load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > &resultProvider) Q_DECL_OVERRIDE
147 { 147 {
148 auto runner = QSharedPointer<QueryRunner>::create(query); 148 auto runner = QSharedPointer<QueryRunner>::create(query);
149 QWeakPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > weakResultProvider = resultProvider; 149 QWeakPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > weakResultProvider = resultProvider;
150 runner->setQuery([this, weakResultProvider, query] (qint64 oldRevision, qint64 newRevision) -> Async::Job<qint64> { 150 runner->setQuery([this, weakResultProvider, query] (qint64 oldRevision, qint64 newRevision) -> KAsync::Job<qint64> {
151 return Async::start<qint64>([this, weakResultProvider, query, oldRevision, newRevision](Async::Future<qint64> &future) { 151 return KAsync::start<qint64>([this, weakResultProvider, query, oldRevision, newRevision](KAsync::Future<qint64> &future) {
152 auto resultProvider = weakResultProvider.toStrongRef(); 152 auto resultProvider = weakResultProvider.toStrongRef();
153 if (!resultProvider) { 153 if (!resultProvider) {
154 Warning() << "Tried executing query after result provider is already gone"; 154 Warning() << "Tried executing query after result provider is already gone";
@@ -175,7 +175,7 @@ public:
175 } 175 }
176 176
177 //We have to capture the runner to keep it alive 177 //We have to capture the runner to keep it alive
178 return synchronizeResource(query.syncOnDemand, query.processAll).template then<void>([runner](Async::Future<void> &future) { 178 return synchronizeResource(query.syncOnDemand, query.processAll).template then<void>([runner](KAsync::Future<void> &future) {
179 runner->run().then<void>([&future]() { 179 runner->run().then<void>([&future]() {
180 future.setFinished(); 180 future.setFinished();
181 }).exec(); 181 }).exec();
@@ -183,7 +183,7 @@ public:
183 } 183 }
184 184
185protected: 185protected:
186 Async::Job<void> sendCreateCommand(const QByteArray &resourceBufferType, const QByteArray &buffer) 186 KAsync::Job<void> sendCreateCommand(const QByteArray &resourceBufferType, const QByteArray &buffer)
187 { 187 {
188 flatbuffers::FlatBufferBuilder fbb; 188 flatbuffers::FlatBufferBuilder fbb;
189 //This is the resource buffer type and not the domain type 189 //This is the resource buffer type and not the domain type
@@ -195,7 +195,7 @@ protected:
195 return mResourceAccess->sendCommand(Akonadi2::Commands::CreateEntityCommand, fbb); 195 return mResourceAccess->sendCommand(Akonadi2::Commands::CreateEntityCommand, fbb);
196 } 196 }
197 197
198 Async::Job<void> synchronizeResource(bool sync, bool processAll) 198 KAsync::Job<void> synchronizeResource(bool sync, bool processAll)
199 { 199 {
200 //TODO check if a sync is necessary 200 //TODO check if a sync is necessary
201 //TODO Only sync what was requested 201 //TODO Only sync what was requested
@@ -203,17 +203,17 @@ protected:
203 //TODO the synchronization should normally not be necessary: We just return what is already available. 203 //TODO the synchronization should normally not be necessary: We just return what is already available.
204 204
205 if (sync || processAll) { 205 if (sync || processAll) {
206 return Async::start<void>([=](Async::Future<void> &future) { 206 return KAsync::start<void>([=](KAsync::Future<void> &future) {
207 mResourceAccess->open(); 207 mResourceAccess->open();
208 mResourceAccess->synchronizeResource(sync, processAll).then<void>([&future]() { 208 mResourceAccess->synchronizeResource(sync, processAll).then<void>([&future]() {
209 future.setFinished(); 209 future.setFinished();
210 }).exec(); 210 }).exec();
211 }); 211 });
212 } 212 }
213 return Async::null<void>(); 213 return KAsync::null<void>();
214 } 214 }
215 215
216 virtual Async::Job<qint64> load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> > &resultProvider, qint64 oldRevision, qint64 newRevision) { return Async::null<qint64>(); }; 216 virtual KAsync::Job<qint64> load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> > &resultProvider, qint64 oldRevision, qint64 newRevision) { return KAsync::null<qint64>(); };
217 217
218protected: 218protected:
219 //TODO use one resource access instance per application => make static 219 //TODO use one resource access instance per application => make static