From 5050b936585871f2c860699de158ce94b4f39d7b Mon Sep 17 00:00:00 2001 From: psychon Date: Fri, 31 Dec 2010 16:15:53 +0000 Subject: [PATCH] WebMods: Clean some stuff up This removes two unused methods (ResolveModule() and FillErrorPage()) and marks some other methods const/static/protected. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2236 726aef4b-f618-498e-8847-2d620e286838 --- WebModules.cpp | 31 ++----------------------------- WebModules.h | 31 +++++++++++-------------------- 2 files changed, 13 insertions(+), 49 deletions(-) diff --git a/WebModules.cpp b/WebModules.cpp index f4ddb1b2..1a0d53fb 100644 --- a/WebModules.cpp +++ b/WebModules.cpp @@ -160,34 +160,7 @@ void CWebSock::ParsePath() { DEBUG("Path [" + m_sPath + "], Module [" + m_sModName + "], Page [" + m_sPage + "]"); } -CModule* CWebSock::ResolveModule() { - ParsePath(); - CModule* pModRet = NULL; - - // Dot means static file, not module - if (m_sModName.find(".") != CString::npos) { - return NULL; - } - - // This could be user level or global level, check both - pModRet = CZNC::Get().GetModules().FindModule(m_sModName); - - if (!pModRet) { - if (!ForceLogin()) { - return NULL; - } - - pModRet = GetSession()->GetUser()->GetModules().FindModule(m_sModName); - } - - if (!pModRet) { - DEBUG("Module not found"); - } - - return pModRet; -} - -size_t CWebSock::GetAvailSkins(vector& vRet) { +size_t CWebSock::GetAvailSkins(vector& vRet) const { vRet.clear(); CString sRoot(GetSkinPath("_default_")); @@ -436,7 +409,7 @@ CWebSock::EPageReqResult CWebSock::PrintTemplate(const CString& sPageName, CStri } } -CString CWebSock::GetSkinPath(const CString& sSkinName) const { +CString CWebSock::GetSkinPath(const CString& sSkinName) { CString sRet = CZNC::Get().GetZNCPath() + "/webskins/" + sSkinName; if (!CFile::IsDir(sRet)) { diff --git a/WebModules.h b/WebModules.h index a8b8e7af..9eb8a504 100644 --- a/WebModules.h +++ b/WebModules.h @@ -125,35 +125,20 @@ public: virtual void OnPageRequest(const CString& sURI); void ParsePath(); // This parses the path portion of the url into some member vars - CModule* ResolveModule(); - //virtual bool PrintFile(const CString& sFileName, CString sContentType = ""); EPageReqResult PrintTemplate(const CString& sPageName, CString& sPageRet, CModule* pModule = NULL); EPageReqResult PrintStaticFile(const CString& sPath, CString& sPageRet, CModule* pModule = NULL); - bool AddModLoop(const CString& sLoopName, CModule& Module); - VCString GetDirs(CModule* pModule, bool bIsTemplate); CString FindTmpl(CModule* pModule, const CString& sName); - void SetPaths(CModule* pModule, bool bIsTemplate = false); - void SetVars(); - - void FillErrorPage(CString& sPageRet, const CString& sError) { - m_Template["Action"] = "error"; - m_Template["Title"] = "Error"; - m_Template["Error"] = sError; - - PrintTemplate("error", sPageRet); - } void PrintErrorPage(const CString& sMessage); CSmartPtr GetSession(); - CString GetCSRFCheck(); virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort); - CString GetSkinPath(const CString& sSkinName) const; + static CString GetSkinPath(const CString& sSkinName); CModule* GetModule() const { return (CModule*) m_pModule; } - size_t GetAvailSkins(vector& vRet); + size_t GetAvailSkins(vector& vRet) const; CString GetSkinName(); CString GetRequestCookie(const CString& sKey); @@ -166,15 +151,21 @@ public: protected: using CHTTPSock::PrintErrorPage; + bool AddModLoop(const CString& sLoopName, CModule& Module); + VCString GetDirs(CModule* pModule, bool bIsTemplate); + void SetPaths(CModule* pModule, bool bIsTemplate = false); + void SetVars(); + CString GetCSRFCheck(); + private: EPageReqResult OnPageRequestInternal(const CString& sURI, CString& sPageRet); bool m_bPathsSet; CTemplate m_Template; CSmartPtr m_spAuth; - CString m_sModName; // Gets filled by ResolveModule() - CString m_sPath; // Gets filled by ResolveModule() - CString m_sPage; // Gets filled by ResolveModule() + CString m_sModName; // Gets filled by ParsePath() + CString m_sPath; // Gets filled by ParsePath() + CString m_sPage; // Gets filled by ParsePath() CSmartPtr m_spSession; static CWebSessionMap m_mspSessions;