63f3b0290c4c95cd59e144adec325e430859c08c
[profile/ivi/genivi/genivi-audio-manager.git] / AudioManagerDaemon / src / DatabaseObserver.cpp
1 /**
2 * Copyright (C) 2011, BMW AG
3 *
4 * GeniviAudioMananger AudioManagerDaemon
5 *
6 * \file DatabaseObserver.cpp
7 *
8 * \date 20-Oct-2011 3:42:04 PM
9 * \author Christian Mueller (christian.ei.mueller@bmw.de)
10 *
11 * \section License
12 * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
13 * Copyright (C) 2011, BMW AG Christian Mueller  Christian.ei.mueller@bmw.de
14 *
15 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
17 * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
18 * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
19 * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
20 * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
21 * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
22 *
23 */
24
25 #include "DatabaseObserver.h"
26 #include "CommandSender.h"
27 #include "RoutingSender.h"
28 #include "TelnetServer.h"
29 #include <assert.h>
30
31 using namespace am;
32
33 DatabaseObserver::DatabaseObserver(CommandSender *iCommandSender, RoutingSender *iRoutingSender)
34         :mCommandSender(iCommandSender),
35          mRoutingSender(iRoutingSender)
36 {
37         assert(mCommandSender!=0);
38         assert(mRoutingSender!=0);
39 }
40
41 DatabaseObserver::DatabaseObserver(CommandSender *iCommandSender, RoutingSender *iRoutingSender, TelnetServer *iTelnetServer)
42         :mCommandSender(iCommandSender),
43          mRoutingSender(iRoutingSender),
44          mTelnetServer(iTelnetServer)
45 {
46         assert(mCommandSender!=0);
47         assert(mRoutingSender!=0);
48         assert(mTelnetServer!=0);
49 }
50
51 DatabaseObserver::~DatabaseObserver() {
52         // TODO Auto-generated destructor stub
53 }
54
55 void DatabaseObserver::newSink(am_Sink_s sink)
56 {
57         mRoutingSender->addSinkLookup(sink);
58         mCommandSender->cbNumberOfSinksChanged();
59 }
60
61
62
63 void DatabaseObserver::newSource(am_Source_s source)
64 {
65         mRoutingSender->addSourceLookup(source);
66         mCommandSender->cbNumberOfSourcesChanged();
67 }
68
69
70
71 void DatabaseObserver::newDomain(am_Domain_s domain)
72 {
73         mRoutingSender->addDomainLookup(domain);
74 }
75
76
77
78 void DatabaseObserver::newGateway(am_Gateway_s gateway)
79 {
80         //todo: implement something
81 }
82
83
84
85 void DatabaseObserver::newCrossfader(am_Crossfader_s crossfader)
86 {
87         mRoutingSender->addCrossfaderLookup(crossfader);
88 }
89
90
91
92 void DatabaseObserver::removedSink(am_sinkID_t sinkID)
93 {
94         mRoutingSender->removeSinkLookup(sinkID);
95         mCommandSender->cbNumberOfSinksChanged();
96 }
97
98
99
100 void DatabaseObserver::removedSource(am_sourceID_t sourceID)
101 {
102         mRoutingSender->removeSourceLookup(sourceID);
103         mCommandSender->cbNumberOfSourcesChanged();
104 }
105
106
107
108 void DatabaseObserver::removeDomain(am_domainID_t domainID)
109 {
110         mRoutingSender->removeDomainLookup(domainID);
111 }
112
113
114
115 void DatabaseObserver::removeGateway(am_gatewayID_t gatewayID)
116 {
117         //todo: implement something
118 }
119
120
121
122 void DatabaseObserver::removeCrossfader(am_crossfaderID_t crossfaderID)
123 {
124         mRoutingSender->removeCrossfaderLookup(crossfaderID);
125 }
126
127
128 void DatabaseObserver::numberOfMainConnectionsChanged()
129 {
130         mCommandSender->cbNumberOfMainConnectionsChanged();
131 }
132
133 void DatabaseObserver::numberOfSinkClassesChanged()
134 {
135         mCommandSender->cbNumberOfSinkClassesChanged();
136 }
137
138
139
140 void DatabaseObserver::numberOfSourceClassesChanged()
141 {
142         mCommandSender->cbNumberOfSourceClassesChanged();
143 }
144
145
146
147 void DatabaseObserver::mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
148 {
149         mCommandSender->cbMainConnectionStateChanged(connectionID,connectionState);
150 }
151
152
153
154 void DatabaseObserver::mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s SoundProperty)
155 {
156         mCommandSender->cbMainSinkSoundPropertyChanged(sinkID,SoundProperty);
157 }
158
159
160
161 void DatabaseObserver::mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s & SoundProperty)
162 {
163         mCommandSender->cbMainSourceSoundPropertyChanged(sourceID,SoundProperty);
164 }
165
166
167
168 void DatabaseObserver::sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s & availability)
169 {
170         mCommandSender->cbSinkAvailabilityChanged(sinkID,availability);
171 }
172
173
174
175 void DatabaseObserver::sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s & availability)
176 {
177         mCommandSender->cbSourceAvailabilityChanged(sourceID,availability);
178 }
179
180
181
182 void DatabaseObserver::volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
183 {
184         mCommandSender->cbVolumeChanged(sinkID,volume);
185 }
186
187
188
189 void DatabaseObserver::sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
190 {
191         mCommandSender->cbSinkMuteStateChanged(sinkID,muteState);
192 }
193
194
195
196 void DatabaseObserver::systemPropertyChanged(const am_SystemProperty_s & SystemProperty)
197 {
198         mCommandSender->cbSystemPropertyChanged(SystemProperty);
199 }
200
201
202
203 void DatabaseObserver::timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time)
204 {
205         mCommandSender->cbTimingInformationChanged(mainConnection,time);
206         //todo:inform the controller via controlsender
207 }
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222