mirror of
https://github.com/znc/znc.git
synced 2026-08-11 19:32:46 +02:00
Move IRCConnectEnabled to each network instead of a global user setting
This commit is contained in:
@@ -302,8 +302,7 @@ void CClient::UserCommand(CString& sLine) {
|
||||
PutStatus("Connecting...");
|
||||
}
|
||||
|
||||
m_pUser->SetIRCConnectEnabled(true);
|
||||
m_pNetwork->CheckIRCConnect();
|
||||
m_pNetwork->SetIRCConnectEnabled(true);
|
||||
return;
|
||||
} else if (sCommand.Equals("DISCONNECT")) {
|
||||
if (!m_pNetwork) {
|
||||
@@ -316,7 +315,7 @@ void CClient::UserCommand(CString& sLine) {
|
||||
GetIRCSock()->Quit(sQuitMsg);
|
||||
}
|
||||
|
||||
m_pUser->SetIRCConnectEnabled(false);
|
||||
m_pNetwork->SetIRCConnectEnabled(false);
|
||||
PutStatus("Disconnected from IRC. Use 'connect' to reconnect.");
|
||||
return;
|
||||
} else if (sCommand.Equals("ENABLECHAN")) {
|
||||
|
||||
+32
-3
@@ -52,6 +52,8 @@ CIRCNetwork::CIRCNetwork(CUser *pUser, const CString& sName) {
|
||||
m_RawBuffer.SetLineCount(100, true); // This should be more than enough raws, especially since we are buffering the MOTD separately
|
||||
m_MotdBuffer.SetLineCount(200, true); // This should be more than enough motd lines
|
||||
m_QueryBuffer.SetLineCount(250, true);
|
||||
|
||||
SetIRCConnectEnabled(true);
|
||||
}
|
||||
|
||||
CIRCNetwork::CIRCNetwork(CUser *pUser, const CIRCNetwork &Network) {
|
||||
@@ -172,6 +174,7 @@ void CIRCNetwork::Clone(const CIRCNetwork& Network) {
|
||||
}
|
||||
// !Modules
|
||||
|
||||
SetIRCConnectEnabled(Network.GetIRCConnectEnabled());
|
||||
}
|
||||
|
||||
CIRCNetwork::~CIRCNetwork() {
|
||||
@@ -240,6 +243,10 @@ bool CIRCNetwork::ParseConfig(CConfig *pConfig, CString& sError, bool bUpgrade)
|
||||
{ "realname", &CIRCNetwork::SetRealName }
|
||||
};
|
||||
size_t numStringOptions = sizeof(StringOptions) / sizeof(StringOptions[0]);
|
||||
TOption<bool> BoolOptions[] = {
|
||||
{ "ircconnectenabled", &CIRCNetwork::SetIRCConnectEnabled },
|
||||
};
|
||||
size_t numBoolOptions = sizeof(BoolOptions) / sizeof(BoolOptions[0]);
|
||||
|
||||
for (size_t i = 0; i < numStringOptions; i++) {
|
||||
CString sValue;
|
||||
@@ -247,6 +254,12 @@ bool CIRCNetwork::ParseConfig(CConfig *pConfig, CString& sError, bool bUpgrade)
|
||||
(this->*StringOptions[i].pSetter)(sValue);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < numBoolOptions; i++) {
|
||||
CString sValue;
|
||||
if (pConfig->FindStringEntry(BoolOptions[i].name, sValue))
|
||||
(this->*BoolOptions[i].pSetter)(sValue.ToBool());
|
||||
}
|
||||
|
||||
pConfig->FindStringVector("loadmodule", vsList);
|
||||
for (vit = vsList.begin(); vit != vsList.end(); ++vit) {
|
||||
CString sValue = *vit;
|
||||
@@ -334,6 +347,8 @@ CConfig CIRCNetwork::ToConfig() {
|
||||
config.AddKeyValuePair("RealName", m_sRealName);
|
||||
}
|
||||
|
||||
config.AddKeyValuePair("IRCConnectEnabled", CString(GetIRCConnectEnabled()));
|
||||
|
||||
// Modules
|
||||
CModules& Mods = GetModules();
|
||||
|
||||
@@ -452,7 +467,7 @@ void CIRCNetwork::ClientConnected(CClient *pClient) {
|
||||
m_QueryBuffer.Clear();
|
||||
|
||||
// Tell them why they won't connect
|
||||
if (!m_pUser->GetIRCConnectEnabled())
|
||||
if (!GetIRCConnectEnabled())
|
||||
pClient->PutStatus("You are currently disconnected from IRC. "
|
||||
"Use 'connect' to reconnect.");
|
||||
}
|
||||
@@ -880,7 +895,7 @@ CString CIRCNetwork::GetCurNick() const {
|
||||
}
|
||||
|
||||
bool CIRCNetwork::Connect() {
|
||||
if (!m_pUser->GetIRCConnectEnabled() || m_pIRCSock || !HasServers())
|
||||
if (!GetIRCConnectEnabled() || m_pIRCSock || !HasServers())
|
||||
return false;
|
||||
|
||||
CServer *pServer = GetNextServer();
|
||||
@@ -941,9 +956,23 @@ void CIRCNetwork::IRCDisconnected() {
|
||||
CheckIRCConnect();
|
||||
}
|
||||
|
||||
void CIRCNetwork::SetIRCConnectEnabled(bool b) {
|
||||
m_bIRCConnectEnabled = b;
|
||||
|
||||
if (m_bIRCConnectEnabled) {
|
||||
CheckIRCConnect();
|
||||
} else if (GetIRCSock()) {
|
||||
if (GetIRCSock()->IsConnected()) {
|
||||
GetIRCSock()->Quit();
|
||||
} else {
|
||||
GetIRCSock()->Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CIRCNetwork::CheckIRCConnect() {
|
||||
// Do we want to connect?
|
||||
if (m_pUser->GetIRCConnectEnabled() && GetIRCSock() == NULL)
|
||||
if (GetIRCConnectEnabled() && GetIRCSock() == NULL)
|
||||
CZNC::Get().AddNetworkToQueue(this);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -929,7 +929,7 @@ void CIRCSock::Disconnected() {
|
||||
IRCSOCKMODULECALL(OnIRCDisconnected(), NOTHING);
|
||||
|
||||
DEBUG(GetSockName() << " == Disconnected()");
|
||||
if (!m_pNetwork->GetUser()->IsBeingDeleted() && m_pNetwork->GetUser()->GetIRCConnectEnabled() &&
|
||||
if (!m_pNetwork->GetUser()->IsBeingDeleted() && m_pNetwork->GetIRCConnectEnabled() &&
|
||||
m_pNetwork->GetServers().size() != 0) {
|
||||
m_pNetwork->PutStatus("Disconnected from IRC. Reconnecting...");
|
||||
}
|
||||
|
||||
+7
-4
@@ -83,7 +83,6 @@ CUser::CUser(const CString& sUserName)
|
||||
m_sTimestampFormat = "[%H:%M:%S]";
|
||||
m_bAppendTimestamp = false;
|
||||
m_bPrependTimestamp = true;
|
||||
m_bIRCConnectEnabled = true;
|
||||
m_pUserTimer = new CUserTimer(this);
|
||||
CZNC::Get().GetManager().AddCron(m_pUserTimer);
|
||||
}
|
||||
@@ -149,7 +148,6 @@ bool CUser::ParseConfig(CConfig* pConfig, CString& sError) {
|
||||
{ "denysetvhost", &CUser::SetDenySetBindHost },
|
||||
{ "appendtimestamp", &CUser::SetTimestampAppend },
|
||||
{ "prependtimestamp", &CUser::SetTimestampPrepend },
|
||||
{ "ircconnectenabled", &CUser::SetIRCConnectEnabled },
|
||||
};
|
||||
size_t numBoolOptions = sizeof(BoolOptions) / sizeof(BoolOptions[0]);
|
||||
|
||||
@@ -408,6 +406,13 @@ bool CUser::ParseConfig(CConfig* pConfig, CString& sError) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Move ircconnectenabled to the networks
|
||||
if (pConfig->FindStringEntry("ircconnectenabled", sValue)) {
|
||||
for (vector<CIRCNetwork*>::iterator it = m_vIRCNetworks.begin(); it != m_vIRCNetworks.end(); ++it) {
|
||||
(*it)->SetIRCConnectEnabled(sValue.ToBool());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -663,7 +668,6 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneNetworks) {
|
||||
// !CTCP Replies
|
||||
|
||||
// Flags
|
||||
SetIRCConnectEnabled(User.GetIRCConnectEnabled());
|
||||
SetKeepBuffer(User.KeepBuffer());
|
||||
SetMultiClients(User.MultiClients());
|
||||
SetDenyLoadMod(User.DenyLoadMod());
|
||||
@@ -825,7 +829,6 @@ CConfig CUser::ToConfig() {
|
||||
config.AddKeyValuePair("TimezoneOffset", CString(m_fTimezoneOffset));
|
||||
config.AddKeyValuePair("JoinTries", CString(m_uMaxJoinTries));
|
||||
config.AddKeyValuePair("MaxJoins", CString(m_uMaxJoins));
|
||||
config.AddKeyValuePair("IRCConnectEnabled", CString(GetIRCConnectEnabled()));
|
||||
|
||||
// Allow Hosts
|
||||
if (!m_ssAllowedHosts.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user