diff options
-rw-r--r-- | common/commands.cpp | 33 | ||||
-rw-r--r-- | common/commands.h | 4 | ||||
-rw-r--r-- | common/resourceaccess.cpp | 4 | ||||
-rw-r--r-- | dummyresource/resourcefactory.cpp | 4 | ||||
-rw-r--r-- | synchronizer/listener.cpp | 10 |
5 files changed, 46 insertions, 9 deletions
diff --git a/common/commands.cpp b/common/commands.cpp index 1dfeabe..99313b9 100644 --- a/common/commands.cpp +++ b/common/commands.cpp | |||
@@ -28,6 +28,39 @@ namespace Akonadi2 | |||
28 | namespace Commands | 28 | namespace Commands |
29 | { | 29 | { |
30 | 30 | ||
31 | QByteArray name(int commandId) | ||
32 | { | ||
33 | switch(commandId) { | ||
34 | case UnknownCommand: | ||
35 | return "Unknown"; | ||
36 | case CommandCompletion: | ||
37 | return "Completion"; | ||
38 | case HandshakeCommand: | ||
39 | return "Handshake"; | ||
40 | case RevisionUpdateCommand: | ||
41 | return "RevisionUpdate"; | ||
42 | case SynchronizeCommand: | ||
43 | return "Synchronize"; | ||
44 | case FetchEntityCommand: | ||
45 | return "FetchEntity"; | ||
46 | case DeleteEntityCommand: | ||
47 | return "DeleteEntity"; | ||
48 | case ModifyEntityCommand: | ||
49 | return "ModifyEntity"; | ||
50 | case CreateEntityCommand: | ||
51 | return "CreateEntity"; | ||
52 | case SearchSourceCommand: | ||
53 | return "SearchSource"; | ||
54 | case ShutdownCommand: | ||
55 | return "Shutdown"; | ||
56 | case NotificationCommand: | ||
57 | return "Notification"; | ||
58 | case CustomCommand: | ||
59 | return "Custom"; | ||
60 | }; | ||
61 | return QByteArray("Invalid commandId"); | ||
62 | } | ||
63 | |||
31 | int headerSize() | 64 | int headerSize() |
32 | { | 65 | { |
33 | return sizeof(int) + (sizeof(uint) * 2); | 66 | return sizeof(int) + (sizeof(uint) * 2); |
diff --git a/common/commands.h b/common/commands.h index 0007ffc..1baedcc 100644 --- a/common/commands.h +++ b/common/commands.h | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include <akonadi2common_export.h> | 23 | #include <akonadi2common_export.h> |
24 | #include <flatbuffers/flatbuffers.h> | 24 | #include <flatbuffers/flatbuffers.h> |
25 | #include <QByteArray> | ||
25 | 26 | ||
26 | class QIODevice; | 27 | class QIODevice; |
27 | 28 | ||
@@ -47,6 +48,9 @@ enum CommandIds { | |||
47 | CustomCommand = 0xffff | 48 | CustomCommand = 0xffff |
48 | }; | 49 | }; |
49 | 50 | ||
51 | |||
52 | QByteArray name(int commandId); | ||
53 | |||
50 | int AKONADI2COMMON_EXPORT headerSize(); | 54 | int AKONADI2COMMON_EXPORT headerSize(); |
51 | void AKONADI2COMMON_EXPORT write(QIODevice *device, int messageId, int commandId); | 55 | void AKONADI2COMMON_EXPORT write(QIODevice *device, int messageId, int commandId); |
52 | void AKONADI2COMMON_EXPORT write(QIODevice *device, int messageId, int commandId, const char *buffer, uint size); | 56 | void AKONADI2COMMON_EXPORT write(QIODevice *device, int messageId, int commandId, const char *buffer, uint size); |
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index 9ecdab1..1dba571 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -200,7 +200,7 @@ void ResourceAccess::sendCommand(const QSharedPointer<QueuedCommand> &command) | |||
200 | //TODO: we should have a timeout for commands | 200 | //TODO: we should have a timeout for commands |
201 | d->messageId++; | 201 | d->messageId++; |
202 | const auto messageId = d->messageId; | 202 | const auto messageId = d->messageId; |
203 | log(QString("Sending command %1 with messageId %2").arg(command->commandId).arg(d->messageId)); | 203 | log(QString("Sending command \"%1\" with messageId %2").arg(QString(Akonadi2::Commands::name(command->commandId))).arg(d->messageId)); |
204 | if (command->callback) { | 204 | if (command->callback) { |
205 | registerCallback(d->messageId, [this, messageId, command](int number, QString foo) { | 205 | registerCallback(d->messageId, [this, messageId, command](int number, QString foo) { |
206 | d->pendingCommands.remove(messageId); | 206 | d->pendingCommands.remove(messageId); |
@@ -215,7 +215,7 @@ void ResourceAccess::sendCommand(const QSharedPointer<QueuedCommand> &command) | |||
215 | void ResourceAccess::processCommandQueue() | 215 | void ResourceAccess::processCommandQueue() |
216 | { | 216 | { |
217 | //TODO: serialize instead of blast them all through the socket? | 217 | //TODO: serialize instead of blast them all through the socket? |
218 | log(QString("We have %1 queued commands").arg(d->commandQueue.size())); | 218 | Trace() << "We have " << d->commandQueue.size() << " queued commands"; |
219 | for (auto command: d->commandQueue) { | 219 | for (auto command: d->commandQueue) { |
220 | sendCommand(command); | 220 | sendCommand(command); |
221 | } | 221 | } |
diff --git a/dummyresource/resourcefactory.cpp b/dummyresource/resourcefactory.cpp index 8f0a2bd..679bba2 100644 --- a/dummyresource/resourcefactory.cpp +++ b/dummyresource/resourcefactory.cpp | |||
@@ -151,7 +151,7 @@ private slots: | |||
151 | 151 | ||
152 | Async::Job<void> processQueuedCommand(const Akonadi2::QueuedCommand *queuedCommand) | 152 | Async::Job<void> processQueuedCommand(const Akonadi2::QueuedCommand *queuedCommand) |
153 | { | 153 | { |
154 | Log() << "Processing command: " << queuedCommand->commandId(); | 154 | Log() << "Processing command: " << Akonadi2::Commands::name(queuedCommand->commandId()); |
155 | //Throw command into appropriate pipeline | 155 | //Throw command into appropriate pipeline |
156 | switch (queuedCommand->commandId()) { | 156 | switch (queuedCommand->commandId()) { |
157 | case Akonadi2::Commands::DeleteEntityCommand: | 157 | case Akonadi2::Commands::DeleteEntityCommand: |
@@ -191,7 +191,7 @@ private slots: | |||
191 | return; | 191 | return; |
192 | } | 192 | } |
193 | auto queuedCommand = Akonadi2::GetQueuedCommand(ptr); | 193 | auto queuedCommand = Akonadi2::GetQueuedCommand(ptr); |
194 | Trace() << "Dequeued: " << queuedCommand->commandId(); | 194 | Trace() << "Dequeued Command: " << Akonadi2::Commands::name(queuedCommand->commandId()); |
195 | //TODO JOBAPI: job lifetime management | 195 | //TODO JOBAPI: job lifetime management |
196 | //Right now we're just leaking jobs. In this case we'd like jobs that are heap allocated and delete | 196 | //Right now we're just leaking jobs. In this case we'd like jobs that are heap allocated and delete |
197 | //themselves once done. In other cases we'd like jobs that only live as long as their handle though. | 197 | //themselves once done. In other cases we'd like jobs that only live as long as their handle though. |
diff --git a/synchronizer/listener.cpp b/synchronizer/listener.cpp index 64e9c21..c68bd9a 100644 --- a/synchronizer/listener.cpp +++ b/synchronizer/listener.cpp | |||
@@ -48,7 +48,7 @@ Listener::Listener(const QByteArray &resourceName, QObject *parent) | |||
48 | this, &Listener::refreshRevision); | 48 | this, &Listener::refreshRevision); |
49 | connect(m_server, &QLocalServer::newConnection, | 49 | connect(m_server, &QLocalServer::newConnection, |
50 | this, &Listener::acceptConnection); | 50 | this, &Listener::acceptConnection); |
51 | Log() << "Trying to open " << m_resourceName; | 51 | Trace() << "Trying to open " << m_resourceName; |
52 | if (!m_server->listen(QString::fromLatin1(resourceName))) { | 52 | if (!m_server->listen(QString::fromLatin1(resourceName))) { |
53 | // FIXME: multiple starts need to be handled here | 53 | // FIXME: multiple starts need to be handled here |
54 | m_server->removeServer(resourceName); | 54 | m_server->removeServer(resourceName); |
@@ -99,7 +99,7 @@ void Listener::closeAllConnections() | |||
99 | 99 | ||
100 | void Listener::acceptConnection() | 100 | void Listener::acceptConnection() |
101 | { | 101 | { |
102 | Log() << QString("Accepting connection"); | 102 | Trace() << "Accepting connection"; |
103 | QLocalSocket *socket = m_server->nextPendingConnection(); | 103 | QLocalSocket *socket = m_server->nextPendingConnection(); |
104 | 104 | ||
105 | if (!socket) { | 105 | if (!socket) { |
@@ -154,7 +154,7 @@ void Listener::readFromSocket() | |||
154 | return; | 154 | return; |
155 | } | 155 | } |
156 | 156 | ||
157 | Log() << "Reading from socket..."; | 157 | Trace() << "Reading from socket..."; |
158 | for (Client &client: m_connections) { | 158 | for (Client &client: m_connections) { |
159 | if (client.socket == socket) { | 159 | if (client.socket == socket) { |
160 | client.commandBuffer += socket->readAll(); | 160 | client.commandBuffer += socket->readAll(); |
@@ -232,7 +232,7 @@ void Listener::processCommand(int commandId, uint messageId, Client &client, uin | |||
232 | case Akonadi2::Commands::DeleteEntityCommand: | 232 | case Akonadi2::Commands::DeleteEntityCommand: |
233 | case Akonadi2::Commands::ModifyEntityCommand: | 233 | case Akonadi2::Commands::ModifyEntityCommand: |
234 | case Akonadi2::Commands::CreateEntityCommand: | 234 | case Akonadi2::Commands::CreateEntityCommand: |
235 | Log() << QString("\tCommand id %1 of type %2 from %3").arg(messageId).arg(commandId).arg(client.name); | 235 | Log() << "\tCommand id " << messageId << " of type \"" << Akonadi2::Commands::name(commandId) << "\" from " << client.name; |
236 | loadResource(); | 236 | loadResource(); |
237 | if (m_resource) { | 237 | if (m_resource) { |
238 | m_resource->processCommand(commandId, client.commandBuffer, size, m_pipeline); | 238 | m_resource->processCommand(commandId, client.commandBuffer, size, m_pipeline); |
@@ -293,7 +293,7 @@ bool Listener::processClientBuffer(Client &client) | |||
293 | auto socket = QPointer<QLocalSocket>(client.socket); | 293 | auto socket = QPointer<QLocalSocket>(client.socket); |
294 | auto clientName = client.name; | 294 | auto clientName = client.name; |
295 | processCommand(commandId, messageId, client, size, [this, messageId, commandId, socket, clientName]() { | 295 | processCommand(commandId, messageId, client, size, [this, messageId, commandId, socket, clientName]() { |
296 | Log() << QString("\tCompleted command messageid %1 of type %2 from %3").arg(messageId).arg(commandId).arg(clientName); | 296 | Log() << QString("\tCompleted command messageid %1 of type \"%2\" from %3").arg(messageId).arg(QString(Akonadi2::Commands::name(commandId))).arg(clientName); |
297 | if (socket) { | 297 | if (socket) { |
298 | sendCommandCompleted(socket.data(), messageId); | 298 | sendCommandCompleted(socket.data(), messageId); |
299 | } else { | 299 | } else { |