20 #pragma warning(disable:4355)
107 class cWebTabCallback
abstract
111 virtual ~cWebTabCallback() {}
209 std::shared_ptr<cWebTabCallback> a_Callback
286 #if defined(_MSC_VER)
AString StringsConcat(const AStringVector &a_Strings, char a_Separator)
Concatenates the specified strings into a single string, separated by the specified separator charact...
std::vector< AString > AStringVector
Encapsulates a Lua state and provides some syntactic sugar for common operations.
Provides storage for an incoming HTTP request.
FormDataMap FormData
Same as PostParams.
StringStringMap PostParams
Parameters posted as a part of a form - either in the URL (GET method) or in the body (POST method)
AString URL
The entire URL presented to the HTTP server.
AString Method
HTTP method used for the request ("GET", "POST" etc.)
std::map< std::string, std::string > StringStringMap
StringStringMap Params
Parameters given in the URL, after the questionmark.
AString Path
The Path part of the request's URL (excluding GET params).
AString Username
Name of the logged-in user.
std::map< std::string, HTTPFormData > FormDataMap
virtual void OnRequestBody(cHTTPServerConnection &a_Connection, cHTTPIncomingRequest &a_Request, const char *a_Data, size_t a_Size) override
Called when another part of request body has arrived.
cLuaState m_TemplateScript
The Lua template script to provide templates.
void Stop(void)
Stops the HTTP server, if it was started.
static AString GetContentTypeFromFileExt(const AString &a_FileExtension)
Returns the content type from the file extension.
AStringVector m_Ports
The ports on which the webadmin is running.
std::shared_ptr< cWebTab > cWebTabPtr
cIniFile m_IniFile
The webadmin.ini file, used for the settings and allowed logins.
void HandleFileRequest(cHTTPServerConnection &a_Connection, cHTTPIncomingRequest &a_Request)
Handles requests for a file.
virtual void OnRequestBegun(cHTTPServerConnection &a_Connection, cHTTPIncomingRequest &a_Request) override
Called when a new request arrives over a connection and all its headers have been parsed.
cCriticalSection m_CS
Protects m_WebTabs, m_TemplateScript, m_LoginTemplate and m_IniFile against multithreaded access.
void HandleWebadminRequest(cHTTPServerConnection &a_Connection, cHTTPIncomingRequest &a_Request)
Handles requests coming to the "/webadmin" or "/~webadmin" URLs.
virtual void OnRequestFinished(cHTTPServerConnection &a_Connection, cHTTPIncomingRequest &a_Request) override
Called when the request body has been fully received in previous calls to OnRequestBody()
bool DelWebTab(const AString &a_UrlPath)
Removes the WebTab with the specified URL path.
std::vector< cWebTabPtr > cWebTabPtrs
bool LoadIniFile(void)
Loads webadmin.ini into m_IniFile.
void HandleRootRequest(cHTTPServerConnection &a_Connection, cHTTPIncomingRequest &a_Request)
Handles requests for the root page.
bool LoadLoginPage(void)
Loads the login template into m_LoginPage.
bool Start(void)
Starts the HTTP server taking care of the webadmin.
bool Init(void)
Initializes the object.
bool m_IsRunning
Set to true if Start() succeeds in starting the server, reset back to false in Stop().
virtual ~cWebAdmin() override
bool HasUsers()
Checks inside the webadmin.ini file if there are users configured.
void RemoveAllPluginWebTabs(const AString &a_PluginName)
Removes all WebTabs registered by the specified plugin.
static AString GetURLEncodedString(const AString &a_Input)
Escapes the string for use in an URL Exported to Lua in ManualBindings.cpp.
AString GetPorts(void) const
Returns the list of ports on which the webadmin is configured to listen.
void Reload(void)
Reloads m_IniFile, m_LoginPage and m_TemplateScript.
void AddWebTab(const AString &a_Title, const AString &a_UrlPath, const AString &a_PluginName, std::shared_ptr< cWebTabCallback > a_Callback)
Adds a new WebTab handler.
cWebTabPtrs m_WebTabs
All registered WebTab handlers.
cHTTPServer m_HTTPServer
The HTTP server which provides the underlying HTTP parsing, serialization and events.
static AString GetBaseURL(const AString &a_URL)
Returns the prefix needed for making a link point to the webadmin root from the given URL ("....
cWebTabPtrs GetAllWebTabs(void)
Returns a copy of all the registered web tabs.
static AString GetHTMLEscapedString(const AString &a_Input)
Escapes text passed into it, so it can be embedded into html.
bool m_IsInitialized
Set to true if Init() succeeds and the webadmin isn't to be disabled.
sWebAdminPage GetPage(const HTTPRequest &a_Request)
Returns the (inner) page contents for the specified request.
AString m_LoginPage
The HTML page that provides the login.
Container for a single web tab.
cWebTab(const AString &a_Title, const AString &a_UrlPath, const AString &a_PluginName, std::shared_ptr< cWebTabCallback > a_Callback)
std::shared_ptr< cWebTabCallback > m_Callback