]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/builtinmodes.h
Merge branch 'master+listmode'
[user/henk/code/inspircd.git] / include / builtinmodes.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
5  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
6  *   Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
7  *
8  * This file is part of InspIRCd.  InspIRCd is free software: you can
9  * redistribute it and/or modify it under the terms of the GNU General Public
10  * License as published by the Free Software Foundation, version 2.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #pragma once
22
23 #include "mode.h"
24 #include "channels.h"
25 #include "listmode.h"
26
27 /** Channel mode +b
28  */
29 class ModeChannelBan : public ListModeBase
30 {
31  public:
32         ModeChannelBan()
33                 : ListModeBase(NULL, "ban", 'b', "End of channel ban list", 367, 368, true, "maxbans")
34         {
35         }
36 };
37
38 /** Channel mode +k
39  */
40 class ModeChannelKey : public ParamMode<ModeChannelKey, LocalStringExt>
41 {
42  public:
43         ModeChannelKey();
44         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
45         void SerializeParam(Channel* chan, const std::string* key, std::string& out);
46         ModeAction OnSet(User* source, Channel* chan, std::string& param);
47 };
48
49 /** Channel mode +l
50  */
51 class ModeChannelLimit : public ParamMode<ModeChannelLimit, LocalIntExt>
52 {
53  public:
54         ModeChannelLimit();
55         bool ResolveModeConflict(std::string &their_param, const std::string &our_param, Channel* channel);
56         void SerializeParam(Channel* chan, intptr_t n, std::string& out);
57         ModeAction OnSet(User* source, Channel* channel, std::string& parameter);
58 };
59
60 /** Channel mode +o
61  */
62 class ModeChannelOp : public PrefixMode
63 {
64  public:
65         ModeChannelOp()
66                 : PrefixMode(NULL, "op", 'o', OP_VALUE, '@')
67         {
68                 levelrequired = OP_VALUE;
69         }
70 };
71
72 /** Channel mode +v
73  */
74 class ModeChannelVoice : public PrefixMode
75 {
76  public:
77         ModeChannelVoice()
78                 : PrefixMode(NULL, "voice", 'v', VOICE_VALUE, '+')
79         {
80                 levelrequired = HALFOP_VALUE;
81         }
82 };
83
84 /** User mode +s
85  */
86 class ModeUserServerNoticeMask : public ModeHandler
87 {
88         /** Process a snomask modifier string, e.g. +abc-de
89          * @param user The target user
90          * @param input A sequence of notice mask characters
91          * @return The cleaned mode sequence which can be output,
92          * e.g. in the above example if masks c and e are not
93          * valid, this function will return +ab-d
94          */
95         std::string ProcessNoticeMasks(User* user, const std::string& input);
96
97  public:
98         ModeUserServerNoticeMask();
99         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
100         void OnParameterMissing(User* user, User* dest, Channel* channel);
101
102         /** Create a displayable mode string of the snomasks set on a given user
103          * @param user The user whose notice masks to format
104          * @return The notice mask character sequence
105          */
106         std::string GetUserParameter(User* user);
107 };
108
109 /** User mode +o
110  */
111 class ModeUserOperator : public ModeHandler
112 {
113  public:
114         ModeUserOperator();
115         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
116 };