diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2014-12-04 01:16:20 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2014-12-04 01:16:20 +0100 |
commit | 7cf9ad9456b0ef80372b2a4f5b48f06ad390ec59 (patch) | |
tree | 27141de909d67d321fe78b6d0f47bcfefa5e9bc1 | |
parent | ef4b74960718bd492dc8f2e49f61ff9d3e5bd10a (diff) | |
download | sink-7cf9ad9456b0ef80372b2a4f5b48f06ad390ec59.tar.gz sink-7cf9ad9456b0ef80372b2a4f5b48f06ad390ec59.zip |
The resource can read (but not very selective yet).
-rw-r--r-- | dummyresource/facade.cpp | 25 |
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 { | |||
49 | public: | 49 | public: |
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 | ||
71 | static 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 | ||
81 | void DummyResourceFacade::load(const Akonadi2::Query &query, const std::function<void(const Akonadi2::Domain::Event::Ptr &)> &resultCallback) | 75 | void 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 | ||