Cmdr/src/session.h
Maurice ONeal fb4d0bed87 Added Windows Build/Install Support
linux_build.sh is now replaced by the build.py and install.py Python
scripts. with this comes cross platform build/install support
between Windows and Linux.

as of v4.x.2.x of the MRCI protocol, the TEXT type id is now
formatted in UTF8 instead of UTF16LE unicode. this change also
affected the tcp rev and several async commands so client code had
to be ajusted accordingly.
2020-08-09 17:22:31 -04:00

119 lines
3.0 KiB
C++

#ifndef SOCKET_H
#define SOCKET_H
// This file is part of Cmdr.
// Cmdr is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Cmdr is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Cmdr under the LICENSE.md file. If not, see
// <http://www.gnu.org/licenses/>.
#include <openssl/ssl.h>
#include <openssl/x509.h>
#include <QObject>
#include <QSslSocket>
#include <QHostAddress>
#include <QFile>
#include <QAbstractSocket>
#include <QCoreApplication>
#include <QTextCodec>
#include <QTextStream>
#include <QXmlStreamWriter>
#include <QSsl>
#include <QSslKey>
#include <QSslCipher>
#include <QSslCertificate>
#include <QSocketNotifier>
#include <QSslConfiguration>
#include <QTimer>
#include "cmd_objs/command.h"
#include "cmd_objs/bookmarks.h"
#include "cmd_objs/host_doc.h"
#define SERVER_HEADER_TAG "MRCI"
#define SERVER_HEADER_LEN 37
#define FRAME_HEADER_LEN 8
class Session : public QSslSocket
{
Q_OBJECT
private:
QTimer *progResetDelay;
quint32 flags;
quint32 dSize;
quint16 cmdId;
quint16 branId;
quint16 hook;
quint8 dType;
bool activeProg;
bool reconnect;
void cacheTxt(quint8 typeId, QString txt);
void dataFromHost(const QByteArray &data);
void procAsync(const QByteArray &data);
void updateProg(int value);
bool isAsync(quint16 id);
private slots:
void dataIn();
void isConnected();
void isDisconnected();
void handShakeDone();
void resetProg();
void startProg();
void sockerr(QAbstractSocket::SocketError err);
void sslErrs(const QList<QSslError> &errors);
public:
enum SessionFlags : uint
{
VER_OK = 1,
DSIZE_RDY = 1 << 2,
GEN_FILE_ON = 1 << 3
};
explicit Session(QObject *parent = nullptr);
public slots:
void hookedBinToServer(const QByteArray &data, quint8 typeId);
void binToServer(quint16 cmdId, const QByteArray &data, quint8 typeId);
void enableGenFile(bool state);
void setCmdHook(quint16 cmdId);
void idle();
void termHostCmd();
void yieldHostCmd();
void resumeHostCmd();
void connectToServ();
void disconnectFromServ();
signals:
void hostFinished();
void txtInCache();
void loopDataIn();
void showProg(bool);
void setProg(int);
void setUserIO(int flgs);
void unsetUserIO(int flgs);
void hostCmdRemoved(quint16 id);
void toGenFile(const QByteArray &data);
};
#endif // SOCKET_H