1 // Collect and manage the available and enabled source
4 // List of sources enabled for the crurent platform
5 private var availableSources: [String: Source] = [
6 "arguments": ArgumentsSource()
9 // Iterate over the sources until we find a track or run out of sources
10 var currentTrack: Track? {
11 for source in enabledSources {
12 if let currentTrack = source.currentTrack {
20 // Return the list of enabled sources based on the configuration
21 var enabledSources: [Source] {
23 // Checks the config and returns an array of sources based on the
24 // enabled and available ones
26 var sources = [Source]()
28 if let sourceNames = Configuration.shared["enabled_sources"] as? [String] {
29 for sourceName in sourceNames {
30 if let source = availableSources[sourceName] {
31 sources.append(source)
39 // Given a source name, it will enable it and add it to the enabled sources config
40 func enable(sourceName: String) {
43 // Given a source name, it will remove it from the enabled sources config
44 func disable(sourceName: String) {
47 // Given a source name, it removes any stored configuration and disables it
48 func reset(sourceName: String) {