diff --git a/Modules.cpp b/Modules.cpp index a45a2537..a5ec25e7 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -144,14 +144,14 @@ CModule::~CModule() { void CModule::SetUser(CUser* pUser) { m_pUser = pUser; } void CModule::SetClient(CClient* pClient) { m_pClient = pClient; } -void CModule::Unload() { throw UNLOAD; } +void CModule::Unload() const { throw UNLOAD; } bool CModule::LoadRegistry() { //CString sPrefix = (m_pUser) ? m_pUser->GetUserName() : ".global"; return (m_mssRegistry.ReadFromDisk(GetSavePath() + "/.registry", 0600) == MCString::MCS_SUCCESS); } -bool CModule::SaveRegistry() { +bool CModule::SaveRegistry() const { //CString sPrefix = (m_pUser) ? m_pUser->GetUserName() : ".global"; return (m_mssRegistry.WriteToDisk(GetSavePath() + "/.registry", 0600) == MCString::MCS_SUCCESS); } @@ -165,8 +165,8 @@ bool CModule::SetNV(const CString & sName, const CString & sValue, bool bWriteTo return true; } -CString CModule::GetNV(const CString & sName) { - MCString::iterator it = m_mssRegistry.find(sName); +CString CModule::GetNV(const CString & sName) const { + MCString::const_iterator it = m_mssRegistry.find(sName); if (it != m_mssRegistry.end()) { return it->second; @@ -247,7 +247,7 @@ bool CModule::UnlinkTimer(CTimer* pTimer) { return false; } -CTimer* CModule::FindTimer(const CString& sLabel) { +CTimer* CModule::FindTimer(const CString& sLabel) const { set::iterator it; for (it = m_sTimers.begin(); it != m_sTimers.end(); ++it) { CTimer* pTimer = *it; @@ -335,7 +335,7 @@ bool CModule::UnlinkSocket(CSocket* pSocket) { return false; } -CSocket* CModule::FindSocket(const CString& sSockName) { +CSocket* CModule::FindSocket(const CString& sSockName) const { set::iterator it; for (it = m_sSockets.begin(); it != m_sSockets.end(); ++it) { CSocket* pSocket = *it; @@ -456,7 +456,7 @@ CModule::EModRet CModule::OnChanNotice(CNick& Nick, CChan& Channel, CString& sMe CModule::EModRet CModule::OnTopic(CNick& Nick, CChan& Channel, CString& sTopic) { return CONTINUE; } CModule::EModRet CModule::OnTimerAutoJoin(CChan& Channel) { return CONTINUE; } -ModHandle CModule::GetDLL() { return m_pDLL; } +ModHandle CModule::GetDLL() const { return m_pDLL; } bool CModule::PutIRC(const CString& sLine) { return (m_pUser) ? m_pUser->PutIRC(sLine) : false; } diff --git a/Modules.h b/Modules.h index e261c80e..49c1caa3 100644 --- a/Modules.h +++ b/Modules.h @@ -255,7 +255,7 @@ public: /** This function throws CModule::UNLOAD which causes this module to be unloaded. */ - void Unload(); + void Unload() const; /** This module hook is called when a module is loaded * @param sArgsi The arguments for the modules. @@ -645,7 +645,7 @@ public: */ virtual EModRet OnTimerAutoJoin(CChan& Channel); - ModHandle GetDLL(); + ModHandle GetDLL() const; static double GetCoreVersion() { return VERSION; } /** This function sends a given raw IRC line to the IRC server, if we @@ -716,7 +716,7 @@ public: bool RemTimer(CTimer* pTimer); bool RemTimer(const CString& sLabel); bool UnlinkTimer(CTimer* pTimer); - CTimer* FindTimer(const CString& sLabel); + CTimer* FindTimer(const CString& sLabel) const; set::const_iterator BeginTimers() const { return m_sTimers.begin(); } set::const_iterator EndTimers() const { return m_sTimers.end(); } virtual void ListTimers(); @@ -727,16 +727,16 @@ public: bool RemSocket(CSocket* pSocket); bool RemSocket(const CString& sSockName); bool UnlinkSocket(CSocket* pSocket); - CSocket* FindSocket(const CString& sSockName); + CSocket* FindSocket(const CString& sSockName) const; set::const_iterator BeginSockets() const { return m_sSockets.begin(); } set::const_iterator EndSockets() const { return m_sSockets.end(); } virtual void ListSockets(); // !Socket stuff bool LoadRegistry(); - bool SaveRegistry(); + bool SaveRegistry() const; bool SetNV(const CString & sName, const CString & sValue, bool bWriteToDisk = true); - CString GetNV(const CString & sName); + CString GetNV(const CString & sName) const; bool DelNV(const CString & sName, bool bWriteToDisk = true); MCString::iterator FindNV(const CString & sName) { return m_mssRegistry.find(sName); } MCString::iterator EndNV() { return m_mssRegistry.end(); } @@ -764,12 +764,12 @@ 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. */ - CClient* GetClient() { return m_pClient; } - CSockManager* GetManager() { return m_pManager; } + CClient* GetClient() const { return m_pClient; } + CSockManager* GetManager() const { return m_pManager; } // !Getters protected: diff --git a/User.cpp b/User.cpp index 0d5239a4..d97006a6 100644 --- a/User.cpp +++ b/User.cpp @@ -602,7 +602,7 @@ bool CUser::DelChan(const CString& sName) { return false; } -bool CUser::PrintLine(CFile& File, CString sName, CString sValue) { +bool CUser::PrintLine(CFile& File, CString sName, CString sValue) const { sName.Trim(); sValue.Trim(); @@ -674,7 +674,7 @@ bool CUser::WriteConfig(CFile& File) { // CTCP Replies if (!m_mssCTCPReplies.empty()) { - for (MCString::iterator itb = m_mssCTCPReplies.begin(); itb != m_mssCTCPReplies.end(); ++itb) { + for (MCString::const_iterator itb = m_mssCTCPReplies.begin(); itb != m_mssCTCPReplies.end(); ++itb) { PrintLine(File, "CTCPReply", itb->first.AsUpper() + " " + itb->second); } @@ -1177,7 +1177,7 @@ bool CUser::SetBufferCount(unsigned int u, bool bForce) { return true; } -void CUser::CheckIRCConnect() { +void CUser::CheckIRCConnect() const { // Do we want to connect? if (m_bIRCConnectEnabled && GetIRCSock() == NULL) CZNC::Get().EnableConnectUser(); diff --git a/User.h b/User.h index fe1628d4..6a621e13 100644 --- a/User.h +++ b/User.h @@ -46,7 +46,7 @@ public: return CUtils::SaltedSHA256Hash(sPass, sSalt); } - bool PrintLine(CFile& File, CString sName, CString sValue); + bool PrintLine(CFile& File, CString sName, CString sValue) const; bool WriteConfig(CFile& File); CChan* FindChan(const CString& sName) const; bool AddChan(CChan* pChan); @@ -111,7 +111,7 @@ public: bool IsIRCConnected() const { return GetIRCSock() != NULL; } void IRCConnected(CIRCSock* pIRCSock); void IRCDisconnected(); - void CheckIRCConnect(); + void CheckIRCConnect() const; void AddDCCBounce(CDCCBounce* p) { m_sDCCBounces.insert(p); } void DelDCCBounce(CDCCBounce* p) { m_sDCCBounces.erase(p); } @@ -220,7 +220,7 @@ public: unsigned long long BytesWritten() const { return m_uBytesWritten; } unsigned int JoinTries() const { return m_uMaxJoinTries; } unsigned int MaxJoins() const { return m_uMaxJoins; } - bool IsIRCAway() { return m_bIRCAway; } + bool IsIRCAway() const { return m_bIRCAway; } CString GetSkinName() const; // !Getters private: diff --git a/ZNCString.cpp b/ZNCString.cpp index 7dcab833..50c16065 100644 --- a/ZNCString.cpp +++ b/ZNCString.cpp @@ -805,13 +805,13 @@ CString CString::SHA256() const { } #ifdef HAVE_LIBSSL -CString CString::Encrypt_n(const CString& sPass, const CString& sIvec) { +CString CString::Encrypt_n(const CString& sPass, const CString& sIvec) const { CString sRet; sRet.Encrypt(sPass, sIvec); return sRet; } -CString CString::Decrypt_n(const CString& sPass, const CString& sIvec) { +CString CString::Decrypt_n(const CString& sPass, const CString& sIvec) const { CString sRet; sRet.Decrypt(sPass, sIvec); return sRet; @@ -1031,7 +1031,7 @@ bool CString::RightChomp(unsigned int uLen) { } //////////////// MCString //////////////// -int MCString::WriteToDisk(const CString& sPath, mode_t iMode) { +int MCString::WriteToDisk(const CString& sPath, mode_t iMode) const { CFile cFile(sPath); if (this->empty()) { @@ -1045,7 +1045,7 @@ int MCString::WriteToDisk(const CString& sPath, mode_t iMode) { return MCS_EOPEN; } - for (MCString::iterator it = this->begin(); it != this->end(); ++it) { + for (MCString::const_iterator it = this->begin(); it != this->end(); ++it) { CString sKey = it->first; CString sValue = it->second; if (!WriteFilter(sKey, sValue)) { @@ -1095,7 +1095,7 @@ int MCString::ReadFromDisk(const CString& sPath, mode_t iMode) { static const char hexdigits[] = "0123456789abcdef"; -CString& MCString::Encode(CString& sValue) { +CString& MCString::Encode(CString& sValue) const { CString sTmp; for (CString::iterator it = sValue.begin(); it != sValue.end(); ++it) { if (isalnum(*it)) { @@ -1111,7 +1111,7 @@ CString& MCString::Encode(CString& sValue) { return sValue; } -CString& MCString::Decode(CString& sValue) { +CString& MCString::Decode(CString& sValue) const { const char *pTmp = sValue.c_str(); char *endptr; CString sTmp; diff --git a/ZNCString.h b/ZNCString.h index 3ced8428..ecb6a3f7 100644 --- a/ZNCString.h +++ b/ZNCString.h @@ -141,8 +141,8 @@ public: CString Base64Encode_n(unsigned int uWrap = 0) const; #ifdef HAVE_LIBSSL - CString Encrypt_n(const CString& sPass, const CString& sIvec = ""); - CString Decrypt_n(const CString& sPass, const CString& sIvec = ""); + CString Encrypt_n(const CString& sPass, const CString& sIvec = "") const; + CString Decrypt_n(const CString& sPass, const CString& sIvec = "") const; void Encrypt(const CString& sPass, const CString& sIvec = ""); void Decrypt(const CString& sPass, const CString& sIvec = ""); void Crypt(const CString& sPass, bool bEncrypt, const CString& sIvec = ""); @@ -198,15 +198,15 @@ public: MCS_EREADFIL = 4 }; - int WriteToDisk(const CString& sPath, mode_t iMode = 0644); + int WriteToDisk(const CString& sPath, mode_t iMode = 0644) const; int ReadFromDisk(const CString& sPath, mode_t iMode = 0644); - virtual bool WriteFilter(CString& sKey, CString& sValue) { return true; } - virtual bool ReadFilter(CString& sKey, CString& sValue) { return true; } + virtual bool WriteFilter(CString& sKey, CString& sValue) const { return true; } + virtual bool ReadFilter(CString& sKey, CString& sValue) const { return true; } //! make them parse safe, right now using hex encoding on anything !isalnum - virtual CString& Encode(CString& sValue); - virtual CString& Decode(CString& sValue); + virtual CString& Encode(CString& sValue) const; + virtual CString& Decode(CString& sValue) const; }; #endif // !ZNCSTRING_H