summaryrefslogtreecommitdiff
path: root/gatoattclient.cpp
diff options
context:
space:
mode:
authorJavier <maemo@javispedro.com>2014-05-20 01:47:23 +0200
committerJavier <maemo@javispedro.com>2014-05-20 01:47:23 +0200
commite0677f561465615d84ca81b48955dbf8e169e02e (patch)
tree339fb87fbacba43ad514d8017d0f8c8a332732d3 /gatoattclient.cpp
parent6163f146b2951c492de312365161b8a0f9d1afd1 (diff)
downloadlibgato-e0677f561465615d84ca81b48955dbf8e169e02e.tar.gz
libgato-e0677f561465615d84ca81b48955dbf8e169e02e.zip
remove gatouint128, simplify gatouuid encoding
Diffstat (limited to 'gatoattclient.cpp')
-rw-r--r--gatoattclient.cpp25
1 files changed, 6 insertions, 19 deletions
diff --git a/gatoattclient.cpp b/gatoattclient.cpp
index 033794f..54e2212 100644
--- a/gatoattclient.cpp
+++ b/gatoattclient.cpp
@@ -184,8 +184,7 @@ uint GatoAttClient::requestReadByType(GatoHandle start, GatoHandle end, const Ga
QByteArray data;
QDataStream s(&data, QIODevice::WriteOnly);
s.setByteOrder(QDataStream::LittleEndian);
- s << start << end;
- writeUuid16or128(s, uuid);
+ s << start << end << gatouuid_to_bytearray(uuid, true, false);
return request(AttOpReadByTypeRequest, data, receiver, member);
}
@@ -205,8 +204,7 @@ uint GatoAttClient::requestReadByGroupType(GatoHandle start, GatoHandle end, con
QByteArray data;
QDataStream s(&data, QIODevice::WriteOnly);
s.setByteOrder(QDataStream::LittleEndian);
- s << start << end;
- writeUuid16or128(s, uuid);
+ s << start << end << gatouuid_to_bytearray(uuid, true, false);
return request(AttOpReadByGroupTypeRequest, data, receiver, member);
}
@@ -429,19 +427,6 @@ bool GatoAttClient::handleResponse(const Request &req, const QByteArray &respons
}
}
-void GatoAttClient::writeUuid16or128(QDataStream &s, const GatoUUID &uuid)
-{
- s.setByteOrder(QDataStream::LittleEndian);
-
- bool uuid16_ok;
- quint16 uuid16 = uuid.toUInt16(&uuid16_ok);
- if (uuid16_ok) {
- s << uuid16;
- } else {
- s << uuid.toUInt128();
- }
-}
-
QList<GatoAttClient::InformationData> GatoAttClient::parseInformationData(const QByteArray &data)
{
const int format = data[0];
@@ -467,15 +452,17 @@ QList<GatoAttClient::InformationData> GatoAttClient::parseInformationData(const
const char *s = data.constData();
for (int i = 0; i < items; i++) {
InformationData d;
+ QByteArray uuid;
d.handle = read_le<GatoHandle>(&s[pos]);
switch (format) {
case 1:
- d.uuid = GatoUUID(read_le<quint16>(&s[pos + 2]));
+ uuid = data.mid(pos + 2, 2);
break;
case 2:
- d.uuid = GatoUUID(read_le<gatouint128>(&s[pos + 2]));
+ uuid = data.mid(pos + 2, 16);
break;
}
+ d.uuid = bytearray_to_gatouuid(uuid);
list.append(d);