aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2019-04-11 15:18:41 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2019-04-17 08:05:49 +0000
commit7706ea979244f81aec815664a33bb4ffc862c954 (patch)
treeefdbe6c2611d86667905de3b0a93a3b0f5c290c8
parent637b228a380d9f5a4a2a2f85fb487b32127076cb (diff)
Add a button for closing the connection in secure client example
Change-Id: Icc21315a5a20eeee02b578dc56459d4697a6361d Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--examples/coap/quicksecureclient/main.qml19
-rw-r--r--examples/coap/quicksecureclient/qmlcoapsecureclient.cpp6
-rw-r--r--examples/coap/quicksecureclient/qmlcoapsecureclient.h1
3 files changed, 23 insertions, 3 deletions
diff --git a/examples/coap/quicksecureclient/main.qml b/examples/coap/quicksecureclient/main.qml
index 8b637db..13eb478 100644
--- a/examples/coap/quicksecureclient/main.qml
+++ b/examples/coap/quicksecureclient/main.qml
@@ -64,8 +64,9 @@ Window {
CoapSecureClient {
id: client
onFinished: {
- outputView.text = result
- statusLabel.text = ""
+ outputView.text = result;
+ statusLabel.text = "";
+ disconnectButton.enabled = true;
}
}
@@ -182,7 +183,6 @@ Window {
id: requestButton
text: qsTr("Send Request")
enabled: securityModeGroup.checkState !== Qt.Unchecked
- Layout.columnSpan: 2
onClicked: {
outputView.text = "";
@@ -201,6 +201,19 @@ Window {
}
}
+ Button {
+ id: disconnectButton
+ text: qsTr("Disconnect")
+ enabled: false
+
+ onClicked: {
+ client.disconnect();
+ statusLabel.text = qsTr("Disconnected.");
+ outputView.text = "";
+ disconnectButton.enabled = false;
+ }
+ }
+
TextArea {
id: outputView
placeholderText: qsTr("<Client Output>")
diff --git a/examples/coap/quicksecureclient/qmlcoapsecureclient.cpp b/examples/coap/quicksecureclient/qmlcoapsecureclient.cpp
index f73af8e..3dda7b0 100644
--- a/examples/coap/quicksecureclient/qmlcoapsecureclient.cpp
+++ b/examples/coap/quicksecureclient/qmlcoapsecureclient.cpp
@@ -159,3 +159,9 @@ void QmlCoapSecureClient::setSecurityConfiguration(const QString &localCertifica
}
m_configuration = configuration;
}
+
+void QmlCoapSecureClient::disconnect()
+{
+ if (m_coapClient)
+ m_coapClient->disconnect();
+}
diff --git a/examples/coap/quicksecureclient/qmlcoapsecureclient.h b/examples/coap/quicksecureclient/qmlcoapsecureclient.h
index 1451d32..bdb0ebc 100644
--- a/examples/coap/quicksecureclient/qmlcoapsecureclient.h
+++ b/examples/coap/quicksecureclient/qmlcoapsecureclient.h
@@ -68,6 +68,7 @@ public:
Q_INVOKABLE void setSecurityConfiguration(const QString &localCertificatePath,
const QString &caCertificatePath,
const QString &privateKeyPath);
+ Q_INVOKABLE void disconnect();
Q_SIGNALS:
void finished(const QString &result);