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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
|
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors: Manuel Mausz (manuel@mausz.at)
* Christian Raschko (c.raschko@netcore.at)
*/
#ifndef TSCOMMAND_H
#define TSCOMMAND_H
#include "tsheaders.h"
#include <wx/wx.h>
#include <wx/stream.h>
#include <wx/datstrm.h>
#include <wx/mstream.h>
#include <wx/dynarray.h>
//Commands
#define TS_CMD_RECV_UNKNOWN 0xffffffff //!< Recv unknown command
#define TS_CMD_SEND_LOGIN 0x0003bef4 //!< Send user, login
#define TS_CMD_RECV_SERVER 0x0004bef4 //!< Recv server Information
#define TS_CMD_SEND_DEFAULT 0x0005bef0 //!< Send default channel
#define TS_CMD_RECV_CHANNEL 0x0006bef0 //!< Recv channels
#define TS_CMD_RECV_USER 0x0007bef0 //!< Recv users
#define TS_CMD_RECV_ACK 0x0000bef1 //!< Recv acknowledge
#define TS_CMD_SEND_ACK 0xff00bef1 //!< pseudo command, send recv same id
#define TS_CMD_RECV_URL 0x0008bef0 //!< Recv ISP Url
#define TS_CMD_SEND_PING 0x0001bef4 //!< Send ping
#define TS_CMD_RECV_PING 0x0002bef4 //!< Recv ping
#define TS_CMD_SEND_LOGOUT 0x012cbef0 //!< Send logout user
#define TS_CMD_RECV_LOGOUT 0x0065bef0 //!< Recv logout information
#define TS_CMD_RECV_ADD_PLAYER 0x0064bef0 //!< Recv player login
#define TS_CMD_RECV_PLAYER_FLAGS 0x0068bef0 //!< Recv player flags
#define TS_CMD_RECV_ADD_CHANNEL 0x006ebef0 //!< Recv add channel
#define TS_CMD_RECV_MOVE_PLAYER 0x0067bef0 //!< Recv move player
#define TS_CMD_RECV_MOVE_PLAYER2 0x006dbef0 //!< Recv move player
#define TS_CMD_RECV_DEL_CHANNEL 0x0073bef0 //!< Recv delete channel
#define TS_CMD_RECV_SERVER_UPDATE 0x008cbef0 //!< Recv update server
#define TS_CMD_SEND_ADD_CHANNEL 0x00c9bef0 //!< Send create channel
#define TS_CMD_SEND_DEL_CHANNEL 0x00d1bef0 //!< Send delete channel
#define TS_CMD_SEND_MOVE_PLAYER 0x014abef0 //!< Send move player
#define TS_CMD_SEND_KICK_PLAYER 0x012dbef0 //!< Send kick player
#define TS_CMD_SEND_SET_CHANNEL_PASSWORD 0x00cbbef0 //!< Send change channel
#define TS_CMD_SEND_SET_CHANNEL_NAME 0x00cebef0 //!< Send change channel
#define TS_CMD_SEND_SET_CHANNEL_TOPIC 0x00cfbef0 //!< Send change channel
#define TS_CMD_SEND_SET_CHANNEL_DESCRIPTION 0x00d0bef0 //!< Send change channel
#define TS_CMD_SEND_SET_CHANNEL_MAXPLAYERS 0x00d2bef0 //!< Send change channel
#define TS_CMD_SEND_SET_CHANNEL_FLAGSCODEC 0x00cdbef0 //!< Send change channel
#define TS_CMD_SEND_SET_CHANNEL_ORDER 0x00d4bef0 //!< Send change channel
#define TS_CMD_RECV_SET_CHANNEL_NAME 0x006fbef0 //!< Recv change channel
#define TS_CMD_RECV_SET_CHANNEL_TOPIC 0x0070bef0 //!< Recv change channel
#define TS_CMD_RECV_SET_CHANNEL_DESCRIPTION 0x0072bef0 //!< Recv change channel
#define TS_CMD_RECV_SET_CHANNEL_MAXPLAYERS 0x0074bef0 //!< Recv change channel
#define TS_CMD_RECV_SET_CHANNEL_FLAGSCODEC 0x0071bef0 //!< Recv change channel
#define TS_CMD_RECV_SET_CHANNEL_ORDER 0x0075bef0 //!< Recv change channel
#define TS_CMD_RECV_CHANNEL_PASSWORD_CHANGED 0x00ccbef0 //!< Recv channel password changed
//------------------------------------------------------------------------------
//! ABC TeamSpeak command.
/*! Abstract base class for processing commands
*/
class TSCommand : public wxObject
{
DECLARE_CLASS(TSCommand)
public:
/*! CTor
*/
TSCommand(wxUint32 const &id) : m_Id(id)
{
}
/*! DTor
*/
virtual ~TSCommand()
{
}
/*! Check if this is the right class.
* \param id Command id.
* \return True if successful.
*/
virtual bool IsCommand(wxUint32 const &id)
{
if(m_Id == id) return true;
else return false;
}
/*! Precess a command.
* \param istrm Input stream.
* \param ostrm Output stream.
* \param cmd TSCmd object.
* \return True if successful.
*/
virtual bool ProcessCommand(wxInputStream &istrm,
wxOutputStream &ostrm,
TSCmd *cmd) = 0;
/*! Gets the LastError message, call this method
* to get more information for an error.
* \return LastError message.
*/
wxString const &GetLastError() const
{
return m_LastError;
}
/*! Get command id.
* \return Command id.
*/
wxUint32 GetId() const
{
return m_Id;
}
protected:
//Sets the LastError message.
void SetLastError(wxString const &str)
{
m_LastError = str;
}
const wxUint32 m_Id;
wxString m_LastError;
//class variable
static wxUint32 m_Cnt;
};
//------------------------------------------------------------------------------
//! TSCmdSendUser
class TSCmdSendLogin : public TSCommand
{
public:
TSCmdSendLogin():TSCommand(TS_CMD_SEND_LOGIN){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvServer
class TSCmdRecvServer : public TSCommand
{
public:
TSCmdRecvServer():TSCommand(TS_CMD_RECV_SERVER){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendDefault
class TSCmdSendDefault : public TSCommand
{
public:
TSCmdSendDefault():TSCommand(TS_CMD_SEND_DEFAULT){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvChannel
class TSCmdRecvChannel : public TSCommand
{
public:
TSCmdRecvChannel():TSCommand(TS_CMD_RECV_CHANNEL){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvUser
class TSCmdRecvUser : public TSCommand
{
public:
TSCmdRecvUser():TSCommand(TS_CMD_RECV_USER){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendAck
class TSCmdSendAck : public TSCommand
{
public:
TSCmdSendAck():TSCommand(TS_CMD_SEND_ACK){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvAck
class TSCmdRecvAck : public TSCommand
{
public:
TSCmdRecvAck():TSCommand(TS_CMD_RECV_ACK){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvUrl
class TSCmdRecvUrl : public TSCommand
{
public:
TSCmdRecvUrl():TSCommand(TS_CMD_RECV_URL){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendPing
class TSCmdSendPing : public TSCommand
{
public:
TSCmdSendPing():TSCommand(TS_CMD_SEND_PING){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvPing
class TSCmdRecvPing : public TSCommand
{
public:
TSCmdRecvPing():TSCommand(TS_CMD_RECV_PING){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendLogout
class TSCmdSendLogout : public TSCommand
{
public:
TSCmdSendLogout():TSCommand(TS_CMD_SEND_LOGOUT){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvLogoutInfo
class TSCmdRecvLogout : public TSCommand
{
public:
TSCmdRecvLogout():TSCommand(TS_CMD_RECV_LOGOUT){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvAddPlayer
class TSCmdRecvAddPlayer : public TSCommand
{
public:
TSCmdRecvAddPlayer():TSCommand(TS_CMD_RECV_ADD_PLAYER){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvPlayerFlags
class TSCmdRecvPlayerFlags : public TSCommand
{
public:
TSCmdRecvPlayerFlags():TSCommand(TS_CMD_RECV_PLAYER_FLAGS){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvAddChannel
class TSCmdRecvAddChannel : public TSCommand
{
public:
TSCmdRecvAddChannel():TSCommand(TS_CMD_RECV_ADD_CHANNEL){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvMovePlayer
class TSCmdRecvMovePlayer : public TSCommand
{
public:
TSCmdRecvMovePlayer():TSCommand(TS_CMD_RECV_MOVE_PLAYER){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvMovePlayer
class TSCmdRecvMovePlayer2 : public TSCommand
{
public:
TSCmdRecvMovePlayer2():TSCommand(TS_CMD_RECV_MOVE_PLAYER2){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvDelChannel
class TSCmdRecvDelChannel : public TSCommand
{
public:
TSCmdRecvDelChannel():TSCommand(TS_CMD_RECV_DEL_CHANNEL){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvServerUpdate
class TSCmdRecvServerUpdate : public TSCommand
{
public:
TSCmdRecvServerUpdate():TSCommand(TS_CMD_RECV_SERVER_UPDATE){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendAddChannel
class TSCmdSendAddChannel : public TSCommand
{
public:
TSCmdSendAddChannel():TSCommand(TS_CMD_SEND_ADD_CHANNEL){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendDelChannel
class TSCmdSendDelChannel : public TSCommand
{
public:
TSCmdSendDelChannel():TSCommand(TS_CMD_SEND_DEL_CHANNEL){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendMovePlayer
class TSCmdSendMovePlayer : public TSCommand
{
public:
TSCmdSendMovePlayer():TSCommand(TS_CMD_SEND_MOVE_PLAYER){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendSetChannelPassword
class TSCmdSendSetChannelPassword : public TSCommand
{
public:
TSCmdSendSetChannelPassword():TSCommand(TS_CMD_SEND_SET_CHANNEL_PASSWORD){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendSetChannelName
class TSCmdSendSetChannelName : public TSCommand
{
public:
TSCmdSendSetChannelName():TSCommand(TS_CMD_SEND_SET_CHANNEL_NAME){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendSetChannelTopic
class TSCmdSendSetChannelTopic : public TSCommand
{
public:
TSCmdSendSetChannelTopic():TSCommand(TS_CMD_SEND_SET_CHANNEL_TOPIC){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendSetChannelDescription
class TSCmdSendSetChannelDescription : public TSCommand
{
public:
TSCmdSendSetChannelDescription():TSCommand(TS_CMD_SEND_SET_CHANNEL_DESCRIPTION){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendSetChannelMaxPlayers
class TSCmdSendSetChannelMaxPlayers : public TSCommand
{
public:
TSCmdSendSetChannelMaxPlayers():TSCommand(TS_CMD_SEND_SET_CHANNEL_MAXPLAYERS){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendSetChannelFlagsCodec
class TSCmdSendSetChannelFlagsCodec : public TSCommand
{
public:
TSCmdSendSetChannelFlagsCodec():TSCommand(TS_CMD_SEND_SET_CHANNEL_FLAGSCODEC){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendSetChannelOrder
class TSCmdSendSetChannelOrder : public TSCommand
{
public:
TSCmdSendSetChannelOrder():TSCommand(TS_CMD_SEND_SET_CHANNEL_ORDER){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvSetChannelName
class TSCmdRecvSetChannelName : public TSCommand
{
public:
TSCmdRecvSetChannelName():TSCommand(TS_CMD_RECV_SET_CHANNEL_NAME){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvSetChannelTopic
class TSCmdRecvSetChannelTopic : public TSCommand
{
public:
TSCmdRecvSetChannelTopic():TSCommand(TS_CMD_RECV_SET_CHANNEL_TOPIC){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvSetChannelDescription
class TSCmdRecvSetChannelDescription : public TSCommand
{
public:
TSCmdRecvSetChannelDescription():TSCommand(TS_CMD_RECV_SET_CHANNEL_DESCRIPTION){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvSetChannelMaxPlayers
class TSCmdRecvSetChannelMaxPlayers : public TSCommand
{
public:
TSCmdRecvSetChannelMaxPlayers():TSCommand(TS_CMD_RECV_SET_CHANNEL_MAXPLAYERS){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvSetChannelFlagsCodec
class TSCmdRecvSetChannelFlagsCodec : public TSCommand
{
public:
TSCmdRecvSetChannelFlagsCodec():TSCommand(TS_CMD_RECV_SET_CHANNEL_FLAGSCODEC){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvSetChannelOrder
class TSCmdRecvSetChannelOrder : public TSCommand
{
public:
TSCmdRecvSetChannelOrder():TSCommand(TS_CMD_RECV_SET_CHANNEL_ORDER){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdSendKickPlayer
class TSCmdSendKickPlayer : public TSCommand
{
public:
TSCmdSendKickPlayer():TSCommand(TS_CMD_SEND_KICK_PLAYER){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvChannelPasswordChanged
class TSCmdRecvChannelPasswordChanged : public TSCommand
{
public:
TSCmdRecvChannelPasswordChanged():TSCommand(TS_CMD_RECV_CHANNEL_PASSWORD_CHANGED){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
//------------------------------------------------------------------------------
//! TSCmdRecvUnknown
class TSCmdRecvUnknown : public TSCommand
{
public:
TSCmdRecvUnknown():TSCommand(TS_CMD_RECV_UNKNOWN){}
//! See baseclass TSCommand for description.
virtual bool ProcessCommand(wxInputStream &istrm, wxOutputStream &ostrm, TSCmd *cmd);
};
#endif
|