2012-06-14 06:06:06 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../WebServer/WebServer.h"
|
2012-09-23 14:23:33 -07:00
|
|
|
#include "OSSupport/Socket.h"
|
2012-06-14 06:06:06 -07:00
|
|
|
|
|
|
|
class cStringMap;
|
2013-07-28 17:37:59 -07:00
|
|
|
class cLuaScript;
|
2012-06-14 06:06:06 -07:00
|
|
|
|
2013-07-28 17:37:59 -07:00
|
|
|
struct HTTPFormData // tolua_export
|
|
|
|
{ // tolua_export
|
|
|
|
std::string Name; // tolua_export
|
|
|
|
std::string Value; // tolua_export
|
|
|
|
std::string Type; // tolua_export
|
2013-01-11 20:46:01 -08:00
|
|
|
};// tolua_export
|
|
|
|
|
2013-07-28 17:37:59 -07:00
|
|
|
struct HTTPRequest // tolua_export
|
|
|
|
{ // tolua_export
|
2012-06-14 06:06:06 -07:00
|
|
|
typedef std::map< std::string, std::string > StringStringMap;
|
|
|
|
typedef std::map< std::string, HTTPFormData > FormDataMap;
|
2013-07-28 17:37:59 -07:00
|
|
|
AString Method; // tolua_export
|
|
|
|
AString Path; // tolua_export
|
|
|
|
StringStringMap Params; // >> EXPORTED IN MANUALBINDINGS <<
|
|
|
|
StringStringMap PostParams; // >> EXPORTED IN MANUALBINDINGS <<
|
|
|
|
AString Username; // tolua_export
|
|
|
|
FormDataMap FormData; // >> EXPORTED IN MANUALBINDINGS <<
|
2013-01-11 20:46:01 -08:00
|
|
|
}; // tolua_export
|
2012-06-14 06:06:06 -07:00
|
|
|
|
2013-07-28 17:37:59 -07:00
|
|
|
struct HTTPTemplateRequest // tolua_export
|
|
|
|
{ // tolua_export
|
|
|
|
HTTPRequest Request; // tolua_export
|
|
|
|
|
|
|
|
}; // tolua_export
|
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
struct sWebAdminPage
|
|
|
|
{
|
|
|
|
AString Content;
|
|
|
|
AString PluginName;
|
|
|
|
AString TabName;
|
|
|
|
};
|
|
|
|
// tolua_end
|
|
|
|
|
2012-06-14 06:06:06 -07:00
|
|
|
struct lua_State;
|
|
|
|
class cEvent;
|
|
|
|
class cIniFile;
|
|
|
|
class cWebPlugin;
|
2013-07-28 17:37:59 -07:00
|
|
|
|
|
|
|
class cWebAdmin // tolua_export
|
|
|
|
{ // tolua_export
|
|
|
|
public: // tolua_export
|
2012-06-14 06:06:06 -07:00
|
|
|
cWebAdmin( int a_Port = 8080 );
|
|
|
|
~cWebAdmin();
|
|
|
|
|
2013-07-28 17:37:59 -07:00
|
|
|
bool Init( int a_Port );
|
2012-06-14 06:06:06 -07:00
|
|
|
|
2013-07-28 17:37:59 -07:00
|
|
|
void AddPlugin( cWebPlugin* a_Plugin );
|
|
|
|
void RemovePlugin( cWebPlugin* a_Plugin );
|
2012-06-14 06:06:06 -07:00
|
|
|
|
|
|
|
typedef std::list< cWebPlugin* > PluginList;
|
|
|
|
|
2013-07-28 17:37:59 -07:00
|
|
|
// 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);
|
|
|
|
|
2013-07-29 01:59:10 -07:00
|
|
|
int GetPort() { return m_Port; } // tolua_export
|
2012-09-30 09:37:44 -07:00
|
|
|
|
2013-07-29 01:59:10 -07:00
|
|
|
sWebAdminPage GetPage(const HTTPRequest& a_Request); // tolua_export
|
|
|
|
AString GetBaseURL(const AString& a_URL); // tolua_export
|
2013-07-28 17:37:59 -07:00
|
|
|
AString GetBaseURL(const AStringVector& a_URLSplit);
|
|
|
|
|
2013-07-29 01:59:10 -07:00
|
|
|
static AString GetMemoryUsage(void); // tolua_export
|
2012-06-14 06:06:06 -07:00
|
|
|
private:
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
static DWORD WINAPI ListenThread(LPVOID lpParam);
|
|
|
|
#else
|
2013-07-28 17:37:59 -07:00
|
|
|
static void * ListenThread( void *lpParam );
|
2012-06-14 06:06:06 -07:00
|
|
|
#endif
|
|
|
|
|
2013-07-28 17:37:59 -07:00
|
|
|
AString GetTemplate();
|
|
|
|
|
|
|
|
cLuaScript* m_pTemplate;
|
2012-06-14 06:06:06 -07:00
|
|
|
|
2013-07-28 17:37:59 -07:00
|
|
|
int m_Port;
|
2012-06-14 06:06:06 -07:00
|
|
|
|
2013-07-28 17:37:59 -07:00
|
|
|
bool m_bConnected;
|
|
|
|
cSocket m_ListenSocket;
|
2012-06-14 06:06:06 -07:00
|
|
|
|
2013-07-28 17:37:59 -07:00
|
|
|
cIniFile* m_IniFile;
|
|
|
|
PluginList m_Plugins;
|
2012-06-14 06:06:06 -07:00
|
|
|
|
2013-07-28 17:37:59 -07:00
|
|
|
cEvent* m_Event;
|
2012-06-14 06:06:06 -07:00
|
|
|
|
2013-07-28 17:37:59 -07:00
|
|
|
webserver* m_WebServer;
|
|
|
|
}; // tolua_export
|