]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_channel/core_channel.h
Move <security:announceinvites> to core_channel.
[user/henk/code/inspircd.git] / src / coremods / core_channel / core_channel.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
5  *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
6  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
7  *   Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
8  *
9  * This file is part of InspIRCd.  InspIRCd is free software: you can
10  * redistribute it and/or modify it under the terms of the GNU General Public
11  * License as published by the Free Software Foundation, version 2.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21
22
23 #pragma once
24
25 #include "inspircd.h"
26 #include "listmode.h"
27 #include "modules/exemption.h"
28
29 namespace Topic
30 {
31         void ShowTopic(LocalUser* user, Channel* chan);
32 }
33
34 namespace Invite
35 {
36         class APIImpl;
37
38         /** Used to indicate who we announce invites to on a channel. */
39         enum AnnounceState
40         {
41                 /** Don't send invite announcements. */
42                 ANNOUNCE_NONE,
43
44                 /** Send invite announcements to all users. */
45                 ANNOUNCE_ALL,
46
47                 /** Send invite announcements to channel operators and higher. */
48                 ANNOUNCE_OPS,
49
50                 /** Send invite announcements to channel half-operators (if available) and higher. */
51                 ANNOUNCE_DYNAMIC
52         };
53 }
54
55 /** Handle /INVITE.
56  */
57 class CommandInvite : public Command
58 {
59         Invite::APIImpl& invapi;
60
61  public:
62         Invite::AnnounceState announceinvites;
63
64         /** Constructor for invite.
65          */
66         CommandInvite(Module* parent, Invite::APIImpl& invapiimpl);
67
68         /** Handle command.
69          * @param parameters The parameters to the command
70          * @param user The user issuing the command
71          * @return A value from CmdResult to indicate command success or failure.
72          */
73         CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE;
74         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) CXX11_OVERRIDE;
75 };
76
77 /** Handle /JOIN.
78  */
79 class CommandJoin : public SplitCommand
80 {
81  public:
82         /** Constructor for join.
83          */
84         CommandJoin(Module* parent);
85
86         /** Handle command.
87          * @param parameters The parameters to the command
88          * @param user The user issuing the command
89          * @return A value from CmdResult to indicate command success or failure.
90          */
91         CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user) CXX11_OVERRIDE;
92 };
93
94 /** Handle /TOPIC.
95  */
96 class CommandTopic : public SplitCommand
97 {
98         CheckExemption::EventProvider exemptionprov;
99         ChanModeReference secretmode;
100         ChanModeReference topiclockmode;
101
102  public:
103         /** Constructor for topic.
104          */
105         CommandTopic(Module* parent);
106
107         /** Handle command.
108          * @param parameters The parameters to the command
109          * @param user The user issuing the command
110          * @return A value from CmdResult to indicate command success or failure.
111          */
112         CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user) CXX11_OVERRIDE;
113 };
114
115 /** Handle /NAMES.
116  */
117 class CommandNames : public SplitCommand
118 {
119         ChanModeReference secretmode;
120         ChanModeReference privatemode;
121         UserModeReference invisiblemode;
122
123  public:
124         /** Constructor for names.
125          */
126         CommandNames(Module* parent);
127
128         /** Handle command.
129          * @param parameters The parameters to the command
130          * @param user The user issuing the command
131          * @return A value from CmdResult to indicate command success or failure.
132          */
133         CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user) CXX11_OVERRIDE;
134
135         /** Spool the NAMES list for a given channel to the given user
136          * @param user User to spool the NAMES list to
137          * @param chan Channel whose nicklist to send
138          * @param show_invisible True to show invisible (+i) members to the user, false to omit them from the list
139          */
140         void SendNames(LocalUser* user, Channel* chan, bool show_invisible);
141 };
142
143 /** Handle /KICK.
144  */
145 class CommandKick : public Command
146 {
147  public:
148         /** Constructor for kick.
149          */
150         CommandKick(Module* parent);
151
152         /** Handle command.
153          * @param parameters The parameters to the command
154          * @param user The user issuing the command
155          * @return A value from CmdResult to indicate command success or failure.
156          */
157         CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE;
158         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) CXX11_OVERRIDE;
159 };
160
161 /** Channel mode +b
162  */
163 class ModeChannelBan : public ListModeBase
164 {
165  public:
166         ModeChannelBan(Module* Creator)
167                 : ListModeBase(Creator, "ban", 'b', "End of channel ban list", 367, 368, true, "maxbans")
168         {
169         }
170 };
171
172 /** Channel mode +k
173  */
174 class ModeChannelKey : public ParamMode<ModeChannelKey, LocalStringExt>
175 {
176  public:
177         static const std::string::size_type maxkeylen;
178         ModeChannelKey(Module* Creator);
179         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding) CXX11_OVERRIDE;
180         void SerializeParam(Channel* chan, const std::string* key, std::string& out)    ;
181         ModeAction OnSet(User* source, Channel* chan, std::string& param) CXX11_OVERRIDE;
182 };
183
184 /** Channel mode +l
185  */
186 class ModeChannelLimit : public ParamMode<ModeChannelLimit, LocalIntExt>
187 {
188  public:
189         size_t minlimit;
190         ModeChannelLimit(Module* Creator);
191         bool ResolveModeConflict(std::string& their_param, const std::string& our_param, Channel* channel) CXX11_OVERRIDE;
192         void SerializeParam(Channel* chan, intptr_t n, std::string& out);
193         ModeAction OnSet(User* source, Channel* channel, std::string& parameter) CXX11_OVERRIDE;
194 };
195
196 /** Channel mode +o
197  */
198 class ModeChannelOp : public PrefixMode
199 {
200  public:
201         ModeChannelOp(Module* Creator)
202                 : PrefixMode(Creator, "op", 'o', OP_VALUE, '@')
203         {
204                 ranktoset = ranktounset = OP_VALUE;
205         }
206 };
207
208 /** Channel mode +v
209  */
210 class ModeChannelVoice : public PrefixMode
211 {
212  public:
213         ModeChannelVoice(Module* Creator)
214                 : PrefixMode(Creator, "voice", 'v', VOICE_VALUE, '+')
215         {
216                 selfremove = false;
217                 ranktoset = ranktounset = HALFOP_VALUE;
218         }
219 };