diff options
| author | hibby <d@vehibberd.com> | 2018-02-16 15:18:44 +0000 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2018-02-16 15:18:44 +0000 |
| commit | 368f5331a7641772aa7e0cd1feea57d09a394a36 (patch) | |
| tree | b421ac60cc6eb726896ea268ea24e47fc4ce7c88 /NetworkMessage.cpp | |
| parent | 71c717edc92fa771c857b3c2e5ed65f523f68f90 (diff) | |
| parent | 37f727ac0746fd85504aa46c1f023c09b3eff33a (diff) | |
Update upstream source from tag 'upstream/1.8.0+repack'
Update to upstream version '1.8.0+repack'
with Debian dir a83ef78cb70a32d1211871fdc08f3ffa295e45a8
Diffstat (limited to 'NetworkMessage.cpp')
| -rw-r--r-- | NetworkMessage.cpp | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/NetworkMessage.cpp b/NetworkMessage.cpp index 5c7e0f1a..b1ad0f11 100644 --- a/NetworkMessage.cpp +++ b/NetworkMessage.cpp @@ -9,23 +9,46 @@ namespace NetworkMessage { - Builder::Builder (QIODevice * device, Type type, QString const& id) + Builder::Builder (QIODevice * device, Type type, QString const& id, quint32 schema) : QDataStream {device} { - common_initialization (type, id); + common_initialization (type, id, schema); } - Builder::Builder (QByteArray * a, Type type, QString const& id) + Builder::Builder (QByteArray * a, Type type, QString const& id, quint32 schema) : QDataStream {a, QIODevice::WriteOnly} { - common_initialization (type, id); + common_initialization (type, id, schema); } - void Builder::common_initialization (Type type, QString const& id) + void Builder::common_initialization (Type type, QString const& id, quint32 schema) { + if (schema <= 1) + { + setVersion (QDataStream::Qt_5_0); // Qt schema version + } +#if QT_VERSION >= 0x050200 + else if (schema <= 2) + { + setVersion (QDataStream::Qt_5_2); // Qt schema version + } +#endif +#if QT_VERSION >= 0x050400 + else if (schema <= 3) + { + setVersion (QDataStream::Qt_5_4); // Qt schema version + } +#endif + else + { + throw std::runtime_error {"Unrecognized message schema"}; + } + + // the following two items assume that the quint32 encoding is + // unchanged over QDataStream versions *this << magic; - *this << schema_number; - setVersion (QDataStream::Qt_5_2); // Qt schema version + *this << schema; + *this << static_cast<quint32> (type) << id.toUtf8 (); } @@ -49,10 +72,18 @@ namespace NetworkMessage { parent->setVersion (QDataStream::Qt_5_0); } +#if QT_VERSION >= 0x050200 else if (schema_ <= 2) { parent->setVersion (QDataStream::Qt_5_2); } +#endif +#if QT_VERSION >= 0x050400 + else if (schema_ <= 3) + { + parent->setVersion (QDataStream::Qt_5_4); + } +#endif quint32 type; *parent >> type >> id_; if (type >= maximum_message_type_) |
