summaryrefslogtreecommitdiffstats
path: root/tschannel.cpp
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2013-03-05 17:39:48 +0100
committermanuel <manuel@mausz.at>2013-03-05 17:39:48 +0100
commit310a2c101b32a5e71a616027b6a1b788a341bc02 (patch)
treea871e1dda8b1de141ae1400ba666fe3b1de96361 /tschannel.cpp
downloadtsclient-310a2c101b32a5e71a616027b6a1b788a341bc02.tar.gz
tsclient-310a2c101b32a5e71a616027b6a1b788a341bc02.tar.bz2
tsclient-310a2c101b32a5e71a616027b6a1b788a341bc02.zip
initial GPLv2 releaseHEADmaster
Diffstat (limited to 'tschannel.cpp')
-rw-r--r--tschannel.cpp199
1 files changed, 199 insertions, 0 deletions
diff --git a/tschannel.cpp b/tschannel.cpp
new file mode 100644
index 0000000..d5530d1
--- /dev/null
+++ b/tschannel.cpp
@@ -0,0 +1,199 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; version 2 of the License.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
14 *
15 * Authors: Manuel Mausz (manuel@mausz.at)
16 * Christian Raschko (c.raschko@netcore.at)
17 */
18
19// Header
20#include "tschannel.h"
21
22//Libraries
23#include <wx/txtstrm.h>
24
25IMPLEMENT_CLASS(TSChannel, wxObject)
26
27//------------------------------------------------------------------------------
28// Default CTor, Initializes the object.
29TSChannel::TSChannel()
30{
31 m_Id = 0;
32 m_Parent = TS_NO_PARENT;
33 m_Codec = 0;
34 m_Order = 3200;
35 m_Flags = 1;
36 m_MaxUsers = 4;
37 m_Users = 0;
38}
39
40//------------------------------------------------------------------------------
41// Default DTor.
42TSChannel::~TSChannel()
43{
44}
45
46//------------------------------------------------------------------------------
47// Sets the channel Id.
48bool TSChannel::SetId(wxUint32 const id)
49{
50 m_Id = id;
51 return true;
52}
53
54//------------------------------------------------------------------------------
55// Sets the channel name.
56bool TSChannel::SetName(wxString const &str)
57{
58 if(str.Length() == 0)
59 {
60 SetLastError(_T("empty string"));
61 return false;
62 }
63
64 m_Name = str;
65 return true;
66}
67
68//------------------------------------------------------------------------------
69// Sets the channel topic.
70bool TSChannel::SetTopic(wxString const &str)
71{
72 m_Topic = str;
73 return true;
74}
75
76//------------------------------------------------------------------------------
77// Sets the channel description.
78bool TSChannel::SetDescription(wxString const &str)
79{
80 m_Description = str;
81 return true;
82}
83
84//------------------------------------------------------------------------------
85// Sets the channel password.
86bool TSChannel::SetPassword(wxString const &str)
87{
88 if(str.Length() != 0)
89 m_Flags |= TS_PASSWORD;
90 else
91 m_Flags &= ~TS_PASSWORD;
92
93 m_Password = str;
94 return true;
95}
96
97//------------------------------------------------------------------------------
98// Sets the channel parent.
99bool TSChannel::SetParent(wxUint32 const parent)
100{
101 m_Parent = parent;
102 return true;
103}
104
105//------------------------------------------------------------------------------
106// Sets the channel codec.
107bool TSChannel::SetCodec(wxUint16 const codec)
108{
109 m_Codec = codec;
110 return true;
111}
112
113//------------------------------------------------------------------------------
114// Sets the channel order.
115bool TSChannel::SetOrder(wxUint16 const order)
116{
117 m_Order = order;
118 return true;
119}
120
121//------------------------------------------------------------------------------
122// Sets the channel flags.
123bool TSChannel::SetFlags(wxString const &str)
124{
125 wxUint16 flags = 1;
126
127 if(str.Find(wxChar('R')) != wxNOT_FOUND)
128 flags &= ~TS_UNREGISTRED;
129 else
130 flags |= TS_UNREGISTRED;
131
132 if(str.Find(wxChar('M')) != wxNOT_FOUND)
133 flags |= TS_MODERATE;
134 else
135 flags &= ~TS_MODERATE;
136
137 if(str.Find(wxChar('S')) != wxNOT_FOUND)
138 flags |= TS_HIERARCHICAL;
139 else
140 flags &= ~TS_HIERARCHICAL;
141
142 if(str.Find(wxChar('D')) != wxNOT_FOUND)
143 flags |= TS_DEFAULT;
144 else
145 flags &= ~TS_DEFAULT;
146
147 if(str.Find(wxChar('P')) != wxNOT_FOUND || m_Password.Length() != 0)
148 flags |= TS_PASSWORD;
149 else
150 flags &= ~TS_PASSWORD;
151
152 m_Flags = flags;
153 return true;
154}
155
156//------------------------------------------------------------------------------
157// Sets the channel flags.
158bool TSChannel::SetFlags(wxUint16 const flags)
159{
160 m_Flags = flags;
161 return true;
162}
163
164//------------------------------------------------------------------------------
165// Sets the channels maximum users count.
166bool TSChannel::SetMaxUsers(wxUint16 const users)
167{
168 m_MaxUsers = users;
169 return true;
170}
171
172//------------------------------------------------------------------------------
173// Sets the channels users count.
174bool TSChannel::SetUsers(wxUint16 const users)
175{
176 m_Users = users;
177 return true;
178}
179
180//------------------------------------------------------------------------------
181// Dumps object.
182void TSChannel::Dump(wxOutputStream &ostrm) const
183{
184 wxTextOutputStream out(ostrm);
185 out << _T("Object: TSChannel (") << wxString::Format(_T("0x%X"), this) << _T(")") << endl;
186 out << _T("-wxUint32 m_Id: ") << wxString::Format(_T("0x%X"), m_Id) << endl;
187 out << _T("-wxString m_Name: ") << m_Name << endl;
188 out << _T("-wxString m_Topic: ") << m_Topic << endl;
189 out << _T("-wxString m_Description: ") << m_Description << endl;
190 out << _T("-wxString m_Password: ") << m_Password << endl;
191 out << _T("-wxUint32 m_Parent: ") << wxString::Format(_T("0x%X"), m_Parent) << endl;
192 out << _T("-wxUint16 m_Codec: ") << wxString::Format(_T("0x%X"), m_Codec) << endl;
193 out << _T("-wxUint16 m_Order: ") << wxString::Format(_T("0x%X"), m_Order) << endl;
194 out << _T("-wxUint16 m_Flags: ") << wxString::Format(_T("0x%X"), m_Flags) << endl;
195 out << _T("-wxUint16 m_MaxUsers: ") << wxString::Format(_T("0x%X"), m_MaxUsers) << endl;
196 out << _T("-wxUint16 m_Users: ") << wxString::Format(_T("0x%X"), m_Users) << endl;
197 out << _T("-wxString m_LastError: ") << m_LastError << endl;
198}
199