summaryrefslogtreecommitdiffstats
path: root/tschannel.h
blob: a1b385513f7c7c6db9199da537981b808373655b (plain)
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
/*
 * 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 TSCHANNEL_H
#define TSCHANNEL_H

#include "tsheaders.h"

// Libraries
#include <wx/wx.h>

//------------------------------------------------------------------------------
//! Channel flags
//! Unregistered:
#define TS_UNREGISTRED  1
//! Moderated:
#define TS_MODERATE     2
//! Password:
#define TS_PASSWORD     4
//! Hierarchical aka Subchannels:
#define TS_HIERARCHICAL 8
//! Default:
#define TS_DEFAULT     16

//------------------------------------------------------------------------------
//! Channel Codecs
//! CELP 5.2
#define TS_CELP_5_2          0
//! CELP 6.3
#define TS_CELP_6_3          1
//! GSM 14.8
#define TS_GSM_14_8          2
//! GSM 16.4
#define TS_GSM_16_4          3
//! Windows CELP 5.2
#define TS_WINDOWS_CELP_5_2  4
//! Speex 3.4
#define TS_SPEEX_3_4         5
//! Speex 5.2
#define TS_SPEEX_5_2         6
//! Speex 7.2
#define TS_SPEEX_7_2         7
//! Speex 9.3
#define TS_SPEEX_9_3         8
//! Speex 12.3
#define TS_SPEEX_12_3        9
//! Speex 16.3
#define TS_SPEEX_16_3       10
//! Speex 19.5
#define TS_SPEEX_19_5       11
//! Speex 25.9
#define TS_SPEEX_25_9       12

//!no parent channel
#define TS_NO_PARENT        0xffffffff

//! TeamSpeak channel.
/*! TSChanel is used to hold all channel informations.
 *  After calling TSClient::Connect(), you can read
 *  out all the channel attributes. These stepps are
 *  necessary to connect to a server and read all information
 *  out.
 *  - Create a TSServer object,edit and link it to the TSClient object
 *    (For more information see TSClient)
 *  - Call TSClient::Connect()
 *  - Call TSClient::GetChannel() or GetChannels()
 *  - Now the class is filled up with the player information
 */
class TSChannel : public wxObject
{
  DECLARE_CLASS(TSChannel)
  public:

   /*! Default CTor, Initializes the object.
    */
    TSChannel();

   /*! Default DTor.
    */
    ~TSChannel();

   /*! Sets the channel Id.
    *  \param id channel Id.
    *  \return Returns false if fails, check GetLastError for details.
    *  \sa GetLastError()
    */
    bool SetId(wxUint32 const id);

   /*! Sets the channel name.
    *  \param str Channel name.
    *  \return Returns false if fails, check GetLastError for details.
    *  \sa GetLastError()
    */
    bool SetName(wxString const &str);

   /*! Sets the channel topic.
    *  \param str Channel topic.
    *  \return Returns false if fails, check GetLastError for details.
    *  \sa GetLastError()
    */
    bool SetTopic(wxString const &str);

   /*! Sets the channel description.
    *  \param str Channel description.
    *  \return Returns false if fails, check GetLastError for details.
    *  \sa GetLastError()
    */
    bool SetDescription(wxString const &str);

   /*! Sets the channel password.
    *  \param str Channel password.
    *  \return Returns false if fails, check GetLastError for details.
    *  \sa GetLastError()
    */
    bool SetPassword(wxString const &str);

   /*! Sets the channel parent.
    *  \param parent Channel parent.
    *  \return Returns false if fails, check GetLastError for details.
    *  \sa GetLastError()
    */
    bool SetParent(wxUint32 const parent);

   /*! Sets the channel codec.
    *   - CELP 5.2:          0
    *   - CELP 6.3:          1
    *   - GSM 14.8:          2
    *   - GSM 16.4:          3
    *   - Windows CELP 5.2:  4
    *   - Speex 3.4:         5
    *   - Speex 5.2:         6
    *   - Speex 7.2:         7
    *   - Speex 9.3:         8
    *   - Speex 12.3:        9
    *   - Speex 16.3:       10
    *   - Speex 19.5:       11
    *   - Speex 25.9:       12
    *  \param codec Channel codec.
    *  \return Returns false if fails, check GetLastError for details.
    *  \sa GetLastError()
    */
    bool SetCodec(wxUint16 const codec);

   /*! Sets the channel order.
    *  \param order Channel order.
    *  \return Returns false if fails, check GetLastError for details.
    *  \sa GetLastError()
    */
    bool SetOrder(wxUint16 const order);

