summaryrefslogtreecommitdiff
path: root/src/bluetooth/qbluetoothserviceinfo_osx.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/bluetooth/qbluetoothserviceinfo_osx.mm')
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_osx.mm59
1 files changed, 36 insertions, 23 deletions
diff --git a/src/bluetooth/qbluetoothserviceinfo_osx.mm b/src/bluetooth/qbluetoothserviceinfo_osx.mm
index 27da70fc..34de4695 100644
--- a/src/bluetooth/qbluetoothserviceinfo_osx.mm
+++ b/src/bluetooth/qbluetoothserviceinfo_osx.mm
@@ -304,80 +304,93 @@ QBluetoothServiceInfo &QBluetoothServiceInfo::operator=(const QBluetoothServiceI
return *this;
}
-static void dumpAttributeVariant(const QVariant &var, const QString indent)
+static void dumpAttributeVariant(QDebug dbg, const QVariant &var, const QString& indent)
{
switch (int(var.type())) {
case QMetaType::Void:
- qDebug("%sEmpty", indent.toLocal8Bit().constData());
+ dbg << QString::asprintf("%sEmpty\n", indent.toUtf8().constData());
break;
case QMetaType::UChar:
- qDebug("%suchar %u", indent.toLocal8Bit().constData(), var.toUInt());
+ dbg << QString::asprintf("%suchar %u\n", indent.toUtf8().constData(), var.toUInt());
break;
case QMetaType::UShort:
- qDebug("%sushort %u", indent.toLocal8Bit().constData(), var.toUInt());
+ dbg << QString::asprintf("%sushort %u\n", indent.toUtf8().constData(), var.toUInt());
+ break;
case QMetaType::UInt:
- qDebug("%suint %u", indent.toLocal8Bit().constData(), var.toUInt());
+ dbg << QString::asprintf("%suint %u\n", indent.toUtf8().constData(), var.toUInt());
break;
case QMetaType::Char:
- qDebug("%schar %d", indent.toLocal8Bit().constData(), var.toInt());
+ dbg << QString::asprintf("%schar %d\n", indent.toUtf8().constData(), var.toInt());
break;
case QMetaType::Short:
- qDebug("%sshort %d", indent.toLocal8Bit().constData(), var.toInt());
+ dbg << QString::asprintf("%sshort %d\n", indent.toUtf8().constData(), var.toInt());
break;
case QMetaType::Int:
- qDebug("%sint %d", indent.toLocal8Bit().constData(), var.toInt());
+ dbg << QString::asprintf("%sint %d\n", indent.toUtf8().constData(), var.toInt());
break;
case QMetaType::QString:
- qDebug("%sstring %s", indent.toLocal8Bit().constData(), var.toString().toLocal8Bit().constData());
+ dbg << QString::asprintf("%sstring %s\n", indent.toUtf8().constData(),
+ var.toString().toUtf8().constData());
+ break;
+ case QMetaType::QByteArray:
+ dbg << QString::asprintf("%sbytearray %s\n", indent.toUtf8().constData(),
+ var.toByteArray().toHex().constData());
break;
case QMetaType::Bool:
- qDebug("%sbool %d", indent.toLocal8Bit().constData(), var.toBool());
+ dbg << QString::asprintf("%sbool %d\n", indent.toUtf8().constData(), var.toBool());
break;
case QMetaType::QUrl:
- qDebug("%surl %s", indent.toLocal8Bit().constData(), var.toUrl().toString().toLocal8Bit().constData());
+ dbg << QString::asprintf("%surl %s\n", indent.toUtf8().constData(),
+ var.toUrl().toString().toUtf8().constData());
break;
case QVariant::UserType:
if (var.userType() == qMetaTypeId<QBluetoothUuid>()) {
QBluetoothUuid uuid = var.value<QBluetoothUuid>();
switch (uuid.minimumSize()) {
case 0:
- qDebug("%suuid NULL", indent.toLocal8Bit().constData());
+ dbg << QString::asprintf("%suuid NULL\n", indent.toUtf8().constData());
break;
case 2:
- qDebug("%suuid %04x", indent.toLocal8Bit().constData(), uuid.toUInt16());
+ dbg << QString::asprintf("%suuid2 %04x\n", indent.toUtf8().constData(),
+ uuid.toUInt16());
break;
case 4:
- qDebug("%suuid %08x", indent.toLocal8Bit().constData(), uuid.toUInt32());
+ dbg << QString::asprintf("%suuid %08x\n", indent.toUtf8().constData(),
+ uuid.toUInt32());
break;
case 16:
- qDebug("%suuid %s", indent.toLocal8Bit().constData(), QByteArray(reinterpret_cast<const char *>(uuid.toUInt128().data), 16).toHex().constData());
+ dbg << QString::asprintf("%suuid %s\n",
+ indent.toUtf8().constData(),
+ QByteArray(reinterpret_cast<const char *>(uuid.toUInt128().data), 16).toHex().constData());
break;
default:
- qDebug("%suuid ???", indent.toLocal8Bit().constData());
- ;
+ dbg << QString::asprintf("%suuid ???\n", indent.toUtf8().constData());
}
} else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Sequence>()) {
- qDebug("%sSequence", indent.toLocal8Bit().constData());
+ dbg << QString::asprintf("%sSequence\n", indent.toUtf8().constData());
const QBluetoothServiceInfo::Sequence *sequence = static_cast<const QBluetoothServiceInfo::Sequence *>(var.data());
for (const QVariant &v : *sequence)
- dumpAttributeVariant(v, indent + QLatin1Char('\t'));
+ dumpAttributeVariant(dbg, v, indent + QLatin1Char('\t'));
} else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Alternative>()) {
- qDebug("%sAlternative", indent.toLocal8Bit().constData());
+ dbg << QString::asprintf("%sAlternative\n", indent.toUtf8().constData());
const QBluetoothServiceInfo::Alternative *alternative = static_cast<const QBluetoothServiceInfo::Alternative *>(var.data());
for (const QVariant &v : *alternative)
- dumpAttributeVariant(v, indent + QLatin1Char('\t'));
+ dumpAttributeVariant(dbg, v, indent + QLatin1Char('\t'));
}
break;
default:
- qDebug("%sunknown variant type %d", indent.toLocal8Bit().constData(), var.userType());
+ dbg << QString::asprintf("%sunknown variant type %d\n", indent.toUtf8().constData(),
+ var.userType());
}
}
QDebug operator << (QDebug dbg, const QBluetoothServiceInfo &info)
{
+ QDebugStateSaver saver(dbg);
+ dbg.noquote() << "\n";
const QList<quint16> attributes = info.attributes();
for (quint16 id : attributes) {
- dumpAttributeVariant(info.attribute(id), QString::fromLatin1("(%1)\t").arg(id));
+ dumpAttributeVariant(dbg, info.attribute(id), QString::fromLatin1("(%1)\t").arg(id));
}
return dbg;
}