Create a connection queue including all the networks we need to connect

This commit is contained in:
Kyle Fuller
2011-10-04 15:17:42 +00:00
parent 0f0591b648
commit a4aedc90d3
4 changed files with 122 additions and 145 deletions

View File

@@ -159,6 +159,9 @@ CIRCNetwork::~CIRCNetwork() {
m_vChans.clear();
SetUser(NULL);
// Make sure we are not in the connection queue
CZNC::Get().GetConnectionQueue().remove(this);
}
void CIRCNetwork::DelServers() {
@@ -810,6 +813,51 @@ CString CIRCNetwork::GetCurNick() const {
return "";
}
bool CIRCNetwork::Connect() {
if (!m_pUser->GetIRCConnectEnabled() || m_pIRCSock || !HasServers())
return false;
CServer *pServer = GetNextServer();
if (!pServer)
return false;
if (CZNC::Get().GetServerThrottle(pServer->GetName())) {
CZNC::Get().AddNetworkToQueue(this);
return false;
}
CZNC::Get().AddServerThrottle(pServer->GetName());
CIRCSock *pIRCSock = new CIRCSock(this);
pIRCSock->SetPass(pServer->GetPass());
bool bSSL = false;
#ifdef HAVE_LIBSSL
if (pServer->IsSSL()) {
bSSL = true;
}
#endif
DEBUG("Connecting user/network [" << m_sName << "/" << m_sName << "]");
NETWORKMODULECALL(OnIRCConnecting(pIRCSock), m_pUser, this, NULL,
DEBUG("Some module aborted the connection attempt");
PutStatus("Some module aborted the connection attempt");
delete pIRCSock;
CZNC::Get().AddNetworkToQueue(this);
return false;
);
CString sSockName = "IRC::" + m_pUser->GetUserName() + "::" + m_sName;
if (!CZNC::Get().GetManager().Connect(pServer->GetName(), pServer->GetPort(), sSockName, 120, bSSL, m_pUser->GetBindHost(), pIRCSock)) {
PutStatus("Unable to connect. (Bad host?)");
CZNC::Get().AddNetworkToQueue(this);
return false;
}
return true;
}
bool CIRCNetwork::IsIRCConnected() const {
const CIRCSock* pSock = GetIRCSock();
return (pSock && pSock->IsAuthed());
@@ -832,7 +880,7 @@ void CIRCNetwork::IRCDisconnected() {
void CIRCNetwork::CheckIRCConnect() {
// Do we want to connect?
if (m_pUser->GetIRCConnectEnabled() && GetIRCSock() == NULL)
CZNC::Get().EnableConnectUser();
CZNC::Get().AddNetworkToQueue(this);
}
bool CIRCNetwork::PutIRC(const CString& sLine) {