2019-02-10 19:15:20 +00:00
|
|
|
' "Registry" is where Roku stores config
|
|
|
|
|
|
|
|
|
|
|
|
' Generic registry accessors
|
|
|
|
function registry_read(key, section=invalid)
|
2019-03-05 05:18:01 +00:00
|
|
|
if section = invalid then return invalid
|
|
|
|
reg = CreateObject("roRegistrySection", section)
|
|
|
|
if reg.exists(key) then return reg.read(key)
|
|
|
|
return invalid
|
2019-02-10 19:15:20 +00:00
|
|
|
end function
|
|
|
|
|
|
|
|
function registry_write(key, value, section=invalid)
|
2019-03-05 05:18:01 +00:00
|
|
|
if section = invalid then return invalid
|
|
|
|
reg = CreateObject("roRegistrySection", section)
|
|
|
|
reg.write(key, value)
|
|
|
|
reg.flush()
|
2019-02-10 19:15:20 +00:00
|
|
|
end function
|
|
|
|
|
|
|
|
function registry_delete(key, section=invalid)
|
2019-03-05 05:18:01 +00:00
|
|
|
if section = invalid then return invalid
|
|
|
|
reg = CreateObject("roRegistrySection", section)
|
|
|
|
reg.delete(key)
|
|
|
|
reg.flush()
|
2019-02-10 19:15:20 +00:00
|
|
|
end function
|
|
|
|
|
|
|
|
|
|
|
|
' "Jellyfin" registry accessors for the default global settings
|
2019-03-13 01:16:12 +00:00
|
|
|
function get_setting(key, default=invalid)
|
|
|
|
value = registry_read(key, "Jellyfin")
|
|
|
|
if value = invalid return default
|
|
|
|
return value
|
2019-02-10 19:15:20 +00:00
|
|
|
end function
|
|
|
|
|
|
|
|
function set_setting(key, value)
|
2019-03-05 05:18:01 +00:00
|
|
|
registry_write(key, value, "Jellyfin")
|
2019-02-10 19:15:20 +00:00
|
|
|
end function
|
|
|
|
|
|
|
|
function unset_setting(key)
|
2019-03-05 05:18:01 +00:00
|
|
|
registry_delete(key, "Jellyfin")
|
2019-02-10 19:15:20 +00:00
|
|
|
end function
|
|
|
|
|
|
|
|
|
|
|
|
' User registry accessors for the currently active user
|
2019-03-13 01:16:12 +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 return default
|
|
|
|
return value
|
2019-02-10 19:15:20 +00:00
|
|
|
end function
|
|
|
|
|
|
|
|
function set_user_setting(key, value)
|
2019-03-05 05:18:01 +00:00
|
|
|
if get_setting("active_user") = invalid then return invalid
|
|
|
|
registry_write(key, value, get_setting("active_user"))
|
2019-02-10 19:15:20 +00:00
|
|
|
end function
|
|
|
|
|
|
|
|
function unset_user_setting(key)
|
2019-03-05 05:18:01 +00:00
|
|
|
if get_setting("active_user") = invalid then return invalid
|
|
|
|
registry_delete(key, get_setting("active_user"))
|
2019-02-10 19:15:20 +00:00
|
|
|
end function
|