41 class HWNewNet : public QObject |
41 class HWNewNet : public QObject |
42 { |
42 { |
43 Q_OBJECT |
43 Q_OBJECT |
44 |
44 |
45 public: |
45 public: |
46 enum ClientState { Disconnected, Connecting, Connected, InLobby, InRoom, InGame }; |
46 enum ClientState { Disconnected, Connecting, Redirected, Connected, InLobby, InRoom, InGame, InDemo }; |
47 |
47 |
48 HWNewNet(); |
48 HWNewNet(); |
49 ~HWNewNet(); |
49 ~HWNewNet(); |
50 void Connect(const QString & hostName, quint16 port, const QString & nick); |
50 void Connect(const QString & hostName, quint16 port, bool useTls, const QString & nick); |
|
51 void ContinueConnection(); |
51 void Disconnect(); |
52 void Disconnect(); |
52 void SendPasswordHash(const QString & hash); |
53 void SendPasswordHash(const QString & hash); |
53 void NewNick(const QString & nick); |
54 void NewNick(const QString & nick); |
54 bool isRoomChief(); |
55 bool isRoomChief(); |
55 bool isInRoom(); |
56 bool isInRoom(); |
66 private: |
67 private: |
67 bool isChief; |
68 bool isChief; |
68 QString mynick; |
69 QString mynick; |
69 QString myroom; |
70 QString myroom; |
70 QString myhost; |
71 QString myhost; |
71 QTcpSocket NetSocket; |
72 QSslSocket NetSocket; |
72 QString seed; |
73 QString seed; |
73 bool m_game_connected; |
74 bool m_game_connected; |
74 bool m_nick_registered; |
75 bool m_nick_registered; |
|
76 bool m_demo_data_pending; |
75 RoomsListModel * m_roomsListModel; |
77 RoomsListModel * m_roomsListModel; |
76 PlayersListModel * m_playersModel; |
78 PlayersListModel * m_playersModel; |
77 QSortFilterProxyModel * m_lobbyPlayersModel; |
79 QSortFilterProxyModel * m_lobbyPlayersModel; |
78 QSortFilterProxyModel * m_roomPlayersModel; |
80 QSortFilterProxyModel * m_roomPlayersModel; |
79 QString m_lastRoom; |
81 QString m_lastRoom; |
85 QStringList cmdbuf; |
87 QStringList cmdbuf; |
86 |
88 |
87 int ByteLength(const QString & str); |
89 int ByteLength(const QString & str); |
88 void RawSendNet(const QString & buf); |
90 void RawSendNet(const QString & buf); |
89 void RawSendNet(const QByteArray & buf); |
91 void RawSendNet(const QByteArray & buf); |
90 void ParseCmd(const QStringList & lst); |
92 void ParseCmd(const QStringList & lst); |
91 void handleNotice(int n); |
93 void handleNotice(int n); |
92 |
94 |
93 void maybeSendPassword(); |
95 void maybeSendPassword(); |
94 |
96 |
95 ClientState netClientState; |
97 ClientState netClientState; |
96 |
98 |
97 signals: |
99 signals: |
98 void AskForRunGame(); |
100 void AskForRunGame(); |
|
101 void AskForOfficialServerDemo(); |
99 void connected(); |
102 void connected(); |
100 void disconnected(const QString & reason); |
103 void disconnected(const QString & reason); |
|
104 void redirected(quint16 port); |
101 void Error(const QString & errmsg); |
105 void Error(const QString & errmsg); |
102 void Warning(const QString & wrnmsg); |
106 void Warning(const QString & wrnmsg); |
103 void NickRegistered(const QString & nick); |
107 void NickRegistered(const QString & nick); |
104 void NickNotRegistered(const QString & nick); |
108 void NickNotRegistered(const QString & nick); |
105 void NickTaken(const QString & nick); |
109 void NickTaken(const QString & nick); |