From 9f540f10e687bb3889de191afbae3b52cc21f415 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Wed, 15 May 2024 18:50:51 +0300 Subject: Add trusted flag to UI callbacks, so not everything is accessible from the script --- indra/llui/lluictrl.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'indra/llui/lluictrl.h') 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 + { + LLSINGLETON_EMPTY_CTOR(SharedCommitCallbackRegistry); + }; protected: -- cgit v1.2.3 From c808d849aa6aa17db95a7814e6eb6bc5162ba816 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Thu, 16 May 2024 02:29:52 +0300 Subject: adjust the flag to be untrusted block/allow/throttle --- indra/llui/lluictrl.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'indra/llui/lluictrl.h') diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index 5039d3e22c..ca8b66cfca 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -285,13 +285,20 @@ public: struct LLCommitCallbackInfo { - LLCommitCallbackInfo(commit_callback_t func = NULL, bool allow_untrusted = false) - : callback_func(func), mAllowUntrusted(allow_untrusted) + enum EUntrustedCall + { + UNTRUSTED_ALLOW, + UNTRUSTED_BLOCK, + UNTRUSTED_THROTTLE + }; + + LLCommitCallbackInfo(commit_callback_t func = NULL, EUntrustedCall handle_untrusted = UNTRUSTED_ALLOW) + : callback_func(func), mHandleUntrusted(handle_untrusted) {} public: - bool mAllowUntrusted; - commit_callback_t callback_func; + EUntrustedCall mHandleUntrusted; + commit_callback_t callback_func; }; class SharedCommitCallbackRegistry : public CallbackRegistry -- cgit v1.2.3 From f08a3c80d61795bb1fc0e576948bca3362ef8e6c Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 31 May 2024 20:03:13 +0300 Subject: Cherry-pick leap.lua changes; other clean up --- indra/llui/lluictrl.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llui/lluictrl.h') diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index 790c483aee..e507178d89 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -284,7 +284,7 @@ public: LLSINGLETON_EMPTY_CTOR(EnableCallbackRegistry); }; - struct LLCommitCallbackInfo + struct CommitCallbackInfo { enum EUntrustedCall { @@ -293,16 +293,16 @@ public: UNTRUSTED_THROTTLE }; - LLCommitCallbackInfo(commit_callback_t func = NULL, EUntrustedCall handle_untrusted = UNTRUSTED_ALLOW) - : callback_func(func), mHandleUntrusted(handle_untrusted) + CommitCallbackInfo(commit_callback_t func = {}, EUntrustedCall handle_untrusted = UNTRUSTED_ALLOW) + : callback_func(func), handle_untrusted(handle_untrusted) {} public: - EUntrustedCall mHandleUntrusted; commit_callback_t callback_func; + EUntrustedCall handle_untrusted; }; - class SharedCommitCallbackRegistry : public CallbackRegistry + class SharedCommitCallbackRegistry : public CallbackRegistry { LLSINGLETON_EMPTY_CTOR(SharedCommitCallbackRegistry); }; -- cgit v1.2.3 From ad608dbc5f0d57ad29ec3a15e4d0a434dfaa38d2 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 10 Jun 2024 14:29:22 +0300 Subject: Remove SharedCommitCallbackRegistry; add helpers CommitRegistrarHelper and ScopedRegistrarHelper --- indra/llui/lluictrl.h | 56 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 17 deletions(-) (limited to 'indra/llui/lluictrl.h') diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index e507178d89..46d651b19c 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -273,17 +273,6 @@ public: template class CallbackRegistry : public LLRegistrySingleton {}; - - class CommitCallbackRegistry : public CallbackRegistry - { - LLSINGLETON_EMPTY_CTOR(CommitCallbackRegistry); - }; - // the enable callback registry is also used for visiblity callbacks - class EnableCallbackRegistry : public CallbackRegistry - { - LLSINGLETON_EMPTY_CTOR(EnableCallbackRegistry); - }; - struct CommitCallbackInfo { enum EUntrustedCall @@ -293,18 +282,51 @@ public: UNTRUSTED_THROTTLE }; - CommitCallbackInfo(commit_callback_t func = {}, EUntrustedCall handle_untrusted = UNTRUSTED_ALLOW) - : callback_func(func), handle_untrusted(handle_untrusted) - {} + CommitCallbackInfo(commit_callback_t func = {}, EUntrustedCall handle_untrusted = UNTRUSTED_ALLOW) : + callback_func(func), + handle_untrusted(handle_untrusted) + { + } public: commit_callback_t callback_func; - EUntrustedCall handle_untrusted; + EUntrustedCall handle_untrusted; + }; + typedef LLUICtrl::CommitCallbackInfo cb_info; + class CommitCallbackRegistry : public CallbackRegistry + { + LLSINGLETON_EMPTY_CTOR(CommitCallbackRegistry); + }; + + class CommitRegistrarHelper + { + public: + CommitRegistrarHelper(LLUICtrl::CommitCallbackRegistry::Registrar ®istrar) : mRegistrar(registrar) {} + + template void add(const std::string &name, ARGS &&...args) + { + mRegistrar.add(name, {std::forward(args)...}); + } + private: + LLUICtrl::CommitCallbackRegistry::Registrar &mRegistrar; + }; + + class ScopedRegistrarHelper + { + public: + template void add(const std::string &name, ARGS &&...args) + { + mRegistrar.add(name, {std::forward(args)...}); + } + + private: + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar mRegistrar; }; - class SharedCommitCallbackRegistry : public CallbackRegistry + // the enable callback registry is also used for visiblity callbacks + class EnableCallbackRegistry : public CallbackRegistry { - LLSINGLETON_EMPTY_CTOR(SharedCommitCallbackRegistry); + LLSINGLETON_EMPTY_CTOR(EnableCallbackRegistry); }; protected: -- cgit v1.2.3