mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 10:39:02 -04:00
Allow contrib modules to specify their own module version.
This commit is contained in:
parent
31c8a3b01a
commit
4e947b8733
@ -218,6 +218,13 @@ protected:
|
||||
*/
|
||||
Module(int mprops, const std::string& mdesc);
|
||||
|
||||
/** Initializes a new instance of the Module class.
|
||||
* @param mprops The properties of this module.
|
||||
* @param mversion The version of this module (for contrib modules).
|
||||
* @param mdesc A description of this module.
|
||||
*/
|
||||
Module(int mprops, const std::string& mversion, const std::string& mdesc);
|
||||
|
||||
/** Detach an event from this module
|
||||
* @param i Event type to detach
|
||||
*/
|
||||
@ -250,6 +257,9 @@ public:
|
||||
/** The properties of this module. */
|
||||
const int properties;
|
||||
|
||||
/** The version of this module. */
|
||||
const std::string version;
|
||||
|
||||
/** Module setup
|
||||
* \exception ModuleException Throwing this class, or any class derived from ModuleException, causes loading of the module to abort.
|
||||
*/
|
||||
@ -275,6 +285,9 @@ public:
|
||||
/** Retrieves a string that represents the properties of this module. */
|
||||
std::string GetPropertyString() const;
|
||||
|
||||
/** Retrieves the version of the module. */
|
||||
std::string GetVersion() const;
|
||||
|
||||
/** This method is called when you should reload module specific configuration:
|
||||
* on boot, on a /REHASH and on module load.
|
||||
* @param status The current status, can be inspected for more information.
|
||||
|
@ -64,8 +64,8 @@ CmdResult CommandModules::Handle(User* user, const Params& parameters)
|
||||
bool has_priv = IS_LOCAL(user) && user->HasPrivPermission("servers/auspex");
|
||||
for (const auto& [modname, mod] : ServerInstance->Modules.GetModules())
|
||||
{
|
||||
const char* version = has_priv ? mod->ModuleDLL->GetVersion() : "*";
|
||||
const std::string props = has_priv ? mod->GetPropertyString() : "*";
|
||||
const auto version = has_priv ? mod->GetVersion() : "*";
|
||||
const auto props = has_priv ? mod->GetPropertyString() : "*";
|
||||
user->WriteRemoteNumeric(RPL_MODLIST, ModuleManager::ShrinkModName(modname), version, props, mod->description);
|
||||
}
|
||||
user->WriteRemoteNumeric(RPL_ENDOFMODLIST, "End of MODULES list");
|
||||
|
@ -82,12 +82,8 @@ bool ModuleManager::Load(const std::string& modname, bool defer)
|
||||
newmod->ReadConfig(confstatus);
|
||||
}
|
||||
|
||||
const char* version = newhandle->GetVersion();
|
||||
if (!version)
|
||||
version = "unknown";
|
||||
|
||||
ServerInstance->Logs.Normal("MODULE", "New module introduced: {} (version {}, properties {})",
|
||||
filename, version, newmod->GetPropertyString());
|
||||
filename, newmod->GetVersion(), newmod->GetPropertyString());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -46,8 +46,14 @@ void dynamic_reference_base::reset_all()
|
||||
}
|
||||
|
||||
Module::Module(int mprops, const std::string& mdesc)
|
||||
: Module(mprops, "", mdesc)
|
||||
{
|
||||
}
|
||||
|
||||
Module::Module(int mprops, const std::string& mversion, const std::string& mdesc)
|
||||
: description(mdesc)
|
||||
, properties(mprops)
|
||||
, version(mversion)
|
||||
{
|
||||
}
|
||||
|
||||
@ -83,6 +89,15 @@ std::string Module::GetPropertyString() const
|
||||
return propstr;
|
||||
}
|
||||
|
||||
std::string Module::GetVersion() const
|
||||
{
|
||||
if (!version.empty())
|
||||
return version;
|
||||
|
||||
const auto* dll_version = ModuleDLL->GetVersion();
|
||||
return dll_version ? dll_version : "unknown";
|
||||
}
|
||||
|
||||
void Module::DetachEvent(Implementation i)
|
||||
{
|
||||
ServerInstance->Modules.Detach(i, this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user