diff options
author | nat-goodspeed <nat@lindenlab.com> | 2024-08-06 09:05:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-06 09:05:25 -0400 |
commit | 628cd605080546c400d3343bf0834bebf693bbcf (patch) | |
tree | 1719f8ce969f99aea819875c35cbde5e9ee0bd32 /indra/newview/scripts/lua | |
parent | d6abce3968925c5cb58c11f1c6fc936605f55c57 (diff) | |
parent | b12d135c38e327774c01594acfa96e37a9e67a64 (diff) |
Merge pull request #2185 from secondlife/lua-login2
Add 'LLPanelLogin' 'login', 'savedLogins' operations.
Diffstat (limited to 'indra/newview/scripts/lua')
-rw-r--r-- | indra/newview/scripts/lua/require/login.lua | 40 | ||||
-rw-r--r-- | indra/newview/scripts/lua/test_login.lua | 13 |
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 + })) |