summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/commands.cpp33
-rw-r--r--common/commands.h4
-rw-r--r--common/resourceaccess.cpp4
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
28namespace Commands 28namespace Commands
29{ 29{
30 30
31QByteArray 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
31int headerSize() 64int 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
26class QIODevice; 27class QIODevice;
27 28
@@ -47,6 +48,9 @@ enum CommandIds {
47 CustomCommand = 0xffff 48 CustomCommand = 0xffff
48}; 49};
49 50
51
52QByteArray name(int commandId);
53
50int AKONADI2COMMON_EXPORT headerSize(); 54int AKONADI2COMMON_EXPORT headerSize();
51void AKONADI2COMMON_EXPORT write(QIODevice *device, int messageId, int commandId); 55void AKONADI2COMMON_EXPORT write(QIODevice *device, int messageId, int commandId);
52void AKONADI2COMMON_EXPORT write(QIODevice *device, int messageId, int commandId, const char *buffer, uint size); 56void 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)
215void ResourceAccess::processCommandQueue() 215void 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 }