diff options
Diffstat (limited to '')
-rw-r--r-- | src/WebAdmin.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index 13cf3cc41..1cb4463e1 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -234,7 +234,7 @@ void cWebAdmin::HandleWebadminRequest(cHTTPConnection & a_Connection, cHTTPReque bool ShouldWrapInTemplate = ((BareURL.length() > 1) && (BareURL[1] != '~')); // Retrieve the request data: - cWebadminRequestData * Data = (cWebadminRequestData *)(a_Request.GetUserData()); + cWebadminRequestData * Data = reinterpret_cast<cWebadminRequestData *>(a_Request.GetUserData()); if (Data == nullptr) { a_Connection.SendStatusAndReason(500, "Bad UserData"); @@ -244,6 +244,7 @@ void cWebAdmin::HandleWebadminRequest(cHTTPConnection & a_Connection, cHTTPReque // Wrap it all up for the Lua call: AString Template; HTTPTemplateRequest TemplateRequest; + TemplateRequest.Request.URL = a_Request.GetURL(); TemplateRequest.Request.Username = a_Request.GetAuthUsername(); TemplateRequest.Request.Method = a_Request.GetMethod(); TemplateRequest.Request.Path = BareURL.substr(1); @@ -464,10 +465,10 @@ sWebAdminPage cWebAdmin::GetPage(const HTTPRequest & a_Request) { if ((*itr)->GetWebTitle() == Split[1]) { - Page.Content = (*itr)->HandleWebRequest(&a_Request); + Page.Content = (*itr)->HandleWebRequest(a_Request); cWebPlugin * WebPlugin = *itr; FoundPlugin = WebPlugin->GetWebTitle(); - AString TabName = WebPlugin->GetTabNameForRequest(&a_Request).first; + AString TabName = WebPlugin->GetTabNameForRequest(a_Request).first; Page.PluginName = FoundPlugin; Page.TabName = TabName; break; @@ -489,20 +490,32 @@ AString cWebAdmin::GetDefaultPage(void) Content += "<h4>Server Name:</h4>"; Content += "<p>" + AString( cRoot::Get()->GetServer()->GetServerID()) + "</p>"; + // Display a list of all plugins: Content += "<h4>Plugins:</h4><ul>"; - cPluginManager * PM = cPluginManager::Get(); - const cPluginManager::PluginMap & List = PM->GetAllPlugins(); - for (cPluginManager::PluginMap::const_iterator itr = List.begin(); itr != List.end(); ++itr) + struct cPluginCallback: + public cPluginManager::cPluginCallback { - if (itr->second == nullptr) + AString & m_Content; + + cPluginCallback(AString & a_Content): + m_Content(a_Content) { - continue; } - AppendPrintf(Content, "<li>%s V.%i</li>", itr->second->GetName().c_str(), itr->second->GetVersion()); - } + + virtual bool Item(cPlugin * a_Plugin) override + { + if (a_Plugin->IsLoaded()) + { + AppendPrintf(m_Content, "<li>%s V.%i</li>", a_Plugin->GetName().c_str(), a_Plugin->GetVersion()); + } + return false; + } + } Callback(Content); + cPluginManager::Get()->ForEachPlugin(Callback); Content += "</ul>"; - Content += "<h4>Players:</h4><ul>"; + // Display a list of all players: + Content += "<h4>Players:</h4><ul>"; cPlayerAccum PlayerAccum; cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players if (World != nullptr) @@ -518,7 +531,7 @@ AString cWebAdmin::GetDefaultPage(void) -AString cWebAdmin::GetBaseURL( const AString& a_URL) +AString cWebAdmin::GetBaseURL(const AString & a_URL) { return GetBaseURL(StringSplit(a_URL, "/")); } |