summaryrefslogtreecommitdiff
path: root/indra/newview/scripts/lua
diff options
context:
space:
mode:
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
+ }))