mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Specify which Extensible subclass an ExtensionItem is valid for
This commit is contained in:
parent
4b6f7d7893
commit
4fc2f7199e
@ -38,7 +38,20 @@ enum SerializeFormat
|
||||
class CoreExport ExtensionItem : public ServiceProvider, public usecountbase
|
||||
{
|
||||
public:
|
||||
ExtensionItem(const std::string& key, Module* owner);
|
||||
/** Extensible subclasses
|
||||
*/
|
||||
enum ExtensibleType
|
||||
{
|
||||
EXT_USER,
|
||||
EXT_CHANNEL,
|
||||
EXT_MEMBERSHIP
|
||||
};
|
||||
|
||||
/** Type (subclass) of Extensible that this ExtensionItem is valid for
|
||||
*/
|
||||
const ExtensibleType type;
|
||||
|
||||
ExtensionItem(const std::string& key, ExtensibleType exttype, Module* owner);
|
||||
virtual ~ExtensionItem();
|
||||
/** Serialize this item into a string
|
||||
*
|
||||
@ -119,7 +132,7 @@ class CoreExport ExtensionManager
|
||||
class CoreExport LocalExtItem : public ExtensionItem
|
||||
{
|
||||
public:
|
||||
LocalExtItem(const std::string& key, Module* owner);
|
||||
LocalExtItem(const std::string& key, ExtensibleType exttype, Module* owner);
|
||||
virtual ~LocalExtItem();
|
||||
virtual std::string serialize(SerializeFormat format, const Extensible* container, void* item) const;
|
||||
virtual void unserialize(SerializeFormat format, Extensible* container, const std::string& value);
|
||||
@ -130,7 +143,8 @@ template <typename T, typename Del = stdalgo::defaultdeleter<T> >
|
||||
class SimpleExtItem : public LocalExtItem
|
||||
{
|
||||
public:
|
||||
SimpleExtItem(const std::string& Key, Module* parent) : LocalExtItem(Key, parent)
|
||||
SimpleExtItem(const std::string& Key, ExtensibleType exttype, Module* parent)
|
||||
: LocalExtItem(Key, exttype, parent)
|
||||
{
|
||||
}
|
||||
|
||||
@ -175,7 +189,7 @@ class SimpleExtItem : public LocalExtItem
|
||||
class CoreExport LocalStringExt : public SimpleExtItem<std::string>
|
||||
{
|
||||
public:
|
||||
LocalStringExt(const std::string& key, Module* owner);
|
||||
LocalStringExt(const std::string& key, ExtensibleType exttype, Module* owner);
|
||||
virtual ~LocalStringExt();
|
||||
std::string serialize(SerializeFormat format, const Extensible* container, void* item) const;
|
||||
};
|
||||
@ -183,7 +197,7 @@ class CoreExport LocalStringExt : public SimpleExtItem<std::string>
|
||||
class CoreExport LocalIntExt : public LocalExtItem
|
||||
{
|
||||
public:
|
||||
LocalIntExt(const std::string& key, Module* owner);
|
||||
LocalIntExt(const std::string& key, ExtensibleType exttype, Module* owner);
|
||||
virtual ~LocalIntExt();
|
||||
std::string serialize(SerializeFormat format, const Extensible* container, void* item) const;
|
||||
intptr_t get(const Extensible* container) const;
|
||||
@ -195,7 +209,7 @@ class CoreExport LocalIntExt : public LocalExtItem
|
||||
class CoreExport StringExtItem : public ExtensionItem
|
||||
{
|
||||
public:
|
||||
StringExtItem(const std::string& key, Module* owner);
|
||||
StringExtItem(const std::string& key, ExtensibleType exttype, Module* owner);
|
||||
virtual ~StringExtItem();
|
||||
std::string* get(const Extensible* container) const;
|
||||
std::string serialize(SerializeFormat format, const Extensible* container, void* item) const;
|
||||
|
@ -43,7 +43,9 @@ class GenericCap
|
||||
public:
|
||||
LocalIntExt ext;
|
||||
const std::string cap;
|
||||
GenericCap(Module* parent, const std::string &Cap) : ext("cap_" + Cap, parent), cap(Cap)
|
||||
GenericCap(Module* parent, const std::string& Cap)
|
||||
: ext("cap_" + Cap, ExtensionItem::EXT_USER, parent)
|
||||
, cap(Cap)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class ParamMode : public ParamModeBase
|
||||
*/
|
||||
ParamMode(Module* Creator, const std::string& Name, char modeletter, ParamSpec ps = PARAM_SETONLY)
|
||||
: ParamModeBase(Creator, Name, modeletter, ps)
|
||||
, ext("parammode_" + Name, Creator)
|
||||
, ext("parammode_" + Name, ExtensionItem::EXT_CHANNEL, Creator)
|
||||
{
|
||||
}
|
||||
|
||||
|
19
src/base.cpp
19
src/base.cpp
@ -89,7 +89,9 @@ ServiceProvider::~ServiceProvider()
|
||||
{
|
||||
}
|
||||
|
||||
ExtensionItem::ExtensionItem(const std::string& Key, Module* mod) : ServiceProvider(mod, Key, SERVICE_METADATA)
|
||||
ExtensionItem::ExtensionItem(const std::string& Key, ExtensibleType exttype, Module* mod)
|
||||
: ServiceProvider(mod, Key, SERVICE_METADATA)
|
||||
, type(exttype)
|
||||
{
|
||||
}
|
||||
|
||||
@ -201,7 +203,8 @@ Extensible::~Extensible()
|
||||
ServerInstance->Logs->Log("CULLLIST", LOG_DEBUG, "Extensible destructor called without cull @%p", (void*)this);
|
||||
}
|
||||
|
||||
LocalExtItem::LocalExtItem(const std::string& Key, Module* mod) : ExtensionItem(Key, mod)
|
||||
LocalExtItem::LocalExtItem(const std::string& Key, ExtensibleType exttype, Module* mod)
|
||||
: ExtensionItem(Key, exttype, mod)
|
||||
{
|
||||
}
|
||||
|
||||
@ -218,8 +221,10 @@ void LocalExtItem::unserialize(SerializeFormat format, Extensible* container, co
|
||||
{
|
||||
}
|
||||
|
||||
LocalStringExt::LocalStringExt(const std::string& Key, Module* Owner)
|
||||
: SimpleExtItem<std::string>(Key, Owner) { }
|
||||
LocalStringExt::LocalStringExt(const std::string& Key, ExtensibleType exttype, Module* Owner)
|
||||
: SimpleExtItem<std::string>(Key, exttype, Owner)
|
||||
{
|
||||
}
|
||||
|
||||
LocalStringExt::~LocalStringExt()
|
||||
{
|
||||
@ -232,7 +237,8 @@ std::string LocalStringExt::serialize(SerializeFormat format, const Extensible*
|
||||
return "";
|
||||
}
|
||||
|
||||
LocalIntExt::LocalIntExt(const std::string& Key, Module* mod) : LocalExtItem(Key, mod)
|
||||
LocalIntExt::LocalIntExt(const std::string& Key, ExtensibleType exttype, Module* mod)
|
||||
: LocalExtItem(Key, exttype, mod)
|
||||
{
|
||||
}
|
||||
|
||||
@ -264,7 +270,8 @@ void LocalIntExt::free(void*)
|
||||
{
|
||||
}
|
||||
|
||||
StringExtItem::StringExtItem(const std::string& Key, Module* mod) : ExtensionItem(Key, mod)
|
||||
StringExtItem::StringExtItem(const std::string& Key, ExtensibleType exttype, Module* mod)
|
||||
: ExtensionItem(Key, exttype, mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -183,8 +183,8 @@ class ModuleHostnameLookup : public Module
|
||||
|
||||
public:
|
||||
ModuleHostnameLookup()
|
||||
: dnsLookup("dnsLookup", this)
|
||||
, ptrHosts("ptrHosts", this)
|
||||
: dnsLookup("dnsLookup", ExtensionItem::EXT_USER, this)
|
||||
, ptrHosts("ptrHosts", ExtensionItem::EXT_USER, this)
|
||||
, DNS(this, "DNS")
|
||||
{
|
||||
dl = &dnsLookup;
|
||||
|
@ -229,7 +229,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
|
||||
* THIS MUST MATCH THE ORDER OF DECLARATION OF THE FUNCTORS, e.g. the methods
|
||||
* themselves within the class.
|
||||
*/
|
||||
OperQuit("operquit", NULL),
|
||||
OperQuit("operquit", ExtensionItem::EXT_USER, NULL),
|
||||
GenRandom(&HandleGenRandom),
|
||||
IsChannel(&HandleIsChannel),
|
||||
IsNick(&HandleIsNick),
|
||||
|
@ -22,7 +22,8 @@
|
||||
ListModeBase::ListModeBase(Module* Creator, const std::string& Name, char modechar, const std::string &eolstr, unsigned int lnum, unsigned int eolnum, bool autotidy, const std::string &ctag)
|
||||
: ModeHandler(Creator, Name, modechar, PARAM_ALWAYS, MODETYPE_CHANNEL, MC_LIST),
|
||||
listnumeric(lnum), endoflistnumeric(eolnum), endofliststring(eolstr), tidy(autotidy),
|
||||
configtag(ctag), extItem("listbase_mode_" + name + "_list", Creator)
|
||||
configtag(ctag)
|
||||
, extItem("listbase_mode_" + name + "_list", ExtensionItem::EXT_CHANNEL, Creator)
|
||||
{
|
||||
list = true;
|
||||
}
|
||||
|
@ -46,7 +46,9 @@ class ModuleGeoIP : public Module
|
||||
}
|
||||
|
||||
public:
|
||||
ModuleGeoIP() : ext("geoip_cc", this), gi(NULL)
|
||||
ModuleGeoIP()
|
||||
: ext("geoip_cc", ExtensionItem::EXT_USER, this)
|
||||
, gi(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class BanRedirect : public ModeWatcher
|
||||
BanRedirect(Module* parent)
|
||||
: ModeWatcher(parent, "ban", MODETYPE_CHANNEL)
|
||||
, ban(parent, "ban")
|
||||
, extItem("banredirect", parent)
|
||||
, extItem("banredirect", ExtensionItem::EXT_CHANNEL, parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,8 @@ class ModuleBlockAmsg : public Module
|
||||
SimpleExtItem<BlockedMessage> blockamsg;
|
||||
|
||||
public:
|
||||
ModuleBlockAmsg() : blockamsg("blockamsg", this)
|
||||
ModuleBlockAmsg()
|
||||
: blockamsg("blockamsg", ExtensionItem::EXT_USER, this)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ class callerid_data
|
||||
struct CallerIDExtInfo : public ExtensionItem
|
||||
{
|
||||
CallerIDExtInfo(Module* parent)
|
||||
: ExtensionItem("callerid_data", parent)
|
||||
: ExtensionItem("callerid_data", ExtensionItem::EXT_USER, parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class CommandCAP : public Command
|
||||
public:
|
||||
LocalIntExt reghold;
|
||||
CommandCAP (Module* mod) : Command(mod, "CAP", 1),
|
||||
reghold("CAP_REGHOLD", mod)
|
||||
reghold("CAP_REGHOLD", ExtensionItem::EXT_USER, mod)
|
||||
{
|
||||
works_before_reg = true;
|
||||
}
|
||||
|
@ -74,7 +74,8 @@ class CommandWebirc : public Command
|
||||
CGIHostlist Hosts;
|
||||
CommandWebirc(Module* Creator)
|
||||
: Command(Creator, "WEBIRC", 4),
|
||||
realhost("cgiirc_realhost", Creator), realip("cgiirc_realip", Creator)
|
||||
realhost("cgiirc_realhost", ExtensionItem::EXT_USER, Creator)
|
||||
, realip("cgiirc_realip", ExtensionItem::EXT_USER, Creator)
|
||||
{
|
||||
works_before_reg = true;
|
||||
this->syntax = "password client hostname ip";
|
||||
@ -225,7 +226,7 @@ class ModuleCgiIRC : public Module
|
||||
public:
|
||||
ModuleCgiIRC()
|
||||
: cmd(this)
|
||||
, waiting("cgiirc-delay", this)
|
||||
, waiting("cgiirc-delay", ExtensionItem::EXT_USER, this)
|
||||
, DNS(this, "DNS")
|
||||
{
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class CloakUser : public ModeHandler
|
||||
|
||||
CloakUser(Module* source)
|
||||
: ModeHandler(source, "cloak", 'x', PARAM_NONE, MODETYPE_USER),
|
||||
ext("cloaked_host", source), debounce_ts(0), debounce_count(0)
|
||||
ext("cloaked_host", ExtensionItem::EXT_USER, source), debounce_ts(0), debounce_count(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,8 @@ class ModuleConnJoin : public Module
|
||||
unsigned int defdelay;
|
||||
|
||||
public:
|
||||
ModuleConnJoin() : ext("join_timer", this)
|
||||
ModuleConnJoin()
|
||||
: ext("join_timer", ExtensionItem::EXT_USER, this)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ class ModuleWaitPong : public Module
|
||||
|
||||
public:
|
||||
ModuleWaitPong()
|
||||
: ext("waitpong_pingstr", this)
|
||||
: ext("waitpong_pingstr", ExtensionItem::EXT_USER, this)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ class CommandTitle : public Command
|
||||
public:
|
||||
StringExtItem ctitle;
|
||||
CommandTitle(Module* Creator) : Command(Creator,"TITLE", 2),
|
||||
ctitle("ctitle", Creator)
|
||||
ctitle("ctitle", ExtensionItem::EXT_USER, Creator)
|
||||
{
|
||||
syntax = "<user> <password>";
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ class ModuleDCCAllow : public Module
|
||||
|
||||
public:
|
||||
ModuleDCCAllow()
|
||||
: ext("dccallow", this)
|
||||
: ext("dccallow", ExtensionItem::EXT_USER, this)
|
||||
, cmd(this, ext)
|
||||
{
|
||||
}
|
||||
|
@ -39,7 +39,9 @@ class ModuleDelayJoin : public Module
|
||||
DelayJoinMode djm;
|
||||
public:
|
||||
LocalIntExt unjoined;
|
||||
ModuleDelayJoin() : djm(this), unjoined("delayjoin", this)
|
||||
ModuleDelayJoin()
|
||||
: djm(this)
|
||||
, unjoined("delayjoin", ExtensionItem::EXT_MEMBERSHIP, this)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ class DelayMsgMode : public ParamMode<DelayMsgMode, LocalIntExt>
|
||||
LocalIntExt jointime;
|
||||
DelayMsgMode(Module* Parent)
|
||||
: ParamMode<DelayMsgMode, LocalIntExt>(Parent, "delaymsg", 'd')
|
||||
, jointime("delaymsg", Parent)
|
||||
, jointime("delaymsg", ExtensionItem::EXT_MEMBERSHIP, Parent)
|
||||
{
|
||||
levelrequired = OP_VALUE;
|
||||
}
|
||||
|
@ -236,7 +236,12 @@ class ModuleDNSBL : public Module
|
||||
return DNSBLConfEntry::I_UNKNOWN;
|
||||
}
|
||||
public:
|
||||
ModuleDNSBL() : DNS(this, "DNS"), nameExt("dnsbl_match", this), countExt("dnsbl_pending", this) { }
|
||||
ModuleDNSBL()
|
||||
: DNS(this, "DNS")
|
||||
, nameExt("dnsbl_match", ExtensionItem::EXT_USER, this)
|
||||
, countExt("dnsbl_pending", ExtensionItem::EXT_USER, this)
|
||||
{
|
||||
}
|
||||
|
||||
Version GetVersion() CXX11_OVERRIDE
|
||||
{
|
||||
|
@ -277,7 +277,8 @@ class ModuleIdent : public Module
|
||||
bool NoLookupPrefix;
|
||||
SimpleExtItem<IdentRequestSocket, stdalgo::culldeleter> ext;
|
||||
public:
|
||||
ModuleIdent() : ext("ident_socket", this)
|
||||
ModuleIdent()
|
||||
: ext("ident_socket", ExtensionItem::EXT_USER, this)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -307,8 +307,8 @@ class ModuleLDAPAuth : public Module
|
||||
public:
|
||||
ModuleLDAPAuth()
|
||||
: LDAP(this, "LDAP")
|
||||
, ldapAuthed("ldapauth", this)
|
||||
, ldapVhost("ldapauth_vhost", this)
|
||||
, ldapAuthed("ldapauth", ExtensionItem::EXT_USER, this)
|
||||
, ldapVhost("ldapauth_vhost", ExtensionItem::EXT_USER, this)
|
||||
{
|
||||
me = this;
|
||||
authed = &ldapAuthed;
|
||||
|
@ -25,7 +25,7 @@ class ModuleMLock : public Module
|
||||
|
||||
public:
|
||||
ModuleMLock()
|
||||
: mlock("mlock", this)
|
||||
: mlock("mlock", ExtensionItem::EXT_CHANNEL, this)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,9 @@ class ModuleNickLock : public Module
|
||||
CommandNickunlock cmd2;
|
||||
public:
|
||||
ModuleNickLock()
|
||||
: locked("nick_locked", this), cmd1(this, locked), cmd2(this, locked)
|
||||
: locked("nick_locked", ExtensionItem::EXT_USER, this)
|
||||
, cmd1(this, locked)
|
||||
, cmd2(this, locked)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ class RepeatMode : public ParamMode<RepeatMode, SimpleExtItem<ChannelSettings> >
|
||||
|
||||
RepeatMode(Module* Creator)
|
||||
: ParamMode<RepeatMode, SimpleExtItem<ChannelSettings> >(Creator, "repeat", 'E')
|
||||
, MemberInfoExt("repeat_memb", Creator)
|
||||
, MemberInfoExt("repeat_memb", ExtensionItem::EXT_MEMBERSHIP, Creator)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,10 @@ class ModuleSASL : public Module
|
||||
|
||||
public:
|
||||
ModuleSASL()
|
||||
: authExt("sasl_auth", this), cap(this, "sasl"), auth(this, authExt, cap), sasl(this, authExt)
|
||||
: authExt("sasl_auth", ExtensionItem::EXT_USER, this)
|
||||
, cap(this, "sasl")
|
||||
, auth(this, authExt, cap)
|
||||
, sasl(this, authExt)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ class AccountExtItemImpl : public AccountExtItem
|
||||
{
|
||||
public:
|
||||
AccountExtItemImpl(Module* mod)
|
||||
: AccountExtItem("accountname", mod)
|
||||
: AccountExtItem("accountname", ExtensionItem::EXT_USER, mod)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,8 @@ class CommandSilence : public Command
|
||||
public:
|
||||
SimpleExtItem<silencelist> ext;
|
||||
CommandSilence(Module* Creator, unsigned int &max) : Command(Creator, "SILENCE", 0),
|
||||
maxsilence(max), ext("silence_list", Creator)
|
||||
maxsilence(max)
|
||||
, ext("silence_list", ExtensionItem::EXT_USER, Creator)
|
||||
{
|
||||
allow_empty_last_param = false;
|
||||
syntax = "{[+|-]<mask> <p|c|i|n|t|a|x>}";
|
||||
|
@ -78,7 +78,9 @@ class ModuleSQLAuth : public Module
|
||||
bool verbose;
|
||||
|
||||
public:
|
||||
ModuleSQLAuth() : pendingExt("sqlauth-wait", this), SQL(this, "SQL")
|
||||
ModuleSQLAuth()
|
||||
: pendingExt("sqlauth-wait", ExtensionItem::EXT_USER, this)
|
||||
, SQL(this, "SQL")
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,11 @@
|
||||
|
||||
class SSLCertExt : public ExtensionItem {
|
||||
public:
|
||||
SSLCertExt(Module* parent) : ExtensionItem("ssl_cert", parent) {}
|
||||
SSLCertExt(Module* parent)
|
||||
: ExtensionItem("ssl_cert", ExtensionItem::EXT_USER, parent)
|
||||
{
|
||||
}
|
||||
|
||||
ssl_cert* get(const Extensible* item) const
|
||||
{
|
||||
return static_cast<ssl_cert*>(get_raw(item));
|
||||
|
@ -31,7 +31,9 @@ class CommandSwhois : public Command
|
||||
{
|
||||
public:
|
||||
StringExtItem swhois;
|
||||
CommandSwhois(Module* Creator) : Command(Creator,"SWHOIS", 2,2), swhois("swhois", Creator)
|
||||
CommandSwhois(Module* Creator)
|
||||
: Command(Creator, "SWHOIS", 2, 2)
|
||||
, swhois("swhois", ExtensionItem::EXT_USER, Creator)
|
||||
{
|
||||
flags_needed = 'o'; syntax = "<nick> :<swhois>";
|
||||
TRANSLATE2(TR_NICK, TR_TEXT);
|
||||
|
@ -90,7 +90,7 @@ class FlagExtItem : public ExtensionItem
|
||||
{
|
||||
public:
|
||||
FlagExtItem(const std::string& key, Module* owner)
|
||||
: ExtensionItem(key, owner)
|
||||
: ExtensionItem(key, ExtensionItem::EXT_CHANNEL, owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ class CommandWatch : public Command
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
CommandWatch(Module* parent, unsigned int &maxwatch) : Command(parent,"WATCH", 0), MAX_WATCH(maxwatch), ext("watchlist", parent)
|
||||
CommandWatch(Module* parent, unsigned int &maxwatch) : Command(parent,"WATCH", 0), MAX_WATCH(maxwatch), ext("watchlist", ExtensionItem::EXT_USER, parent)
|
||||
{
|
||||
syntax = "[C|L|S]|[+|-<nick>]";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user