]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_channel/core_channel.h
Merge pull request #1446 from B00mX0r/master+wrongnumeric
[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
39 /** Handle /INVITE.
40  */
41 class CommandInvite : public Command
42 {
43         Invite::APIImpl& invapi;
44
45  public:
46         /** Constructor for invite.
47          */
48         CommandInvite(Module* parent, Invite::APIImpl& invapiimpl);
49
50         /** Handle command.
51          * @param parameters The parameters to the command
52          * @param user The user issuing the command
53          * @return A value from CmdResult to indicate command success or failure.
54          */
55         CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE;
56         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) CXX11_OVERRIDE;
57 };
58
59 /** Handle /JOIN.
60  */
61 class CommandJoin : public SplitCommand
62 {
63  public:
64         /** Constructor for join.
65          */
66         CommandJoin(Module* parent);
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 HandleLocal(const std::vector<std::string>& parameters, LocalUser* user) CXX11_OVERRIDE;
74 };
75
76 /** Handle /TOPIC.
77  */
78 class CommandTopic : public SplitCommand
79 {
80         CheckExemption::EventProvider exemptionprov;
81         ChanModeReference secretmode;
82         ChanModeReference topiclockmode;
83
84  public:
85         /** Constructor for topic.
86          */
87         CommandTopic(Module* parent);
88
89         /** Handle command.
90          * @param parameters The parameters to the command
91          * @param user The user issuing the command
92          * @return A value from CmdResult to indicate command success or failure.
93          */
94         CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user) CXX11_OVERRIDE;
95 };
96
97 /** Handle /NAMES.
98  */
99 class CommandNames : public SplitCommand
100 {
101         ChanModeReference secretmode;
102         ChanModeReference privatemode;
103         UserModeReference invisiblemode;
104
105  public:
106         /** Constructor for names.
107          */
108         CommandNames(Module* parent);
109
110         /** Handle command.
111          * @param parameters The parameters to the command
112          * @param user The user issuing the command
113          * @return A value from CmdResult to indicate command success or failure.
114          */
115         CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user) CXX11_OVERRIDE;
116
117         /** Spool the NAMES list for a given channel to the given user
118          * @param user User to spool the NAMES list to
119          * @param chan Channel whose nicklist to send
120          * @param show_invisible True to show invisible (+i) members to the user, false to omit them from the list
121          */
122         void SendNames(LocalUser* user, Channel* chan, bool show_invisible);
123 };
124
125 /** Handle /KICK.
126  */
127 class CommandKick : public Command
128 {
129  public:
130         /** Constructor for kick.
131          */
132         CommandKick(Module* parent);
133
134         /** Handle command.
135          * @param parameters The parameters to the command
136          * @param user The user issuing the command
137          * @return A value from CmdResult to indicate command success or failure.
138          */
139         CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE;
140         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) CXX11_OVERRIDE;
141 };
142
143 /** Channel mode +b
144  */
145 class ModeChannelBan : public ListModeBase
146 {
147  public:
148         ModeChannelBan(Module* Creator)
149                 : ListModeBase(Creator, "ban", 'b', "End of channel ban list", 367, 368, true, "maxbans")
150         {
151         }
152 };
153
154 /** Channel mode +k
155  */
156 class ModeChannelKey : public ParamMode<ModeChannelKey, LocalStringExt>
157 {
158         static const std::string::size_type maxkeylen = 32;
159  public:
160         ModeChannelKey(Module* Creator);
161         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding) CXX11_OVERRIDE;
162         void SerializeParam(Channel* chan, const std::string* key, std::string& out)    ;
163         ModeAction OnSet(User* source, Channel* chan, std::string& param) CXX11_OVERRIDE;
164 };
165
166 /** Channel mode +l
167  */
168 class ModeChannelLimit : public ParamMode<ModeChannelLimit, LocalIntExt>
169 {
170  public:
171         size_t minlimit;
172         ModeChannelLimit(Module* Creator);
173         bool ResolveModeConflict(std::string& their_param, const std::string& our_param, Channel* channel) CXX11_OVERRIDE;
174         void SerializeParam(Channel* chan, intptr_t n, std::string& out);
175         ModeAction OnSet(User* source, Channel* channel, std::string& parameter) CXX11_OVERRIDE;
176 };
177
178 /** Channel mode +o
179  */
180 class ModeChannelOp : public PrefixMode
181 {
182  public:
183         ModeChannelOp(Module* Creator)
184                 : PrefixMode(Creator, "op", 'o', OP_VALUE, '@')
185         {
186                 ranktoset = ranktounset = OP_VALUE;
187         }
188 };
189
190 /** Channel mode +v
191  */
192 class ModeChannelVoice : public PrefixMode
193 {
194  public:
195         ModeChannelVoice(Module* Creator)
196                 : PrefixMode(Creator, "voice", 'v', VOICE_VALUE, '+')
197         {
198                 selfremove = false;
199                 ranktoset = ranktounset = HALFOP_VALUE;
200         }
201 };