summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-01-30 01:10:37 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-01-30 01:10:37 +0100
commitbf00b2c3a0fbfbdcbd7c5f4ab519049dc02c1263 (patch)
tree1facb41649496418c5a2120391917e28302f8270
parente7743002a75d83e24de94f712fac0f0b61ab0ca3 (diff)
downloadsink-bf00b2c3a0fbfbdcbd7c5f4ab519049dc02c1263.tar.gz
sink-bf00b2c3a0fbfbdcbd7c5f4ab519049dc02c1263.zip
Shutdown command for synchronizers, used by the dummyresourcetest.
Otherwise the synchronizer keeps a Storage object alive, while the tests deletes the db. This causes subsequent writes to fail in the next test.
-rw-r--r--common/clientapi.cpp12
-rw-r--r--common/clientapi.h2
-rw-r--r--common/commands.h1
-rw-r--r--synchronizer/listener.cpp6
-rw-r--r--tests/dummyresourcetest.cpp4
5 files changed, 24 insertions, 1 deletions
diff --git a/common/clientapi.cpp b/common/clientapi.cpp
index 2a4b603..260b6b8 100644
--- a/common/clientapi.cpp
+++ b/common/clientapi.cpp
@@ -1,5 +1,7 @@
1 1
2#include "clientapi.h" 2#include "clientapi.h"
3#include "resourceaccess.h"
4#include "commands.h"
3 5
4namespace async 6namespace async
5{ 7{
@@ -35,4 +37,14 @@ QString getTypeName<Todo>()
35 37
36} // namespace Domain 38} // namespace Domain
37 39
40void Store::shutdown(const QString &identifier)
41{
42 Akonadi2::ResourceAccess resourceAccess(identifier);
43 resourceAccess.open();
44 resourceAccess.sendCommand(Akonadi2::Commands::ShutdownCommand).then<void>([](Async::Future<void> &f){
45 //TODO wait for disconnect
46 f.setFinished();
47 }).exec().waitForFinished();
48}
49
38} // namespace Akonadi2 50} // namespace Akonadi2
diff --git a/common/clientapi.h b/common/clientapi.h
index 542039e..71317a1 100644
--- a/common/clientapi.h
+++ b/common/clientapi.h
@@ -488,6 +488,8 @@ public:
488 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceIdentifier); 488 auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceIdentifier);
489 facade.remove(domainObject); 489 facade.remove(domainObject);
490 } 490 }
491
492 static void shutdown(const QString &resourceIdentifier);
491}; 493};
492 494
493} 495}
diff --git a/common/commands.h b/common/commands.h
index c63bb47..26729dc 100644
--- a/common/commands.h
+++ b/common/commands.h
@@ -42,6 +42,7 @@ enum CommandIds {
42 ModifyEntityCommand, 42 ModifyEntityCommand,
43 CreateEntityCommand, 43 CreateEntityCommand,
44 SearchSourceCommand, // need a buffer definition for this, but relies on Query API 44 SearchSourceCommand, // need a buffer definition for this, but relies on Query API
45 ShutdownCommand,
45 CustomCommand = 0xffff 46 CustomCommand = 0xffff
46}; 47};
47 48
diff --git a/synchronizer/listener.cpp b/synchronizer/listener.cpp
index f52e48c..d191bb8 100644
--- a/synchronizer/listener.cpp
+++ b/synchronizer/listener.cpp
@@ -243,6 +243,12 @@ void Listener::processCommand(int commandId, uint messageId, Client &client, uin
243 m_resource->processCommand(commandId, client.commandBuffer, size, m_pipeline); 243 m_resource->processCommand(commandId, client.commandBuffer, size, m_pipeline);
244 } 244 }
245 break; 245 break;
246 case Akonadi2::Commands::ShutdownCommand:
247 log(QString("\tReceived shutdown command from %1").arg(client.name));
248 callback();
249 m_server->close();
250 emit noClients();
251 return;
246 default: 252 default:
247 if (commandId > Akonadi2::Commands::CustomCommand) { 253 if (commandId > Akonadi2::Commands::CustomCommand) {
248 loadResource(); 254 loadResource();
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp
index 6548659..b185664 100644
--- a/tests/dummyresourcetest.cpp
+++ b/tests/dummyresourcetest.cpp
@@ -34,11 +34,13 @@ private Q_SLOTS:
34 34
35 void cleanup() 35 void cleanup()
36 { 36 {
37 //TODO kill the synchronizer first? 37 Akonadi2::Store::shutdown("org.kde.dummy");
38 removeFromDisk("org.kde.dummy"); 38 removeFromDisk("org.kde.dummy");
39 removeFromDisk("org.kde.dummy.userqueue"); 39 removeFromDisk("org.kde.dummy.userqueue");
40 removeFromDisk("org.kde.dummy.synchronizerqueue"); 40 removeFromDisk("org.kde.dummy.synchronizerqueue");
41 removeFromDisk("org.kde.dummy.index.uid"); 41 removeFromDisk("org.kde.dummy.index.uid");
42 auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy");
43 QVERIFY(factory);
42 } 44 }
43 45
44 void testProcessCommand() 46 void testProcessCommand()