summaryrefslogtreecommitdiff
path: root/indra/newview/scripts/lua
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2024-08-06 18:00:32 +0300
committerGitHub <noreply@github.com>2024-08-06 18:00:32 +0300
commit0bf3b61457e7c77e91fb03d91b4caf0d702f99fa (patch)
tree8f43417c7f5605c3cee9a4d5c9fe255abbd63b4a /indra/newview/scripts/lua
parentcf29b701b19644062a1428a64023c3cf9829e2de (diff)
parent628cd605080546c400d3343bf0834bebf693bbcf (diff)
Merge branch 'release/luau-scripting' into lua-ui-visibility
Diffstat (limited to 'indra/newview/scripts/lua')
-rw-r--r--indra/newview/scripts/lua/require/login.lua40
-rw-r--r--indra/newview/scripts/lua/test_login.lua13
2 files changed, 35 insertions, 18 deletions
diff --git a/indra/newview/scripts/lua/require/login.lua b/indra/newview/scripts/lua/require/login.lua
index 0d8591cace..50fc9e3793 100644
--- a/indra/newview/scripts/lua/require/login.lua
+++ b/indra/newview/scripts/lua/require/login.lua
@@ -1,19 +1,33 @@
-local UI = require 'UI'
local leap = require 'leap'
+local startup = require 'startup'
+local mapargs = require 'mapargs'
-local function login(username, password)
- if username and password then
- local userpath = '//username_combo/Combo Text Entry'
- local passpath = '//password_edit'
- -- first clear anything presently in those text fields
- for _, path in pairs({userpath, passpath}) do
- UI.click(path)
- UI.keypress{keysym='Backsp', path=path}
- end
- UI.type{path=userpath, text=username}
- UI.type{path=passpath, text=password}
+local login = {}
+
+local function ensure_login_state(op)
+ -- no point trying to login until the viewer is ready
+ startup.wait('STATE_LOGIN_WAIT')
+ -- Once we've actually started login, LLPanelLogin is destroyed, and so is
+ -- its "LLPanelLogin" listener. At that point,
+ -- leap.request("LLPanelLogin", ...) will hang indefinitely because no one
+ -- is listening on that LLEventPump any more. Intercept that case and
+ -- produce a sensible error.
+ local state = startup.state()
+ if startup.before('STATE_LOGIN_WAIT', state) then
+ error(`Can't engage login operation {op} once we've reached state {state}`, 2)
end
- leap.send('LLPanelLogin', {op='onClickConnect'})
+end
+
+function login.login(...)
+ ensure_login_state('login')
+ local args = mapargs('username,grid,slurl', ...)
+ args.op = 'login'
+ return leap.request('LLPanelLogin', args)
+end
+
+function login.savedLogins(grid)
+ ensure_login_state('savedLogins')
+ return leap.request('LLPanelLogin', {op='savedLogins'})['logins']
end
return login
diff --git a/indra/newview/scripts/lua/test_login.lua b/indra/newview/scripts/lua/test_login.lua
index a8c31807bc..54d3635a41 100644
--- a/indra/newview/scripts/lua/test_login.lua
+++ b/indra/newview/scripts/lua/test_login.lua
@@ -1,7 +1,10 @@
-startup = require 'startup'
+inspect = require 'inspect'
login = require 'login'
-startup.wait('STATE_LOGIN_WAIT')
-login()
--- Fill in valid credentials as they would be entered on the login screen
--- login('My Username', 'password')
+local grid = 'agni'
+print(inspect(login.savedLogins(grid)))
+
+print(inspect(login.login{
+ username='Your Username',
+ grid=grid
+ }))