Implement cap negotiation 3.2 on server side

Used for "server-dependent" caps which already rely on sending NEW and
DEL to client. This functionality is not yet available for caps added by
modules.
This commit is contained in:
Alexey Sokolov
2023-01-09 01:08:04 +00:00
parent d49168b93f
commit c15fc63c55
15 changed files with 201 additions and 74 deletions

View File

@@ -999,6 +999,9 @@ CModule::EModRet CModule::OnSendToIRCMessage(CMessage& Message) {
}
bool CModule::OnServerCapAvailable(const CString& sCap) { return false; }
bool CModule::OnServerCap302Available(const CString& sCap, const CString& sValue) {
return OnServerCapAvailable(sCap);
}
void CModule::OnServerCapResult(const CString& sCap, bool bSuccess) {}
bool CModule::PutIRC(const CString& sLine) {
@@ -1491,7 +1494,7 @@ bool CModules::OnModCTCP(const CString& sMessage) {
}
// Why MODHALTCHK works only with functions returning EModRet ? :(
bool CModules::OnServerCapAvailable(const CString& sCap) {
bool CModules::OnServerCapAvailable(const CString& sCap, const CString& sValue) {
bool bResult = false;
for (CModule* pMod : *this) {
try {
@@ -1500,11 +1503,11 @@ bool CModules::OnServerCapAvailable(const CString& sCap) {
if (m_pUser) {
CUser* pOldUser = pMod->GetUser();
pMod->SetUser(m_pUser);
bResult |= pMod->OnServerCapAvailable(sCap);
bResult |= pMod->OnServerCap302Available(sCap, sValue);
pMod->SetUser(pOldUser);
} else {
// WTF? Is that possible?
bResult |= pMod->OnServerCapAvailable(sCap);
bResult |= pMod->OnServerCap302Available(sCap, sValue);
}
pMod->SetClient(pOldClient);
} catch (const CModule::EModException& e) {