-
Notifications
You must be signed in to change notification settings - Fork 7
/
abstractedsocket.h
executable file
·51 lines (38 loc) · 1.09 KB
/
abstractedsocket.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef ABSTRACTEDSOCKET_H
#define ABSTRACTEDSOCKET_H
#include <QIODevice>
#include <QEventLoop>
#include <QTimer>
const int JAVA_INT_MAX_VAL = 2147483647;
class AbstractedSocket : public QObject
{
Q_OBJECT
public:
AbstractedSocket(QIODevice *socket, bool bluetooth);
~AbstractedSocket();
void initSession(long iv, QByteArray passHash);
QByteArray getSessionHash();
bool waitForBytesWritten(qint64 ms);
bool waitForReadyRead(qint64 ms);
bool writeDataUnencrypted(QByteArray data);
bool writeDataEncrypted(QByteArray data);
QByteArray readDataUnencrypted();
QByteArray readDataEncrypted();
bool writeString(QString str, bool encrypt);
QString readString(bool decrypt);
void closeSocket();
private:
bool readAllData(QByteArray *data);
bool writeAllData(QByteArray data);
QIODevice *socket;
bool socketIsBluetooth;
long sessionIV;
QByteArray sessionPasswordHash;
QEventLoop eventLoop;
QTimer timeoutTimer;
public slots:
void timeout();
void readyRead();
void bytesWritten();
};
#endif // ABSTRACTEDSOCKET_H