diff --git a/include/znc/Chan.h b/include/znc/Chan.h index 8bc782d5..d9f28e15 100644 --- a/include/znc/Chan.h +++ b/include/znc/Chan.h @@ -60,7 +60,7 @@ public: ~CChan(); void Reset(); - CConfig ToConfig(); + CConfig ToConfig() const; void Clone(CChan& chan); void Cycle() const; void JoinUser(bool bForce = false, const CString& sKey = "", CClient* pClient = NULL); @@ -92,7 +92,7 @@ public: // Buffer const CBuffer& GetBuffer() const { return m_Buffer; } unsigned int GetBufferCount() const { return m_Buffer.GetLineCount(); } - bool SetBufferCount(unsigned int u, bool bForce = false) { m_bHasBufferCountSet = true; return m_Buffer.SetLineCount(u, bForce); }; + bool SetBufferCount(unsigned int u, bool bForce = false) { m_bHasBufferCountSet = true; return m_Buffer.SetLineCount(u, bForce); } void InheritBufferCount(unsigned int u, bool bForce = false) { if (!m_bHasBufferCountSet) m_Buffer.SetLineCount(u, bForce); } size_t AddBuffer(const CString& sFormat, const CString& sText = "", const timeval* ts = NULL) { return m_Buffer.AddLine(sFormat, sText, ts); } void ClearBuffer() { m_Buffer.Clear(); } diff --git a/include/znc/Client.h b/include/znc/Client.h index 99ee9859..4842d13d 100644 --- a/include/znc/Client.h +++ b/include/znc/Client.h @@ -131,7 +131,7 @@ public: void PutModule(const CString& sModule, const CString& sLine); void PutModNotice(const CString& sModule, const CString& sLine); - bool IsCapEnabled(const CString& sCap) { return 1 == m_ssAcceptedCaps.count(sCap); } + bool IsCapEnabled(const CString& sCap) const { return 1 == m_ssAcceptedCaps.count(sCap); } virtual void ReadLine(const CString& sData); bool SendMotd(); @@ -148,10 +148,10 @@ public: CUser* GetUser() const { return m_pUser; } void SetNetwork(CIRCNetwork* pNetwork, bool bDisconnect=true, bool bReconnect=true); CIRCNetwork* GetNetwork() const { return m_pNetwork; } - std::vector& GetClients(); + const std::vector& GetClients() const; const CIRCSock* GetIRCSock() const; CIRCSock* GetIRCSock(); - CString GetFullName(); + CString GetFullName() const; private: void HandleCap(const CString& sLine); void RespondCap(const CString& sResponse); diff --git a/include/znc/FileUtils.h b/include/znc/FileUtils.h index 4be163ab..fdfcbb11 100644 --- a/include/znc/FileUtils.h +++ b/include/znc/FileUtils.h @@ -238,8 +238,8 @@ public: return uRet; } - CFile::EFileAttr GetSortAttr() { return m_eSortAttr; } - bool IsDescending() { return m_bDesc; } + CFile::EFileAttr GetSortAttr() const { return m_eSortAttr; } + bool IsDescending() const { return m_bDesc; } // Check if sPath + "/" + sAdd (~/ is handled) is an absolute path which // resides under sPath. Returns absolute path on success, else "". diff --git a/include/znc/HTTPSock.h b/include/znc/HTTPSock.h index 2c3cc872..08919364 100644 --- a/include/znc/HTTPSock.h +++ b/include/znc/HTTPSock.h @@ -56,7 +56,7 @@ public: void ParseURI(); void GetPage(); static CString GetDate(time_t tm = 0); - virtual CString GetRemoteIP(); + virtual CString GetRemoteIP() const; // Cookies CString GetRequestCookie(const CString& sKey) const; diff --git a/include/znc/IRCNetwork.h b/include/znc/IRCNetwork.h index 28aff9f6..8b06069d 100644 --- a/include/znc/IRCNetwork.h +++ b/include/znc/IRCNetwork.h @@ -57,12 +57,12 @@ public: void Clone(const CIRCNetwork& Network, bool bCloneName = true); - CString GetNetworkPath(); + CString GetNetworkPath() const; void DelServers(); bool ParseConfig(CConfig *pConfig, CString& sError, bool bUpgrade = false); - CConfig ToConfig(); + CConfig ToConfig() const; void BounceAllClients(); @@ -71,10 +71,10 @@ public: void ClientConnected(CClient *pClient); void ClientDisconnected(CClient *pClient); - CUser* GetUser(); + CUser* GetUser() const; const CString& GetName() const; - bool IsNetworkAttached() const { return !m_vClients.empty(); }; - std::vector& GetClients() { return m_vClients; } + bool IsNetworkAttached() const { return !m_vClients.empty(); } + const std::vector& GetClients() const { return m_vClients; } void SetUser(CUser *pUser); bool SetName(const CString& sName); @@ -103,8 +103,8 @@ public: CQuery* AddQuery(const CString& sName); bool DelQuery(const CString& sName); - const CString& GetChanPrefixes() const { return m_sChanPrefixes; }; - void SetChanPrefixes(const CString& s) { m_sChanPrefixes = s; }; + const CString& GetChanPrefixes() const { return m_sChanPrefixes; } + void SetChanPrefixes(const CString& s) { m_sChanPrefixes = s; } bool IsChan(const CString& sChan) const; const std::vector& GetServers() const; diff --git a/include/znc/Modules.h b/include/znc/Modules.h index 71f1ad67..c595ee47 100644 --- a/include/znc/Modules.h +++ b/include/znc/Modules.h @@ -978,13 +978,13 @@ public: * except when we are in a user-specific module hook in which * case this is the user pointer. */ - CUser* GetUser() { return m_pUser; } + CUser* GetUser() const { return m_pUser; } /** @returns NULL except when we are in a client-specific module hook in * which case this is the client for which the hook is called. */ - CIRCNetwork* GetNetwork() { return m_pNetwork; } - CClient* GetClient() { return m_pClient; } - CSockManager* GetManager() { return m_pManager; } + CIRCNetwork* GetNetwork() const { return m_pNetwork; } + CClient* GetClient() const { return m_pClient; } + CSockManager* GetManager() const { return m_pManager; } // !Getters // Global Modules @@ -1114,9 +1114,9 @@ public: void SetUser(CUser* pUser) { m_pUser = pUser; } void SetNetwork(CIRCNetwork* pNetwork) { m_pNetwork = pNetwork; } void SetClient(CClient* pClient) { m_pClient = pClient; } - CUser* GetUser() { return m_pUser; } - CIRCNetwork* GetNetwork() { return m_pNetwork; } - CClient* GetClient() { return m_pClient; } + CUser* GetUser() const { return m_pUser; } + CIRCNetwork* GetNetwork() const { return m_pNetwork; } + CClient* GetClient() const { return m_pClient; } void UnloadAll(); diff --git a/include/znc/User.h b/include/znc/User.h index 588dce32..f8e9108a 100644 --- a/include/znc/User.h +++ b/include/znc/User.h @@ -57,7 +57,7 @@ public: return CUtils::SaltedSHA256Hash(sPass, sSalt); } - CConfig ToConfig(); + CConfig ToConfig() const; bool CheckPass(const CString& sPass) const; bool AddAllowedHost(const CString& sHostMask); bool IsHostAllowed(const CString& sHostMask) const; @@ -91,7 +91,7 @@ public: void UserConnected(CClient* pClient); void UserDisconnected(CClient* pClient); - CString GetLocalDCCIP(); + CString GetLocalDCCIP() const; CString ExpandString(const CString& sStr) const; CString& ExpandString(const CString& sStr, CString& sRet) const; @@ -141,8 +141,8 @@ public: // !Setters // Getters - std::vector& GetUserClients() { return m_vClients; } - std::vector GetAllClients(); + const std::vector& GetUserClients() const { return m_vClients; } + std::vector GetAllClients() const; const CString& GetUserName() const; const CString& GetCleanUserName() const; const CString& GetNick(bool bAllowDefault = true) const; diff --git a/include/znc/WebModules.h b/include/znc/WebModules.h index 44e477e5..8d24e7c5 100644 --- a/include/znc/WebModules.h +++ b/include/znc/WebModules.h @@ -135,7 +135,6 @@ public: virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort); static CString GetSkinPath(const CString& sSkinName); - CModule* GetModule() const { return (CModule*) m_pModule; } void GetAvailSkins(VCString& vRet) const; CString GetSkinName(); diff --git a/src/Chan.cpp b/src/Chan.cpp index b2ce8ba7..befa225c 100644 --- a/src/Chan.cpp +++ b/src/Chan.cpp @@ -80,7 +80,7 @@ void CChan::Reset() { ResetJoinTries(); } -CConfig CChan::ToConfig() { +CConfig CChan::ToConfig() const { CConfig config; if (m_bHasBufferCountSet) @@ -141,8 +141,8 @@ void CChan::JoinUser(bool bForce, const CString& sKey, CClient* pClient) { CString sLine = sPre; CString sPerm, sNick; - vector& vpClients = m_pNetwork->GetClients(); - for (vector::iterator it = vpClients.begin(); it != vpClients.end(); ++it) { + const vector& vpClients = m_pNetwork->GetClients(); + for (vector::const_iterator it = vpClients.begin(); it != vpClients.end(); ++it) { CClient* pThisClient; if (!pClient) pThisClient = *it; diff --git a/src/Client.cpp b/src/Client.cpp index cc188b57..52802aa3 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -271,7 +271,7 @@ void CClient::ReadLine(const CString& sData) { // Relay to the rest of the clients that may be connected to this user if (m_pNetwork->IsChan(sTarget)) { - vector& vClients = GetClients(); + const vector& vClients = GetClients(); for (unsigned int a = 0; a < vClients.size(); a++) { CClient* pClient = vClients[a]; @@ -325,7 +325,7 @@ void CClient::ReadLine(const CString& sData) { } // Relay to the rest of the clients that may be connected to this user - vector& vClients = GetClients(); + const vector& vClients = GetClients(); for (unsigned int a = 0; a < vClients.size(); a++) { CClient* pClient = vClients[a]; @@ -394,7 +394,7 @@ void CClient::ReadLine(const CString& sData) { // Relay to the rest of the clients that may be connected to this user if (m_pNetwork->IsChan(sTarget)) { - vector& vClients = GetClients(); + const vector& vClients = GetClients(); for (unsigned int a = 0; a < vClients.size(); a++) { CClient* pClient = vClients[a]; @@ -575,7 +575,7 @@ void CClient::SetNetwork(CIRCNetwork* pNetwork, bool bDisconnect, bool bReconnec } } -vector& CClient::GetClients() { +const vector& CClient::GetClients() const { if (m_pNetwork) { return m_pNetwork->GetClients(); } @@ -775,7 +775,7 @@ void CClient::PutIRC(const CString& sLine) { } } -CString CClient::GetFullName() { +CString CClient::GetFullName() const { if (!m_pUser) return GetRemoteIP(); if (!m_pNetwork) diff --git a/src/HTTPSock.cpp b/src/HTTPSock.cpp index f46efd92..29e6f19c 100644 --- a/src/HTTPSock.cpp +++ b/src/HTTPSock.cpp @@ -181,7 +181,7 @@ void CHTTPSock::ReadLine(const CString& sData) { } } -CString CHTTPSock::GetRemoteIP() { +CString CHTTPSock::GetRemoteIP() const { if (!m_sForwardedIP.empty()) { return m_sForwardedIP; } diff --git a/src/IRCNetwork.cpp b/src/IRCNetwork.cpp index 4739037d..ae3f6809 100644 --- a/src/IRCNetwork.cpp +++ b/src/IRCNetwork.cpp @@ -44,7 +44,7 @@ protected: pIRCSock->PutIRC("PING :ZNC"); } - vector& vClients = m_pNetwork->GetClients(); + const vector& vClients = m_pNetwork->GetClients(); for (size_t b = 0; b < vClients.size(); b++) { CClient* pClient = vClients[b]; @@ -305,7 +305,7 @@ void CIRCNetwork::DelServers() { m_vServers.clear(); } -CString CIRCNetwork::GetNetworkPath() { +CString CIRCNetwork::GetNetworkPath() const { CString sNetworkPath = m_pUser->GetUserPath() + "/networks/" + m_sName; if (!CFile::Exists(sNetworkPath)) { @@ -455,7 +455,7 @@ bool CIRCNetwork::ParseConfig(CConfig *pConfig, CString& sError, bool bUpgrade) return true; } -CConfig CIRCNetwork::ToConfig() { +CConfig CIRCNetwork::ToConfig() const { CConfig config; if (!m_sNick.empty()) { @@ -487,7 +487,7 @@ CConfig CIRCNetwork::ToConfig() { } // Modules - CModules& Mods = GetModules(); + const CModules& Mods = GetModules(); if (!Mods.empty()) { for (unsigned int a = 0; a < Mods.size(); a++) { @@ -638,7 +638,7 @@ void CIRCNetwork::ClientDisconnected(CClient *pClient) { } } -CUser* CIRCNetwork::GetUser() { +CUser* CIRCNetwork::GetUser() const { return m_pUser; } diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index cbf88fd6..0fdde95d 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -181,7 +181,7 @@ void CIRCSock::ReadLine(const CString& sData) { m_bAuthed = true; m_pNetwork->PutStatus("Connected!"); - vector& vClients = m_pNetwork->GetClients(); + const vector& vClients = m_pNetwork->GetClients(); for (unsigned int a = 0; a < vClients.size(); a++) { CClient* pClient = vClients[a]; @@ -354,8 +354,8 @@ void CIRCSock::ReadLine(const CString& sData) { if (m_bNamesx && (sNick.size() > 1) && IsPermChar(sNick[1])) { // sLine uses multi-prefix - vector& vClients = m_pNetwork->GetClients(); - vector::iterator it; + const vector& vClients = m_pNetwork->GetClients(); + vector::const_iterator it; for (it = vClients.begin(); it != vClients.end(); ++it) { CClient *pClient = *it; @@ -1233,8 +1233,8 @@ CString CIRCSock::GetISupport(const CString& sKey, const CString& sDefault) cons } void CIRCSock::ForwardRaw353(const CString& sLine) const { - vector& vClients = m_pNetwork->GetClients(); - vector::iterator it; + const vector& vClients = m_pNetwork->GetClients(); + vector::const_iterator it; for (it = vClients.begin(); it != vClients.end(); ++it) { ForwardRaw353(sLine, *it); diff --git a/src/User.cpp b/src/User.cpp index f6fe9213..edb409b9 100644 --- a/src/User.cpp +++ b/src/User.cpp @@ -37,7 +37,7 @@ public: private: protected: virtual void RunJob() { - vector& vUserClients = m_pUser->GetUserClients(); + const vector& vUserClients = m_pUser->GetUserClients(); for (size_t c = 0; c < vUserClients.size(); ++c) { CClient* pUserClient = vUserClients[c]; @@ -659,7 +659,7 @@ void CUser::CloneNetworks(const CUser& User) { // have requested the rehash. Then when we do // client->PutStatus("Rehashing succeeded!") we would // crash if there was no client anymore. - vector& vClients = FindNetwork(*it)->GetClients(); + const vector& vClients = FindNetwork(*it)->GetClients(); while (vClients.begin() != vClients.end()) { CClient *pClient = vClients.front(); @@ -859,7 +859,7 @@ bool CUser::IsValid(CString& sErrMsg, bool bSkipPass) const { return true; } -CConfig CUser::ToConfig() { +CConfig CUser::ToConfig() const { CConfig config; CConfig passConfig; @@ -923,7 +923,7 @@ CConfig CUser::ToConfig() { } // Modules - CModules& Mods = GetModules(); + const CModules& Mods = GetModules(); if (!Mods.empty()) { for (unsigned int a = 0; a < Mods.size(); a++) { @@ -976,11 +976,11 @@ bool CUser::CheckPass(const CString& sPass) const { return (CClient*) CZNC::Get().GetManager().FindSockByName(sSockName); }*/ -CString CUser::GetLocalDCCIP() { +CString CUser::GetLocalDCCIP() const { if (!GetDCCBindHost().empty()) return GetDCCBindHost(); - for (vector::iterator it = m_vIRCNetworks.begin(); it != m_vIRCNetworks.end(); ++it) { + for (vector::const_iterator it = m_vIRCNetworks.begin(); it != m_vIRCNetworks.end(); ++it) { CIRCNetwork *pNetwork = *it; CIRCSock* pIRCSock = pNetwork->GetIRCSock(); if (pIRCSock) { @@ -1167,7 +1167,7 @@ bool CUser::SetStatusPrefix(const CString& s) { // !Setters // Getters -vector CUser::GetAllClients() { +vector CUser::GetAllClients() const { vector vClients; for (unsigned int a = 0; a < m_vIRCNetworks.size(); a++) {