cb21075d |
1 | // Channel.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 |
39b022cb |
17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
cb21075d |
18 | |
19 | #ifndef CHANNEL_H |
20 | #define CHANNEL_H |
21 | |
22 | #include <ctime> |
23 | #include <map> |
24 | #include <vector> |
25 | |
26 | #include "User.H" |
27 | #include "Person.H" |
28 | #include "ServerConnection.H" |
29 | #include "BanEntry.H" |
30 | |
31 | class Bot; |
32 | class Parser; |
33 | class Commands; |
34 | class UserCommands; |
35 | |
36 | #define DEFAULT_KEEPMODES "iklmnpst" |
37 | |
38 | // This struct is used to keep information about |
39 | // the channel we want to join, the modes we |
40 | // want to set/keep on these channels, and the |
41 | // channel keys |
42 | struct wantedChannel { |
43 | String mode; |
44 | String keep; |
45 | String key; |
46 | |
47 | wantedChannel(String m, String kp, String ky) |
48 | : mode(m), keep(kp), key(ky) { } |
49 | }; |
50 | |
51 | class Channel { |
52 | String channelName; |
53 | String channelTopic; |
54 | bool lockedTopic; |
55 | int channelMode; |
56 | int channelLimit; |
57 | String channelKey; |
58 | String keepModes; |
59 | String wantedModes; |
60 | |
61 | int count; |
62 | int countOp; |
63 | bool joined; |
64 | bool doMode; |
65 | bool gotWho; |
66 | std::map<String, User *, std::less<String> > channelMemory; |
67 | std::vector<BanEntry *> channelBanlist; |
68 | ServerConnection * cnx; |
69 | |
70 | public: |
71 | |
72 | enum { |
73 | PRIVATE = 1, // +p |
74 | SECRET = 2, // +s |
75 | INVITE_ONLY = 4, // +i |
76 | TOPIC_RESTRICTED = 8, // +t |
77 | EXTMSG_RESTRICTED = 16, // +n |
78 | MODERATED = 32, // +m |
79 | HAS_KEY = 64, // +k <key> |
80 | IS_LIMITED = 128 // +l <limit> |
81 | }; |
82 | |
83 | Channel(ServerConnection *, String, String); |
84 | ~Channel(); |
85 | |
86 | void addNick(String, String, int, UserList *, bool = false); |
87 | void delNick(String); |
88 | void changeNick(String, String); |
89 | bool hasNick(String); |
90 | User * getUser(String); |
91 | |
92 | void addBan(String, std::time_t = -1); |
93 | void delBan(String); |
94 | |
95 | void parseMode(Person *, String); |
96 | void resynchModes(); |
97 | |
98 | friend class Bot; |
99 | friend class Parser; |
100 | friend class Commands; |
101 | friend class UserCommands; |
102 | }; |
103 | |
104 | #endif |