]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/mode.h
Remove dummy API_VERSION from Version constructor
[user/henk/code/inspircd.git] / include / mode.h
index db115a3c90588af452e2ec08b68e5a8076c24d31..81858a823897496ddf1c2cb968003f50a9da6e70 100644 (file)
@@ -105,13 +105,29 @@ class CoreExport ModeHandler : public classbase
 {
  protected:
        /**
-        * The mode letter you're implementing.
+        * The mode parameter translation type
         */
-       char mode;
+       TranslateType m_paramtype;
 
        /** What kind of parameters does the mode take?
         */
        ParamSpec parameters_taken;
+
+       /**
+        * The mode letter you're implementing.
+        */
+       const char mode;
+
+       /** Mode prefix, or 0
+        */
+       char prefix;
+
+       /**
+        * True if the mode requires oper status
+        * to set.
+        */
+       bool oper;
+
        /**
         * Mode is a 'list' mode. The behaviour
         * of your mode is now set entirely within
@@ -123,24 +139,12 @@ class CoreExport ModeHandler : public classbase
         * (e.g. banlists, etc)
         */
        bool list;
+
        /**
         * The mode type, either MODETYPE_USER or
         * MODETYPE_CHANNEL.
         */
        ModeType m_type;
-       /**
-        * The mode parameter translation type
-        */
-       TranslateType m_paramtype;
-       /**
-        * True if the mode requires oper status
-        * to set.
-        */
-       bool oper;
-
-       /** Mode prefix, or 0
-        */
-       char prefix;
 
        /** Number of items with this mode set on them
         */
@@ -153,29 +157,22 @@ class CoreExport ModeHandler : public classbase
 
  public:
        /** Module that created this mode. NULL for core modes */
-       Module* creator;
+       Module* const creator;
+       /** Long-form name
+        */
+       const std::string name;
 
        /**
         * The constructor for ModeHandler initalizes the mode handler.
         * The constructor of any class you derive from ModeHandler should
         * probably call this constructor with the parameters set correctly.
+        * @param name A one-word name for the mode
         * @param modeletter The mode letter you wish to handle
-        * @param parameters_on The number of parameters your mode takes when being set. Note that any nonzero value is treated as 1.
-        * @param parameters_off The number of parameters your mode takes when being unset. Note that any nonzero value is treated as 1.
-        * @param listmode Set to true if your mode is a listmode, e.g. it will respond to MODE #channel +modechar with a list of items
-        * @param ModeType Set this to MODETYPE_USER for a usermode, or MODETYPE_CHANNEL for a channelmode.
-        * @param operonly Set this to true if only opers should be allowed to set or unset the mode.
-        * @param mprefix For listmodes where parameters are NICKNAMES which are on the channel (for example, +ohv), you may define a prefix.
-        * When you define a prefix, it can be returned in NAMES, WHO etc if it has the highest value (as returned by GetPrefixRank())
-        * In the core, the only modes to implement prefixes are +ovh (ops, voice, halfop) which define the prefix characters @, % and +
-        * and the rank values OP_VALUE, HALFOP_VALUE and VOICE_VALUE respectively. Any prefixes you define should have unique values proportional
-        * to these three defaults or proportional to another mode in a module you depend on. See src/cmode_o.cpp as an example.
-        * @param prefixrequired The prefix required to change this mode
-        */
-       ModeHandler(Module* me, char modeletter, ParamSpec params, ModeType type);
-       /**
-        * The default destructor does nothing
+        * @param params Parameters taken by the mode
+        * @param type Type of the mode (MODETYPE_USER or MODETYPE_CHANNEL)
         */
+       ModeHandler(Module* me, const std::string& name, char modeletter, ParamSpec params, ModeType type);
+       virtual bool cull();
        virtual ~ModeHandler();
        /**
         * Returns true if the mode is a list mode
@@ -230,6 +227,16 @@ class CoreExport ModeHandler : public classbase
         */
        virtual std::string GetUserParameter(User* useor);
 
+       /**
+        * Called when a channel mode change access check for your mode occurs.
+        * @param source Contains the user setting the mode.
+        * @param channel contains the destination channel the modes are being set on.
+        * @param parameter The parameter for your mode. This is modifiable.
+        * @param adding This value is true when the mode is being set, or false when it is being unset.
+        * @return allow, deny, or passthru to check against the required level
+        */
+       virtual ModResult AccessCheck(User* source, Channel* channel, std::string &parameter, bool adding);
+
        /**
         * Called when a mode change for your mode occurs.
         * @param source Contains the user setting the mode.
@@ -276,7 +283,7 @@ class CoreExport ModeHandler : public classbase
         * @param channel The channel we are checking against
         * @return True if the other side wins the merge, false if we win the merge for this mode.
         */
-       virtual bool CheckTimeStamp(std::string &their_param, const std::string &our_param, Channel* channel);
+       virtual bool ResolveModeConflict(std::string &their_param, const std::string &our_param, Channel* channel);
 
        /**
         * When a remote server needs to bounce a set of modes, it will call this method for every mode
@@ -312,7 +319,7 @@ class CoreExport ModeHandler : public classbase
         * @param channel The channel which the server wants to remove your mode from
         */
        virtual void RemoveMode(Channel* channel, irc::modestacker* stack = NULL);
-       
+
        inline unsigned int GetLevelRequired() const { return levelrequired; }
 };
 
