new control dbus plugin 58/16258/1
authorJaska Uimonen <jaska.uimonen@helsinki.fi>
Mon, 11 Nov 2013 10:46:26 +0000 (12:46 +0200)
committerJaska Uimonen <jaska.uimonen@helsinki.fi>
Wed, 12 Feb 2014 08:22:20 +0000 (10:22 +0200)
Change-Id: I00efd30b39256988910bb3a48c4f6d6756432955

21 files changed:
AudioManagerDaemon/include/CAmControlReceiver.h
AudioManagerDaemon/src/CAmControlReceiver.cpp
AudioManagerDaemon/src/main.cpp
CMakeLists.txt
PluginCommandInterfaceDbus/include/configCommandDbus.h
PluginControlInterfaceDbus/CMakeLists.txt [new file with mode: 0644]
PluginControlInterfaceDbus/cmake/config.cmake [new file with mode: 0644]
PluginControlInterfaceDbus/include/CAmControlDbusMessageHandler.h [new file with mode: 0644]
PluginControlInterfaceDbus/include/CAmControlDbusSend.h [new file with mode: 0644]
PluginControlInterfaceDbus/include/CAmControlSenderBase.h [new file with mode: 0644]
PluginControlInterfaceDbus/include/ControlReceiver.xml [new file with mode: 0644]
PluginControlInterfaceDbus/include/IAmControlReceiverDbusShadow.h [new file with mode: 0644]
PluginControlInterfaceDbus/include/configControlDbus.h [new file with mode: 0644]
PluginControlInterfaceDbus/src/CAmControlDbusMessageHandler.cpp [new file with mode: 0644]
PluginControlInterfaceDbus/src/CAmControlDbusSend.cpp [new file with mode: 0644]
PluginControlInterfaceDbus/src/CAmControlSenderBase.cpp [new file with mode: 0644]
PluginControlInterfaceDbus/src/IAmControlReceiverShadow.cpp [new file with mode: 0644]
PluginRoutingInterfaceDbus/include/configRoutingDbus.h
PluginRoutingInterfaceDbus/src/IAmRoutingReceiverShadow.cpp
include/control/IAmControlReceive.h
packaging/genivi-audio-manager.spec

index 11e295d..da7f065 100644 (file)
@@ -33,6 +33,7 @@ class CAmRoutingSender;
 class CAmCommandSender;
 class CAmRouter;
 class CAmNodeStateCommunicator;
+class CAmDbusWrapper;
 
 /**
  * This class is used to receive all commands from the control interface
@@ -42,6 +43,7 @@ class CAmControlReceiver: public IAmControlReceive
 public:
     CAmControlReceiver(CAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter, CAmNodeStateCommunicator* iNodeStateCommunicator);
     CAmControlReceiver(CAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter);
+    CAmControlReceiver(CAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter, CAmDbusWrapper *iDBusWrapper);
     ~CAmControlReceiver();
     am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s>& returnList);
     am_Error_e connect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID);
@@ -136,12 +138,15 @@ public:
     am_Error_e getInterfaceVersionNSM(uint32_t& version) ;
     NsmErrorStatus_e sendLifecycleRequestCompleteNSM(const uint32_t RequestId, const NsmErrorStatus_e status) ;
 
+    am_Error_e getDBusConnectionWrapper(CAmDbusWrapper*& dbusConnectionWrapper) const;
+
 private:
     CAmDatabaseHandler* mDatabaseHandler; //!< pointer tto the databasehandler
     CAmRoutingSender* mRoutingSender; //!< pointer to the routing send interface.
     CAmCommandSender* mCommandSender; //!< pointer to the command send interface
     CAmSocketHandler* mSocketHandler; //!< pointer to the socketHandler
     CAmRouter* mRouter; //!< pointer to the Router
+    CAmDbusWrapper* mDBusWrapper;
     CAmNodeStateCommunicator* mNodeStateCommunicator;
 };
 
index 2867305..d3f6a46 100644 (file)
@@ -44,6 +44,7 @@ CAmControlReceiver::CAmControlReceiver(CAmDatabaseHandler *iDatabaseHandler, CAm
         mCommandSender(iCommandSender), //
         mSocketHandler(iSocketHandler), //
         mRouter(iRouter), //
+        mDBusWrapper(NULL),
         mNodeStateCommunicator(iNodeStateCommunicator)
 {
     assert(mDatabaseHandler!=NULL);
@@ -60,6 +61,7 @@ CAmControlReceiver::CAmControlReceiver(CAmDatabaseHandler *iDatabaseHandler, CAm
         mCommandSender(iCommandSender), //
         mSocketHandler(iSocketHandler), //
         mRouter(iRouter), //
+        mDBusWrapper(NULL),
         mNodeStateCommunicator(NULL)
 {
     assert(mDatabaseHandler!=NULL);
@@ -69,6 +71,23 @@ CAmControlReceiver::CAmControlReceiver(CAmDatabaseHandler *iDatabaseHandler, CAm
     assert(mRouter!=NULL);
 }
 
+CAmControlReceiver::CAmControlReceiver(CAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter, CAmDbusWrapper *iDBusWrapper) :
+        mDatabaseHandler(iDatabaseHandler), //
+        mRoutingSender(iRoutingSender), //
+        mCommandSender(iCommandSender), //
+        mSocketHandler(iSocketHandler), //
+        mRouter(iRouter), //
+        mDBusWrapper(iDBusWrapper),
+        mNodeStateCommunicator(NULL)
+{
+    assert(mDatabaseHandler!=NULL);
+    assert(mRoutingSender!=NULL);
+    assert(mCommandSender!=NULL);
+    assert(mSocketHandler!=NULL);
+    assert(mRouter!=NULL);
+    assert(mDBusWrapper!=NULL);
+}
+
 CAmControlReceiver::~CAmControlReceiver()
 {
 }
@@ -736,5 +755,15 @@ NsmErrorStatus_e CAmControlReceiver::sendLifecycleRequestCompleteNSM(const uint3
 
 }
 
+am_Error_e CAmControlReceiver::getDBusConnectionWrapper(CAmDbusWrapper *& dbusConnectionWrapper) const
+{
+#ifdef WITH_DBUS_WRAPPER
+    dbusConnectionWrapper = mDBusWrapper;
+    return (E_OK);
+#else
+    return (E_UNKNOWN);
+#endif
+}
+
 }
 
index de10b73..51bbbfc 100755 (executable)
@@ -326,7 +326,8 @@ void mainProgram()
     CAmControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter, &iNodeStateCommunicator);
     iNodeStateCommunicator.registerControlSender(&iControlSender);
 #else /*WITH_NSM*/
-    CAmControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter);
+    // CAmControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter);
+    CAmControlReceiver iControlReceiver(&iDatabaseHandler, &iRoutingSender, &iCommandSender, &iSocketHandler, &iRouter, &iDBusWrapper);
 #endif /*WITH_NSM*/
 #else /*WITH_DBUS_WRAPPER*/
     CAmCommandReceiver iCommandReceiver(&iDatabaseHandler,&iControlSender,&iSocketHandler);
index 2b5df6b..047809d 100755 (executable)
@@ -129,7 +129,7 @@ if(USE_BUILD_LIBS)
                SET(DEFAULT_PLUGIN_ROUTING_DIR "${PLUGINS_OUTPUT_PATH}/routing")
        ENDIF(NOT DEFINED DEFAULT_PLUGIN_ROUTING_DIR)           
        IF(NOT DEFINED CONTROLLER_PLUGIN)
-               SET(CONTROLLER_PLUGIN "${PLUGINS_OUTPUT_PATH}/control/libPluginControlInterface.so")
+               SET(CONTROLLER_PLUGIN "${PLUGINS_OUTPUT_PATH}/control/libPluginControlInterfaceDbus.so")
        ENDIF(NOT DEFINED CONTROLLER_PLUGIN)
 else(USE_BUILD_LIBS)
        IF(NOT DEFINED DEFAULT_PLUGIN_COMMAND_DIR)
@@ -139,7 +139,7 @@ else(USE_BUILD_LIBS)
                SET(DEFAULT_PLUGIN_ROUTING_DIR "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/routing")
        ENDIF(NOT DEFINED DEFAULT_PLUGIN_ROUTING_DIR)
        IF(NOT DEFINED CONTROLLER_PLUGIN)
-               SET(CONTROLLER_PLUGIN "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/control/libPluginControlInterface.so")
+               SET(CONTROLLER_PLUGIN "${CMAKE_INSTALL_PREFIX}/lib/${LIB_INSTALL_SUFFIX}/control/libPluginControlInterfaceDbus.so")
        ENDIF(NOT DEFINED CONTROLLER_PLUGIN)
 endif(USE_BUILD_LIBS)
 
@@ -193,6 +193,7 @@ endif(WITH_PLUGIN_ROUTING)
 
 if(WITH_PLUGIN_CONTROL)
        add_subdirectory (PluginControlInterface)
+       add_subdirectory (PluginControlInterfaceDbus)
 endif(WITH_PLUGIN_CONTROL)
 
 add_subdirectory (AudioManagerDaemon)
index 369beea..e87d6ca 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _COMMANDDBUS_CONFIG_H
 #define _COMMANDDBUS_CONFIG_H
 
-#define COMMAND_DBUS_INTROSPECTION_FILE "/home/christian/workspace/AudioManager/bin/CommandInterface.xml"
-#define LIBRARY_OUTPUT_PATH "/home/christian/workspace/AudioManager/bin/plugins/command"
+#define COMMAND_DBUS_INTROSPECTION_FILE "/usr/share/audiomanager/CommandInterface.xml"
+#define LIBRARY_OUTPUT_PATH "/home/juimonen/work/upstream_pulse/genivi-audio-manager/bin/plugins/command"
 
 #endif /* _COMMANDDBUS_CONFIG_H */
