mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Added CUser::IsBeingDeleted() to allow for different messaging when a user is being deleted vs detaching or disconnecting
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@703 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
16
IRCSock.cpp
16
IRCSock.cpp
@@ -779,22 +779,30 @@ void CIRCSock::Disconnected() {
|
||||
VOIDMODULECALL(OnIRCDisconnected());
|
||||
|
||||
DEBUG_ONLY(cout << GetSockName() << " == Disconnected()" << endl);
|
||||
m_pUser->PutStatus("Disconnected from IRC. Reconnecting...");
|
||||
if (!m_pUser->IsBeingDeleted()) {
|
||||
m_pUser->PutStatus("Disconnected from IRC. Reconnecting...");
|
||||
}
|
||||
}
|
||||
|
||||
void CIRCSock::SockError(int iErrno) {
|
||||
DEBUG_ONLY(cout << GetSockName() << " == SockError(" << iErrno << ")" << endl);
|
||||
m_pUser->PutStatus("Disconnected from IRC. Reconnecting...");
|
||||
if (!m_pUser->IsBeingDeleted()) {
|
||||
m_pUser->PutStatus("Disconnected from IRC. Reconnecting...");
|
||||
}
|
||||
}
|
||||
|
||||
void CIRCSock::Timeout() {
|
||||
DEBUG_ONLY(cout << GetSockName() << " == Timeout()" << endl);
|
||||
m_pUser->PutStatus("IRC connection timed out. Reconnecting...");
|
||||
if (!m_pUser->IsBeingDeleted()) {
|
||||
m_pUser->PutStatus("IRC connection timed out. Reconnecting...");
|
||||
}
|
||||
}
|
||||
|
||||
void CIRCSock::ConnectionRefused() {
|
||||
DEBUG_ONLY(cout << GetSockName() << " == ConnectionRefused()" << endl);
|
||||
m_pUser->PutStatus("Connection Refused. Reconnecting...");
|
||||
if (!m_pUser->IsBeingDeleted()) {
|
||||
m_pUser->PutStatus("Connection Refused. Reconnecting...");
|
||||
}
|
||||
}
|
||||
|
||||
void CIRCSock::ParseISupport(const CString& sLine) {
|
||||
|
||||
1
User.cpp
1
User.cpp
@@ -34,6 +34,7 @@ CUser::CUser(const CString& sUserName) {
|
||||
m_uBufferCount = 50;
|
||||
m_bKeepBuffer = false;
|
||||
m_bAutoCycle = true;
|
||||
m_bBeingDeleted = false;
|
||||
m_pBackNickTimer = NULL;
|
||||
m_pAwayNickTimer = NULL;
|
||||
m_pKeepNickTimer = new CKeepNickTimer(this);
|
||||
|
||||
3
User.h
3
User.h
@@ -125,6 +125,7 @@ public:
|
||||
void SetKeepBuffer(bool b);
|
||||
void SetAutoCycle(bool b);
|
||||
void SetChanPrefixes(const CString& s) { m_sChanPrefixes = (s.empty()) ? "#&" : s; }
|
||||
void SetBeingDeleted(bool b) { m_bBeingDeleted = b; }
|
||||
// !Setters
|
||||
|
||||
// Getters
|
||||
@@ -164,6 +165,7 @@ public:
|
||||
unsigned int GetBufferCount() const;
|
||||
bool KeepBuffer() const;
|
||||
bool AutoCycle() const;
|
||||
bool IsBeingDeleted() const { return m_bBeingDeleted; }
|
||||
// !Getters
|
||||
private:
|
||||
protected:
|
||||
@@ -202,6 +204,7 @@ protected:
|
||||
bool m_bAdmin;
|
||||
bool m_bKeepBuffer;
|
||||
bool m_bAutoCycle;
|
||||
bool m_bBeingDeleted;
|
||||
|
||||
CBackNickTimer* m_pBackNickTimer;
|
||||
CAwayNickTimer* m_pAwayNickTimer;
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void OnUserDetached() {
|
||||
if (!m_pUser->IsUserAttached()) {
|
||||
if (!m_pUser->IsUserAttached() && !m_pUser->IsBeingDeleted()) {
|
||||
for (map<CString, set<CString> >::iterator it = m_msChans.begin(); it != m_msChans.end(); it++) {
|
||||
set<CString>& ssNicks = it->second;
|
||||
|
||||
|
||||
7
znc.cpp
7
znc.cpp
@@ -34,6 +34,10 @@ CZNC::~CZNC() {
|
||||
delete m_vpListeners[b];
|
||||
}
|
||||
|
||||
for (map<CString,CUser*>::iterator a = m_msUsers.begin(); a != m_msUsers.end(); a++) {
|
||||
a->second->SetBeingDeleted(true);
|
||||
}
|
||||
|
||||
m_Manager.Cleanup();
|
||||
DeleteUsers();
|
||||
delete m_pModules;
|
||||
@@ -76,9 +80,11 @@ int CZNC::Loop() {
|
||||
if (m_ssDelUsers.size()) {
|
||||
for (set<CUser*>::iterator it = m_ssDelUsers.begin(); it != m_ssDelUsers.end(); it++) {
|
||||
CUser* pUser = *it;
|
||||
pUser->SetBeingDeleted(true);
|
||||
|
||||
#ifdef _MODULES
|
||||
if (GetModules().OnDeleteUser(*pUser)) {
|
||||
pUser->SetBeingDeleted(false);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
@@ -250,6 +256,7 @@ bool CZNC::WritePemFile() {
|
||||
|
||||
void CZNC::DeleteUsers() {
|
||||
for (map<CString,CUser*>::iterator a = m_msUsers.begin(); a != m_msUsers.end(); a++) {
|
||||
a->second->SetBeingDeleted(true);
|
||||
delete a->second;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user