From fdb7207aa0d1f25ed3e14fbc4e8615e8383e508c Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 1 Aug 2024 16:52:44 -0400 Subject: Add UI.callables() and corresponding entry point. --- indra/newview/lluilistener.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'indra/newview/lluilistener.cpp') diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp index c73c93859a..2b2187a73b 100644 --- a/indra/newview/lluilistener.cpp +++ b/indra/newview/lluilistener.cpp @@ -55,6 +55,13 @@ LLUIListener::LLUIListener(): &LLUIListener::call, llsd::map("function", LLSD(), "reply", LLSD())); + add("callables", + "Return a list [\"callables\"] of dicts {name, access} of functions registered to\n" + "invoke with \"call\".\n" + "access has values \"allow\", \"block\" or \"throttle\".", + &LLUIListener::callables, + llsd::map("reply", LLSD::String())); + add("getValue", "For the UI control identified by the path in [\"path\"], return the control's\n" "current value as [\"value\"] reply.", @@ -131,6 +138,42 @@ void LLUIListener::call(const LLSD& event) (info->callback_func)(NULL, event["parameter"]); } +void LLUIListener::callables(const LLSD& event) const +{ + Response response(LLSD(), event); + + using Registry = LLUICtrl::CommitCallbackRegistry; + using Method = Registry::Registrar& (*)(); + static Method registrars[] = + { + &Registry::defaultRegistrar, + &Registry::currentRegistrar, + }; + LLSD list; + for (auto method : registrars) + { + auto& registrar{ (*method)() }; + for (auto it = registrar.beginItems(), end = registrar.endItems(); it != end; ++it) + { + LLSD entry{ llsd::map("name", it->first) }; + switch (it->second.handle_untrusted) + { + case LLUICtrl::CommitCallbackInfo::UNTRUSTED_ALLOW: + entry["access"] = "allow"; + break; + case LLUICtrl::CommitCallbackInfo::UNTRUSTED_BLOCK: + entry["access"] = "block"; + break; + case LLUICtrl::CommitCallbackInfo::UNTRUSTED_THROTTLE: + entry["access"] = "throttle"; + break; + } + list.append(entry); + } + } + response["callables"] = list; +} + void LLUIListener::getValue(const LLSD&event) const { Response response(LLSD(), event); -- cgit v1.2.3