diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/commands.cpp | 33 | ||||
-rw-r--r-- | common/commands.h | 4 | ||||
-rw-r--r-- | common/resourceaccess.cpp | 4 |
3 files changed, 39 insertions, 2 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 | } |