delserver: Allow selecting the server more exactly

Before this you could only give the hostname of a server and delserver would
delete the first server with that hostname. Now you can also specify port and
password to select the server to remove more exactly.

One can't specify the ssl flag for delserver since this would be a little ugly,
but since you can't do ssl/plain-text on the same port anyway this shouldn't be
a big problem.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1640 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-09-26 18:41:24 +00:00
parent f2cf1165f1
commit fa054942e9
3 changed files with 30 additions and 21 deletions
+25 -18
View File
@@ -752,7 +752,7 @@ CServer* CUser::FindServer(const CString& sName) const {
return NULL;
}
bool CUser::DelServer(const CString& sName) {
bool CUser::DelServer(const CString& sName, unsigned short uPort, const CString& sPass) {
if (sName.empty()) {
return false;
}
@@ -762,29 +762,36 @@ bool CUser::DelServer(const CString& sName) {
for (vector<CServer*>::iterator it = m_vServers.begin(); it != m_vServers.end(); it++, a++) {
CServer* pServer = *it;
if (pServer->GetName().Equals(sName)) {
CServer* pCurServer = GetCurrentServer();
m_vServers.erase(it);
if (!pServer->GetName().Equals(sName))
continue;
if (pServer == pCurServer) {
CIRCSock* pIRCSock = GetIRCSock();
if (uPort != 0 && pServer->GetPort() != uPort)
continue;
if (m_uServerIdx) {
m_uServerIdx--;
}
if (!sPass.empty() && pServer->GetPass() != sPass)
continue;
if (pIRCSock) {
pIRCSock->Quit();
PutStatus("Your current server was removed, jumping...");
}
} else if (m_uServerIdx >= m_vServers.size()) {
m_uServerIdx = 0;
CServer* pCurServer = GetCurrentServer();
m_vServers.erase(it);
if (pServer == pCurServer) {
CIRCSock* pIRCSock = GetIRCSock();
if (m_uServerIdx) {
m_uServerIdx--;
}
delete pServer;
return true;
if (pIRCSock) {
pIRCSock->Quit();
PutStatus("Your current server was removed, jumping...");
}
} else if (m_uServerIdx >= m_vServers.size()) {
m_uServerIdx = 0;
}
delete pServer;
return true;
}
return false;