Exemplo n.º 1
0
// Why MODHALTCHK works only with functions returning EModRet ? :(
bool CModules::OnServerCapAvailable(const CString& sCap) {
	bool bResult = false;
	for (unsigned int a = 0; a < size(); ++a) {
		try {
			CModule* pMod = (*this)[a];
			CClient* pOldClient = pMod->GetClient();
			pMod->SetClient(m_pClient);
			if (m_pUser) {
				CUser* pOldUser = pMod->GetUser();
				pMod->SetUser(m_pUser);
				bResult |= pMod->OnServerCapAvailable(sCap);
				pMod->SetUser(pOldUser);
			} else {
				// WTF? Is that possible?
				bResult |= pMod->OnServerCapAvailable(sCap);
			}
			pMod->SetClient(pOldClient);
		} catch (CModule::EModException e) {
			if (CModule::UNLOAD == e) {
				UnloadModule((*this)[a]->GetModName());
			}
		}
	}
	return bResult;
}
Exemplo n.º 2
0
Arquivo: Modules.cpp Projeto: SjB/znc
// Maybe create new macro for this?
bool CModules::IsClientCapSupported(CClient* pClient, const CString& sCap, bool bState) {
	bool bResult = false;
	for (unsigned int a = 0; a < size(); ++a) {
		try {
			CModule* pMod = (CModule*) (*this)[a];
			CClient* pOldClient = pMod->GetClient();
			pMod->SetClient(m_pClient);
			if (m_pUser) {
				CUser* pOldUser = pMod->GetUser();
				pMod->SetUser(m_pUser);
				bResult |= pMod->IsClientCapSupported(pClient, sCap, bState);
				pMod->SetUser(pOldUser);
			} else {
				// WTF? Is that possible?
				bResult |= pMod->IsClientCapSupported(pClient, sCap, bState);
			}
			pMod->SetClient(pOldClient);
		} catch (CModule::EModException e) {
			if (CModule::UNLOAD == e) {
				UnloadModule((*this)[a]->GetModName());
			}
		}
	}
	return bResult;
}