Make UpdateModule reload the module for every module type

UpdateModule has been moved to CZNC because it doesn't really fit into
CUser. The new UpdateModule will reload the module for global modules,
user modules and network modules.

Fixes #69
This commit is contained in:
Kyle Fuller
2011-10-19 10:32:04 +00:00
parent 3a7d0150cf
commit 8659d7224a
5 changed files with 98 additions and 40 deletions
-27
View File
@@ -411,33 +411,6 @@ bool CUser::ParseConfig(CConfig* pConfig, CString& sError) {
return true;
}
bool CUser::UpdateModule(const CString &sModule) {
const map<CString,CUser*>& Users = CZNC::Get().GetUserMap();
map<CString,CUser*>::const_iterator it;
map<CUser*, CString> Affected;
map<CUser*, CString>::iterator it2;
bool error = false;
for (it = Users.begin(); it != Users.end(); ++it) {
CModule *pMod = it->second->GetModules().FindModule(sModule);
if (pMod) {
Affected[it->second] = pMod->GetArgs();
it->second->GetModules().UnloadModule(pMod->GetModName());
}
}
CString sErr;
for (it2 = Affected.begin(); it2 != Affected.end(); ++it2) {
if (!it2->first->GetModules().LoadModule(sModule, it2->second, CModInfo::UserModule, it2->first, NULL, sErr)) {
error = true;
DEBUG("Failed to reload [" << sModule << "] for [" << it2->first->GetUserName()
<< "]: " << sErr);
}
}
return !error;
}
CIRCNetwork* CUser::AddNetwork(const CString &sNetwork) {
if (!CIRCNetwork::IsValidNetwork(sNetwork) || FindNetwork(sNetwork)) {
return NULL;