summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon/src
diff options
context:
space:
mode:
authorAleksandar Donchev <aleksander.donchev@partner.bmw.de>2013-09-02 11:57:28 +0200
committerChristian Linke <Christian.Linke@bmw.de>2013-09-03 17:26:04 +0200
commita2edae5cee4254b933f42399edc0e092abd4f5cf (patch)
treeead58f525b947deed4b8c76ab9c89c80b5056227 /AudioManagerDaemon/src
parent7aee1baeea1777318932cc49a8eac18f194233cd (diff)
downloadaudiomanager-a2edae5cee4254b933f42399edc0e092abd4f5cf.tar.gz
*PluginCommandInterfaceCAPI, PluginRoutingInterfaceCAPI, NodeStateCommunicatorCAPI with unit tests first version.
Choosing between DBUS and Common-API via cmake. CommonAPI - legacy support for DBus properties (Set 1) Signed-off-by: Christian Linke <christian.linke@bmw.de> (cherry picked from commit ea96ef59e29466667c90b506426e2a5a9cdb82d2)
Diffstat (limited to 'AudioManagerDaemon/src')
-rw-r--r--AudioManagerDaemon/src/CAmCommonAPIWrapper.cpp275
-rw-r--r--AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp2
-rw-r--r--AudioManagerDaemon/src/CAmDbusWrapper.cpp2
-rw-r--r--AudioManagerDaemon/src/CAmNodeStateCommunicatorCAPI.cpp361
-rw-r--r--AudioManagerDaemon/src/CAmNodeStateCommunicatorDBus.cpp (renamed from AudioManagerDaemon/src/CAmNodeStateCommunicator.cpp)163
-rw-r--r--AudioManagerDaemon/src/CAmRoutingReceiver.cpp4
-rwxr-xr-xAudioManagerDaemon/src/main.cpp45
7 files changed, 751 insertions, 101 deletions
diff --git a/AudioManagerDaemon/src/CAmCommonAPIWrapper.cpp b/AudioManagerDaemon/src/CAmCommonAPIWrapper.cpp
new file mode 100644
index 0000000..28103de
--- /dev/null
+++ b/AudioManagerDaemon/src/CAmCommonAPIWrapper.cpp
@@ -0,0 +1,275 @@
+/**
+ * Copyright (C) 2012, BMW AG
+ *
+ * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * \file CAmCommonAPIWrapper.cpp
+ * For further information see http://www.genivi.org/.
+ */
+
+
+#include <config.h>
+#include <fstream>
+#include <sstream>
+#include <string>
+#include <algorithm>
+#include <cassert>
+#include <cstdlib>
+#include <stdexcept>
+#include <poll.h>
+#include <tuple>
+#include "audiomanagertypes.h"
+#include "shared/CAmSocketHandler.h"
+#include "shared/CAmDltWrapper.h"
+#include "shared/CAmCommonAPIWrapper.h"
+
+
+namespace am
+{
+static CAmCommonAPIWrapper* pSingleCommonAPIInstance = NULL;
+
+
+using namespace CommonAPI;
+
+CAmCommonAPIWrapper::CAmCommonAPIWrapper(CAmSocketHandler* socketHandler):
+ pCommonPrepareCallback(this,&CAmCommonAPIWrapper::commonPrepareCallback), //
+ pCommonDispatchCallback(this, &CAmCommonAPIWrapper::commonDispatchCallback), //
+ pCommonFireCallback(this, &CAmCommonAPIWrapper::commonFireCallback), //
+ pCommonCheckCallback(this, &CAmCommonAPIWrapper::commonCheckCallback), //
+ pCommonTimerCallback(this, &CAmCommonAPIWrapper::commonTimerCallback), //
+ mpSocketHandler(socketHandler), //
+ mWatchToCheck(NULL)
+{
+ assert(NULL!=socketHandler);
+//1. Load the runtime
+ std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load();
+//2. Get the context and store a pointer to it
+ mContext = runtime->getNewMainLoopContext();
+//3. Make subscriptions
+ mDispatchSourceListenerSubscription = mContext->subscribeForDispatchSources(
+ std::bind(&CAmCommonAPIWrapper::registerDispatchSource, this, std::placeholders::_1, std::placeholders::_2),
+ std::bind(&CAmCommonAPIWrapper::deregisterDispatchSource, this, std::placeholders::_1));
+ mWatchListenerSubscription = mContext->subscribeForWatches(
+ std::bind(&CAmCommonAPIWrapper::registerWatch, this, std::placeholders::_1, std::placeholders::_2),
+ std::bind(&CAmCommonAPIWrapper::deregisterWatch, this, std::placeholders::_1));
+ mTimeoutSourceListenerSubscription = mContext->subscribeForTimeouts(
+ std::bind(&CAmCommonAPIWrapper::registerTimeout, this, std::placeholders::_1, std::placeholders::_2),
+ std::bind(&CAmCommonAPIWrapper::deregisterTimeout, this, std::placeholders::_1));
+//4. Create the factory
+ std::shared_ptr<CommonAPI::Factory> factory = runtime->createFactory(mContext);
+ assert(factory);
+ logInfo(__PRETTY_FUNCTION__,"CommonAPI -> Factory created");
+ mFactory = factory;
+//5. Get the publisher V.2.1
+// std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher = runtime->getServicePublisher();
+// assert(servicePublisher);
+// logInfo(__PRETTY_FUNCTION__,"CommonAPI -> Publisher available");
+//6. Instantiate your concrete stub implementations
+// std::shared_ptr<StubImpl> theStub = std::make_shared<StubImpl>(1);
+//7. Register the services
+// std::string capiAddress("local:org.genivi.audiomanager.sourcestate:de.bmw.infotainment.broadcast.ta");
+// registerStub(theStub, capiAddress);
+}
+
+CAmCommonAPIWrapper::~CAmCommonAPIWrapper()
+{
+ mContext->unsubscribeForDispatchSources(mDispatchSourceListenerSubscription);
+ mContext->unsubscribeForWatches(mWatchListenerSubscription);
+ mContext->unsubscribeForTimeouts(mTimeoutSourceListenerSubscription);
+//The following objects must be released in the given order.
+ mFactory.reset();
+ mContext.reset();
+
+ mpSocketHandler = NULL;
+ mWatchToCheck = NULL;
+}
+
+CAmCommonAPIWrapper* CAmCommonAPIWrapper::instantiateOnce(CAmSocketHandler* socketHandler)
+{
+ if(NULL==pSingleCommonAPIInstance)
+ {
+ if(NULL==socketHandler)
+ throw std::runtime_error(std::string("Expected a valid socket handler. The socket handler pointer must not be NULL."));
+ else
+ pSingleCommonAPIInstance = new CAmCommonAPIWrapper(socketHandler);
+ }
+ else
+ throw std::logic_error(std::string("The singleton instance has been already instantiated. This method should be called only once."));
+ return pSingleCommonAPIInstance;
+}
+
+CAmCommonAPIWrapper* CAmCommonAPIWrapper::getInstance()
+{
+ assert(NULL!=pSingleCommonAPIInstance);
+ return pSingleCommonAPIInstance;
+}
+
+std::shared_ptr<CommonAPI::Factory> CAmCommonAPIWrapper::factory() const
+{
+ return mFactory;
+}
+
+
+std::shared_ptr<CommonAPI::Runtime> CAmCommonAPIWrapper::runtime() const
+{
+ return mFactory->getRuntime();
+}
+
+bool CAmCommonAPIWrapper::commonDispatchCallback(const sh_pollHandle_t handle, void *userData)
+{
+ (void) handle;
+ (void) userData;
+
+ std::list<DispatchSource*>::iterator iterator(mSourcesToDispatch.begin());
+ for(;iterator!=mSourcesToDispatch.end();)
+ {
+ DispatchSource* source = *iterator;
+ if (!source->dispatch()) {
+ iterator=mSourcesToDispatch.erase(iterator);
+ }
+ else
+ iterator++;
+ }
+ if (!mSourcesToDispatch.empty())
+ return (true);
+
+ return false;
+}
+
+bool CAmCommonAPIWrapper::commonCheckCallback(const sh_pollHandle_t, void *)
+{
+ std::vector<DispatchSource*> vecDispatch=mWatchToCheck->getDependentDispatchSources();
+ mSourcesToDispatch.insert(mSourcesToDispatch.end(), vecDispatch.begin(), vecDispatch.end());
+
+ return (mWatchToCheck || !mSourcesToDispatch.empty());
+}
+
+void CAmCommonAPIWrapper::commonFireCallback(const pollfd pollfd, const sh_pollHandle_t, void *)
+{
+ mWatchToCheck=NULL;
+ try
+ {
+ mWatchToCheck=mMapWatches.at(pollfd.fd);
+ }
+ catch (const std::out_of_range& error) {
+ logInfo(__PRETTY_FUNCTION__,error.what());
+ return;
+ }
+
+ mWatchToCheck->dispatch(pollfd.events);
+}
+
+void CAmCommonAPIWrapper::commonPrepareCallback(const sh_pollHandle_t, void*)
+{
+ for (auto dispatchSourceIterator = mRegisteredDispatchSources.begin();
+ dispatchSourceIterator != mRegisteredDispatchSources.end();
+ dispatchSourceIterator++)
+ {
+ int64_t dispatchTimeout(TIMEOUT_INFINITE);
+ if(dispatchSourceIterator->second->prepare(dispatchTimeout))
+ {
+ while (dispatchSourceIterator->second->dispatch());
+ }
+ }
+}
+
+void CAmCommonAPIWrapper::registerDispatchSource(DispatchSource* dispatchSource, const DispatchPriority dispatchPriority)
+{
+ mRegisteredDispatchSources.insert({dispatchPriority, dispatchSource});
+}
+
+void CAmCommonAPIWrapper::deregisterDispatchSource(DispatchSource* dispatchSource)
+{
+ for(auto dispatchSourceIterator = mRegisteredDispatchSources.begin();
+ dispatchSourceIterator != mRegisteredDispatchSources.end();
+ dispatchSourceIterator++) {
+
+ if(dispatchSourceIterator->second == dispatchSource) {
+ mRegisteredDispatchSources.erase(dispatchSourceIterator);
+ break;
+ }
+ }
+}
+
+void CAmCommonAPIWrapper::deregisterWatch(Watch* watch)
+{
+ logInfo(__PRETTY_FUNCTION__);
+ for(std::map<int,Watch*>::iterator iter(mMapWatches.begin());iter!=mMapWatches.end();iter++)
+ {
+ if (iter->second == watch)
+ {
+ mMapWatches.erase(iter);
+ break;
+ }
+ }
+}
+
+void CAmCommonAPIWrapper::registerTimeout(Timeout* timeout, const DispatchPriority)
+{
+ logInfo(__PRETTY_FUNCTION__);
+ timespec pollTimeout;
+ int64_t localTimeout = timeout->getTimeoutInterval();
+
+ pollTimeout.tv_sec = localTimeout / 1000;
+ pollTimeout.tv_nsec = (localTimeout % 1000) * 1000000;
+
+ //prepare handle and callback. new is eval, but there is no other choice because we need the pointer!
+ sh_timerHandle_t handle;
+ timerHandles myHandle({handle,timeout});
+ mpListTimerhandles.push_back(myHandle);
+
+ //add the timer to the pollLoop
+ mpSocketHandler->addTimer(pollTimeout, &pCommonTimerCallback, handle, timeout);
+
+ return;
+}
+
+void CAmCommonAPIWrapper::deregisterTimeout(Timeout* timeout)
+{
+ logInfo(__PRETTY_FUNCTION__);
+ for( std::vector<timerHandles>::iterator iter(mpListTimerhandles.begin());iter!=mpListTimerhandles.end();iter++)
+ {
+ if(iter->timeout==timeout)
+ {
+ mpSocketHandler->removeTimer(iter->handle);
+ }
+ }
+}
+
+void CAmCommonAPIWrapper::registerWatch(Watch* watch, const DispatchPriority)
+{
+ logInfo(__PRETTY_FUNCTION__);
+ pollfd pollfd_ (watch->getAssociatedFileDescriptor());
+ sh_pollHandle_t handle (0);
+
+ am_Error_e error = mpSocketHandler->addFDPoll(pollfd_.fd, pollfd_.events, &pCommonPrepareCallback, &pCommonFireCallback, &pCommonCheckCallback, &pCommonDispatchCallback, watch, handle);
+
+ //if everything is alright, add the watch and the handle to our map so we know this relationship
+ if (error == !am_Error_e::E_OK || handle == 0)
+ logError(__PRETTY_FUNCTION__,"entering watch failed");
+
+ mMapWatches.insert(std::make_pair(pollfd_.fd,watch));
+}
+
+void CAmCommonAPIWrapper::commonTimerCallback(sh_timerHandle_t handle, void *)
+{
+ for( std::vector<timerHandles>::iterator iter(mpListTimerhandles.begin());iter!=mpListTimerhandles.end();iter++)
+ {
+ if(iter->handle==handle)
+ {
+ iter->timeout->dispatch();
+ }
+ }
+}
+
+}
diff --git a/AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp b/AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp
index ba19641..3e83cc5 100644
--- a/AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp
+++ b/AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp
@@ -2418,7 +2418,7 @@ am_Error_e CAmDatabaseHandlerMap::getRoutingTree(bool onlyfree, CAmRoutingTree&
{
if(!onlyfree || std::find_if(mMappedData.mConnectionMap.begin(),
mMappedData.mConnectionMap.end(),
- [refGateway](const std::pair<am_connectionID_t, am_Connection_Database_s>& refConnection)
+ [&](const std::pair<am_connectionID_t, am_Connection_Database_s>& refConnection)
{
return (refConnection.second.sinkID == refGateway.second.sinkID ||
refConnection.second.sourceID ==refGateway.second.sourceID);
diff --git a/AudioManagerDaemon/src/CAmDbusWrapper.cpp b/AudioManagerDaemon/src/CAmDbusWrapper.cpp
index 18cf70b..c9c26a4 100644
--- a/AudioManagerDaemon/src/CAmDbusWrapper.cpp
+++ b/AudioManagerDaemon/src/CAmDbusWrapper.cpp
@@ -48,10 +48,10 @@ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
CAmDbusWrapper* CAmDbusWrapper::mpReference = NULL;
CAmDbusWrapper::CAmDbusWrapper(CAmSocketHandler* socketHandler, DBusBusType type) :
+ pDbusPrepareCallback(this,&CAmDbusWrapper::dbusPrepareCallback), //
pDbusDispatchCallback(this, &CAmDbusWrapper::dbusDispatchCallback), //
pDbusFireCallback(this, &CAmDbusWrapper::dbusFireCallback), //
pDbusCheckCallback(this, &CAmDbusWrapper::dbusCheckCallback), //
- pDbusPrepareCallback(this,&CAmDbusWrapper::dbusPrepareCallback), //
pDbusTimerCallback(this, &CAmDbusWrapper::dbusTimerCallback), //
mpDbusConnection(0), //
mDBusError(), //
diff --git a/AudioManagerDaemon/src/CAmNodeStateCommunicatorCAPI.cpp b/AudioManagerDaemon/src/CAmNodeStateCommunicatorCAPI.cpp
new file mode 100644
index 0000000..3761fca
--- /dev/null
+++ b/AudioManagerDaemon/src/CAmNodeStateCommunicatorCAPI.cpp
@@ -0,0 +1,361 @@
+/**
+ * Copyright (C) 2012, BMW AG
+ *
+ * This file is part of GENIVI Project AudioManager.
+ *
+ * Contributions are licensed to the GENIVI Alliance under one or more
+ * Contribution License Agreements.
+ *
+ * \copyright
+ * This Source Code Form is subject to the terms of the
+ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+ * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \file CAmNodeStateCommunicatorCAPI.cpp
+ * For further information see http://www.genivi.org/.
+ *
+ */
+
+#include <assert.h>
+#include <string>
+#include <fstream>
+#include <sstream>
+#include <stdexcept>
+#include <functional>
+#include <memory>
+#include <CommonAPI/CommonAPI.h>
+#include "config.h"
+#include "shared/CAmCommonAPIWrapper.h"
+#include "shared/CAmDltWrapper.h"
+#include "CAmNodeStateCommunicatorCAPI.h"
+#include "CAmControlSender.h"
+#include "LifeCycleConsumer.h"
+
+
+
+
+namespace am
+{
+
+const char * CAmNodeStateCommunicatorCAPI::CLIENT_STRING = "local:org.genivi.NodeStateManager.Consumer:org.genivi.NodeStateManager";
+const char * CAmNodeStateCommunicatorCAPI::SERVER_STRING = "local:org.genivi.NodeStateManager.LifeCycleConsumer:org.genivi.audiomanger";
+
+const char * CAmNodeStateCommunicatorCAPI::OBJECT_NAME = "/org/genivi/audiomanager/LifeCycleConsumer";
+const char * CAmNodeStateCommunicatorCAPI::BUS_NAME = "org.genivi.audiomanager";
+
+
+#define IF_NOT_AVAILABLE_RETURN(error) \
+if(!mIsServiceAvailable) { logError(__PRETTY_FUNCTION__, "Node State Manager not available yet"); return error; }
+
+/**
+ * Retrieves the value from given attribute wrapper.
+ */
+template <typename TValueReturnType, class TValueClass> am_Error_e getAttributeValue(Attribute<TValueClass>* attribute, TValueReturnType & resultValue)
+{
+ CallStatus status;
+ typename Attribute<TValueClass>::ValueType value;
+ attribute->getValue(status, value);
+ std::cout << std::endl << "CallStatus : " << static_cast<int>(status) << std::endl;
+ if( CallStatus::SUCCESS == status)
+ {
+ resultValue = static_cast<TValueReturnType>(value);
+ return E_OK;
+ }
+ return E_UNKNOWN;
+}
+
+
+CAmNodeStateCommunicatorCAPI::CAmNodeStateCommunicatorCAPI(CAmCommonAPIWrapper* iCAPIWrapper) :
+ CAmNodeStateCommunicator(),
+ mpCAPIWrapper(iCAPIWrapper),
+ mIsServiceAvailable(false)
+{
+ assert(mpCAPIWrapper);
+ logInfo("CAmNodeStateCommunicatorCAPI::CAmNodeStateCommunicatorCAPI started");
+
+ //Gets the factory pointer and build a proxy object
+ std::shared_ptr<CommonAPI::Factory> factory = iCAPIWrapper->factory();
+ mNSMProxy = factory->buildProxy<ConsumerProxy>(CAmNodeStateCommunicatorCAPI::CLIENT_STRING);
+
+ //Makes subscriptions to the following 3 events
+ mNSMProxy->getNodeStateEvent().subscribe(
+ std::bind(&CAmNodeStateCommunicatorCAPI::onNodeStateEvent, this, std::placeholders::_1)
+ );
+ mNSMProxy->getNodeApplicationModeEvent().subscribe(
+ std::bind(&CAmNodeStateCommunicatorCAPI::onNodeApplicationModeEvent, this, std::placeholders::_1)
+ );
+ mNSMProxy->getSessionStateChangedEvent().subscribe(
+ std::bind(&CAmNodeStateCommunicatorCAPI::onSessionStateChangedEvent, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)
+ );
+ mNSMProxy->getProxyStatusEvent().subscribe(std::bind(&CAmNodeStateCommunicatorCAPI::onServiceStatusEvent,this,std::placeholders::_1));
+ //Instantiates the concrete stub implementation
+ mNSMStub = std::make_shared<CAmNodeStateCommunicatorCAPI::CAmNodeStateCommunicatorServiceImpl>(this);
+
+ //Registers the service
+ iCAPIWrapper->registerStub(mNSMStub, CAmNodeStateCommunicatorCAPI::SERVER_STRING);
+}
+
+CAmNodeStateCommunicatorCAPI::~CAmNodeStateCommunicatorCAPI()
+{
+ mNSMProxy.reset();
+ mpCAPIWrapper->unregisterStub(CAmNodeStateCommunicatorCAPI::SERVER_STRING);
+ mNSMStub->setDelegate(NULL);
+ mNSMStub.reset();
+ mpCAPIWrapper = NULL;
+}
+
+bool CAmNodeStateCommunicatorCAPI::isServiceAvailable()
+{
+ return mIsServiceAvailable;
+}
+
+/** retrieves the actual restart reason
+ *
+ * @param restartReason
+ * @return E_OK on success
+ */
+am_Error_e CAmNodeStateCommunicatorCAPI::nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason)
+{
+ //Check the service via the proxy object is available
+ IF_NOT_AVAILABLE_RETURN(E_NOT_POSSIBLE)
+ //Get the attribute
+ return getAttributeValue(&mNSMProxy->getRestartReasonAttribute(), restartReason);
+}
+
+/** retrieves the actual shutdown reason
+ *
+ * @param ShutdownReason
+ * @return E_OK on success
+ */
+am_Error_e CAmNodeStateCommunicatorCAPI::nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason)
+{
+ //Check the service via the proxy object is available
+ IF_NOT_AVAILABLE_RETURN(E_NOT_POSSIBLE)
+ //Get the attribute
+ return getAttributeValue(&mNSMProxy->getShutdownReasonAttribute(), ShutdownReason);
+}
+
+/** retrieves the actual running reason
+ *
+ * @param nsmRunningReason
+ * @return E_OK on success
+ */
+am_Error_e CAmNodeStateCommunicatorCAPI::nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason)
+{
+ //Check the service via the proxy object is available
+ IF_NOT_AVAILABLE_RETURN(E_NOT_POSSIBLE)
+ //Get the attribute
+ return getAttributeValue(&mNSMProxy->getWakeUpReasonAttribute(), nsmRunningReason);
+}
+
+/** gets the node state
+ *
+ * @param nsmNodeState
+ * @return NsmErrorStatus_Ok on success
+ */
+NsmErrorStatus_e CAmNodeStateCommunicatorCAPI::nsmGetNodeState(NsmNodeState_e& nsmNodeState)
+{
+ //Check the service via the proxy object is available
+ IF_NOT_AVAILABLE_RETURN(NsmErrorStatus_Error)
+
+ CallStatus callStatus;
+ int32_t tmpNodeState = 0, errorCode = 0;
+ mNSMProxy->GetNodeState(callStatus, tmpNodeState, errorCode);
+ if( CallStatus::SUCCESS == callStatus )
+ {
+ nsmNodeState = static_cast<NsmNodeState_e>(tmpNodeState);
+ return (static_cast<NsmErrorStatus_e>(errorCode));
+ }
+ return NsmErrorStatus_Error;
+}
+
+/** gets the session state for a session and seatID
+ *
+ * @param sessionName the name of the session
+ * @param seatID the seatID
+ * @param sessionState
+ * @return NsmErrorStatus_Ok on success
+ */
+NsmErrorStatus_e CAmNodeStateCommunicatorCAPI::nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState)
+{
+ //Check the service via the proxy object is available
+ IF_NOT_AVAILABLE_RETURN(NsmErrorStatus_Error)
+
+ CallStatus callStatus;
+ int32_t tmpSessionState = 0 , errorCode = 0;
+ mNSMProxy->GetSessionState(sessionName, seatID, callStatus, tmpSessionState, errorCode);
+
+ if( CallStatus::SUCCESS == callStatus)
+ {
+ sessionState = static_cast<NsmSessionState_e>(tmpSessionState);
+ return (static_cast<NsmErrorStatus_e>(errorCode));
+ }
+ return NsmErrorStatus_Error;
+}
+
+/** gets the application mode
+ *
+ * @param applicationMode
+ * @return NsmErrorStatus_Ok on success
+ */
+NsmErrorStatus_e CAmNodeStateCommunicatorCAPI::nsmGetApplicationMode(NsmApplicationMode_e& applicationMode)
+{
+ //Check the service via the proxy object is available
+ IF_NOT_AVAILABLE_RETURN(NsmErrorStatus_Error)
+
+ CallStatus callStatus;
+ int32_t tmpAppMode = 0 , errorCode = 0;
+ mNSMProxy->GetApplicationMode(callStatus, tmpAppMode, errorCode);
+ if( CallStatus::SUCCESS == callStatus)
+ {
+ applicationMode = static_cast<NsmApplicationMode_e>(tmpAppMode);
+ return (static_cast<NsmErrorStatus_e>(errorCode));
+ }
+ return NsmErrorStatus_Dbus;
+}
+
+/** this function registers the AudioManager as shutdown client at the NSM
+ * for more information check the Nodestatemanager
+ * @param shutdownMode the shutdownmode you wish to set
+ * @param timeoutMs the timeout you need to have
+ * @return NsmErrorStatus_Ok on success
+ */
+NsmErrorStatus_e CAmNodeStateCommunicatorCAPI::nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs)
+{
+ //Check the service via the proxy object is available
+ IF_NOT_AVAILABLE_RETURN(NsmErrorStatus_Error)
+
+ CallStatus callStatus;
+ int32_t errorCode = 0;
+ std::string objName = std::string(CAmNodeStateCommunicatorCAPI::OBJECT_NAME);
+ std::string busName = std::string(CAmNodeStateCommunicatorCAPI::BUS_NAME);
+ mNSMProxy->RegisterShutdownClient(busName, objName, shutdownMode, timeoutMs, callStatus, errorCode);
+ if( CallStatus::SUCCESS == callStatus)
+ return (static_cast<NsmErrorStatus_e>(errorCode));
+ return NsmErrorStatus_Dbus;
+
+}
+
+/** this function unregisters the AudioManager as shutdown client at the NSM
+ *
+ * @param shutdownMode
+ * @return NsmErrorStatus_Ok on success
+ */
+NsmErrorStatus_e CAmNodeStateCommunicatorCAPI::nsmUnRegisterShutdownClient(const uint32_t shutdownMode)
+{
+ //Check the service via the proxy object is available
+ IF_NOT_AVAILABLE_RETURN(NsmErrorStatus_Error)
+
+ CallStatus callStatus;
+ int32_t errorCode = 0;
+ std::string objName = std::string(CAmNodeStateCommunicatorCAPI::OBJECT_NAME);
+ std::string busName = std::string(CAmNodeStateCommunicatorCAPI::BUS_NAME);
+ mNSMProxy->UnRegisterShutdownClient(busName, objName, shutdownMode, callStatus, errorCode);
+ if( CallStatus::SUCCESS == callStatus)
+ return (static_cast<NsmErrorStatus_e>(errorCode));
+ return NsmErrorStatus_Dbus;
+}
+
+/** returns the interface version
+ *
+ * @param version
+ * @return E_OK on success
+ */
+am_Error_e CAmNodeStateCommunicatorCAPI::nsmGetInterfaceVersion(uint32_t& version)
+{
+ //Check the service via the proxy object is available
+ IF_NOT_AVAILABLE_RETURN(E_NOT_POSSIBLE)
+
+ CallStatus callStatus;
+ mNSMProxy->GetInterfaceVersion(callStatus, version);
+ if( CallStatus::SUCCESS == callStatus)
+ return E_OK;
+ return E_UNKNOWN;
+}
+
+/** sends out the Lifecycle request complete message
+ *
+ * @param RequestId
+ * @param status
+ * @return NsmErrorStatus_Ok on success
+ */
+NsmErrorStatus_e CAmNodeStateCommunicatorCAPI::nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status)
+{
+ //Check the service via the proxy object is available
+ IF_NOT_AVAILABLE_RETURN(NsmErrorStatus_Error)
+
+ CallStatus callStatus;
+ int32_t errorCode = 0;
+ mNSMProxy->LifecycleRequestComplete(RequestId, status, callStatus, errorCode);
+ if( CallStatus::SUCCESS == callStatus)
+ {
+ return (static_cast<NsmErrorStatus_e>(errorCode));
+ }
+ return NsmErrorStatus_Dbus;
+}
+
+/** notification handler for changed node state
+ *
+ * @param nodeState
+ * @return none
+ */
+void CAmNodeStateCommunicatorCAPI::onNodeStateEvent(const int32_t nodeState)
+{
+ logInfo(__PRETTY_FUNCTION__, " got signal NodeState, with nodeState",nodeState);
+ assert(mpControlSender);
+ mpControlSender->hookSystemNodeStateChanged(static_cast<NsmNodeState_e>(nodeState));
+}
+
+/** notification handler for changed node application mode
+ *
+ * @param nodeApplicationMode
+ * @return none
+ */
+void CAmNodeStateCommunicatorCAPI::onNodeApplicationModeEvent(const int32_t nodeApplicationMode)
+{
+ logInfo(__PRETTY_FUNCTION__, " got signal nodeApplicationMode, with applicationMode",nodeApplicationMode);
+ assert(mpControlSender);
+ mpControlSender->hookSystemNodeApplicationModeChanged(static_cast<NsmApplicationMode_e>(nodeApplicationMode));
+}
+
+/** notification handler for changed session state
+ *
+ * @param sessionName
+ * @param seatID
+ * @param sessionState
+ * @return none
+ */
+void CAmNodeStateCommunicatorCAPI::onSessionStateChangedEvent(const std::string & sessionName, const int32_t seatID, const int32_t sessionState)
+{
+ logInfo(__PRETTY_FUNCTION__, " got signal sessionStateChanged, with session",sessionName,"seatID=",seatID,"sessionState",sessionState);
+ assert(mpControlSender);
+ mpControlSender->hookSystemSessionStateChanged(sessionName, static_cast<NsmSeat_e>(seatID), static_cast<NsmSessionState_e>(sessionState));
+}
+
+void CAmNodeStateCommunicatorCAPI::onServiceStatusEvent(const CommonAPI::AvailabilityStatus& serviceStatus)
+{
+ std::stringstream avail;
+ avail << "(" << static_cast<int>(serviceStatus) << ")";
+
+ logInfo("Service Status of the NSM changed to ", avail.str());
+ std::cout << std::endl << "Service Status of the NSM changed to " << avail.str();
+ mIsServiceAvailable = (serviceStatus==CommonAPI::AvailabilityStatus::AVAILABLE);
+}
+
+/** implements the service part, which is invoked from the node state manager
+ *
+ * @param sessionName
+ * @param seatID
+ * @param sessionState
+ * @return none
+ */
+void CAmNodeStateCommunicatorCAPI::cbReceivedLifecycleRequest(uint32_t Request, uint32_t RequestId, int32_t& ErrorCode)
+{
+ assert(mpControlSender);
+ ErrorCode = mpControlSender->hookSystemLifecycleRequest(Request, RequestId);
+}
+
+} /* namespace am */
diff --git a/AudioManagerDaemon/src/CAmNodeStateCommunicator.cpp b/AudioManagerDaemon/src/CAmNodeStateCommunicatorDBus.cpp
index 689b975..4173890 100644
--- a/AudioManagerDaemon/src/CAmNodeStateCommunicator.cpp
+++ b/AudioManagerDaemon/src/CAmNodeStateCommunicatorDBus.cpp
@@ -14,29 +14,28 @@
*
* \author Christian Linke, christian.linke@bmw.de BMW 2012
*
- * \file CAmNodeStateCommunicator.cpp
+ * \file CAmNodeStateCommunicatorDBus.cpp
* For further information see http://www.genivi.org/.
*
*/
-#include "CAmNodeStateCommunicator.h"
+#include "CAmNodeStateCommunicatorDBus.h"
#include <assert.h>
#include <string>
#include <fstream>
+#include <sstream>
#include <stdexcept>
#include "CAmControlSender.h"
#include "shared/CAmDltWrapper.h"
#include "config.h"
-#include <sstream>
namespace am
{
static DBusObjectPathVTable gObjectPathVTable;
-CAmNodeStateCommunicator::CAmNodeStateCommunicator(CAmDbusWrapper* iDbusWrapper) :
+CAmNodeStateCommunicatorDBus::CAmNodeStateCommunicatorDBus(CAmDbusWrapper* iDbusWrapper) : CAmNodeStateCommunicator(),
mpDbusWrapper(iDbusWrapper), //
- mpControlSender(NULL), //
mpDBusConnection(NULL)
{
assert(mpDbusWrapper);
@@ -48,12 +47,12 @@ CAmNodeStateCommunicator::CAmNodeStateCommunicator(CAmDbusWrapper* iDbusWrapper)
//register the path and the callback for receiving messages
std::string path("LifeCycleConsumer");
- gObjectPathVTable.message_function=CAmNodeStateCommunicator::receiveCallback;
+ gObjectPathVTable.message_function=CAmNodeStateCommunicatorDBus::receiveCallback;
mpDbusWrapper->registerCallback(&gObjectPathVTable, path, this);
//now we need to make sure we catch the signals from the NSM:
dbus_bus_add_match(mpDBusConnection, "type=\'signal\',path=\'/org/genivi/NodeStateManager\'", NULL);
- if (!dbus_connection_add_filter(mpDBusConnection, CAmNodeStateCommunicator::signalCallback, this, NULL))
+ if (!dbus_connection_add_filter(mpDBusConnection, CAmNodeStateCommunicatorDBus::signalCallback, this, NULL))
{
logError("CAmNodeStateCommunicator::CAmNodeStateCommunicator not enought memory!");
throw std::runtime_error("CAmNodeStateCommunicator::CAmNodeStateCommunicator not enought memory!");
@@ -61,7 +60,7 @@ CAmNodeStateCommunicator::CAmNodeStateCommunicator(CAmDbusWrapper* iDbusWrapper)
dbus_connection_flush(mpDBusConnection);
}
-CAmNodeStateCommunicator::~CAmNodeStateCommunicator()
+CAmNodeStateCommunicatorDBus::~CAmNodeStateCommunicatorDBus()
{}
/** retrieves the actual restartReason
@@ -69,7 +68,7 @@ CAmNodeStateCommunicator::~CAmNodeStateCommunicator()
* @param restartReason
* @return E_OK on success
*/
-am_Error_e CAmNodeStateCommunicator::nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason)
+am_Error_e CAmNodeStateCommunicatorDBus::nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason)
{
int32_t answer(0);
am_Error_e error=readIntegerProperty("RestartReason",answer);
@@ -82,7 +81,7 @@ am_Error_e CAmNodeStateCommunicator::nsmGetRestartReasonProperty(NsmRestartReaso
* @param ShutdownReason
* @return E_OK on success
*/
-am_Error_e CAmNodeStateCommunicator::nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason)
+am_Error_e CAmNodeStateCommunicatorDBus::nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason)
{
int32_t answer(0);
am_Error_e error=readIntegerProperty("ShutdownReason",answer);
@@ -95,7 +94,7 @@ am_Error_e CAmNodeStateCommunicator::nsmGetShutdownReasonProperty(NsmShutdownRea
* @param nsmRunningReason
* @return E_OK on success
*/
-am_Error_e CAmNodeStateCommunicator::nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason)
+am_Error_e CAmNodeStateCommunicatorDBus::nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason)
{
int32_t answer(0);
am_Error_e error=readIntegerProperty("WakeUpReason",answer);
@@ -108,7 +107,7 @@ am_Error_e CAmNodeStateCommunicator::nsmGetRunningReasonProperty(NsmRunningReaso
* @param nsmNodeState
* @return NsmErrorStatus_Ok on success
*/
-NsmErrorStatus_e CAmNodeStateCommunicator::nsmGetNodeState(NsmNodeState_e& nsmNodeState)
+NsmErrorStatus_e CAmNodeStateCommunicatorDBus::nsmGetNodeState(NsmNodeState_e& nsmNodeState)
{
DBusError error;
dbus_error_init(&error);
@@ -120,14 +119,14 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmGetNodeState(NsmNodeState_e& nsmNo
if (!message)
{
- logError("CAmNodeStateCommunicator::nsmGetNodeState dbus error:", error.message);
+ logError("CAmNodeStateCommunicatorDBus::nsmGetNodeState dbus error:", error.message);
return (NsmErrorStatus_Dbus);
}
DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error));
if (!reply)
{
- logError("CAmNodeStateCommunicator::nsmGetNodeState failed, dbus error", error.message);
+ logError("CAmNodeStateCommunicatorDBus::nsmGetNodeState failed, dbus error", error.message);
return (NsmErrorStatus_Dbus);
}
@@ -147,7 +146,7 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmGetNodeState(NsmNodeState_e& nsmNo
* @param sessionState
* @return NsmErrorStatus_Ok on success
*/
-NsmErrorStatus_e CAmNodeStateCommunicator::nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState)
+NsmErrorStatus_e CAmNodeStateCommunicatorDBus::nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState)
{
DBusError error;
dbus_error_init(&error);
@@ -160,7 +159,7 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmGetSessionState(const std::string&
if (!message)
{
- logError("CAmNodeStateCommunicator::nsmGetSessionState dbus error:", error.message);
+ logError("CAmNodeStateCommunicatorDBus::nsmGetSessionState dbus error:", error.message);
return (NsmErrorStatus_Dbus);
}
@@ -168,20 +167,20 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmGetSessionState(const std::string&
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &sessionName))
{
- logError( "CAmNodeStateCommunicator::nsmGetSessionState no more memory");
+ logError( "CAmNodeStateCommunicatorDBus::nsmGetSessionState no more memory");
return (NsmErrorStatus_Dbus);
}
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &seatID))
{
- logError( "CAmNodeStateCommunicator::nsmGetSessionState no more memory");
+ logError( "CAmNodeStateCommunicatorDBus::nsmGetSessionState no more memory");
return (NsmErrorStatus_Dbus);
}
DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error));
if (!reply)
{
- logError("CAmNodeStateCommunicator::nsmGetSessionState failed, dbus error", error.message);
+ logError("CAmNodeStateCommunicatorDBus::nsmGetSessionState failed, dbus error", error.message);
return (NsmErrorStatus_Dbus);
}
@@ -201,7 +200,7 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmGetSessionState(const std::string&
* @param applicationMode
* @return NsmErrorStatus_Ok on success
*/
-NsmErrorStatus_e CAmNodeStateCommunicator::nsmGetApplicationMode(NsmApplicationMode_e& applicationMode)
+NsmErrorStatus_e CAmNodeStateCommunicatorDBus::nsmGetApplicationMode(NsmApplicationMode_e& applicationMode)
{
DBusError error;
dbus_error_init(&error);
@@ -212,14 +211,14 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmGetApplicationMode(NsmApplicationM
if (!message)
{
- logError("CAmNodeStateCommunicator::nsmGetApplicationMode dbus error:", error.message);
+ logError("CAmNodeStateCommunicatorDBus::nsmGetApplicationMode dbus error:", error.message);
return (NsmErrorStatus_Dbus);
}
DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error));
if (!reply)
{
- logError("CAmNodeStateCommunicator::nsmGetApplicationMode failed, dbus error", error.message);
+ logError("CAmNodeStateCommunicatorDBus::nsmGetApplicationMode failed, dbus error", error.message);
return (NsmErrorStatus_Dbus);
}
@@ -238,7 +237,7 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmGetApplicationMode(NsmApplicationM
* @param timeoutMs the timeout you need to have
* @return NsmErrorStatus_Ok on success
*/
-NsmErrorStatus_e CAmNodeStateCommunicator::nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs)
+NsmErrorStatus_e CAmNodeStateCommunicatorDBus::nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs)
{
DBusError error;
DBusMessageIter iter;
@@ -251,32 +250,32 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmRegisterShutdownClient(const uint3
if (!message)
{
- logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient dbus error:", error.message);
+ logError( "CAmNodeStateCommunicatorDBus::nsmRegisterShutdownClient dbus error:", error.message);
return (NsmErrorStatus_Dbus);
}
dbus_message_iter_init_append(message, &iter);
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &service))
{
- logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient no more memory");
+ logError( "CAmNodeStateCommunicatorDBus::nsmRegisterShutdownClient no more memory");
return (NsmErrorStatus_Dbus);
}
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &charPath))
{
- logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient no more memory");
+ logError( "CAmNodeStateCommunicatorDBus::nsmRegisterShutdownClient no more memory");
return (NsmErrorStatus_Dbus);
}
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &shutdownMode))
{
- logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient no more memory");
+ logError( "CAmNodeStateCommunicatorDBus::nsmRegisterShutdownClient no more memory");
return (NsmErrorStatus_Dbus);
}
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &timeoutMs))
{
- logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient no more memory");
+ logError( "CAmNodeStateCommunicatorDBus::nsmRegisterShutdownClient no more memory");
return (NsmErrorStatus_Dbus);
}
@@ -305,7 +304,7 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmRegisterShutdownClient(const uint3
* @param shutdownMode
* @return NsmErrorStatus_Ok on success
*/
-NsmErrorStatus_e CAmNodeStateCommunicator::nsmUnRegisterShutdownClient(const uint32_t shutdownMode)
+NsmErrorStatus_e CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient(const uint32_t shutdownMode)
{
DBusError error;
DBusMessageIter iter;
@@ -318,26 +317,26 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmUnRegisterShutdownClient(const uin
if (!message)
{
- logError( "CAmNodeStateCommunicator::nsmUnRegisterShutdownClient dbus error:", error.message);
+ logError( "CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient dbus error:", error.message);
return (NsmErrorStatus_Dbus);
}
dbus_message_iter_init_append(message, &iter);
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &service))
{
- logError( "CAmNodeStateCommunicator::nsmUnRegisterShutdownClient no more memory");
+ logError( "CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient no more memory");
return (NsmErrorStatus_Dbus);
}
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &charPath))
{
- logError( "CAmNodeStateCommunicator::nsmUnRegisterShutdownClient no more memory");
+ logError( "CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient no more memory");
return (NsmErrorStatus_Dbus);
}
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &shutdownMode))
{
- logError( "CAmNodeStateCommunicator::nsmUnRegisterShutdownClient no more memory");
+ logError( "CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient no more memory");
return (NsmErrorStatus_Dbus);
}
@@ -346,13 +345,13 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmUnRegisterShutdownClient(const uin
if (!reply)
{
- logError( "CAmNodeStateCommunicator::nsmUnRegisterShutdownClient failed, dbus error", error.message);
+ logError( "CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient failed, dbus error", error.message);
return (NsmErrorStatus_Dbus);
}
if(!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &returnError, DBUS_TYPE_INVALID))
{
- logError( "CAmNodeStateCommunicator::nsmUnRegisterShutdownClient failed, dbus error", error.message);
+ logError( "CAmNodeStateCommunicatorDBus::nsmUnRegisterShutdownClient failed, dbus error", error.message);
return (NsmErrorStatus_Dbus);
}
dbus_message_unref(reply);
@@ -365,7 +364,7 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmUnRegisterShutdownClient(const uin
* @param version
* @return E_OK on success
*/
-am_Error_e CAmNodeStateCommunicator::nsmGetInterfaceVersion(uint32_t& version)
+am_Error_e CAmNodeStateCommunicatorDBus::nsmGetInterfaceVersion(uint32_t& version)
{
DBusError error;
dbus_error_init(&error);
@@ -374,7 +373,7 @@ am_Error_e CAmNodeStateCommunicator::nsmGetInterfaceVersion(uint32_t& version)
if (!message)
{
- logError("CAmNodeStateCommunicator::nsmGetInterfaceVersion dbus error:", error.message);
+ logError("CAmNodeStateCommunicatorDBus::nsmGetInterfaceVersion dbus error:", error.message);
return (E_UNKNOWN);
}
@@ -384,13 +383,13 @@ am_Error_e CAmNodeStateCommunicator::nsmGetInterfaceVersion(uint32_t& version)
if (!reply)
{
- logError("CAmNodeStateCommunicator::nsmGetInterfaceVersion failed, dbus error", error.message);
+ logError("CAmNodeStateCommunicatorDBus::nsmGetInterfaceVersion failed, dbus error", error.message);
return (E_UNKNOWN);
}
if(!dbus_message_get_args(reply, &error, DBUS_TYPE_UINT32, &version, DBUS_TYPE_INVALID))
{
- logError("CAmNodeStateCommunicator::nsmGetInterfaceVersion failed, dbus error", error.message);
+ logError("CAmNodeStateCommunicatorDBus::nsmGetInterfaceVersion failed, dbus error", error.message);
return (E_UNKNOWN);
}
@@ -405,7 +404,7 @@ am_Error_e CAmNodeStateCommunicator::nsmGetInterfaceVersion(uint32_t& version)
* @param status
* @return NsmErrorStatus_Ok on success
*/
-NsmErrorStatus_e CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status)
+NsmErrorStatus_e CAmNodeStateCommunicatorDBus::nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status)
{
DBusError error;
DBusMessageIter iter;
@@ -415,20 +414,20 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete(const
if (!message)
{
- logError( "CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete dbus error:", error.message);
+ logError( "CAmNodeStateCommunicatorDBus::nsmSendLifecycleRequestComplete dbus error:", error.message);
return (NsmErrorStatus_Dbus);
}
dbus_message_iter_init_append(message, &iter);
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &RequestId))
{
- logError( "CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete no more memory");
+ logError( "CAmNodeStateCommunicatorDBus::nsmSendLifecycleRequestComplete no more memory");
return (NsmErrorStatus_Dbus);
}
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32,&status))
{
- logError( "CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete no more memory");
+ logError( "CAmNodeStateCommunicatorDBus::nsmSendLifecycleRequestComplete no more memory");
return (NsmErrorStatus_Dbus);
}
@@ -437,13 +436,13 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete(const
if (!reply)
{
- logError( "CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete failed, dbus error", error.message);
+ logError( "CAmNodeStateCommunicatorDBus::nsmSendLifecycleRequestComplete failed, dbus error", error.message);
return (NsmErrorStatus_Dbus);
}
if(!dbus_message_get_args(reply, &error,DBUS_TYPE_INT32, &returnError, DBUS_TYPE_INVALID))
{
- logError( "CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete failed, dbus error", error.message);
+ logError( "CAmNodeStateCommunicatorDBus::nsmSendLifecycleRequestComplete failed, dbus error", error.message);
return (NsmErrorStatus_Dbus);
}
dbus_message_unref(reply);
@@ -451,20 +450,14 @@ NsmErrorStatus_e CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete(const
return (static_cast<NsmErrorStatus_e>(returnError));
}
-void CAmNodeStateCommunicator::registerControlSender(CAmControlSender* iControlSender)
-{
- assert(iControlSender);
- mpControlSender=iControlSender;
-}
-
-DBusHandlerResult CAmNodeStateCommunicator::receiveCallback(DBusConnection* conn, DBusMessage* msg, void* user_data)
+DBusHandlerResult CAmNodeStateCommunicatorDBus::receiveCallback(DBusConnection* conn, DBusMessage* msg, void* user_data)
{
- CAmNodeStateCommunicator* instance = static_cast<CAmNodeStateCommunicator*>(user_data);
+ CAmNodeStateCommunicatorDBus* instance = static_cast<CAmNodeStateCommunicatorDBus*>(user_data);
assert(instance);
return (instance->receiveCallbackDelegate(conn,msg));
}
-DBusHandlerResult CAmNodeStateCommunicator::receiveCallbackDelegate(DBusConnection* conn, DBusMessage* msg)
+DBusHandlerResult CAmNodeStateCommunicatorDBus::receiveCallbackDelegate(DBusConnection* conn, DBusMessage* msg)
{
if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
{
@@ -482,7 +475,7 @@ DBusHandlerResult CAmNodeStateCommunicator::receiveCallbackDelegate(DBusConnecti
DBusMessageIter iter,replyIter;
if (!dbus_message_iter_init(msg, &iter))
{
- logError("CAmNodeStateCommunicator::receiveCallbackDelegate DBus Message has no arguments!");
+ logError("CAmNodeStateCommunicatorDBus::receiveCallbackDelegate DBus Message has no arguments!");
returnMessage = dbus_message_new_error(msg,DBUS_ERROR_INVALID_ARGS, "DBUS Message has no arguments!");
sendMessage(returnMessage,msg);
return (DBUS_HANDLER_RESULT_HANDLED);
@@ -490,7 +483,7 @@ DBusHandlerResult CAmNodeStateCommunicator::receiveCallbackDelegate(DBusConnecti
if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_UINT32)
{
- logError("CAmNodeStateCommunicator::receiveCallbackDelegate DBus Message has invalid arguments!");
+ logError("CAmNodeStateCommunicatorDBus::receiveCallbackDelegate DBus Message has invalid arguments!");
returnMessage = dbus_message_new_error(msg,DBUS_ERROR_INVALID_ARGS,"DBus argument is not uint32_t!");
sendMessage(returnMessage,msg);
return (DBUS_HANDLER_RESULT_HANDLED);
@@ -501,7 +494,7 @@ DBusHandlerResult CAmNodeStateCommunicator::receiveCallbackDelegate(DBusConnecti
if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_UINT32)
{
- logError("CAmNodeStateCommunicator::receiveCallbackDelegate DBus Message has invalid arguments!");
+ logError("CAmNodeStateCommunicatorDBus::receiveCallbackDelegate DBus Message has invalid arguments!");
returnMessage = dbus_message_new_error(msg,DBUS_ERROR_INVALID_ARGS,"DBus argument is not uint32_t!");
sendMessage(returnMessage,msg);
return (DBUS_HANDLER_RESULT_HANDLED);
@@ -516,7 +509,7 @@ DBusHandlerResult CAmNodeStateCommunicator::receiveCallbackDelegate(DBusConnecti
if (returnMessage == NULL)
{
- logError("CAmNodeStateCommunicator::receiveCallbackDelegate Cannot allocate DBus message!");
+ logError("CAmNodeStateCommunicatorDBus::receiveCallbackDelegate Cannot allocate DBus message!");
returnMessage = dbus_message_new_error(msg,DBUS_ERROR_NO_MEMORY,"Cannot create reply!");
sendMessage(returnMessage,msg);
return (DBUS_HANDLER_RESULT_HANDLED);
@@ -526,7 +519,7 @@ DBusHandlerResult CAmNodeStateCommunicator::receiveCallbackDelegate(DBusConnecti
if (!dbus_message_iter_append_basic(&replyIter, DBUS_TYPE_INT32, &returnError))
{
- logError("CAmNodeStateCommunicator::receiveCallbackDelegate Cannot allocate DBus message!");
+ logError("CAmNodeStateCommunicatorDBus::receiveCallbackDelegate Cannot allocate DBus message!");
returnMessage = dbus_message_new_error(msg,DBUS_ERROR_NO_MEMORY,"Cannot create reply!");
}
sendMessage(returnMessage,msg);
@@ -536,7 +529,7 @@ DBusHandlerResult CAmNodeStateCommunicator::receiveCallbackDelegate(DBusConnecti
return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
}
-void CAmNodeStateCommunicator::sendIntrospection(DBusConnection* conn, DBusMessage* msg)
+void CAmNodeStateCommunicatorDBus::sendIntrospection(DBusConnection* conn, DBusMessage* msg)
{
assert(conn != NULL);
assert(msg != NULL);
@@ -562,13 +555,13 @@ void CAmNodeStateCommunicator::sendIntrospection(DBusConnection* conn, DBusMessa
dbus_message_iter_init_append(reply, &args);
if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &string))
{
- logError( "CAmNodeStateCommunicator::sendIntrospection DBUS handler Out Of Memory!");
+ logError( "CAmNodeStateCommunicatorDBus::sendIntrospection DBUS handler Out Of Memory!");
}
// send the reply && flush the connection
if (!dbus_connection_send(conn, reply, &serial))
{
- logError( "CAmNodeStateCommunicator::sendIntrospection DBUS handler Out Of Memory!");
+ logError( "CAmNodeStateCommunicatorDBus::sendIntrospection DBUS handler Out Of Memory!");
}
dbus_connection_flush(conn);
@@ -576,22 +569,22 @@ void CAmNodeStateCommunicator::sendIntrospection(DBusConnection* conn, DBusMessa
dbus_message_unref(reply);
}
-void CAmNodeStateCommunicator::sendMessage(DBusMessage* message, DBusMessage* origMessage)
+void CAmNodeStateCommunicatorDBus::sendMessage(DBusMessage* message, DBusMessage* origMessage)
{
dbus_uint32_t serial = dbus_message_get_serial(origMessage);
if(!dbus_connection_send(mpDBusConnection, message, &serial))
{
- logError( "CAmNodeStateCommunicator::sendMessage DBUS handler Out Of Memory!");
+ logError( "CAmNodeStateCommunicatorDBus::sendMessage DBUS handler Out Of Memory!");
}
dbus_connection_flush(mpDBusConnection);
dbus_message_unref(message);
}
-DBusHandlerResult CAmNodeStateCommunicator::signalCallback(DBusConnection* conn, DBusMessage* msg, void* user_data)
+DBusHandlerResult CAmNodeStateCommunicatorDBus::signalCallback(DBusConnection* conn, DBusMessage* msg, void* user_data)
{
(void) conn;
- CAmNodeStateCommunicator* instance(static_cast<CAmNodeStateCommunicator*>(user_data));
+ CAmNodeStateCommunicatorDBus* instance(static_cast<CAmNodeStateCommunicatorDBus*>(user_data));
const char* iface = dbus_message_get_interface(msg);
if (iface==NULL)
@@ -607,19 +600,19 @@ DBusHandlerResult CAmNodeStateCommunicator::signalCallback(DBusConnection* conn,
DBusMessageIter iter;
if (!dbus_message_iter_init(msg, &iter))
{
- logError("CAmNodeStateCommunicator::signalCallback NodeState DBus Message has no arguments!");
+ logError("CAmNodeStateCommunicatorDBus::signalCallback NodeState DBus Message has no arguments!");
return (DBUS_HANDLER_RESULT_HANDLED);
}
if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_INT32)
{
- logError("CAmNodeStateCommunicator::signalCallback NodeState DBus Message has invalid arguments!");
+ logError("CAmNodeStateCommunicatorDBus::signalCallback NodeState DBus Message has invalid arguments!");
return (DBUS_HANDLER_RESULT_HANDLED);
}
dbus_message_iter_get_basic(&iter, &nodeState);
- logInfo("CAmNodeStateCommunicator::signalCallback got signal NodeState, with nodeState",nodeState);
+ logInfo("CAmNodeStateCommunicatorDBus::signalCallback got signal NodeState, with nodeState",nodeState);
assert(instance->mpControlSender);
instance->mpControlSender->hookSystemNodeStateChanged(static_cast<NsmNodeState_e>(nodeState));
@@ -632,19 +625,19 @@ DBusHandlerResult CAmNodeStateCommunicator::signalCallback(DBusConnection* conn,
DBusMessageIter iter;
if (!dbus_message_iter_init(msg, &iter))
{
- logError("CAmNodeStateCommunicator::signalCallback nodeApplicationMode DBus Message has no arguments!");
+ logError("CAmNodeStateCommunicatorDBus::signalCallback nodeApplicationMode DBus Message has no arguments!");
return (DBUS_HANDLER_RESULT_HANDLED);
}
if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_INT32)
{
- logError("CAmNodeStateCommunicator::signalCallback nodeApplicationMode DBus Message has invalid arguments!");
+ logError("CAmNodeStateCommunicatorDBus::signalCallback nodeApplicationMode DBus Message has invalid arguments!");
return (DBUS_HANDLER_RESULT_HANDLED);
}
dbus_message_iter_get_basic(&iter, &nodeApplicationMode);
- logInfo("CAmNodeStateCommunicator::signalCallback got signal nodeApplicationMode, with applicationMode",nodeApplicationMode);
+ logInfo("CAmNodeStateCommunicatorDBus::signalCallback got signal nodeApplicationMode, with applicationMode",nodeApplicationMode);
assert(instance->mpControlSender);
instance->mpControlSender->hookSystemNodeApplicationModeChanged(static_cast<NsmApplicationMode_e>(nodeApplicationMode));
@@ -659,13 +652,13 @@ DBusHandlerResult CAmNodeStateCommunicator::signalCallback(DBusConnection* conn,
DBusMessageIter iter;
if (!dbus_message_iter_init(msg, &iter))
{
- logError("CAmNodeStateCommunicator::signalCallback nodeApplicationMode DBus Message has no arguments!");
+ logError("CAmNodeStateCommunicatorDBus::signalCallback nodeApplicationMode DBus Message has no arguments!");
return (DBUS_HANDLER_RESULT_HANDLED);
}
if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_STRING)
{
- logError("CAmNodeStateCommunicator::signalCallback nodeApplicationMode DBus Message has invalid arguments!");
+ logError("CAmNodeStateCommunicatorDBus::signalCallback nodeApplicationMode DBus Message has invalid arguments!");
return (DBUS_HANDLER_RESULT_HANDLED);
}
@@ -676,7 +669,7 @@ DBusHandlerResult CAmNodeStateCommunicator::signalCallback(DBusConnection* conn,
if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_INT32)
{
- logError("CAmNodeStateCommunicator::signalCallback nodeApplicationMode DBus Message has invalid arguments!");
+ logError("CAmNodeStateCommunicatorDBus::signalCallback nodeApplicationMode DBus Message has invalid arguments!");
return (DBUS_HANDLER_RESULT_HANDLED);
}
@@ -685,14 +678,14 @@ DBusHandlerResult CAmNodeStateCommunicator::signalCallback(DBusConnection* conn,
if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_INT32)
{
- logError("CAmNodeStateCommunicator::signalCallback nodeApplicationMode DBus Message has invalid arguments!");
+ logError("CAmNodeStateCommunicatorDBus::signalCallback nodeApplicationMode DBus Message has invalid arguments!");
return (DBUS_HANDLER_RESULT_HANDLED);
}
dbus_message_iter_get_basic(&iter, &sessionState);
- logInfo("CAmNodeStateCommunicator::signalCallback got signal sessionStateChanged, with session",sessionName,"seatID=",seatID,"sessionState",sessionState);
+ logInfo("CAmNodeStateCommunicatorDBus::signalCallback got signal sessionStateChanged, with session",sessionName,"seatID=",seatID,"sessionState",sessionState);
assert(instance->mpControlSender);
instance->mpControlSender->hookSystemSessionStateChanged(sessionName,seatID,sessionState);
@@ -708,7 +701,7 @@ DBusHandlerResult CAmNodeStateCommunicator::signalCallback(DBusConnection* conn,
return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
}
-am_Error_e CAmNodeStateCommunicator::readIntegerProperty(const std::string property, int32_t& value)
+am_Error_e CAmNodeStateCommunicatorDBus::readIntegerProperty(const std::string property, int32_t& value)
{
DBusError error;
dbus_error_init(&error);
@@ -718,7 +711,7 @@ am_Error_e CAmNodeStateCommunicator::readIntegerProperty(const std::string prope
if (!message)
{
- logError("CAmNodeStateCommunicator::readIntegerProperty dbus error:", error.message);
+ logError("CAmNodeStateCommunicatorDBus::readIntegerProperty dbus error:", error.message);
dbus_message_unref(message);
return (E_UNKNOWN);
}
@@ -729,14 +722,14 @@ am_Error_e CAmNodeStateCommunicator::readIntegerProperty(const std::string prope
const char *propertyChar=property.c_str();
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &interface))
{
- logError("CAmNodeStateCommunicator::readIntegerProperty append error");
+ logError("CAmNodeStateCommunicatorDBus::readIntegerProperty append error");
dbus_message_unref(message);
return (E_UNKNOWN);
}
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &propertyChar))
{
- logError("CAmNodeStateCommunicator::readIntegerProperty append error");
+ logError("CAmNodeStateCommunicatorDBus::readIntegerProperty append error");
dbus_message_unref(message);
return (E_UNKNOWN);
}
@@ -744,21 +737,21 @@ am_Error_e CAmNodeStateCommunicator::readIntegerProperty(const std::string prope
DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error));
if (!reply)
{
- logError("CAmNodeStateCommunicator::readIntegerProperty failed, dbus error", error.message);
+ logError("CAmNodeStateCommunicatorDBus::readIntegerProperty failed, dbus error", error.message);
dbus_message_unref(message);
return (E_UNKNOWN);
}
if(!dbus_message_iter_init(reply,&iterVariant))
{
- logError("CAmNodeStateCommunicator::readIntegerProperty failed, dbus error", error.message);
+ logError("CAmNodeStateCommunicatorDBus::readIntegerProperty failed, dbus error", error.message);
dbus_message_unref(message);
dbus_message_unref(reply);
return (E_UNKNOWN);
}
if (dbus_message_iter_get_arg_type (&iterVariant)!= DBUS_TYPE_VARIANT)
{
- logError("CAmNodeStateCommunicator::readIntegerProperty failed, dbus return type wrong");
+ logError("CAmNodeStateCommunicatorDBus::readIntegerProperty failed, dbus return type wrong");
dbus_message_unref(reply);
dbus_message_unref(message);
return (E_UNKNOWN);
@@ -767,7 +760,7 @@ am_Error_e CAmNodeStateCommunicator::readIntegerProperty(const std::string prope
dbus_message_iter_recurse (&iterVariant, &subiter);
if (dbus_message_iter_get_arg_type (&subiter)!= DBUS_TYPE_INT32)
{
- logError("CAmNodeStateCommunicator::readIntegerProperty failed, dbus return type wrong");
+ logError("CAmNodeStateCommunicatorDBus::readIntegerProperty failed, dbus return type wrong");
dbus_message_unref(reply);
dbus_message_unref(message);
return (E_UNKNOWN);
diff --git a/AudioManagerDaemon/src/CAmRoutingReceiver.cpp b/AudioManagerDaemon/src/CAmRoutingReceiver.cpp
index 116ee1a..a6c769f 100644
--- a/AudioManagerDaemon/src/CAmRoutingReceiver.cpp
+++ b/AudioManagerDaemon/src/CAmRoutingReceiver.cpp
@@ -328,12 +328,14 @@ am_Error_e CAmRoutingReceiver::peekSourceClassID(const std::string& name, am_sou
return (mpDatabaseHandler->peekSourceClassID(name, sourceClassID));
}
+#ifdef WITH_DBUS_WRAPPER
am_Error_e CAmRoutingReceiver::getDBusConnectionWrapper(CAmDbusWrapper *& dbusConnectionWrapper) const
{
-#ifdef WITH_DBUS_WRAPPER
dbusConnectionWrapper = mpDBusWrapper;
return (E_OK);
#else
+am_Error_e CAmRoutingReceiver::getDBusConnectionWrapper(CAmDbusWrapper *& ) const
+{
return (E_UNKNOWN);
#endif
}
diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp
index 9bcc57c..c6d212e 100755
--- a/AudioManagerDaemon/src/main.cpp
+++ b/AudioManagerDaemon/src/main.cpp
@@ -32,11 +32,21 @@
#ifdef WITH_TELNET
#include "CAmTelnetServer.h"
#endif
-#ifdef WITH_DBUS_WRAPPER
- #include "shared/CAmDbusWrapper.h"
+
+#ifdef WITH_CAPI_WRAPPER
+ #include "shared/CAmCommonAPIWrapper.h"
+#else
+ #ifdef WITH_DBUS_WRAPPER
+ #include "shared/CAmDbusWrapper.h"
+ #endif
#endif
+
#ifdef WITH_NSM
- #include "CAmNodeStateCommunicator.h"
+ #ifdef WITH_DBUS_WRAPPER
+ #include "CAmNodeStateCommunicatorDBus.h"
+ #else
+ #include "CAmNodeStateCommunicatorCAPI.h"
+ #endif
#endif
#ifdef WITH_DATABASE_STORAGE
@@ -72,6 +82,7 @@
#include "shared/CAmDltWrapper.h"
#include "shared/CAmSocketHandler.h"
+
using namespace am;
DLT_DECLARE_CONTEXT(AudioManager)
@@ -309,10 +320,19 @@ void mainProgram()
//Instantiate all classes. Keep in same order !
CAmSocketHandler iSocketHandler;
+#ifdef WITH_CAPI_WRAPPER
+ //We instantiate a singleton with the current socket handler, which loads the common-api runtime.
+ CAmCommonAPIWrapper *pCAPIWrapper = CAmCommonAPIWrapper::instantiateOnce(&iSocketHandler);
+ CAmCommonAPIWrapper iDBusWrapper = *pCAPIWrapper;
+#ifdef WITH_NSM
+ CAmNodeStateCommunicatorCAPI iNodeStateCommunicator(&iDBusWrapper);
+#endif /*WITH_NSM*/
+#endif /*WITH_CAPI_WRAPPER */
+
#ifdef WITH_DBUS_WRAPPER
CAmDbusWrapper iDBusWrapper(&iSocketHandler,dbusWrapperType);
#ifdef WITH_NSM
- CAmNodeStateCommunicator iNodeStateCommunicator(&iDBusWrapper);
+ CAmNodeStateCommunicatorDBus iNodeStateCommunicator(&iDBusWrapper);
#endif /*WITH_NSM*/
#endif /*WITH_DBUS_WRAPPER */
@@ -335,18 +355,17 @@ void mainProgram()
#ifdef WITH_DBUS_WRAPPER
CAmCommandReceiver iCommandReceiver(pDatabaseHandler, &iControlSender, &iSocketHandler, &iDBusWrapper);
CAmRoutingReceiver iRoutingReceiver(pDatabaseHandler, &iRoutingSender, &iControlSender, &iSocketHandler, &iDBusWrapper);
-#ifdef WITH_NSM
- CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter, &iNodeStateCommunicator);
- iNodeStateCommunicator.registerControlSender(&iControlSender);
-#else /*WITH_NSM*/
- CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter);
-#endif /*WITH_NSM*/
#else /*WITH_DBUS_WRAPPER*/
- CAmCommandReceiver iCommandReceiver(pDatabaseHandler,&iControlSender,&iSocketHandler);
- CAmRoutingReceiver iRoutingReceiver(pDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler);
- CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter);
+ CAmCommandReceiver iCommandReceiver(pDatabaseHandler,&iControlSender,&iSocketHandler);
+ CAmRoutingReceiver iRoutingReceiver(pDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler);
#endif /*WITH_DBUS_WRAPPER*/
+#ifdef WITH_NSM
+ CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter, &iNodeStateCommunicator);
+ iNodeStateCommunicator.registerControlSender(&iControlSender);
+#else /*WITH_NSM*/
+ CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter);
+#endif /*WITH_NSM*/
#ifdef WITH_TELNET
CAmTelnetServer iTelnetServer(&iSocketHandler, &iCommandSender, &iCommandReceiver, &iRoutingSender, &iRoutingReceiver, &iControlSender, &iControlReceiver, pDatabaseHandler, &iRouter, telnetport, maxConnections);