diff options
author | Mnikolenko Productengine <mnikolenko@productengine.com> | 2024-05-15 18:50:51 +0300 |
---|---|---|
committer | Mnikolenko Productengine <mnikolenko@productengine.com> | 2024-05-15 18:50:51 +0300 |
commit | 9f540f10e687bb3889de191afbae3b52cc21f415 (patch) | |
tree | 48f561539193be6993dfd40e853a67b01cdb1812 /indra/llui | |
parent | cec3b8d870085925cd0c9fb900b7d5e4629bcbfd (diff) |
Add trusted flag to UI callbacks, so not everything is accessible from the script
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llmenugl.h | 9 | ||||
-rw-r--r-- | indra/llui/lluictrl.cpp | 8 | ||||
-rw-r--r-- | indra/llui/lluictrl.h | 16 |
3 files changed, 29 insertions, 4 deletions
diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index fdbfb38474..1dcf79d02c 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -950,16 +950,17 @@ public: LLUICtrl::EnableCallbackRegistry::currentRegistrar().add(name, boost::bind(&view_listener_t::handleEvent, listener, _2)); } - static void addCommit(view_listener_t* listener, const std::string& name) + static void addCommit(view_listener_t* listener, const std::string& name, bool allow_untrusted = false) { - LLUICtrl::CommitCallbackRegistry::currentRegistrar().add(name, boost::bind(&view_listener_t::handleEvent, listener, _2)); + LLUICtrl::SharedCommitCallbackRegistry::currentRegistrar().add(name, + LLUICtrl::LLCommitCallbackInfo(boost::bind(&view_listener_t::handleEvent, listener, _2), allow_untrusted)); } - static void addMenu(view_listener_t* listener, const std::string& name) + static void addMenu(view_listener_t* listener, const std::string& name, bool allow_untrusted = true) { // For now, add to both click and enable registries addEnable(listener, name); - addCommit(listener, name); + addCommit(listener, name, allow_untrusted); } static void cleanup() diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 7eb9ae69fb..ee41d20d7a 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -284,6 +284,7 @@ LLUICtrl::commit_signal_t::slot_type LLUICtrl::initCommitCallback(const CommitCa std::string function_name = cb.function_name; setFunctionName(function_name); commit_callback_t* func = (CommitCallbackRegistry::getValue(function_name)); + LLUICtrl::LLCommitCallbackInfo* info = LLUICtrl::SharedCommitCallbackRegistry::getValue(function_name); if (func) { if (cb.parameter.isProvided()) @@ -291,6 +292,13 @@ LLUICtrl::commit_signal_t::slot_type LLUICtrl::initCommitCallback(const CommitCa else return commit_signal_t::slot_type(*func); } + else if (info && info->callback_func) + { + if (cb.parameter.isProvided()) + return boost::bind((info->callback_func), _1, cb.parameter); + else + return commit_signal_t::slot_type(info->callback_func); + } else if (!function_name.empty()) { LL_WARNS() << "No callback found for: '" << function_name << "' in control: " << getName() << LL_ENDL; diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index cffb9933d4..5039d3e22c 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -282,6 +282,22 @@ public: { LLSINGLETON_EMPTY_CTOR(EnableCallbackRegistry); }; + + struct LLCommitCallbackInfo + { + LLCommitCallbackInfo(commit_callback_t func = NULL, bool allow_untrusted = false) + : callback_func(func), mAllowUntrusted(allow_untrusted) + {} + + public: + bool mAllowUntrusted; + commit_callback_t callback_func; + }; + + class SharedCommitCallbackRegistry : public CallbackRegistry<LLCommitCallbackInfo, SharedCommitCallbackRegistry> + { + LLSINGLETON_EMPTY_CTOR(SharedCommitCallbackRegistry); + }; protected: |