From db21f88584f0a2e3343d2bfbd747e051a38ccdb4 Mon Sep 17 00:00:00 2001 From: psychon Date: Wed, 29 Oct 2008 17:26:30 +0000 Subject: [PATCH] Rename OnUserAttached and OnUserDetached and add OnClientConnect OnUserAttached is renamed to OnClientLogin and OnUserDetached to OnClientDisconnect. This adds some new function with different arguments for the old names to cause warnings from -Woverloaded-virtual while compiling. This patch also adds OnClientConnect() which is called when the low-level raw connection is established. (No SSL-handshake was done at this point yet!) git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1266 726aef4b-f618-498e-8847-2d620e286838 --- Client.cpp | 4 ++-- Modules.cpp | 13 +++++++++---- Modules.h | 12 ++++++++---- modules/away.cpp | 4 ++-- modules/awaynick.cpp | 4 ++-- modules/email.cpp | 4 ++-- modules/modperl.cpp | 4 ++-- modules/partyline.cpp | 4 ++-- modules/schat.cpp | 2 +- modules/simple_away.cpp | 4 ++-- modules/watch.cpp | 2 +- znc.h | 4 +++- 12 files changed, 36 insertions(+), 25 deletions(-) diff --git a/Client.cpp b/Client.cpp index 7c9e6e23..0247bcde 100644 --- a/Client.cpp +++ b/Client.cpp @@ -660,7 +660,7 @@ void CClient::AcceptLogin(CUser& User) { SendMotd(); - MODULECALL(OnUserAttached(), m_pUser, this, ); + MODULECALL(OnClientLogin(), m_pUser, this, ); } void CClient::StartLoginTimeout() { @@ -693,7 +693,7 @@ void CClient::Disconnected() { m_pIRCSock = NULL; - MODULECALL(OnUserDetached(), m_pUser, this, ); + MODULECALL(OnClientDisconnect(), m_pUser, this, ); } void CClient::ReachedMaxBuffer() { diff --git a/Modules.cpp b/Modules.cpp index d16f940c..954d91a9 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -473,8 +473,8 @@ void CModule::OnKick(const CNick& Nick, const CString& sKickedNick, CChan& Chann void CModule::OnJoin(const CNick& Nick, CChan& Channel) {} void CModule::OnPart(const CNick& Nick, CChan& Channel) {} -void CModule::OnUserAttached() {} -void CModule::OnUserDetached() {} +void CModule::OnClientLogin() {} +void CModule::OnClientDisconnect() {} CModule::EModRet CModule::OnUserRaw(CString& sLine) { return CONTINUE; } CModule::EModRet CModule::OnUserCTCPReply(CString& sTarget, CString& sMessage) { return CONTINUE; } CModule::EModRet CModule::OnUserCTCP(CString& sTarget, CString& sMessage) { return CONTINUE; } @@ -539,6 +539,7 @@ bool CModule::PutModNotice(const CString& sLine, const CString& sIdent, const CS /////////////////// CModule::EModRet CGlobalModule::OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan) { return CONTINUE; } CModule::EModRet CGlobalModule::OnDeleteUser(CUser& User) { return CONTINUE; } +void CGlobalModule::OnClientConnect(CClient* pClient, const CString& sHost, unsigned short uPort) {} CModule::EModRet CGlobalModule::OnLoginAttempt(CSmartPtr Auth) { return CONTINUE; } void CGlobalModule::OnFailedLogin(const CString& sUsername, const CString& sRemoteIP) {} @@ -591,8 +592,8 @@ bool CModules::OnRawMode(const CNick& OpNick, CChan& Channel, const CString& sMo bool CModules::OnMode(const CNick& OpNick, CChan& Channel, char uMode, const CString& sArg, bool bAdded, bool bNoChange) { MODUNLOADCHK(OnMode(OpNick, Channel, uMode, sArg, bAdded, bNoChange)); return false; } bool CModules::OnRaw(CString& sLine) { MODHALTCHK(OnRaw(sLine)); } -bool CModules::OnUserAttached() { MODUNLOADCHK(OnUserAttached()); return false; } -bool CModules::OnUserDetached() { MODUNLOADCHK(OnUserDetached()); return false; } +bool CModules::OnClientLogin() { MODUNLOADCHK(OnClientLogin()); return false; } +bool CModules::OnClientDisconnect() { MODUNLOADCHK(OnClientDisconnect()); return false; } bool CModules::OnUserRaw(CString& sLine) { MODHALTCHK(OnUserRaw(sLine)); } bool CModules::OnUserCTCPReply(CString& sTarget, CString& sMessage) { MODHALTCHK(OnUserCTCPReply(sTarget, sMessage)); } bool CModules::OnUserCTCP(CString& sTarget, CString& sMessage) { MODHALTCHK(OnUserCTCP(sTarget, sMessage)); } @@ -635,6 +636,10 @@ bool CGlobalModules::OnDeleteUser(CUser& User) { GLOBALMODHALTCHK(OnDeleteUser(User)); } +void CGlobalModules::OnClientConnect(CClient* pClient, const CString& sHost, unsigned short uPort) { + GLOBALMODCALL(OnClientConnect(pClient, sHost, uPort)); +} + bool CGlobalModules::OnLoginAttempt(CSmartPtr Auth) { GLOBALMODHALTCHK(OnLoginAttempt(Auth)); } diff --git a/Modules.h b/Modules.h index 1fcbee4d..ea5338a7 100644 --- a/Modules.h +++ b/Modules.h @@ -254,8 +254,10 @@ public: virtual void OnJoin(const CNick& Nick, CChan& Channel); virtual void OnPart(const CNick& Nick, CChan& Channel); - virtual void OnUserAttached(); - virtual void OnUserDetached(); + virtual void OnUserAttached(bool thisFunctionWasRemoved, bool UseOnClientLogin) {} + virtual void OnUserDetached(bool thisFunctionWasRemoved, bool UseOnClientDisconnect) {} + virtual void OnClientLogin(); + virtual void OnClientDisconnect(); virtual EModRet OnUserRaw(CString& sLine); virtual EModRet OnUserCTCPReply(CString& sTarget, CString& sMessage); virtual EModRet OnUserCTCP(CString& sTarget, CString& sMessage); @@ -395,8 +397,8 @@ public: virtual bool OnJoin(const CNick& Nick, CChan& Channel); virtual bool OnPart(const CNick& Nick, CChan& Channel); - virtual bool OnUserAttached(); - virtual bool OnUserDetached(); + virtual bool OnClientLogin(); + virtual bool OnClientDisconnect(); virtual bool OnUserRaw(CString& sLine); virtual bool OnUserCTCPReply(CString& sTarget, CString& sMessage); virtual bool OnUserCTCP(CString& sTarget, CString& sMessage); @@ -441,6 +443,7 @@ public: virtual EModRet OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan); virtual EModRet OnDeleteUser(CUser& User); + virtual void OnClientConnect(CClient* pClient, const CString& sHost, unsigned short uPort); virtual EModRet OnLoginAttempt(CSmartPtr Auth); virtual void OnFailedLogin(const CString& sUsername, const CString& sRemoteIP); private: @@ -453,6 +456,7 @@ public: virtual bool OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan); virtual bool OnDeleteUser(CUser& User); + virtual void OnClientConnect(CClient* pClient, const CString& sHost, unsigned short uPort); virtual bool OnLoginAttempt(CSmartPtr Auth); virtual void OnFailedLogin(const CString& sUsername, const CString& sRemoteIP); private: diff --git a/modules/away.cpp b/modules/away.cpp index 874f8c7a..f132546b 100644 --- a/modules/away.cpp +++ b/modules/away.cpp @@ -138,11 +138,11 @@ public: } } - virtual void OnUserAttached() + virtual void OnClientLogin() { Back(true); } - virtual void OnUserDetached() + virtual void OnClientDisconnect() { Away(); } diff --git a/modules/awaynick.cpp b/modules/awaynick.cpp index c99be272..9a97ac86 100644 --- a/modules/awaynick.cpp +++ b/modules/awaynick.cpp @@ -94,11 +94,11 @@ public: RemTimer("BackNickTimer"); } - virtual void OnUserAttached() { + virtual void OnClientLogin() { StartBackNickTimer(); } - virtual void OnUserDetached() { + virtual void OnClientDisconnect() { if (!m_pUser->IsUserAttached()) { StartAwayNickTimer(); } diff --git a/modules/email.cpp b/modules/email.cpp index 07475fc6..e0f04c36 100644 --- a/modules/email.cpp +++ b/modules/email.cpp @@ -62,14 +62,14 @@ public: return true; } - virtual void OnUserAttached() + virtual void OnClientLogin() { stringstream s; s << "You have " << m_ssUidls.size() << " emails."; PutModule(s.str()); StartTimer(); } - virtual void OnUserDetached() + virtual void OnClientDisconnect() { RemTimer("EMAIL::" + m_pUser->GetUserName()); } diff --git a/modules/modperl.cpp b/modules/modperl.cpp index a9de569f..0db72d37 100644 --- a/modules/modperl.cpp +++ b/modules/modperl.cpp @@ -302,8 +302,8 @@ public: void UnSetUser() { m_pUser = NULL; } virtual bool OnLoad(const CString & sArgs, CString & sMessage); - virtual void OnUserAttached() { CBNone("OnUserAttached"); } - virtual void OnUserDetached() { CBNone("OnUserDetached"); } + virtual void OnClientLogin() { CBNone("OnClientLogin"); } + virtual void OnClientDisconnect() { CBNone("OnClientDisconnect"); } virtual void OnIRCDisconnected() { CBNone("OnIRCDisconnected"); } virtual void OnIRCConnected() { CBNone("OnIRCConnected"); } diff --git a/modules/partyline.cpp b/modules/partyline.cpp index 495b7426..cf63c1d8 100644 --- a/modules/partyline.cpp +++ b/modules/partyline.cpp @@ -148,7 +148,7 @@ public: m_spInjectedPrefixes.erase(m_pUser); } - virtual void OnUserAttached() { + virtual void OnClientLogin() { if (m_spInjectedPrefixes.find(m_pUser) == m_spInjectedPrefixes.end()) { m_pClient->PutClient(":" + GetIRCServer(m_pUser) + " 005 " + m_pUser->GetIRCNick().GetNick() + " CHANTYPES=" + m_pUser->GetChanPrefixes() + "~ :are supported by this server."); } @@ -193,7 +193,7 @@ public: } } - virtual void OnUserDetached() { + virtual void OnClientDisconnect() { if (!m_pUser->IsUserAttached() && !m_pUser->IsBeingDeleted()) { for (set::iterator it = m_ssChannels.begin(); it != m_ssChannels.end(); it++) { const set& ssNicks = (*it)->GetNicks(); diff --git a/modules/schat.cpp b/modules/schat.cpp index 1bc0b41e..17658941 100644 --- a/modules/schat.cpp +++ b/modules/schat.cpp @@ -135,7 +135,7 @@ public: return true; } - virtual void OnUserAttached() + virtual void OnClientLogin() { CString sName = "SCHAT::" + m_pUser->GetUserName(); for (u_int a = 0; a < m_pManager->size(); a++) diff --git a/modules/simple_away.cpp b/modules/simple_away.cpp index 0e4441b0..1b898b79 100644 --- a/modules/simple_away.cpp +++ b/modules/simple_away.cpp @@ -79,11 +79,11 @@ public: SetAway(false); } - virtual void OnUserAttached() { + virtual void OnClientLogin() { SetBack(); } - virtual void OnUserDetached() { + virtual void OnClientDisconnect() { /* There might still be other clients */ if (!m_pUser->IsUserAttached()) SetAway(); diff --git a/modules/watch.cpp b/modules/watch.cpp index 13385185..c5bf78a4 100644 --- a/modules/watch.cpp +++ b/modules/watch.cpp @@ -163,7 +163,7 @@ public: Process(OpNick, "* " + OpNick.GetNick() + " sets mode: " + sModes + " " + sArgs + " on " + Channel.GetName(), Channel.GetName()); } - virtual void OnUserAttached() { + virtual void OnClientLogin() { CString sBufLine; while (m_Buffer.GetNextLine(m_pUser->GetCurNick(), sBufLine)) { PutUser(sBufLine); diff --git a/znc.h b/znc.h index d2e62f00..c24dedad 100644 --- a/znc.h +++ b/znc.h @@ -234,7 +234,9 @@ public: } virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort) { - return new CClient(sHost, uPort); + CClient *pClient = new CClient(sHost, uPort); + CZNC::Get().GetModules().OnClientConnect(pClient, sHost, uPort); + return pClient; } virtual void SockError(int iErrno) {