diff options
author | Javier <dev.git@javispedro.com> | 2015-12-13 20:36:52 +0100 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2015-12-13 20:36:52 +0100 |
commit | ce8a092a235c8d59f01631c80786f920eb6a777b (patch) | |
tree | cc59e0bdd786a681ff831619ae9a60bf85814064 /saprotocol.cc | |
parent | c48db815c7847b88907aae58f2a1af5c20d9dc8f (diff) | |
download | sapd-ce8a092a235c8d59f01631c80786f920eb6a777b.tar.gz sapd-ce8a092a235c8d59f01631c80786f920eb6a777b.zip |
Add terminate connection frame structs
Diffstat (limited to 'saprotocol.cc')
-rw-r--r-- | saprotocol.cc | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/saprotocol.cc b/saprotocol.cc index c580f12..9f25613 100644 --- a/saprotocol.cc +++ b/saprotocol.cc @@ -364,6 +364,79 @@ QByteArray SAProtocol::packServiceConnectionResponseFrame(const ServiceConnectio return data; } +SAProtocol::ServiceTerminationRequestFrame SAProtocol::unpackServiceTerminationRequestFrame(const QByteArray &data) +{ + ServiceTerminationRequestFrame frame; + int offset = 0; + + frame.messageType = read<quint8>(data, offset); + frame.acceptorId = read<quint8>(data, offset); + frame.initiatorId = read<quint8>(data, offset); + + int marker = data.indexOf(';', offset); + if (marker == -1) { + qWarning() << "No profile in termination request"; + return frame; + } + + frame.profile = QString::fromUtf8(&data.constData()[offset], marker - offset); + + return frame; +} + +QByteArray SAProtocol::packServiceTerminationRequestFrame(const ServiceTerminationRequestFrame &frame) +{ + QByteArray data; + + append<quint8>(data, frame.messageType); + append<quint16>(data, frame.acceptorId); + append<quint16>(data, frame.initiatorId); + + data.append(frame.profile.toUtf8()); + data.append(';'); + + return data; +} + +SAProtocol::ServiceTerminationResponseFrame SAProtocol::unpackServiceTerminationResponseFrame(const QByteArray &data) +{ + ServiceTerminationResponseFrame frame; + int offset = 0; + + frame.messageType = read<quint8>(data, offset); + frame.acceptorId = read<quint8>(data, offset); + frame.initiatorId = read<quint8>(data, offset); + + int marker = data.indexOf(';', offset); + if (marker == -1) { + qWarning() << "No profile in termination response"; + return frame; + } + + frame.profile = QString::fromUtf8(&data.constData()[offset], marker - offset); + offset = marker + 1; + + frame.statusCode = read<quint8>(data, offset); + + return frame; +} + +QByteArray SAProtocol::packServiceTerminationResponseFrame(const ServiceTerminationResponseFrame &frame) +{ + QByteArray data; + + append<quint8>(data, frame.messageType); + append<quint16>(data, frame.acceptorId); + append<quint16>(data, frame.initiatorId); + + data.append(frame.profile.toUtf8()); + data.append(';'); + + append<quint8>(data, frame.statusCode); + + return data; +} + SAProtocol::CapabilityDiscoveryQuery SAProtocol::unpackCapabilityDiscoveryQuery(const QByteArray &data) { CapabilityDiscoveryQuery msg; |