]>
Commit | Line | Data |
---|---|---|
d852b84e | 1 | // Collect and manage the available and enabled source |
a968bff7 | 2 | class SourceManager { |
4425e900 | 3 | |
d852b84e | 4 | // List of sources enabled for the crurent platform |
4425e900 | 5 | private var availableSources: [String: Source] = [ |
f24ce9a2 | 6 | "arguments": ArgumentsSource(), |
d1a147d4 ER |
7 | "itunes": ItunesSource(), |
8 | "spotify": SpotifySource() | |
4425e900 BB |
9 | ] |
10 | ||
d852b84e | 11 | // Iterate over the sources until we find a track or run out of sources |
4425e900 | 12 | var currentTrack: Track? { |
1263f62c BB |
13 | for source in enabledSources { |
14 | if let currentTrack = source.currentTrack { | |
15 | return currentTrack | |
4425e900 | 16 | } |
4425e900 | 17 | } |
1263f62c BB |
18 | |
19 | return nil | |
4425e900 BB |
20 | } |
21 | ||
d852b84e | 22 | // Return the list of enabled sources based on the configuration |
4425e900 BB |
23 | var enabledSources: [Source] { |
24 | ||
25 | // Checks the config and returns an array of sources based on the | |
26 | // enabled and available ones | |
27 | ||
1263f62c | 28 | var sources = [Source]() |
4425e900 | 29 | |
d852b84e | 30 | if let sourceNames = Configuration.shared["enabled_sources"] as? [String] { |
1263f62c BB |
31 | for sourceName in sourceNames { |
32 | if let source = availableSources[sourceName] { | |
33 | sources.append(source) | |
4425e900 BB |
34 | } |
35 | } | |
4425e900 | 36 | } |
1263f62c BB |
37 | |
38 | return sources | |
4425e900 BB |
39 | } |
40 | ||
d852b84e | 41 | // Given a source name, it will enable it and add it to the enabled sources config |
4425e900 BB |
42 | func enable(sourceName: String) { |
43 | } | |
44 | ||
d852b84e | 45 | // Given a source name, it will remove it from the enabled sources config |
4425e900 BB |
46 | func disable(sourceName: String) { |
47 | } | |
48 | ||
d852b84e | 49 | // Given a source name, it removes any stored configuration and disables it |
4425e900 BB |
50 | func reset(sourceName: String) { |
51 | } | |
4425e900 | 52 | } |