summaryrefslogtreecommitdiffstats
path: root/tsplayer.cpp
blob: 268adfca3e4515bdde7f3de19acab1ae9d63ba92 (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
/*
 * 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 "tsplayer.h"

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

IMPLEMENT_CLASS(TSPlayer, wxObject)

//------------------------------------------------------------------------------
//Default CTor, Initializes the object.
TSPlayer::TSPlayer()
{
  m_Id = 0;
  m_Flags = 0;
  m_Privileges = 0;
  m_ChannelId = 0;
  m_ChannelPrivileges = 0;
  m_Anonymous = true;
  m_ServerAssingnsNickname = false;
}

//------------------------------------------------------------------------------
//Default DTor.
TSPlayer::~TSPlayer()
{
}

//------------------------------------------------------------------------------
// Sets the player id.
bool TSPlayer::SetId(wxUint32 const id)
{
  m_Id = id;
  return true;
}

//------------------------------------------------------------------------------
// Sets the player channel Id.
bool TSPlayer::SetChannelId(wxUint32 const id)
{
  m_ChannelId = id;
  return true;
}

//------------------------------------------------------------------------------
// Sets the player flags.
bool TSPlayer::SetFlags(wxUint16 const flags)
{
  m_Flags = flags;
  return true;
}

//------------------------------------------------------------------------------
// Sets the player privileges.
bool TSPlayer::SetPrivileges(wxUint16 const privs)
{
  m_Privileges = privs;
  return true;
}

//------------------------------------------------------------------------------
// Sets the channel privileges.
bool TSPlayer::SetChannelPrivileges(wxUint16 const privs)
{
  m_ChannelPrivileges = privs;
  return true;
}

//------------------------------------------------------------------------------
// Sets the player nickname.
bool TSPlayer::SetNickname(wxString const &str)
{
  if(str.Length() == 0)
  {
    SetLastError(_T("empty string"));
    return false;
  }

  m_Nickname = str;
  return true;
}

//------------------------------------------------------------------------------
// Sets the login name.
bool TSPlayer::SetLoginName(wxString const &str)
{
  if(str.Length() == 0)
  {
    m_Anonymous = ANONYMOUS_YES;
    return true;
  }

  m_LoginName = str;
  m_Anonymous = ANONYMOUS_NO;
  return true;
}

//------------------------------------------------------------------------------
// Sets the login password.
bool TSPlayer::SetLoginPassword(wxString const &str)
{
  if(str.Length() == 0)
  {
    SetLastError(_T("empty string"));
    return false;
  }

  m_LoginPassword = str;
  return true;
}

//------------------------------------------------------------------------------
// Sets the default channel.
bool TSPlayer::SetDefaultChannel(wxString const &str)
{
  if(str.Length() == 0)
  {
    SetLastError(_T("empty string"));
    return false;
  }

  m_DefaultChannel = str;
  return true;
}

//------------------------------------------------------------------------------
// Sets the default subchannel.
 bool TSPlayer::SetDefaultSubchannel(wxString const &str)
{
  if(str.Length() == 0)
  {
    SetLastError(_T("empty string"));
    return false;
  }

  m_DefaultSubchannel = str;
  return true;
}

//------------------------------------------------------------------------------
// Sets the default channel password.
bool TSPlayer::SetDefaultChannelPassword(wxString const &str)
{
  if(str.Length() == 0)
  {
    SetLastError(_T("empty string"));
    return false;
  }

  m_DefaultChannelPassword = str;
  return true;
}

//------------------------------------------------------------------------------
// Dumps object.
void TSPlayer::Dump(wxOutputStream &ostrm) const
{
  wxTextOutputStream out(ostrm);
  out << _T("Object: TSPlayer (")                   << wxString::Format(_T("0x%X"), this) << _T(")") << endl;
  out << _T("-wxUint32 m_Id: ")                     << wxString::Format(_T("0x%X"), m_Id) << endl;
  out << _T("-wxUint16 m_Flags: ")                  << wxString::Format(_T("0x%X"), m_Flags) << endl;
  out << _T("-wxUint16 m_Privileges: ")             << wxString::Format(_T("0x%X"), m_Privileges) << endl;
  out << _T("-wxUint32 m_ChannelId: ")              << wxString::Format(_T("0x%X"), m_ChannelId) << endl;
  out << _T("-wxUint16 m_ChannelPrivileges: ")      << wxString::Format(_T("0x%X"), m_ChannelPrivileges) << endl;
  out << _T("-wxString m_Nickname: ")               << m_Nickname << endl;
  out << _T("-wxString m_LoginName: ")              << m_LoginName << endl;
  out << _T("-wxString m_LoginPassword: ")          << m_LoginPassword << endl;
  out << _T("-wxString m_DefaultChannel: ")         << m_DefaultChannel << endl;
  out << _T("-wxString m_DefaultSubchannel: ")      << m_DefaultSubchannel << endl;
  out << _T("-wxString m_DefaultChannelPassword: ") << m_DefaultChannelPassword << endl;
  out << _T("-wxUint8  m_Anonymous: ")              << wxString::Format(_T("0x%X"), m_Anonymous) << endl;
  out << _T("-wxUint8  m_ServerAssingnsNickname: ") << wxString::Format(_T("0x%X"), m_ServerAssingnsNickname) << endl;
  out << _T("-wxString m_LastError: ")              << m_LastError << endl;
}

//------------------------------------------------------------------------------
// Should the server assing a nickname.
bool TSPlayer::SetServerAssingnsNickname(wxUint8 const assing)
{
  m_ServerAssingnsNickname = assing;
  return true;
}