#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 // . #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "cmd_objs/command.h" #include "cmd_objs/bookmarks.h" #include "cmd_objs/host_doc.h" #define SERVER_HEADER_TAG "MRCI" #define CLIENT_HEADER_LEN 410 #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 &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