From: <ps...@us...> - 2009-09-26 18:41:32
|
Revision: 1640 http://znc.svn.sourceforge.net/znc/?rev=1640&view=rev Author: psychon Date: 2009-09-26 18:41:24 +0000 (Sat, 26 Sep 2009) Log Message: ----------- 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. Modified Paths: -------------- trunk/ClientCommand.cpp trunk/User.cpp trunk/User.h Modified: trunk/ClientCommand.cpp =================================================================== --- trunk/ClientCommand.cpp 2009-09-26 15:04:08 UTC (rev 1639) +++ trunk/ClientCommand.cpp 2009-09-26 18:41:24 UTC (rev 1640) @@ -329,9 +329,11 @@ } } else if (sCommand.Equals("REMSERVER") || sCommand.Equals("DELSERVER")) { CString sServer = sLine.Token(1); + unsigned short uPort = sLine.Token(2).ToUShort(); + CString sPass = sLine.Token(3); if (sServer.empty()) { - PutStatus("Usage: RemServer <host>"); + PutStatus("Usage: RemServer <host> [port] [pass]"); return; } @@ -340,7 +342,7 @@ return; } - if (m_pUser->DelServer(sServer)) { + if (m_pUser->DelServer(sServer, uPort, sPass)) { PutStatus("Server removed"); } else { PutStatus("No such server"); Modified: trunk/User.cpp =================================================================== --- trunk/User.cpp 2009-09-26 15:04:08 UTC (rev 1639) +++ trunk/User.cpp 2009-09-26 18:41:24 UTC (rev 1640) @@ -752,7 +752,7 @@ 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 @@ 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; + if (pIRCSock) { + pIRCSock->Quit(); + PutStatus("Your current server was removed, jumping..."); + } + } else if (m_uServerIdx >= m_vServers.size()) { + m_uServerIdx = 0; + } - return true; - } + delete pServer; + + return true; } return false; Modified: trunk/User.h =================================================================== --- trunk/User.h 2009-09-26 15:04:08 UTC (rev 1639) +++ trunk/User.h 2009-09-26 18:41:24 UTC (rev 1640) @@ -57,7 +57,7 @@ void JoinChans(); bool JoinChan(CChan* pChan); CServer* FindServer(const CString& sName) const; - bool DelServer(const CString& sName); + bool DelServer(const CString& sName, unsigned short uPort, const CString& sPass); bool AddServer(const CString& sName); bool AddServer(const CString& sName, unsigned short uPort, const CString& sPass = "", bool bSSL = false); CServer* GetNextServer(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |