* formatting all the source code with eclipse source code style
[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 {
53     // TODO Auto-generated destructor stub
54 }
55
56 void DatabaseObserver::newSink(am_Sink_s sink)
57 {
58     mRoutingSender->addSinkLookup(sink);
59     mCommandSender->cbNumberOfSinksChanged();
60 }
61
62 void DatabaseObserver::newSource(am_Source_s source)
63 {
64     mRoutingSender->addSourceLookup(source);
65     mCommandSender->cbNumberOfSourcesChanged();
66 }
67
68 void DatabaseObserver::newDomain(am_Domain_s domain)
69 {
70     mRoutingSender->addDomainLookup(domain);
71 }
72
73 void DatabaseObserver::newGateway(am_Gateway_s gateway)
74 {
75     //todo: implement something
76 }
77
78 void DatabaseObserver::newCrossfader(am_Crossfader_s crossfader)
79 {
80     mRoutingSender->addCrossfaderLookup(crossfader);
81 }
82
83 void DatabaseObserver::removedSink(am_sinkID_t sinkID)
84 {
85     mRoutingSender->removeSinkLookup(sinkID);
86     mCommandSender->cbNumberOfSinksChanged();
87 }
88
89 void DatabaseObserver::removedSource(am_sourceID_t sourceID)
90 {
91     mRoutingSender->removeSourceLookup(sourceID);
92     mCommandSender->cbNumberOfSourcesChanged();
93 }
94
95 void DatabaseObserver::removeDomain(am_domainID_t domainID)
96 {
97     mRoutingSender->removeDomainLookup(domainID);
98 }
99
100 void DatabaseObserver::removeGateway(am_gatewayID_t gatewayID)
101 {
102     //todo: implement something
103 }
104
105 void DatabaseObserver::removeCrossfader(am_crossfaderID_t crossfaderID)
106 {
107     mRoutingSender->removeCrossfaderLookup(crossfaderID);
108 }
109
110 void DatabaseObserver::numberOfMainConnectionsChanged()
111 {
112     mCommandSender->cbNumberOfMainConnectionsChanged();
113 }
114
115 void DatabaseObserver::numberOfSinkClassesChanged()
116 {
117     mCommandSender->cbNumberOfSinkClassesChanged();
118 }
119
120 void DatabaseObserver::numberOfSourceClassesChanged()
121 {
122     mCommandSender->cbNumberOfSourceClassesChanged();
123 }
124
125 void DatabaseObserver::mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
126 {
127     mCommandSender->cbMainConnectionStateChanged(connectionID, connectionState);
128 }
129
130 void DatabaseObserver::mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s SoundProperty)
131 {
132     mCommandSender->cbMainSinkSoundPropertyChanged(sinkID, SoundProperty);
133 }
134
135 void DatabaseObserver::mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s & SoundProperty)
136 {
137     mCommandSender->cbMainSourceSoundPropertyChanged(sourceID, SoundProperty);
138 }
139
140 void DatabaseObserver::sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s & availability)
141 {
142     mCommandSender->cbSinkAvailabilityChanged(sinkID, availability);
143 }
144
145 void DatabaseObserver::sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s & availability)
146 {
147     mCommandSender->cbSourceAvailabilityChanged(sourceID, availability);
148 }
149
150 void DatabaseObserver::volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
151 {
152     mCommandSender->cbVolumeChanged(sinkID, volume);
153 }
154
155 void DatabaseObserver::sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
156 {
157     mCommandSender->cbSinkMuteStateChanged(sinkID, muteState);
158 }
159
160 void DatabaseObserver::systemPropertyChanged(const am_SystemProperty_s & SystemProperty)
161 {
162     mCommandSender->cbSystemPropertyChanged(SystemProperty);
163 }
164
165 void DatabaseObserver::timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time)
166 {
167     mCommandSender->cbTimingInformationChanged(mainConnection, time);
168     //todo:inform the controller via controlsender
169 }
170