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