Permalink
Browse files

Include less headers in WebModules.h

From Client.h, only CAuthBase is needed. This is solved by moving the whole
CWebAuth class to WebModules.cpp.

The include of FileUtils.h is avoided by changing the API. GetAvailSkins() now
returns the skin names instead of a CFile for the skin's path.

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information...
1 parent 3fa04f8 commit ad442f4f107260d91e91c3e2121984fbff4b9b32 @psychon psychon committed Apr 3, 2011
Showing with 29 additions and 30 deletions.
  1. +18 −5 WebModules.cpp
  2. +3 −17 WebModules.h
  3. +8 −8 modules/webadmin.cpp
View
@@ -34,6 +34,20 @@ typedef std::multimap<CString, CWebSession*>::iterator mIPSessionsIterator;
static CSessionManager Sessions;
+class CWebAuth : public CAuthBase {
+public:
+ CWebAuth(CWebSock* pWebSock, const CString& sUsername, const CString& sPassword);
+ virtual ~CWebAuth() {}
+
+ void SetWebSock(CWebSock* pWebSock) { m_pWebSock = pWebSock; }
+ void AcceptedLogin(CUser& User);
+ void RefusedLogin(const CString& sReason);
+ void Invalidate();
+private:
+protected:
+ CWebSock* m_pWebSock;
+};
+
void CWebSock::FinishUserSessions(const CUser& User) {
Sessions.m_mspSessions.FinishUserSessions(User);
}
@@ -198,7 +212,7 @@ void CWebSock::ParsePath() {
DEBUG("Path [" + m_sPath + "], Module [" + m_sModName + "], Page [" + m_sPage + "]");
}
-size_t CWebSock::GetAvailSkins(vector<CFile>& vRet) const {
+void CWebSock::GetAvailSkins(VCString& vRet) const {
vRet.clear();
CString sRoot(GetSkinPath("_default_"));
@@ -218,20 +232,19 @@ size_t CWebSock::GetAvailSkins(vector<CFile>& vRet) const {
const CFile& SubDir = *Dir[d];
if (SubDir.IsDir() && SubDir.GetShortName() == "_default_") {
- vRet.push_back(SubDir);
+ vRet.push_back(SubDir.GetShortName());
+ break;
}
}
for (unsigned int e = 0; e < Dir.size(); e++) {
const CFile& SubDir = *Dir[e];
if (SubDir.IsDir() && SubDir.GetShortName() != "_default_" && SubDir.GetShortName() != ".svn") {
- vRet.push_back(SubDir);
+ vRet.push_back(SubDir.GetShortName());
}
}
}
-
- return vRet.size();
}
VCString CWebSock::GetDirs(CModule* pModule, bool bIsTemplate) {
View
@@ -10,11 +10,11 @@
#define _WEBMODULES_H
#include "zncconfig.h"
-#include "Client.h"
#include "Template.h"
#include "HTTPSock.h"
-#include "FileUtils.h"
+class CAuthBase;
+class CUser;
class CWebSock;
class CModule;
class CWebSubPage;
@@ -91,20 +91,6 @@ class CWebSubPage {
VPair m_vParams;
};
-class CWebAuth : public CAuthBase {
-public:
- CWebAuth(CWebSock* pWebSock, const CString& sUsername, const CString& sPassword);
- virtual ~CWebAuth() {}
-
- void SetWebSock(CWebSock* pWebSock) { m_pWebSock = pWebSock; }
- void AcceptedLogin(CUser& User);
- void RefusedLogin(const CString& sReason);
- void Invalidate();
-private:
-protected:
- CWebSock* m_pWebSock;
-};
-
class CWebSessionMap : public TCacheMap<CString, CSmartPtr<CWebSession> > {
public:
CWebSessionMap(unsigned int uTTL = 5000) : TCacheMap<CString, CSmartPtr<CWebSession> >(uTTL) {}
@@ -141,7 +127,7 @@ class CWebSock : public CHTTPSock {
virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort);
static CString GetSkinPath(const CString& sSkinName);
CModule* GetModule() const { return (CModule*) m_pModule; }
- size_t GetAvailSkins(vector<CFile>& vRet) const;
+ void GetAvailSkins(VCString& vRet) const;
CString GetSkinName();
CString GetRequestCookie(const CString& sKey);
View
@@ -724,15 +724,15 @@ class CWebAdminMod : public CGlobalModule {
}
}
- vector<CFile> vDirs;
+ vector<CString> vDirs;
WebSock.GetAvailSkins(vDirs);
for (unsigned int d = 0; d < vDirs.size(); d++) {
- const CFile& SubDir = vDirs[d];
+ const CString& SubDir = vDirs[d];
CTemplate& l = Tmpl.AddRow("SkinLoop");
- l["Name"] = SubDir.GetShortName();
+ l["Name"] = SubDir;
- if (pUser && SubDir.GetShortName() == pUser->GetSkinName()) {
+ if (pUser && SubDir == pUser->GetSkinName()) {
l["Checked"] = "true";
}
}
@@ -1019,15 +1019,15 @@ class CWebAdminMod : public CGlobalModule {
#endif
}
- vector<CFile> vDirs;
+ vector<CString> vDirs;
WebSock.GetAvailSkins(vDirs);
for (unsigned int d = 0; d < vDirs.size(); d++) {
- const CFile& SubDir = vDirs[d];
+ const CString& SubDir = vDirs[d];
CTemplate& l = Tmpl.AddRow("SkinLoop");
- l["Name"] = SubDir.GetShortName();
+ l["Name"] = SubDir;
- if (SubDir.GetShortName() == CZNC::Get().GetSkinName()) {
+ if (SubDir == CZNC::Get().GetSkinName()) {
l["Checked"] = "true";
}
}

0 comments on commit ad442f4

Please sign in to comment.