X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fmode.h;h=87d79c7d563902a4954a54690a3e0d58881d0348;hb=511c11b8da024363fe2711a5ea9d600326073c8c;hp=091d11c3df453ddcd19a97db375b8d91f59bbd60;hpb=b868bb52c55fc902e0acab3c4a43576826817e85;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/mode.h b/include/mode.h index 091d11c3d..87d79c7d5 100644 --- a/include/mode.h +++ b/include/mode.h @@ -2,7 +2,7 @@ * | 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 @@ -14,11 +14,7 @@ #ifndef __MODE_H #define __MODE_H -/* Forward declarations. */ -class User; - #include "ctables.h" -#include "channels.h" /** * Holds the values for different type of modes @@ -94,7 +90,7 @@ enum ParamSpec * 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: /** @@ -109,7 +105,7 @@ class CoreExport ModeHandler : public classbase /** * The mode letter you're implementing. */ - const char mode; + char mode; /** Mode prefix, or 0 */ @@ -139,22 +135,12 @@ class CoreExport ModeHandler : public classbase */ 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 @@ -177,12 +163,6 @@ class CoreExport ModeHandler : public classbase * 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. @@ -214,7 +194,7 @@ class CoreExport ModeHandler : public classbase * 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 */ @@ -329,6 +309,16 @@ class CoreExport SimpleChannelModeHandler : public ModeHandler 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, @@ -553,9 +543,10 @@ class CoreExport ModeParser 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