summaryrefslogtreecommitdiff
path: root/indra/newview/llcommandhandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llcommandhandler.cpp')
-rw-r--r--indra/newview/llcommandhandler.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/indra/newview/llcommandhandler.cpp b/indra/newview/llcommandhandler.cpp
index 8c7e7bea83..dc506a1692 100644
--- a/indra/newview/llcommandhandler.cpp
+++ b/indra/newview/llcommandhandler.cpp
@@ -36,6 +36,7 @@
#include "llcommandhandler.h"
#include "llnotificationsutil.h"
#include "llcommanddispatcherlistener.h"
+#include "stringize.h"
// system includes
#include <boost/tokenizer.hpp>
@@ -67,6 +68,7 @@ public:
bool trusted_browser);
private:
+ friend LLSD LLCommandDispatcher::enumerate();
std::map<std::string, LLCommandHandlerInfo> mMap;
};
@@ -175,3 +177,56 @@ bool LLCommandDispatcher::dispatch(const std::string& cmd,
return LLCommandHandlerRegistry::instance().dispatch(
cmd, params, query_map, web, trusted_browser);
}
+
+static std::string lookup(LLCommandHandler::EUntrustedAccess value);
+
+LLSD LLCommandDispatcher::enumerate()
+{
+ LLSD response;
+ LLCommandHandlerRegistry& registry(LLCommandHandlerRegistry::instance());
+ for (std::map<std::string, LLCommandHandlerInfo>::const_iterator chi(registry.mMap.begin()),
+ chend(registry.mMap.end());
+ chi != chend; ++chi)
+ {
+ LLSD info;
+ info["untrusted"] = chi->second.mUntrustedBrowserAccess;
+ info["untrusted_str"] = lookup(chi->second.mUntrustedBrowserAccess);
+ response[chi->first] = info;
+ }
+ return response;
+}
+
+/*------------------------------ lookup stuff ------------------------------*/
+struct symbol_info
+{
+ const char* name;
+ LLCommandHandler::EUntrustedAccess value;
+};
+
+#define ent(SYMBOL) \
+ { \
+ #SYMBOL + 28, /* skip "LLCommandHandler::UNTRUSTED_" prefix */ \
+ SYMBOL \
+ }
+
+symbol_info symbols[] =
+{
+ ent(LLCommandHandler::UNTRUSTED_ALLOW), // allow commands from untrusted browsers
+ ent(LLCommandHandler::UNTRUSTED_BLOCK), // ignore commands from untrusted browsers
+ ent(LLCommandHandler::UNTRUSTED_THROTTLE) // allow untrusted, but only a few per min.
+};
+
+#undef ent
+
+static std::string lookup(LLCommandHandler::EUntrustedAccess value)
+{
+ for (symbol_info *sii(symbols), *siend(symbols + (sizeof(symbols)/sizeof(symbols[0])));
+ sii != siend; ++sii)
+ {
+ if (sii->value == value)
+ {
+ return sii->name;
+ }
+ }
+ return STRINGIZE("UNTRUSTED_" << value);
+}