HMS

Home Media Server for Roku Players
git clone https://www.brianlane.com/git/HMS
Log | Files | Refs | README | LICENSE

commit 03708ad6170aca2d75bd01a70bc87da8963edef9
parent 7eeb0a507e62fc26ea9560c28a8a2a0a8e4a2fe9
Author: Brian C. Lane <bcl@brianlane.com>
Date:   Sun, 13 Nov 2022 11:54:35 -0800

Server url validation, save and recall of server url are all working

It now reads the url from the registry and saves it when the user sets
it. Currently there is no way to change it once it is set.

Diffstat:
MHMS/components/MainScene.brs | 9++++++---
MHMS/components/SetupServerDialog.brs | 12++++--------
MHMS/components/SetupServerDialog.xml | 2+-
DHMS/source/checkServerUrl.brs | 51---------------------------------------------------
4 files changed, 11 insertions(+), 63 deletions(-)

diff --git a/HMS/components/MainScene.brs b/HMS/components/MainScene.brs @@ -8,7 +8,7 @@ sub Init() url = RegRead("ServerURL") if url = invalid then - RunSetupServerDialog() + RunSetupServerDialog("") else ' Validate the url RunValidateURLTask(url) @@ -48,17 +48,20 @@ sub OnValidateChanged() print m.validateTask.valid if not m.validateTask.valid then ' Still invalid, run it again - RunSetupServerDialog() + RunSetupServerDialog(m.validateTask.serverurl) else ' Valid url, trigger the content load m.top.serverurl = m.validateTask.serverurl + ' And save it for next time + RegWrite("ServerURL", m.validateTask.serverurl) end if end sub -sub RunSetupServerDialog() +sub RunSetupServerDialog(url as string) print "MainScene->RunSetupServerDialog()" m.serverDialog = createObject("roSGNode", "SetupServerDialog") m.serverDialog.ObserveField("serverurl", "OnSetupServerURL") + m.serverDialog.text = url m.top.dialog = m.serverDialog end sub diff --git a/HMS/components/SetupServerDialog.brs b/HMS/components/SetupServerDialog.brs @@ -1,14 +1,14 @@ +'******************************************************************** +'** Home Media Server Application - SetupServerDialog +'** Copyright (c) 2022 Brian C. Lane All Rights Reserved. +'******************************************************************** function init() print "SetupServerDialog->Init()" - -' m.top.width = 1800 m.top.title = "Setup HMS Server URL" m.top.message = ["Enter server name or IP address"] m.top.buttons = ["OK"] m.top.observeFieldScoped("buttonSelected", "dismissDialog") - m.top.observeFieldScoped("text", "textChanged") - m.top.observeFieldScoped("wasClosed", "wasClosedChanged") end function @@ -18,10 +18,6 @@ sub wasClosedChanged() m.top.serverurl = m.top.text end sub -sub textChanged() - print "ENTERED TEXT: "; m.top.text -end sub - sub dismissDialog() m.top.close = true end sub diff --git a/HMS/components/SetupServerDialog.xml b/HMS/components/SetupServerDialog.xml @@ -3,7 +3,7 @@ <script type="text/brightscript" uri="SetupServerDialog.brs" /> <interface> - <field id="serverurl" type="uri" /> + <field id="serverurl" type="uri" alwaysNotify="true" /> </interface> <children> </children> diff --git a/HMS/source/checkServerUrl.brs b/HMS/source/checkServerUrl.brs @@ -1,51 +0,0 @@ -'***************************************************************** -'** Home Media Server Application -'** Copyright (c) 2010-2013 Brian C. Lane All Rights Reserved. -'***************************************************************** - -'************************************************************ -' ** Check the registry for the server URL -' ** Prompt the user to enter the URL or IP if it is not -' ** found and write it to the registry. -'************************************************************ -Function checkServerUrl(forceEdit As Boolean) As Boolean - serverUrl = RegRead("ServerURL") - if (serverUrl = invalid) then - print "ServerUrl not found in the registry" - serverUrl = "video.local" - else if not forceEdit and isUrlValid(serverUrl+"/Setup-SD.png") then - print "Server set to "; serverUrl - return true - end if - - screen = CreateObject("roKeyboardScreen") - port = CreateObject("roMessagePort") - screen.SetMessagePort(port) - screen.SetTitle("HMS Video Server URL") - screen.SetText(serverURL) - screen.SetDisplayText("Enter Host Name or IP Address") - screen.SetMaxLength(25) - screen.AddButton(1, "finished") - screen.Show() - - while true - msg = wait(0, screen.GetMessagePort()) - print "message received" - if type(msg) = "roKeyboardScreenEvent" - if msg.isScreenClosed() - return false - else if msg.isButtonPressed() then - print "Evt: ";msg.GetMessage();" idx:"; msg.GetIndex() - if msg.GetIndex() = 1 then - serverText = screen.GetText() - print "Server set to "; serverText - - if isUrlValid(serverText) then - RegWrite("ServerURL", serverText) - return true - end if - endif - endif - endif - end while -End Function