mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-03 15:55:27 +08:00
qt 6.5.1 original
This commit is contained in:
52
examples/network/securesocketclient/CMakeLists.txt
Normal file
52
examples/network/securesocketclient/CMakeLists.txt
Normal file
@ -0,0 +1,52 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(securesocketclient LANGUAGES CXX)
|
||||
|
||||
if(NOT DEFINED INSTALL_EXAMPLESDIR)
|
||||
set(INSTALL_EXAMPLESDIR "examples")
|
||||
endif()
|
||||
|
||||
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/network/securesocketclient")
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Network Widgets)
|
||||
|
||||
qt_standard_project_setup()
|
||||
|
||||
qt_add_executable(securesocketclient
|
||||
certificateinfo.cpp certificateinfo.h certificateinfo.ui
|
||||
main.cpp
|
||||
sslclient.cpp sslclient.h sslclient.ui
|
||||
sslerrors.ui
|
||||
)
|
||||
|
||||
set_target_properties(securesocketclient PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
MACOSX_BUNDLE TRUE
|
||||
)
|
||||
|
||||
target_link_libraries(securesocketclient PRIVATE
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Network
|
||||
Qt6::Widgets
|
||||
)
|
||||
|
||||
# Resources:
|
||||
set(securesocketclient_resource_files
|
||||
"encrypted.png"
|
||||
)
|
||||
|
||||
qt_add_resources(securesocketclient "securesocketclient"
|
||||
PREFIX
|
||||
"/"
|
||||
FILES
|
||||
${securesocketclient_resource_files}
|
||||
)
|
||||
|
||||
install(TARGETS securesocketclient
|
||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
)
|
58
examples/network/securesocketclient/certificateinfo.cpp
Normal file
58
examples/network/securesocketclient/certificateinfo.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include "certificateinfo.h"
|
||||
#include "ui_certificateinfo.h"
|
||||
|
||||
CertificateInfo::CertificateInfo(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
form = new Ui_CertificateInfo;
|
||||
form->setupUi(this);
|
||||
|
||||
connect(form->certificationPathView, &QComboBox::currentIndexChanged,
|
||||
this, &CertificateInfo::updateCertificateInfo);
|
||||
}
|
||||
|
||||
CertificateInfo::~CertificateInfo()
|
||||
{
|
||||
delete form;
|
||||
}
|
||||
|
||||
void CertificateInfo::setCertificateChain(const QList<QSslCertificate> &chain)
|
||||
{
|
||||
certificateChain = chain;
|
||||
|
||||
form->certificationPathView->clear();
|
||||
for (int i = 0; i < certificateChain.size(); ++i) {
|
||||
const QSslCertificate &cert = certificateChain.at(i);
|
||||
form->certificationPathView->addItem(tr("%1%2 (%3)").arg(!i ? QString() : tr("Issued by: "))
|
||||
.arg(cert.subjectInfo(QSslCertificate::Organization).join(QLatin1Char(' ')))
|
||||
.arg(cert.subjectInfo(QSslCertificate::CommonName).join(QLatin1Char(' '))));
|
||||
}
|
||||
form->certificationPathView->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void CertificateInfo::updateCertificateInfo(int index)
|
||||
{
|
||||
form->certificateInfoView->clear();
|
||||
if (index >= 0 && index < certificateChain.size()) {
|
||||
const QSslCertificate &cert = certificateChain.at(index);
|
||||
QStringList lines;
|
||||
lines << tr("Organization: %1").arg(cert.subjectInfo(QSslCertificate::Organization).join(QLatin1Char(' ')))
|
||||
<< tr("Subunit: %1").arg(cert.subjectInfo(QSslCertificate::OrganizationalUnitName).join(QLatin1Char(' ')))
|
||||
<< tr("Country: %1").arg(cert.subjectInfo(QSslCertificate::CountryName).join(QLatin1Char(' ')))
|
||||
<< tr("Locality: %1").arg(cert.subjectInfo(QSslCertificate::LocalityName).join(QLatin1Char(' ')))
|
||||
<< tr("State/Province: %1").arg(cert.subjectInfo(QSslCertificate::StateOrProvinceName).join(QLatin1Char(' ')))
|
||||
<< tr("Common Name: %1").arg(cert.subjectInfo(QSslCertificate::CommonName).join(QLatin1Char(' ')))
|
||||
<< QString()
|
||||
<< tr("Issuer Organization: %1").arg(cert.issuerInfo(QSslCertificate::Organization).join(QLatin1Char(' ')))
|
||||
<< tr("Issuer Unit Name: %1").arg(cert.issuerInfo(QSslCertificate::OrganizationalUnitName).join(QLatin1Char(' ')))
|
||||
<< tr("Issuer Country: %1").arg(cert.issuerInfo(QSslCertificate::CountryName).join(QLatin1Char(' ')))
|
||||
<< tr("Issuer Locality: %1").arg(cert.issuerInfo(QSslCertificate::LocalityName).join(QLatin1Char(' ')))
|
||||
<< tr("Issuer State/Province: %1").arg(cert.issuerInfo(QSslCertificate::StateOrProvinceName).join(QLatin1Char(' ')))
|
||||
<< tr("Issuer Common Name: %1").arg(cert.issuerInfo(QSslCertificate::CommonName).join(QLatin1Char(' ')));
|
||||
for (const auto &line : lines)
|
||||
form->certificateInfoView->addItem(line);
|
||||
}
|
||||
}
|
32
examples/network/securesocketclient/certificateinfo.h
Normal file
32
examples/network/securesocketclient/certificateinfo.h
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#ifndef CERTIFICATEINFO_H
|
||||
#define CERTIFICATEINFO_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QList>
|
||||
#include <QSslCertificate>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class Ui_CertificateInfo;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class CertificateInfo : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CertificateInfo(QWidget *parent = nullptr);
|
||||
~CertificateInfo();
|
||||
|
||||
void setCertificateChain(const QList<QSslCertificate> &chain);
|
||||
|
||||
private slots:
|
||||
void updateCertificateInfo(int index);
|
||||
|
||||
private:
|
||||
Ui_CertificateInfo *form = nullptr;
|
||||
QList<QSslCertificate> certificateChain;
|
||||
};
|
||||
|
||||
#endif
|
101
examples/network/securesocketclient/certificateinfo.ui
Normal file
101
examples/network/securesocketclient/certificateinfo.ui
Normal file
@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CertificateInfo</class>
|
||||
<widget class="QDialog" name="CertificateInfo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>397</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Display Certificate Information</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Certification Path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="certificationPathView">
|
||||
<property name="minimumContentsLength">
|
||||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Certificate Information</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="certificateInfoView">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>clicked(QAbstractButton*)</signal>
|
||||
<receiver>CertificateInfo</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>343</x>
|
||||
<y>374</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>352</x>
|
||||
<y>422</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
BIN
examples/network/securesocketclient/encrypted.png
Normal file
BIN
examples/network/securesocketclient/encrypted.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 750 B |
28
examples/network/securesocketclient/main.cpp
Normal file
28
examples/network/securesocketclient/main.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QtNetwork>
|
||||
|
||||
QT_REQUIRE_CONFIG(ssl);
|
||||
|
||||
#include "sslclient.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Q_INIT_RESOURCE(securesocketclient);
|
||||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
if (!QSslSocket::supportsSsl()) {
|
||||
QMessageBox::information(nullptr, "Secure Socket Client",
|
||||
"This system does not support TLS.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
SslClient client;
|
||||
client.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
19
examples/network/securesocketclient/securesocketclient.pro
Normal file
19
examples/network/securesocketclient/securesocketclient.pro
Normal file
@ -0,0 +1,19 @@
|
||||
requires(qtHaveModule(network))
|
||||
|
||||
HEADERS += certificateinfo.h \
|
||||
sslclient.h
|
||||
SOURCES += certificateinfo.cpp \
|
||||
main.cpp \
|
||||
sslclient.cpp
|
||||
RESOURCES += securesocketclient.qrc
|
||||
FORMS += certificateinfo.ui \
|
||||
sslclient.ui \
|
||||
sslerrors.ui
|
||||
QT += network widgets
|
||||
requires(qtConfig(listwidget))
|
||||
requires(qtConfig(combobox))
|
||||
|
||||
# install
|
||||
target.path = $$[QT_INSTALL_EXAMPLES]/network/securesocketclient
|
||||
INSTALLS += target
|
||||
|
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>encrypted.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
198
examples/network/securesocketclient/sslclient.cpp
Normal file
198
examples/network/securesocketclient/sslclient.cpp
Normal file
@ -0,0 +1,198 @@
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include "certificateinfo.h"
|
||||
#include "sslclient.h"
|
||||
|
||||
#include "ui_sslclient.h"
|
||||
#include "ui_sslerrors.h"
|
||||
|
||||
SslClient::SslClient(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi();
|
||||
setupSecureSocket();
|
||||
}
|
||||
|
||||
SslClient::~SslClient()
|
||||
{
|
||||
delete socket;
|
||||
delete form;
|
||||
}
|
||||
|
||||
void SslClient::updateEnabledState()
|
||||
{
|
||||
const bool unconnected = socket->state() == QAbstractSocket::UnconnectedState;
|
||||
form->hostNameEdit->setReadOnly(!unconnected);
|
||||
form->hostNameEdit->setFocusPolicy(unconnected ? Qt::StrongFocus : Qt::NoFocus);
|
||||
form->hostNameLabel->setEnabled(unconnected);
|
||||
form->portBox->setEnabled(unconnected);
|
||||
form->portLabel->setEnabled(unconnected);
|
||||
form->connectButton->setEnabled(unconnected && !form->hostNameEdit->text().isEmpty());
|
||||
|
||||
const bool connected = socket->state() == QAbstractSocket::ConnectedState;
|
||||
form->sessionOutput->setEnabled(connected);
|
||||
form->sessionInput->setEnabled(connected);
|
||||
form->sessionInputLabel->setEnabled(connected);
|
||||
form->sendButton->setEnabled(connected);
|
||||
}
|
||||
|
||||
void SslClient::secureConnect()
|
||||
{
|
||||
socket->connectToHostEncrypted(form->hostNameEdit->text(), form->portBox->value());
|
||||
updateEnabledState();
|
||||
}
|
||||
|
||||
void SslClient::socketStateChanged(QAbstractSocket::SocketState state)
|
||||
{
|
||||
if (executingDialog)
|
||||
return;
|
||||
|
||||
updateEnabledState();
|
||||
|
||||
if (state == QAbstractSocket::UnconnectedState) {
|
||||
form->sessionInput->clear();
|
||||
form->hostNameEdit->setPalette(QPalette());
|
||||
form->hostNameEdit->setFocus();
|
||||
form->cipherLabel->setText(tr("<none>"));
|
||||
padLock->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void SslClient::socketEncrypted()
|
||||
{
|
||||
form->sessionOutput->clear();
|
||||
form->sessionInput->setFocus();
|
||||
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::Base, QColor(255, 255, 192));
|
||||
form->hostNameEdit->setPalette(palette);
|
||||
|
||||
const QSslCipher cipher = socket->sessionCipher();
|
||||
const QString cipherInfo = QString("%1, %2 (%3/%4)").arg(cipher.authenticationMethod())
|
||||
.arg(cipher.name()).arg(cipher.usedBits())
|
||||
.arg(cipher.supportedBits());;
|
||||
form->cipherLabel->setText(cipherInfo);
|
||||
padLock->show();
|
||||
}
|
||||
|
||||
void SslClient::socketReadyRead()
|
||||
{
|
||||
appendString(QString::fromUtf8(socket->readAll()));
|
||||
}
|
||||
|
||||
void SslClient::sendData()
|
||||
{
|
||||
const QString input = form->sessionInput->text();
|
||||
appendString(input + '\n');
|
||||
socket->write(input.toUtf8() + "\r\n");
|
||||
form->sessionInput->clear();
|
||||
}
|
||||
|
||||
void SslClient::socketError(QAbstractSocket::SocketError)
|
||||
{
|
||||
if (handlingSocketError)
|
||||
return;
|
||||
|
||||
handlingSocketError = true;
|
||||
QMessageBox::critical(this, tr("Connection error"), socket->errorString());
|
||||
handlingSocketError = false;
|
||||
}
|
||||
|
||||
void SslClient::sslErrors(const QList<QSslError> &errors)
|
||||
{
|
||||
QDialog errorDialog(this);
|
||||
Ui_SslErrors ui;
|
||||
ui.setupUi(&errorDialog);
|
||||
connect(ui.certificateChainButton, &QPushButton::clicked,
|
||||
this, &SslClient::displayCertificateInfo);
|
||||
|
||||
for (const auto &error : errors)
|
||||
ui.sslErrorList->addItem(error.errorString());
|
||||
|
||||
executingDialog = true;
|
||||
if (errorDialog.exec() == QDialog::Accepted)
|
||||
socket->ignoreSslErrors();
|
||||
executingDialog = false;
|
||||
|
||||
// did the socket state change?
|
||||
if (socket->state() != QAbstractSocket::ConnectedState)
|
||||
socketStateChanged(socket->state());
|
||||
}
|
||||
|
||||
void SslClient::displayCertificateInfo()
|
||||
{
|
||||
CertificateInfo info;
|
||||
info.setCertificateChain(socket->peerCertificateChain());
|
||||
info.exec();
|
||||
}
|
||||
|
||||
void SslClient::setupUi()
|
||||
{
|
||||
if (form)
|
||||
return;
|
||||
|
||||
form = new Ui_Form;
|
||||
form->setupUi(this);
|
||||
form->hostNameEdit->setSelection(0, form->hostNameEdit->text().size());
|
||||
form->sessionOutput->setHtml(tr("<not connected>"));
|
||||
|
||||
connect(form->hostNameEdit, &QLineEdit::textChanged,
|
||||
this, &SslClient::updateEnabledState);
|
||||
connect(form->connectButton, &QPushButton::clicked,
|
||||
this, &SslClient::secureConnect);
|
||||
connect(form->sendButton, &QPushButton::clicked,
|
||||
this, &SslClient::sendData);
|
||||
|
||||
padLock = new QToolButton;
|
||||
padLock->setIcon(QIcon(":/encrypted.png"));
|
||||
connect(padLock, &QToolButton::clicked,
|
||||
this, &SslClient::displayCertificateInfo);
|
||||
|
||||
#if QT_CONFIG(cursor)
|
||||
padLock->setCursor(Qt::ArrowCursor);
|
||||
#endif
|
||||
padLock->setToolTip(tr("Display encryption details."));
|
||||
|
||||
const int extent = form->hostNameEdit->height() - 2;
|
||||
padLock->resize(extent, extent);
|
||||
padLock->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout(form->hostNameEdit);
|
||||
const int margin = form->hostNameEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
layout->setContentsMargins(margin, margin, margin, margin);
|
||||
layout->setSpacing(0);
|
||||
layout->addStretch();
|
||||
layout->addWidget(padLock);
|
||||
|
||||
form->hostNameEdit->setLayout(layout);
|
||||
padLock->hide();
|
||||
}
|
||||
|
||||
void SslClient::setupSecureSocket()
|
||||
{
|
||||
if (socket)
|
||||
return;
|
||||
|
||||
socket = new QSslSocket(this);
|
||||
|
||||
connect(socket, &QSslSocket::stateChanged,
|
||||
this, &SslClient::socketStateChanged);
|
||||
connect(socket, &QSslSocket::encrypted,
|
||||
this, &SslClient::socketEncrypted);
|
||||
connect(socket, &QSslSocket::errorOccurred,
|
||||
this, &SslClient::socketError);
|
||||
connect(socket, QOverload<const QList<QSslError> &>::of(&QSslSocket::sslErrors),
|
||||
this, &SslClient::sslErrors);
|
||||
connect(socket, &QSslSocket::readyRead,
|
||||
this, &SslClient::socketReadyRead);
|
||||
|
||||
}
|
||||
|
||||
void SslClient::appendString(const QString &line)
|
||||
{
|
||||
QTextCursor cursor(form->sessionOutput->textCursor());
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
cursor.insertText(line);
|
||||
form->sessionOutput->verticalScrollBar()->setValue(form->sessionOutput->verticalScrollBar()->maximum());
|
||||
}
|
47
examples/network/securesocketclient/sslclient.h
Normal file
47
examples/network/securesocketclient/sslclient.h
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2017 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#ifndef SSLCLIENT_H
|
||||
#define SSLCLIENT_H
|
||||
|
||||
#include <QtNetwork>
|
||||
|
||||
QT_REQUIRE_CONFIG(ssl);
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class Ui_Form;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class SslClient : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SslClient(QWidget *parent = nullptr);
|
||||
~SslClient();
|
||||
|
||||
private slots:
|
||||
void updateEnabledState();
|
||||
void secureConnect();
|
||||
void socketStateChanged(QAbstractSocket::SocketState state);
|
||||
void socketEncrypted();
|
||||
void socketReadyRead();
|
||||
void sendData();
|
||||
void socketError(QAbstractSocket::SocketError error);
|
||||
void sslErrors(const QList<QSslError> &errors);
|
||||
void displayCertificateInfo();
|
||||
|
||||
private:
|
||||
void setupUi();
|
||||
void setupSecureSocket();
|
||||
void appendString(const QString &line);
|
||||
|
||||
QSslSocket *socket = nullptr;
|
||||
QToolButton *padLock = nullptr;
|
||||
Ui_Form *form = nullptr;
|
||||
bool handlingSocketError = false;
|
||||
bool executingDialog = false;
|
||||
};
|
||||
|
||||
#endif
|
199
examples/network/securesocketclient/sslclient.ui
Normal file
199
examples/network/securesocketclient/sslclient.ui
Normal file
@ -0,0 +1,199 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>343</width>
|
||||
<height>320</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>343</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Secure Socket Client</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="hostNameLabel">
|
||||
<property name="text">
|
||||
<string>Host name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="hostNameEdit">
|
||||
<property name="text">
|
||||
<string>www.qt.io</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="portLabel">
|
||||
<property name="text">
|
||||
<string>Port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="portBox">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>443</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Active session</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="connectButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connect to host</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="cipherText">
|
||||
<property name="text">
|
||||
<string>Cryptographic Cipher:</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="cipherLabel">
|
||||
<property name="text">
|
||||
<string><none></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QTextEdit" name="sessionOutput">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'.SF NS Text'; font-size:13pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br /></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="sessionInputLabel">
|
||||
<property name="text">
|
||||
<string>Input:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="sessionInput">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="sendButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::TabFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Send</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>hostNameEdit</sender>
|
||||
<signal>returnPressed()</signal>
|
||||
<receiver>connectButton</receiver>
|
||||
<slot>animateClick()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>126</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>142</x>
|
||||
<y>78</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>sessionInput</sender>
|
||||
<signal>returnPressed()</signal>
|
||||
<receiver>sendButton</receiver>
|
||||
<slot>animateClick()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>142</x>
|
||||
<y>241</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>297</x>
|
||||
<y>234</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
115
examples/network/securesocketclient/sslerrors.ui
Normal file
115
examples/network/securesocketclient/sslerrors.ui
Normal file
@ -0,0 +1,115 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SslErrors</class>
|
||||
<widget class="QDialog" name="SslErrors">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>371</width>
|
||||
<height>216</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Unable To Validate The Connection</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600; color:#ff0000;">Warning</span><span style=" color:#ff0000;">:</span><span style=" color:#000000;"> One or more errors with this connection prevent validating the authenticity of the host you are connecting to. Please review the following list of errors, and click </span><span style=" color:#000000;">Ignore</span><span style=" color:#000000;"> to continue, or </span><span style=" color:#000000;">Cancel</span><span style=" color:#000000;"> to abort the connection.</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="sslErrorList">
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="certificateChainButton">
|
||||
<property name="text">
|
||||
<string>View Certificate Chain</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Ignore</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>pushButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>SslErrors</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>235</x>
|
||||
<y>185</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>228</x>
|
||||
<y>287</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pushButton_2</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>SslErrors</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>325</x>
|
||||
<y>192</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>333</x>
|
||||
<y>231</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Reference in New Issue
Block a user