diff --git a/PluginControlInterfaceDbus/CMakeLists.txt b/PluginControlInterfaceDbus/CMakeLists.txt
new file mode 100644 (file)
index 0000000..2169737
--- /dev/null
@@ -0,0 +1,92 @@
+# Copyright (c) 2012 BMW
+#
+# author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
+#
+# 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.
+#
+# For further information see http://www.genivi.org/.
+#
+
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(PluginControlInterfaceDbus)
+
+OPTION (WITH_CONTROL_INTERFACE_DBUS 
+        "Build with control interface dbus plugin" ON)
+
+IF (WITH_CONTROL_INTERFACE_DBUS)
+
+set(LIBRARY_OUTPUT_PATH ${PLUGINS_OUTPUT_PATH}/control)
+set(DOC_OUTPUT_PATH ${DOC_OUTPUT_PATH}/ControlPlugin)
+set(INCLUDE_FOLDER "include")
+
+SET(SHARED_FOLDER "${CMAKE_INSTALL_PREFIX}/share")
+FILE(READ "${AUDIO_INCLUDE_FOLDER}/control/IAmControlSend.h" VERSION_BUFFER LIMIT 6000)
+STRING(REGEX MATCH "ControlSendVersion*.[^0-9]*[0-9].[0-9]*[0-9]" LIB_INTERFACE_VERSION_STRING ${VERSION_BUFFER})
+STRING(REGEX REPLACE "ControlSendVersion*.." "" LIB_INTERFACE_VERSION ${LIB_INTERFACE_VERSION_STRING})
+MESSAGE(STATUS "Building against control interface version ${LIB_INTERFACE_VERSION}")
+
+IF(USE_BUILD_LIBS) 
+    SET(CONTROL_DBUS_INTROSPECTION_FOLDER ${EXECUTABLE_OUTPUT_PATH})
+    SET(CONTROL_DBUS_INTROSPECTION_FILE ${EXECUTABLE_OUTPUT_PATH}/ControlReceiver.xml)
+ELSE(USE_BUILD_LIBS) 
+    SET(CONTROL_DBUS_INTROSPECTION_FOLDER ${SHARED_FOLDER}/audiomanager)
+    SET(CONTROL_DBUS_INTROSPECTION_FILE ${SHARED_FOLDER}/audiomanager/ControlReceiver.xml)
+ENDIF(USE_BUILD_LIBS)
+
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake ${CMAKE_CURRENT_SOURCE_DIR}/include/configControlDbus.h )
+
+FIND_PACKAGE(DBUS REQUIRED)
+FIND_PACKAGE(NSM REQUIRED)
+
+INCLUDE_DIRECTORIES(
+       ${CMAKE_SOURCE_DIR} 
+       ${CMAKE_CURRENT_BINARY_DIR}
+       ${DBUS_INCLUDE_DIR}
+       ${DBUS_ARCH_INCLUDE_DIR}
+       ${AUDIO_INCLUDE_FOLDER}
+       ${PROJECT_INCLUDE_FOLDER}
+       ${INCLUDE_FOLDER}
+    ${NSM_INCLUDE_DIR}
+)
+
+# all source files go here
+file(GLOB PLUGIN_CONTROL_DBUS_SRCS_CXX "src/*.cpp")
+
+add_library(PluginControlInterfaceDbus SHARED ${PLUGIN_CONTROL_DBUS_SRCS_CXX})
+
+SET_TARGET_PROPERTIES(PluginControlInterfaceDbus PROPERTIES 
+                                            SOVERSION "${LIB_INTERFACE_VERSION}"
+)
+
+TARGET_LINK_LIBRARIES(PluginControlInterfaceDbus 
+    ${DLT_LIBRARIES}
+    ${DBUS_LIBRARY}
+)
+
+IF(WITH_TESTS)
+       add_subdirectory (test)
+ENDIF(WITH_TESTS)
+
+INSTALL(TARGETS PluginControlInterfaceDbus 
+        DESTINATION "lib/${LIB_INSTALL_SUFFIX}/control"
+        PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
+        COMPONENT sampleplugins
+)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/ControlReceiver.xml 
+        DESTINATION "${CONTROL_DBUS_INTROSPECTION_FOLDER}"
+        COMPONENT sampleplugins
+)
+
+SET(ADD_DEPEND "audiomanager-bin" "libdbus-1-3(>=1.2.16)")
+set_property(GLOBAL APPEND PROPERTY sampleplugins_prop "${ADD_DEPEND}")
+
+ENDIF (WITH_CONTROL_INTERFACE_DBUS)
diff --git a/PluginControlInterfaceDbus/cmake/config.cmake b/PluginControlInterfaceDbus/cmake/config.cmake
new file mode 100644 (file)
index 0000000..8bab95e
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _CONTROLDBUS_CONFIG_H
+#define _CONTROLDBUS_CONFIG_H
+
+#cmakedefine CONTROL_DBUS_INTROSPECTION_FILE "@CONTROL_DBUS_INTROSPECTION_FILE@"
+
+#endif /* _CONTROLDBUS_CONFIG_H */
diff --git a/PluginControlInterfaceDbus/include/CAmControlDbusMessageHandler.h b/PluginControlInterfaceDbus/include/CAmControlDbusMessageHandler.h
new file mode 100644 (file)
index 0000000..f1927bd
--- /dev/null
@@ -0,0 +1,136 @@
+/**
+ *  Copyright (c) copyright 2011-2012 Aricent® Group  and its licensors
+ *  Copyright (c) 2012 BMW
+ *
+ *  \author Sampreeth Ramavana
+ *  \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
+ *
+ *  \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.
+ *
+ *  For further information see http://www.genivi.org/.
+ */
+
+#ifndef _CAMCONTROLDBUSMESSAGEHANDLER_H_
+#define _CAMCONTROLDBUSMESSAGEHANDLER_H_
+
+
+#include <dbus/dbus.h>
+#include <vector>
+#include <sstream>
+#include <string>
+#include <list>
+#include "audiomanagertypes.h"
+
+namespace am {
+
+
+/**
+ * handles DBus Messages, is used to extract & append parameters and send messages
+ */
+class CAmControlDbusMessageHandler
+{
+public:
+    CAmControlDbusMessageHandler();
+    ~CAmControlDbusMessageHandler();
+
+    /**
+     * sets the DBus Connection
+     * @param connection pointer to the DBus Connection
+     */
+    void setDBusConnection(DBusConnection*& connection);
+
+    /**
+     * is called to initiate the receiving of a message
+     * @param msg pointer to the message to be received
+     */
+    void initReceive(DBusMessage* msg);
+
+    /**
+     *  is called to initiate the reply to a message
+     * @param msg pointer to the message the reply is for
+     */
+    void initReply(DBusMessage* msg);
+
+    /**
+     * inits a signal to be sent via dbus
+     * parameters can be added before sending the signal
+     * @param path the path
+     * @param signalName the signal name
+     */
+    void initSignal(std::string path, std::string signalName);
+
+    /**
+     * sends out the message
+     */
+    void sendMessage();
+
+    /**
+     * the get functions return a value from the received dbus message
+     * @return
+     */
+    dbus_uint16_t getUInt();
+    dbus_uint16_t getUInt(DBusMessageIter& iter, bool next);
+    dbus_int16_t getInt();
+    dbus_int16_t getInt(DBusMessageIter& iter, bool next);
+    dbus_bool_t getBool();
+    dbus_bool_t getBool(DBusMessageIter& iter, bool next);
+    char getByte();
+    char getByte(DBusMessageIter& iter, bool next);
+    double getDouble();
+    double getDouble(DBusMessageIter& iter, bool next);
+    char* getString();
+    char* getString(DBusMessageIter& iter, bool next);
+    am::am_Availability_s getAvailability();
+    std::vector<am::am_EarlyData_s> getEarlyData();
+    am_Domain_s getDomainData();
+    am_Source_s getSourceData();
+    am_Sink_s getSinkData();
+    am_Gateway_s getGatewayData();
+    am_Crossfader_s getCrossfaderData();
+    am_MainSoundProperty_s getMainSoundProperty();
+
+    /**
+     * the overloaded append function appends different datatypes to the dbusmessage
+     */
+    void append(dbus_int16_t toAppend);
+    void append(dbus_uint16_t toAppend);
+    void append(dbus_uint32_t toAppend);
+    void append(char toAppend);
+    void append(bool toAppend);
+    void append(double toAppend);
+    void append(const am::am_Error_e error);
+    void append(const am::am_SinkType_s& sinkType);
+    void append(const am::am_SourceType_s& sourceType);
+    void append(const am::am_MainSoundProperty_s mainSoundProperty);
+    void append(const am::am_Availability_s & availability);
+    void append(const am::am_SystemProperty_s & SystemProperty);
+    void append(const std::vector<am::am_MainConnectionType_s>& listMainConnections);
+    void append(const std::vector<am::am_SinkType_s>& listMainSinks);
+    void append(const std::vector<am::am_SourceType_s>& listMainSources);
+    void append(const std::vector<am::am_MainSoundProperty_s>& listMainSoundProperties);
+    void append(const std::vector<am::am_SourceClass_s>& listSourceClasses);
+    void append(const std::vector<am::am_SinkClass_s>& listSinkClasses);
+    void append(const std::vector<am::am_SystemProperty_s>& listSystemProperties);
+
+private:
+
+    DBusMessageIter mDBusMessageIter;
+    DBusError mDBusError;
+    dbus_uint32_t mSerial;
+    std::string mErrorName;
+    std::string mErrorMsg;
+    DBusMessage* mpDBusMessage;
+    DBusMessage* mpReceiveMessage;
+    DBusConnection* mpDBusConnection;
+};
+
+}
+
+#endif // _CAMCONTROLDBUSMESSAGEHANDLER_H_
diff --git a/PluginControlInterfaceDbus/include/CAmControlDbusSend.h b/PluginControlInterfaceDbus/include/CAmControlDbusSend.h
new file mode 100644 (file)
index 0000000..112f921
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+ *  Copyright (c) copyright 2011-2012 Aricent® Group  and its licensors
+ *  Copyright (c) 2012 BMW
+ *
+ *  \author Sampreeth Ramavana
+ *  \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
+ *
+ *  \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.
+ *
+ *  For further information see http://www.genivi.org/.
+ */
+
+#ifndef _CAMCONTROLDBUSSEND_H_
+#define _CAMCONTROLDBUSSEND_H_
+
+#include <dbus/dbus.h>
+#include <string>
+#include <vector>
+#include "audiomanagertypes.h"
+
+namespace am
+{
+
+class CAmControlDbusSend
+{
+public:
+    CAmControlDbusSend(DBusConnection* conn, std::string bus_name, std::string  path, std::string  interface, std::string  method);
+    virtual ~CAmControlDbusSend();
+    void append(std::string string);
+    void append(uint16_t integer);
+    void append(int16_t integer);
+    void append(std::vector<am_SoundProperty_s> listSoundProperties);
+    void append(am_SoundProperty_s soundProperty);
+    am_Error_e send();
+
+private:
+    DBusMessage* mpDbusMessage;
+    DBusConnection* mpDbusConnection;
+    DBusMessageIter mDbusMessageIter;
+    DBusError mDBusError;
+};
+}
+
+#endif /* _CAMCONTROLDBUSSEND_H_ */
diff --git a/PluginControlInterfaceDbus/include/CAmControlSenderBase.h b/PluginControlInterfaceDbus/include/CAmControlSenderBase.h
new file mode 100644 (file)
index 0000000..0335a00
--- /dev/null
@@ -0,0 +1,252 @@
+/**
+ *  Copyright (c) 2012 BMW
+ *
+ *  \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
+ *
+ *  \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.
+ *
+ *  For further information see http://www.genivi.org/.
+ */
+
+#ifndef CONTROLSENDER_H_
+#define CONTROLSENDER_H_
+
+#include "control/IAmControlSend.h"
+#include "IAmControlReceiverDbusShadow.h"
+#include "CAmControlDbusMessageHandler.h"
+#include "shared/CAmDbusWrapper.h"
+
+#include <list>
+
+namespace am
+{
+
+class CAmControlSenderBase: public IAmControlSend
+{
+public:
+    CAmControlSenderBase();
+    virtual ~CAmControlSenderBase();
+    am_Error_e startupController(IAmControlReceive* controlreceiveinterface);
+    void setControllerReady();
+    void setControllerRundown(const int16_t signal);
+    am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID);
+    am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID);
+    am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty);
+    am_Error_e hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty);
+    am_Error_e hookUserSetSystemProperty(const am_SystemProperty_s& property);
+    am_Error_e hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume);
+    am_Error_e hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment);
+    am_Error_e hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState);
+    am_Error_e hookSystemRegisterDomain(const am_Domain_s& domainData, am_domainID_t& domainID);
+    am_Error_e hookSystemDeregisterDomain(const am_domainID_t domainID);
+    void hookSystemDomainRegistrationComplete(const am_domainID_t domainID);
+    am_Error_e hookSystemRegisterSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID);
+    am_Error_e hookSystemDeregisterSink(const am_sinkID_t sinkID);
+    am_Error_e hookSystemRegisterSource(const am_Source_s& sourceData, am_sourceID_t& sourceID);
+    am_Error_e hookSystemDeregisterSource(const am_sourceID_t sourceID);
+    am_Error_e hookSystemRegisterGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID);
+    am_Error_e hookSystemDeregisterGateway(const am_gatewayID_t gatewayID);
+    am_Error_e hookSystemRegisterCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID);
+    am_Error_e hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID);
+    void hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume);
+    void hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume);
+    void hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState);
+    void hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s& availability);
+    void hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s& availability);
+    void hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state);
+    void hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s>& data);
+    void hookSystemSpeedChange(const am_speed_t speed);
+    void hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time);
+    void cbAckConnect(const am_Handle_s handle, const am_Error_e errorID);
+    void cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID);
+    void cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error);
+    void cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error);
+    void cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error);
+    void cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error);
+    void cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error);
+    void cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error);
+    void cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error);
+    void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error);
+    am_Error_e getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector<am_ConnectionFormat_e> listPossibleConnectionFormats, std::vector<am_ConnectionFormat_e>& listPrioConnectionFormats);
+    void getInterfaceVersion(std::string& version) const;
+    void confirmCommandReady(const am_Error_e error) ;
+    void confirmRoutingReady(const am_Error_e error) ;
+    void confirmCommandRundown(const am_Error_e error) ;
+    void confirmRoutingRundown(const am_Error_e error) ;
+    am_Error_e hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) ;
+    am_Error_e hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) ;
+    am_Error_e hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector<am_ConnectionFormat_e>& listSourceConnectionFormats, const std::vector<am_ConnectionFormat_e>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix) ;
+    void cbAckSetVolumes(const am_Handle_s handle, const std::vector<am_Volumes_s>& listVolumes, const am_Error_e error) ;
+    void cbAckSetSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ;
+    void cbAckSetSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ;
+    void hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s& payload) ;
+    void hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s& payload) ;
+    am_Error_e hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration) ;
+    am_Error_e hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration) ;
+    void hookSystemNodeStateChanged(const NsmNodeState_e NodeStateId) ;
+    void hookSystemNodeApplicationModeChanged(const NsmApplicationMode_e ApplicationModeId) ;
+    void hookSystemSessionStateChanged(const std::string& sessionName, const NsmSeat_e seatID, const NsmSessionState_e sessionStateID) ;
+    NsmErrorStatus_e hookSystemLifecycleRequest(const uint32_t Request, const uint32_t RequestId) ;
+
+private:
+
+    void disconnect(am_mainConnectionID_t connectionID);
+    void connect(am_sourceID_t sourceID, am_sinkID_t sinkID, am_mainConnectionID_t mainConnectionID);
+
+    struct handleStatus
+    {
+        bool status;
+        am_Handle_s handle;
+    };
+
+    struct mainConnectionSet
+    {
+        am_mainConnectionID_t connectionID;
+        std::vector<handleStatus> listHandleStaus;
+    };
+
+    struct mainVolumeSet
+    {
+        am_sinkID_t sinkID;
+        am_Handle_s handle;
+        am_mainVolume_t mainVolume;
+    };
+
+    struct mainSinkSoundPropertySet
+    {
+        am_sinkID_t sinkID;
+        am_Handle_s handle;
+        am_MainSoundProperty_s mainSoundProperty;
+    };
+
+    class findHandle
+    {
+        handleStatus mHandle;
+    public:
+        explicit findHandle(handleStatus handle) :
+                mHandle(handle)
+        {
+        }
+        bool operator()(const handleStatus& handle) const
+        {
+            return (handle.handle.handle == mHandle.handle.handle);
+        }
+    };
+
+    struct checkHandle
+    {
+
+        handleStatus mHandleStatus;
+        explicit checkHandle(const handleStatus& value) :
+                mHandleStatus(value)
+        {
+        }
+
+        bool operator()(const handleStatus &value)
+        {
+            return !value.status;
+        }
+    };
+
+    struct checkMainConnectionID
+    {
+        am_MainConnection_s mMainConnection;
+        explicit checkMainConnectionID(const am_MainConnection_s& mainConnection) :
+                mMainConnection(mainConnection)
+        {
+        }
+        bool operator()(const am_MainConnection_s& mainConnection)
+        {
+            if (mMainConnection.mainConnectionID == mainConnection.mainConnectionID)
+                return true;
+            return false;
+        }
+    };
+
+    enum cs_stateflow_e
+    {
+        SF_NONE,
+        SF_CONNECT,
+        SF_NAVI,
+        SF_TA
+    };
+
+    enum cs_connectSf_e
+    {
+        SFC_RAMP_DOWN,
+        SFC_SOURCE_STATE_OFF,
+        SFC_DISCONNECT,
+        SFC_CONNECT,
+        SFC_SOURCE_STATE_ON,
+        SFC_RAMP_UP,
+        SFC_FINISHED
+    };
+
+    enum cs_naviSf_e
+    {
+        NAVC_RAMP_DOWN,
+        NAVC_CONNECT,
+        NAVC_SOURCE_STATE_ON,
+        NAVC_RAMP_UP,
+        NAVC_WAIT_STATE,
+        NAVC_RAMP_DOWN_AGAIN,
+        NAVC_SOURCE_VOLUME_BACK,
+        NAVC_SOURCE_ACTIVITY_BACK,
+        NAVC_DISCONNECT,
+        NAVC_FINISHED
+    };
+
+    enum cs_trafficSf_e
+    {
+        TA_RAMP_DOWN,
+        TA_CONNECT,
+        TA_SOURCE_STATE_ON,
+        TA_RAMP_UP,
+        TA_WAIT_STATE,
+        TA_RAMP_DOWN_AGAIN,
+        TA_SOURCE_STATE_OFF,
+        TA_SOURCE_STATE_OLD_OFF,
+        TA_DISCONNECT,
+        TA_FINISHED
+    };
+
+    struct cs_connectData_s
+    {
+        am_mainConnectionID_t currentMainConnection;
+        am_mainConnectionID_t newMainConnection;
+        am_sourceID_t oldSourceID;
+        am_sinkID_t sinkID;
+        am_sourceID_t sourceID;
+    };
+
+    void callStateFlowHandler();
+    void callConnectHandler();
+    void callNaviHandler();
+    void callTAHandler();
+
+    IAmControlReceive * mControlReceiveInterface;
+    CAmDbusWrapper* mpCAmDBusWrapper;
+    DBusConnection* mpDBusConnection;
+    CAmControlDbusMessageHandler mCAmControlDBusMessageHandler;
+    IAmControlReceiverDbusShadow mIAmControlReceiverShadowDbus;
+
+    std::vector<mainConnectionSet> mListOpenConnections;
+    std::vector<mainConnectionSet> mListOpenDisconnections;
+    std::vector<mainVolumeSet> mListOpenVolumeChanges;
+    std::vector<mainSinkSoundPropertySet> mListMainSoundPropertyChanges;
+
+    cs_connectSf_e mConnectSf;
+    cs_naviSf_e mNaviSf;
+    cs_trafficSf_e mTrafficSf;
+    cs_connectData_s mConnectData;
+    cs_stateflow_e mStateflow;
+};
+}
+#endif /* CONTROLSENDER_H_ */
diff --git a/PluginControlInterfaceDbus/include/ControlReceiver.xml b/PluginControlInterfaceDbus/include/ControlReceiver.xml
new file mode 100644 (file)
index 0000000..1e37732
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE node PUBLIC
+  "-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
+  "http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
+
+<node>  
+       <interface name="org.genivi.audiomanager.ControlInterface">          
+       <method name="connect">      
+               <arg name="format" type="n" direction="in" />
+        <arg name="sourceID" type="q" direction="in" />
+        <arg name="sinkID" type="q" direction="in" />
+       </method>
+       <method name="disconnect">
+        <arg name="connectionID" type="q" direction="in" /> 
+        <arg name="sourceID" type="q" direction="in" /> 
+        <arg name="sinkID" type="q" direction="in" /> 
+       </method>
+       </interface>
+</node>
diff --git a/PluginControlInterfaceDbus/include/IAmControlReceiverDbusShadow.h b/PluginControlInterfaceDbus/include/IAmControlReceiverDbusShadow.h
new file mode 100644 (file)
index 0000000..dc9f985
--- /dev/null
@@ -0,0 +1,172 @@
+/**
+ *  Copyright (c) 2012 BMW
+ *
+ *  \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
+ *
+ *  \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.
+ *
+ *  For further information see http://www.genivi.org/.
+ */
+
+#ifndef IAMCONTROLRECEIVERDBUSSHADOW_H_
+#define IAMCONTROLRECEIVERDBUSSHADOW_H_
+
+#include <dbus/dbus.h>
+#include <map>
+#include "audiomanagertypes.h"
+#include "shared/CAmSerializer.h"
+#include "CAmControlDbusMessageHandler.h"
+
+namespace am
+{
+class IAmControlReceive;
+class CAmSocketHandler;
+class CAmDbusWrapper;
+class CAmControlSenderBase;
+
+#define CONTROL_NODE "ControlInterface"
+
+/**
+ * shadow class that used CAmSerializer to make threadsafe calls to the IAmControlReceive interface.
+ */
+class IAmControlReceiverDbusShadow
+{
+public:
+    IAmControlReceiverDbusShadow(IAmControlReceive* iReceiveInterface);
+    ~IAmControlReceiverDbusShadow();
+    am_Error_e getRoute(bool onlyfree, am_sourceID_t sourceID, am_sinkID_t sinkID, std::vector<am_Route_s>& returnList);
+
+    void connect(DBusConnection *conn, DBusMessage *msg);
+    void disconnect(DBusConnection *conn, DBusMessage *msg);
+
+    am_Error_e crossfade(am_Handle_s& handle, am_HotSink_e hotSource, am_crossfaderID_t crossfaderID, am_RampType_e rampType, am_time_t rampTime);
+    am_Error_e abortAction(am_Handle_s handle);
+    am_Error_e setSourceState(am_Handle_s& handle, am_sourceID_t sourceID, am_SourceState_e state);
+    am_Error_e setSinkVolume(am_Handle_s& handle, am_sinkID_t sinkID, am_volume_t volume, am_RampType_e ramp, am_time_t time);
+    am_Error_e setSourceVolume(am_Handle_s& handle, am_sourceID_t sourceID, am_volume_t volume, am_RampType_e rampType, am_time_t time);
+    am_Error_e setSinkSoundProperties(am_Handle_s& handle, am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& soundProperty);
+    am_Error_e setSinkSoundProperty(am_Handle_s& handle, am_sinkID_t sinkID, am_SoundProperty_s& soundProperty);
+    am_Error_e setSourceSoundProperties(am_Handle_s& handle, am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& soundProperty);
+    am_Error_e setSourceSoundProperty(am_Handle_s& handle, am_sourceID_t sourceID, am_SoundProperty_s& soundProperty);
+    am_Error_e setDomainState(am_domainID_t domainID, am_DomainState_e domainState);
+    am_Error_e enterDomainDB(am_Domain_s& domainData, am_domainID_t& domainID);
+    am_Error_e enterMainConnectionDB(am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID);
+    am_Error_e enterSinkDB(am_Sink_s& sinkData, am_sinkID_t& sinkID);
+    am_Error_e enterCrossfaderDB(am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID);
+    am_Error_e enterGatewayDB(am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID);
+    am_Error_e enterSourceDB(am_Source_s& sourceData, am_sourceID_t& sourceID);
+    am_Error_e enterSinkClassDB(am_SinkClass_s& sinkClass, am_sinkClass_t& sinkClassID);
+    am_Error_e enterSourceClassDB(am_sourceClass_t& sourceClassID, am_SourceClass_s& sourceClass);
+    am_Error_e changeSinkClassInfoDB(am_SinkClass_s& sinkClass);
+    am_Error_e changeSourceClassInfoDB(am_SourceClass_s& sourceClass);
+    am_Error_e enterSystemPropertiesListDB(std::vector<am_SystemProperty_s>& listSystemProperties);
+    am_Error_e changeMainConnectionRouteDB(am_mainConnectionID_t mainconnectionID, std::vector<am_connectionID_t>& listConnectionID);
+    am_Error_e changeMainConnectionStateDB(am_mainConnectionID_t mainconnectionID, am_ConnectionState_e connectionState);
+    am_Error_e changeSinkMainVolumeDB(am_mainVolume_t mainVolume, am_sinkID_t sinkID);
+    am_Error_e changeSinkAvailabilityDB(am_Availability_s& availability, am_sinkID_t sinkID);
+    am_Error_e changDomainStateDB(am_DomainState_e domainState, am_domainID_t domainID);
+    am_Error_e changeSinkMuteStateDB(am_MuteState_e muteState, am_sinkID_t sinkID);
+    am_Error_e changeMainSinkSoundPropertyDB(am_MainSoundProperty_s& soundProperty, am_sinkID_t sinkID);
+    am_Error_e changeMainSourceSoundPropertyDB(am_MainSoundProperty_s& soundProperty, am_sourceID_t sourceID);
+    am_Error_e changeSourceAvailabilityDB(am_Availability_s& availability, am_sourceID_t sourceID);
+    am_Error_e changeSystemPropertyDB(am_SystemProperty_s& property);
+    am_Error_e removeMainConnectionDB(am_mainConnectionID_t mainConnectionID);
+    am_Error_e removeSinkDB(am_sinkID_t sinkID);
+    am_Error_e removeSourceDB(am_sourceID_t sourceID);
+    am_Error_e removeGatewayDB(am_gatewayID_t gatewayID);
+    am_Error_e removeCrossfaderDB(am_crossfaderID_t crossfaderID);
+    am_Error_e removeDomainDB(am_domainID_t domainID);
+    am_Error_e removeSinkClassDB(am_sinkClass_t sinkClassID);
+    am_Error_e removeSourceClassDB(am_sourceClass_t sourceClassID);
+    am_Error_e getSourceClassInfoDB(am_sourceID_t sourceID, am_SourceClass_s& classInfo);
+    am_Error_e getSinkClassInfoDB(am_sinkID_t sinkID, am_SinkClass_s& sinkClass);
+    am_Error_e getSinkInfoDB(am_sinkID_t sinkID, am_Sink_s& sinkData);
+    am_Error_e getSourceInfoDB(am_sourceID_t sourceID, am_Source_s& sourceData);
+    am_Error_e getGatewayInfoDB(am_gatewayID_t gatewayID, am_Gateway_s& gatewayData);
+    am_Error_e getCrossfaderInfoDB(am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData);
+    am_Error_e getMainConnectionInfoDB(am_mainConnectionID_t mainConnectionID, am_MainConnection_s& mainConnectionData);
+    am_Error_e getListSinksOfDomain(am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID);
+    am_Error_e getListSourcesOfDomain(am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID);
+    am_Error_e getListCrossfadersOfDomain(am_domainID_t domainID, std::vector<am_crossfaderID_t>& listCrossfadersID);
+    am_Error_e getListGatewaysOfDomain(am_domainID_t domainID, std::vector<am_gatewayID_t>& listGatewaysID);
+    am_Error_e getListMainConnections(std::vector<am_MainConnection_s>& listMainConnections);
+    am_Error_e getListDomains(std::vector<am_Domain_s>& listDomains);
+    am_Error_e getListConnections(std::vector<am_Connection_s>& listConnections);
+    am_Error_e getListSinks(std::vector<am_Sink_s>& listSinks);
+    am_Error_e getListSources(std::vector<am_Source_s>& listSources);
+    am_Error_e getListSourceClasses(std::vector<am_SourceClass_s>& listSourceClasses);
+    am_Error_e getListHandles(std::vector<am_Handle_s>& listHandles);
+    am_Error_e getListCrossfaders(std::vector<am_Crossfader_s>& listCrossfaders);
+    am_Error_e getListGateways(std::vector<am_Gateway_s>& listGateways);
+    am_Error_e getListSinkClasses(std::vector<am_SinkClass_s>& listSinkClasses);
+    am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s>& listSystemProperties);
+    void setControlReady();
+    void setControlRundown();
+    void confirmControllerReady(am_Error_e error);
+    void confirmControllerRundown(am_Error_e error);
+    am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler);
+
+    void confirmControlReady(DBusConnection *conn, DBusMessage *msg);
+    void confirmControlRundown(DBusConnection *conn, DBusMessage *msg);
+
+    void setControlReceiver(IAmControlReceive*& receiver);
+    void setControlSender(CAmControlSenderBase* sender);
+
+    void gotReady(int16_t numberDomains, uint16_t handle);
+    void gotRundown(int16_t numberDomains, uint16_t handle);
+
+private:
+    IAmControlReceive *mpIAmControlReceiver;
+    /* CAmControlSenderBase* iControlSender; */
+
+    typedef void (IAmControlReceiverDbusShadow::*CallBackMethod)(DBusConnection *connection, DBusMessage *message);
+    CAmDbusWrapper* mDBusWrapper;
+    DBusConnection* mpDBusConnection;
+
+    typedef std::map<std::string, CallBackMethod> functionMap_t;
+    functionMap_t mFunctionMap;
+    CAmControlDbusMessageHandler mDBUSMessageHandler;
+    int16_t mNumberDomains;
+    uint16_t mHandle;
+
+    am_Error_e autoConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID);
+    void connect_auto(am_sourceID_t sourceID, am_sinkID_t sinkID, am_mainConnectionID_t mainConnectionID);
+
+    /**
+     * receives a callback whenever the path of the plugin is called
+     */
+    static DBusHandlerResult receiveCallback(DBusConnection *conn, DBusMessage *msg, void *user_data);
+
+    /**
+     * dynamic delegate that handles the Callback of the static receiveCallback
+     * @param conn DBus connection
+     * @param msg DBus message
+     * @param user_data pointer to instance of IAmRoutingReceiverShadow
+     * @return
+     */
+    DBusHandlerResult receiveCallbackDelegate(DBusConnection *conn, DBusMessage *msg);
+
+    /**
+     * sends out introspectiondata read from an xml file.
+     * @param conn
+     * @param msg
+     */
+    void sendIntrospection(DBusConnection* conn, DBusMessage* msg);
+
+    /**
+     * creates the function map needed to combine DBus messages and function adresses
+     * @return the map
+     */
+    functionMap_t createMap();
+
+};
+
+} /* namespace am */
+#endif /* IAMCONTROLRECEIVERDBUSSHADOW_H_ */
diff --git a/PluginControlInterfaceDbus/include/configControlDbus.h b/PluginControlInterfaceDbus/include/configControlDbus.h
new file mode 100644 (file)
index 0000000..e3999d0
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _CONTROLDBUS_CONFIG_H
+#define _CONTROLDBUS_CONFIG_H
+
+#define CONTROL_DBUS_INTROSPECTION_FILE "/usr/share/audiomanager/ControlReceiver.xml"
+
+#endif /* _CONTROLDBUS_CONFIG_H */
diff --git a/PluginControlInterfaceDbus/src/CAmControlDbusMessageHandler.cpp b/PluginControlInterfaceDbus/src/CAmControlDbusMessageHandler.cpp
new file mode 100644 (file)
index 0000000..b2fe3a3
--- /dev/null
@@ -0,0 +1,935 @@
+/**
+ *  Copyright (c) 2014 Intel
+ *  Copyright (c) copyright 2011-2012 Aricent® Group  and its licensors
+ *  Copyright (c) 2012 BMW
+ *
+ *  \author Jaska Uimonen
+ *  \author Sampreeth Ramavana
+ *  \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
+ *
+ *  \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.
+ *
+ *  For further information see http://www.genivi.org/.
+ */
+
+#include "CAmControlDbusMessageHandler.h"
+#include "config.h"
+#include <cstdlib>
+#include <cassert>
+#include <vector>
+#include "shared/CAmDltWrapper.h"
+
+#define CONTROL_NODE "ControlInterface"
+
+namespace am
+{
+DLT_IMPORT_CONTEXT(controlDbus)
+
+CAmControlDbusMessageHandler::CAmControlDbusMessageHandler() :
+        mDBusMessageIter(), //
+        mDBusError(), //
+        mSerial(0), //
+        mErrorName(""), //
+        mErrorMsg(""), //
+        mpDBusMessage(NULL), //
+        mpReceiveMessage(NULL), //
+        mpDBusConnection(NULL)
+{
+    log(&controlDbus, DLT_LOG_INFO, "DBusMessageHandler constructed");
+}
+
+CAmControlDbusMessageHandler::~CAmControlDbusMessageHandler()
+{
+    log(&controlDbus, DLT_LOG_INFO, "DBUSMessageHandler destructed");
+}
+
+void CAmControlDbusMessageHandler::initReceive(DBusMessage* msg)
+{
+    assert(msg!=NULL);
+    mpReceiveMessage = msg;
+    if (!dbus_message_iter_init(msg, &mDBusMessageIter))
+    {
+        log(&controlDbus, DLT_LOG_INFO, "DBusMessageHandler::initReceive DBus Message has no arguments!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBUS Message has no arguments!";
+    }
+}
+
+void CAmControlDbusMessageHandler::initReply(DBusMessage* msg)
+{
+    assert(msg!=NULL);
+    mpDBusMessage = dbus_message_new_method_return(msg);
+    if (mpDBusMessage == NULL)
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::initReply Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+    dbus_message_iter_init_append(mpDBusMessage, &mDBusMessageIter);
+}
+
+void CAmControlDbusMessageHandler::initSignal(std::string path, std::string signalName)
+{
+    assert(!path.empty());
+    assert(!signalName.empty());
+    std::string completePath = std::string(DBUS_SERVICE_OBJECT_PATH) + "/" + path;
+       std::string completeInterface = std::string(DBUS_SERVICE_PREFIX) + "." + CONTROL_NODE;
+    mpDBusMessage = dbus_message_new_signal(completePath.c_str(), completeInterface.c_str(), signalName.c_str());
+
+    if (mpDBusMessage == NULL)
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::initSignal Cannot allocate DBus message!");
+    }
+    dbus_message_iter_init_append(mpDBusMessage, &mDBusMessageIter);
+}
+
+void CAmControlDbusMessageHandler::sendMessage()
+{
+    assert(mpDBusConnection!=NULL);
+    if (mpReceiveMessage != 0)
+    {
+        mSerial = dbus_message_get_serial(mpReceiveMessage);
+    }
+    else
+    {
+        mSerial = 1;
+    }
+    if (!mErrorName.empty())
+    {
+        mpDBusMessage = dbus_message_new_error(mpReceiveMessage, mErrorName.c_str(), mErrorMsg.c_str());
+    }
+    if (!dbus_connection_send(mpDBusConnection, mpDBusMessage, &mSerial))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::sendMessage cannot send message!");
+    }
+    dbus_connection_flush(mpDBusConnection);
+    dbus_message_unref(mpDBusMessage);
+    mpDBusMessage = NULL;
+}
+
+char* CAmControlDbusMessageHandler::getString(DBusMessageIter& iter, bool next)
+{
+    char* param = NULL;
+
+    if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&iter))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::getString DBUS handler argument is no String!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBus argument is no string";
+    }
+    else
+    {
+        dbus_message_iter_get_basic(&iter, &param);
+        if (next)
+            dbus_message_iter_next(&iter);
+    }
+    return (param);
+}
+
+char* CAmControlDbusMessageHandler::getString()
+{
+    return (getString(mDBusMessageIter, true));
+}
+
+dbus_bool_t CAmControlDbusMessageHandler::getBool(DBusMessageIter& iter, bool next)
+{
+    dbus_bool_t boolparam = false;
+
+    if (DBUS_TYPE_BOOLEAN != dbus_message_iter_get_arg_type(&iter))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::getBool DBUS handler argument is no bool!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBus argument is no bool";
+    }
+    else
+    {
+        dbus_message_iter_get_basic(&iter, &boolparam);
+        if (next)
+            dbus_message_iter_next(&iter);
+    }
+    return (boolparam);
+}
+
+dbus_bool_t CAmControlDbusMessageHandler::getBool()
+{
+    return (getBool(mDBusMessageIter, true));
+}
+
+char CAmControlDbusMessageHandler::getByte(DBusMessageIter& iter, bool next)
+{
+    char param(0);
+
+    if (DBUS_TYPE_BYTE != dbus_message_iter_get_arg_type(&iter))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::getByte DBUS handler argument is no byte!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBus argument is no byte";
+    }
+    else
+    {
+        dbus_message_iter_get_basic(&iter, &param);
+        if (next)
+            dbus_message_iter_next(&iter);
+    }
+    return (param);
+}
+
+char CAmControlDbusMessageHandler::getByte()
+{
+    return (getByte(mDBusMessageIter, true));
+}
+
+dbus_uint16_t CAmControlDbusMessageHandler::getUInt(DBusMessageIter& iter, bool next)
+{
+    dbus_uint16_t param(0);
+#ifdef GLIB_DBUS_TYPES_TOLERANT
+    if (DBUS_TYPE_UINT16 != dbus_message_iter_get_arg_type(&iter) && DBUS_TYPE_UINT32 != dbus_message_iter_get_arg_type(&iter))
+#else
+    if (DBUS_TYPE_UINT16 != dbus_message_iter_get_arg_type(&iter))
+#endif
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::getUInt DBUS handler argument is no uint16_t!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBus argument is no uint16_t";
+    }
+    else
+    {
+        dbus_message_iter_get_basic(&iter, &param);
+        if (next)
+            dbus_message_iter_next(&iter);
+    }
+    return (param);
+}
+
+dbus_uint16_t CAmControlDbusMessageHandler::getUInt()
+{
+    return (getUInt(mDBusMessageIter, true));
+}
+
+dbus_int16_t CAmControlDbusMessageHandler::getInt(DBusMessageIter& iter, bool next)
+{
+    dbus_int16_t param(0);
+#ifdef GLIB_DBUS_TYPES_TOLERANT
+    if (DBUS_TYPE_INT16 != dbus_message_iter_get_arg_type(&iter) && DBUS_TYPE_INT32 != dbus_message_iter_get_arg_type(&iter))
+#else
+    if (DBUS_TYPE_INT16 != dbus_message_iter_get_arg_type(&iter))
+#endif
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::getInt DBUS handler argument is no int16_t!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBus argument is no int16_t";
+    }
+    else
+    {
+        dbus_message_iter_get_basic(&iter, &param);
+        if (next)
+            dbus_message_iter_next(&iter);
+    }
+    return (param);
+}
+
+dbus_int16_t CAmControlDbusMessageHandler::getInt()
+{
+    return (getInt(mDBusMessageIter, true));
+}
+
+double CAmControlDbusMessageHandler::getDouble(DBusMessageIter& iter, bool next)
+{
+    double param(0);
+    if (DBUS_TYPE_DOUBLE != dbus_message_iter_get_arg_type(&iter))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::getDouble DBUS handler argument is no double!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBus argument is no double";
+    }
+    else
+    {
+        dbus_message_iter_get_basic(&iter, &param);
+        if (next)
+            dbus_message_iter_next(&iter);
+    }
+    return (param);
+}
+
+double CAmControlDbusMessageHandler::getDouble()
+{
+    return (getDouble(mDBusMessageIter, true));
+}
+
+am::am_Availability_s CAmControlDbusMessageHandler::getAvailability()
+{
+    am::am_Availability_s availability;
+    availability.availability=A_UNKNOWN;
+    availability.availabilityReason=AR_UNKNOWN;
+    if (DBUS_TYPE_STRUCT != dbus_message_iter_get_arg_type(&mDBusMessageIter))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::getAvailability DBUS handler argument is no struct!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBus argument is no struct";
+    }
+    else
+    {
+        DBusMessageIter structIter;
+        dbus_message_iter_recurse(&mDBusMessageIter, &structIter);
+        availability.availability = static_cast<am_Availability_e>(getInt(structIter, true));
+        availability.availabilityReason = static_cast<am_AvailabilityReason_e>(getInt(structIter, false));
+        dbus_message_iter_next(&mDBusMessageIter);
+    }
+    return (availability);
+}
+
+std::vector<am_EarlyData_s> CAmControlDbusMessageHandler::getEarlyData()
+{
+    std::vector<am_EarlyData_s> listEarlyData;
+    if (DBUS_TYPE_ARRAY != dbus_message_iter_get_arg_type(&mDBusMessageIter))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::getProperty DBUS handler argument is no array!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBus argument is no array";
+    }
+    else
+    {
+        DBusMessageIter arrayIter, structIter, soundpropIter;
+        am_EarlyData_s earlyData;
+
+        //first the volume array
+        do
+        {
+            dbus_message_iter_recurse(&mDBusMessageIter, &arrayIter);
+            dbus_message_iter_recurse(&arrayIter, &structIter);
+            earlyData.type = static_cast<am_EarlyDataType_e>(getUInt(structIter, true));
+            if (earlyData.type==ED_SINK_VOLUME)
+                earlyData.sinksource.sink = static_cast<am_sinkID_t>(getUInt(structIter, true));
+            else
+                earlyData.sinksource.source = static_cast<am_sourceID_t>(getUInt(structIter, true));
+            earlyData.data.volume = static_cast<am_volume_t>(getInt(structIter, false));
+            listEarlyData.push_back(earlyData);
+        } while (dbus_message_iter_next(&arrayIter));
+        dbus_message_iter_next(&mDBusMessageIter);
+
+        //then the soundproperty array
+        do
+        {
+            dbus_message_iter_recurse(&mDBusMessageIter, &arrayIter);
+            dbus_message_iter_recurse(&arrayIter, &structIter);
+            earlyData.type = static_cast<am_EarlyDataType_e>(getUInt(structIter, true));
+            if (earlyData.type==ED_SINK_PROPERTY)
+                earlyData.sinksource.sink = static_cast<am_sinkID_t>(getUInt(structIter, true));
+            else
+                earlyData.sinksource.source = static_cast<am_sourceID_t>(getUInt(structIter, true));
+            dbus_message_iter_recurse(&structIter, &soundpropIter);
+            earlyData.data.soundProperty.type = static_cast<am_SoundPropertyType_e>(getInt(soundpropIter, true));
+            earlyData.data.soundProperty.value = (getInt(soundpropIter, false));
+            listEarlyData.push_back(earlyData);
+        } while (dbus_message_iter_next(&arrayIter));
+    }
+    return (listEarlyData);
+}
+
+am_Domain_s CAmControlDbusMessageHandler::getDomainData()
+{
+    am_Domain_s domainData;
+    DBusMessageIter domainDataIter;
+
+    if (DBUS_TYPE_STRUCT != dbus_message_iter_get_arg_type(&mDBusMessageIter))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "CAmControlDbusMessageHandler::getDomainData DBUS handler argument is no struct!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBus argument is no struct";
+    }
+    else
+    {
+        dbus_message_iter_recurse(&mDBusMessageIter, &domainDataIter);
+       domainData.domainID = static_cast<am_domainID_t>(getUInt(domainDataIter, true));
+       domainData.name = getString(domainDataIter, true);
+       domainData.busname = getString(domainDataIter, true);
+       domainData.nodename = getString(domainDataIter, true);
+       domainData.early = getBool(domainDataIter, true);
+       domainData.complete = getBool(domainDataIter, true);
+       domainData.state = static_cast<am_DomainState_e>(getUInt(domainDataIter, false));
+        dbus_message_iter_next(&mDBusMessageIter);
+    }
+    return (domainData);
+}
+
+am_Source_s CAmControlDbusMessageHandler::getSourceData()
+{
+    am_Source_s sourceData;
+    DBusMessageIter sourceDataIter, availIter, arrayIter, structIter;
+    am_SoundProperty_s soundProperty;
+    am_ConnectionFormat_e connectionFormat;
+    am_MainSoundProperty_s mainSoundProperty;
+
+    if (DBUS_TYPE_STRUCT != dbus_message_iter_get_arg_type(&mDBusMessageIter))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "CAmControlDbusMessageHandler::getSourceData DBUS handler argument is no struct!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBus argument is no struct";
+    }
+    else
+    {
+        dbus_message_iter_recurse(&mDBusMessageIter, &sourceDataIter);
+       sourceData.sourceID = static_cast<am_sourceID_t>(getUInt(sourceDataIter, true));
+       sourceData.domainID = static_cast<am_domainID_t>(getUInt(sourceDataIter, true));
+       sourceData.name = getString(sourceDataIter, true);
+       sourceData.sourceClassID = static_cast<am_sourceClass_t>(getUInt(sourceDataIter, true));
+       sourceData.sourceState = static_cast<am_SourceState_e>(getUInt(sourceDataIter, true));
+       sourceData.volume = static_cast<am_volume_t>(getInt(sourceDataIter, true));
+       sourceData.visible = getBool(sourceDataIter, true);
+       dbus_message_iter_recurse(&sourceDataIter, &availIter);
+       sourceData.available.availability = static_cast<am_Availability_e>(getInt(availIter, true));
+       sourceData.available.availabilityReason = static_cast<am_AvailabilityReason_e>(getInt(availIter, false));
+       dbus_message_iter_next(&sourceDataIter);
+       sourceData.interruptState = static_cast<am_InterruptState_e>(getUInt(sourceDataIter, true));
+       dbus_message_iter_recurse(&sourceDataIter, &arrayIter);
+       do
+       {
+           dbus_message_iter_recurse(&arrayIter, &structIter);
+           soundProperty.type = static_cast<am_SoundPropertyType_e>(getInt(structIter, true));
+           soundProperty.value = static_cast<int16_t>(getInt(structIter, false));
+           sourceData.listSoundProperties.push_back(soundProperty);
+       } while (dbus_message_iter_next(&arrayIter));
+       dbus_message_iter_next(&sourceDataIter);
+       dbus_message_iter_recurse(&sourceDataIter, &arrayIter);
+       do
+       {
+           connectionFormat = static_cast<am_ConnectionFormat_e>(getInt(arrayIter, false));
+           sourceData.listConnectionFormats.push_back(connectionFormat);
+       } while (dbus_message_iter_next(&arrayIter));
+       dbus_message_iter_next(&sourceDataIter);
+
+       dbus_message_iter_recurse(&sourceDataIter, &arrayIter);
+       do
+       {
+           dbus_message_iter_recurse(&arrayIter, &structIter);
+           mainSoundProperty.type = static_cast<am_MainSoundPropertyType_e>(getInt(structIter, true));
+           mainSoundProperty.value = static_cast<int16_t>(getInt(structIter, false));
+           sourceData.listMainSoundProperties.push_back(mainSoundProperty);
+       } while (dbus_message_iter_next(&arrayIter));
+        dbus_message_iter_next(&mDBusMessageIter);
+    }
+    return (sourceData);
+}
+
+am_Sink_s CAmControlDbusMessageHandler::getSinkData()
+{
+    am_Sink_s sinkData;
+    DBusMessageIter sinkDataIter, structIter, availIter, arrayIter;
+    am_SoundProperty_s soundProperty;
+    am_ConnectionFormat_e connectionFormat;
+    am_MainSoundProperty_s mainSoundProperty;
+
+    if (DBUS_TYPE_STRUCT != dbus_message_iter_get_arg_type(&mDBusMessageIter))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "CAmControlDbusMessageHandler::getSinkData DBUS handler argument is no struct!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBus argument is no struct";
+    }
+    else
+    {
+        dbus_message_iter_recurse(&mDBusMessageIter, &sinkDataIter);
+       sinkData.sinkID = static_cast<am_sinkID_t>(getUInt(sinkDataIter, true));
+       sinkData.name = getString(sinkDataIter, true);
+       sinkData.domainID = static_cast<am_domainID_t>(getUInt(sinkDataIter, true));
+       sinkData.sinkClassID = static_cast<am_sinkClass_t>(getUInt(sinkDataIter, true));
+       sinkData.volume = static_cast<am_volume_t>(getInt(sinkDataIter, true));
+       sinkData.visible = getBool(sinkDataIter, true);
+       dbus_message_iter_recurse(&sinkDataIter, &availIter);
+       sinkData.available.availability = static_cast<am_Availability_e>(getInt(availIter, true));
+       sinkData.available.availabilityReason = static_cast<am_AvailabilityReason_e>(getInt(availIter, false));
+       dbus_message_iter_next(&sinkDataIter);
+       sinkData.muteState = static_cast<am_MuteState_e>(getInt(sinkDataIter, true));
+       sinkData.mainVolume = static_cast<am_mainVolume_t>(getInt(sinkDataIter, true));
+
+       dbus_message_iter_recurse(&sinkDataIter, &arrayIter);
+       do
+       {
+           dbus_message_iter_recurse(&arrayIter, &structIter);
+           soundProperty.type = static_cast<am_SoundPropertyType_e>(getInt(structIter, true));
+           soundProperty.value = static_cast<int16_t>(getInt(structIter, false));
+           sinkData.listSoundProperties.push_back(soundProperty);
+       } while (dbus_message_iter_next(&arrayIter));
+
+       dbus_message_iter_next(&sinkDataIter);
+
+       dbus_message_iter_recurse(&sinkDataIter, &arrayIter);
+       do
+       {
+           connectionFormat = static_cast<am_ConnectionFormat_e>(getInt(arrayIter, false));
+           sinkData.listConnectionFormats.push_back(connectionFormat);
+       } while (dbus_message_iter_next(&arrayIter));
+       dbus_message_iter_next(&sinkDataIter);
+
+       dbus_message_iter_recurse(&sinkDataIter, &arrayIter);
+       do
+       {
+           dbus_message_iter_recurse(&arrayIter, &structIter);
+           mainSoundProperty.type = static_cast<am_MainSoundPropertyType_e>(getInt(structIter, true));
+           mainSoundProperty.value = static_cast<int16_t>(getInt(structIter, false));
+           sinkData.listMainSoundProperties.push_back(mainSoundProperty);
+       } while (dbus_message_iter_next(&arrayIter));
+        dbus_message_iter_next(&mDBusMessageIter);
+    }
+    return (sinkData);
+}
+
+am_Gateway_s CAmControlDbusMessageHandler::getGatewayData()
+{
+    am_Gateway_s gatewayData;
+    DBusMessageIter gatewayDataIter, arrayIter;
+    am_ConnectionFormat_e connectionFormat;
+    bool convertion;
+    if (DBUS_TYPE_STRUCT != dbus_message_iter_get_arg_type(&mDBusMessageIter))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "CAmControlDbusMessageHandler::getDomainData DBUS handler argument is no struct!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBus argument is no struct";
+    }
+    else
+    {
+        dbus_message_iter_recurse(&mDBusMessageIter, &gatewayDataIter);
+       gatewayData.gatewayID = static_cast<am_gatewayID_t>(getUInt(gatewayDataIter, true));
+       gatewayData.name = getString(gatewayDataIter, true);
+       gatewayData.sinkID = static_cast<am_sinkID_t>(getUInt(gatewayDataIter, true));
+       gatewayData.sourceID = static_cast<am_sourceID_t>(getUInt(gatewayDataIter, true));
+       gatewayData.domainSinkID = static_cast<am_domainID_t>(getUInt(gatewayDataIter, true));
+       gatewayData.domainSourceID = static_cast<am_domainID_t>(getUInt(gatewayDataIter, true));
+       gatewayData.controlDomainID = static_cast<am_domainID_t>(getUInt(gatewayDataIter, true));
+       do
+       {
+           dbus_message_iter_recurse(&gatewayDataIter, &arrayIter);
+           connectionFormat = static_cast<am_ConnectionFormat_e>(getUInt(arrayIter, false));
+           gatewayData.listSourceFormats.push_back(connectionFormat);
+       } while (dbus_message_iter_next(&arrayIter));
+       dbus_message_iter_next(&gatewayDataIter);
+       do
+       {
+           dbus_message_iter_recurse(&gatewayDataIter, &arrayIter);
+           connectionFormat = static_cast<am_ConnectionFormat_e>(getUInt(arrayIter, false));
+           gatewayData.listSinkFormats.push_back(connectionFormat);
+       } while (dbus_message_iter_next(&arrayIter));
+       dbus_message_iter_next(&gatewayDataIter);
+       do
+       {
+           dbus_message_iter_recurse(&gatewayDataIter, &arrayIter);
+           convertion = getBool(arrayIter, false);
+           gatewayData.convertionMatrix.push_back(convertion);
+       } while (dbus_message_iter_next(&arrayIter));
+        dbus_message_iter_next(&mDBusMessageIter);
+    }
+    return (gatewayData);
+}
+
+am_Crossfader_s CAmControlDbusMessageHandler::getCrossfaderData()
+{
+    am_Crossfader_s crossfaderData;
+    DBusMessageIter crossfaderDataIter;
+
+    if (DBUS_TYPE_STRUCT != dbus_message_iter_get_arg_type(&mDBusMessageIter))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "CAmControlDbusMessageHandler::getCrossfaderData DBUS handler argument is no struct!");
+        mErrorName = std::string(DBUS_ERROR_INVALID_ARGS);
+        mErrorMsg = "DBus argument is no struct";
+    }
+    else
+    {
+        dbus_message_iter_recurse(&mDBusMessageIter, &crossfaderDataIter);
+       crossfaderData.crossfaderID = static_cast<am_crossfaderID_t> (getInt(crossfaderDataIter, true));
+       crossfaderData.name = static_cast<std::string> (getString(crossfaderDataIter, true));
+       crossfaderData.sinkID_A = static_cast<am_sinkID_t> (getInt(crossfaderDataIter, true));
+       crossfaderData.sinkID_B = static_cast<am_sinkID_t> (getInt(crossfaderDataIter, true));
+       crossfaderData.sourceID = static_cast<am_sourceID_t> (getInt(crossfaderDataIter, true));
+       crossfaderData.hotSink = static_cast<am_HotSink_e> (getInt(crossfaderDataIter, false));
+        dbus_message_iter_next(&mDBusMessageIter);
+    }
+    return (crossfaderData);
+}
+
+am_MainSoundProperty_s CAmControlDbusMessageHandler::getMainSoundProperty()
+{
+    am_MainSoundProperty_s mainSoundProperty;
+    DBusMessageIter structIter;
+
+    dbus_message_iter_recurse(&mDBusMessageIter, &structIter);
+    mainSoundProperty.type = static_cast<am_MainSoundPropertyType_e>(getInt(structIter, true));
+    mainSoundProperty.value = static_cast<int16_t>(getInt(structIter, false));
+    dbus_message_iter_next(&mDBusMessageIter);
+
+    return (mainSoundProperty);
+}
+
+void CAmControlDbusMessageHandler::append(bool toAppend)
+{
+    dbus_bool_t mybool = toAppend;
+    if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_BOOLEAN, &mybool))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(double toAppend)
+{
+    if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_DOUBLE, &toAppend))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(char toAppend)
+{
+    if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_BYTE, &toAppend))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(dbus_int16_t toAppend)
+{
+    if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_INT16, &toAppend))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(dbus_uint16_t toAppend)
+{
+    if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_UINT16, &toAppend))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::setDBusConnection(DBusConnection*& connection)
+{
+    assert(connection != NULL);
+    mpDBusConnection = connection;
+}
+
+void CAmControlDbusMessageHandler::append(const am::am_SinkType_s& sinkType)
+{
+    DBusMessageIter structIter;
+    DBusMessageIter structAvailIter;
+    dbus_bool_t success = true;
+    success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sinkType.sinkID);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &sinkType.name);
+    success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &structAvailIter);
+    success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sinkType.availability.availability);
+    success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sinkType.availability.availabilityReason);
+    success = success && dbus_message_iter_close_container(&structIter, &structAvailIter);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &sinkType.volume);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &sinkType.muteState);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sinkType.sinkClassID);
+    success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter);
+    if (!success)
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(const am::am_SourceType_s& sourceType)
+{
+    DBusMessageIter structIter;
+    DBusMessageIter structAvailIter;
+    dbus_bool_t success = true;
+    success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sourceType.sourceID);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &sourceType.name);
+    success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &structAvailIter);
+    success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sourceType.availability.availability);
+    success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sourceType.availability.availabilityReason);
+    success = success && dbus_message_iter_close_container(&structIter, &structAvailIter);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sourceType.sourceClassID);
+    success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter);
+    if (!success)
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(const am::am_MainSoundProperty_s mainSoundProperty)
+{
+    DBusMessageIter structIter;
+    dbus_bool_t success = true;
+    success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &mainSoundProperty.type);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &mainSoundProperty.value);
+    success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter);
+    if (!success)
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(const am::am_Availability_s& availability)
+{
+    DBusMessageIter structAvailIter;
+    dbus_bool_t success = true;
+    success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structAvailIter);
+    success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &availability.availability);
+    success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &availability.availabilityReason);
+    success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structAvailIter);
+    if (!success)
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(const am::am_SystemProperty_s& SystemProperty)
+{
+    DBusMessageIter structIter;
+    dbus_bool_t success = true;
+    success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &SystemProperty.type);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &SystemProperty.value);
+    success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter);
+    if (!success)
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(const std::vector<am::am_MainConnectionType_s>& listMainConnections)
+{
+    DBusMessageIter arrayIter;
+    DBusMessageIter structIter;
+    std::vector<am::am_MainConnectionType_s>::const_iterator listIterator = listMainConnections.begin();
+    dbus_bool_t success = true;
+    success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qqqnn)", &arrayIter);
+    for (; listIterator < listMainConnections.end(); ++listIterator)
+    {
+        success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->mainConnectionID);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceID);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkID);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->delay);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->connectionState);
+        success = success && dbus_message_iter_close_container(&arrayIter, &structIter);
+    }
+    success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
+    if (!success)
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(const std::vector<am::am_SinkType_s>& listMainSinks)
+{
+    DBusMessageIter arrayIter;
+    DBusMessageIter structIter;
+    DBusMessageIter availIter;
+    std::vector<am::am_SinkType_s>::const_iterator listIterator = listMainSinks.begin();
+    dbus_bool_t success = true;
+    success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qs(nn)nnq)", &arrayIter);
+    for (; listIterator < listMainSinks.end(); ++listIterator)
+    {
+        success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkID);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name);
+        success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &availIter);
+        success = success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availability);
+        success = success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availabilityReason);
+        success = success && dbus_message_iter_close_container(&structIter, &availIter);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->volume);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->muteState);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkClassID);
+        success = success && dbus_message_iter_close_container(&arrayIter, &structIter);
+    }
+    success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
+    if (!success)
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(const std::vector<am::am_SourceType_s>& listMainSources)
+{
+    DBusMessageIter arrayIter;
+    DBusMessageIter structIter;
+    DBusMessageIter availIter;
+    std::vector<am::am_SourceType_s>::const_iterator listIterator = listMainSources.begin();
+    dbus_bool_t success = true;
+    success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qs(nn)q)", &arrayIter);
+    for (; listIterator < listMainSources.end(); ++listIterator)
+    {
+        success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceID);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name);
+        success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &availIter);
+        success = success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availability);
+        success = success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availabilityReason);
+        success = success && dbus_message_iter_close_container(&structIter, &availIter);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceClassID);
+        success = success && dbus_message_iter_close_container(&arrayIter, &structIter);
+    }
+    success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
+    if (!success)
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(const std::vector<am::am_MainSoundProperty_s>& listMainSoundProperties)
+{
+    DBusMessageIter arrayIter;
+    DBusMessageIter structIter;
+    std::vector<am::am_MainSoundProperty_s>::const_iterator listIterator = listMainSoundProperties.begin();
+    dbus_bool_t success = true;
+    success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(nn)", &arrayIter);
+    for (; listIterator < listMainSoundProperties.end(); ++listIterator)
+    {
+        success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->type);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->value);
+        success = success && dbus_message_iter_close_container(&arrayIter, &structIter);
+    }
+    success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
+    if (!success)
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(const std::vector<am::am_SourceClass_s>& listSourceClasses)
+{
+    DBusMessageIter arrayIter;
+    DBusMessageIter structIter;
+    DBusMessageIter propIter;
+    DBusMessageIter innerIter;
+    std::vector<am::am_SourceClass_s>::const_iterator listIterator = listSourceClasses.begin();
+    dbus_bool_t success = true;
+    success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qsa(nn))", &arrayIter);
+    for (; listIterator < listSourceClasses.end(); ++listIterator)
+    {
+        success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceClassID);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name);
+        success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_ARRAY, "(nn)", &innerIter);
+
+        std::vector<am::am_ClassProperty_s>::const_iterator listInnerIterator = listIterator->listClassProperties.begin();
+        for (; listInnerIterator < listIterator->listClassProperties.end(); ++listInnerIterator)
+        {
+            success = success && dbus_message_iter_open_container(&innerIter, DBUS_TYPE_STRUCT, NULL, &propIter);
+            success = success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->classProperty);
+            success = success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->value);
+            success = success && dbus_message_iter_close_container(&innerIter, &propIter);
+        }
+        success = success && dbus_message_iter_close_container(&structIter, &innerIter);
+        success = success && dbus_message_iter_close_container(&arrayIter, &structIter);
+    }
+    success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
+    if (!success)
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(const std::vector<am::am_SinkClass_s>& listSinkClasses)
+{
+    DBusMessageIter arrayIter;
+    DBusMessageIter structIter;
+    DBusMessageIter propIter;
+    DBusMessageIter innerIter;
+    std::vector<am::am_SinkClass_s>::const_iterator listIterator = listSinkClasses.begin();
+    dbus_bool_t success = true;
+    success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qsa(nn))", &arrayIter);
+    for (; listIterator < listSinkClasses.end(); ++listIterator)
+    {
+        success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkClassID);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name);
+        success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_ARRAY, "(nn)", &innerIter);
+
+        std::vector<am::am_ClassProperty_s>::const_iterator listInnerIterator = listIterator->listClassProperties.begin();
+        for (; listInnerIterator < listIterator->listClassProperties.end(); ++listInnerIterator)
+        {
+            success = success && dbus_message_iter_open_container(&innerIter, DBUS_TYPE_STRUCT, NULL, &propIter);
+            success = success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->classProperty);
+            success = success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->value);
+            success = success && dbus_message_iter_close_container(&innerIter, &propIter);
+        }
+        success = success && dbus_message_iter_close_container(&structIter, &innerIter);
+        success = success && dbus_message_iter_close_container(&arrayIter, &structIter);
+    }
+    success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
+    if (!success)
+    {
+        {
+            log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+            mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+            mErrorMsg = "Cannot create reply!";
+        }
+    }
+}
+
+void CAmControlDbusMessageHandler::append(const std::vector<am::am_SystemProperty_s>& listSystemProperties)
+{
+    DBusMessageIter arrayIter;
+    DBusMessageIter structIter;
+    std::vector<am::am_SystemProperty_s>::const_iterator listIterator = listSystemProperties.begin();
+    dbus_bool_t success = true;
+    success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(nn)", &arrayIter);
+    for (; listIterator < listSystemProperties.end(); ++listIterator)
+    {
+        success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->type);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->value);
+        success = success && dbus_message_iter_close_container(&arrayIter, &structIter);
+    }
+    success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter);
+    if (!success)
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+void CAmControlDbusMessageHandler::append(const am::am_Error_e error)
+{
+    if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_UINT16, &error))
+    {
+        log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!");
+        mErrorName = std::string(DBUS_ERROR_NO_MEMORY);
+        mErrorMsg = "Cannot create reply!";
+    }
+}
+
+}
diff --git a/PluginControlInterfaceDbus/src/CAmControlDbusSend.cpp b/PluginControlInterfaceDbus/src/CAmControlDbusSend.cpp
new file mode 100644 (file)
index 0000000..65546ff
--- /dev/null
@@ -0,0 +1,133 @@
+/**
+ *  Copyright (c) 2014 Intel
+ *  Copyright (c) copyright 2011-2012 Aricent® Group  and its licensors
+ *  Copyright (c) 2012 BMW
+ *
+ *  \author Jaska Uimonen
+ *  \author Sampreeth Ramavana
+ *  \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
+ *
+ *  \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.
+ *
+ *  For further information see http://www.genivi.org/.
+ */
+
+#include "CAmControlDbusSend.h"
+#include "shared/CAmDltWrapper.h"
+
+namespace am
+{
+
+CAmControlDbusSend::CAmControlDbusSend(DBusConnection* conn, std::string bus_name, std::string path, std::string interface, std::string method) :
+        mpDbusMessage(NULL), //
+        mpDbusConnection(conn), //
+        mDbusMessageIter(), //
+        mDBusError()
+{
+    dbus_error_init(&mDBusError);
+    mpDbusMessage = dbus_message_new_method_call(bus_name.c_str(), path.c_str(), interface.c_str(), method.c_str());
+    if (NULL == mpDbusMessage)
+    {
+        /* log(&controlDbus, DLT_LOG_ERROR, "CAmControlDbusSend::CAmControlDbusSend dbus error:", mDBusError.message); */
+        this->~CAmControlDbusSend();
+    }
+}
+
+CAmControlDbusSend::~CAmControlDbusSend()
+{
+}
+
+void CAmControlDbusSend::append(std::string string)
+{
+    dbus_message_iter_init_append(mpDbusMessage, &mDbusMessageIter);
+    if (!dbus_message_iter_append_basic(&mDbusMessageIter, DBUS_TYPE_STRING, string.c_str()))
+    {
+        /* log(&controlDbus, DLT_LOG_ERROR, "CAmControlDbusSend::append no more memory"); */
+        this->~CAmControlDbusSend();
+    }
+}
+
+void CAmControlDbusSend::append(uint16_t integer)
+{
+    dbus_message_iter_init_append(mpDbusMessage, &mDbusMessageIter);
+    if (!dbus_message_iter_append_basic(&mDbusMessageIter, DBUS_TYPE_UINT16, &integer))
+    {
+        /* log(&controlDbus, DLT_LOG_ERROR, "CAmControlDbusSend::append no more memory"); */
+        this->~CAmControlDbusSend();
+    }
+}
+
+void CAmControlDbusSend::append(int16_t integer)
+{
+    dbus_message_iter_init_append(mpDbusMessage, &mDbusMessageIter);
+    if (!dbus_message_iter_append_basic(&mDbusMessageIter, DBUS_TYPE_INT16, &integer))
+    {
+        /* log(&controlDbus, DLT_LOG_ERROR, "CAmControlDbusSend::append no more memory"); */
+        this->~CAmControlDbusSend();
+    }
+}
+
+void CAmControlDbusSend::append(std::vector<am_SoundProperty_s> listSoundProperties)
+{
+    DBusMessageIter arrayIter;
+    DBusMessageIter structIter;
+    std::vector<am_SoundProperty_s>::const_iterator listIterator = listSoundProperties.begin();
+    dbus_bool_t success = true;
+
+    success = success && dbus_message_iter_open_container(&mDbusMessageIter, DBUS_TYPE_ARRAY, "(nn)", &arrayIter);
+    for (; listIterator < listSoundProperties.end(); ++listIterator)
+    {
+        success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->type);
+        success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->value);
+        success = success && dbus_message_iter_close_container(&arrayIter, &structIter);
+    }
+    success = success && dbus_message_iter_close_container(&mDbusMessageIter, &arrayIter);
+
+    if (!success)
+    {
+        /* log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append error", mDBusError.message); */
+    }
+}
+
+void CAmControlDbusSend::append(am_SoundProperty_s soundProperty)
+{
+    DBusMessageIter structIter;
+    dbus_bool_t success = true;
+
+    success = success && dbus_message_iter_open_container(&mDbusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &soundProperty.type);
+    success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &soundProperty.value);
+    success = success && dbus_message_iter_close_container(&mDbusMessageIter, &structIter);
+
+    if (!success)
+    {
+        /* log(&controlDbus, DLT_LOG_ERROR, "DBusMessageHandler::append error", mDBusError.message); */
+    }
+}
+
+am_Error_e CAmControlDbusSend::send()
+{
+
+    int16_t error;
+    DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDbusConnection, mpDbusMessage, -1, &mDBusError));
+    if (!reply)
+    {
+        /* log(&controlDbus, DLT_LOG_ERROR, "CAmControlDbusSend::send failed, dbus error", mDBusError.message); */
+        return (E_UNKNOWN);
+    }
+    if(!dbus_message_get_args(reply, &mDBusError, //
+            DBUS_TYPE_INT16, &error, //
+            DBUS_TYPE_INVALID))
+        return (E_UNKNOWN);
+    dbus_message_unref(reply);
+    return (static_cast<am_Error_e>(error));
+}
+}
diff --git a/PluginControlInterfaceDbus/src/CAmControlSenderBase.cpp b/PluginControlInterfaceDbus/src/CAmControlSenderBase.cpp
new file mode 100644 (file)
index 0000000..910c08a
--- /dev/null
@@ -0,0 +1,937 @@
+/**
+ *  Copyright (c) 2014 Intel
+ *  Copyright (c) 2012 BMW
+ *
+ *  \author Jaska Uimonen
+ *  \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
+ *
+ *  \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.
+ *
+ *  For further information see http://www.genivi.org/.
+ */
+
+#include "CAmControlSenderBase.h"
+#include <cassert>
+#include <algorithm>
+#include "shared/CAmDltWrapper.h"
+#include "control/IAmControlReceive.h"
+
+namespace am
+{
+DLT_DECLARE_CONTEXT(controlDbus)
+
+extern "C" IAmControlSend* PluginControlInterfaceDbusFactory()
+{
+    CAmDltWrapper::instance()->registerContext(controlDbus, "DCS", "DBus Plugin");
+    return (new CAmControlSenderBase());
+}
+
+extern "C" void destroyControlPluginInterface(IAmControlSend* controlSendInterface)
+{
+    delete controlSendInterface;
+}
+
+CAmControlSenderBase::CAmControlSenderBase() :
+       mControlReceiveInterface(),
+       mpCAmDBusWrapper(),
+    mpDBusConnection(),
+    mCAmControlDBusMessageHandler(),
+    mIAmControlReceiverShadowDbus(mControlReceiveInterface),
+    mListOpenConnections(), //
+    mListOpenDisconnections(), //
+    mListOpenVolumeChanges(),//
+    mConnectSf (SFC_RAMP_DOWN), //
+    mNaviSf(NAVC_RAMP_DOWN), //
+    mTrafficSf(TA_RAMP_DOWN),//
+    mConnectData(), //
+    mStateflow(SF_NONE)
+{
+}
+
+CAmControlSenderBase::~CAmControlSenderBase()
+{
+}
+
+am_Error_e CAmControlSenderBase::startupController(IAmControlReceive *controlreceiveinterface)
+{
+    log(&controlDbus, DLT_LOG_INFO, "startupInterface called");
+
+    assert(controlreceiveinterface);
+    mControlReceiveInterface = controlreceiveinterface;
+    mIAmControlReceiverShadowDbus.setControlReceiver(controlreceiveinterface);
+    mControlReceiveInterface->getDBusConnectionWrapper(mpCAmDBusWrapper);
+    assert(mpCAmDBusWrapper!=NULL);
+    mpCAmDBusWrapper->getDBusConnection(mpDBusConnection);
+    assert(mpDBusConnection!=NULL);
+    mCAmControlDBusMessageHandler.setDBusConnection(mpDBusConnection);
+
+    return (E_OK);
+}
+
+void CAmControlSenderBase::setControllerReady()
+{
+    //here is a good place to insert Source and SinkClasses into the database...
+    mControlReceiveInterface->setRoutingReady();
+    mControlReceiveInterface->setCommandReady();
+}
+
+am_Error_e CAmControlSenderBase::hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t & mainConnectionID)
+{
+    std::vector<am_Route_s> listRoutes;
+    std::vector<am_connectionID_t> listConnectionIDs;
+    std::vector<am_MainConnection_s> listAllMainConnections;
+
+    if (mStateflow!=SF_NONE)
+        return (E_NOT_POSSIBLE);
+
+    mControlReceiveInterface->getRoute(false, sourceID, sinkID, listRoutes);
+    if (listRoutes.empty())
+        return (E_NOT_POSSIBLE);
+
+    mControlReceiveInterface->getListMainConnections(listAllMainConnections);
+
+    /* go through all connections */
+    std::vector<am_MainConnection_s>::iterator itAll(listAllMainConnections.begin());
+    for (; itAll != listAllMainConnections.end(); ++itAll)
+    {
+        if (itAll->sinkID == sinkID && itAll->sourceID == sourceID)
+            return (E_ALREADY_EXISTS);
+    }
+
+    am_MainConnection_s mainConnectionData;
+    mainConnectionData.mainConnectionID = 0;
+    mainConnectionData.sinkID = sinkID;
+    mainConnectionData.sourceID = sourceID;
+    mainConnectionData.connectionState = CS_CONNECTING;
+    mainConnectionData.delay = 0;
+
+    mControlReceiveInterface->enterMainConnectionDB(mainConnectionData, mainConnectionID);
+    mConnectData.newMainConnection=mainConnectionID;
+    mConnectData.sourceID=sourceID;
+    mConnectData.sinkID=sinkID;
+
+    connect(mConnectData.sourceID, mConnectData.sinkID, mConnectData.newMainConnection);
+
+    return (E_OK);
+}
+
+
+am_Error_e CAmControlSenderBase::hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID)
+{
+    if (mStateflow!=SF_NONE)
+        return (E_NOT_POSSIBLE);
+
+    disconnect(connectionID);
+
+    return (E_OK);
+}
+
+am_Error_e CAmControlSenderBase::hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s & soundProperty)
+{
+    if (mStateflow!=SF_NONE)
+        return (E_NOT_POSSIBLE);
+
+    if (sinkID == 0)
+        return (E_NON_EXISTENT);
+
+    mainSinkSoundPropertySet set;
+    set.sinkID = sinkID;
+    set.mainSoundProperty = soundProperty;
+    am_SoundProperty_s sp;
+    std::vector<mainSinkSoundPropertySet>::iterator it(mListMainSoundPropertyChanges.begin());
+    for (; it != mListMainSoundPropertyChanges.end(); ++it)
+    {
+        if (it->sinkID == sinkID)
+            return E_NOT_POSSIBLE;
+    }
+
+    //I know this is bad - just for the reference, ok?
+    sp.type = static_cast<am_SoundPropertyType_e>(soundProperty.type);
+    sp.value = (soundProperty.value - 5) * 30;
+    am_Error_e error;
+    if ((error = mControlReceiveInterface->setSinkSoundProperty(set.handle, sinkID, sp)) != E_OK)
+    {
+        return error;
+    }
+    mListMainSoundPropertyChanges.push_back(set);
+    return E_OK;
+}
+
+am_Error_e CAmControlSenderBase::hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s & soundProperty)
+{
+    (void) sourceID;
+    (void) soundProperty;
+    return E_NOT_USED;
+}
+
+am_Error_e CAmControlSenderBase::hookUserSetSystemProperty(const am_SystemProperty_s & property)
+{
+    (void) property;
+    return E_NOT_USED;
+}
+
+am_Error_e CAmControlSenderBase::hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume)
+{
+    if (mStateflow!=SF_NONE)
+        return (E_NOT_POSSIBLE);
+
+    assert(SinkID!=0);
+    mainVolumeSet set;
+    set.sinkID = SinkID;
+    set.mainVolume = newVolume;
+    am_Error_e error;
+
+    std::vector<mainVolumeSet>::iterator it(mListOpenVolumeChanges.begin());
+    for (; it != mListOpenVolumeChanges.end(); ++it)
+    {
+        if (it->sinkID == SinkID)
+            return E_NOT_POSSIBLE;
+    }
+
+    am_Sink_s sinkData;
+    mControlReceiveInterface->getSinkInfoDB(SinkID, sinkData);
+
+    if (sinkData.mainVolume == newVolume)
+        return E_NO_CHANGE;
+
+    if ((error = mControlReceiveInterface->setSinkVolume(set.handle, SinkID, (newVolume-10)*6, RAMP_UNKNOWN, 20)) != E_OK)
+    {
+        return error;
+    }
+    mListOpenVolumeChanges.push_back(set);
+    return E_OK;
+}
+
+am_Error_e CAmControlSenderBase::hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment)
+{
+    if (mStateflow!=SF_NONE)
+        return (E_NOT_POSSIBLE);
+
+    assert(SinkID!=0);
+    mainVolumeSet set;
+    set.sinkID = SinkID;
+    am_Error_e error;
+    am_Sink_s sink;
+    std::vector<mainVolumeSet>::iterator it(mListOpenVolumeChanges.begin());
+    for (; it != mListOpenVolumeChanges.end(); ++it)
+    {
+        if (it->sinkID == SinkID)
+            return E_NOT_POSSIBLE;
+    }
+    mControlReceiveInterface->getSinkInfoDB(SinkID, sink);
+    set.mainVolume = sink.mainVolume + increment;
+    if ((error = mControlReceiveInterface->setSinkVolume(set.handle, SinkID, (set.mainVolume-10)*6, RAMP_UNKNOWN, 20)) != E_OK)
+    {
+        return error;
+    }
+    mListOpenVolumeChanges.push_back(set);
+    return E_OK;
+}
+
+am_Error_e CAmControlSenderBase::hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState)
+{
+    if (mStateflow!=SF_NONE)
+        return (E_NOT_POSSIBLE);
+
+    assert(sinkID!=0);
+
+    mainVolumeSet set;
+    set.sinkID = sinkID;
+    am_Error_e error;
+    am_Sink_s sink;
+    mControlReceiveInterface->getSinkInfoDB(sinkID, sink);
+
+    if (muteState == MS_MUTED)
+    {
+        set.mainVolume = sink.mainVolume;
+        if ((error = mControlReceiveInterface->setSinkVolume(set.handle, sinkID, 0, RAMP_GENIVI_DIRECT, 20)) != E_OK)
+        {
+            return error;
+        }
+    }
+    else
+    {
+        set.mainVolume = sink.mainVolume;
+        if ((error = mControlReceiveInterface->setSinkVolume(set.handle, sinkID, set.mainVolume, RAMP_GENIVI_DIRECT, 20)) != E_OK)
+        {
+            return error;
+        }
+    }
+    mListOpenVolumeChanges.push_back(set);
+    mControlReceiveInterface->changeSinkMuteStateDB(muteState, sinkID);
+    return (E_OK);
+}
+
+am_Error_e CAmControlSenderBase::hookSystemRegisterDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
+{
+//this application does not do anything with it -> but some product might want to take influence here
+    return mControlReceiveInterface->enterDomainDB(domainData, domainID);
+}
+
+am_Error_e CAmControlSenderBase::hookSystemDeregisterDomain(const am_domainID_t domainID)
+{
+//this application does not do anything with it -> but some product might want to take influence here
+    return mControlReceiveInterface->removeDomainDB(domainID);
+}
+
+void CAmControlSenderBase::hookSystemDomainRegistrationComplete(const am_domainID_t domainID)
+{
+    (void) domainID;
+}
+
+am_Error_e CAmControlSenderBase::hookSystemRegisterSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
+{
+//this application does not do anything with it -> but some product might want to take influence here
+    return mControlReceiveInterface->enterSinkDB(sinkData, sinkID);
+}
+
+am_Error_e CAmControlSenderBase::hookSystemDeregisterSink(const am_sinkID_t sinkID)
+{
+    logInfo("CAmControlSenderBase::hookSystemDeregisterSink() was called", sinkID);
+
+    std::vector<am_connectionID_t> listConnectionIDs;
+    std::vector<am_MainConnection_s> listAllMainConnections;
+    bool found = false;
+
+    mControlReceiveInterface->getListMainConnections(listAllMainConnections);
+
+    /* find possible connection */
+    std::vector<am_MainConnection_s>::iterator itAll(listAllMainConnections.begin());
+    for (; itAll != listAllMainConnections.end(); ++itAll)
+    {
+        if (itAll->sinkID == sinkID) {
+            found = true;
+            break;
+        }
+    }
+
+    if (found)
+        mControlReceiveInterface->removeMainConnectionDB(itAll->mainConnectionID);
+
+    return mControlReceiveInterface->removeSinkDB(sinkID);
+}
+
+am_Error_e CAmControlSenderBase::hookSystemRegisterSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
+{
+//this application does not do anything with it -> but some product might want to take influence here
+    return mControlReceiveInterface->enterSourceDB(sourceData, sourceID);
+}
+
+am_Error_e CAmControlSenderBase::hookSystemDeregisterSource(const am_sourceID_t sourceID)
+{
+    logInfo("CAmControlSenderBase::hookSystemDeregisterSource() was called", sourceID);
+
+    std::vector<am_connectionID_t> listConnectionIDs;
+    std::vector<am_MainConnection_s> listAllMainConnections;
+    bool found = false;
+
+    mControlReceiveInterface->getListMainConnections(listAllMainConnections);
+
+    /* find possible connection */
+    std::vector<am_MainConnection_s>::iterator itAll(listAllMainConnections.begin());
+    for (; itAll != listAllMainConnections.end(); ++itAll)
+    {
+        if (itAll->sourceID == sourceID) {
+            found = true;
+            break;
+        }
+    }
+
+    if (found)
+        mControlReceiveInterface->removeMainConnectionDB(itAll->mainConnectionID);
+
+    return mControlReceiveInterface->removeSourceDB(sourceID);
+}
+
+am_Error_e CAmControlSenderBase::hookSystemRegisterGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
+{
+//this application does not do anything with it -> but some product might want to take influence here
+    return mControlReceiveInterface->enterGatewayDB(gatewayData, gatewayID);
+}
+
+am_Error_e CAmControlSenderBase::hookSystemDeregisterGateway(const am_gatewayID_t gatewayID)
+{
+//this application does not do anything with it -> but some product might want to take influence here
+    return mControlReceiveInterface->removeGatewayDB(gatewayID);
+}
+
+am_Error_e CAmControlSenderBase::hookSystemRegisterCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
+{
+//this application does not do anything with it -> but some product might want to take influence here
+    return mControlReceiveInterface->enterCrossfaderDB(crossfaderData, crossfaderID);
+}
+
+am_Error_e CAmControlSenderBase::hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID)
+{
+//this application does not do anything with it -> but some product might want to take influence here
+    return mControlReceiveInterface->removeCrossfaderDB(crossfaderID);
+}
+
+void CAmControlSenderBase::hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
+{
+    (void) handle;
+    (void) sinkID;
+    (void) volume;
+}
+
+void CAmControlSenderBase::hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
+{
+    (void) handle;
+    (void) sourceID;
+    (void) volume;
+}
+
+void CAmControlSenderBase::hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
+{
+    (void) sourceID;
+    (void) interruptState;
+}
+
+void CAmControlSenderBase::hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
+{
+    (void) sinkID;
+    (void) availability;
+}
+
+void CAmControlSenderBase::hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
+{
+    (void) sourceID;
+    (void) availability;
+}
+
+void CAmControlSenderBase::hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state)
+{
+    (void) domainID;
+    (void) state;
+}
+
+void CAmControlSenderBase::hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s> & data)
+{
+    (void) data;
+}
+
+void CAmControlSenderBase::hookSystemSpeedChange(const am_speed_t speed)
+{
+    (void) speed;
+}
+void CAmControlSenderBase::hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)
+{
+    (void) mainConnectionID;
+    (void) time;
+}
+
+void CAmControlSenderBase::cbAckConnect(const am_Handle_s handle, const am_Error_e errorID)
+{
+    (void) errorID;
+//\todo:error checking
+    std::vector<mainConnectionSet>::iterator it(mListOpenConnections.begin());
+    for (; it != mListOpenConnections.end(); ++it)
+    {
+        std::vector<handleStatus>::iterator hit;
+        handleStatus status;
+        status.status = true;
+        status.handle = handle;
+        hit = std::find_if(it->listHandleStaus.begin(), it->listHandleStaus.end(), findHandle(status));
+        if (hit == it->listHandleStaus.end())
+            continue;
+        hit->status = true;
+        if (it->listHandleStaus.end() == std::find_if(it->listHandleStaus.begin(), it->listHandleStaus.end(), checkHandle(status)))
+        {
+            mControlReceiveInterface->changeMainConnectionStateDB(it->connectionID, CS_CONNECTED);
+            mListOpenConnections.erase(it);
+            break;
+        }
+    }
+    callStateFlowHandler();
+}
+
+void CAmControlSenderBase::cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID)
+{
+    (void) errorID;
+//\todo:error checking
+    std::vector<mainConnectionSet>::iterator it(mListOpenDisconnections.begin());
+    for (; it != mListOpenDisconnections.end(); ++it)
+    {
+        std::vector<handleStatus>::iterator hit;
+        handleStatus status;
+        status.status = true;
+        status.handle = handle;
+        hit = std::find_if(it->listHandleStaus.begin(), it->listHandleStaus.end(), findHandle(status));
+        if (hit == it->listHandleStaus.end())
+            continue;
+        hit->status = true;
+        if (it->listHandleStaus.end() == std::find_if(it->listHandleStaus.begin(), it->listHandleStaus.end(), checkHandle(status)))
+        {
+            mControlReceiveInterface->removeMainConnectionDB(it->connectionID);
+            mListOpenDisconnections.erase(it);
+            break;
+        }
+    }
+    callStateFlowHandler();
+}
+
+void CAmControlSenderBase::cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error)
+{
+    (void) handle;
+    (void) hostsink;
+    (void) error;
+}
+
+void CAmControlSenderBase::cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
+{
+    (void) error;
+    (void) volume;
+    //\todo:error checking
+    std::vector<mainVolumeSet>::iterator it(mListOpenVolumeChanges.begin());
+    for (; it != mListOpenVolumeChanges.end(); ++it)
+    {
+        if (handle.handle == it->handle.handle)
+        {
+            mControlReceiveInterface->changeSinkMainVolumeDB(it->mainVolume, it->sinkID);
+            mListOpenVolumeChanges.erase(it);
+            break;
+        }
+    }
+    callStateFlowHandler();
+}
+
+void CAmControlSenderBase::cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error)
+{
+    (void) error;
+    (void) voulme;
+    (void) handle;
+    callStateFlowHandler();
+}
+
+void CAmControlSenderBase::cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error)
+{
+    (void) error;
+    (void) handle;
+    callStateFlowHandler();
+}
+
+void CAmControlSenderBase::cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
+{
+    (void) error;
+    (void) handle;
+}
+
+void CAmControlSenderBase::cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
+{
+    (void) error;
+//\todo:error checking
+    std::vector<mainSinkSoundPropertySet>::iterator it(mListMainSoundPropertyChanges.begin());
+    for (; it != mListMainSoundPropertyChanges.end(); ++it)
+    {
+        if (handle.handle == it->handle.handle)
+        {
+            mControlReceiveInterface->changeMainSinkSoundPropertyDB(it->mainSoundProperty, it->sinkID);
+            mListMainSoundPropertyChanges.erase(it);
+            break;
+        }
+    }
+}
+
+void CAmControlSenderBase::cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error)
+{
+    (void) error;
+    (void) handle;
+}
+
+void CAmControlSenderBase::cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error)
+{
+    (void) error;
+    (void) handle;
+}
+
+void CAmControlSenderBase::setControllerRundown(const int16_t signal)
+{
+    logInfo("CAmControlSenderBase::setControllerRundown() was called signal=",signal);
+    if (signal==2)
+        mControlReceiveInterface->confirmControllerRundown(E_UNKNOWN);
+
+    mControlReceiveInterface->confirmControllerRundown(E_OK);
+}
+
+am_Error_e CAmControlSenderBase::getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector<am_ConnectionFormat_e> listPossibleConnectionFormats, std::vector<am_ConnectionFormat_e> & listPrioConnectionFormats)
+{
+    (void) sourceID;
+    (void) sinkID;
+    (void) listRoute;
+//ok, this is cheap. In a real product you have your preferences, right?
+    listPrioConnectionFormats = listPossibleConnectionFormats;
+    return (E_OK);
+}
+
+void CAmControlSenderBase::getInterfaceVersion(std::string & version) const
+{
+    version = ControlSendVersion;
+}
+
+
+void CAmControlSenderBase::disconnect(am_mainConnectionID_t connectionID)
+{
+    am_MainConnection_s mainConnection;
+    am_Error_e error;
+    std::vector<handleStatus> listHandleStaus;
+    mainConnectionSet set;
+
+    if ((error = mControlReceiveInterface->getMainConnectionInfoDB(connectionID, mainConnection)) != E_OK)
+    {
+            logError("CAmControlSenderBase::disconnect Could not getInfor for mainconnection Error: ", error);
+            return;
+    }
+
+    std::vector<am_connectionID_t>::iterator it(mainConnection.listConnectionID.begin());
+
+    for (; it != mainConnection.listConnectionID.end(); ++it)
+    {
+        handleStatus status;
+        status.status = false;
+        if ((error = mControlReceiveInterface->disconnect(status.handle, *it)))
+        {
+            logError("Could not disconnect, Error", error);
+        }
+        listHandleStaus.push_back(status);
+    }
+
+    set.connectionID = connectionID;
+    set.listHandleStaus = listHandleStaus;
+    mListOpenDisconnections.push_back(set);
+}
+
+void CAmControlSenderBase::connect(am_sourceID_t sourceID, am_sinkID_t sinkID, am_mainConnectionID_t mainConnectionID)
+{
+    std::vector<am_Route_s> listRoutes;
+    std::vector<am_connectionID_t> listConnectionIDs;
+    am_Handle_s handle;
+    std::vector<handleStatus> listHandleStaus;
+    mainConnectionSet set;
+
+    mControlReceiveInterface->getRoute(false, sourceID, sinkID, listRoutes);
+
+    if (listRoutes.empty())
+        logError("CAmControlSenderBase::connect not possible");
+
+    std::vector<am_RoutingElement_s>::iterator it(listRoutes[0].route.begin());
+
+    for (; it != listRoutes[0].route.end(); ++it)
+    {
+        am_connectionID_t connectionID;
+        mControlReceiveInterface->connect(handle, connectionID, it->connectionFormat, it->sourceID, it->sinkID);
+        handleStatus status;
+        status.handle = handle;
+        status.status = false;
+        listHandleStaus.push_back(status);
+        listConnectionIDs.push_back(connectionID);
+    }
+
+    set.connectionID = mainConnectionID;
+    set.listHandleStaus = listHandleStaus;
+    mControlReceiveInterface->changeMainConnectionRouteDB(mainConnectionID,listConnectionIDs);
+    mListOpenConnections.push_back(set);
+}
+
+void CAmControlSenderBase::callStateFlowHandler()
+{
+    logInfo("CAmControlSenderBase::callStateFlowHandler() called, state ",mStateflow);
+
+    switch(mStateflow)
+    {
+    case SF_CONNECT:
+        callConnectHandler();
+        break;
+    case SF_TA:
+        callTAHandler();
+        break;
+    case SF_NAVI:
+        callNaviHandler();
+        break;
+    default:
+        break;
+
+    }
+}
+
+void CAmControlSenderBase::callConnectHandler()
+{
+    logInfo("CAmControlSenderBase::callConnectHandler() called, state ",mConnectSf);
+
+    am_Handle_s handle;
+    am_Sink_s sinkData;
+    switch (mConnectSf)
+    {
+    case SFC_RAMP_DOWN:
+        mControlReceiveInterface->setSinkVolume(handle, mConnectData.sinkID, -60, RAMP_GENIVI_EXP_INV, 4000);
+        mConnectSf = SFC_SOURCE_STATE_OFF;
+        break;
+    case SFC_SOURCE_STATE_OFF:
+        mControlReceiveInterface->setSourceState(handle, mConnectData.oldSourceID, SS_OFF);
+        mConnectSf = SFC_DISCONNECT;
+        break;
+    case SFC_DISCONNECT:
+        disconnect(mConnectData.currentMainConnection);
+        mConnectSf = SFC_CONNECT;
+        break;
+    case SFC_CONNECT:
+        connect(mConnectData.sourceID, mConnectData.sinkID, mConnectData.newMainConnection);
+        mConnectSf = SFC_SOURCE_STATE_ON;
+        break;
+    case SFC_SOURCE_STATE_ON:
+        mControlReceiveInterface->setSourceState(handle, mConnectData.sourceID, SS_ON);
+        mConnectSf = SFC_RAMP_UP;
+        break;
+    case SFC_RAMP_UP:
+        mControlReceiveInterface->getSinkInfoDB(mConnectData.sinkID, sinkData);
+        if (mControlReceiveInterface->setSinkVolume(handle, mConnectData.sinkID, (sinkData.mainVolume-10)*6, RAMP_GENIVI_EXP_INV, 4000)==E_NO_CHANGE)
+            mStateflow=SF_NONE;
+        mConnectSf=SFC_FINISHED;
+        break;
+    case SFC_FINISHED:
+        mStateflow=SF_NONE;
+        break;
+    default:
+        break;
+    }
+}
+
+void CAmControlSenderBase::callNaviHandler()
+{
+    logInfo("CAmControlSenderBase::callNaviHandler() called, state ",mConnectSf);
+
+       am_Handle_s handle;
+       am_Source_s sourceData;
+       am_Sink_s sinkData;
+       switch (mNaviSf)
+       {
+       case NAVC_RAMP_DOWN:
+           mControlReceiveInterface->setSourceVolume(handle, mConnectData.oldSourceID, -13, RAMP_UNKNOWN, 2000);
+           mNaviSf = NAVC_CONNECT;
+           break;
+       case NAVC_CONNECT:
+           connect(mConnectData.sourceID, mConnectData.sinkID, mConnectData.newMainConnection);
+           mNaviSf = NAVC_SOURCE_STATE_ON;
+           break;
+       case NAVC_SOURCE_STATE_ON:
+           mControlReceiveInterface->setSourceState(handle, mConnectData.sourceID, SS_ON);
+           mNaviSf = NAVC_RAMP_UP;
+           break;
+       case NAVC_RAMP_UP:
+           mControlReceiveInterface->getSinkInfoDB(mConnectData.sinkID, sinkData);
+           mControlReceiveInterface->setSinkVolume(handle, mConnectData.sinkID, (sinkData.mainVolume-10)*60+2, RAMP_UNKNOWN, 2000);
+           mNaviSf=NAVC_WAIT_STATE;
+           break;
+       case NAVC_WAIT_STATE:
+           mNaviSf=NAVC_RAMP_DOWN_AGAIN;
+           break;
+       case NAVC_RAMP_DOWN_AGAIN:
+           mControlReceiveInterface->setSinkVolume(handle, mConnectData.sinkID, (sinkData.mainVolume-10)*60, RAMP_UNKNOWN, 2000);
+           mNaviSf=NAVC_SOURCE_VOLUME_BACK;
+           break;
+       case NAVC_SOURCE_VOLUME_BACK:
+           mControlReceiveInterface->setSourceVolume(handle, mConnectData.oldSourceID, 0, RAMP_UNKNOWN, 2000);
+           mNaviSf=NAVC_SOURCE_ACTIVITY_BACK;
+           break;
+       case NAVC_SOURCE_ACTIVITY_BACK:
+           mControlReceiveInterface->setSourceState(handle, mConnectData.sourceID, SS_OFF);
+           mNaviSf=NAVC_DISCONNECT;
+           break;
+       case NAVC_DISCONNECT:
+           disconnect(mConnectData.newMainConnection);
+           mNaviSf=NAVC_FINISHED;
+           break;
+       case NAVC_FINISHED:
+           mStateflow=SF_NONE;
+           break;
+       default:
+           break;
+       }
+}
+
+void CAmControlSenderBase::confirmCommandReady(const am_Error_e error)
+{
+    (void) error;
+    logInfo("ControlSenderPlugin got Command Ready confirmed");
+}
+
+void CAmControlSenderBase::confirmRoutingReady(const am_Error_e error)
+{
+    (void)error;
+    logInfo("ControlSenderPlugin got Routing Ready confirmed");
+}
+
+void CAmControlSenderBase::confirmCommandRundown(const am_Error_e error)
+{
+    (void)error;
+       logInfo("ControlSenderPlugin got Command Rundown confirmed");
+}
+
+void CAmControlSenderBase::confirmRoutingRundown(const am_Error_e error)
+{
+    (void)error;
+       logInfo("ControlSenderPlugin got Routing Rundown confirmed");
+}
+
+void CAmControlSenderBase::hookSystemNodeStateChanged(const NsmNodeState_e NodeStateId)
+{
+    (void) NodeStateId;
+    //here you can process informations about the notestate
+}
+
+void CAmControlSenderBase::hookSystemNodeApplicationModeChanged(const NsmApplicationMode_e ApplicationModeId)
+{
+    (void) ApplicationModeId;
+}
+
+
+void CAmControlSenderBase::cbAckSetSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error)
+{
+    (void) handle;
+    (void) error;
+}
+
+void CAmControlSenderBase::cbAckSetSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error)
+{
+    (void) handle;
+    (void) error;
+}
+
+
+NsmErrorStatus_e CAmControlSenderBase::hookSystemLifecycleRequest(const uint32_t Request, const uint32_t RequestId)
+{
+    (void) Request;
+    (void) RequestId;
+    logInfo("CAmControlSenderBase::hookSystemLifecycleRequest request=",Request," requestID=",RequestId);
+    return (NsmErrorStatus_Error);
+}
+
+am_Error_e CAmControlSenderBase::hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+{
+    (void) sinkID;
+    (void) sinkClassID;
+    (void) listMainSoundProperties;
+    (void) listConnectionFormats;
+    (void) listSoundProperties;
+    return (E_NOT_USED);
+}
+
+am_Error_e CAmControlSenderBase::hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+{
+    (void) sourceID;
+    (void) sourceClassID;
+    (void) listSoundProperties;
+    (void) listMainSoundProperties;
+    (void) listConnectionFormats;
+    return (E_NOT_USED);
+}
+
+am_Error_e CAmControlSenderBase::hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector<am_ConnectionFormat_e>& listSourceConnectionFormats, const std::vector<am_ConnectionFormat_e>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix)
+{
+    (void) gatewayID;
+    (void) listSourceConnectionFormats;
+    (void) listSinkConnectionFormats;
+    (void) convertionMatrix;
+    return (E_NOT_USED);
+}
+
+void CAmControlSenderBase::cbAckSetVolumes(const am_Handle_s handle, const std::vector<am_Volumes_s>& listVolumes, const am_Error_e error)
+{
+    (void) handle;
+    (void) listVolumes;
+    (void) error;
+}
+
+void CAmControlSenderBase::hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s& payload)
+{
+    (void) sinkID;
+    (void) payload;
+}
+
+void CAmControlSenderBase::hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s& payload)
+{
+    (void) sourceID;
+    (void) payload;
+}
+
+am_Error_e CAmControlSenderBase::hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration)
+{
+    (void) sinkID;
+    (void) notificationConfiguration;
+    return (E_NOT_USED);
+}
+
+am_Error_e CAmControlSenderBase::hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration)
+{
+    (void) sourceID;
+    (void) notificationConfiguration;
+    return (E_NOT_USED);
+}
+
+void CAmControlSenderBase::hookSystemSessionStateChanged(const std::string& sessionName, const NsmSeat_e seatID, const NsmSessionState_e sessionStateID)
+{
+    (void) sessionName;
+    (void) seatID;
+    (void) sessionStateID;
+}
+
+void CAmControlSenderBase::callTAHandler()
+{
+    logInfo("CAmControlSenderBase::callTAHandler() called, state ",mConnectSf);
+
+       am_Handle_s handle;
+       am_Source_s sourceData;
+       am_Sink_s sinkData;
+       switch (mTrafficSf)
+       {
+       case TA_RAMP_DOWN:
+           mControlReceiveInterface->setSourceState(handle, mConnectData.oldSourceID, SS_PAUSED);
+           mTrafficSf = TA_CONNECT;
+           break;
+       case TA_CONNECT:
+           connect(mConnectData.sourceID, mConnectData.sinkID, mConnectData.newMainConnection);
+           mTrafficSf = TA_SOURCE_STATE_ON;
+           break;
+       case TA_SOURCE_STATE_ON:
+           mControlReceiveInterface->setSourceState(handle, mConnectData.sourceID, SS_ON);
+           mTrafficSf = TA_RAMP_UP;
+           break;
+       case TA_RAMP_UP:
+           mControlReceiveInterface->getSinkInfoDB(mConnectData.sinkID, sinkData);
+           mControlReceiveInterface->setSinkVolume(handle, mConnectData.sinkID, (sinkData.mainVolume-10)*60+2, RAMP_UNKNOWN, 2000);
+           mTrafficSf=TA_WAIT_STATE;
+           break;
+       case TA_WAIT_STATE:
+           mTrafficSf=TA_RAMP_DOWN_AGAIN;
+           break;
+       case TA_RAMP_DOWN_AGAIN:
+           mControlReceiveInterface->setSinkVolume(handle, mConnectData.sinkID, (sinkData.mainVolume-10)*60, RAMP_UNKNOWN, 2000);
+           mTrafficSf=TA_SOURCE_STATE_OFF;
+           break;
+       case TA_SOURCE_STATE_OFF:
+           mControlReceiveInterface->setSourceState(handle, mConnectData.oldSourceID, SS_ON);
+           mTrafficSf=TA_SOURCE_STATE_OLD_OFF;
+           break;
+       case TA_SOURCE_STATE_OLD_OFF:
+           mControlReceiveInterface->setSourceState(handle, mConnectData.sourceID, SS_OFF);
+           mTrafficSf=TA_DISCONNECT;
+           break;
+       case TA_DISCONNECT:
+           disconnect(mConnectData.newMainConnection);
+           mTrafficSf=TA_FINISHED;
+           break;
+       case TA_FINISHED:
+           mStateflow=SF_NONE;
+           break;
+       default:
+           break;
+       }
+}
+
+}
diff --git a/PluginControlInterfaceDbus/src/IAmControlReceiverShadow.cpp b/PluginControlInterfaceDbus/src/IAmControlReceiverShadow.cpp
new file mode 100644 (file)
index 0000000..3ea541e
--- /dev/null
@@ -0,0 +1,746 @@
+/**
+ *  Copyright (c) 2014 Intel
+ *  Copyright (c) 2012 BMW
+ *
+ *  \author Jaska Uimonen
+ *  \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
+ *
+ *  \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.
+ *
+ *  For further information see http://www.genivi.org/.
+ */
+
+#include "IAmControlReceiverDbusShadow.h"
+#include "control/IAmControlReceive.h"
+
+#include <string.h>
+#include <fstream>
+#include <stdexcept>
+#include <cassert>
+#include "shared/CAmDbusWrapper.h"
+#include "shared/CAmDltWrapper.h"
+#include "configControlDbus.h"
+
+namespace am
+{
+
+DLT_IMPORT_CONTEXT(controlDbus)
+
+/**
+ * static ObjectPathTable is needed for DBus Callback handling
+ */
+static DBusObjectPathVTable gObjectPathVTable;
+
+IAmControlReceiverDbusShadow::IAmControlReceiverDbusShadow(IAmControlReceive *iReceiveInterface) :
+        mpIAmControlReceiver(iReceiveInterface),
+        mDBusWrapper(NULL),
+        mFunctionMap(createMap()),
+        mDBUSMessageHandler(),
+        mHandle(0)
+{
+}
+
+IAmControlReceiverDbusShadow::~IAmControlReceiverDbusShadow()
+{
+
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getRoute(bool onlyfree, am_sourceID_t sourceID, am_sinkID_t sinkID, std::vector<am_Route_s> & returnList)
+{
+    am_Error_e error = E_OK;
+    mpIAmControlReceiver->getRoute(onlyfree, sourceID, sinkID, returnList);
+    return (error);
+}
+
+void IAmControlReceiverDbusShadow::connect(DBusConnection *conn, DBusMessage *msg)
+{
+    (void) ((conn));
+    assert(mpIAmControlReceiver != NULL);
+    mDBUSMessageHandler.initReceive(msg);
+    am_mainConnectionID_t id;
+    am_ConnectionFormat_e format = (am_ConnectionFormat_e)mDBUSMessageHandler.getInt();
+    am_sourceID_t sourceID = mDBUSMessageHandler.getUInt();
+    am_sinkID_t sinkID = mDBUSMessageHandler.getUInt();
+
+    am_Error_e returnCode = autoConnectionRequest(sourceID, sinkID, id);
+
+    mDBUSMessageHandler.initReply(msg);
+    mDBUSMessageHandler.append(returnCode);
+    mDBUSMessageHandler.sendMessage();
+}
+
+
+void IAmControlReceiverDbusShadow::disconnect(DBusConnection *conn, DBusMessage *msg)
+{
+       (void)((conn));
+
+    bool found = false;
+    am_Handle_s handle;
+    am_connectionID_t connectionID;
+    am_sourceID_t sourceID;
+    am_sinkID_t sinkID;
+       am_Error_e error;
+    std::vector<am_MainConnection_s> listAllMainConnections;
+
+    assert(mpIAmControlReceiver != NULL);
+    mDBUSMessageHandler.initReceive(msg);
+
+    connectionID = mDBUSMessageHandler.getUInt();
+    sourceID= mDBUSMessageHandler.getUInt();
+    sinkID = mDBUSMessageHandler.getUInt();
+
+    mpIAmControlReceiver->getListMainConnections(listAllMainConnections);
+
+    // find the connection
+    std::vector<am_MainConnection_s>::iterator itAll(listAllMainConnections.begin());
+    for (; itAll != listAllMainConnections.end(); ++itAll)
+    {
+        if (itAll->sinkID == sinkID && itAll->sourceID == sourceID) {
+            found = true;
+            continue;
+        }
+    }
+
+    if (!found)
+        return;
+
+    error = removeMainConnectionDB(itAll->mainConnectionID);
+
+    mDBUSMessageHandler.initReply(msg);
+    mDBUSMessageHandler.append(error);
+    mDBUSMessageHandler.sendMessage();
+}
+
+am_Error_e IAmControlReceiverDbusShadow::crossfade(am_Handle_s & handle, am_HotSink_e hotSource, am_crossfaderID_t crossfaderID, am_RampType_e rampType, am_time_t rampTime)
+{
+       (void)handle;
+       (void)hotSource;
+       (void)crossfaderID;
+       (void)rampType;
+       (void)rampTime;
+
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::abortAction(am_Handle_s handle)
+{
+       (void)handle;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::setSourceState(am_Handle_s & handle, am_sourceID_t sourceID, am_SourceState_e state)
+{
+       (void)handle;
+       (void)sourceID;
+       (void)state;
+       am_Error_e error = E_OK;
+    return (error);
+
+}
+
+am_Error_e IAmControlReceiverDbusShadow::setSinkVolume(am_Handle_s & handle, am_sinkID_t sinkID, am_volume_t volume, am_RampType_e ramp, am_time_t time)
+{
+       (void)handle;
+       (void)sinkID;
+       (void)volume;
+       (void)ramp;
+       (void)time;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::setSourceVolume(am_Handle_s & handle, am_sourceID_t sourceID, am_volume_t volume, am_RampType_e rampType, am_time_t time)
+{
+       (void)handle;
+       (void)sourceID;
+       (void)volume;
+       (void)rampType;
+       (void)time;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::setSinkSoundProperties(am_Handle_s & handle, am_sinkID_t sinkID, std::vector<am_SoundProperty_s> & soundProperty)
+{
+       (void)handle;
+       (void)sinkID;
+       (void)soundProperty;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::setSinkSoundProperty(am_Handle_s & handle, am_sinkID_t sinkID, am_SoundProperty_s & soundProperty)
+{
+       (void)handle;
+       (void)sinkID;
+       (void)soundProperty;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::setSourceSoundProperties(am_Handle_s & handle, am_sourceID_t sourceID, std::vector<am_SoundProperty_s> & soundProperty)
+{
+       (void)handle;
+       (void)sourceID;
+       (void)soundProperty;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::setSourceSoundProperty(am_Handle_s & handle, am_sourceID_t sourceID, am_SoundProperty_s & soundProperty)
+{
+       (void)handle;
+       (void)sourceID;
+       (void)soundProperty;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::setDomainState(am_domainID_t domainID, am_DomainState_e domainState)
+{
+       (void)domainID;
+       (void)domainState;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::enterDomainDB(am_Domain_s & domainData, am_domainID_t & domainID)
+{
+       (void)domainData;
+       (void)domainID;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::enterMainConnectionDB(am_MainConnection_s & mainConnectionData, am_mainConnectionID_t & connectionID)
+{
+       (void)mainConnectionData;
+       (void)connectionID;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::enterSinkDB(am_Sink_s & sinkData, am_sinkID_t & sinkID)
+{
+       (void)sinkData;
+       (void)sinkID;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::enterCrossfaderDB(am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
+{
+       (void)crossfaderData;
+       (void)crossfaderID;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::enterGatewayDB(am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
+{
+       (void)gatewayData;
+       (void)gatewayID;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::enterSourceDB(am_Source_s & sourceData, am_sourceID_t & sourceID)
+{
+       (void)sourceData;
+       (void)sourceID;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::enterSinkClassDB(am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID)
+{
+       (void)sinkClass;
+       (void)sinkClassID;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::enterSourceClassDB(am_sourceClass_t & sourceClassID, am_SourceClass_s & sourceClass)
+{
+       (void)sourceClassID;
+       (void)sourceClass;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::changeSinkClassInfoDB(am_SinkClass_s & sinkClass)
+{
+       (void)sinkClass;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::changeSourceClassInfoDB(am_SourceClass_s & sourceClass)
+{
+       (void)sourceClass;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::enterSystemPropertiesListDB(std::vector<am_SystemProperty_s> & listSystemProperties)
+{
+       (void)listSystemProperties;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::changeMainConnectionRouteDB(am_mainConnectionID_t mainconnectionID, std::vector<am_connectionID_t> & listConnectionID)
+{
+       (void)mainconnectionID;
+       (void)listConnectionID;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::changeMainConnectionStateDB(am_mainConnectionID_t mainconnectionID, am_ConnectionState_e connectionState)
+{
+       (void)mainconnectionID;
+       (void)connectionState;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::changeSinkMainVolumeDB(am_mainVolume_t mainVolume, am_sinkID_t sinkID)
+{
+       (void)mainVolume;
+       (void)sinkID;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections)
+{
+       (void)listMainConnections;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListDomains(std::vector<am_Domain_s> & listDomains)
+{
+       (void)listDomains;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListConnections(std::vector<am_Connection_s> & listConnections)
+{
+       (void)listConnections;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListSinks(std::vector<am_Sink_s> & listSinks)
+{
+       (void)listSinks;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListSources(std::vector<am_Source_s> & listSources)
+{
+       (void)listSources;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses)
+{
+       (void)listSourceClasses;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListHandles(std::vector<am_Handle_s> & listHandles)
+{
+       (void)listHandles;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders)
+{
+       (void)listCrossfaders;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListGateways(std::vector<am_Gateway_s> & listGateways)
+{
+       (void)listGateways;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses)
+{
+       (void)listSinkClasses;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties)
+{
+       (void)listSystemProperties;
+       am_Error_e error = E_OK;
+    return (error);
+}
+
+void IAmControlReceiverDbusShadow::setControlReady()
+{
+    // mpIAmControlReceiver->setControlReady();
+}
+
+void IAmControlReceiverDbusShadow::setControlRundown()
+{
+    // mCAmSerializer.asyncCall<IAmControlReceive>(mpIAmControlReceiver, &IAmControlReceive::setRoutingRundown);
+}
+
+void am::IAmControlReceiverDbusShadow::confirmControllerReady(am_Error_e error)
+{
+     mpIAmControlReceiver->confirmControllerReady(error);
+}
+
+void am::IAmControlReceiverDbusShadow::confirmControllerRundown(am_Error_e error)
+{
+       mpIAmControlReceiver->confirmControllerRundown(error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getSocketHandler(CAmSocketHandler *& socketHandler)
+{
+    am_Error_e error = mpIAmControlReceiver->getSocketHandler(socketHandler);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::changeSinkAvailabilityDB(am_Availability_s& availability, am_sinkID_t sinkID)
+{
+    am_Error_e error = mpIAmControlReceiver->changeSinkAvailabilityDB(availability, sinkID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::changDomainStateDB(am_DomainState_e domainState, am_domainID_t domainID)
+{
+    am_Error_e error = mpIAmControlReceiver->changDomainStateDB(domainState, domainID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::changeSinkMuteStateDB(am_MuteState_e muteState, am_sinkID_t sinkID)
+{
+    am_Error_e error = mpIAmControlReceiver->changeSinkMuteStateDB(muteState, sinkID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::changeMainSinkSoundPropertyDB(am_MainSoundProperty_s& soundProperty, am_sinkID_t sinkID)
+{
+    am_Error_e error = mpIAmControlReceiver->changeMainSinkSoundPropertyDB(soundProperty, sinkID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::changeMainSourceSoundPropertyDB(am_MainSoundProperty_s& soundProperty, am_sourceID_t sourceID)
+{
+    am_Error_e error = mpIAmControlReceiver->changeMainSourceSoundPropertyDB(soundProperty, sourceID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::changeSourceAvailabilityDB(am_Availability_s& availability, am_sourceID_t sourceID)
+{
+    am_Error_e error = mpIAmControlReceiver->changeSourceAvailabilityDB(availability, sourceID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::changeSystemPropertyDB(am_SystemProperty_s& property)
+{
+    am_Error_e error = mpIAmControlReceiver->changeSystemPropertyDB(property);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::removeMainConnectionDB(am_mainConnectionID_t mainConnectionID)
+{
+    am_Error_e error = mpIAmControlReceiver->removeMainConnectionDB(mainConnectionID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::removeSinkDB(am_sinkID_t sinkID)
+{
+    am_Error_e error = mpIAmControlReceiver->removeSinkDB(sinkID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::removeSourceDB(am_sourceID_t sourceID)
+{
+    am_Error_e error = mpIAmControlReceiver->removeSourceDB(sourceID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::removeGatewayDB(am_gatewayID_t gatewayID)
+{
+    am_Error_e error = mpIAmControlReceiver->removeGatewayDB(gatewayID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::removeCrossfaderDB(am_crossfaderID_t crossfaderID)
+{
+    am_Error_e error = mpIAmControlReceiver->removeCrossfaderDB(crossfaderID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::removeDomainDB(am_domainID_t domainID)
+{
+    am_Error_e error = mpIAmControlReceiver->removeDomainDB(domainID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::removeSinkClassDB(am_sinkClass_t sinkClassID)
+{
+    am_Error_e error = mpIAmControlReceiver->removeSinkClassDB(sinkClassID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::removeSourceClassDB(am_sourceClass_t sourceClassID)
+{
+    am_Error_e error = mpIAmControlReceiver->removeSourceClassDB(sourceClassID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getSourceClassInfoDB(am_sourceID_t sourceID, am_SourceClass_s& classInfo)
+{
+    am_Error_e error = mpIAmControlReceiver->getSourceClassInfoDB(sourceID, classInfo);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getSinkClassInfoDB(am_sinkID_t sinkID, am_SinkClass_s& sinkClass)
+{
+    am_Error_e error = mpIAmControlReceiver->getSinkClassInfoDB(sinkID, sinkClass);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getSinkInfoDB(am_sinkID_t sinkID, am_Sink_s& sinkData)
+{
+    am_Error_e error = mpIAmControlReceiver->getSinkInfoDB(sinkID, sinkData);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getSourceInfoDB(am_sourceID_t sourceID, am_Source_s& sourceData)
+{
+    am_Error_e error = mpIAmControlReceiver->getSourceInfoDB(sourceID, sourceData);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getGatewayInfoDB(am_gatewayID_t gatewayID, am_Gateway_s& gatewayData)
+{
+    am_Error_e error = mpIAmControlReceiver->getGatewayInfoDB(gatewayID, gatewayData);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getCrossfaderInfoDB(am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData)
+{
+    am_Error_e error = mpIAmControlReceiver->getCrossfaderInfoDB(crossfaderID, crossfaderData);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getMainConnectionInfoDB(am_mainConnectionID_t mainConnectionID, am_MainConnection_s& mainConnectionData)
+{
+    am_Error_e error = mpIAmControlReceiver->getMainConnectionInfoDB(mainConnectionID, mainConnectionData);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListSinksOfDomain(am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID)
+{
+    am_Error_e error = E_OK;
+    mpIAmControlReceiver->getListSinksOfDomain(domainID, listSinkID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListSourcesOfDomain(am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID)
+{
+    am_Error_e error = mpIAmControlReceiver->getListSourcesOfDomain(domainID, listSourceID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListCrossfadersOfDomain(am_domainID_t domainID, std::vector<am_crossfaderID_t>& listCrossfadersID)
+{
+    am_Error_e error = mpIAmControlReceiver->getListCrossfadersOfDomain(domainID, listCrossfadersID);
+    return (error);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::getListGatewaysOfDomain(am_domainID_t domainID, std::vector<am_gatewayID_t>& listGatewaysID)
+{
+    am_Error_e error = mpIAmControlReceiver->getListGatewaysOfDomain(domainID, listGatewaysID);
+    return (error);
+}
+
+DBusHandlerResult IAmControlReceiverDbusShadow::receiveCallback(DBusConnection* conn, DBusMessage* msg, void* user_data)
+{
+    assert(conn != NULL);
+    assert(msg != NULL);
+    assert(user_data != NULL);
+    IAmControlReceiverDbusShadow* reference = (IAmControlReceiverDbusShadow*) ((user_data));
+    return (reference->receiveCallbackDelegate(conn, msg));
+}
+
+void IAmControlReceiverDbusShadow::sendIntrospection(DBusConnection* conn, DBusMessage* msg)
+{
+    assert(conn != NULL);
+    assert(msg != NULL);
+    DBusMessage* reply;
+    DBusMessageIter args;
+    dbus_uint32_t serial = 0;
+
+    // create a reply from the message
+    reply = dbus_message_new_method_return(msg);
+    std::string fullpath(CONTROL_DBUS_INTROSPECTION_FILE);
+    std::ifstream in(fullpath.c_str(), std::ifstream::in);
+    if (!in)
+    {
+        logError("IAmControlReceiverDbusShadow::sendIntrospection could not load xml file ",fullpath);
+        throw std::runtime_error("IAmControlReceiverDbusShadow::sendIntrospection Could not load introspecton XML");
+    }
+    std::string introspect((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
+    const char* string = introspect.c_str();
+
+    // add the arguments to the reply
+    dbus_message_iter_init_append(reply, &args);
+    if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &string))
+    {
+        log(&controlDbus, DLT_LOG_INFO, "DBUS handler Out Of Memory!");
+    }
+
+    // send the reply && flush the connection
+    if (!dbus_connection_send(conn, reply, &serial))
+    {
+        log(&controlDbus, DLT_LOG_INFO, "DBUS handler Out Of Memory!");
+    }
+    dbus_connection_flush(conn);
+
+    // free the reply
+    dbus_message_unref(reply);
+}
+
+DBusHandlerResult IAmControlReceiverDbusShadow::receiveCallbackDelegate(DBusConnection* conn, DBusMessage* msg)
+{
+    if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
+    {
+        sendIntrospection(conn, msg);
+        return (DBUS_HANDLER_RESULT_HANDLED);
+    }
+    functionMap_t::iterator iter = mFunctionMap.begin();
+    std::string k(dbus_message_get_member(msg));
+    log(&controlDbus, DLT_LOG_INFO, k.c_str());
+    iter = mFunctionMap.find(k);
+    if (iter != mFunctionMap.end())
+    {
+        std::string p(iter->first);
+        CallBackMethod cb = iter->second;
+        (this->*cb)(conn, msg);
+        return (DBUS_HANDLER_RESULT_HANDLED);
+    }
+    return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+}
+
+void IAmControlReceiverDbusShadow::setControlReceiver(IAmControlReceive*& receiver)
+{
+    assert(receiver != NULL);
+    mpIAmControlReceiver = receiver;
+    gObjectPathVTable.message_function = IAmControlReceiverDbusShadow::receiveCallback;
+    DBusConnection* connection;
+    mpIAmControlReceiver->getDBusConnectionWrapper(mDBusWrapper);
+    assert(mDBusWrapper != NULL);
+    mDBusWrapper->getDBusConnection(connection);
+    assert(connection != NULL);
+    mDBUSMessageHandler.setDBusConnection(connection);
+    std::string path(CONTROL_NODE);
+    {
+        assert(receiver != NULL);
+    }
+    mDBusWrapper->registerCallback(&gObjectPathVTable, path, this);
+}
+
+void IAmControlReceiverDbusShadow::gotReady(int16_t numberDomains, uint16_t handle)
+{
+       (void)numberDomains;
+       (void)handle;
+}
+
+void IAmControlReceiverDbusShadow::gotRundown(int16_t numberDomains, uint16_t handle)
+{
+       (void)numberDomains;
+       (void)handle;
+}
+
+IAmControlReceiverDbusShadow::functionMap_t IAmControlReceiverDbusShadow::createMap()
+{
+    functionMap_t m;
+    m["connect"] = &IAmControlReceiverDbusShadow::connect;
+    m["disconnect"] = &IAmControlReceiverDbusShadow::disconnect;
+    return (m);
+}
+
+am_Error_e IAmControlReceiverDbusShadow::autoConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t & mainConnectionID)
+{
+    std::vector<am_Route_s> listRoutes;
+    std::vector<am_connectionID_t> listConnectionIDs;
+    am_mainConnectionID_t currentMainConnection;
+    am_mainConnectionID_t newMainConnection;
+    am_sourceID_t oldSourceID;
+    am_MainConnection_s mainConnectionData;
+    std::vector<am_MainConnection_s> listAllMainConnections;
+
+    mpIAmControlReceiver->getRoute(false, sourceID, sinkID, listRoutes);
+
+    if (listRoutes.empty())
+        return (E_NOT_POSSIBLE);
+
+
+    mpIAmControlReceiver->getListMainConnections(listAllMainConnections);
+
+    //go through all connections
+    std::vector<am_MainConnection_s>::iterator itAll(listAllMainConnections.begin());
+    for (; itAll != listAllMainConnections.end(); ++itAll)
+    {
+        if (itAll->sinkID == sinkID && itAll->sourceID == sourceID)
+            return (E_ALREADY_EXISTS);
+    }
+
+    mainConnectionData.mainConnectionID = 0;
+    mainConnectionData.sinkID = sinkID;
+    mainConnectionData.sourceID = sourceID;
+    mainConnectionData.connectionState = CS_CONNECTED;
+    mainConnectionData.delay = 0;
+
+    mpIAmControlReceiver->enterMainConnectionDB(mainConnectionData, mainConnectionID);
+    newMainConnection=mainConnectionID;
+
+    connect_auto(sourceID, sinkID, newMainConnection);
+
+    return (E_OK);
+}
+
+void IAmControlReceiverDbusShadow::connect_auto(am_sourceID_t sourceID, am_sinkID_t sinkID, am_mainConnectionID_t mainConnectionID)
+{
+    std::vector<am_Route_s> listRoutes;
+    std::vector<am_connectionID_t> listConnectionIDs;
+    am_SourceClass_s sourceClass, tempSourceClass;
+    am_Handle_s handle;
+    am_connectionID_t connectionID;
+
+    mpIAmControlReceiver->connect(handle, connectionID, CF_GENIVI_AUTO, sourceID, sinkID);
+
+    listConnectionIDs.push_back(connectionID);
+
+    mpIAmControlReceiver->changeMainConnectionRouteDB(mainConnectionID,listConnectionIDs);
+}
+
+} /* namespace am */
index 2420184..6ce5638 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef _ROUTINGDBUS_CONFIG_H
 #define _ROUTINGDBUS_CONFIG_H
 
-#define ROUTING_DBUS_INTROSPECTION_FILE "/home/christian/workspace/AudioManager/bin/RoutingReceiver.xml"
+#define ROUTING_DBUS_INTROSPECTION_FILE "/usr/share/audiomanager/RoutingReceiver.xml"
 
 #endif /* _ROUTINGDBUS_CONFIG_H */
index b07065e..fb6a4e0 100644 (file)
@@ -645,6 +645,7 @@ void IAmRoutingReceiverShadowDbus::setRoutingReceiver(IAmRoutingReceive*& receiv
     DBusConnection* connection;
     mRoutingReceiveInterface->getDBusConnectionWrapper(mDBusWrapper);
     assert(mDBusWrapper != NULL);
+
     mDBusWrapper->getDBusConnection(connection);
     assert(connection != NULL);
     mDBUSMessageHandler.setDBusConnection(connection);
index b5ed674..4205bca 100644 (file)
@@ -26,6 +26,7 @@
 #include <string>\r
 #include "audiomanagertypes.h"\r
 namespace am {\r
+class CAmDbusWrapper;\r
 class CAmSocketHandler;\r
 }\r
 
@@ -838,6 +839,15 @@ namespace am {
                 */
                virtual NsmErrorStatus_e sendLifecycleRequestCompleteNSM(const uint32_t RequestId, const NsmErrorStatus_e status) =0;
 
+               /**
+                * this function is used to retrieve a pointer to the dBusConnectionWrapper
+                * @return E_OK if pointer is valid, E_UKNOWN if AudioManager was compiled without DBus Support
+                * 
+                * @param dbusConnectionWrapper    This is a wrapper class that is needed to keep dbus inclusions away from the interface.
+                * The DBusWrapperClass will return the pointer to the DbusConnection call (getDBusConnection)
+                */
+               virtual am_Error_e getDBusConnectionWrapper(CAmDbusWrapper*& dbusConnectionWrapper) const =0;
+
        };
 }
 #endif // !defined(EA_D485A61C_B7C5_4803_B4BD_2AD92893E9CA__INCLUDED_)
index 6c14f85..b7dff75 100644 (file)
@@ -33,7 +33,7 @@ Requires:   %{name} = %{version}-%{release}
 mkdir build
 cd build
 
-cmake -DUSE_BUILD_LIBS=OFF -DWITH_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr ..
+cmake -DUSE_BUILD_LIBS=OFF -DWITH_TESTS=OFF -DWITH_DBUS_WRAPPER=ON -DWITH_NSM=OFF -DCMAKE_INSTALL_PREFIX=/usr ..
 #make VERBOSE=1
 make %{?_smp_mflags} 
 
@@ -51,6 +51,7 @@ rm $RPM_BUILD_ROOT%{_libdir}/audioManager/routing/libPluginRoutingInterfaceAsync
 %{_libdir}/audioManager/command/libPluginCommandInterfaceDbus.so*
 %{_libdir}/audioManager/routing/libPluginRoutingInterfaceDbus.so*
 %{_libdir}/audioManager/control/libPluginControlInterface.so*
+%{_libdir}/audioManager/control/libPluginControlInterfaceDbus.so*
 %{_datadir}/audiomanager/*xml
 
 %files devel