summaryrefslogtreecommitdiff
path: root/include/modes.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/modes.h')
-rw-r--r--include/modes.h119
1 files changed, 38 insertions, 81 deletions
diff --git a/include/modes.h b/include/modes.h
index 03f6f8a58..49e923cda 100644
--- a/include/modes.h
+++ b/include/modes.h
@@ -1,17 +1,30 @@
-/* Mode support
+/*
+ * Anope IRC Services
*
- * (C) 2008-2011 Adam <Adam@anope.org>
- * (C) 2008-2016 Anope Team <team@anope.org>
+ * Copyright (C) 2008-2011 Adam <Adam@anope.org>
+ * Copyright (C) 2009-2016 Anope Team <team@anope.org>
*
- * Please read COPYING and README for further details.
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
*/
-#ifndef MODES_H
-#define MODES_H
+#pragma once
#include "anope.h"
#include "base.h"
+namespace Configuration { class Conf; }
+
/** The different types of modes
*/
enum ModeType
@@ -48,6 +61,9 @@ class CoreExport Mode : public Base
/* Type of mode this is, eg MODE_LIST */
ModeType type;
+ bool setable = true;
+ bool oper_only = false;
+
/** constructor
* @param mname The mode name
* @param mclass The type of mode this is
@@ -57,6 +73,9 @@ class CoreExport Mode : public Base
Mode(const Anope::string &mname, ModeClass mclass, char mc, ModeType type);
virtual ~Mode();
+ void SetSetable(bool b) { setable = b; }
+ void SetOperOnly(bool b) { oper_only = b; }
+
/** Can a user set this mode, used for mlock
* @param u The user
*/
@@ -105,7 +124,7 @@ class CoreExport ChannelMode : public Mode
*/
ChannelMode(const Anope::string &name, char mc);
- bool CanSet(User *u) const anope_override;
+ bool CanSet(User *u) const override;
virtual void Check() { }
@@ -146,18 +165,6 @@ class CoreExport ChannelModeList : public ChannelMode
* @return true on match
*/
virtual bool Matches(User *u, const Entry *e) { return false; }
-
- /** Called when a mask is added to a channel
- * @param chan The channel
- * @param mask The mask
- */
- virtual void OnAdd(Channel *chan, const Anope::string &mask) { }
-
- /** Called when a mask is removed from a channel
- * @param chan The channel
- * @param mask The mask
- */
- virtual void OnDel(Channel *chan, const Anope::string &mask) { }
};
/** This is a mode with a paramater, eg +k/l. These modes should use/inherit from this
@@ -175,11 +182,13 @@ class CoreExport ChannelModeParam : public ChannelMode
/* Should we send an arg when unsetting this mode? */
bool minus_no_arg;
+ std::regex param_validation;
+
/** Is the param valid
* @param value The param
* @return true for yes, false for no
*/
- virtual bool IsValid(Anope::string &value) const { return true; }
+ virtual bool IsValid(Anope::string &value) const;
};
/** This is a mode that is a channel status, eg +v/h/o/a/q.
@@ -197,7 +206,7 @@ class CoreExport ChannelModeStatus : public ChannelMode
/** constructor
* @param name The mode name
* @param mc The mode char
- * @param msymbol The symbol for the mode, eg @ %
+ * @param msymbol The symbol for the mode, eg @ %
* @param mlevel A level for the mode, which is usually determined by the PREFIX capab
*/
ChannelModeStatus(const Anope::string &name, char mc, char msymbol, short mlevel);
@@ -217,11 +226,11 @@ class CoreExport ChannelModeVirtual : public T
~ChannelModeVirtual();
- void Check() anope_override;
+ void Check() override;
- ChannelMode *Wrap(Anope::string &param) anope_override;
+ ChannelMode *Wrap(Anope::string &param) override;
- ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) = 0;
+ ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) override anope_abstract;
};
/* The status a user has on a channel (+v, +h, +o) etc */
@@ -240,53 +249,6 @@ class CoreExport ChannelStatus
Anope::string BuildModePrefixList() const;
};
-class CoreExport UserModeOperOnly : public UserMode
-{
- public:
- UserModeOperOnly(const Anope::string &mname, char um) : UserMode(mname, um) { }
-
- bool CanSet(User *u) const anope_override;
-};
-
-class CoreExport UserModeNoone : public UserMode
-{
- public:
- UserModeNoone(const Anope::string &mname, char um) : UserMode(mname, um) { }
-
- bool CanSet(User *u) const anope_override;
-};
-
-/** Channel mode +k (key)
- */
-class CoreExport ChannelModeKey : public ChannelModeParam
-{
- public:
- ChannelModeKey(char mc) : ChannelModeParam("KEY", mc) { }
-
- bool IsValid(Anope::string &value) const anope_override;
-};
-
-/** This class is used for oper only channel modes
- */
-class CoreExport ChannelModeOperOnly : public ChannelMode
-{
- public:
- ChannelModeOperOnly(const Anope::string &mname, char mc) : ChannelMode(mname, mc) { }
-
- /* Opers only */
- bool CanSet(User *u) const anope_override;
-};
-
-/** This class is used for channel modes only servers may set
- */
-class CoreExport ChannelModeNoone : public ChannelMode
-{
- public:
- ChannelModeNoone(const Anope::string &mname, char mc) : ChannelMode(mname, mc) { }
-
- bool CanSet(User *u) const anope_override;
-};
-
/** This is the mode manager
* It contains functions for adding modes to Anope so Anope can track them
* and do things such as MLOCK.
@@ -296,11 +258,6 @@ class CoreExport ChannelModeNoone : public ChannelMode
class CoreExport ModeManager
{
public:
-
- /* Number of generic channel and user modes we are tracking */
- static unsigned GenericChannelModes;
- static unsigned GenericUserModes;
-
/** Add a user mode to Anope
* @param um A UserMode or UserMode derived class
* @return true on success, false on error
@@ -365,7 +322,7 @@ class CoreExport ModeManager
* @param set true for setting, false for removing
* @param param The param, if there is one
*/
- static void StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool set, const Anope::string &param = "");
+ static void StackerAdd(User *bi, Channel *c, ChannelMode *cm, bool set, const Anope::string &param = "");
/** Add a mode to the stacker to be set on a user
* @param bi The client to set the modes from
@@ -374,7 +331,7 @@ class CoreExport ModeManager
* @param set true for setting, false for removing
* @param param The param, if there is one
*/
- static void StackerAdd(BotInfo *bi, User *u, UserMode *um, bool set, const Anope::string &param = "");
+ static void StackerAdd(User *bi, User *u, UserMode *um, bool set, const Anope::string &param = "");
/** Process all of the modes in the stacker and send them to the IRCd to be set on channels/users
*/
@@ -385,6 +342,8 @@ class CoreExport ModeManager
static void StackerDel(User *u);
static void StackerDel(Channel *c);
static void StackerDel(Mode *m);
+
+ static void Apply(Configuration::Conf *old);
};
/** Represents a mask set on a channel (b/e/I)
@@ -395,7 +354,7 @@ class CoreExport Entry
Anope::string mask;
public:
unsigned short cidr_len;
- int family;
+ int family = 0;
Anope::string nick, user, host, real;
/** Constructor
@@ -418,5 +377,3 @@ class CoreExport Entry
*/
bool Matches(User *u, bool full = false) const;
};
-
-#endif // MODES_H