Line data Source code
1 : // SPDX-FileCopyrightText: 2022 Paul Colby <git@colby.id.au> 2 : // SPDX-License-Identifier: LGPL-3.0-or-later 3 : 4 : #include "abstractcommand.h" 5 : 6 800 : class ScanCommand : public AbstractCommand 7 : { 8 : public: 9 : explicit ScanCommand(QObject * const parent); 10 : 11 : QStringList requiredOptions(const QCommandLineParser &parser) const override; 12 : QStringList supportedOptions(const QCommandLineParser &parser) const override; 13 : 14 : public slots: 15 : QStringList processOptions(const QCommandLineParser &parser) override; 16 : bool start() override; 17 : 18 : protected slots: 19 : void deviceDiscovered(const QBluetoothDeviceInfo &info) override; 20 : #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) // Required signal, and Fields, added in Qt 5.12. 21 : void deviceUpdated(const QBluetoothDeviceInfo &info, 22 : const QBluetoothDeviceInfo::Fields updatedFields); 23 : #endif 24 : void deviceDiscoveryFinished() override; 25 : 26 : private: 27 : bool showCsvHeader; ///< Whether or not to show a header as the first line of CSV output. 28 : 29 : static QJsonObject toJson(const QBluetoothDeviceInfo &info); 30 : static QJsonArray toJson(const QBluetoothDeviceInfo::CoreConfigurations &configurations); 31 : static QJsonValue toJson(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass); 32 : static QJsonValue toJson(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass, const quint8 minorClass); 33 : static QJsonArray toJson(const QBluetoothDeviceInfo::ServiceClasses &classes); 34 : static QJsonArray toJson(const QList<QBluetoothUuid> &uuids); 35 : static QJsonObject toJson(const QMultiHash<quint16, QByteArray> &data); 36 : 37 : static QString toString(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass); 38 : static QString toString(const QBluetoothDeviceInfo::MajorDeviceClass &majorClass, const quint8 minorClass); 39 : 40 : friend class TestScanCommand; 41 : };