jf-roku/source/utils/config.brs

60 lines
1.6 KiB
Plaintext
Raw Normal View History

' "Registry" is where Roku stores config
' Generic registry accessors
2021-07-09 20:08:32 +00:00
function registry_read(key, section = invalid)
if section = invalid then return invalid
reg = CreateObject("roRegistrySection", section)
if reg.exists(key) then return reg.read(key)
return invalid
end function
2021-07-09 20:08:32 +00:00
sub registry_write(key, value, section = invalid)
if section = invalid then return
reg = CreateObject("roRegistrySection", section)
reg.write(key, value)
reg.flush()
end sub
2021-07-09 20:08:32 +00:00
sub registry_delete(key, section = invalid)
if section = invalid then return
reg = CreateObject("roRegistrySection", section)
reg.delete(key)
reg.flush()
end sub
' "Jellyfin" registry accessors for the default global settings
2021-07-09 20:08:32 +00:00
function get_setting(key, default = invalid)
value = registry_read(key, "Jellyfin")
if value = invalid then return default
return value
end function
sub set_setting(key, value)
2021-07-09 20:08:32 +00:00
registry_write(key, value, "Jellyfin")
end sub
sub unset_setting(key)
2021-07-09 20:08:32 +00:00
registry_delete(key, "Jellyfin")
end sub
' User registry accessors for the currently active user
2021-07-09 20:08:32 +00:00
function get_user_setting(key, default = invalid)
if get_setting("active_user") = invalid then return default
value = registry_read(key, get_setting("active_user"))
if value = invalid then return default
return value
end function
sub set_user_setting(key, value)
2021-07-09 20:08:32 +00:00
if get_setting("active_user") = invalid then return
registry_write(key, value, get_setting("active_user"))
end sub
sub unset_user_setting(key)
2021-07-09 20:08:32 +00:00
if get_setting("active_user") = invalid then return
registry_delete(key, get_setting("active_user"))
end sub