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.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'source/WebAdmin.cpp') diff --git a/source/WebAdmin.cpp b/source/WebAdmin.cpp index be7efa18d..788bf664e 100644 --- a/source/WebAdmin.cpp +++ b/source/WebAdmin.cpp @@ -13,7 +13,6 @@ #include "Player.h" #include "Server.h" #include "Root.h" -#include "LuaScript.h" #include "../iniFile/iniFile.h" @@ -54,13 +53,13 @@ cWebAdmin * WebAdmin = NULL; -cWebAdmin::cWebAdmin( int a_Port /* = 8080 */ ) - : m_Port( a_Port ) - , m_bConnected( false ) +cWebAdmin::cWebAdmin( int a_Port /* = 8080 */ ) : + m_Port(a_Port), + m_bConnected(false), + m_TemplateScript("") { WebAdmin = this; m_Event = new cEvent(); - m_pTemplate = new cLuaScript(); Init( m_Port ); } @@ -75,7 +74,6 @@ cWebAdmin::~cWebAdmin() m_WebServer->Stop(); delete m_WebServer; - delete m_pTemplate; delete m_IniFile; m_Event->Wait(); @@ -174,11 +172,11 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) TemplateRequest.Request.FormData[ fd.name_ ] = HTTPfd; } + // Try to get the template from the Lua template script bool bLuaTemplateSuccessful = false; if (!bDontShowTemplate) { - // New Lua web template - bLuaTemplateSuccessful = WebAdmin->m_pTemplate->CallShowPage(*WebAdmin, TemplateRequest, Template); + bLuaTemplateSuccessful = WebAdmin->m_TemplateScript.Call("ShowPage", WebAdmin, &TemplateRequest, cLuaState::Return, Template); } if (!bLuaTemplateSuccessful) @@ -269,7 +267,7 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) -bool cWebAdmin::Init( int a_Port ) +bool cWebAdmin::Init(int a_Port) { m_Port = a_Port; @@ -280,10 +278,11 @@ bool cWebAdmin::Init( int a_Port ) } // Initialize the WebAdmin template script and load the file - m_pTemplate->Initialize(); - if (!m_pTemplate->LoadFile(FILE_IO_PREFIX "webadmin/template.lua")) + m_TemplateScript.Create(); + if (!m_TemplateScript.LoadFile(FILE_IO_PREFIX "webadmin/template.lua")) { - LOGWARN("Could not load WebAdmin template."); + LOGWARN("Could not load WebAdmin template \"%s\", using default template.", FILE_IO_PREFIX "webadmin/template.lua"); + m_TemplateScript.Close(); } -- cgit v1.2.3