summaryrefslogtreecommitdiffstats
path: root/common/commands.cpp
diff options
context:
space:
mode:
authorAaron Seigo <aseigo@kde.org>2014-12-16 22:40:44 +0100
committerAaron Seigo <aseigo@kde.org>2014-12-16 22:40:44 +0100
commit77944384d24b5005d6b8648572a31a3ae84dd946 (patch)
tree8726831773b4182cb6177d6c72a723e08a6c15aa /common/commands.cpp
parent66b21fd2e3c53e4a820e3343b192be7b043da110 (diff)
downloadsink-77944384d24b5005d6b8648572a31a3ae84dd946.tar.gz
sink-77944384d24b5005d6b8648572a31a3ae84dd946.zip
add pipelines (as a sketch only), message ids and message responses
Diffstat (limited to 'common/commands.cpp')
-rw-r--r--common/commands.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/common/commands.cpp b/common/commands.cpp
index ecbbfdb..1dfeabe 100644
--- a/common/commands.cpp
+++ b/common/commands.cpp
@@ -28,17 +28,23 @@ namespace Akonadi2
28namespace Commands 28namespace Commands
29{ 29{
30 30
31void write(QIODevice *device, int commandId) 31int headerSize()
32{ 32{
33 write(device, commandId, 0, 0); 33 return sizeof(int) + (sizeof(uint) * 2);
34} 34}
35 35
36void write(QIODevice *device, int commandId, const char *buffer, uint size) 36void write(QIODevice *device, int messageId, int commandId)
37{
38 write(device, messageId, commandId, 0, 0);
39}
40
41void write(QIODevice *device, int messageId, int commandId, const char *buffer, uint size)
37{ 42{
38 if (size > 0 && !buffer) { 43 if (size > 0 && !buffer) {
39 size = 0; 44 size = 0;
40 } 45 }
41 46
47 device->write((const char*)&messageId, sizeof(int));
42 device->write((const char*)&commandId, sizeof(int)); 48 device->write((const char*)&commandId, sizeof(int));
43 device->write((const char*)&size, sizeof(uint)); 49 device->write((const char*)&size, sizeof(uint));
44 if (buffer) { 50 if (buffer) {
@@ -46,9 +52,10 @@ void write(QIODevice *device, int commandId, const char *buffer, uint size)
46 } 52 }
47} 53}
48 54
49void write(QIODevice *device, int commandId, flatbuffers::FlatBufferBuilder &fbb) 55void write(QIODevice *device, int messageId, int commandId, flatbuffers::FlatBufferBuilder &fbb)
50{ 56{
51 const int dataSize = fbb.GetSize(); 57 const int dataSize = fbb.GetSize();
58 device->write((const char*)&messageId, sizeof(int));
52 device->write((const char*)&commandId, sizeof(int)); 59 device->write((const char*)&commandId, sizeof(int));
53 device->write((const char*)&dataSize, sizeof(int)); 60 device->write((const char*)&dataSize, sizeof(int));
54 device->write((const char*)fbb.GetBufferPointer(), dataSize); 61 device->write((const char*)fbb.GetBufferPointer(), dataSize);