Add CIRCNetwork::LoadModule() helper

Makes it easier to retry loading replacement modules when
loading retired modules fail.
This commit is contained in:
J-P Nurmi
2014-09-26 15:39:05 +02:00
parent 5206e71bdb
commit eaf2d737d7
2 changed files with 20 additions and 8 deletions

View File

@@ -377,35 +377,32 @@ bool CIRCNetwork::ParseConfig(CConfig *pConfig, CString& sError, bool bUpgrade)
for (vit = vsList.begin(); vit != vsList.end(); ++vit) {
CString sValue = *vit;
CString sModName = sValue.Token(0);
CString sNotice = "Loading network module [" + sModName + "]";
// XXX Legacy crap, added in ZNC 0.203, modified in 0.207
// Note that 0.203 == 0.207
if (sModName == "away") {
CUtils::PrintMessage("NOTICE: [away] was renamed, "
"loading [awaystore] instead");
sNotice = "NOTICE: [away] was renamed, loading [awaystore] instead";
sModName = "awaystore";
}
// XXX Legacy crap, added in ZNC 0.207
if (sModName == "autoaway") {
CUtils::PrintMessage("NOTICE: [autoaway] was renamed, "
"loading [awaystore] instead");
sNotice = "NOTICE: [autoaway] was renamed, loading [awaystore] instead";
sModName = "awaystore";
}
// XXX Legacy crap, added in 1.1; fakeonline module was dropped in 1.0 and returned in 1.1
if (sModName == "fakeonline") {
CUtils::PrintMessage("NOTICE: [fakeonline] was renamed, loading [modules_online] instead");
sNotice = "NOTICE: [fakeonline] was renamed, loading [modules_online] instead";
sModName = "modules_online";
}
CUtils::PrintAction("Loading network module [" + sModName + "]");
CString sModRet;
CString sArgs = sValue.Token(1, true);
bool bModRet = GetModules().LoadModule(sModName, sArgs, CModInfo::NetworkModule, GetUser(), this, sModRet);
bool bModRet = LoadModule(sModName, sArgs, sNotice, sModRet);
CUtils::PrintStatus(bModRet, sModRet);
if (!bModRet) {
sError = sModRet;
return false;
@@ -1351,3 +1348,17 @@ CString& CIRCNetwork::ExpandString(const CString& sStr, CString& sRet) const {
return m_pUser->ExpandString(sRet, sRet);
}
bool CIRCNetwork::LoadModule(const CString& sModName, const CString& sArgs, const CString& sNotice, CString& sError)
{
CUtils::PrintAction(sNotice);
CString sModRet;
bool bModRet = GetModules().LoadModule(sModName, sArgs, CModInfo::NetworkModule, GetUser(), this, sModRet);
CUtils::PrintStatus(bModRet, sModRet);
if (!bModRet) {
sError = sModRet;
}
return bModRet;
}