1
// This program is free software: you can redistribute it and/or modify
2
// it under the terms of the GNU General Public License as published by
3
// the Free Software Foundation, either version 3 of the License, or
4
// (at your option) any later version.
6
// This program is distributed in the hope that it will be useful,
7
// but WITHOUT ANY WARRANTY; without even the implied warranty of
8
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
// GNU General Public License for more details.
11
// You should have received a copy of the GNU General Public License
12
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
using System.Collections.Generic;
17
using System.Threading;
21
using Do.Platform.Linux;
23
namespace SqueezeCenter
26
public class ItemSource : Do.Universe.ItemSource, IConfigurable
29
List<AlbumMusicItem> albums;
30
List<ArtistMusicItem> artists;
34
items = new List<Item> ();
35
albums = new List<AlbumMusicItem>();
36
artists = new List<ArtistMusicItem>();
40
public Gtk.Bin GetConfiguration ()
42
return new Configuration ();
45
public override string Name { get { return "SqueezeCenter"; } }
46
public override string Description { get { return "Artists, albums and radio."; } }
47
public override string Icon { get { return "SB on.png@" + this.GetType ().Assembly.FullName; } }
49
public override IEnumerable<Type> SupportedItemTypes {
54
typeof (BrowseMusicItem),
55
typeof (IApplicationItem),
60
public override IEnumerable<Item> Items
68
public override IEnumerable<Item> ChildrenOfItem (Item parent)
70
List<Item> children = new List<Item> ();
72
if (parent is IApplicationItem && parent.Name == this.Name) {
73
children.Add (new BrowseAlbumsMusicItem ());
74
children.Add (new BrowseArtistsMusicItem ());
76
else if (parent is ArtistMusicItem) {
77
foreach (AlbumMusicItem album in albums)
78
if(album.Artist == parent)
81
else if (parent is BrowseAlbumsMusicItem) {
82
foreach (AlbumMusicItem album in albums)
85
else if (parent is BrowseArtistsMusicItem) {
86
foreach (ArtistMusicItem album in artists)
89
else if (parent is RadioItem) {
90
children.AddRange ((parent as RadioItem).Children);
96
public override void UpdateItems ()
102
albums.AddRange (Server.Instance.GetAlbums ());
106
artists.AddRange (Server.Instance.GetArtists ());
108
// Add radios and all children
109
foreach (RadioSuperItem r in Server.Instance.GetRadios ()) {
111
Console.WriteLine ("SQC: Adding radio:" + r.Name + " Children: " + r.GetChildrenRecursive ().Length);
114
items.AddRange (r.GetChildrenRecursive ());
118
items.AddRange (Server.Instance.GetConnectedPlayersAsItem ());
120
// Add browse features
121
items.Add (new BrowseAlbumsMusicItem ());
122
items.Add (new BrowseArtistsMusicItem ());
125
// Add artists and albums to items
126
items.Capacity = Math.Max (items.Capacity, items.Count + albums.Count + artists.Count);
127
foreach (Item album in albums) items.Add (album);
128
foreach (Item artist in artists) items.Add (artist);