From 68754d27819f27dd7f5ed9fb9c599029d7096fcd Mon Sep 17 00:00:00 2001 From: cflakes Date: Mon, 11 Jan 2010 12:49:00 +0000 Subject: [PATCH] Update to the makeconf procedure... We now only ask for 9 common modules, instead of for all 20 or 30. This will keep people from loading the sample or saslauth (or away) modules and thereby avoid stupid questions. Instead of listing and asking for all modules, we only show the most widely used ones plus "And X other (uncommon) modules. You can enable those later.". To add a module, append its name to the array in CZNC::FilterUncommonModules(). git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1706 726aef4b-f618-498e-8847-2d620e286838 --- znc.cpp | 32 ++++++++++++++++++++++++++++++++ znc.h | 1 + 2 files changed, 33 insertions(+) diff --git a/znc.cpp b/znc.cpp index 697ccda1..9b222c54 100644 --- a/znc.cpp +++ b/znc.cpp @@ -681,6 +681,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) { #ifdef _MODULES set ssGlobalMods; GetModules().GetAvailableMods(ssGlobalMods, true); + size_t uNrOtherGlobalMods = FilterUncommonModules(ssGlobalMods); if (ssGlobalMods.size()) { CUtils::PrintMessage(""); @@ -705,6 +706,10 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) { CUtils::PrintMessage(sLine); } + if (uNrOtherGlobalMods > 0) { + CUtils::PrintMessage("And " + CString(uNrOtherGlobalMods) + " other (uncommon) modules. You can enable those later."); + } + CUtils::PrintMessage(""); for (it = ssGlobalMods.begin(); it != ssGlobalMods.end(); it++) { @@ -784,6 +789,7 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) { #ifdef _MODULES set ssUserMods; GetModules().GetAvailableMods(ssUserMods); + size_t uNrOtherUserMods = FilterUncommonModules(ssUserMods); if (ssUserMods.size()) { vsLines.push_back(""); @@ -809,6 +815,10 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) { CUtils::PrintMessage(sLine); } + if (uNrOtherUserMods > 0) { + CUtils::PrintMessage("And " + CString(uNrOtherUserMods) + " other (uncommon) modules. You can enable those later."); + } + CUtils::PrintMessage(""); for (it = ssUserMods.begin(); it != ssUserMods.end(); it++) { @@ -948,6 +958,28 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) { return bFileOpen && CUtils::GetBoolInput("Launch znc now?", true); } +#ifdef _MODULES +size_t CZNC::FilterUncommonModules(set& ssModules) { + const char* ns[] = { "webadmin", "admin", + "chansaver", "keepnick", "simple_away", "partyline", + "kickrejoin", "nickserv", "perform" }; + const set ssNames(ns, ns + sizeof(ns) / sizeof(ns[0])); + + size_t uNrRemoved = 0; + for(set::iterator it = ssModules.begin(); it != ssModules.end(); ) { + if(ssNames.count(it->GetName()) > 0) { + it++; + } else { + set::iterator it2 = it++; + ssModules.erase(it2); + uNrRemoved++; + } + } + + return uNrRemoved; +} +#endif + bool CZNC::ParseConfig(const CString& sConfig) { CString s; diff --git a/znc.h b/znc.h index 82f91a28..c5bd934f 100644 --- a/znc.h +++ b/znc.h @@ -93,6 +93,7 @@ public: const CSockManager& GetManager() const { return m_Manager; } #ifdef _MODULES CGlobalModules& GetModules() { return *m_pModules; } + size_t FilterUncommonModules(set& ssModules); #endif const CString& GetStatusPrefix() const { return m_sStatusPrefix; } const CString& GetCurPath() const { if (!CFile::Exists(m_sCurPath)) { CDir::MakeDir(m_sCurPath); } return m_sCurPath; }