summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dummyresource/facade.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/dummyresource/facade.cpp b/dummyresource/facade.cpp
index 288552c..162f76f 100644
--- a/dummyresource/facade.cpp
+++ b/dummyresource/facade.cpp
@@ -49,6 +49,7 @@ class DummyEventAdaptor : public Akonadi2::Domain::Event {
49public: 49public:
50 DummyEventAdaptor(const QString &resource, const QString &identifier, qint64 revision):Akonadi2::Domain::Event(resource, identifier, revision){}; 50 DummyEventAdaptor(const QString &resource, const QString &identifier, qint64 revision):Akonadi2::Domain::Event(resource, identifier, revision){};
51 51
52 //TODO
52 // void setProperty(const QString &key, const QVariant &value) 53 // void setProperty(const QString &key, const QVariant &value)
53 // { 54 // {
54 // //Record changes to send to resource? 55 // //Record changes to send to resource?
@@ -66,25 +67,23 @@ public:
66 67
67 //Data is read-only 68 //Data is read-only
68 DummyEvent const *buffer; 69 DummyEvent const *buffer;
69};
70 70
71static Akonadi2::Domain::Event::Ptr createEvent(const std::string &data) 71 //Keep query alive so values remain valid
72{ 72 QSharedPointer<ReadTransaction> db;
73 //We will have to buffers stored after each other 73};
74 auto eventBuffer = GetDummyEvent(data.c_str());
75 auto event = QSharedPointer<DummyEventAdaptor>::create("dummyresource", "key", 0);
76 event->buffer = eventBuffer;
77 // qDebug() << readEvent->summary()->c_str();
78 return event;
79}
80 74
81void DummyResourceFacade::load(const Akonadi2::Query &query, const std::function<void(const Akonadi2::Domain::Event::Ptr &)> &resultCallback) 75void DummyResourceFacade::load(const Akonadi2::Query &query, const std::function<void(const Akonadi2::Domain::Event::Ptr &)> &resultCallback)
82{ 76{
83 qDebug() << "load called"; 77 qDebug() << "load called";
84 //TODO only read values matching the query 78 //TODO only read values matching the query
85 //FIXME the interface should probably simply return a void pointer + size 79 auto db = QSharedPointer<ReadTransaction>::create("dummyresource");
86 mDatabase->read("", [resultCallback](const std::string &result) { 80 db->read("", [resultCallback, db](void *data, int size) {
87 resultCallback(createEvent(result)); 81 //TODO read second buffer as well
82 auto eventBuffer = GetDummyEvent(data);
83 auto event = QSharedPointer<DummyEventAdaptor>::create("dummyresource", "key", 0);
84 event->buffer = eventBuffer;
85 event->db = db;
86 resultCallback(event);
88 }); 87 });
89} 88}
90 89