Skip to content

Commit

Permalink
Fix implicit context of OnSendTo* hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthGandalf committed Jan 11, 2015
1 parent 5608e4f commit af1e986
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
28 changes: 14 additions & 14 deletions include/znc/main.h
Expand Up @@ -77,30 +77,30 @@ extern bool ZNC_NO_NEED_TO_DO_ANYTHING_ON_MODULE_CALL_EXITER;

#define _USERMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER) \
do { \
assert(macUSER != NULL); \
bool bGlobalExited = false; \
_GLOBALMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, &bGlobalExited); \
if (bGlobalExited) { \
*macEXITER = true; \
break; \
} \
CModules& UMods = macUSER->GetModules(); \
CIRCNetwork* pOldUNetwork = UMods.GetNetwork(); \
CClient* pOldUClient = UMods.GetClient(); \
UMods.SetNetwork(macNETWORK); \
UMods.SetClient(macCLIENT); \
if (UMods.macFUNC) { \
UMods.SetNetwork(pOldUNetwork); \
UMods.SetClient(pOldUClient); \
*macEXITER = true; \
} \
UMods.SetNetwork(pOldUNetwork); \
UMods.SetClient(pOldUClient); \
if (macUSER != nullptr) { \
CModules& UMods = macUSER->GetModules(); \
CIRCNetwork* pOldUNetwork = UMods.GetNetwork(); \
CClient* pOldUClient = UMods.GetClient(); \
UMods.SetNetwork(macNETWORK); \
UMods.SetClient(macCLIENT); \
if (UMods.macFUNC) { \
UMods.SetNetwork(pOldUNetwork); \
UMods.SetClient(pOldUClient); \
*macEXITER = true; \
} \
UMods.SetNetwork(pOldUNetwork); \
UMods.SetClient(pOldUClient); \
} \
} while (false)

#define NETWORKMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER) \
do { \
assert(macUSER != NULL); \
bool bUserExited = false; \
_USERMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, &bUserExited); \
if (bUserExited) { \
Expand Down
2 changes: 1 addition & 1 deletion src/Client.cpp
Expand Up @@ -770,7 +770,7 @@ CString CClient::GetFullName() const {
void CClient::PutClient(const CString& sLine) {
bool bReturn = false;
CString sCopy = sLine;
ALLMODULECALL(OnSendToClient(sCopy, *this), &bReturn);
NETWORKMODULECALL(OnSendToClient(sCopy, *this), m_pUser, m_pNetwork, this, &bReturn);
if (bReturn) return;
DEBUG("(" << GetFullName() << ") ZNC -> CLI [" << sCopy << "]");
Write(sCopy + "\r\n");
Expand Down
2 changes: 1 addition & 1 deletion src/IRCSock.cpp
Expand Up @@ -1049,7 +1049,7 @@ void CIRCSock::TrySend() {
m_iSendsAllowed--;
bool bSkip = false;
CString& sLine = m_vsSendQueue.front();
ALLMODULECALL(OnSendToIRC(sLine), &bSkip);
IRCSOCKMODULECALL(OnSendToIRC(sLine), &bSkip);
if (!bSkip) {;
DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" << m_pNetwork->GetName() << ") ZNC -> IRC [" << sLine << "]");
Write(sLine + "\r\n");
Expand Down

0 comments on commit af1e986

Please sign in to comment.