equal
deleted
inserted
replaced
15 * You should have received a copy of the GNU General Public License |
15 * You should have received a copy of the GNU General Public License |
16 * along with this program; if not, write to the Free Software |
16 * along with this program; if not, write to the Free Software |
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
18 */ |
18 */ |
19 |
19 |
20 #include <QMessageBox> |
|
21 #include <QDebug> |
20 #include <QDebug> |
22 |
21 |
23 #include "hwconsts.h" |
22 #include "hwconsts.h" |
24 #include "newnetclient.h" |
23 #include "newnetclient.h" |
25 #include "proto.h" |
24 #include "proto.h" |
47 } |
46 } |
48 |
47 |
49 HWNewNet::~HWNewNet() |
48 HWNewNet::~HWNewNet() |
50 { |
49 { |
51 if (m_game_connected) |
50 if (m_game_connected) |
|
51 { |
52 RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit")); |
52 RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit")); |
|
53 emit Disconnected(); |
|
54 } |
53 NetSocket.flush(); |
55 NetSocket.flush(); |
54 } |
56 } |
55 |
57 |
56 void HWNewNet::Connect(const QString & hostName, quint16 port, const QString & nick) |
58 void HWNewNet::Connect(const QString & hostName, quint16 port, const QString & nick) |
57 { |
59 { |
62 void HWNewNet::Disconnect() |
64 void HWNewNet::Disconnect() |
63 { |
65 { |
64 if (m_game_connected) |
66 if (m_game_connected) |
65 RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit")); |
67 RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit")); |
66 m_game_connected = false; |
68 m_game_connected = false; |
|
69 |
67 NetSocket.disconnectFromHost(); |
70 NetSocket.disconnectFromHost(); |
68 } |
71 } |
69 |
72 |
70 void HWNewNet::CreateRoom(const QString & room) |
73 void HWNewNet::CreateRoom(const QString & room) |
71 { |
74 { |
170 m_game_connected = false; |
173 m_game_connected = false; |
171 } |
174 } |
172 |
175 |
173 void HWNewNet::displayError(QAbstractSocket::SocketError socketError) |
176 void HWNewNet::displayError(QAbstractSocket::SocketError socketError) |
174 { |
177 { |
|
178 emit Disconnected(); |
|
179 |
175 switch (socketError) { |
180 switch (socketError) { |
176 case QAbstractSocket::RemoteHostClosedError: |
181 case QAbstractSocket::RemoteHostClosedError: |
177 break; |
182 break; |
178 case QAbstractSocket::HostNotFoundError: |
183 case QAbstractSocket::HostNotFoundError: |
179 QMessageBox::information(0, tr("Error"), |
184 emit showMessage(tr("The host was not found. Please check the host name and port settings.")); |
180 tr("The host was not found. Please check the host name and port settings.")); |
|
181 break; |
185 break; |
182 case QAbstractSocket::ConnectionRefusedError: |
186 case QAbstractSocket::ConnectionRefusedError: |
183 QMessageBox::information(0, tr("Error"), |
187 emit showMessage(tr("Connection refused")); |
184 tr("Connection refused")); |
|
185 break; |
188 break; |
186 default: |
189 default: |
187 QMessageBox::information(0, tr("Error"), |
190 emit showMessage(NetSocket.errorString()); |
188 NetSocket.errorString()); |
|
189 } |
191 } |
190 } |
192 } |
191 |
193 |
192 void HWNewNet::ParseCmd(const QStringList & lst) |
194 void HWNewNet::ParseCmd(const QStringList & lst) |
193 { |
195 { |