MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / publisherGetConfig

Method publisherGetConfig

app/src/API/Handlers/MqttHandler.cpp:221–258  ·  view source on GitHub ↗

* @brief Returns the publisher configuration; password is never included. */

Source from the content-addressed store, hash-verified

219 * @brief Returns the publisher configuration; password is never included.
220 */
221API::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.

Callers

nothing calls this directly

Calls 15

hasCredentialsMethod · 0.80
customClientIdMethod · 0.80
topicBaseMethod · 0.80
notificationTopicMethod · 0.80
publishNotificationsMethod · 0.80
modeLabelMethod · 0.80
publishFrequencyMethod · 0.80
hostnameMethod · 0.45
portMethod · 0.45
enabledMethod · 0.45
clientIdMethod · 0.45
usernameMethod · 0.45

Tested by

no test coverage detected