From 34028376b21cef3647b47a120fb51192552d71ca Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 22 May 2014 14:20:07 +0200 Subject: Add QBluetoothUuid::protocolToString() [ChangeLog][QtBluetooth][General] Added QBluetoothUuid::protocolToString(QBluetoothUuid::ProtocolUuid) which returns a human-readable string for the given protocol uuid. Change-Id: I26b9a1b47b1254ac8a49091c2854d1cfab0c66d6 Reviewed-by: Aaron McCarthy --- src/bluetooth/qbluetoothuuid.cpp | 45 ++++++++++++++++++++++++++++++++++++++++ src/bluetooth/qbluetoothuuid.h | 1 + 2 files changed, 46 insertions(+) (limited to 'src/bluetooth') diff --git a/src/bluetooth/qbluetoothuuid.cpp b/src/bluetooth/qbluetoothuuid.cpp index 91d0fc8b..0d20b2ec 100644 --- a/src/bluetooth/qbluetoothuuid.cpp +++ b/src/bluetooth/qbluetoothuuid.cpp @@ -369,6 +369,7 @@ quint128 QBluetoothUuid::toUInt128() const represented by \a uuid. \sa QBluetoothUuid::ServiceClassUuid + \since Qt 5.4 */ QString QBluetoothUuid::serviceClassToString(QBluetoothUuid::ServiceClassUuid uuid) { @@ -443,6 +444,50 @@ QString QBluetoothUuid::serviceClassToString(QBluetoothUuid::ServiceClassUuid uu return QString(); } + +/*! + Returns a human-readable and translated name for the given protocol + represented by \a uuid. + + \sa QBluetoothUuid::ProtocolUuid + + \since Qt 5.4 + */ +QString QBluetoothUuid::protocolToString(QBluetoothUuid::ProtocolUuid uuid) +{ + switch (uuid) { + case QBluetoothUuid::Sdp: return QBluetoothServiceDiscoveryAgent::tr("Service Discovery Protocol"); + case QBluetoothUuid::Udp: return QBluetoothServiceDiscoveryAgent::tr("User Datagram Protocol"); + case QBluetoothUuid::Rfcomm: return QBluetoothServiceDiscoveryAgent::tr("Radio Frequency Communication"); + case QBluetoothUuid::Tcp: return QBluetoothServiceDiscoveryAgent::tr("Transmission Control Protocol"); + case QBluetoothUuid::TcsBin: return QBluetoothServiceDiscoveryAgent::tr("Telephony Control Specification - Binary"); + case QBluetoothUuid::TcsAt: return QBluetoothServiceDiscoveryAgent::tr("Telephony Control Specification - AT"); + case QBluetoothUuid::Att: return QBluetoothServiceDiscoveryAgent::tr("Attribute Protocol"); + case QBluetoothUuid::Obex: return QBluetoothServiceDiscoveryAgent::tr("Object Exchange Protocol"); + case QBluetoothUuid::Ip: return QBluetoothServiceDiscoveryAgent::tr("Internet Protocol"); + case QBluetoothUuid::Ftp: return QBluetoothServiceDiscoveryAgent::tr("File Transfer Protocol"); + case QBluetoothUuid::Http: return QBluetoothServiceDiscoveryAgent::tr("Hypertext Transfer Protocol"); + case QBluetoothUuid::Wsp: return QBluetoothServiceDiscoveryAgent::tr("Wireless Short Packet Protocol"); + case QBluetoothUuid::Bnep: return QBluetoothServiceDiscoveryAgent::tr("Bluetooth Network Encapsulation Protocol"); + case QBluetoothUuid::Upnp: return QBluetoothServiceDiscoveryAgent::tr("Extended Service Discovery Protocol"); + case QBluetoothUuid::Hidp: return QBluetoothServiceDiscoveryAgent::tr("Human Interface Device Protocol"); + case QBluetoothUuid::HardcopyControlChannel: return QBluetoothServiceDiscoveryAgent::tr("Hardcopy Control Channel"); + case QBluetoothUuid::HardcopyDataChannel: return QBluetoothServiceDiscoveryAgent::tr("Hardcopy Data Channel"); + case QBluetoothUuid::HardcopyNotification: return QBluetoothServiceDiscoveryAgent::tr("Hardcopy Notification"); + case QBluetoothUuid::Avctp: return QBluetoothServiceDiscoveryAgent::tr("Audio/Video Control Transport Protocol"); + case QBluetoothUuid::Avdtp: return QBluetoothServiceDiscoveryAgent::tr("Audio/Video Distribution Transport Protocol"); + case QBluetoothUuid::Cmtp: return QBluetoothServiceDiscoveryAgent::tr("Common ISDN Access Protocol"); + case QBluetoothUuid::UdiCPlain: return QBluetoothServiceDiscoveryAgent::tr("UdiCPlain"); + case QBluetoothUuid::McapControlChannel: return QBluetoothServiceDiscoveryAgent::tr("Multi-Channel Adaptation Protocol -Conrol"); + case QBluetoothUuid::McapDataChannel: return QBluetoothServiceDiscoveryAgent::tr("Multi-Channel Adaptation Protocol - Data"); + case QBluetoothUuid::L2cap: return QBluetoothServiceDiscoveryAgent::tr("Layer 2 Control Protocol"); + default: + break; + } + + return QString(); +} + /*! Returns true if \a other is equal to this Bluetooth UUID, otherwise false. */ diff --git a/src/bluetooth/qbluetoothuuid.h b/src/bluetooth/qbluetoothuuid.h index 46cff826..957a4ed2 100644 --- a/src/bluetooth/qbluetoothuuid.h +++ b/src/bluetooth/qbluetoothuuid.h @@ -174,6 +174,7 @@ public: quint128 toUInt128() const; static QString serviceClassToString(ServiceClassUuid uuid); + static QString protocolToString(ProtocolUuid uuid); }; #ifndef QT_NO_DEBUG_STREAM -- cgit v1.2.3