74 lines
2.4 KiB
Plaintext
74 lines
2.4 KiB
Plaintext
namespace RegistryUtils
|
|
|
|
const DEFAULT_SECTION = "Playlet"
|
|
|
|
const USER_PREFERENCES = "user_prefs"
|
|
const USER_PROFILES = "user_profiles"
|
|
|
|
const SEARCH_HISTORY = "search_history"
|
|
const PLAYLET_LIB_URLS = "playlet_lib_urls"
|
|
const BOOKMARKS = "bookmarks"
|
|
const MESSAGES = "messages"
|
|
|
|
const INNERTUBE_SESSION_DATA = "innertube_session_data"
|
|
const INNERTUBE_POTOKENS = "innertube_potokens"
|
|
const LAST_LOUNGE_DATA = "last_lounge_data"
|
|
|
|
' "invidious_instances" is deprecated, but we keep for migration purposes
|
|
const INVIDIOUS_INSTANCES = "invidious_instances"
|
|
' "invidious_token" is deprecated, but we keep for migration purposes
|
|
const INVIDIOUS_TOKEN = "invidious_token"
|
|
|
|
function Read(key as string, sectionName = DEFAULT_SECTION as string) as dynamic
|
|
section = CreateObject("roRegistrySection", sectionName)
|
|
if section.Exists(key)
|
|
return section.Read(key)
|
|
end if
|
|
return invalid
|
|
end function
|
|
|
|
function Write(key as string, value as string, sectionName = DEFAULT_SECTION as string)
|
|
section = CreateObject("roRegistrySection", sectionName)
|
|
section.Write(key, value)
|
|
section.Flush()
|
|
end function
|
|
|
|
function Delete(key as string, sectionName = DEFAULT_SECTION as string)
|
|
section = CreateObject("roRegistrySection", sectionName)
|
|
section.Delete(key)
|
|
section.Flush()
|
|
end function
|
|
|
|
function ReadAll() as object
|
|
result = {}
|
|
registry = CreateObject("roRegistry")
|
|
sectionNames = registry.GetSectionList()
|
|
for each sectionName in sectionNames
|
|
section = CreateObject("roRegistrySection", sectionName)
|
|
keys = section.GetKeyList()
|
|
values = section.ReadMulti(keys)
|
|
result[sectionName] = values
|
|
end for
|
|
return result
|
|
end function
|
|
|
|
function WriteAll(values as object) as void
|
|
DeleteAll()
|
|
for each sectionName in values
|
|
section = CreateObject("roRegistrySection", sectionName)
|
|
section.WriteMulti(values[sectionName])
|
|
section.Flush()
|
|
end for
|
|
end function
|
|
|
|
function DeleteAll() as void
|
|
registry = CreateObject("roRegistry")
|
|
sectionNames = registry.GetSectionList()
|
|
for each sectionName in sectionNames
|
|
registry.Delete(sectionName)
|
|
end for
|
|
registry.Flush()
|
|
end function
|
|
|
|
end namespace
|