Split user list from Channel into ChannelUserList
[clinton/bobotpp.git] / source / User.C
CommitLineData
cb21075d 1// User.C -*- C++ -*-
2// Copyright (c) 1997, 1998 Etienne BERNARD
71cf2688 3// Copyright (C) 2009 Clinton Ebadi
cb21075d 4
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// any later version.
9
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
7b564711 17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18// 02110-1301, USA.
cb21075d 19
cb21075d 20#include "User.H"
21
cfa82921 22#include "UserListItem.H"
23#include "Utils.H"
24
71cf2688 25User::User(String n, String uh, String channel, int mode, UserListItem *uli)
cb21075d 26 : mode(mode), floodNum(0),
71cf2688 27 userListItem(uli),
cb21075d 28 nick(n), userhost(uh),
29 userkey("")
30{ }
31
32User::User(String n, int mode)
33 : mode(mode), floodNum(0),
34 userListItem(0), nick(n), userhost("")
35{ }
36
37int
71cf2688 38User::getLevel() const
cb21075d 39{
40 if (userListItem && userListItem->identified &&
41 (userListItem->expirationDate == -1 ||
42 userListItem->expirationDate > time(0)))
43 return userListItem->level;
44 return 0;
45}
46
47int
71cf2688 48User::getProt() const
cb21075d 49{
50 if (userListItem && userListItem->identified &&
51 (userListItem->expirationDate == -1 ||
52 userListItem->expirationDate > time(0)))
53 return userListItem->prot;
54 return 0;
55}
56
57bool
71cf2688 58User::getAop() const
cb21075d 59{
60 if (userListItem && userListItem->identified &&
61 (userListItem->expirationDate == -1 ||
62 userListItem->expirationDate < time(0)))
63 return userListItem->aop;
64 return false;
65}
71cf2688 66
67bool
68User::operator< (const User &rh) const
69{
70 return Utils::to_lower (nick) < Utils::to_lower (rh.nick);
71}
72
73bool
74User::operator== (const User &rh) const
75{
76 return Utils::to_lower (nick) == Utils::to_lower (rh.nick);
77}