19 |
19 |
20 #ifndef _TCPBASE_INCLUDED |
20 #ifndef _TCPBASE_INCLUDED |
21 #define _TCPBASE_INCLUDED |
21 #define _TCPBASE_INCLUDED |
22 |
22 |
23 #include <QObject> |
23 #include <QObject> |
24 #include <QTcpServer> |
|
25 #include <QTcpSocket> |
|
26 #include <QByteArray> |
|
27 #include <QString> |
|
28 #include <QDir> |
|
29 #include <QProcess> |
24 #include <QProcess> |
30 #include <QPointer> |
|
31 |
|
32 #include <QImage> |
|
33 |
|
34 #define MAXMSGCHARS 255 |
|
35 |
25 |
36 class TCPBase : public QObject |
26 class TCPBase : public QObject |
37 { |
27 { |
38 Q_OBJECT |
28 Q_OBJECT |
39 |
29 |
40 public: |
30 public: |
41 TCPBase(bool demoMode, QObject * parent = 0); |
31 TCPBase(QObject * parent = 0); |
42 virtual ~TCPBase(); |
32 virtual ~TCPBase(); |
43 |
33 |
44 virtual bool couldBeRemoved(); |
34 virtual bool couldBeRemoved(); |
45 |
35 |
46 signals: |
36 signals: |
47 void isReadyNow(); |
37 void nextPlease(); |
48 |
38 |
49 protected: |
39 protected: |
50 bool m_hasStarted; |
40 bool m_hasStarted; |
51 quint16 ipc_port; |
41 int m_port; |
52 |
42 |
53 void Start(bool couldCancelPreviousRequest); |
43 void start(bool couldCancelPreviousRequest); |
54 |
44 |
55 QByteArray readbuffer; |
45 virtual QStringList getArguments() = 0; |
|
46 virtual void onEngineStart() = 0; |
56 |
47 |
57 QByteArray toSendBuf; |
48 void clientDisconnected(); |
58 QByteArray demo; |
|
59 |
|
60 void SendIPC(const QByteArray & buf); |
|
61 void RawSendIPC(const QByteArray & buf); |
|
62 |
|
63 virtual QStringList getArguments()=0; |
|
64 virtual void onClientRead(); |
|
65 virtual void onClientDisconnect(); |
|
66 virtual void SendToClientFirst(); |
|
67 |
49 |
68 private: |
50 private: |
69 static QPointer<QTcpServer> IPCServer; |
|
70 |
|
71 bool m_isDemoMode; |
|
72 void RealStart(); |
51 void RealStart(); |
73 QPointer<QTcpSocket> IPCSocket; |
|
74 |
52 |
75 private slots: |
53 private slots: |
76 void NewConnection(); |
54 void iStart(); |
77 void ClientDisconnect(); |
|
78 void ClientRead(); |
|
79 void StartProcessError(QProcess::ProcessError error); |
|
80 |
|
81 void tcpServerReady(); |
|
82 }; |
55 }; |
83 |
56 |
84 #endif // _TCPBASE_INCLUDED |
57 #endif // _TCPBASE_INCLUDED |