Wrapped TSocketManager into CSockManager

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@650 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
prozacx
2006-02-12 21:00:59 +00:00
parent 3d7bf1fce8
commit 0eaf9bdc1e
9 changed files with 25 additions and 21 deletions
+2 -2
View File
@@ -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<Csock>& 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<Csock>& Manager = CZNC::Get().GetManager();
CSockManager& Manager = CZNC::Get().GetManager();
CTable Table;
Table.AddColumn("Type");
+1 -5
View File
@@ -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();
}
-5
View File
@@ -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<Csock>* 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<Csock>* 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<Csock>* m_pManager;
unsigned short m_uRemotePort;
bool m_bIsChat;
bool m_bIsRemote;
+1 -1
View File
@@ -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<Csock>& Manager = CZNC::Get().GetManager();
CSockManager& Manager = CZNC::Get().GetManager();
for (unsigned int a = 0; a < Manager.size(); a++) {
CDCCBounce* pSock = (CDCCBounce*) Manager[a];
+3 -3
View File
@@ -59,7 +59,7 @@ class CChan;
class Csock;
class CModule;
class CFPTimer;
template<class T> 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<Csock>* GetManager() { return m_pManager; }
CSockManager* GetManager() { return m_pManager; }
// !Getters
protected:
@@ -305,7 +305,7 @@ protected:
vector<CTimer*> m_vTimers;
vector<CSocket*> m_vSockets;
void* m_pDLL;
TSocketManager<Csock>* m_pManager;
CSockManager* m_pManager;
CUser* m_pUser;
CClient* m_pClient;
CString m_sModName;
+2 -2
View File
@@ -697,7 +697,7 @@ bool CUser::CheckPass(const CString& sPass) {
/*CClient* CUser::GetClient() {
// Todo: optimize this by saving a pointer to the sock
TSocketManager<Csock>& 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<Csock>& 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) {
+4
View File
@@ -1,3 +1,4 @@
#include "znc.h"
#include "main.h"
#include "User.h"
#include "Nick.h"
@@ -15,6 +16,9 @@
* Author: imaginos <imaginos@imaginos.net>
*
* $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
*
+1 -1
View File
@@ -271,7 +271,7 @@ public:
DEBUG_ONLY( cerr << sTmp << endl );
}
TSocketManager<Csock> * GetSockManager() { return( m_pManager ); }
CSockManager * GetSockManager() { return( m_pManager ); }
void DestroyAllSocks( const CString & sModuleName = "" );
CUser * GetUser( const CString & sUsername = "", bool bSetUserContext = false )
+11 -2
View File
@@ -15,6 +15,15 @@ class CUser;
class CClient;
class CListener;
class CSockManager : public TSocketManager<Csock> {
public:
CSockManager() : TSocketManager<Csock>() {}
virtual ~CSockManager() {}
private:
protected:
};
class CZNC {
public:
CZNC();
@@ -47,7 +56,7 @@ public:
// !Setters
// Getters
TSocketManager<Csock>& GetManager() { return m_Manager; }
CSockManager& GetManager() { return m_Manager; }
#ifdef _MODULES
CGlobalModules& GetModules() { return *m_pModules; }
#endif
@@ -86,7 +95,7 @@ protected:
vector<CListener*> m_vpListeners;
map<CString,CUser*> m_msUsers;
set<CUser*> m_ssDelUsers;
TSocketManager<Csock> m_Manager;
CSockManager m_Manager;
CString m_sCurPath;
CString m_sModPath;