author | Xeli |
Fri, 16 Sep 2011 17:36:05 +0200 | |
branch | hedgeroid |
changeset 5828 | 667fb58d7f18 |
parent 5213 | a86768368309 |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
4976 | 3 |
* Copyright (c) 2006-2007 Igor Ulyanov <iulyanov@gmail.com> |
4 |
* Copyright (c) 2007-2011 Andrey Korotaev <unC0Rr@gmail.com> |
|
184 | 5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
|
7 |
* it under the terms of the GNU General Public License as published by |
|
8 |
* the Free Software Foundation; version 2 of the License |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
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 |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
18 |
*/ |
|
19 |
||
20 |
#ifndef _TCPBASE_INCLUDED |
|
21 |
#define _TCPBASE_INCLUDED |
|
22 |
||
23 |
#include <QObject> |
|
24 |
#include <QTcpServer> |
|
25 |
#include <QTcpSocket> |
|
26 |
#include <QByteArray> |
|
27 |
#include <QString> |
|
28 |
#include <QDir> |
|
29 |
#include <QProcess> |
|
389 | 30 |
#include <QPointer> |
184 | 31 |
|
32 |
#include <QImage> |
|
33 |
||
34 |
#define MAXMSGCHARS 255 |
|
35 |
||
36 |
class TCPBase : public QObject |
|
37 |
{ |
|
38 |
Q_OBJECT |
|
389 | 39 |
|
184 | 40 |
public: |
41 |
TCPBase(bool demoMode); |
|
419
fdeed9718e6b
virtual destructors for tcpBase derived classes, readarray clear removed as unneeded
displacer
parents:
389
diff
changeset
|
42 |
virtual ~TCPBase(); |
184 | 43 |
|
44 |
signals: |
|
45 |
void isReadyNow(); |
|
46 |
||
47 |
protected: |
|
291 | 48 |
quint16 ipc_port; |
49 |
||
184 | 50 |
void Start(); |
51 |
||
52 |
QByteArray readbuffer; |
|
53 |
||
54 |
QByteArray toSendBuf; |
|
533 | 55 |
QByteArray demo; |
184 | 56 |
|
57 |
void SendIPC(const QByteArray & buf); |
|
58 |
void RawSendIPC(const QByteArray & buf); |
|
59 |
||
5213
a86768368309
make the associate button use the user's settings for loading demos/saves
nemo
parents:
4976
diff
changeset
|
60 |
virtual QStringList getArguments()=0; |
184 | 61 |
virtual void onClientRead(); |
62 |
virtual void onClientDisconnect(); |
|
63 |
virtual void SendToClientFirst(); |
|
64 |
||
65 |
private: |
|
389 | 66 |
static QPointer<QTcpServer> IPCServer; |
185 | 67 |
|
184 | 68 |
bool m_isDemoMode; |
185 | 69 |
void RealStart(); |
389 | 70 |
QPointer<QTcpSocket> IPCSocket; |
184 | 71 |
|
72 |
private slots: |
|
73 |
void NewConnection(); |
|
74 |
void ClientDisconnect(); |
|
75 |
void ClientRead(); |
|
76 |
void StartProcessError(QProcess::ProcessError error); |
|
77 |
||
78 |
void tcpServerReady(); |
|
79 |
}; |
|
80 |
||
81 |
#endif // _TCPBASE_INCLUDED |