From a3bc3f687754877ec6cbc49449abed63145effa1 Mon Sep 17 00:00:00 2001 From: psychon Date: Thu, 5 Aug 2010 12:13:44 +0000 Subject: [PATCH] Reduce number of module hooks The new hooks OnServerCapAccepted() and OnServerCapRejected() are replaced by OnServerCapResult(). This should force people who want to use this to handle possible failures in requesting the capability. Again, thanks to DarthGandalf for the patch. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2100 726aef4b-f618-498e-8847-2d620e286838 --- IRCSock.cpp | 4 ++-- Modules.cpp | 6 ++---- Modules.h | 15 ++++++--------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/IRCSock.cpp b/IRCSock.cpp index fdeab932..ce42ee60 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -688,7 +688,7 @@ void CIRCSock::ReadLine(const CString& sData) { } else if (sSubCmd == "ACK") { sArgs.Trim(); m_ssPendingCaps.erase(sArgs); - MODULECALL(OnServerCapAccepted(sArgs), m_pUser, NULL, ); + MODULECALL(OnServerCapResult(sArgs, true), m_pUser, NULL, ); if ("multi-prefix" == sArgs) { m_bNamesx = true; } else if ("userhost-in-names" == sArgs) { @@ -700,7 +700,7 @@ void CIRCSock::ReadLine(const CString& sData) { // capability with length of name more than 100 characters. sArgs.Trim(); m_ssPendingCaps.erase(sArgs); - MODULECALL(OnServerCapRejected(sArgs), m_pUser, NULL, ); + MODULECALL(OnServerCapResult(sArgs, false), m_pUser, NULL, ); } if (m_ssPendingCaps.empty()) { diff --git a/Modules.cpp b/Modules.cpp index 62af05a5..b144cde2 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -456,8 +456,7 @@ CModule::EModRet CModule::OnTopic(CNick& Nick, CChan& Channel, CString& sTopic) 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) {} +void CModule::OnServerCapResult(const CString& sCap, bool bSuccess) {} bool CModule::PutIRC(const CString& sLine) { return (m_pUser) ? m_pUser->PutIRC(sLine) : false; @@ -628,8 +627,7 @@ bool CModules::OnServerCapAvailable(const CString& sCap) { return bResult; } -bool CModules::OnServerCapAccepted(const CString& sCap) { MODUNLOADCHK(OnServerCapAccepted(sCap)); return false; } -bool CModules::OnServerCapRejected(const CString& sCap) { MODUNLOADCHK(OnServerCapRejected(sCap)); return false; } +bool CModules::OnServerCapResult(const CString& sCap, bool bSuccess) { MODUNLOADCHK(OnServerCapResult(sCap, bSuccess)); return false; } //////////////////// // CGlobalModules // diff --git a/Modules.h b/Modules.h index bed2e5d8..ae10feaf 100644 --- a/Modules.h +++ b/Modules.h @@ -644,14 +644,12 @@ public: * needs to turn it on with CAP REQ. */ virtual bool OnServerCapAvailable(const CString& sCap); - /** Called for every CAP accepted by server (with CAP ACK after our CAP REQ). - * @param sCap capability accepted by server. + /** Called for every CAP accepted or rejected by server + * (with CAP ACK or CAP NAK after our CAP REQ). + * @param sCap capability accepted/rejected by server. + * @param sSuccess true if capability was accepted, false if rejected. */ - virtual void OnServerCapAccepted(const CString& sCap); - /** Called for every CAP rejected by server (with CAP NAK after our CAP REQ). - * @param sCap capability rejected by server. - */ - virtual void OnServerCapRejected(const CString& sCap); + virtual void OnServerCapResult(const CString& sCap, bool bSuccess); /** This module hook is called just before ZNC tries to join a channel * by itself because it's in the config but wasn't joined yet. @@ -884,8 +882,7 @@ public: bool OnTimerAutoJoin(CChan& Channel); bool OnServerCapAvailable(const CString& sCap); - bool OnServerCapAccepted(const CString& sCap); - bool OnServerCapRejected(const CString& sCap); + bool OnServerCapResult(const CString& sCap, bool bSuccess); CModule* FindModule(const CString& sModule) const; bool LoadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg);