blob: d287fcf35884ef7c36a6b38a24378e4a3b69071f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#include "clientapi.h"
#include "resourceaccess.h"
#include "commands.h"
#include "log.h"
#include <QtConcurrent/QtConcurrentRun>
namespace async
{
void run(const std::function<void()> &runner) {
//TODO use a job that runs in a thread?
QtConcurrent::run(runner);
};
} // namespace async
namespace Akonadi2
{
namespace ApplicationDomain
{
template<>
QByteArray getTypeName<Event>()
{
return "event";
}
template<>
QByteArray getTypeName<Todo>()
{
return "todo";
}
template<>
QByteArray getTypeName<AkonadiResource>()
{
return "akonadiresource";
}
} // namespace Domain
void Store::shutdown(const QByteArray &identifier)
{
Trace() << "shutdown";
ResourceAccess::connectToServer(identifier).then<void, QSharedPointer<QLocalSocket>>([identifier](const QSharedPointer<QLocalSocket> &socket, KAsync::Future<void> &future) {
//We can't currently reuse the socket
socket->close();
auto resourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(identifier);
resourceAccess->open();
resourceAccess->sendCommand(Akonadi2::Commands::ShutdownCommand).then<void>([&future, resourceAccess]() {
future.setFinished();
}).exec();
},
[](int, const QString &) {
//Resource isn't started, nothing to shutdown
}).exec().waitForFinished();
}
void Store::synchronize(const QByteArray &identifier)
{
Trace() << "synchronize";
auto resourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(identifier);
resourceAccess->open();
resourceAccess->synchronizeResource(true, false).exec().waitForFinished();
}
} // namespace Akonadi2
|