diff options
author | Adam <Adam@anope.org> | 2013-04-10 22:26:40 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-04-10 22:26:40 -0500 |
commit | 207c46c871e85b55ae66acc456c6bc412c0c79f9 (patch) | |
tree | 27b07dc9d1e0ee068872ec7841920eea9b846b65 /modules/commands/os_modinfo.cpp | |
parent | 957cb2bf93d77a5ebb97d945b0656bd1e7bec164 (diff) |
Move some of the modules in extras/ that arent really extra out of extras. Mark our modules as VENDOR and allow modules to have multple types.
Diffstat (limited to 'modules/commands/os_modinfo.cpp')
-rw-r--r-- | modules/commands/os_modinfo.cpp | 199 |
1 files changed, 78 insertions, 121 deletions
diff --git a/modules/commands/os_modinfo.cpp b/modules/commands/os_modinfo.cpp index 014418e6e..b6f793796 100644 --- a/modules/commands/os_modinfo.cpp +++ b/modules/commands/os_modinfo.cpp @@ -29,7 +29,7 @@ class CommandOSModInfo : public Command Module *m = ModuleManager::FindModule(file); if (m) { - source.Reply(_("Module: \002%s\002 Version: \002%s\002 Author: \002%s\002 loaded: \002%s\002"), m->name.c_str(), !m->version.empty() ? m->version.c_str() : "?", !m->author.empty() ? m->author.c_str() : "?", Anope::strftime(m->created).c_str()); + source.Reply(_("Module: \002%s\002 Version: \002%s\002 Author: \002%s\002 loaded: \002%s\002"), m->name.c_str(), !m->version.empty() ? m->version.c_str() : "?", !m->author.empty() ? m->author.c_str() : "Unknown", Anope::strftime(m->created).c_str()); std::vector<Anope::string> servicekeys = Service::GetServiceKeys("Command"); for (unsigned i = 0; i < servicekeys.size(); ++i) @@ -76,157 +76,115 @@ class CommandOSModList : public Command CommandOSModList(Module *creator) : Command(creator, "operserv/modlist", 0, 1) { this->SetDesc(_("List loaded modules")); - this->SetSyntax(_("[Core|3rd|protocol|encryption|supported]")); + this->SetSyntax(_("[all|third|vendor|database|encryption|pseudoclient|protocol]")); } void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { const Anope::string ¶m = !params.empty() ? params[0] : ""; + bool third = false, extra = false, vendor = false, database = false, encryption = false, pseudoclient = false, protocol = false; + + if (param.equals_ci("all")) + third = extra = vendor = database = encryption = pseudoclient = protocol = true; + else if (param.equals_ci("third")) + third = true; + else if (param.equals_ci("vendor")) + vendor = true; + else if (param.equals_ci("database")) + database = true; + else if (param.equals_ci("encryption")) + encryption = true; + else if (param.equals_ci("pseudoclient")) + pseudoclient = true; + else if (param.equals_ci("protocol")) + protocol = true; + else + third = extra = database = encryption = protocol = true; + + Module *protomod = ModuleManager::FindFirstOf(PROTOCOL); + + source.Reply(_("Current module list:")); + int count = 0; - int showCore = 0; - int showThird = 1; - int showProto = 1; - int showEnc = 1; - int showSupported = 1; - int showDB = 1; - - char core[] = "Core"; - char third[] = "3rd"; - char proto[] = "Protocol"; - char enc[] = "Encryption"; - char supported[] = "Supported"; - char db[] = "Database"; - - if (!param.empty()) + for (std::list<Module *>::iterator it = ModuleManager::Modules.begin(), it_end = ModuleManager::Modules.end(); it != it_end; ++it) { - if (param.equals_ci(core)) + Module *m = *it; + + bool show = false; + Anope::string mtype; + + if (m->type & PROTOCOL) { - showCore = 1; - showThird = 0; - showProto = 0; - showEnc = 0; - showSupported = 0; - showDB = 0; + show |= protocol; + if (!mtype.empty()) + mtype += ", "; + mtype += "Protocol"; } - else if (param.equals_ci(third)) + if (m->type & PSEUDOCLIENT) { - showCore = 0; - showThird = 1; - showSupported = 0; - showProto = 0; - showEnc = 0; - showDB = 0; + show |= pseudoclient; + if (!mtype.empty()) + mtype += ", "; + mtype += "Pseudoclient"; } - else if (param.equals_ci(proto)) + if (m->type & ENCRYPTION) { - showCore = 0; - showThird = 0; - showProto = 1; - showEnc = 0; - showSupported = 0; - showDB = 0; + show |= encryption; + if (!mtype.empty()) + mtype += ", "; + mtype += "Encryption"; } - else if (param.equals_ci(supported)) + if (m->type & DATABASE) { - showCore = 0; - showThird = 0; - showProto = 0; - showSupported = 1; - showEnc = 0; - showDB = 0; + show |= database; + if (!mtype.empty()) + mtype += ", "; + mtype += "Database"; } - else if (param.equals_ci(enc)) + if (m->type & VENDOR) { - showCore = 0; - showThird = 0; - showProto = 0; - showSupported = 0; - showEnc = 1; - showDB = 0; + show |= vendor; + if (!mtype.empty()) + mtype += ", "; + mtype += "Vendor"; } - else if (param.equals_ci(db)) + if (m->type & EXTRA) { - showCore = 0; - showThird = 0; - showProto = 0; - showSupported = 0; - showEnc = 0; - showDB = 1; + show |= extra; + if (!mtype.empty()) + mtype += ", "; + mtype += "Extra"; + } + if (m->type & THIRD) + { + show |= third; + if (!mtype.empty()) + mtype += ", "; + mtype += "Third"; } - } - - Module *protocol = ModuleManager::FindFirstOf(PROTOCOL); - source.Reply(_("Current module list:")); + if (!show) + continue; + else if (m->type & PROTOCOL && param.empty() && m != protomod) + continue; - for (std::list<Module *>::iterator it = ModuleManager::Modules.begin(), it_end = ModuleManager::Modules.end(); it != it_end; ++it) - { - Module *m = *it; + ++count; - switch (m->type) - { - case CORE: - if (showCore) - { - source.Reply(_("Module: \002%s\002 [%s] [%s]"), m->name.c_str(), m->version.c_str(), core); - ++count; - } - break; - case THIRD: - if (showThird) - { - source.Reply(_("Module: \002%s\002 [%s] [%s]"), m->name.c_str(), m->version.c_str(), third); - ++count; - } - break; - case PROTOCOL: - if (m != protocol) - break; - if (showProto) - { - source.Reply(_("Module: \002%s\002 [%s] [%s]"), m->name.c_str(), m->version.c_str(), proto); - ++count; - } - break; - case SUPPORTED: - if (showSupported) - { - source.Reply(_("Module: \002%s\002 [%s] [%s]"), m->name.c_str(), m->version.c_str(), supported); - ++count; - } - break; - case ENCRYPTION: - if (showEnc) - { - source.Reply(_("Module: \002%s\002 [%s] [%s]"), m->name.c_str(), m->version.c_str(), enc); - ++count; - } - break; - case DATABASE: - if (showDB) - { - source.Reply(_("Module: \002%s\002 [%s] [%s]"), m->name.c_str(), m->version.c_str(), db); - ++count; - } - break; - default: - break; - } + source.Reply(_("Module: \002%s\002 [%s] [%s]"), m->name.c_str(), m->version.c_str(), mtype.c_str()); } + if (!count) - source.Reply(_("No modules currently loaded.")); + source.Reply(_("No modules currently loaded matching that criteria.")); else source.Reply(_("%d modules loaded."), count); - - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override { this->SendSyntax(source); source.Reply(" "); - source.Reply(_("Lists all currently loaded modules.")); + source.Reply(_("Lists currently loaded modules.")); return true; } }; @@ -237,10 +195,9 @@ class OSModInfo : public Module CommandOSModList commandosmodlist; public: - OSModInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), + OSModInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandosmodinfo(this), commandosmodlist(this) { - this->SetAuthor("Anope"); } }; |