From c8f8285f65ae4479fcfeb09c6155403d555a2cce Mon Sep 17 00:00:00 2001 From: prozacx Date: Sat, 23 Apr 2005 17:54:20 +0000 Subject: [PATCH] Added KeepBuffer/Buffer config options to the User class git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@168 726aef4b-f618-498e-8847-2d620e286838 --- Chan.cpp | 13 +++++++++++++ Chan.h | 14 ++------------ User.cpp | 10 ++++++++-- User.h | 9 ++++++++- znc.conf | 24 +++++++++++++----------- znc.cpp | 8 +++++++- 6 files changed, 51 insertions(+), 27 deletions(-) diff --git a/Chan.cpp b/Chan.cpp index 1ebd4bef..00e92849 100644 --- a/Chan.cpp +++ b/Chan.cpp @@ -3,6 +3,19 @@ #include "User.h" #include "Utils.h" +CChan::CChan(const string& sName, CUser* pUser) { + m_sName = sName; + m_pUser = pUser; + m_bAutoCycle = true; + m_bDetached = false; + m_uBufferCount = m_pUser->GetBufferCount(); + m_bKeepBuffer = m_pUser->KeepBuffer(); + Reset(); +} +CChan::~CChan() { + ClearNicks(); +} + void CChan::Reset() { m_bWhoDone = false; m_bIsOn = false; diff --git a/Chan.h b/Chan.h index ce65008f..aadec5a4 100644 --- a/Chan.h +++ b/Chan.h @@ -23,18 +23,8 @@ public: Key = 1 << 6 } EMode; - CChan(const string& sName, CUser* pUser, unsigned int uBufferCount = 0) { - m_sName = sName; - m_pUser = pUser; - m_bKeepBuffer = false; - m_bAutoCycle = true; - m_bDetached = false; - m_uBufferCount = uBufferCount; - Reset(); - } - virtual ~CChan() { - ClearNicks(); - } + CChan(const string& sName, CUser* pUser); + virtual ~CChan(); void Reset(); void Joined(); diff --git a/User.cpp b/User.cpp index 27de9511..f7ea7805 100644 --- a/User.cpp +++ b/User.cpp @@ -21,6 +21,8 @@ CUser::CUser(const string& sUserName, CZNC* pZNC) { m_bKeepNick = false; m_bDenyLoadMod = false; m_sStatusPrefix = "*"; + m_uBufferCount = 50; + m_bKeepBuffer = false; m_pZNC->GetManager().AddCron(new CKeepNickTimer(this)); m_pZNC->GetManager().AddCron(new CJoinTimer(this)); } @@ -80,7 +82,7 @@ bool CUser::AddChan(CChan* pChan) { return true; } -bool CUser::AddChan(const string& sName, unsigned int uBufferCount) { +bool CUser::AddChan(const string& sName) { if (sName.empty()) { return false; } @@ -91,7 +93,7 @@ bool CUser::AddChan(const string& sName, unsigned int uBufferCount) { } } - CChan* pChan = new CChan(sName, this, uBufferCount); + CChan* pChan = new CChan(sName, this); m_vChans.push_back(pChan); return true; } @@ -379,6 +381,8 @@ void CUser::SetIRCNick(const CNick& n) { m_IRCNick = n; } void CUser::SetIRCServer(const string& s) { m_sIRCServer = s; } void CUser::SetQuitMsg(const string& s) { m_sQuitMsg = s; } void CUser::SetVersionReply(const string& s) { m_sVersionReply = s; } +void CUser::SetBufferCount(unsigned int u) { m_uBufferCount = u; } +void CUser::SetKeepBuffer(bool b) { m_bKeepBuffer = b; } bool CUser::SetStatusPrefix(const string& s) { if ((!s.empty()) && (s.length() < 6) && (s.find(' ') == string::npos)) { @@ -416,4 +420,6 @@ const CNick& CUser::GetIRCNick() const { return m_IRCNick; } const string& CUser::GetIRCServer() const { return m_sIRCServer; } const string& CUser::GetQuitMsg() const { return m_sQuitMsg; } const string& CUser::GetVersionReply() const { return m_sVersionReply; } +unsigned int CUser::GetBufferCount() const { return m_uBufferCount; } +bool CUser::KeepBuffer() const { return m_bKeepBuffer; } // !Getters diff --git a/User.h b/User.h index 254bb600..927b325e 100644 --- a/User.h +++ b/User.h @@ -25,7 +25,7 @@ public: CChan* FindChan(const string& sName); bool AddChan(CChan* pChan); - bool AddChan(const string& sName, unsigned int uBufferCount = 50); + bool AddChan(const string& sName); bool DelChan(const string& sName); bool AddServer(const string& sName); bool AddServer(const string& sName, unsigned short uPort, const string& sPass = "", bool bSSL = false); @@ -71,6 +71,8 @@ public: void SetIRCServer(const string& s); void SetQuitMsg(const string& s); void SetVersionReply(const string& s); + void SetBufferCount(unsigned int u); + void SetKeepBuffer(bool b); // !Setters // Getters @@ -103,6 +105,8 @@ public: const string& GetIRCServer() const; const string& GetQuitMsg() const; const string& GetVersionReply() const; + unsigned int GetBufferCount() const; + bool KeepBuffer() const; // !Getters private: protected: @@ -126,10 +130,13 @@ protected: bool m_bUseClientIP; bool m_bKeepNick; bool m_bDenyLoadMod; + bool m_bKeepBuffer; + vector m_vServers; vector m_vChans; set m_ssAllowedHosts; unsigned int m_uServerIdx; + unsigned int m_uBufferCount; #ifdef _MODULES CModules m_Modules; diff --git a/znc.conf b/znc.conf index d3dd3899..efc25eb7 100644 --- a/znc.conf +++ b/znc.conf @@ -23,6 +23,15 @@ StatusPrefix = * // You can override the global StatusPrefix on a per user basis. Using - is a good alternative in mIRC but it breaks BitchX #StatusPrefix = - + // This is the playback buffer size (in LINES) - WARNING: setting this too high could cause you to get a lot of text when you attach + Buffer = 50 + + // This will play the whole channel buffer back to you each time you connect. It will also buffer channels while you are attached + KeepBuffer = false + + // You may choose not to take advantage of znc's auto cycle which will cycle the channel if you are the last person and not opped + #AutoCycle = false + // Password used to connect. Pass = pass @@ -41,9 +50,6 @@ StatusPrefix = * ChanModes = +stn KeepNick = true - // You may choose not to take advantage of znc's auto cycle which will cycle the channel if you are the last person and not opped - #AutoCycle = false - // You may use multiple Allow lines to restrict access to this user. All connections are denied by default unless they match an ip below. // Note: IPs only! Allow = * @@ -79,17 +85,13 @@ StatusPrefix = * Key = znc Modes = +sn-t - // You can override the user's auto cycle on a per channel basis - #AutoCycle = true - // You can add channels that znc will join but not forward to your client #Detached = true - // This is the playback buffer size (in LINES) - WARNING: setting this too high could cause you to get a lot of text when you attach - Buffer = 50 - - // This will play the whole buffer back to you each time you connect. It will also buffer channels while you are attached - #KeepBuffer = true + // You can override some of the user options on a per channel basis + AutoCycle = true + Buffer = 500 + KeepBuffer = true diff --git a/znc.cpp b/znc.cpp index 2e19d200..2d365544 100644 --- a/znc.cpp +++ b/znc.cpp @@ -367,7 +367,13 @@ bool CZNC::ParseConfig(const string& sConfigFile) { continue; } } else { - if (strcasecmp(sName.c_str(), "Nick") == 0) { + if (strcasecmp(sName.c_str(), "Buffer") == 0) { + pUser->SetBufferCount(strtoul(sValue.c_str(), NULL, 10)); + continue; + } else if (strcasecmp(sName.c_str(), "KeepBuffer") == 0) { + pUser->SetKeepBuffer((strcasecmp(sValue.c_str(), "true") == 0)); + continue; + } else if (strcasecmp(sName.c_str(), "Nick") == 0) { pUser->SetNick(sValue); continue; } else if (strcasecmp(sName.c_str(), "VersionReply") == 0) {