· 8 years ago · Mar 16, 2018, 06:36 PM
1//
2// RadioSource.cs
3//
4// Authors:
5// William Farrington <wcfarrington@gmail.com>
6// Alexander Hixon <hixon.alexander@mediati.org>
7// Aaron Bockover <abockover@novell.com>
8//
9// Copyright (C) 2008 Will Farrington, Alexander Hixon, Novell, Inc.
10//
11// Permission is hereby granted, free of charge, to any person obtaining
12// a copy of this software and associated documentation files (the
13// "Software"), to deal in the Software without restriction, including
14// without limitation the rights to use, copy, modify, merge, publish,
15// distribute, sublicense, and/or sell copies of the Software, and to
16// permit persons to whom the Software is furnished to do so, subject to
17// the following conditions:
18//
19// The above copyright notice and this permission notice shall be
20// included in all copies or substantial portions of the Software.
21//
22// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29//
30
31using System;
32using System.Collections.Generic;
33using Mono.Unix;
34
35using Banshee.Base;
36using Banshee.Sources;
37using Banshee.Collection;
38using Banshee.Collection.Database;
39using Banshee.ServiceStack;
40
41namespace Banshee.Radio
42{
43 public class RadioSource : Source, ITrackModelSource, IUnmapableSource, IDisposable
44 {
45 private TrackListModel track_model;
46
47 public RadioSource () : base ("radio", Catalog.GetString ("Radio"), 120)
48 {
49 Properties.SetString ("Icon.Name", "radio");
50 track_model = new StationTrackModel ();
51
52 ServiceManager.SourceManager.AddSource (this);
53 }
54
55 private void Initialize ()
56 {
57 CreateTablesIfNecessary ();
58 MigrateLegacyIfNecessary ();
59 }
60
61 public void Dispose ()
62 {
63 }
64
65 private void CreateTablesIfNecessary () {
66 // this method should check if the table RadioStations exists
67 // and if it doesn't, create it.
68 // if it does, continue on our way
69 if (/* test */) {
70 Execute("
71 CREATE TABLE RadioStations (
72 StationID INTEGER PRIMARY KEY,
73 Name TEXT,
74 Url TEXT,
75 Genre TEXT,
76 Comment TEXT)");
77 }
78 }
79
80 private void MigrateLegecyIfNecessary ()
81 {
82 // checks gconf for old radio stations and imports them into new db
83 // if not, continue on our way
84 if (/* test */) {
85 // Run migrations
86 }
87 }
88
89#region Source overrides
90 public TrackListModel TrackModel {
91 get { return track_model; }
92 }
93
94 public IEnumerable<IFilterListModel> FilterModels {
95 get { return null; }
96 }
97
98 public void Reload ()
99 {
100 track_model.Reload ();
101 }
102
103 public bool HasDependencies {
104 get { return false; }
105 }
106
107 public bool CanUnmap {
108 get { return false; }
109 }
110
111 public bool ConfirmBeforeUnmap {
112 get { return false; }
113 }
114
115 public bool Unmap ()
116 {
117 throw new NotImplementedException ();
118 }
119
120 public override void Save ()
121 {
122 throw new NotImplementedException ();
123 }
124
125 public void RemoveSelectedTracks ()
126 {
127 throw new NotImplementedException ();
128 }
129
130 public void DeleteSelectedTracks ()
131 {
132 throw new NotImplementedException ("Should not call DeleteSelectedTracks on RadioSource.");
133 }
134
135 // TODO: For now.
136 public bool CanAddTracks {
137 get { return false; }
138 }
139
140 // TODO: For now.
141 public bool CanRemoveTracks {
142 get { return false; }
143 }
144
145 public bool CanDeleteTracks {
146 get { return false; }
147 }
148
149 public bool ConfirmRemoveTracks {
150 get { return false; }
151 }
152
153 public bool ShowBrowser {
154 get { return true; }
155 }
156#endregion
157
158 protected override string TypeUniqueId {
159 get { return "radio"; }
160 }
161 }
162}