From eb323166d9ae600fe422725ea29575ba4613b6d2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 8 Aug 2013 16:30:02 +0200 Subject: Removed LuaScript. The WebAdmin now uses LuaState directly to call the one function it needs. --- source/WebAdmin.h | 132 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 87 insertions(+), 45 deletions(-) (limited to 'source/WebAdmin.h') diff --git a/source/WebAdmin.h b/source/WebAdmin.h index 4b12b955e..a62b532f1 100644 --- a/source/WebAdmin.h +++ b/source/WebAdmin.h @@ -2,34 +2,62 @@ #include "../WebServer/WebServer.h" #include "OSSupport/Socket.h" +#include "LuaState.h" + + + +// fwd: class cStringMap; -class cLuaScript; +class cEvent; +class cIniFile; +class cWebPlugin; + + + + + +// tolua_begin +struct HTTPFormData +{ + std::string Name; + std::string Value; + std::string Type; +} ; +// tolua_end + -struct HTTPFormData // tolua_export -{ // tolua_export - std::string Name; // tolua_export - std::string Value; // tolua_export - std::string Type; // tolua_export -};// tolua_export -struct HTTPRequest // tolua_export -{ // tolua_export + +// tolua_begin +struct HTTPRequest +{ typedef std::map< std::string, std::string > StringStringMap; typedef std::map< std::string, HTTPFormData > FormDataMap; - AString Method; // tolua_export - AString Path; // tolua_export + + AString Method; + AString Path; + AString Username; + // tolua_end StringStringMap Params; // >> EXPORTED IN MANUALBINDINGS << StringStringMap PostParams; // >> EXPORTED IN MANUALBINDINGS << - AString Username; // tolua_export FormDataMap FormData; // >> EXPORTED IN MANUALBINDINGS << -}; // tolua_export +} ; // tolua_export + + + + + +// tolua_begin +struct HTTPTemplateRequest +{ + HTTPRequest Request; +} ; +// tolua_end + + -struct HTTPTemplateRequest // tolua_export -{ // tolua_export - HTTPRequest Request; // tolua_export -}; // tolua_export // tolua_begin struct sWebAdminPage @@ -40,14 +68,19 @@ struct sWebAdminPage }; // tolua_end -struct lua_State; -class cEvent; -class cIniFile; -class cWebPlugin; -class cWebAdmin // tolua_export -{ // tolua_export -public: // tolua_export + + + +// tolua_begin +class cWebAdmin +{ +public: + // tolua_end + + typedef std::list< cWebPlugin* > PluginList; + + cWebAdmin( int a_Port = 8080 ); ~cWebAdmin(); @@ -56,41 +89,50 @@ public: // tolua_export void AddPlugin( cWebPlugin* a_Plugin ); void RemovePlugin( cWebPlugin* a_Plugin ); - typedef std::list< cWebPlugin* > PluginList; - // TODO: Convert this to the auto-locking callback mechanism used for looping players in worlds and such PluginList GetPlugins() const { return m_Plugins; } // >> EXPORTED IN MANUALBINDINGS << static void Request_Handler(webserver::http_request* r); - int GetPort() { return m_Port; } // tolua_export + // tolua_begin + static AString GetMemoryUsage(void); + + int GetPort() { return m_Port; } + + sWebAdminPage GetPage(const HTTPRequest& a_Request); + AString GetBaseURL(const AString& a_URL); + + // tolua_end - sWebAdminPage GetPage(const HTTPRequest& a_Request); // tolua_export - AString GetBaseURL(const AString& a_URL); // tolua_export AString GetBaseURL(const AStringVector& a_URLSplit); - static AString GetMemoryUsage(void); // tolua_export + private: + int m_Port; + + bool m_bConnected; + cSocket m_ListenSocket; + + cIniFile * m_IniFile; + PluginList m_Plugins; + + cEvent * m_Event; + + webserver * m_WebServer; -#ifdef _WIN32 - static DWORD WINAPI ListenThread(LPVOID lpParam); -#else - static void * ListenThread( void *lpParam ); -#endif + /// The Lua template script to provide templates: + cLuaState m_TemplateScript; - AString GetTemplate(); - cLuaScript* m_pTemplate; + #ifdef _WIN32 + static DWORD WINAPI ListenThread(LPVOID lpParam); + #else + static void * ListenThread(void * lpParam); + #endif - int m_Port; + AString GetTemplate(); +} ; // tolua_export - bool m_bConnected; - cSocket m_ListenSocket; - cIniFile* m_IniFile; - PluginList m_Plugins; - cEvent* m_Event; - webserver* m_WebServer; -}; // tolua_export \ No newline at end of file -- cgit v1.2.3