diff options
-rw-r--r-- | common/commands.cpp | 18 | ||||
-rw-r--r-- | common/commands.h | 3 |
2 files changed, 21 insertions, 0 deletions
diff --git a/common/commands.cpp b/common/commands.cpp index abed8b9..ecbbfdb 100644 --- a/common/commands.cpp +++ b/common/commands.cpp | |||
@@ -28,6 +28,24 @@ namespace Akonadi2 | |||
28 | namespace Commands | 28 | namespace Commands |
29 | { | 29 | { |
30 | 30 | ||
31 | void write(QIODevice *device, int commandId) | ||
32 | { | ||
33 | write(device, commandId, 0, 0); | ||
34 | } | ||
35 | |||
36 | void write(QIODevice *device, int commandId, const char *buffer, uint size) | ||
37 | { | ||
38 | if (size > 0 && !buffer) { | ||
39 | size = 0; | ||
40 | } | ||
41 | |||
42 | device->write((const char*)&commandId, sizeof(int)); | ||
43 | device->write((const char*)&size, sizeof(uint)); | ||
44 | if (buffer) { | ||
45 | device->write(buffer, size); | ||
46 | } | ||
47 | } | ||
48 | |||
31 | void write(QIODevice *device, int commandId, flatbuffers::FlatBufferBuilder &fbb) | 49 | void write(QIODevice *device, int commandId, flatbuffers::FlatBufferBuilder &fbb) |
32 | { | 50 | { |
33 | const int dataSize = fbb.GetSize(); | 51 | const int dataSize = fbb.GetSize(); |
diff --git a/common/commands.h b/common/commands.h index 0a2452f..2e84a2f 100644 --- a/common/commands.h +++ b/common/commands.h | |||
@@ -35,9 +35,12 @@ enum CommandIds { | |||
35 | UnknownCommand = 0, | 35 | UnknownCommand = 0, |
36 | HandshakeCommand, | 36 | HandshakeCommand, |
37 | RevisionUpdateCommand, | 37 | RevisionUpdateCommand, |
38 | SynchronizeCommand, | ||
38 | CustomCommand = 0xffff | 39 | CustomCommand = 0xffff |
39 | }; | 40 | }; |
40 | 41 | ||
42 | void AKONADI2COMMON_EXPORT write(QIODevice *device, int commandId); | ||
43 | void AKONADI2COMMON_EXPORT write(QIODevice *device, int commandId, const char *buffer, uint size); | ||
41 | void AKONADI2COMMON_EXPORT write(QIODevice *device, int commandId, flatbuffers::FlatBufferBuilder &fbb); | 44 | void AKONADI2COMMON_EXPORT write(QIODevice *device, int commandId, flatbuffers::FlatBufferBuilder &fbb); |
42 | 45 | ||
43 | } | 46 | } |