summaryrefslogtreecommitdiffstats
path: root/src/Bindings/WebPlugin.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-04-19 14:35:04 +0200
committerMattes D <github@xoft.cz>2015-04-19 14:35:04 +0200
commit288d2280fa85225613534ae56a59e35465bbefe2 (patch)
tree85234752e9cd96f21fcdc56d48f3ae651bdc7c1a /src/Bindings/WebPlugin.h
parentSplit the plugin names and plugin folders to avoid confusing them. (diff)
downloadcuberite-288d2280fa85225613534ae56a59e35465bbefe2.tar
cuberite-288d2280fa85225613534ae56a59e35465bbefe2.tar.gz
cuberite-288d2280fa85225613534ae56a59e35465bbefe2.tar.bz2
cuberite-288d2280fa85225613534ae56a59e35465bbefe2.tar.lz
cuberite-288d2280fa85225613534ae56a59e35465bbefe2.tar.xz
cuberite-288d2280fa85225613534ae56a59e35465bbefe2.tar.zst
cuberite-288d2280fa85225613534ae56a59e35465bbefe2.zip
Diffstat (limited to 'src/Bindings/WebPlugin.h')
-rw-r--r--src/Bindings/WebPlugin.h61
1 files changed, 47 insertions, 14 deletions
diff --git a/src/Bindings/WebPlugin.h b/src/Bindings/WebPlugin.h
index 9b825b918..ade4f4359 100644
--- a/src/Bindings/WebPlugin.h
+++ b/src/Bindings/WebPlugin.h
@@ -12,34 +12,67 @@ class cWebPlugin
{
public:
// tolua_end
+
+ struct cTab
+ {
+ AString m_Title;
+ AString m_SafeTitle;
+ int m_UserData;
+
+ cTab(const AString & a_Title, int a_UserData):
+ m_Title(a_Title),
+ m_SafeTitle(cWebPlugin::SafeString(a_Title)),
+ m_UserData(a_UserData)
+ {
+ }
+ };
+
+ typedef SharedPtr<cTab> cTabPtr;
+ typedef std::list<cTabPtr> cTabPtrs;
+ typedef std::list<std::pair<AString, AString>> cTabNames;
+
+
cWebPlugin();
+
virtual ~cWebPlugin();
// tolua_begin
+
+ /** Returns the title of the plugin, as it should be presented in the webadmin's pages tree. */
virtual const AString GetWebTitle(void) const = 0;
- virtual AString HandleWebRequest(const HTTPRequest * a_Request) = 0;
+ /** Sanitizes the input string, replacing spaces with underscores. */
+ static AString SafeString(const AString & a_String);
- static AString SafeString( const AString & a_String);
// tolua_end
- struct sWebPluginTab
- {
- std::string Title;
- std::string SafeTitle;
+ virtual AString HandleWebRequest(const HTTPRequest & a_Request) = 0;
- int UserData;
- };
+ /** Adds a new web tab with the specified contents. */
+ void AddNewWebTab(const AString & a_Title, int a_UserData);
+
+ /** Removes all the tabs. */
+ void ClearTabs(void);
- typedef std::list< sWebPluginTab* > TabList;
- TabList & GetTabs() { return m_Tabs; }
+ /** Returns all the tabs that this plugin has registered. */
+ const cTabPtrs & GetTabs(void) const { return m_Tabs; }
- typedef std::list< std::pair<AString, AString> > TabNameList;
- TabNameList GetTabNames(); // >> EXPORTED IN MANUALBINDINGS <<
- std::pair< AString, AString > GetTabNameForRequest(const HTTPRequest* a_Request);
+ /** Returns all of the tabs that this plugin has registered. */
+ cTabNames GetTabNames(void) const; // Exported in ManualBindings.cpp
+
+ /** Returns the tab that has the specified SafeTitle.
+ Returns nullptr if no such tab. */
+ cTabPtr GetTabBySafeTitle(const AString & a_SafeTitle) const;
+
+ std::pair<AString, AString> GetTabNameForRequest(const HTTPRequest & a_Request);
private:
- TabList m_Tabs;
+ /** All tabs that this plugin has registered.
+ Protected against multithreaded access by m_CSTabs. */
+ cTabPtrs m_Tabs;
+
+ /** Protects m_Tabs against multithreaded access. */
+ mutable cCriticalSection m_CSTabs;
}; // tolua_export