From 3d7d1793aa8b7c1ab5719cb07fd12ecff1df2c05 Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Wed, 11 Jan 2012 14:06:11 +0000 Subject: [PATCH] Move IRCConnectEnabled to each network instead of a global user setting --- include/znc/IRCNetwork.h | 4 +++ include/znc/User.h | 3 -- modules/admin.cpp | 13 ++----- modules/blockuser.cpp | 9 +---- .../data/webadmin/tmpl/add_edit_network.tmpl | 6 ++++ modules/data/webadmin/tmpl/add_edit_user.tmpl | 8 ----- modules/webadmin.cpp | 8 +++-- src/ClientCommand.cpp | 5 ++- src/IRCNetwork.cpp | 35 +++++++++++++++++-- src/IRCSock.cpp | 2 +- src/User.cpp | 11 +++--- 11 files changed, 60 insertions(+), 44 deletions(-) diff --git a/include/znc/IRCNetwork.h b/include/znc/IRCNetwork.h index a9ea3336..1895472d 100644 --- a/include/znc/IRCNetwork.h +++ b/include/znc/IRCNetwork.h @@ -89,6 +89,9 @@ public: bool SetNextServer(const CServer* pServer); bool IsLastServer() const; + void SetIRCConnectEnabled(bool b); + bool GetIRCConnectEnabled() const { return m_bIRCConnectEnabled; } + CIRCSock* GetIRCSock() { return m_pIRCSock; } const CIRCSock* GetIRCSock() const { return m_pIRCSock; } const CString& GetIRCServer() const; @@ -159,6 +162,7 @@ protected: CString m_sChanPrefixes; + bool m_bIRCConnectEnabled; CString m_sIRCServer; vector m_vServers; unsigned int m_uServerIdx; ///< Index in m_vServers of our current server + 1 diff --git a/include/znc/User.h b/include/znc/User.h index 266c2931..6e375dcb 100644 --- a/include/znc/User.h +++ b/include/znc/User.h @@ -125,7 +125,6 @@ public: void SetJoinTries(unsigned int i) { m_uMaxJoinTries = i; } void SetMaxJoins(unsigned int i) { m_uMaxJoins = i; } void SetSkinName(const CString& s) { m_sSkinName = s; } - void SetIRCConnectEnabled(bool b) { m_bIRCConnectEnabled = b; } // !Setters // Getters @@ -146,7 +145,6 @@ public: const CString& GetTimestampFormat() const; bool GetTimestampAppend() const; bool GetTimestampPrepend() const; - bool GetIRCConnectEnabled() const { return m_bIRCConnectEnabled; } const CString& GetUserPath() const; @@ -202,7 +200,6 @@ protected: bool m_bBeingDeleted; bool m_bAppendTimestamp; bool m_bPrependTimestamp; - bool m_bIRCConnectEnabled; CUserTimer* m_pUserTimer; diff --git a/modules/admin.cpp b/modules/admin.cpp index bac6a8a5..9133960e 100644 --- a/modules/admin.cpp +++ b/modules/admin.cpp @@ -559,7 +559,6 @@ class CAdminMod : public CModule { PutModule("Error: Cloning failed! [" + sError + "]"); return; } - pNewUser->SetIRCConnectEnabled(false); if (!CZNC::Get().AddUser(pNewUser, sError)) { delete pNewUser; @@ -730,8 +729,7 @@ class CAdminMod : public CModule { } // then reconnect - pUser->SetIRCConnectEnabled(true); - pNetwork->CheckIRCConnect(); + pNetwork->SetIRCConnectEnabled(true); PutModule("Queued user for a reconnect."); } @@ -757,14 +755,7 @@ class CAdminMod : public CModule { return; } - CIRCSock *pIRCSock = pNetwork->GetIRCSock(); - if (pIRCSock && !pIRCSock->IsConnected()) - pIRCSock->Close(); - else if(pIRCSock) - pIRCSock->Quit(); - - pUser->SetIRCConnectEnabled(false); - + pNetwork->SetIRCConnectEnabled(false); PutModule("Closed user's IRC connection."); } diff --git a/modules/blockuser.cpp b/modules/blockuser.cpp index e04287ee..7d06b673 100644 --- a/modules/blockuser.cpp +++ b/modules/blockuser.cpp @@ -158,16 +158,9 @@ private: // Disconnect all networks from irc vector vNetworks = pUser->GetNetworks(); for (vector::iterator it2 = vNetworks.begin(); it2 != vNetworks.end(); ++it2) { - CIRCNetwork *pNetwork = *it2; - CIRCSock *pIRCSock = pNetwork->GetIRCSock(); - if (pIRCSock) { - pIRCSock->Quit(); - } + (*it2)->SetIRCConnectEnabled(false); } - // ...and don't reconnect - pUser->SetIRCConnectEnabled(false); - SetNV(pUser->GetUserName(), ""); return true; } diff --git a/modules/data/webadmin/tmpl/add_edit_network.tmpl b/modules/data/webadmin/tmpl/add_edit_network.tmpl index 3131add1..24c715df 100644 --- a/modules/data/webadmin/tmpl/add_edit_network.tmpl +++ b/modules/data/webadmin/tmpl/add_edit_network.tmpl @@ -38,6 +38,12 @@
+
+
Active:
+
checked="checked" /> +
+
+
Servers: