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
|
/*
* 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)
*/
// Header
#include "tschannel.h"
//Libraries
#include <wx/txtstrm.h>
IMPLEMENT_CLASS(TSChannel, wxObject)
//------------------------------------------------------------------------------
// Default CTor, Initializes the object.
TSChannel::TSChannel()
{
m_Id = 0;
m_Parent = TS_NO_PARENT;
m_Codec = 0;
m_Order = 3200;
m_Flags = 1;
m_MaxUsers = 4;
m_Users = 0;
}
//------------------------------------------------------------------------------
// Default DTor.
TSChannel::~TSChannel()
{
}
//------------------------------------------------------------------------------
// Sets the channel Id.
bool TSChannel::SetId(wxUint32 const id)
{
m_Id = id;
return true;
}
//------------------------------------------------------------------------------
// Sets the channel name.
bool TSChannel::SetName(wxString const &str)
{
if(str.Length() == 0)
{
SetLastError(_T("empty string"));
return false;
}
m_Name = str;
return true;
}
//------------------------------------------------------------------------------
// Sets the channel topic.
bool TSChannel::SetTopic(wxString const &str)
{
m_Topic = str;
return true;
}
//------------------------------------------------------------------------------
// Sets the channel description.
bool TSChannel::SetDescription(wxString const &str)
{
m_Description = str;
return true;
}
//------------------------------------------------------------------------------
// Sets the channel password.
bool TSChannel::SetPassword(wxString const &str)
{
if(str.Length() != 0)
m_Flags |= TS_PASSWORD;
else
m_Flags &= ~TS_PASSWORD;
m_Password = str;
return true;
}
//------------------------------------------------------------------------------
// Sets the channel parent.
bool TSChannel::SetParent(wxUint32 const parent)
{
m_Parent = parent;
return true;
}
//------------------------------------------------------------------------------
// Sets the channel codec.
bool TSChannel::SetCodec(wxUint16 const codec)
{
m_Codec = codec;
return true;
}
//------------------------------------------------------------------------------
// Sets the channel order.
bool TSChannel::SetOrder(wxUint16 const order)
{
m_Order = order;
return true;
}
//------------------------------------------------------------------------------
// Sets the channel flags.
bool TSChannel::SetFlags(wxString const &str)
{
wxUint16 flags = 1;
if(str.Find(wxChar('R')) != wxNOT_FOUND)
flags &= ~TS_UNREGISTRED;
else
flags |= TS_UNREGISTRED;
if(str.Find(wxChar('M')) != wxNOT_FOUND)
flags |= TS_MODERATE;
else
flags &= ~TS_MODERATE;
if(str.Find(wxChar('S')) != wxNOT_FOUND)
flags |= TS_HIERARCHICAL;
else
flags &= ~TS_HIERARCHICAL;
if(str.Find(wxChar('D')) != wxNOT_FOUND)
flags |= TS_DEFAULT;
else
flags &= ~TS_DEFAULT;
if(str.Find(wxChar('P')) != wxNOT_FOUND || m_Password.Length() != 0)
flags |= TS_PASSWORD;
else
flags &= ~TS_PASSWORD;
m_Flags = flags;
return true;
}
//------------------------------------------------------------------------------
// Sets the channel flags.
bool TSChannel::SetFlags(wxUint16 const flags)
{
m_Flags = flags;
return true;
}
//------------------------------------------------------------------------------
// Sets the channels maximum users count.
bool TSChannel::SetMaxUsers(wxUint16 const users)
{
m_MaxUsers = users;
return true;
}
//------------------------------------------------------------------------------
// Sets the channels users count.
bool TSChannel::SetUsers(wxUint16 const users)
{
m_Users = users;
return true;
}
//------------------------------------------------------------------------------
// Dumps object.
void TSChannel::Dump(wxOutputStream &ostrm) const
{
wxTextOutputStream out(ostrm);
out << _T("Object: TSChannel (") << wxString::Format(_T("0x%X"), this) << _T(")") << endl;
out << _T("-wxUint32 m_Id: ") << wxString::Format(_T("0x%X"), m_Id) << endl;
out << _T("-wxString m_Name: ") << m_Name << endl;
out << _T("-wxString m_Topic: ") << m_Topic << endl;
out << _T("-wxString m_Description: ") << m_Description << endl;
out << _T("-wxString m_Password: ") << m_Password << endl;
out << _T("-wxUint32 m_Parent: ") << wxString::Format(_T("0x%X"), m_Parent) << endl;
out << _T("-wxUint16 m_Codec: ") << wxString::Format(_T("0x%X"), m_Codec) << endl;
out << _T("-wxUint16 m_Order: ") << wxString::Format(_T("0x%X"), m_Order) << endl;
out << _T("-wxUint16 m_Flags: ") << wxString::Format(_T("0x%X"), m_Flags) << endl;
out << _T("-wxUint16 m_MaxUsers: ") << wxString::Format(_T("0x%X"), m_MaxUsers) << endl;
out << _T("-wxUint16 m_Users: ") << wxString::Format(_T("0x%X"), m_Users) << endl;
out << _T("-wxString m_LastError: ") << m_LastError << endl;
}
|