mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Add module calls for client CAPs
This commit adds new module calls which make it possibly to announce new capabilities from a module. Thanks to DarthGandalf for the patch and for not going mad from my comments. :) git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2071 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
39
Modules.cpp
39
Modules.cpp
@@ -503,6 +503,9 @@ void CGlobalModule::OnClientConnect(CZNCSock* pClient, const CString& sHost, uns
|
||||
CModule::EModRet CGlobalModule::OnLoginAttempt(CSmartPtr<CAuthBase> Auth) { return CONTINUE; }
|
||||
void CGlobalModule::OnFailedLogin(const CString& sUsername, const CString& sRemoteIP) {}
|
||||
CModule::EModRet CGlobalModule::OnUnknownUserRaw(CClient* pClient, CString& sLine) { return CONTINUE; }
|
||||
void CGlobalModule::OnClientCapLs(SCString& ssCaps) {}
|
||||
bool CGlobalModule::IsClientCapSupported(const CString& sCap, bool bState) { return false; }
|
||||
void CGlobalModule::OnClientCapRequest(CClient* pClient, const CString& sCap, bool bState) {}
|
||||
|
||||
|
||||
CModules::CModules() {
|
||||
@@ -627,6 +630,42 @@ bool CGlobalModules::OnUnknownUserRaw(CClient* pClient, CString& sLine) {
|
||||
GLOBALMODHALTCHK(OnUnknownUserRaw(pClient, sLine));
|
||||
}
|
||||
|
||||
void CGlobalModules::OnClientCapLs(SCString& ssCaps) {
|
||||
GLOBALMODCALL(OnClientCapLs(ssCaps));
|
||||
}
|
||||
|
||||
// Maybe create new macro for this?
|
||||
bool CGlobalModules::IsClientCapSupported(const CString& sCap, bool bState) {
|
||||
bool bResult = false;
|
||||
for (unsigned int a = 0; a < size(); ++a) {
|
||||
try {
|
||||
CGlobalModule* pMod = (CGlobalModule*) (*this)[a];
|
||||
CClient* pOldClient = pMod->GetClient();
|
||||
pMod->SetClient(m_pClient);
|
||||
if (m_pUser) {
|
||||
CUser* pOldUser = pMod->GetUser();
|
||||
pMod->SetUser(m_pUser);
|
||||
bResult |= pMod->IsClientCapSupported(sCap, bState);
|
||||
pMod->SetUser(pOldUser);
|
||||
} else {
|
||||
// WTF? Is that possible?
|
||||
bResult |= pMod->IsClientCapSupported(sCap, bState);
|
||||
}
|
||||
pMod->SetClient(pOldClient);
|
||||
} catch (CModule::EModException e) {
|
||||
if (CModule::UNLOAD == e) {
|
||||
UnloadModule((*this)[a]->GetModName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
|
||||
void CGlobalModules::OnClientCapRequest(CClient* pClient, const CString& sCap, bool bState) {
|
||||
GLOBALMODCALL(OnClientCapRequest(pClient, sCap, bState));
|
||||
}
|
||||
|
||||
|
||||
CModule* CModules::FindModule(const CString& sModule) const {
|
||||
for (unsigned int a = 0; a < size(); a++) {
|
||||
if (sModule.Equals((*this)[a]->GetModName())) {
|
||||
|
||||
Reference in New Issue
Block a user