Keep track of the timers and delete them upon destruction

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@407 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
prozacx
2005-07-04 23:26:47 +00:00
parent 0148a28aec
commit cb2d3da911
4 changed files with 25 additions and 6 deletions
+11 -4
View File
@@ -9,6 +9,7 @@ CIRCSock::CIRCSock(CZNC* pZNC, CUser* pUser) : Csock() {
m_pZNC = pZNC;
m_pUser = pUser;
m_pUserSock = NULL;
m_pAwayNickTimer = NULL;
m_uQueryBufferCount = 50;
m_bISpoofReleased = false;
m_bKeepNick = true;
@@ -56,6 +57,8 @@ CIRCSock::~CIRCSock() {
PutServ("QUIT :" + m_pUser->GetQuitMsg());
m_msChans.clear();
m_pZNC->GetManager().DelCronByAddr(m_pAwayNickTimer);
}
void CIRCSock::ReadLine(const CString& sData) {
@@ -91,7 +94,10 @@ void CIRCSock::ReadLine(const CString& sData) {
case 1: {// :irc.server.com 001 nick :Welcome to the Internet Relay Network nick
SetTimeout(900); // Now that we are connected, let nature take its course
PutServ("WHO " + sNick);
m_pZNC->GetManager().AddCron(new CAwayNickTimer(m_pUser));
if (!m_pAwayNickTimer) {
m_pAwayNickTimer = new CAwayNickTimer(m_pUser);
m_pZNC->GetManager().AddCron(m_pAwayNickTimer);
}
VOIDMODULECALL(OnIRCConnected());
@@ -803,8 +809,9 @@ void CIRCSock::UserConnected(CUserSock* pUserSock) {
}
void CIRCSock::UserDisconnected() {
if (m_pUserSock) {
m_pZNC->GetManager().AddCron(new CAwayNickTimer(m_pUser));
if (m_pUserSock && !m_pAwayNickTimer) {
m_pAwayNickTimer = new CAwayNickTimer(m_pUser);
m_pZNC->GetManager().AddCron(m_pAwayNickTimer);
}
m_pUserSock = NULL;
@@ -887,7 +894,7 @@ void CIRCSock::ParseISupport(const CString& sLine) {
if (sName.CaseCmp("PREFIX") == 0) {
CString sPrefixes = sValue.Token(1, false, ")");
CString sPermModes = sValue.Token(0, false, ")");
sPermModes.LeftTrim("(");
sPermModes.TrimLeft("(");
if (!sPrefixes.empty() && sPermModes.size() == sPrefixes.size()) {
m_sPerms = sPrefixes;
+2
View File
@@ -9,6 +9,7 @@
// Forward Declarations
class CZNC;
class CUserSock;
class CAwayNickTimer;
// !Forward Declarations
class CIRCSock : public Csock {
@@ -90,6 +91,7 @@ protected:
map<CString, CChan*> m_msChans;
unsigned int m_uMaxNickLen;
unsigned int m_uQueryBufferCount;
CAwayNickTimer* m_pAwayNickTimer;
CBuffer m_QueryBuffer;
};
+7 -2
View File
@@ -28,8 +28,10 @@ CUser::CUser(const CString& sUserName, CZNC* pZNC) {
m_sStatusPrefix = "*";
m_uBufferCount = 50;
m_bKeepBuffer = false;
m_pZNC->GetManager().AddCron(new CKeepNickTimer(this));
m_pZNC->GetManager().AddCron(new CJoinTimer(this));
m_pKeepNickTimer = new CKeepNickTimer(this);
m_pJoinTimer = new CJoinTimer(this);
m_pZNC->GetManager().AddCron(m_pKeepNickTimer);
m_pZNC->GetManager().AddCron(m_pJoinTimer);
m_sUserPath = m_pZNC->GetUserPath() + "/" + sUserName;
m_sDLPath = GetUserPath() + "/downloads";
}
@@ -45,6 +47,9 @@ CUser::~CUser() {
for (unsigned int b = 0; b < m_vChans.size(); b++) {
delete m_vChans[b];
}
m_pZNC->GetManager().DelCronByAddr(m_pKeepNickTimer);
m_pZNC->GetManager().DelCronByAddr(m_pJoinTimer);
}
bool CUser::OnBoot() {
+5
View File
@@ -19,6 +19,8 @@ class CChan;
class CServer;
class CIRCSock;
class CUserSock;
class CKeepNickTimer;
class CJoinTimer;
class CUser {
public:
@@ -154,6 +156,9 @@ protected:
bool m_bDenyLoadMod;
bool m_bKeepBuffer;
CKeepNickTimer* m_pKeepNickTimer;
CJoinTimer* m_pJoinTimer;
vector<CServer*> m_vServers;
vector<CChan*> m_vChans;
set<CString> m_ssAllowedHosts;