2019-01-30 04:19:27 +00:00
|
|
|
sub Main()
|
2019-05-02 17:45:07 +00:00
|
|
|
|
|
|
|
' If the Rooibos files are included in deployment, run tests
|
|
|
|
if (type(Rooibos__Init) = "Function") then Rooibos__Init()
|
|
|
|
|
2019-04-29 16:44:37 +00:00
|
|
|
' The main function that runs when the application is launched.
|
2019-03-06 02:28:52 +00:00
|
|
|
keepalive = CreateObject("roSGScreen")
|
|
|
|
keepalive.show()
|
|
|
|
|
2019-04-22 19:08:10 +00:00
|
|
|
app_start:
|
2019-03-05 04:59:31 +00:00
|
|
|
' First thing to do is validate the ability to use the API
|
2019-04-22 19:08:10 +00:00
|
|
|
LoginFlow()
|
2019-03-05 04:31:58 +00:00
|
|
|
|
2019-04-22 19:08:10 +00:00
|
|
|
' Confirm the configured server and user work
|
|
|
|
ShowLibrarySelect()
|
|
|
|
|
|
|
|
' Have a catch for exiting the library on sign-out
|
|
|
|
if get_setting("active_user") = invalid
|
|
|
|
goto app_start
|
|
|
|
end if
|
2019-04-22 20:07:34 +00:00
|
|
|
if getGlobal("user_change") = true
|
2019-04-25 04:15:25 +00:00
|
|
|
' Signal caught, reset
|
2019-04-22 20:07:34 +00:00
|
|
|
setGlobal("user_change", false)
|
|
|
|
goto app_start
|
|
|
|
end if
|
2019-04-22 19:08:10 +00:00
|
|
|
end sub
|
|
|
|
|
|
|
|
sub LoginFlow()
|
2019-04-29 16:44:37 +00:00
|
|
|
'Collect Jellyfin server and user information
|
2019-03-06 02:28:52 +00:00
|
|
|
start_login:
|
2019-03-05 04:31:58 +00:00
|
|
|
if get_setting("server") = invalid then
|
|
|
|
print "Get server details"
|
|
|
|
ShowServerSelect()
|
|
|
|
end if
|
2019-01-30 04:19:27 +00:00
|
|
|
|
2019-03-05 04:31:58 +00:00
|
|
|
if get_setting("active_user") = invalid then
|
|
|
|
print "Get user login"
|
2019-03-06 02:28:52 +00:00
|
|
|
ShowSigninSelect()
|
2019-03-05 04:31:58 +00:00
|
|
|
end if
|
2019-03-02 22:03:11 +00:00
|
|
|
|
2019-03-05 04:59:31 +00:00
|
|
|
m.user = AboutMe()
|
2019-04-20 17:40:06 +00:00
|
|
|
if m.user = invalid or m.user.id <> get_setting("active_user")
|
2019-03-06 02:28:52 +00:00
|
|
|
print "Login failed, restart flow"
|
2019-04-20 17:40:06 +00:00
|
|
|
unset_setting("active_user")
|
2019-03-06 02:28:52 +00:00
|
|
|
goto start_login
|
2019-03-05 04:59:31 +00:00
|
|
|
end if
|
2019-01-30 04:19:27 +00:00
|
|
|
end sub
|