* @brief Returns the publisher configuration; password is never included. */
| 219 | * @brief Returns the publisher configuration; password is never included. |
| 220 | */ |
| 221 | API::CommandResponse API::Handlers::MqttHandler::publisherGetConfig(const QString& id, |
| 222 | const QJsonObject& params) |
| 223 | { |
| 224 | Q_UNUSED(params) |
| 225 | |
| 226 | const auto& p = MQTT::Publisher::instance(); |
| 227 | |
| 228 | MQTT::CredentialVault vault; |
| 229 | const bool hasCreds = vault.hasCredentials(p.hostname(), p.port()); |
| 230 | |
| 231 | QJsonObject result; |
| 232 | result[QStringLiteral("enabled")] = p.enabled(); |
| 233 | result[QStringLiteral("hostname")] = p.hostname(); |
| 234 | result[QStringLiteral("port")] = p.port(); |
| 235 | result[QStringLiteral("clientId")] = p.clientId(); |
| 236 | result[QStringLiteral("customClientId")] = p.customClientId(); |
| 237 | result[QStringLiteral("username")] = p.username(); |
| 238 | result[QStringLiteral("hasCredentials")] = hasCreds; |
| 239 | result[QStringLiteral("topicBase")] = p.topicBase(); |
| 240 | result[QStringLiteral("notificationTopic")] = p.notificationTopic(); |
| 241 | result[QStringLiteral("publishNotifications")] = p.publishNotifications(); |
| 242 | result[QStringLiteral("mode")] = p.mode(); |
| 243 | result[QStringLiteral("modeLabel")] = p.modeLabel(); |
| 244 | result[QStringLiteral("publishFrequency")] = p.publishFrequency(); |
| 245 | result[QStringLiteral("cleanSession")] = p.cleanSession(); |
| 246 | result[QStringLiteral("keepAlive")] = p.keepAlive(); |
| 247 | result[QStringLiteral("mqttVersion")] = p.mqttVersion(); |
| 248 | result[QStringLiteral("sslEnabled")] = p.sslEnabled(); |
| 249 | result[QStringLiteral("sslProtocol")] = p.sslProtocol(); |
| 250 | result[QStringLiteral("peerVerifyMode")] = p.peerVerifyMode(); |
| 251 | result[QStringLiteral("peerVerifyDepth")] = p.peerVerifyDepth(); |
| 252 | |
| 253 | result[QStringLiteral("modes")] = QJsonArray::fromStringList(p.modes()); |
| 254 | result[QStringLiteral("mqttVersions")] = QJsonArray::fromStringList(p.mqttVersions()); |
| 255 | result[QStringLiteral("sslProtocols")] = QJsonArray::fromStringList(p.sslProtocols()); |
| 256 | result[QStringLiteral("peerVerifyModes")] = QJsonArray::fromStringList(p.peerVerifyModes()); |
| 257 | return CommandResponse::makeSuccess(id, result); |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * @brief Applies endpoint + credential fields to the publisher; returns error on failure. |
nothing calls this directly
no test coverage detected