-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChatClient.h
79 lines (72 loc) · 2.81 KB
/
ChatClient.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef CHATCLIENT_H
#define CHATCLIENT_H
#include <QObject>
#include <QTcpSocket>
#include <QMap>
#include "ChatMessages.h"
class ChatClient : public QObject
{
Q_OBJECT
private:
QTcpSocket *m_tcpSocket;
quint16 m_nextBlockSize;
QString m_username;
QString m_password; //password stored in string, kekeke
bool m_userdataAssigned;
bool m_authorized;
void sendMessageToServer(ChatMessageBody *msgBody) const;
void processMessage(const ChannelMessage *msg);
void processMessage(const DisconnectMessage *msg);
void processMessage(const RegistrationAnswer *msg);
void processMessage(const ChannelListMessage *msg);
void processMessage(const ChannelJoinResult *msg);
void processMessage(const ChannelSystemMessage *msg);
void processMessage(const ChannelUserList *msg);
void processMessage(const ChannelCreateResult *msg);
void processMessage(const ChannelThemeChanged *msg);
void processMessage(const ClientStatusChanged *msg);
void processMessage(const UserInfoMessage *msg);
void processMessage(const PasswordChangeResult *msg);
public:
enum ChannelListType
{
listOfJoined,
listOfAll
};
explicit ChatClient(QObject *parent = 0);
void setUserInfo(const QString &un, const QString &pass);
QString username();
bool start(QTcpSocket *socket);
void requestLists();
void shutdown();
signals:
void errorOccured(const QString &);
void channelMsg(QString channel, QString nick, QString msg);
void clientAuthorized();
void displayChannelList(QMap<QString, QString> list, ChatClient::ChannelListType type);
void channelJoinResult(QString channelname, bool result);
void channelSystemMsg(QString channel, QString msg);
void userList(QString channelname, QStringList list);
void channelCreateResult(QString str);
void channelThemeChange(QString channel, QString theme);
void clientStatusChanged(QString username, QString status);
void userInfo(QString username, QString info);
void ownerInfo(QString username, QString info);
void changePasswordResult(QString result);
private slots:
void clientGotNewMessage();
void socketError(const QAbstractSocket::SocketError &error);
public slots:
void sendChannelMessage(const QString &rcvr, const QString &body) const;
void sendDisconnectMessage() const;
void allChannelsRequest();
void joinChannelRequest(QString channelname);
void leaveChannel(QString channelname);
void createChannelRequest(QString name, QString topic, QString description);
void changeChannelTheme(QString channel, QString theme);
void changeStatus(QString status);
void userInfoRequest(QString username);
void sendOwnerProfile(QString username, QString info);
void changePassword(QString oldPass, QString newPass);
};
#endif // CHATCLIENT_H