Added some more global module support

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@349 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
prozacx
2005-05-22 02:03:31 +00:00
parent 3dde793e62
commit 0bbab8f472
3 changed files with 45 additions and 11 deletions
+8 -3
View File
@@ -677,21 +677,26 @@ CString CModules::FindModPath(const CString& sModule, CUser* pUser) {
return (m_pZNC) ? m_pZNC->FindModPath(sModule) : "";
}
void CModules::GetAvailableMods(set<CModInfo>& ssMods, CZNC* pZNC) {
void CModules::GetAvailableMods(set<CModInfo>& ssMods, CZNC* pZNC, bool bGlobal) {
ssMods.clear();
unsigned int a = 0;
CDir Dir;
Dir.FillByWildcard(pZNC->GetModPath(), "*.so");
for (a = 0; a < Dir.size(); a++) {
CFile& File = *Dir[a];
ssMods.insert(CModInfo(File.GetShortName(), File.GetLongName(), false));
if ((File.GetShortName().Left(2).CaseCmp("g_") == 0) == bGlobal) {
ssMods.insert(CModInfo(File.GetShortName(), File.GetLongName(), false, bGlobal));
}
}
Dir.FillByWildcard(_MODDIR_, "*.so");
for (a = 0; a < Dir.size(); a++) {
CFile& File = *Dir[a];
ssMods.insert(CModInfo(File.GetShortName(), File.GetLongName(), true));
if ((File.GetShortName().Left(2).CaseCmp("g_") == 0) == bGlobal) {
ssMods.insert(CModInfo(File.GetShortName(), File.GetLongName(), true, bGlobal));
}
}
}
+5 -2
View File
@@ -96,8 +96,9 @@ private:
class CModInfo {
public:
CModInfo(const CString& sName, const CString& sPath, bool bSystem) {
CModInfo(const CString& sName, const CString& sPath, bool bSystem, bool bGlobal) {
m_bSystem = bSystem;
m_bGlobal = bGlobal;
m_sName = sName;
m_sPath = sPath;
}
@@ -111,10 +112,12 @@ public:
const CString& GetName() const { return m_sName; }
const CString& GetPath() const { return m_sPath; }
bool IsSystem() const { return m_bSystem; }
bool IsGlobal() const { return m_bGlobal; }
// !Getters
private:
protected:
bool m_bSystem;
bool m_bGlobal;
CString m_sName;
CString m_sPath;
};
@@ -282,7 +285,7 @@ public:
bool ReloadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg);
CString FindModPath(const CString& sModule, CUser* pUser = NULL);
static void GetAvailableMods(set<CModInfo>& ssMods, CZNC* pZNC);
static void GetAvailableMods(set<CModInfo>& ssMods, CZNC* pZNC, bool bGlobal = false);
private:
CZNC* m_pZNC;
+32 -6
View File
@@ -283,6 +283,32 @@ bool CZNC::WriteNewConfig(const CString& sConfig) {
vsLines.push_back("ListenPort = " + CString((bAnswer) ? "+" : "") + CString::ToString(uPort));
// !ListenPort
#ifdef _MODULES
set<CModInfo> ssGlobalMods;
CModules::GetAvailableMods(ssGlobalMods, this, true);
if (ssGlobalMods.size()) {
CUtils::PrintMessage("");
CUtils::PrintMessage("-- Global Modules --");
CUtils::PrintMessage("");
if (CUtils::GetBoolInput("Do you want to load any global modules?")) {
for (set<CModInfo>::iterator it = ssGlobalMods.begin(); it != ssGlobalMods.end(); it++) {
const CModInfo& Info = *it;
CString sName = Info.GetName();
if (sName.Right(3).CaseCmp(".so") == 0) {
sName.RightChomp(3);
}
if (CUtils::GetBoolInput("Load global module <\033[1m" + sName + "\033[22m>?", false)) {
vsLines.push_back("LoadModule = " + sName);
}
}
}
}
#endif
// User
CUtils::PrintMessage("");
CUtils::PrintMessage("Now we need to setup a user...");
@@ -324,17 +350,17 @@ bool CZNC::WriteNewConfig(const CString& sConfig) {
}
#ifdef _MODULES
set<CModInfo> ssMods;
CModules::GetAvailableMods(ssMods, this);
set<CModInfo> ssUserMods;
CModules::GetAvailableMods(ssUserMods, this);
if (ssMods.size()) {
if (ssUserMods.size()) {
vsLines.push_back("");
CUtils::PrintMessage("");
CUtils::PrintMessage("-- Modules --");
CUtils::PrintMessage("-- User Modules --");
CUtils::PrintMessage("");
if (CUtils::GetBoolInput("Do you want to automatically load any modules at all?")) {
for (set<CModInfo>::iterator it = ssMods.begin(); it != ssMods.end(); it++) {
if (CUtils::GetBoolInput("Do you want to automatically load any user modules for this user?")) {
for (set<CModInfo>::iterator it = ssUserMods.begin(); it != ssUserMods.end(); it++) {
const CModInfo& Info = *it;
CString sName = Info.GetName();