   /*! Sets the channel flags.
    *  - Unregistered:   1
    *  - Moderated:      2
    *  - Password:       4
    *  - Hierarchical:   8
    *  - Default:        16
    *  \param flags Channel flags.
    *  \return Returns false if fails, check GetLastError for details.
    *  \sa GetLastError()
    */
    bool SetFlags(wxUint16 const flags);

   /*! Sets the channel flags.
    *  - Registered:     R
    *  - Moderated:      M
    *  - Password:       P
    *  - Hierarchical:   S
    *  - Default:        D
    *  \param flags Channel flags.
    *  \return Returns false if fails, check GetLastError for details.
    *  \sa GetLastError()
    */
    bool SetFlags(wxString const &str);

   /*! Sets the channels maximum users count.
    *  \param users Channel maximum users count.
    *  \return Returns false if fails, check GetLastError for details.
    *  \sa GetLastError()
    */
    bool SetMaxUsers(wxUint16 const users);

   /*! Sets the channels users count.
    *  \param users Channel maximum users count.
    *  \return Returns false if fails, check GetLastError for details.
    *  \sa GetLastError()
    */
    bool SetUsers(wxUint16 const users);

   /*! Gets the channel id.
    *  \return Channel Id.
    */
    wxUint32 GetId() const
    {
      return m_Id;
    }

   /*! Gets the channel name.
    *  \return Channel name.
    */
    wxString const &GetName() const
    {
      return m_Name;
    }

   /*! Gets the channel topic.
    *  \return Channel topic.
    */
    wxString const &GetTopic() const
    {
      return m_Topic;
    }

   /*! Gets the channel description.
    *  \return Channel description.
    */
    wxString const &GetDescription() const
    {
      return m_Description;
    }

   /*! Gets the channel password.
    *  \return Channel password.
    */
    wxString const &GetPassword() const
    {
      return m_Password;
    }

   /*! Gets the channel parent.
    *  \return Channel parent.
    */
    wxUint32 GetParent() const
    {
      return m_Parent;
    }

   /*! Gets the channel codec.
    *   - CELP 5.2:          0
    *   - CELP 6.3:          1
    *   - GSM 14.8:          2
    *   - GSM 16.4:          3
    *   - Windows CELP 5.2:  4
    *   - Speex 3.4:         5
    *   - Speex 5.2:         6
    *   - Speex 7.2:         7
    *   - Speex 9.3:         8
    *   - Speex 12.3:        9
    *   - Speex 16.3:       10
    *   - Speex 19.5:       11
    *   - Speex 25.9:       12
    *  \return Channel codec.
    */
    wxUint16 GetCodec() const
    {
      return m_Codec;
    }

   /*! Gets the channel order.
    *  \return Channel order.
    */
    wxUint16 GetOrder() const
    {
      return m_Order;
    }

   /*! Gets the channel flags.
    *  - Unregistered:   1
    *  - Moderated:      2
    *  - Password:       4
    *  - Hierarchical:   8
    *  - Default:        16
    *  \return Channel flags.
    */
    wxUint16 GetFlags() const
    {
      return m_Flags;
    }

   /*! Gets the channel flags.
    *  - Unregistered:   1
    *  - Moderated:      2
    *  - Password:       4
    *  - Hierarchical:   8
    *  - Default:        16
    *  \return Channel flags.
    */
    wxString const GetFlagsString() const
    {
      wxString str;
      if((m_Flags &TS_MODERATE))
        str += _T("M");
      if((m_Flags &TS_DEFAULT))
        str += _T("D");
      if((m_Flags &TS_HIERARCHICAL))
        str += _T("S");
      if((m_Flags &TS_PASSWORD))
        str += _T("P");
      if(!(m_Flags &TS_UNREGISTRED))
        str += _T("R");
      return str;
    }
   /*! Gets the channel max users.
    *  \return Channel max users.
    */
    wxUint16 GetMaxUsers() const
    {
      return m_MaxUsers;
    }

   /*! Gets the channel user count.
    *  \return Channel user count.
    */
    wxUint16 GetUsers() const
    {
      return m_Users;
    }

   /*! Gets the LastError message, call this method
    *  to get more information for an error.
    *  \return LastError message.
    */
    wxString const &GetLastError() const
    {
      return m_LastError;
    }

   /*! Dumps object.
    *  \param ostrm Stream to write.
    */
    void Dump(wxOutputStream &ostrm) const;


  private:

    //Sets the LastError message.
    void SetLastError(wxString const &str)
    {
      m_LastError = str;
    }

    //members
    wxUint32 m_Id;
    wxString m_Name;
    wxString m_Topic;
    wxString m_Description;
    wxString m_Password;
    wxUint32 m_Parent;
    wxUint16 m_Codec;
    wxUint16 m_Order;
    wxUint16 m_Flags;
    wxUint16 m_MaxUsers;
    wxUint16 m_Users;
    wxString m_LastError;
};

#endif