* @brief Returns the subscriber driver configuration; password is never included. */
| 453 | * @brief Returns the subscriber driver configuration; password is never included. |
| 454 | */ |
| 455 | API::CommandResponse API::Handlers::MqttHandler::subscriberGetConfig(const QString& id, |
| 456 | const QJsonObject& params) |
| 457 | { |
| 458 | Q_UNUSED(params) |
| 459 | |
| 460 | const auto* d = subscriber(); |
| 461 | if (!d) |
| 462 | return CommandResponse::makeError( |
| 463 | id, ErrorCode::ExecutionError, QStringLiteral("MQTT subscriber driver unavailable")); |
| 464 | |
| 465 | MQTT::CredentialVault vault; |
| 466 | const bool hasCreds = vault.hasCredentials(d->hostname(), d->port()); |
| 467 | |
| 468 | QJsonObject result; |
| 469 | result[QStringLiteral("hostname")] = d->hostname(); |
| 470 | result[QStringLiteral("port")] = d->port(); |
| 471 | result[QStringLiteral("clientId")] = d->clientId(); |
| 472 | result[QStringLiteral("username")] = d->username(); |
| 473 | result[QStringLiteral("hasCredentials")] = hasCreds; |
| 474 | result[QStringLiteral("topicFilter")] = d->topicFilter(); |
| 475 | result[QStringLiteral("cleanSession")] = d->cleanSession(); |
| 476 | result[QStringLiteral("autoKeepAlive")] = d->autoKeepAlive(); |
| 477 | result[QStringLiteral("keepAlive")] = d->keepAlive(); |
| 478 | result[QStringLiteral("mqttVersion")] = d->mqttVersion(); |
| 479 | result[QStringLiteral("sslEnabled")] = d->sslEnabled(); |
| 480 | result[QStringLiteral("sslProtocol")] = d->sslProtocol(); |
| 481 | result[QStringLiteral("peerVerifyMode")] = d->peerVerifyMode(); |
| 482 | result[QStringLiteral("peerVerifyDepth")] = d->peerVerifyDepth(); |
| 483 | |
| 484 | result[QStringLiteral("mqttVersions")] = QJsonArray::fromStringList(d->mqttVersions()); |
| 485 | result[QStringLiteral("sslProtocols")] = QJsonArray::fromStringList(d->sslProtocols()); |
| 486 | result[QStringLiteral("peerVerifyModes")] = QJsonArray::fromStringList(d->peerVerifyModes()); |
| 487 | return CommandResponse::makeSuccess(id, result); |
| 488 | } |
| 489 | |
| 490 | /** |
| 491 | * @brief Applies endpoint + credential + topic fields to the subscriber. |
nothing calls this directly
no test coverage detected