diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-06-08 10:47:57 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-06-08 10:47:57 +0200 |
commit | 63919d3040295415306267df7b66e7a5e2c9395f (patch) | |
tree | cb5e416487243ca68e6ad3ecff40a00527017ec6 | |
parent | 810543a625074fb8685c7c59e36123c055e8fda6 (diff) | |
download | sink-63919d3040295415306267df7b66e7a5e2c9395f.tar.gz sink-63919d3040295415306267df7b66e7a5e2c9395f.zip |
Differentiate between resource name and instance identifier
-rw-r--r-- | common/clientapi.h | 15 | ||||
-rw-r--r-- | common/domain/event.cpp | 4 | ||||
-rw-r--r-- | common/resourceaccess.cpp | 29 | ||||
-rw-r--r-- | examples/dummyresource/facade.cpp | 8 | ||||
-rw-r--r-- | examples/dummyresource/resourcefacade.cpp | 2 | ||||
-rw-r--r-- | examples/dummyresource/resourcefactory.cpp | 2 | ||||
-rw-r--r-- | synchronizer/listener.cpp | 17 | ||||
-rw-r--r-- | synchronizer/listener.h | 1 | ||||
-rw-r--r-- | tests/dummyresourcetest.cpp | 28 |
9 files changed, 62 insertions, 44 deletions
diff --git a/common/clientapi.h b/common/clientapi.h index 38ec1ee..4948c59 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -193,6 +193,13 @@ public: | |||
193 | return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage"; | 193 | return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage"; |
194 | } | 194 | } |
195 | 195 | ||
196 | static QByteArray resourceName(const QByteArray &instanceIdentifier) | ||
197 | { | ||
198 | auto split = instanceIdentifier.split('.'); | ||
199 | split.removeLast(); | ||
200 | return split.join('.'); | ||
201 | } | ||
202 | |||
196 | /** | 203 | /** |
197 | * Asynchronusly load a dataset | 204 | * Asynchronusly load a dataset |
198 | */ | 205 | */ |
@@ -209,7 +216,7 @@ public: | |||
209 | KAsync::iterate(query.resources) | 216 | KAsync::iterate(query.resources) |
210 | .template each<void, QByteArray>([query, resultSet](const QByteArray &resource, KAsync::Future<void> &future) { | 217 | .template each<void, QByteArray>([query, resultSet](const QByteArray &resource, KAsync::Future<void> &future) { |
211 | //TODO pass resource identifier to factory | 218 | //TODO pass resource identifier to factory |
212 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resource); | 219 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resource)); |
213 | if (facade) { | 220 | if (facade) { |
214 | facade->load(query, resultSet).template then<void>([&future](){future.setFinished();}).exec(); | 221 | facade->load(query, resultSet).template then<void>([&future](){future.setFinished();}).exec(); |
215 | //Keep the facade alive for the lifetime of the resultSet. | 222 | //Keep the facade alive for the lifetime of the resultSet. |
@@ -254,7 +261,7 @@ public: | |||
254 | template <class DomainType> | 261 | template <class DomainType> |
255 | static void create(const DomainType &domainObject, const QByteArray &resourceIdentifier) { | 262 | static void create(const DomainType &domainObject, const QByteArray &resourceIdentifier) { |
256 | //Potentially move to separate thread as well | 263 | //Potentially move to separate thread as well |
257 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceIdentifier); | 264 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier)); |
258 | facade->create(domainObject).exec().waitForFinished(); | 265 | facade->create(domainObject).exec().waitForFinished(); |
259 | //TODO return job? | 266 | //TODO return job? |
260 | } | 267 | } |
@@ -267,7 +274,7 @@ public: | |||
267 | template <class DomainType> | 274 | template <class DomainType> |
268 | static void modify(const DomainType &domainObject, const QByteArray &resourceIdentifier) { | 275 | static void modify(const DomainType &domainObject, const QByteArray &resourceIdentifier) { |
269 | //Potentially move to separate thread as well | 276 | //Potentially move to separate thread as well |
270 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceIdentifier); | 277 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier)); |
271 | facade->modify(domainObject).exec().waitForFinished(); | 278 | facade->modify(domainObject).exec().waitForFinished(); |
272 | //TODO return job? | 279 | //TODO return job? |
273 | } | 280 | } |
@@ -278,7 +285,7 @@ public: | |||
278 | template <class DomainType> | 285 | template <class DomainType> |
279 | static void remove(const DomainType &domainObject, const QByteArray &resourceIdentifier) { | 286 | static void remove(const DomainType &domainObject, const QByteArray &resourceIdentifier) { |
280 | //Potentially move to separate thread as well | 287 | //Potentially move to separate thread as well |
281 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceIdentifier); | 288 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier)); |
282 | facade->remove(domainObject).exec().waitForFinished(); | 289 | facade->remove(domainObject).exec().waitForFinished(); |
283 | //TODO return job? | 290 | //TODO return job? |
284 | } | 291 | } |
diff --git a/common/domain/event.cpp b/common/domain/event.cpp index c435c6b..08ce698 100644 --- a/common/domain/event.cpp +++ b/common/domain/event.cpp | |||
@@ -36,7 +36,7 @@ ResultSet TypeImplementation<Event>::queryIndexes(const Akonadi2::Query &query, | |||
36 | { | 36 | { |
37 | QVector<QByteArray> keys; | 37 | QVector<QByteArray> keys; |
38 | if (query.propertyFilter.contains("uid")) { | 38 | if (query.propertyFilter.contains("uid")) { |
39 | Index uidIndex(Akonadi2::Store::storageLocation(), resourceInstanceIdentifier + "index.uid", Akonadi2::Storage::ReadOnly); | 39 | Index uidIndex(Akonadi2::Store::storageLocation(), resourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly); |
40 | uidIndex.lookup(query.propertyFilter.value("uid").toByteArray(), [&](const QByteArray &value) { | 40 | uidIndex.lookup(query.propertyFilter.value("uid").toByteArray(), [&](const QByteArray &value) { |
41 | keys << value; | 41 | keys << value; |
42 | }, | 42 | }, |
@@ -50,7 +50,7 @@ ResultSet TypeImplementation<Event>::queryIndexes(const Akonadi2::Query &query, | |||
50 | 50 | ||
51 | void TypeImplementation<Event>::index(const Event &type) | 51 | void TypeImplementation<Event>::index(const Event &type) |
52 | { | 52 | { |
53 | Index uidIndex(Akonadi2::Store::storageLocation(), type.resourceInstanceIdentifier() + "index.uid", Akonadi2::Storage::ReadWrite); | 53 | Index uidIndex(Akonadi2::Store::storageLocation(), type.resourceInstanceIdentifier() + ".index.uid", Akonadi2::Storage::ReadWrite); |
54 | const auto uid = type.getProperty("uid"); | 54 | const auto uid = type.getProperty("uid"); |
55 | if (uid.isValid()) { | 55 | if (uid.isValid()) { |
56 | uidIndex.add(uid.toByteArray(), type.identifier()); | 56 | uidIndex.add(uid.toByteArray(), type.identifier()); |
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index feffcf4..249dd55 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -69,10 +69,11 @@ public: | |||
69 | class ResourceAccess::Private | 69 | class ResourceAccess::Private |
70 | { | 70 | { |
71 | public: | 71 | public: |
72 | Private(const QByteArray &name, ResourceAccess *ra); | 72 | Private(const QByteArray &name, const QByteArray &instanceIdentifier, ResourceAccess *ra); |
73 | KAsync::Job<void> tryToConnect(); | 73 | KAsync::Job<void> tryToConnect(); |
74 | KAsync::Job<void> initializeSocket(); | 74 | KAsync::Job<void> initializeSocket(); |
75 | QByteArray resourceName; | 75 | QByteArray resourceName; |
76 | QByteArray resourceInstanceIdentifier; | ||
76 | QSharedPointer<QLocalSocket> socket; | 77 | QSharedPointer<QLocalSocket> socket; |
77 | QByteArray partialMessageBuffer; | 78 | QByteArray partialMessageBuffer; |
78 | flatbuffers::FlatBufferBuilder fbb; | 79 | flatbuffers::FlatBufferBuilder fbb; |
@@ -82,8 +83,9 @@ public: | |||
82 | uint messageId; | 83 | uint messageId; |
83 | }; | 84 | }; |
84 | 85 | ||
85 | ResourceAccess::Private::Private(const QByteArray &name, ResourceAccess *q) | 86 | ResourceAccess::Private::Private(const QByteArray &name, const QByteArray &instanceIdentifier, ResourceAccess *q) |
86 | : resourceName(name), | 87 | : resourceName(name), |
88 | resourceInstanceIdentifier(instanceIdentifier), | ||
87 | messageId(0) | 89 | messageId(0) |
88 | { | 90 | { |
89 | } | 91 | } |
@@ -118,7 +120,7 @@ KAsync::Job<void> ResourceAccess::Private::tryToConnect() | |||
118 | [this](KAsync::Future<void> &future) { | 120 | [this](KAsync::Future<void> &future) { |
119 | Trace() << "Loop"; | 121 | Trace() << "Loop"; |
120 | KAsync::wait(50) | 122 | KAsync::wait(50) |
121 | .then(connectToServer(resourceName)) | 123 | .then(connectToServer(resourceInstanceIdentifier)) |
122 | .then<void, QSharedPointer<QLocalSocket> >([this, &future](const QSharedPointer<QLocalSocket> &s) { | 124 | .then<void, QSharedPointer<QLocalSocket> >([this, &future](const QSharedPointer<QLocalSocket> &s) { |
123 | Q_ASSERT(s); | 125 | Q_ASSERT(s); |
124 | socket = s; | 126 | socket = s; |
@@ -134,7 +136,7 @@ KAsync::Job<void> ResourceAccess::Private::initializeSocket() | |||
134 | { | 136 | { |
135 | return KAsync::start<void>([this](KAsync::Future<void> &future) { | 137 | return KAsync::start<void>([this](KAsync::Future<void> &future) { |
136 | Trace() << "Trying to connect"; | 138 | Trace() << "Trying to connect"; |
137 | connectToServer(resourceName).then<void, QSharedPointer<QLocalSocket> >([this, &future](const QSharedPointer<QLocalSocket> &s) { | 139 | connectToServer(resourceInstanceIdentifier).then<void, QSharedPointer<QLocalSocket> >([this, &future](const QSharedPointer<QLocalSocket> &s) { |
138 | Trace() << "Connected to resource, without having to start it."; | 140 | Trace() << "Connected to resource, without having to start it."; |
139 | Q_ASSERT(s); | 141 | Q_ASSERT(s); |
140 | socket = s; | 142 | socket = s; |
@@ -144,7 +146,7 @@ KAsync::Job<void> ResourceAccess::Private::initializeSocket() | |||
144 | Trace() << "Failed to connect, starting resource"; | 146 | Trace() << "Failed to connect, starting resource"; |
145 | //We failed to connect, so let's start the resource | 147 | //We failed to connect, so let's start the resource |
146 | QStringList args; | 148 | QStringList args; |
147 | args << resourceName; | 149 | args << resourceInstanceIdentifier; |
148 | qint64 pid = 0; | 150 | qint64 pid = 0; |
149 | if (QProcess::startDetached("akonadi2_synchronizer", args, QDir::homePath(), &pid)) { | 151 | if (QProcess::startDetached("akonadi2_synchronizer", args, QDir::homePath(), &pid)) { |
150 | Trace() << "Started resource " << pid; | 152 | Trace() << "Started resource " << pid; |
@@ -159,9 +161,16 @@ KAsync::Job<void> ResourceAccess::Private::initializeSocket() | |||
159 | }); | 161 | }); |
160 | } | 162 | } |
161 | 163 | ||
162 | ResourceAccess::ResourceAccess(const QByteArray &resourceName, QObject *parent) | 164 | static QByteArray getResourceName(const QByteArray &instanceIdentifier) |
165 | { | ||
166 | auto split = instanceIdentifier.split('.'); | ||
167 | split.removeLast(); | ||
168 | return split.join('.'); | ||
169 | } | ||
170 | |||
171 | ResourceAccess::ResourceAccess(const QByteArray &resourceInstanceIdentifier, QObject *parent) | ||
163 | : QObject(parent), | 172 | : QObject(parent), |
164 | d(new Private(resourceName, this)) | 173 | d(new Private(getResourceName(resourceInstanceIdentifier), resourceInstanceIdentifier, this)) |
165 | { | 174 | { |
166 | log("Starting access"); | 175 | log("Starting access"); |
167 | } | 176 | } |
@@ -316,7 +325,7 @@ void ResourceAccess::disconnected() | |||
316 | void ResourceAccess::connectionError(QLocalSocket::LocalSocketError error) | 325 | void ResourceAccess::connectionError(QLocalSocket::LocalSocketError error) |
317 | { | 326 | { |
318 | if (error == QLocalSocket::PeerClosedError) { | 327 | if (error == QLocalSocket::PeerClosedError) { |
319 | Log(d->resourceName) << "The resource closed the connection."; | 328 | Log(d->resourceInstanceIdentifier) << "The resource closed the connection."; |
320 | } else { | 329 | } else { |
321 | Warning() << QString("Connection error: %1 : %2").arg(error).arg(d->socket->errorString()); | 330 | Warning() << QString("Connection error: %1 : %2").arg(error).arg(d->socket->errorString()); |
322 | } | 331 | } |
@@ -379,7 +388,7 @@ bool ResourceAccess::processMessageBuffer() | |||
379 | auto buffer = GetNotification(d->partialMessageBuffer.constData() + headerSize); | 388 | auto buffer = GetNotification(d->partialMessageBuffer.constData() + headerSize); |
380 | switch (buffer->type()) { | 389 | switch (buffer->type()) { |
381 | case Akonadi2::NotificationType::NotificationType_Shutdown: | 390 | case Akonadi2::NotificationType::NotificationType_Shutdown: |
382 | Log(d->resourceName) << "Received shutdown notification."; | 391 | Log(d->resourceInstanceIdentifier) << "Received shutdown notification."; |
383 | close(); | 392 | close(); |
384 | break; | 393 | break; |
385 | default: | 394 | default: |
@@ -406,7 +415,7 @@ void ResourceAccess::callCallbacks(int id) | |||
406 | 415 | ||
407 | void ResourceAccess::log(const QString &message) | 416 | void ResourceAccess::log(const QString &message) |
408 | { | 417 | { |
409 | Log(d->resourceName) << this << message; | 418 | Log(d->resourceInstanceIdentifier) << this << message; |
410 | } | 419 | } |
411 | 420 | ||
412 | } | 421 | } |
diff --git a/examples/dummyresource/facade.cpp b/examples/dummyresource/facade.cpp index 9849a92..9d4f64b 100644 --- a/examples/dummyresource/facade.cpp +++ b/examples/dummyresource/facade.cpp | |||
@@ -40,7 +40,7 @@ using namespace flatbuffers; | |||
40 | 40 | ||
41 | 41 | ||
42 | DummyResourceFacade::DummyResourceFacade() | 42 | DummyResourceFacade::DummyResourceFacade() |
43 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>("org.kde.dummy", QSharedPointer<DummyEventAdaptorFactory>::create()) | 43 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>("org.kde.dummy.instance1", QSharedPointer<DummyEventAdaptorFactory>::create()) |
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
@@ -82,7 +82,7 @@ void DummyResourceFacade::readValue(const QSharedPointer<Akonadi2::Storage> &sto | |||
82 | //Not i.e. for tags that are stored as flags in each entity of an imap store. | 82 | //Not i.e. for tags that are stored as flags in each entity of an imap store. |
83 | //additional properties that don't have a 1:1 mapping (such as separately stored tags), | 83 | //additional properties that don't have a 1:1 mapping (such as separately stored tags), |
84 | //could be added to the adaptor | 84 | //could be added to the adaptor |
85 | auto event = QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("org.kde.dummy", key, revision, mDomainTypeAdaptorFactory->createAdaptor(entity)); | 85 | auto event = QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("org.kde.dummy.instance1", key, revision, mDomainTypeAdaptorFactory->createAdaptor(entity)); |
86 | resultCallback(event); | 86 | resultCallback(event); |
87 | return true; | 87 | return true; |
88 | }); | 88 | }); |
@@ -91,7 +91,7 @@ void DummyResourceFacade::readValue(const QSharedPointer<Akonadi2::Storage> &sto | |||
91 | static ResultSet getResultSet(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::Storage> &storage) | 91 | static ResultSet getResultSet(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::Storage> &storage) |
92 | { | 92 | { |
93 | QSet<QByteArray> appliedFilters; | 93 | QSet<QByteArray> appliedFilters; |
94 | ResultSet resultSet = Akonadi2::ApplicationDomain::TypeImplementation<Akonadi2::ApplicationDomain::Event>::queryIndexes(query, "org.kde.dummy", appliedFilters); | 94 | ResultSet resultSet = Akonadi2::ApplicationDomain::TypeImplementation<Akonadi2::ApplicationDomain::Event>::queryIndexes(query, "org.kde.dummy.instance1", appliedFilters); |
95 | const auto remainingFilters = query.propertyFilter.keys().toSet() - appliedFilters; | 95 | const auto remainingFilters = query.propertyFilter.keys().toSet() - appliedFilters; |
96 | 96 | ||
97 | if (resultSet.isEmpty()) { | 97 | if (resultSet.isEmpty()) { |
@@ -109,7 +109,7 @@ static ResultSet getResultSet(const Akonadi2::Query &query, const QSharedPointer | |||
109 | KAsync::Job<qint64> DummyResourceFacade::load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> > &resultProvider, qint64 oldRevision, qint64 newRevision) | 109 | KAsync::Job<qint64> DummyResourceFacade::load(const Akonadi2::Query &query, const QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> > &resultProvider, qint64 oldRevision, qint64 newRevision) |
110 | { | 110 | { |
111 | return KAsync::start<qint64>([=]() { | 111 | return KAsync::start<qint64>([=]() { |
112 | auto storage = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::Store::storageLocation(), "org.kde.dummy"); | 112 | auto storage = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::Store::storageLocation(), "org.kde.dummy.instance1"); |
113 | storage->setDefaultErrorHandler([](const Akonadi2::Storage::Error &error) { | 113 | storage->setDefaultErrorHandler([](const Akonadi2::Storage::Error &error) { |
114 | Warning() << "Error during query: " << error.store << error.message; | 114 | Warning() << "Error during query: " << error.store << error.message; |
115 | }); | 115 | }); |
diff --git a/examples/dummyresource/resourcefacade.cpp b/examples/dummyresource/resourcefacade.cpp index af293d4..31c0b21 100644 --- a/examples/dummyresource/resourcefacade.cpp +++ b/examples/dummyresource/resourcefacade.cpp | |||
@@ -78,6 +78,6 @@ KAsync::Job<void> DummyResourceConfigFacade::load(const Akonadi2::Query &query, | |||
78 | // | 78 | // |
79 | //TODO use correct instance identifier | 79 | //TODO use correct instance identifier |
80 | //TODO key == instance identifier ? | 80 | //TODO key == instance identifier ? |
81 | resultProvider->add(QSharedPointer<Akonadi2::ApplicationDomain::AkonadiResource>::create("org.kde.dummy", "org.kde.dummy.config", 0, memoryAdaptor)); | 81 | resultProvider->add(QSharedPointer<Akonadi2::ApplicationDomain::AkonadiResource>::create("org.kde.dummy.instance1", "org.kde.dummy.config", 0, memoryAdaptor)); |
82 | }); | 82 | }); |
83 | } | 83 | } |
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp index 31ec972..e244131 100644 --- a/examples/dummyresource/resourcefactory.cpp +++ b/examples/dummyresource/resourcefactory.cpp | |||
@@ -158,7 +158,7 @@ KAsync::Job<void> DummyResource::synchronizeWithSource(Akonadi2::Pipeline *pipel | |||
158 | { | 158 | { |
159 | return KAsync::start<void>([this, pipeline](KAsync::Future<void> &f) { | 159 | return KAsync::start<void>([this, pipeline](KAsync::Future<void> &f) { |
160 | //TODO use a read-only transaction during the complete sync to sync against a defined revision | 160 | //TODO use a read-only transaction during the complete sync to sync against a defined revision |
161 | auto storage = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::Store::storageLocation(), "org.kde.dummy"); | 161 | auto storage = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::Store::storageLocation(), "org.kde.dummy.instance1"); |
162 | for (auto it = s_dataSource.constBegin(); it != s_dataSource.constEnd(); it++) { | 162 | for (auto it = s_dataSource.constBegin(); it != s_dataSource.constEnd(); it++) { |
163 | bool isNew = true; | 163 | bool isNew = true; |
164 | if (storage->exists()) { | 164 | if (storage->exists()) { |
diff --git a/synchronizer/listener.cpp b/synchronizer/listener.cpp index 71723c9..c8b81e8 100644 --- a/synchronizer/listener.cpp +++ b/synchronizer/listener.cpp | |||
@@ -35,12 +35,13 @@ | |||
35 | #include <QTimer> | 35 | #include <QTimer> |
36 | #include <QLockFile> | 36 | #include <QLockFile> |
37 | 37 | ||
38 | Listener::Listener(const QByteArray &resourceName, QObject *parent) | 38 | Listener::Listener(const QByteArray &resourceInstanceIdentifier, QObject *parent) |
39 | : QObject(parent), | 39 | : QObject(parent), |
40 | m_server(new QLocalServer(this)), | 40 | m_server(new QLocalServer(this)), |
41 | m_resourceName(resourceName), | 41 | m_resourceName(Akonadi2::Store::resourceName(resourceInstanceIdentifier)), |
42 | m_resourceInstanceIdentifier(resourceInstanceIdentifier), | ||
42 | m_resource(0), | 43 | m_resource(0), |
43 | m_pipeline(new Akonadi2::Pipeline(resourceName, parent)), | 44 | m_pipeline(new Akonadi2::Pipeline(resourceInstanceIdentifier, parent)), |
44 | m_clientBufferProcessesTimer(new QTimer(this)), | 45 | m_clientBufferProcessesTimer(new QTimer(this)), |
45 | m_messageId(0) | 46 | m_messageId(0) |
46 | { | 47 | { |
@@ -48,19 +49,19 @@ Listener::Listener(const QByteArray &resourceName, QObject *parent) | |||
48 | this, &Listener::refreshRevision); | 49 | this, &Listener::refreshRevision); |
49 | connect(m_server, &QLocalServer::newConnection, | 50 | connect(m_server, &QLocalServer::newConnection, |
50 | this, &Listener::acceptConnection); | 51 | this, &Listener::acceptConnection); |
51 | Trace() << "Trying to open " << m_resourceName; | 52 | Trace() << "Trying to open " << m_resourceInstanceIdentifier; |
52 | 53 | ||
53 | m_lockfile = new QLockFile(resourceName + ".lock"); | 54 | m_lockfile = new QLockFile(m_resourceInstanceIdentifier + ".lock"); |
54 | m_lockfile->setStaleLockTime(0); | 55 | m_lockfile->setStaleLockTime(0); |
55 | if (!m_lockfile->tryLock(0)) { | 56 | if (!m_lockfile->tryLock(0)) { |
56 | Warning() << "Failed to acquire exclusive lock on socket."; | 57 | Warning() << "Failed to acquire exclusive lock on socket."; |
57 | exit(-1); | 58 | exit(-1); |
58 | } | 59 | } |
59 | 60 | ||
60 | if (!m_server->listen(QString::fromLatin1(resourceName))) { | 61 | if (!m_server->listen(QString::fromLatin1(m_resourceInstanceIdentifier))) { |
61 | // FIXME: multiple starts need to be handled here | 62 | // FIXME: multiple starts need to be handled here |
62 | m_server->removeServer(resourceName); | 63 | m_server->removeServer(m_resourceInstanceIdentifier); |
63 | if (!m_server->listen(QString::fromLatin1(resourceName))) { | 64 | if (!m_server->listen(QString::fromLatin1(m_resourceInstanceIdentifier))) { |
64 | Warning() << "Utter failure to start server"; | 65 | Warning() << "Utter failure to start server"; |
65 | exit(-1); | 66 | exit(-1); |
66 | } | 67 | } |
diff --git a/synchronizer/listener.h b/synchronizer/listener.h index b3929e7..2577673 100644 --- a/synchronizer/listener.h +++ b/synchronizer/listener.h | |||
@@ -90,6 +90,7 @@ private: | |||
90 | QVector<Client> m_connections; | 90 | QVector<Client> m_connections; |
91 | flatbuffers::FlatBufferBuilder m_fbb; | 91 | flatbuffers::FlatBufferBuilder m_fbb; |
92 | const QByteArray m_resourceName; | 92 | const QByteArray m_resourceName; |
93 | const QByteArray m_resourceInstanceIdentifier; | ||
93 | Akonadi2::Resource *m_resource; | 94 | Akonadi2::Resource *m_resource; |
94 | Akonadi2::Pipeline *m_pipeline; | 95 | Akonadi2::Pipeline *m_pipeline; |
95 | QTimer *m_clientBufferProcessesTimer; | 96 | QTimer *m_clientBufferProcessesTimer; |
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index 9523e5d..fe04d99 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp | |||
@@ -26,19 +26,19 @@ private Q_SLOTS: | |||
26 | { | 26 | { |
27 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | 27 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); |
28 | QVERIFY(factory); | 28 | QVERIFY(factory); |
29 | removeFromDisk("org.kde.dummy"); | 29 | removeFromDisk("org.kde.dummy.instance1"); |
30 | removeFromDisk("org.kde.dummy.userqueue"); | 30 | removeFromDisk("org.kde.dummy.instance1.userqueue"); |
31 | removeFromDisk("org.kde.dummy.synchronizerqueue"); | 31 | removeFromDisk("org.kde.dummy.instance1.synchronizerqueue"); |
32 | removeFromDisk("org.kde.dummy.index.uid"); | 32 | removeFromDisk("org.kde.dummy.instance1.index.uid"); |
33 | } | 33 | } |
34 | 34 | ||
35 | void cleanup() | 35 | void cleanup() |
36 | { | 36 | { |
37 | Akonadi2::Store::shutdown("org.kde.dummy"); | 37 | Akonadi2::Store::shutdown("org.kde.dummy.instance1"); |
38 | removeFromDisk("org.kde.dummy"); | 38 | removeFromDisk("org.kde.dummy.instance1"); |
39 | removeFromDisk("org.kde.dummy.userqueue"); | 39 | removeFromDisk("org.kde.dummy.instance1.userqueue"); |
40 | removeFromDisk("org.kde.dummy.synchronizerqueue"); | 40 | removeFromDisk("org.kde.dummy.instance1.synchronizerqueue"); |
41 | removeFromDisk("org.kde.dummy.index.uid"); | 41 | removeFromDisk("org.kde.dummy.instance1.index.uid"); |
42 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | 42 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); |
43 | QVERIFY(factory); | 43 | QVERIFY(factory); |
44 | } | 44 | } |
@@ -83,7 +83,7 @@ private Q_SLOTS: | |||
83 | } | 83 | } |
84 | 84 | ||
85 | //Actual test | 85 | //Actual test |
86 | Akonadi2::Pipeline pipeline("org.kde.dummy"); | 86 | Akonadi2::Pipeline pipeline("org.kde.dummy.instance1"); |
87 | QSignalSpy revisionSpy(&pipeline, SIGNAL(revisionUpdated())); | 87 | QSignalSpy revisionSpy(&pipeline, SIGNAL(revisionUpdated())); |
88 | DummyResource resource; | 88 | DummyResource resource; |
89 | resource.configurePipeline(&pipeline); | 89 | resource.configurePipeline(&pipeline); |
@@ -109,10 +109,10 @@ private Q_SLOTS: | |||
109 | event.setProperty("uid", "testuid"); | 109 | event.setProperty("uid", "testuid"); |
110 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); | 110 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); |
111 | event.setProperty("summary", "summaryValue"); | 111 | event.setProperty("summary", "summaryValue"); |
112 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Event>(event, "org.kde.dummy"); | 112 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Event>(event, "org.kde.dummy.instance1"); |
113 | 113 | ||
114 | Akonadi2::Query query; | 114 | Akonadi2::Query query; |
115 | query.resources << "org.kde.dummy"; | 115 | query.resources << "org.kde.dummy.instance1"; |
116 | query.syncOnDemand = false; | 116 | query.syncOnDemand = false; |
117 | query.processAll = true; | 117 | query.processAll = true; |
118 | 118 | ||
@@ -126,7 +126,7 @@ private Q_SLOTS: | |||
126 | 126 | ||
127 | void testResourceSync() | 127 | void testResourceSync() |
128 | { | 128 | { |
129 | Akonadi2::Pipeline pipeline("org.kde.dummy"); | 129 | Akonadi2::Pipeline pipeline("org.kde.dummy.instance1"); |
130 | DummyResource resource; | 130 | DummyResource resource; |
131 | resource.configurePipeline(&pipeline); | 131 | resource.configurePipeline(&pipeline); |
132 | auto job = resource.synchronizeWithSource(&pipeline); | 132 | auto job = resource.synchronizeWithSource(&pipeline); |
@@ -143,7 +143,7 @@ private Q_SLOTS: | |||
143 | void testSyncAndFacade() | 143 | void testSyncAndFacade() |
144 | { | 144 | { |
145 | Akonadi2::Query query; | 145 | Akonadi2::Query query; |
146 | query.resources << "org.kde.dummy"; | 146 | query.resources << "org.kde.dummy.instance1"; |
147 | query.syncOnDemand = true; | 147 | query.syncOnDemand = true; |
148 | query.processAll = true; | 148 | query.processAll = true; |
149 | 149 | ||