2023-10-03 16:11:25 +00:00
|
|
|
import "pkg:/source/api/userauth.bs"
|
|
|
|
import "pkg:/source/api/baserequest.bs"
|
|
|
|
import "pkg:/source/utils/config.bs"
|
2023-06-01 12:43:27 +00:00
|
|
|
import "pkg:/source/utils/session.bs"
|
2023-05-03 21:21:04 +00:00
|
|
|
|
2022-05-29 20:00:38 +00:00
|
|
|
sub init()
|
|
|
|
m.quickConnectTimer = m.top.findNode("quickConnectTimer")
|
|
|
|
m.quickConnectTimer.observeField("fire", "quickConnectStatus")
|
|
|
|
m.quickConnectTimer.control = "start"
|
|
|
|
m.top.observeFieldScoped("buttonSelected", "onButtonSelected")
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub quickConnectStatus()
|
|
|
|
m.quickConnectTimer.control = "stop"
|
|
|
|
m.checkTask = CreateObject("roSGNode", "QuickConnect")
|
|
|
|
m.checkTask.secret = m.top.quickConnectJson.secret
|
2024-01-13 17:00:29 +00:00
|
|
|
m.checkTask.saveCredentials = m.top.saveCredentials
|
2022-05-29 20:00:38 +00:00
|
|
|
m.checkTask.observeField("authenticated", "OnAuthenticated")
|
|
|
|
m.checkTask.control = "run"
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub OnAuthenticated()
|
2024-01-13 17:00:29 +00:00
|
|
|
m.checkTask.control = "stop"
|
2022-05-29 20:00:38 +00:00
|
|
|
m.checkTask.unobserveField("authenticated")
|
|
|
|
|
|
|
|
' Did we get the A-OK to authenticate?
|
|
|
|
authenticated = m.checkTask.authenticated
|
|
|
|
if authenticated < 0
|
|
|
|
' Still waiting, check again in 3 seconds...
|
|
|
|
authenticated = 0
|
|
|
|
m.quickConnectTimer.control = "start"
|
|
|
|
else if authenticated > 0
|
2024-01-13 17:00:29 +00:00
|
|
|
' We've been logged in via Quick Connect...
|
|
|
|
m.top.close = true
|
|
|
|
m.top.authenticated = true
|
2022-05-29 20:00:38 +00:00
|
|
|
end if
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub quickConnectClosed()
|
|
|
|
m.quickConnectTimer.control = "stop"
|
|
|
|
if m.checkTask <> invalid
|
2024-01-13 17:00:29 +00:00
|
|
|
m.checkTask.control = "stop"
|
2022-05-29 20:00:38 +00:00
|
|
|
m.checkTask.unobserveField("authenticated")
|
|
|
|
end if
|
|
|
|
m.top.close = true
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub onButtonSelected()
|
|
|
|
' only one button at the moment...
|
|
|
|
quickConnectClosed()
|
|
|
|
end sub
|
|
|
|
|
|
|
|
function onKeyEvent(key as string, press as boolean) as boolean
|
|
|
|
if not press then return false
|
|
|
|
|
|
|
|
' Note that "OK" does not get sent here, hence onButtonSelected() above.
|
|
|
|
if key = "back"
|
|
|
|
quickConnectClosed()
|
|
|
|
return true
|
|
|
|
end if
|
|
|
|
|
|
|
|
return false
|
|
|
|
end function
|