]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_channel/core_channel.h
Merge branch 'insp20' into insp3.
[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(User* user, const Params& parameters) CXX11_OVERRIDE;
74         RouteDescriptor GetRouting(User* user, const Params& 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(LocalUser* user, const Params& parameters) 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(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
113 };
114
115 /** Handle /NAMES.
116  */
117 class CommandNames : public SplitCommand
118 {
119  private:
120         ChanModeReference secretmode;
121         ChanModeReference privatemode;
122         UserModeReference invisiblemode;
123         Events::ModuleEventProvider namesevprov;
124
125  public:
126         /** Constructor for names.
127          */
128         CommandNames(Module* parent);
129
130         /** Handle command.
131          * @param parameters The parameters to the command
132          * @param user The user issuing the command
133          * @return A value from CmdResult to indicate command success or failure.
134          */
135         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE;
136
137         /** Spool the NAMES list for a given channel to the given user
138          * @param user User to spool the NAMES list to
139          * @param chan Channel whose nicklist to send
140          * @param show_invisible True to show invisible (+i) members to the user, false to omit them from the list
141          */
142         void SendNames(LocalUser* user, Channel* chan, bool show_invisible);
143 };
144
145 /** Handle /KICK.
146  */
147 class CommandKick : public Command
148 {
149  public:
150         /** Constructor for kick.
151          */
152         CommandKick(Module* parent);
153
154         /** Handle command.
155          * @param parameters The parameters to the command
156          * @param user The user issuing the command
157          * @return A value from CmdResult to indicate command success or failure.
158          */
159         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
160         RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE;
161 };
162
163 /** Channel mode +b
164  */
165 class ModeChannelBan : public ListModeBase
166 {
167  public:
168         ModeChannelBan(Module* Creator)
169                 : ListModeBase(Creator, "ban", 'b', "End of channel ban list", 367, 368, true)
170         {
171         }
172 };
173
174 /** Channel mode +k
175  */
176 class ModeChannelKey : public ParamMode<ModeChannelKey, LocalStringExt>
177 {
178  public:
179         static const std::string::size_type maxkeylen;
180         ModeChannelKey(Module* Creator);
181         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding) CXX11_OVERRIDE;
182         void SerializeParam(Channel* chan, const std::string* key, std::string& out)    ;
183         ModeAction OnSet(User* source, Channel* chan, std::string& param) CXX11_OVERRIDE;
184         bool IsParameterSecret() CXX11_OVERRIDE;
185 };
186
187 /** Channel mode +l
188  */
189 class ModeChannelLimit : public ParamMode<ModeChannelLimit, LocalIntExt>
190 {
191  public:
192         size_t minlimit;
193         ModeChannelLimit(Module* Creator);
194         bool ResolveModeConflict(std::string& their_param, const std::string& our_param, Channel* channel) CXX11_OVERRIDE;
195         void SerializeParam(Channel* chan, intptr_t n, std::string& out);
196         ModeAction OnSet(User* source, Channel* channel, std::string& parameter) CXX11_OVERRIDE;
197 };
198
199 /** Channel mode +o
200  */
201 class ModeChannelOp : public PrefixMode
202 {
203  public:
204         ModeChannelOp(Module* Creator)
205                 : PrefixMode(Creator, "op", 'o', OP_VALUE, '@')
206         {
207                 ranktoset = ranktounset = OP_VALUE;
208         }
209 };
210
211 /** Channel mode +v
212  */
213 class ModeChannelVoice : public PrefixMode
214 {
215  public:
216         ModeChannelVoice(Module* Creator)
217                 : PrefixMode(Creator, "voice", 'v', VOICE_VALUE, '+')
218         {
219                 selfremove = false;
220                 ranktoset = ranktounset = HALFOP_VALUE;
221         }
222 };