From 0eaf9bdc1e0ee8195931fc3d166ef5a3fb76f78f Mon Sep 17 00:00:00 2001 From: prozacx Date: Sun, 12 Feb 2006 21:00:59 +0000 Subject: [PATCH] Wrapped TSocketManager into CSockManager git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@650 726aef4b-f618-498e-8847-2d620e286838 --- Client.cpp | 4 ++-- DCCBounce.cpp | 6 +----- DCCBounce.h | 5 ----- IRCSock.cpp | 2 +- Modules.h | 6 +++--- User.cpp | 4 ++-- modules/email.cpp | 4 ++++ modules/modperl.cpp | 2 +- znc.h | 13 +++++++++++-- 9 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Client.cpp b/Client.cpp index 5c091a4b..fceffc19 100644 --- a/Client.cpp +++ b/Client.cpp @@ -353,7 +353,7 @@ void CClient::ReadLine(const CString& sData) { if (strncasecmp(sTarget.c_str(), m_pUser->GetStatusPrefix().c_str(), m_pUser->GetStatusPrefix().length()) == 0) { } else { // Need to lookup the connection by port, filter the port, and forward to the user - TSocketManager& Manager = CZNC::Get().GetManager(); + CSockManager& Manager = CZNC::Get().GetManager(); for (unsigned int a = 0; a < Manager.size(); a++) { CDCCBounce* pSock = (CDCCBounce*) Manager[a]; @@ -882,7 +882,7 @@ void CClient::UserCommand(const CString& sLine) { m_pUser->SendFile(GetNick(), sFile); } } else if (sCommand.CaseCmp("LISTDCCS") == 0) { - TSocketManager& Manager = CZNC::Get().GetManager(); + CSockManager& Manager = CZNC::Get().GetManager(); CTable Table; Table.AddColumn("Type"); diff --git a/DCCBounce.cpp b/DCCBounce.cpp index ece14475..7a8faf0f 100644 --- a/DCCBounce.cpp +++ b/DCCBounce.cpp @@ -84,10 +84,6 @@ void CDCCBounce::Shutdown() { Csock* CDCCBounce::GetSockObj(const CString& sHost, unsigned short uPort) { Close(); - if (!m_pManager) { - return NULL; - } - if (m_sRemoteIP.empty()) { m_sRemoteIP = sHost; } @@ -99,7 +95,7 @@ Csock* CDCCBounce::GetSockObj(const CString& sHost, unsigned short uPort) { pRemoteSock->SetRemote(true); pSock->SetRemote(false); - if (!m_pManager->Connect(m_sConnectIP, m_uRemotePort, "DCC::" + CString((m_bIsChat) ? "Chat" : "XFER") + "::Remote::" + m_sRemoteNick, 60, false, m_sLocalIP, pRemoteSock)) { + if (!CZNC::Get().GetManager().Connect(m_sConnectIP, m_uRemotePort, "DCC::" + CString((m_bIsChat) ? "Chat" : "XFER") + "::Remote::" + m_sRemoteNick, 60, false, m_sLocalIP, pRemoteSock)) { pRemoteSock->Close(); } diff --git a/DCCBounce.h b/DCCBounce.h index 83f11e66..3e3b3490 100644 --- a/DCCBounce.h +++ b/DCCBounce.h @@ -15,7 +15,6 @@ public: m_sFileName = sFileName; m_sRemoteNick = sRemoteNick; m_pUser = pUser; - m_pManager = &(CZNC::Get().GetManager()); m_bIsChat = bIsChat; m_sLocalIP = sLocalIP; m_pPeer = NULL; @@ -29,7 +28,6 @@ public: CDCCBounce(const CString& sHostname, unsigned short uPort, CUser* pUser, const CString& sRemoteNick, const CString& sRemoteIP, const CString& sFileName, int iTimeout = 60, bool bIsChat = false) : Csock(sHostname, uPort, iTimeout) { m_uRemotePort = 0; m_bIsChat = bIsChat; - m_pManager = &(CZNC::Get().GetManager()); m_pUser = pUser; m_pPeer = NULL; m_sRemoteNick = sRemoteNick; @@ -67,7 +65,6 @@ public: void SetPeer(CDCCBounce* p) { m_pPeer = p; } void SetRemoteIP(const CString& s) { m_sRemoteIP = s; } void SetRemoteNick(const CString& s) { m_sRemoteNick = s; } - void SetManager(TSocketManager* p) { m_pManager = p; } void SetRemote(bool b) { m_bIsRemote = b; } // !Setters @@ -77,7 +74,6 @@ public: const CString& GetRemoteNick() const { return m_sRemoteNick; } const CString& GetFileName() const { return m_sFileName; } CDCCBounce* GetPeer() const { return m_pPeer; } - TSocketManager* GetManager() const { return m_pManager; } bool IsRemote() { return m_bIsRemote; } // !Getters private: @@ -89,7 +85,6 @@ protected: CString m_sFileName; CUser* m_pUser; CDCCBounce* m_pPeer; - TSocketManager* m_pManager; unsigned short m_uRemotePort; bool m_bIsChat; bool m_bIsRemote; diff --git a/IRCSock.cpp b/IRCSock.cpp index c88390be..92856121 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -654,7 +654,7 @@ bool CIRCSock::OnPrivCTCP(CNick& Nick, CString& sMessage) { } } else if (sType.CaseCmp("ACCEPT") == 0) { // Need to lookup the connection by port, filter the port, and forward to the user - TSocketManager& Manager = CZNC::Get().GetManager(); + CSockManager& Manager = CZNC::Get().GetManager(); for (unsigned int a = 0; a < Manager.size(); a++) { CDCCBounce* pSock = (CDCCBounce*) Manager[a]; diff --git a/Modules.h b/Modules.h index c0977e2f..c30753fa 100644 --- a/Modules.h +++ b/Modules.h @@ -59,7 +59,7 @@ class CChan; class Csock; class CModule; class CFPTimer; -template class TSocketManager; +class CSockManager; // !Forward Declarations class CTimer : public CCron { @@ -296,7 +296,7 @@ public: const CString& GetArgs() const { return m_sArgs; } CUser* GetUser() { return m_pUser; } CClient* GetClient() { return m_pClient; } - TSocketManager* GetManager() { return m_pManager; } + CSockManager* GetManager() { return m_pManager; } // !Getters protected: @@ -305,7 +305,7 @@ protected: vector m_vTimers; vector m_vSockets; void* m_pDLL; - TSocketManager* m_pManager; + CSockManager* m_pManager; CUser* m_pUser; CClient* m_pClient; CString m_sModName; diff --git a/User.cpp b/User.cpp index f0f4370e..f3002eeb 100644 --- a/User.cpp +++ b/User.cpp @@ -697,7 +697,7 @@ bool CUser::CheckPass(const CString& sPass) { /*CClient* CUser::GetClient() { // Todo: optimize this by saving a pointer to the sock - TSocketManager& Manager = CZNC::Get().GetManager(); + CSockManager& Manager = CZNC::Get().GetManager(); CString sSockName = "USR::" + m_sUserName; for (unsigned int a = 0; a < Manager.size(); a++) { @@ -799,7 +799,7 @@ bool CUser::PutModule(const CString& sModule, const CString& sLine, CClient* pCl } bool CUser::ResumeFile(const CString& sRemoteNick, unsigned short uPort, unsigned long uFileSize) { - TSocketManager& Manager = CZNC::Get().GetManager(); + CSockManager& Manager = CZNC::Get().GetManager(); for (unsigned int a = 0; a < Manager.size(); a++) { if (strncasecmp(Manager[a]->GetSockName().c_str(), "DCC::LISTEN::", 13) == 0) { diff --git a/modules/email.cpp b/modules/email.cpp index a9012ec8..ab8d9e37 100644 --- a/modules/email.cpp +++ b/modules/email.cpp @@ -1,3 +1,4 @@ +#include "znc.h" #include "main.h" #include "User.h" #include "Nick.h" @@ -15,6 +16,9 @@ * Author: imaginos * * $Log$ + * Revision 1.11 2006/02/12 21:00:59 prozacx + * Wrapped TSocketManager into CSockManager + * * Revision 1.10 2006/02/11 11:55:55 imaginos * fixed wrong type being used on 64bit * diff --git a/modules/modperl.cpp b/modules/modperl.cpp index c0f8f37d..f34cf9cc 100644 --- a/modules/modperl.cpp +++ b/modules/modperl.cpp @@ -271,7 +271,7 @@ public: DEBUG_ONLY( cerr << sTmp << endl ); } - TSocketManager * GetSockManager() { return( m_pManager ); } + CSockManager * GetSockManager() { return( m_pManager ); } void DestroyAllSocks( const CString & sModuleName = "" ); CUser * GetUser( const CString & sUsername = "", bool bSetUserContext = false ) diff --git a/znc.h b/znc.h index 153652e9..beffbb5c 100644 --- a/znc.h +++ b/znc.h @@ -15,6 +15,15 @@ class CUser; class CClient; class CListener; +class CSockManager : public TSocketManager { +public: + CSockManager() : TSocketManager() {} + virtual ~CSockManager() {} + +private: +protected: +}; + class CZNC { public: CZNC(); @@ -47,7 +56,7 @@ public: // !Setters // Getters - TSocketManager& GetManager() { return m_Manager; } + CSockManager& GetManager() { return m_Manager; } #ifdef _MODULES CGlobalModules& GetModules() { return *m_pModules; } #endif @@ -86,7 +95,7 @@ protected: vector m_vpListeners; map m_msUsers; set m_ssDelUsers; - TSocketManager m_Manager; + CSockManager m_Manager; CString m_sCurPath; CString m_sModPath;