add functions for control interface to use dbus
[profile/ivi/genivi/genivi-audio-manager.git] / AudioManagerDaemon / src / CAmControlReceiver.cpp
1 /**
2  * Copyright (C) 2012, BMW AG
3  *
4  * This file is part of GENIVI Project AudioManager.
5  *
6  * Contributions are licensed to the GENIVI Alliance under one or more
7  * Contribution License Agreements.
8  *
9  * \copyright
10  * This Source Code Form is subject to the terms of the
11  * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with
12  * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
13  *
14  *
15  * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
16  *
17  * \file CAmControlReceiver.cpp
18  * For further information see http://www.genivi.org/.
19  *
20  */
21
22 #include "CAmControlReceiver.h"
23 #include <cassert>
24 #include <stdlib.h>
25 #include <stdexcept>
26 #include "config.h"
27 #include "IAmDatabaseHandler.h"
28 #include "CAmRoutingSender.h"
29 #include "CAmCommandSender.h"
30 #include "CAmRouter.h"
31 #include "shared/CAmDltWrapper.h"
32 #include "shared/CAmSocketHandler.h"
33 #ifdef WITH_NSM
34     #include "CAmNodeStateCommunicator.h"
35 #endif
36
37
38
39 namespace am {
40
41 CAmControlReceiver::CAmControlReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter, CAmNodeStateCommunicator* iNodeStateCommunicator) :
42         mDatabaseHandler(iDatabaseHandler), //
43         mRoutingSender(iRoutingSender), //
44         mCommandSender(iCommandSender), //
45         mSocketHandler(iSocketHandler), //
46         mRouter(iRouter), //
47         mDBusWrapper(NULL),
48         mNodeStateCommunicator(iNodeStateCommunicator)
49 {
50     assert(mDatabaseHandler!=NULL);
51     assert(mRoutingSender!=NULL);
52     assert(mCommandSender!=NULL);
53     assert(mSocketHandler!=NULL);
54     assert(mRouter!=NULL);
55     assert(iNodeStateCommunicator!=NULL);
56 }
57
58 CAmControlReceiver::CAmControlReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter) :
59         mDatabaseHandler(iDatabaseHandler), //
60         mRoutingSender(iRoutingSender), //
61         mCommandSender(iCommandSender), //
62         mSocketHandler(iSocketHandler), //
63         mRouter(iRouter), //
64         mDBusWrapper(NULL),
65         mNodeStateCommunicator(NULL)
66 {
67     assert(mDatabaseHandler!=NULL);
68     assert(mRoutingSender!=NULL);
69     assert(mCommandSender!=NULL);
70     assert(mSocketHandler!=NULL);
71     assert(mRouter!=NULL);
72 }
73
74 CAmControlReceiver::CAmControlReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter, CAmDbusWrapper *iDBusWrapper) :
75         mDatabaseHandler(iDatabaseHandler), //
76         mRoutingSender(iRoutingSender), //
77         mCommandSender(iCommandSender), //
78         mSocketHandler(iSocketHandler), //
79         mRouter(iRouter), //
80         mDBusWrapper(iDBusWrapper),
81         mNodeStateCommunicator(NULL)
82 {
83     assert(mDatabaseHandler!=NULL);
84     assert(mRoutingSender!=NULL);
85     assert(mCommandSender!=NULL);
86     assert(mSocketHandler!=NULL);
87     assert(mRouter!=NULL);
88     assert(mDBusWrapper!=NULL);
89 }
90
91 CAmControlReceiver::~CAmControlReceiver()
92 {
93 }
94
95 am_Error_e CAmControlReceiver::getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & returnList)
96 {
97     return (mRouter->getRoute(onlyfree, sourceID, sinkID, returnList));
98 }
99
100 am_Error_e CAmControlReceiver::connect(am_Handle_s & handle, am_connectionID_t & connectionID, const am_CustomConnectionFormat_t format, const am_sourceID_t sourceID, const am_sinkID_t sinkID)
101 {
102     logInfo("CAmControlReceiver::connect got called, connectionFormat=", format, "sourceID=", sourceID, "sinkID=", sinkID);
103
104     am_Connection_s tempConnection;
105     tempConnection.sinkID = sinkID;
106     tempConnection.sourceID = sourceID;
107     tempConnection.connectionFormat = format;
108     tempConnection.connectionID = 0;
109     tempConnection.delay=-1;
110
111     mDatabaseHandler->enterConnectionDB(tempConnection, connectionID);
112     return (mRoutingSender->asyncConnect(handle, connectionID, sourceID, sinkID, format));
113 }
114
115 am_Error_e CAmControlReceiver::disconnect(am_Handle_s & handle, const am_connectionID_t connectionID)
116 {
117     logInfo("CAmControlReceiver::disconnect got called, connectionID=", connectionID);
118     return (mRoutingSender->asyncDisconnect(handle, connectionID));
119 }
120
121 am_Error_e CAmControlReceiver::crossfade(am_Handle_s & handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_CustomRampType_t rampType, const am_time_t rampTime)
122 {
123     logInfo("CAmControlReceiver::crossfade got called, hotSource=", hotSource, "crossfaderID=", crossfaderID, "rampType=", rampType, "rampTime=", rampTime);
124     return (mRoutingSender->asyncCrossFade(handle, crossfaderID, hotSource, rampType, rampTime));
125 }
126
127 am_Error_e CAmControlReceiver::setSourceState(am_Handle_s & handle, const am_sourceID_t sourceID, const am_SourceState_e state)
128 {
129     logInfo("CAmControlReceiver::setSourceState got called, sourceID=", sourceID, "state=", state);
130     return (mRoutingSender->asyncSetSourceState(handle, sourceID, state));
131 }
132
133 am_Error_e CAmControlReceiver::setSinkVolume(am_Handle_s & handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time)
134 {
135     logInfo("CAmControlReceiver::setSinkVolume got called, sinkID=", sinkID, "volume=", volume, "ramp=", ramp, "time=", time);
136     return (mRoutingSender->asyncSetSinkVolume(handle, sinkID, volume, ramp, time));
137 }
138
139 am_Error_e CAmControlReceiver::setSourceVolume(am_Handle_s & handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t rampType, const am_time_t time)
140 {
141     logInfo("CAmControlReceiver::setSourceVolume got called, sourceID=", sourceID, "volume=", volume, "ramp=", rampType, "time=", time);
142     return (mRoutingSender->asyncSetSourceVolume(handle, sourceID, volume, rampType, time));
143 }
144
145 am_Error_e CAmControlReceiver::setSinkSoundProperty(am_Handle_s & handle, const am_sinkID_t sinkID, const am_SoundProperty_s & soundProperty)
146 {
147     logInfo("CAmControlReceiver::setSinkSoundProperty got called, sinkID=", sinkID, "soundProperty.Type=", soundProperty.type, "soundProperty.value=", soundProperty.value);
148     return (mRoutingSender->asyncSetSinkSoundProperty(handle, sinkID, soundProperty));
149 }
150
151 am_Error_e CAmControlReceiver::setSinkSoundProperties(am_Handle_s & handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s> & listSoundProperties)
152 {
153     logInfo("CAmControlReceiver::setSinkSoundProperties got called, sinkID=", sinkID);
154     return (mRoutingSender->asyncSetSinkSoundProperties(handle, listSoundProperties, sinkID));
155 }
156
157 am_Error_e CAmControlReceiver::setSourceSoundProperty(am_Handle_s & handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty)
158 {
159     logInfo("CAmControlReceiver::setSourceSoundProperty got called, sourceID=", sourceID, "soundProperty.Type=", soundProperty.type, "soundProperty.value=", soundProperty.value);
160     return (mRoutingSender->asyncSetSourceSoundProperty(handle, sourceID, soundProperty));
161 }
162
163 am_Error_e CAmControlReceiver::setSourceSoundProperties(am_Handle_s & handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s> & listSoundProperties)
164 {
165     logInfo("CAmControlReceiver::setSourceSoundProperties got called, sourceID=", sourceID);
166     return (mRoutingSender->asyncSetSourceSoundProperties(handle, listSoundProperties, sourceID));
167 }
168
169 am_Error_e CAmControlReceiver::setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState)
170 {
171     logInfo("CAmControlReceiver::setDomainState got called, domainID=", domainID, "domainState=", domainState);
172     return (mRoutingSender->setDomainState(domainID, domainState));
173 }
174
175 am_Error_e CAmControlReceiver::abortAction(const am_Handle_s handle)
176 {
177     logInfo("CAmControlReceiver::abortAction got called, handle.type=", handle.handle, "handle.handleType=", handle.handleType);
178     return (mRoutingSender->asyncAbort(handle));
179 }
180
181 am_Error_e CAmControlReceiver::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID)
182 {
183     return (mDatabaseHandler->enterDomainDB(domainData, domainID));
184 }
185
186 am_Error_e CAmControlReceiver::enterMainConnectionDB(const am_MainConnection_s & mainConnectionData, am_mainConnectionID_t & connectionID)
187 {
188     return (mDatabaseHandler->enterMainConnectionDB(mainConnectionData, connectionID));
189 }
190
191 am_Error_e CAmControlReceiver::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
192 {
193     return (mDatabaseHandler->enterSinkDB(sinkData, sinkID));
194 }
195
196 am_Error_e CAmControlReceiver::enterCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
197 {
198     return (mDatabaseHandler->enterCrossfaderDB(crossfaderData, crossfaderID));
199 }
200
201 am_Error_e CAmControlReceiver::enterGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
202 {
203     return (mDatabaseHandler->enterGatewayDB(gatewayData, gatewayID));
204 }
205
206 am_Error_e CAmControlReceiver::enterSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID)
207 {
208     return (mDatabaseHandler->enterSourceDB(sourceData, sourceID));
209 }
210
211 am_Error_e CAmControlReceiver::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID)
212 {
213     return (mDatabaseHandler->enterSinkClassDB(sinkClass, sinkClassID));
214 }
215
216 am_Error_e CAmControlReceiver::enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass)
217 {
218     return (mDatabaseHandler->enterSourceClassDB(sourceClassID, sourceClass));
219 }
220
221 am_Error_e CAmControlReceiver::enterSystemPropertiesListDB(const std::vector<am_SystemProperty_s> & listSystemProperties)
222 {
223     return (mDatabaseHandler->enterSystemProperties(listSystemProperties));
224 }
225
226 am_Error_e CAmControlReceiver::changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t>& listConnectionID)
227 {
228     return (mDatabaseHandler->changeMainConnectionRouteDB(mainconnectionID, listConnectionID));
229 }
230
231 am_Error_e CAmControlReceiver::changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState)
232 {
233     return (mDatabaseHandler->changeMainConnectionStateDB(mainconnectionID, connectionState));
234 }
235
236 am_Error_e CAmControlReceiver::changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID)
237 {
238     return (mDatabaseHandler->changeSinkMainVolumeDB(mainVolume, sinkID));
239 }
240
241 am_Error_e CAmControlReceiver::changeSinkAvailabilityDB(const am_Availability_s & availability, const am_sinkID_t sinkID)
242 {
243     return (mDatabaseHandler->changeSinkAvailabilityDB(availability, sinkID));
244 }
245
246 am_Error_e CAmControlReceiver::changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID)
247 {
248     return (mDatabaseHandler->changDomainStateDB(domainState, domainID));
249 }
250
251 am_Error_e CAmControlReceiver::changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID)
252 {
253     return (mDatabaseHandler->changeSinkMuteStateDB(muteState, sinkID));
254 }
255
256 am_Error_e CAmControlReceiver::changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID)
257 {
258     return (mDatabaseHandler->changeMainSinkSoundPropertyDB(soundProperty, sinkID));
259 }
260
261 am_Error_e CAmControlReceiver::changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID)
262 {
263     return (mDatabaseHandler->changeMainSourceSoundPropertyDB(soundProperty, sourceID));
264 }
265
266 am_Error_e CAmControlReceiver::changeSourceAvailabilityDB(const am_Availability_s & availability, const am_sourceID_t sourceID)
267 {
268     return (mDatabaseHandler->changeSourceAvailabilityDB(availability, sourceID));
269 }
270
271 am_Error_e CAmControlReceiver::changeSystemPropertyDB(const am_SystemProperty_s & property)
272 {
273     return (mDatabaseHandler->changeSystemPropertyDB(property));
274 }
275
276 am_Error_e CAmControlReceiver::removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID)
277 {
278     return (mDatabaseHandler->removeMainConnectionDB(mainConnectionID));
279 }
280
281 am_Error_e CAmControlReceiver::removeSinkDB(const am_sinkID_t sinkID)
282 {
283     return (mDatabaseHandler->removeSinkDB(sinkID));
284 }
285
286 am_Error_e CAmControlReceiver::removeSourceDB(const am_sourceID_t sourceID)
287 {
288     return (mDatabaseHandler->removeSourceDB(sourceID));
289 }
290
291 am_Error_e CAmControlReceiver::removeGatewayDB(const am_gatewayID_t gatewayID)
292 {
293     return (mDatabaseHandler->removeGatewayDB(gatewayID));
294 }
295
296 am_Error_e CAmControlReceiver::removeCrossfaderDB(const am_crossfaderID_t crossfaderID)
297 {
298     return (mDatabaseHandler->removeCrossfaderDB(crossfaderID));
299 }
300
301 am_Error_e CAmControlReceiver::removeDomainDB(const am_domainID_t domainID)
302 {
303     return (mDatabaseHandler->removeDomainDB(domainID));
304 }
305
306 am_Error_e CAmControlReceiver::getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s & classInfo) const
307 {
308     return (mDatabaseHandler->getSourceClassInfoDB(sourceID, classInfo));
309 }
310
311 am_Error_e CAmControlReceiver::getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s & sinkClass) const
312 {
313     return (mDatabaseHandler->getSinkClassInfoDB(sinkID, sinkClass));
314 }
315
316 am_Error_e CAmControlReceiver::getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s & sinkData) const
317 {
318     return (mDatabaseHandler->getSinkInfoDB(sinkID, sinkData));
319 }
320
321 am_Error_e CAmControlReceiver::getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s & sourceData) const
322 {
323     return (mDatabaseHandler->getSourceInfoDB(sourceID, sourceData));
324 }
325
326 am_Error_e CAmControlReceiver::getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s & mainConnectionData) const
327 {
328     return (mDatabaseHandler->getMainConnectionInfoDB(mainConnectionID, mainConnectionData));
329 }
330
331 am_Error_e CAmControlReceiver::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s & gatewayData) const
332 {
333     return (mDatabaseHandler->getGatewayInfoDB(gatewayID, gatewayData));
334 }
335
336 am_Error_e CAmControlReceiver::getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s & crossfaderData) const
337 {
338     return (mDatabaseHandler->getCrossfaderInfoDB(crossfaderID, crossfaderData));
339 }
340
341 am_Error_e CAmControlReceiver::getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> & listSinkID) const
342 {
343     return (mDatabaseHandler->getListSinksOfDomain(domainID, listSinkID));
344 }
345
346 am_Error_e CAmControlReceiver::getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> & listSourceID) const
347 {
348     return (mDatabaseHandler->getListSourcesOfDomain(domainID, listSourceID));
349 }
350
351 am_Error_e CAmControlReceiver::getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> & listGatewaysID) const
352 {
353     return (mDatabaseHandler->getListCrossfadersOfDomain(domainID, listGatewaysID));
354 }
355
356 am_Error_e CAmControlReceiver::getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> & listGatewaysID) const
357 {
358     return (mDatabaseHandler->getListGatewaysOfDomain(domainID, listGatewaysID));
359 }
360
361 am_Error_e CAmControlReceiver::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections) const
362 {
363     return (mDatabaseHandler->getListMainConnections(listMainConnections));
364 }
365
366 am_Error_e CAmControlReceiver::getListDomains(std::vector<am_Domain_s> & listDomains) const
367 {
368     return (mDatabaseHandler->getListDomains(listDomains));
369 }
370
371 am_Error_e CAmControlReceiver::getListConnections(std::vector<am_Connection_s> & listConnections) const
372 {
373     return (mDatabaseHandler->getListConnections(listConnections));
374 }
375
376 am_Error_e CAmControlReceiver::getListSinks(std::vector<am_Sink_s> & listSinks) const
377 {
378     return (mDatabaseHandler->getListSinks(listSinks));
379 }
380
381 am_Error_e CAmControlReceiver::getListSources(std::vector<am_Source_s> & listSources) const
382 {
383     return (mDatabaseHandler->getListSources(listSources));
384 }
385
386 am_Error_e CAmControlReceiver::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const
387 {
388     return (mDatabaseHandler->getListSourceClasses(listSourceClasses));
389 }
390
391 am_Error_e CAmControlReceiver::getListHandles(std::vector<am_Handle_s> & listHandles) const
392 {
393     return (mRoutingSender->getListHandles(listHandles));
394 }
395
396 am_Error_e CAmControlReceiver::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders) const
397 {
398     return (mDatabaseHandler->getListCrossfaders(listCrossfaders));
399 }
400
401 am_Error_e CAmControlReceiver::getListGateways(std::vector<am_Gateway_s> & listGateways) const
402 {
403     return (mDatabaseHandler->getListGateways(listGateways));
404 }
405
406 am_Error_e CAmControlReceiver::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const
407 {
408     return (mDatabaseHandler->getListSinkClasses(listSinkClasses));
409 }
410
411 am_Error_e CAmControlReceiver::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const
412 {
413     return (mDatabaseHandler->getListSystemProperties(listSystemProperties));
414 }
415
416 am_Error_e CAmControlReceiver::changeSinkClassInfoDB(const am_SinkClass_s & classInfo)
417 {
418     return (mDatabaseHandler->changeSinkClassInfoDB(classInfo));
419 }
420
421 am_Error_e CAmControlReceiver::changeSourceClassInfoDB(const am_SourceClass_s & classInfo)
422 {
423     return(mDatabaseHandler->changeSourceClassInfoDB(classInfo));
424 }
425
426 am_Error_e CAmControlReceiver::removeSinkClassDB(const am_sinkClass_t sinkClassID)
427 {
428     return (mDatabaseHandler->removeSinkClassDB(sinkClassID));
429 }
430
431 am_Error_e CAmControlReceiver::removeSourceClassDB(const am_sourceClass_t sourceClassID)
432 {
433     return (mDatabaseHandler->removeSourceClassDB(sourceClassID));
434 }
435
436 void CAmControlReceiver::setCommandReady()
437 {
438     logInfo("CAmControlReceiver::setCommandReady got called");
439     mCommandSender->setCommandReady();
440 }
441
442 void CAmControlReceiver::setRoutingReady()
443 {
444     logInfo("CAmControlReceiver::setRoutingReady got called");
445     mRoutingSender->setRoutingReady();
446 }
447
448 void CAmControlReceiver::confirmControllerReady(const am_Error_e error)
449 {
450     //todo: one time implement here system interaction with NSM
451         if (error!=E_OK)
452                 logError("CAmControlReceiver::confirmControllerReady controller reported error", error);
453 }
454
455 void CAmControlReceiver::confirmControllerRundown(const am_Error_e error)
456 {
457         if (error!=E_OK)
458         {
459                 logError("CAmControlReceiver::confirmControllerRundown() exited with error ",error);
460                 //we might be blocked here -> so lets better exit right away
461                 throw std::runtime_error("controller Confirmed with error");
462         }
463
464         logInfo ("CAmControlReceiver::confirmControllerRundown(), will exit now");
465
466         //end the mainloop here...
467         mSocketHandler->exit_mainloop();
468 }
469
470 am_Error_e CAmControlReceiver::getSocketHandler(CAmSocketHandler *& socketHandler)
471 {
472     socketHandler = mSocketHandler;
473     return (E_OK);
474 }
475
476 void CAmControlReceiver::setCommandRundown()
477 {
478     logInfo("CAmControlReceiver::setCommandRundown got called");
479     mCommandSender->setCommandRundown();
480 }
481
482 void CAmControlReceiver::setRoutingRundown()
483 {
484     logInfo("CAmControlReceiver::setRoutingRundown got called");
485     mRoutingSender->setRoutingRundown();
486 }
487
488 void CAmControlReceiver::getInterfaceVersion(std::string & version) const
489 {
490     version = ControlReceiveVersion;
491 }
492
493 am_Error_e CAmControlReceiver::changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
494 {
495     logInfo("CAmControlReceiver::changeSourceDB was called, sourceID", sourceID);
496     return (mDatabaseHandler->changeSourceDB(sourceID,sourceClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties));
497 }
498
499 am_Error_e CAmControlReceiver::changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
500 {
501     logInfo("CAmControlReceiver::changeSinkDB was called with sinkID", sinkID);
502     return (mDatabaseHandler->changeSinkDB(sinkID,sinkClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties));
503 }
504
505 am_Error_e CAmControlReceiver::changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t>& listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix)
506 {
507     logInfo("CAmControlReceiver::changeGatewayDB was called with gatewayID", gatewayID);
508     return (mDatabaseHandler->changeGatewayDB(gatewayID,listSourceConnectionFormats,listSinkConnectionFormats,convertionMatrix));
509 }
510
511 am_Error_e CAmControlReceiver::setVolumes(am_Handle_s& handle, const std::vector<am_Volumes_s>& listVolumes)
512 {
513     logInfo("CAmControlReceiver::setVolumes got called");
514     return (mRoutingSender->asyncSetVolumes(handle,listVolumes));
515 }
516
517 am_Error_e CAmControlReceiver::setSinkNotificationConfiguration(am_Handle_s& handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration)
518 {
519     logInfo("CAmControlReceiver::setSinkNotificationConfiguration called, sinkID=",sinkID,"notificationConfiguration.type=",notificationConfiguration.type,"notificationConfiguration.status",notificationConfiguration.status,"notificationConfiguration.parameter",notificationConfiguration.parameter);
520     return (mRoutingSender->asyncSetSinkNotificationConfiguration(handle,sinkID,notificationConfiguration));
521 }
522
523 am_Error_e CAmControlReceiver::setSourceNotificationConfiguration(am_Handle_s& handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration)
524 {
525     logInfo("CAmControlReceiver::setSourceNotificationConfiguration called, sourceID=",sourceID,"notificationConfiguration.type=",notificationConfiguration.type,"notificationConfiguration.status",notificationConfiguration.status,"notificationConfiguration.parameter",notificationConfiguration.parameter);
526     return (mRoutingSender->asyncSetSourceNotificationConfiguration(handle,sourceID,notificationConfiguration));
527 }
528
529 void CAmControlReceiver::sendMainSinkNotificationPayload(const am_sinkID_t sinkID, const am_NotificationPayload_s& notificationPayload)
530 {
531     logInfo("CAmControlReceiver::sendSinkMainNotificationPayload called, sinkID=",sinkID,"type=",notificationPayload.type,"value=",notificationPayload.value);
532     mCommandSender->cbSinkNotification(sinkID,notificationPayload);
533 }
534
535 void CAmControlReceiver::sendMainSourceNotificationPayload(const am_sourceID_t sourceID, const am_NotificationPayload_s& notificationPayload)
536 {
537     logInfo("CAmControlReceiver::sendSourceMainNotificationPayload called, sourceID=",sourceID,"type=",notificationPayload.type,"value=",notificationPayload.value);
538     mCommandSender->cbSourceNotification(sourceID,notificationPayload);
539 }
540
541 am_Error_e CAmControlReceiver::changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& mainNotificationConfiguration)
542 {
543     logInfo("CAmControlReceiver::changeMainSinkNotificationConfigurationDB was called with sinkID", sinkID);
544     return (mDatabaseHandler->changeMainSinkNotificationConfigurationDB(sinkID,mainNotificationConfiguration));
545 }
546
547 am_Error_e CAmControlReceiver::changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& mainNotificationConfiguration)
548 {
549     logInfo("CAmControlReceiver::changeMainSourceNotificationConfigurationDB was called with sourceID", sourceID);
550     return (mDatabaseHandler->changeMainSourceNotificationConfigurationDB(sourceID,mainNotificationConfiguration));
551 }
552
553 am_Error_e CAmControlReceiver::getRestartReasonPropertyNSM(NsmRestartReason_e& restartReason)
554 {
555     if (!mNodeStateCommunicator)
556         return (E_NON_EXISTENT);
557 #ifdef WITH_NSM
558     return (mNodeStateCommunicator->nsmGetRestartReasonProperty(restartReason));
559 #else
560     (void)restartReason;
561     return (E_NON_EXISTENT);
562 #endif
563 }
564
565 am_Error_e CAmControlReceiver::getShutdownReasonPropertyNSM(NsmShutdownReason_e& ShutdownReason)
566 {
567     if (!mNodeStateCommunicator)
568         return (E_NON_EXISTENT);
569 #ifdef WITH_NSM
570     return (mNodeStateCommunicator->nsmGetShutdownReasonProperty(ShutdownReason));
571 #else
572     (void)ShutdownReason;
573     return (E_NON_EXISTENT);
574 #endif
575
576 }
577
578 am_Error_e CAmControlReceiver::getRunningReasonPropertyNSM(NsmRunningReason_e& nsmRunningReason)
579 {
580     if (!mNodeStateCommunicator)
581         return (E_NON_EXISTENT);
582 #ifdef WITH_NSM
583     return (mNodeStateCommunicator->nsmGetRunningReasonProperty(nsmRunningReason));
584 #else
585     (void)nsmRunningReason;
586     return (E_NON_EXISTENT);
587 #endif
588
589 }
590
591 NsmErrorStatus_e CAmControlReceiver::getNodeStateNSM(NsmNodeState_e& nsmNodeState)
592 {
593     if (!mNodeStateCommunicator)
594         return (NsmErrorStatus_Error);
595 #ifdef WITH_NSM
596     return (mNodeStateCommunicator->nsmGetNodeState(nsmNodeState));
597 #else
598     (void) nsmNodeState;
599     return (NsmErrorStatus_Error);
600 #endif
601 }
602
603 NsmErrorStatus_e CAmControlReceiver::getSessionStateNSM(const std::string& sessionName, const NsmSeat_e seatID, NsmSessionState_e& sessionState)
604 {
605     if (!mNodeStateCommunicator)
606         return (NsmErrorStatus_Error);
607 #ifdef WITH_NSM
608     return (mNodeStateCommunicator->nsmGetSessionState(sessionName,seatID,sessionState));
609 #else
610     (void) sessionName;
611     (void) seatID;
612     (void) sessionState;
613     return (NsmErrorStatus_Error);
614 #endif
615
616 }
617
618 NsmErrorStatus_e CAmControlReceiver::getApplicationModeNSM(NsmApplicationMode_e& applicationMode)
619 {
620     if (!mNodeStateCommunicator)
621         return (NsmErrorStatus_Error);
622 #ifdef WITH_NSM
623     return (mNodeStateCommunicator->nsmGetApplicationMode(applicationMode));
624 #else
625     (void) applicationMode;
626     return (NsmErrorStatus_Error);
627 #endif
628
629 }
630
631 NsmErrorStatus_e CAmControlReceiver::registerShutdownClientNSM(const uint32_t shutdownMode, const uint32_t timeoutMs)
632 {
633     if (!mNodeStateCommunicator)
634         return (NsmErrorStatus_Error);
635 #ifdef WITH_NSM
636     return (mNodeStateCommunicator->nsmRegisterShutdownClient(shutdownMode,timeoutMs));
637 #else
638     (void) shutdownMode;
639     (void) timeoutMs;
640     return (NsmErrorStatus_Error);
641 #endif
642
643 }
644
645 NsmErrorStatus_e CAmControlReceiver::unRegisterShutdownClientNSM(const uint32_t shutdownMode)
646 {
647     if (!mNodeStateCommunicator)
648         return (NsmErrorStatus_Error);
649 #ifdef WITH_NSM
650     return (mNodeStateCommunicator->nsmUnRegisterShutdownClient(shutdownMode));
651 #else
652     (void) shutdownMode;
653     return (NsmErrorStatus_Error);
654 #endif
655
656 }
657
658 am_Error_e CAmControlReceiver::getInterfaceVersionNSM(uint32_t& version)
659 {
660     if (!mNodeStateCommunicator)
661         return (E_NON_EXISTENT);
662 #ifdef WITH_NSM
663     return (mNodeStateCommunicator->nsmGetInterfaceVersion(version));
664 #else
665     (void) version;
666     return (E_NON_EXISTENT);
667 #endif
668
669 }
670
671 NsmErrorStatus_e CAmControlReceiver::sendLifecycleRequestCompleteNSM(const uint32_t RequestId, const NsmErrorStatus_e status)
672 {
673     if (!mNodeStateCommunicator)
674         return (NsmErrorStatus_Error);
675 #ifdef WITH_NSM
676     return (mNodeStateCommunicator->nsmSendLifecycleRequestComplete(RequestId,status));
677 #else
678     (void) RequestId;
679     (void) status;
680     return (NsmErrorStatus_Error);
681 #endif
682
683 }
684
685 am_Error_e CAmControlReceiver::getDBusConnectionWrapper(CAmDbusWrapper *& dbusConnectionWrapper) const
686 {
687 #ifdef WITH_DBUS_WRAPPER
688     dbusConnectionWrapper = mDBusWrapper;
689     return (E_OK);
690 #else
691     return (E_UNKNOWN);
692 #endif
693 }
694
695 }