From f99e5190cdac3bdec270f51373408d02a8a619b7 Mon Sep 17 00:00:00 2001 From: psychon Date: Thu, 28 Jan 2010 19:44:37 +0000 Subject: [PATCH] CClient: Use CUser's IRC Socket pointer CUser already saves the pointer to the IRC socket, so why would CClient's have to do the same? git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1725 726aef4b-f618-498e-8847-2d620e286838 --- Client.cpp | 20 ++++++++------------ Client.h | 8 ++------ ClientCommand.cpp | 2 +- User.cpp | 8 -------- 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/Client.cpp b/Client.cpp index 1e31ea58..4943025a 100644 --- a/Client.cpp +++ b/Client.cpp @@ -568,6 +568,14 @@ void CClient::SetNick(const CString& s) { m_sNick = s; } +const CIRCSock* CClient::GetIRCSock() const { + return m_pUser->GetIRCSock(); +} + +CIRCSock* CClient::GetIRCSock() { + return m_pUser->GetIRCSock(); +} + void CClient::StatusCTCP(const CString& sLine) { CString sCommand = sLine.Token(0); @@ -689,7 +697,6 @@ void CClient::AcceptLogin(CUser& User) { SetSockName("USR::" + m_pUser->GetUserName()); - m_pIRCSock = (CIRCSock*) CZNC::Get().FindSockByName("IRC::" + m_pUser->GetUserName()); m_pUser->UserConnected(this); SendMotd(); @@ -715,8 +722,6 @@ void CClient::Disconnected() { m_pUser->UserDisconnected(this); } - m_pIRCSock = NULL; - MODULECALL(OnClientDisconnect(), m_pUser, this, ); } @@ -728,20 +733,11 @@ void CClient::ReachedMaxBuffer() { Close(); } -void CClient::IRCConnected(CIRCSock* pIRCSock) { - m_pIRCSock = pIRCSock; -} - void CClient::BouncedOff() { PutStatusNotice("You are being disconnected because another user just authenticated as you."); - m_pIRCSock = NULL; Close(Csock::CLT_AFTERWRITE); } -void CClient::IRCDisconnected() { - m_pIRCSock = NULL; -} - void CClient::PutIRC(const CString& sLine) { if (GetIRCSock()) { GetIRCSock()->PutIRC(sLine); diff --git a/Client.h b/Client.h index e2c41933..4f80d207 100644 --- a/Client.h +++ b/Client.h @@ -75,7 +75,6 @@ class CClient : public CZNCSock { public: CClient(const CString& sHostname, unsigned short uPort) : CZNCSock(sHostname, uPort) { m_pUser = NULL; - m_pIRCSock = NULL; m_bGotPass = false; m_bGotNick = false; m_bGotUser = false; @@ -105,8 +104,6 @@ public: void UserCommand(CString& sCommand); void StatusCTCP(const CString& sCommand); - void IRCConnected(CIRCSock* pIRCSock); - void IRCDisconnected(); void BouncedOff(); bool IsAttached() const { return m_pUser != NULL; } @@ -130,8 +127,8 @@ public: void SetNick(const CString& s); CUser* GetUser() const { return m_pUser; } - const CIRCSock* GetIRCSock() const { return m_pIRCSock; } - CIRCSock* GetIRCSock() { return m_pIRCSock; } + const CIRCSock* GetIRCSock() const; + CIRCSock* GetIRCSock(); private: protected: @@ -144,7 +141,6 @@ protected: CString m_sNick; CString m_sPass; CString m_sUser; - CIRCSock* m_pIRCSock; CSmartPtr m_spAuth; }; diff --git a/ClientCommand.cpp b/ClientCommand.cpp index bcd7a834..3453aa63 100644 --- a/ClientCommand.cpp +++ b/ClientCommand.cpp @@ -242,7 +242,7 @@ void CClient::UserCommand(CString& sLine) { m_pUser->CheckIRCConnect(); return; } else if (sCommand.Equals("DISCONNECT")) { - // m_pIRCSock is only set after the low level connection + // GetIRCSock() is only set after the low level connection // to the IRC server was established. Before this we can // only find the IRC socket by its name. if (GetIRCSock()) { diff --git a/User.cpp b/User.cpp index 27fa058d..62b75684 100644 --- a/User.cpp +++ b/User.cpp @@ -166,19 +166,11 @@ void CUser::DelServers() void CUser::IRCConnected(CIRCSock* pIRCSock) { m_pIRCSock = pIRCSock; - - for (unsigned int a = 0; a < m_vClients.size(); a++) { - m_vClients[a]->IRCConnected(pIRCSock); - } } void CUser::IRCDisconnected() { m_pIRCSock = NULL; - for (unsigned int a = 0; a < m_vClients.size(); a++) { - m_vClients[a]->IRCDisconnected(); - } - SetIRCServer(""); m_bIRCAway = false;