diff --git a/include/znc/Chan.h b/include/znc/Chan.h index 2c448eb3..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); diff --git a/include/znc/Client.h b/include/znc/Client.h index 32fa1e2c..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(); @@ -151,7 +151,7 @@ public: 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 ad7bb122..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,7 +71,7 @@ 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(); } const std::vector& GetClients() const { return m_vClients; } 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 f0661ec7..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 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/src/Chan.cpp b/src/Chan.cpp index f962773c..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) diff --git a/src/Client.cpp b/src/Client.cpp index 8c8603c2..52802aa3 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -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 9534261e..ae3f6809 100644 --- a/src/IRCNetwork.cpp +++ b/src/IRCNetwork.cpp @@ -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/User.cpp b/src/User.cpp index d348bdd2..edb409b9 100644 --- a/src/User.cpp +++ b/src/User.cpp @@ -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++) {