@@ -324,8 +331,8 @@ class CoreExport ModeHandler : public classbase
 class CoreExport SimpleUserModeHandler : public ModeHandler
 {
  public:
-       SimpleUserModeHandler(Module* Creator, char modeletter)
-               : ModeHandler(Creator, modeletter, PARAM_NONE, MODETYPE_USER) {}
+       SimpleUserModeHandler(Module* Creator, const std::string& Name, char modeletter)
+               : ModeHandler(Creator, Name, modeletter, PARAM_NONE, MODETYPE_USER) {}
        virtual ~SimpleUserModeHandler() {}
        virtual ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
 };
@@ -338,8 +345,8 @@ class CoreExport SimpleUserModeHandler : public ModeHandler
 class CoreExport SimpleChannelModeHandler : public ModeHandler
 {
  public:
-       SimpleChannelModeHandler(InspIRCd* Instance, Module* Creator, char modeletter)
-               : ModeHandler(Creator, modeletter, PARAM_NONE, MODETYPE_CHANNEL) {}
+       SimpleChannelModeHandler(Module* Creator, const std::string& Name, char modeletter)
+               : ModeHandler(Creator, Name, modeletter, PARAM_NONE, MODETYPE_CHANNEL) {}
        virtual ~SimpleChannelModeHandler() {}
        virtual ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
 };
@@ -353,10 +360,6 @@ class CoreExport SimpleChannelModeHandler : public ModeHandler
 class CoreExport ModeWatcher : public classbase
 {
  protected:
-       /**
-        * Creator/owner pointer
-        */
-       InspIRCd* ServerInstance;
        /**
         * The mode letter this class is watching
         */
@@ -367,10 +370,11 @@ class CoreExport ModeWatcher : public classbase
        ModeType m_type;
 
  public:
+       Module* const creator;
        /**
         * The constructor initializes the mode and the mode type
         */
-       ModeWatcher(InspIRCd* Instance, char modeletter, ModeType type);
+       ModeWatcher(Module* creator, char modeletter, ModeType type);
        /**
         * The default destructor does nothing.
         */
@@ -464,7 +468,7 @@ class CoreExport ModeParser : public classbase
 
        /** The constructor initializes all the RFC basic modes by using ModeParserAddMode().
         */
-       ModeParser(InspIRCd* Instance);
+       ModeParser();
        ~ModeParser();
 
        /** Used to check if user 'd' should be allowed to do operation 'MASK' on channel 'chan'.
@@ -506,6 +510,7 @@ class CoreExport ModeParser : public classbase
         * @return True if the mode was successfully removed.
         */
        bool DelMode(ModeHandler* mh);
+
        /** Add a mode watcher.
         * A mode watcher is triggered before and after a mode handler is
         * triggered. See the documentation of class ModeWatcher for more