forked from KIJ-D-NANA/Chat-Client-Qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection.h
57 lines (48 loc) · 1.32 KB
/
connection.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
52
53
54
55
56
57
#ifndef CONNECTION_H
#define CONNECTION_H
#include <QObject>
#include <QTcpSocket>
#include <QTimer>
#include <string>
#include <openssl/rsa.h>
#include "rc4algorithm.h"
#include "sha1hash.h"
#include "rsacrpto.h"
#include "rsaalgorithm.h"
class Connection : public QObject
{
Q_OBJECT
public:
explicit Connection(int refreshRate_msec = 1000, QObject *parent = 0);
~Connection();
bool connectToHost(QString IP, quint16 Port, QString Username);
void setServerKeyPair(const char* key, int key_len);
void getPubKey(QString name);
private:
QTimer timer;
SHA1Hash HashEngine;
QTcpSocket* socket;
bool isApplicationRunning;
QString username;
RSACrpto ServKey;
RSACrpto ClientKey;
static constexpr char* alphabet =
"abcdefghijklmnopqrstuvwxyz\
ABCDEFGHIJKLMNOPQRSTUVWXYZ\
0123456789";
RC4Algorithm* rc4;
private:
std::string randomStringGen(size_t LEN);
void SetRC4Key();
void postPubKey();
signals:
public slots:
void incomingMessage();
void checkUserList();
void disconnected();
void outgoingPublicMessage(QString messageContent);
void outgoingPrivateMessage(QString receiver, QString messageContent, RC4Algorithm* ClientRC4Key);
void newPrivateWindow(QObject* privateWindow);
void newSessionHandler(QObject* sender);
};
#endif // CONNECTION_H