! * \brief Tests the currently selected connection */
| 599 | * \brief Tests the currently selected connection |
| 600 | */ |
| 601 | void MQTTConnectionManagerWidget::testConnection() { |
| 602 | if (!m_currentConnection) |
| 603 | return; |
| 604 | |
| 605 | WAIT_CURSOR; |
| 606 | |
| 607 | m_testing = true; |
| 608 | |
| 609 | if (!m_client) { |
| 610 | m_client = new QMqttClient; |
| 611 | m_testTimer = new QTimer(this); |
| 612 | m_testTimer->setInterval(5000); |
| 613 | connect(m_client, &QMqttClient::connected, this, &MQTTConnectionManagerWidget::onConnect); |
| 614 | connect(m_client, &QMqttClient::disconnected, this, &MQTTConnectionManagerWidget::onDisconnect); |
| 615 | connect(m_testTimer, &QTimer::timeout, this, &MQTTConnectionManagerWidget::testTimeout); |
| 616 | } |
| 617 | |
| 618 | m_client->setHostname(m_currentConnection->hostName); |
| 619 | m_client->setPort(m_currentConnection->port); |
| 620 | |
| 621 | if (m_currentConnection->useID) |
| 622 | m_client->setClientId(m_currentConnection->clientID); |
| 623 | |
| 624 | if (m_currentConnection->useAuthentication) { |
| 625 | m_client->setUsername(m_currentConnection->userName); |
| 626 | m_client->setPassword(m_currentConnection->password); |
| 627 | } |
| 628 | |
| 629 | m_testTimer->start(); |
| 630 | m_client->connectToHost(); |
| 631 | } |
| 632 | |
| 633 | /*! |
| 634 | * \brief Called when the client connects to the host, this means the test was successful |
nothing calls this directly
no test coverage detected