[project @ 2002-08-06 20:48:44 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;
29class Utils;
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
73 friend class User;
74 friend class Utils;
75 friend class Parser;
76 friend class Channel;
77 friend class UserList;
78 friend class Commands;
79 friend class UserCommands;
80};
81
82#endif