[project @ 2005-06-23 06:43:12 by unknown_lamer]
[clinton/bobotpp.git] / source / UserListItem.H
CommitLineData
cb21075d 1// UserListItem.H -*- C++ -*-
2// Copyright (c) 1997, 1998 Etienne BERNARD
3// Copyright (c) 2002 Clinton Ebadi
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
17// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18
19// An UserListItem object is the object that is stored in the UserList.
20
21#ifndef USERLISTITEM_H
22#define USERLISTITEM_H
23
24#include <ctime>
25
26#include "Mask.H"
27
28class User;
cb21075d 29class UserList;
30class Commands;
31class UserCommands;
32
33class UserListItem {
34 // Mask on the user
35 Mask mask;
36 // Mask on the channel
37 Mask channelMask;
38 // Level (from 0 to 4)
39 int level;
40 // Protection (from 0 to 2)
41 int prot;
42 // Auto-op
43 bool aop;
44 // Date until which the UserListItem is valid
45 time_t expirationDate;
46 // Password
47 String passwd;
48 // How many channels are we identified on ?
49 int identified;
50 // Is this item automatically added ?
51 bool autoEntry;
52
53public:
54 UserListItem(String m, String mc, int l, int p, bool a,
55 std::time_t e = -1, String pass= "", bool ae = false)
56 : mask(m), channelMask(mc), level(l), prot(p), aop(a),
57 expirationDate(e), passwd(pass), identified(0), autoEntry(ae) { }
58
59 // Returns true if it matches <m> on channel(s) <mc>
60 bool matches(String m, String mc)
61 { if (mc.length()==0) return mask.matches(m);
62 else return mask.matches(m) && channelMask.matches(mc); }
63
64 // Returns true if it matches <m>
65 bool matches(String m)
66 { return mask.matches(m); }
67
68 // Is the item still valid ? (-1 means infinity)
69 bool isStillValid()
70 { return expirationDate == -1 || std::time(NULL) <= expirationDate; }
71
cb21075d 72 friend class Parser;
73 friend class Channel;
f2b83452 74 friend class User;
cb21075d 75 friend class UserList;
76 friend class Commands;
77 friend class UserCommands;
78};
79
80#endif