diff --git a/include/znc/WebModules.h b/include/znc/WebModules.h index 44e477e5..aa0a7310 100644 --- a/include/znc/WebModules.h +++ b/include/znc/WebModules.h @@ -27,7 +27,7 @@ class CWebSock; class CModule; class CWebSubPage; -typedef CSmartPtr TWebSubPage; +typedef std::shared_ptr TWebSubPage; typedef std::vector VWebSubPages; class CZNCTagHandler : public CTemplateTagHandler { @@ -102,9 +102,9 @@ private: VPair m_vParams; }; -class CWebSessionMap : public TCacheMap > { +class CWebSessionMap : public TCacheMap > { public: - CWebSessionMap(unsigned int uTTL = 5000) : TCacheMap >(uTTL) {} + CWebSessionMap(unsigned int uTTL = 5000) : TCacheMap >(uTTL) {} void FinishUserSessions(const CUser& User); }; @@ -131,7 +131,7 @@ public: void PrintErrorPage(const CString& sMessage); - CSmartPtr GetSession(); + std::shared_ptr GetSession(); virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort); static CString GetSkinPath(const CString& sSkinName); @@ -162,7 +162,7 @@ private: CString m_sModName; CString m_sPath; CString m_sPage; - CSmartPtr m_spSession; + std::shared_ptr m_spSession; static const unsigned int m_uiMaxSessions; }; diff --git a/modules/webadmin.cpp b/modules/webadmin.cpp index f575e76c..f8d08067 100644 --- a/modules/webadmin.cpp +++ b/modules/webadmin.cpp @@ -76,10 +76,10 @@ public: MODCONSTRUCTOR(CWebAdminMod) { VPair vParams; vParams.push_back(make_pair("user", "")); - AddSubPage(new CWebSubPage("settings", "Global Settings", CWebSubPage::F_ADMIN)); - AddSubPage(new CWebSubPage("edituser", "Your Settings", vParams)); - AddSubPage(new CWebSubPage("traffic", "Traffic Info", CWebSubPage::F_ADMIN)); - AddSubPage(new CWebSubPage("listusers", "Manage Users", CWebSubPage::F_ADMIN)); + AddSubPage(std::make_shared("settings", "Global Settings", CWebSubPage::F_ADMIN)); + AddSubPage(std::make_shared("edituser", "Your Settings", vParams)); + AddSubPage(std::make_shared("traffic", "Traffic Info", CWebSubPage::F_ADMIN)); + AddSubPage(std::make_shared("listusers", "Manage Users", CWebSubPage::F_ADMIN)); } virtual ~CWebAdminMod() { @@ -164,7 +164,7 @@ public: } CUser* GetNewUser(CWebSock& WebSock, CUser* pUser) { - CSmartPtr spSession = WebSock.GetSession(); + std::shared_ptr spSession = WebSock.GetSession(); CString sUsername = WebSock.GetParam("newuser"); if (sUsername.empty()) { @@ -402,7 +402,7 @@ public: virtual CString GetWebMenuTitle() { return "webadmin"; } virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { - CSmartPtr spSession = WebSock.GetSession(); + std::shared_ptr spSession = WebSock.GetSession(); if (sPageName == "settings") { // Admin Check @@ -597,7 +597,7 @@ public: } bool ChanPage(CWebSock& WebSock, CTemplate& Tmpl, CIRCNetwork* pNetwork, CChan* pChan = NULL) { - CSmartPtr spSession = WebSock.GetSession(); + std::shared_ptr spSession = WebSock.GetSession(); Tmpl.SetFile("add_edit_chan.tmpl"); CUser* pUser = pNetwork->GetUser(); @@ -727,7 +727,7 @@ public: } bool NetworkPage(CWebSock& WebSock, CTemplate& Tmpl, CUser* pUser, CIRCNetwork* pNetwork = NULL) { - CSmartPtr spSession = WebSock.GetSession(); + std::shared_ptr spSession = WebSock.GetSession(); Tmpl.SetFile("add_edit_network.tmpl"); if (!WebSock.GetParam("submitted").ToUInt()) { @@ -1073,7 +1073,7 @@ public: } bool UserPage(CWebSock& WebSock, CTemplate& Tmpl, CUser* pUser = NULL) { - CSmartPtr spSession = WebSock.GetSession(); + std::shared_ptr spSession = WebSock.GetSession(); Tmpl.SetFile("add_edit_user.tmpl"); if (!WebSock.GetParam("submitted").ToUInt()) { @@ -1380,7 +1380,7 @@ public: } bool ListUsersPage(CWebSock& WebSock, CTemplate& Tmpl) { - CSmartPtr spSession = WebSock.GetSession(); + std::shared_ptr spSession = WebSock.GetSession(); const map& msUsers = CZNC::Get().GetUserMap(); Tmpl["Title"] = "Manage Users"; Tmpl["Action"] = "listusers"; diff --git a/src/WebModules.cpp b/src/WebModules.cpp index c5552811..b359748c 100644 --- a/src/WebModules.cpp +++ b/src/WebModules.cpp @@ -153,7 +153,7 @@ void CWebSessionMap::FinishUserSessions(const CUser& User) { void CWebAuth::AcceptedLogin(CUser& User) { if (m_pWebSock) { - CSmartPtr spSession = m_pWebSock->GetSession(); + std::shared_ptr spSession = m_pWebSock->GetSession(); spSession->SetUser(&User); @@ -167,7 +167,7 @@ void CWebAuth::AcceptedLogin(CUser& User) { void CWebAuth::RefusedLogin(const CString& sReason) { if (m_pWebSock) { - CSmartPtr spSession = m_pWebSock->GetSession(); + std::shared_ptr spSession = m_pWebSock->GetSession(); spSession->AddError("Invalid login!"); spSession->SetUser(NULL); @@ -192,7 +192,7 @@ CWebSock::CWebSock(const CString& sURIPrefix) : CHTTPSock(NULL, sURIPrefix) { } CWebSock::~CWebSock() { - if (!m_spAuth.IsNull()) { + if (m_spAuth) { m_spAuth->Invalidate(); } @@ -819,13 +819,13 @@ static inline bool compareLastActive(const std::pairGetLastActive() < second.second->GetLastActive(); } -CSmartPtr CWebSock::GetSession() { - if (!m_spSession.IsNull()) { +std::shared_ptr CWebSock::GetSession() { + if (m_spSession) { return m_spSession; } const CString sCookieSessionId = GetRequestCookie("SessionId"); - CSmartPtr *pSession = Sessions.m_mspSessions.GetItem(sCookieSessionId); + std::shared_ptr *pSession = Sessions.m_mspSessions.GetItem(sCookieSessionId); if (pSession != NULL) { // Refresh the timeout @@ -855,7 +855,7 @@ CSmartPtr CWebSock::GetSession() { DEBUG("Auto generated session: [" + sSessionID + "]"); } while (Sessions.m_mspSessions.HasItem(sSessionID)); - CSmartPtr spSession(new CWebSession(sSessionID, GetRemoteIP())); + std::shared_ptr spSession(new CWebSession(sSessionID, GetRemoteIP())); Sessions.m_mspSessions.AddItem(spSession->GetId(), spSession); m_spSession = spSession; @@ -864,7 +864,7 @@ CSmartPtr CWebSock::GetSession() { } CString CWebSock::GetCSRFCheck() { - CSmartPtr pSession = GetSession(); + std::shared_ptr pSession = GetSession(); return pSession->GetId().MD5(); } @@ -889,7 +889,7 @@ Csock* CWebSock::GetSockObj(const CString& sHost, unsigned short uPort) { } CString CWebSock::GetSkinName() { - CSmartPtr spSession = GetSession(); + std::shared_ptr spSession = GetSession(); if (spSession->IsLoggedIn() && !spSession->GetUser()->GetSkinName().empty()) { return spSession->GetUser()->GetSkinName();