summaryrefslogtreecommitdiffstats
path: root/common/entitystorage.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-09-08 21:08:54 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-09-08 21:08:54 +0200
commitbbbda3fe9444eba6795a5490da0425cdf8f26361 (patch)
treed558ce110b71278df91135db5ac29c484e588ac5 /common/entitystorage.cpp
parent43ae43bc74800473aadf9c5c807603cdf8516d36 (diff)
downloadsink-bbbda3fe9444eba6795a5490da0425cdf8f26361.tar.gz
sink-bbbda3fe9444eba6795a5490da0425cdf8f26361.zip
Added support for mails to akonadi and the dummyresource.
Adding new types definitely needs to become easier.
Diffstat (limited to 'common/entitystorage.cpp')
-rw-r--r--common/entitystorage.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/common/entitystorage.cpp b/common/entitystorage.cpp
index 8a3391e..bcc3562 100644
--- a/common/entitystorage.cpp
+++ b/common/entitystorage.cpp
@@ -19,9 +19,9 @@
19 19
20#include "entitystorage.h" 20#include "entitystorage.h"
21 21
22static void scan(const Akonadi2::Storage::Transaction &transaction, const QByteArray &key, std::function<bool(const QByteArray &key, const Akonadi2::Entity &entity)> callback) 22static void scan(const Akonadi2::Storage::Transaction &transaction, const QByteArray &key, std::function<bool(const QByteArray &key, const Akonadi2::Entity &entity)> callback, const QByteArray &bufferType)
23{ 23{
24 transaction.openDatabase().scan(key, [=](const QByteArray &key, const QByteArray &value) -> bool { 24 transaction.openDatabase(bufferType + ".main").scan(key, [=](const QByteArray &key, const QByteArray &value) -> bool {
25 //Skip internals 25 //Skip internals
26 if (Akonadi2::Storage::isInternalKey(key)) { 26 if (Akonadi2::Storage::isInternalKey(key)) {
27 return true; 27 return true;
@@ -58,17 +58,17 @@ void EntityStorageBase::readValue(const Akonadi2::Storage::Transaction &transact
58 auto domainObject = create(key, revision, mDomainTypeAdaptorFactory->createAdaptor(entity)); 58 auto domainObject = create(key, revision, mDomainTypeAdaptorFactory->createAdaptor(entity));
59 resultCallback(domainObject); 59 resultCallback(domainObject);
60 return true; 60 return true;
61 }); 61 }, mBufferType);
62} 62}
63 63
64static ResultSet fullScan(const Akonadi2::Storage::Transaction &transaction) 64static ResultSet fullScan(const Akonadi2::Storage::Transaction &transaction, const QByteArray &bufferType)
65{ 65{
66 //TODO use a result set with an iterator, to read values on demand 66 //TODO use a result set with an iterator, to read values on demand
67 QVector<QByteArray> keys; 67 QVector<QByteArray> keys;
68 scan(transaction, QByteArray(), [=, &keys](const QByteArray &key, const Akonadi2::Entity &) { 68 scan(transaction, QByteArray(), [=, &keys](const QByteArray &key, const Akonadi2::Entity &) {
69 keys << key; 69 keys << key;
70 return true; 70 return true;
71 }); 71 }, bufferType);
72 Trace() << "Full scan found " << keys.size() << " results"; 72 Trace() << "Full scan found " << keys.size() << " results";
73 return ResultSet(keys); 73 return ResultSet(keys);
74} 74}
@@ -99,7 +99,7 @@ ResultSet EntityStorageBase::getResultSet(const Akonadi2::Query &query, Akonadi2
99 99
100 //We do a full scan if there were no indexes available to create the initial set. 100 //We do a full scan if there were no indexes available to create the initial set.
101 if (appliedFilters.isEmpty()) { 101 if (appliedFilters.isEmpty()) {
102 resultSet = fullScan(transaction); 102 resultSet = fullScan(transaction, mBufferType);
103 } 103 }
104 104
105 auto filter = [remainingFilters, query, baseRevision, topRevision](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject) -> bool { 105 auto filter = [remainingFilters, query, baseRevision, topRevision](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject) -> bool {