1 package org.rpi.plugingateway;
2
3 import java.util.Observable;
4 import java.util.concurrent.ConcurrentHashMap;
5 import org.apache.log4j.Logger;
6 import org.rpi.config.Config;
7 import org.rpi.main.SimpleDevice;
8 import org.rpi.player.events.EventBase;
9 import org.rpi.player.events.EventSourceChanged;
10 import org.rpi.sources.Source;
11
12 public class PluginGateWay extends Observable {
13
14 private static PluginGateWay instance = null;
15 private Logger log = Logger.getLogger(this.getClass());
16 private ConcurrentHashMap<String, Source> sources = new ConcurrentHashMap<String,Source>();
17 private String source_name = "";
18
19 private SimpleDevice simpleDevice = null;
20 private String default_pin = "";
21
22 public static PluginGateWay getInstance() {
23 if (instance == null) {
24 instance = new PluginGateWay();
25 }
26 return instance;
27 }
28
29 protected PluginGateWay() {
30
31 }
32
33
34
35 public void setSimpleDevice(SimpleDevice simpleDevice) {
36 this.simpleDevice = simpleDevice;
37 }
38
39
40
41
42
43
44
45
46 public synchronized void AddSource(String type, String name, boolean visible) {
47 simpleDevice.getProduct().addSource(Config.friendly_name, name, type, true);
48 }
49
50
51
52
53
54
55 public synchronized void setSourceId(String name) {
56 setSourceName(name);
57 EventSourceChanged ev = new EventSourceChanged();
58 ev.setName(name);
59 fireEvent(ev);
60 }
61
62 private synchronized void fireEvent(EventBase ev) {
63 setChanged();
64 notifyObservers(ev);
65 }
66
67
68
69
70
71 public ConcurrentHashMap<String, Source> getSources() {
72 return sources;
73 }
74
75
76
77
78
79 public void setSources(ConcurrentHashMap<String, Source> sources) {
80 this.sources = sources;
81 }
82
83 public String getSourceName() {
84 return source_name;
85 }
86
87 private void setSourceName(String source_name) {
88 this.source_name = source_name;
89 }
90
91 public void setDefaultSourcePin(String default_pin) {
92 this.default_pin = default_pin;
93 }
94
95 public String getDefaultSourcePin() {
96 return default_pin;
97 }
98 }
99
100