mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Server part of CAP stuff
This introduces the code for modules to request CAPs on the IRC server. They will get a callback when the capability was accepted or rejected. Thanks to DarthGandalf for this patch. This should turn DarthGandalf and tomaw into happy znc users again. ;) git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2099 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
34
Modules.cpp
34
Modules.cpp
@@ -455,6 +455,10 @@ CModule::EModRet CModule::OnChanNotice(CNick& Nick, CChan& Channel, CString& sMe
|
||||
CModule::EModRet CModule::OnTopic(CNick& Nick, CChan& Channel, CString& sTopic) { return CONTINUE; }
|
||||
CModule::EModRet CModule::OnTimerAutoJoin(CChan& Channel) { return CONTINUE; }
|
||||
|
||||
bool CModule::OnServerCapAvailable(const CString& sCap) { return false; }
|
||||
void CModule::OnServerCapAccepted(const CString& sCap) {}
|
||||
void CModule::OnServerCapRejected(const CString& sCap) {}
|
||||
|
||||
bool CModule::PutIRC(const CString& sLine) {
|
||||
return (m_pUser) ? m_pUser->PutIRC(sLine) : false;
|
||||
}
|
||||
@@ -597,6 +601,36 @@ bool CModules::OnModCommand(const CString& sCommand) { MODUNLOADCHK(OnModCommand
|
||||
bool CModules::OnModNotice(const CString& sMessage) { MODUNLOADCHK(OnModNotice(sMessage)); return false; }
|
||||
bool CModules::OnModCTCP(const CString& sMessage) { MODUNLOADCHK(OnModCTCP(sMessage)); return false; }
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
bool CModules::OnServerCapAccepted(const CString& sCap) { MODUNLOADCHK(OnServerCapAccepted(sCap)); return false; }
|
||||
bool CModules::OnServerCapRejected(const CString& sCap) { MODUNLOADCHK(OnServerCapRejected(sCap)); return false; }
|
||||
|
||||
////////////////////
|
||||
// CGlobalModules //
|
||||
////////////////////
|
||||
|
||||
Reference in New Issue
Block a user