* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * InspIRCd: (C) 2002-2010 InspIRCd Development Team
* See: http://wiki.inspircd.org/Credits
*
* This program is free but copyrighted software; see
#ifndef __MODE_H
#define __MODE_H
-/* Forward declarations. */
-class User;
-
#include "ctables.h"
-#include "channels.h"
/**
* Holds the values for different type of modes
* mode is expected to have a parameter, then this is
* equivalent to returning MODEACTION_DENY.
*/
-class CoreExport ModeHandler : public classbase
+class CoreExport ModeHandler : public ServiceProvider
{
protected:
/**
/**
* The mode letter you're implementing.
*/
- const char mode;
+ char mode;
/** Mode prefix, or 0
*/
*/
ModeType m_type;
- /** Number of items with this mode set on them
- */
- unsigned int count;
-
/** The prefix char needed on channel to use this mode,
* only checked for channel modes
*/
int levelrequired;
public:
- /** Module that created this mode. NULL for core modes */
- ModuleRef 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
* value for this mode prefix.
*/
inline char GetPrefix() const { return prefix; }
- /** Get number of items with this mode set on them
- */
- virtual unsigned int GetCount();
- /** Adjust usage count returned by GetCount
- */
- virtual void ChangeCount(int modifier);
/**
* Get the 'value' of this modes prefix.
* determines which to display when there are multiple.
* Returns the mode character this handler handles.
* @return The mode character
*/
- char GetModeChar();
+ inline char GetModeChar() { return mode; }
/** For user modes, return the current parameter, if any
*/
virtual ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding);
};
+class CoreExport ParamChannelModeHandler : public ModeHandler
+{
+ public:
+ ParamChannelModeHandler(Module* Creator, const std::string& Name, char modeletter)
+ : ModeHandler(Creator, Name, modeletter, PARAM_SETONLY, MODETYPE_CHANNEL) {}
+ virtual ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding);
+ /** Validate the parameter - you may change the value to normalize it. Return true if it is valid. */
+ virtual bool ParamValidate(std::string& parameter);
+};
+
/**
* The ModeWatcher class can be used to alter the behaviour of a mode implemented
* by the core or by another module. To use ModeWatcher, derive a class from it,
static bool PrefixComparison(ModeHandler* one, ModeHandler* two);
- /** This returns the PREFIX=(ohv)@%+ section of the 005 numeric.
+ /** This returns the PREFIX=(ohv)@%+ section of the 005 numeric, or
+ * just the "@%+" part if the parameter false
*/
- std::string BuildPrefixes();
+ std::string BuildPrefixes(bool lettersAndModes = true);
};
#endif