Q3270
A Qt-based 3270 Terminal Emulator
Loading...
Searching...
No Matches
SocketConnection.h
1/*
2 * Q3270 Terminal Emulator
3 *
4 * Copyright (c) 2020–2025 Andy Styles
5 * SPDX-License-Identifier: BSD-3-Clause
6 *
7 * This file is part of Q3270.
8 * See the LICENSE file in the project root for full license information.
9 */
10
11#ifndef SOCKETCONNECTION_H
12#define SOCKETCONNECTION_H
13
14#include <QDebug>
15
16#include <QObject>
17#include <QSslSocket>
18#include <QDataStream>
19
20#include <QSslConfiguration>
21#include <QSslCipher>
22
23#include <stdio.h>
24#include <stdlib.h>
25#include <iostream>
26#include <string.h>
27
28#include <arpa/telnet.h>
29
30#include "ProcessDataStream.h"
31
32class QHostAddress;
33
34class SocketConnection : public QObject
35{
36 Q_OBJECT
37 Q_DISABLE_COPY(SocketConnection)
38
39 public:
40
41 explicit SocketConnection(int modelType);
43
44 void setSecure(bool s);
45 void setVerify(bool v);
46 void sendResponse(QByteArray &b);
47
48 QList<QSslCertificate> getCertDetails();
49
50 public slots:
51 void connectMainframe(const QString &address, quint16 port, const QString luName, ProcessDataStream *d);
53 void opened();
54 void closed();
55
56 signals:
57 void connectionStarted();
58 void connectionEnded(QString message = "");
59 void dataStreamComplete(QByteArray &b, bool tn3270e);
60 void encryptedConnection(Q3270::Encryption e);
61
62 private slots:
63 void onReadyRead();
64 void sslErrors(const QList<QSslError> &errors);
65 void socketStateChanged(QAbstractSocket::SocketState state);
66 void error(QAbstractSocket::SocketError socketError);
67 void socketEncrypted();
68
69 private:
70
71 bool tn3270e_Mode;
72
73 bool secureMode;
74 bool verifyCerts;
75 bool certErrors;
76
77 Q3270::TelnetState telnetState;
78 QSslSocket *dataSocket;
79// QTcpSocket *dataSocket;
80 QDataStream dataStream;
81 ProcessDataStream *displayDataStream;
82
83 QString termName;
84 QString luName;
85
86 QByteArray incomingData;
87 QByteArray subNegotiationBuffer;
88
89 void processSubNegotiation();
90
91 const char *tn3270e_functions_strings[5] = { "BIND_IMAGE", "DATA_STREAM_CTL", "RESPONSES", "SCS_CTL_CODES", "SYSREQ" };
92
93 QString tn3270e_terminal_types[5] = { "IBM-3279-2-E", "IBM-3279-3-E", "IBM-3279-4-E", "IBM-3279-5-E", "IBM-DYNAMIC" };
94
95 char tn32703_functions_flags[5];
96
97 void dump(QByteArray &a, QString title);
98};
99
100#endif // SOCKETCONNECTION_H
Definition ProcessDataStream.h:27
Definition SocketConnection.h:35
~SocketConnection()
SocketConnection::~SocketConnection - destructor.
Definition SocketConnection.cpp:84
void sendResponse(QByteArray &b)
SocketConnection::sendResponse - send data back to the host.
Definition SocketConnection.cpp:485
void opened()
SocketConnection::opened - successful open of socket.
Definition SocketConnection.cpp:97
void connectMainframe(const QString &address, quint16 port, const QString luName, ProcessDataStream *d)
SocketConnection::connectMainframe - called when the user connects to a host.
Definition SocketConnection.cpp:140
QList< QSslCertificate > getCertDetails()
SocketConnection::getCertDetails()
Definition SocketConnection.cpp:225
void disconnectMainframe()
SocketConnection::disconnectMainframe - slot called when the connection is terminated.
Definition SocketConnection.cpp:120
void setVerify(bool v)
SocketConnection::setVerify - indicate that the certificates should be verified for a secure connecti...
Definition SocketConnection.cpp:61
void closed()
SocketConnection::closed - socket has been closed.
Definition SocketConnection.cpp:109
void setSecure(bool s)
SocketConnection::setSecure - indicate that this connection should be secured.
Definition SocketConnection.cpp:50