diff options
| author | Øystein Heskestad <oystein.heskestad@qt.io> | 2023-05-22 16:41:35 +0200 |
|---|---|---|
| committer | Øystein Heskestad <oystein.heskestad@qt.io> | 2023-06-06 07:35:51 +0000 |
| commit | 743de69538696ea14e299c32056d40851bb9fdcd (patch) | |
| tree | bbe4b9197043614d8d13700afa383257ed75f081 /examples/remoteobjects/ssl/sslcppclient/main.cpp | |
| parent | 98522adc399e4fcd97808a0ae4c3a231d6c67739 (diff) | |
Revamp SSL example
The example did not work because the two applications used different
rep-files to generate the remote objects. Use the same file in both
applications, fix usage of case in naming, expand the documentation,
and add a picture. Remove unused PresetData from rep-file.
Task-number: QTBUG-112850
Pick-to: 6.5 6.6
Change-Id: Ia7aafc52d647bca9ffec12b8dd548377f20b6ce4
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples/remoteobjects/ssl/sslcppclient/main.cpp')
| -rw-r--r-- | examples/remoteobjects/ssl/sslcppclient/main.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/examples/remoteobjects/ssl/sslcppclient/main.cpp b/examples/remoteobjects/ssl/sslcppclient/main.cpp index 9d49a12..33a3437 100644 --- a/examples/remoteobjects/ssl/sslcppclient/main.cpp +++ b/examples/remoteobjects/ssl/sslcppclient/main.cpp @@ -11,12 +11,13 @@ #include <QRemoteObjectNode> -class tester : public QObject +class Tester : public QObject { Q_OBJECT public: - tester() : QObject(nullptr) + Tester() : QObject(nullptr) { + //! [0] QRemoteObjectNode m_client; auto socket = setupConnection(); connect(socket, &QSslSocket::errorOccurred, @@ -24,35 +25,49 @@ public: qDebug() << "QSslSocket::error" << error; }) ; m_client.addClientSideConnection(socket); + //! [0] + //! [1] ptr1.reset(m_client.acquire< MinuteTimerReplica >()); ptr2.reset(m_client.acquire< MinuteTimerReplica >()); ptr3.reset(m_client.acquire< MinuteTimerReplica >()); - QTimer::singleShot(0, this, &tester::clear); - QTimer::singleShot(1, this, &tester::clear); - QTimer::singleShot(10000, this, &tester::clear); - QTimer::singleShot(11000, this, &tester::clear); + QTimer::singleShot(0, this, &Tester::clear); + QTimer::singleShot(1, this, &Tester::clear); + QTimer::singleShot(10000, this, &Tester::clear); + QTimer::singleShot(11000, this, &Tester::clear); + //! [1] } public slots: + + //! [2] void clear() { static int i = 0; if (i == 0) { i++; + if (ptr1.isNull()) + qCritical() << "Pointer 1 was not set"; ptr1.reset(); } else if (i == 1) { i++; + if (ptr2.isNull()) + qCritical() << "Pointer 2 was not set"; ptr2.reset(); } else if (i == 2) { i++; + if (ptr3.isNull()) + qCritical() << "Pointer 3 was not set"; ptr3.reset(); } else { qApp->quit(); } } + //! [2] private: - QScopedPointer<MinuteTimerReplica> ptr1, ptr2, ptr3; + QScopedPointer<MinuteTimerReplica> ptr1; + QScopedPointer<MinuteTimerReplica> ptr2; + QScopedPointer<MinuteTimerReplica> ptr3; QSslSocket *setupConnection() { @@ -70,6 +85,7 @@ private: } }; +//! [3] int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); @@ -78,8 +94,9 @@ int main(int argc, char *argv[]) config.setCaCertificates(QSslCertificate::fromPath(QStringLiteral(":/sslcert/rootCA.pem"))); QSslConfiguration::setDefaultConfiguration(config); - tester t; + Tester t; return a.exec(); } +//! [3] #include "main.moc" |
