diff options
Diffstat (limited to 'common/commands.cpp')
-rw-r--r-- | common/commands.cpp | 15 |
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 | |||
28 | namespace Commands | 28 | namespace Commands |
29 | { | 29 | { |
30 | 30 | ||
31 | void write(QIODevice *device, int commandId) | 31 | int headerSize() |
32 | { | 32 | { |
33 | write(device, commandId, 0, 0); | 33 | return sizeof(int) + (sizeof(uint) * 2); |
34 | } | 34 | } |
35 | 35 | ||
36 | void write(QIODevice *device, int commandId, const char *buffer, uint size) | 36 | void write(QIODevice *device, int messageId, int commandId) |
37 | { | ||
38 | write(device, messageId, commandId, 0, 0); | ||
39 | } | ||
40 | |||
41 | void 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 | ||
49 | void write(QIODevice *device, int commandId, flatbuffers::FlatBufferBuilder &fbb) | 55 | void 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); |