summaryrefslogtreecommitdiff
path: root/PluginCommandInterfaceDbus
diff options
context:
space:
mode:
authorchristian mueller <christian.ei.mueller@bmw.de>2012-03-01 19:12:55 +0100
committerchristian mueller <christian.ei.mueller@bmw.de>2012-03-01 19:12:55 +0100
commitdfcafbec34e0e454d9995551998af5d40a27c7ad (patch)
treed93d70fea7feb7004f6a2ce9bfce9b83d3469e42 /PluginCommandInterfaceDbus
parentffccf1e2003cea4230413ccfdfd4cd6515484e4f (diff)
downloadaudiomanager-dfcafbec34e0e454d9995551998af5d40a27c7ad.tar.gz
* fix [GAM-28] problems in routingsender.cpp
* [GAM-27] major refactoring: bringing everything to standardized names * Enhancement of CAmSerializer.h * improvement of documentation * adoption & regeneration of inerfaces
Diffstat (limited to 'PluginCommandInterfaceDbus')
-rw-r--r--PluginCommandInterfaceDbus/CMakeLists.txt12
-rw-r--r--PluginCommandInterfaceDbus/include/CAmCommandSenderDbus.h (renamed from PluginCommandInterfaceDbus/include/DBusCommandSender.h)77
-rw-r--r--PluginCommandInterfaceDbus/include/CAmDbusMessageHandler.h (renamed from PluginCommandInterfaceDbus/include/DBusMessageHandler.h)15
-rw-r--r--PluginCommandInterfaceDbus/include/CommandInterface.xml174
-rw-r--r--PluginCommandInterfaceDbus/include/IAmCommandReceiverShadow.h (renamed from PluginCommandInterfaceDbus/include/CommandReceiverShadow.h)28
-rw-r--r--PluginCommandInterfaceDbus/include/mainpage.h32
-rw-r--r--PluginCommandInterfaceDbus/src/CAmCommandSenderDbus.cpp331
-rw-r--r--PluginCommandInterfaceDbus/src/CAmDbusMessageHandler.cpp (renamed from PluginCommandInterfaceDbus/src/DBusMessageHandler.cpp)116
-rw-r--r--PluginCommandInterfaceDbus/src/DBusCommandSender.cpp328
-rw-r--r--PluginCommandInterfaceDbus/src/IAmCommandReceiverShadow.cpp (renamed from PluginCommandInterfaceDbus/src/CommandReceiverShadow.cpp)225
-rw-r--r--PluginCommandInterfaceDbus/test/CAmCommandSenderDbusBackdoor.cpp (renamed from PluginCommandInterfaceDbus/test/DbusCommandInterfaceBackdoor.cpp)19
-rw-r--r--PluginCommandInterfaceDbus/test/CAmCommandSenderDbusBackdoor.h (renamed from PluginCommandInterfaceDbus/test/DbusCommandInterfaceBackdoor.h)25
-rw-r--r--PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.cpp (renamed from PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.cpp)352
-rw-r--r--PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.h (renamed from PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.h)18
-rw-r--r--PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.cpp (renamed from PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.cpp)95
-rw-r--r--PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.h (renamed from PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.h)23
-rw-r--r--PluginCommandInterfaceDbus/test/CMakeLists.txt47
-rw-r--r--PluginCommandInterfaceDbus/test/MockIAmCommandReceive.h59
-rw-r--r--PluginCommandInterfaceDbus/test/MockInterfaces.h85
19 files changed, 1050 insertions, 1011 deletions
diff --git a/PluginCommandInterfaceDbus/CMakeLists.txt b/PluginCommandInterfaceDbus/CMakeLists.txt
index 7c4c776..2d5c6cc 100644
--- a/PluginCommandInterfaceDbus/CMakeLists.txt
+++ b/PluginCommandInterfaceDbus/CMakeLists.txt
@@ -4,9 +4,9 @@ PROJECT(PluginCommandInterfaceDbus)
set(LIBRARY_OUTPUT_PATH ${PLUGINS_OUTPUT_PATH}/command)
set(DOC_OUTPUT_PATH ${DOC_OUTPUT_PATH}/CommandDBusPlugin)
-set(INCLUDES_FOLDER "include")
+set(include_FOLDER "include")
-FILE(READ "${AUDIO_INCLUDES_FOLDER}/command/CommandSendInterface.h" VERSION_BUFFER LIMIT 6000)
+FILE(READ "${AUDIO_include_FOLDER}/command/IAmCommandSend.h" VERSION_BUFFER LIMIT 6000)
STRING(REGEX MATCH "CommandSendVersion*.[^0-9]*[0-9].[0-9]*[0-9]" LIB_INTERFACE_VERSION_STRING ${VERSION_BUFFER})
STRING(REGEX REPLACE "CommandSendVersion*.." "" LIB_INTERFACE_VERSION ${LIB_INTERFACE_VERSION_STRING})
MESSAGE(STATUS "Building against command interface version ${LIB_INTERFACE_VERSION}")
@@ -18,9 +18,9 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
${DBUS_INCLUDE_DIR}
${DBUS_ARCH_INCLUDE_DIR}
- ${AUDIO_INCLUDES_FOLDER}
+ ${AUDIO_include_FOLDER}
${DLT_INCLUDE_DIRS}
- ${INCLUDES_FOLDER}
+ ${include_FOLDER}
)
# all source files go here
@@ -38,7 +38,7 @@ TARGET_LINK_LIBRARIES(PluginCommandInterfaceDbus
)
IF(WITH_TESTS)
-# add_subdirectory (test)
+ add_subdirectory (test)
ENDIF(WITH_TESTS)
#IF(WITH_DOCUMENTATION)
@@ -56,5 +56,7 @@ INSTALL(TARGETS PluginCommandInterfaceDbus
COMPONENT sampleplugins
)
+execute_process(COMMAND cp "${CMAKE_SOURCE_DIR}/PluginCommandInterfaceDbus/${include_FOLDER}/CommandInterface.xml" ${EXECUTABLE_OUTPUT_PATH}/CommandInterface.xml)
+
SET(ADD_DEPEND "audiomanager-bin" "dlt" "libdbus-1-3(>=1.2.16)")
set_property(GLOBAL APPEND PROPERTY sampleplugins_prop "${ADD_DEPEND}")
diff --git a/PluginCommandInterfaceDbus/include/DBusCommandSender.h b/PluginCommandInterfaceDbus/include/CAmCommandSenderDbus.h
index e64e6f6..ad625dc 100644
--- a/PluginCommandInterfaceDbus/include/DBusCommandSender.h
+++ b/PluginCommandInterfaceDbus/include/CAmCommandSenderDbus.h
@@ -26,16 +26,18 @@
#ifndef DBUSCOMMANDSENDER_H_
#define DBUSCOMMANDSENDER_H_
+#include <dbus/dbus.h>
+#include <map>
+#include "shared/CAmDbusWrapper.h"
+#include "CAmDbusMessageHandler.h"
+#include "IAmCommandReceiverShadow.h"
+#include "command/IAmCommandSend.h"
+
#ifdef UNIT_TEST
-#include "../test/DbusCommandInterfaceBackdoor.h"
+#include "../test/CAmCommandSenderDbusBackdoor.h"
#endif
-#include <command/CommandSendInterface.h>
-#include <dbus/dbus.h>
-#include <dbus/DBusWrapper.h>
-#include <map>
-#include "DBusMessageHandler.h"
-#include "CommandReceiverShadow.h"
+
namespace am
{
@@ -45,43 +47,42 @@ const char MY_NODE[] = "CommandInterface";
/**
* Dbus Implementation of CommandSendInterface
*/
-class DbusCommandSender: public CommandSendInterface
+class CAmCommandSenderDbus: public IAmCommandSend
{
public:
- DbusCommandSender();
- virtual ~DbusCommandSender();
- am_Error_e startupInterface(CommandReceiveInterface* commandreceiveinterface) ;
- void setCommandReady(const uint16_t handle) ;
- void setCommandRundown(const uint16_t handle) ;
- void cbNewMainConnection(const am_MainConnectionType_s mainConnection) ;
- void cbRemovedMainConnection(const am_mainConnectionID_t mainConnection) ;
- void cbNewSink(const am_SinkType_s& sink) ;
- void cbRemovedSink(const am_sinkID_t sinkID) ;
- void cbNewSource(const am_SourceType_s& source) ;
- void cbRemovedSource(const am_sourceID_t source) ;
- void cbNumberOfSinkClassesChanged() ;
- void cbNumberOfSourceClassesChanged() ;
- void cbMainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState) ;
- void cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty) ;
- void cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty) ;
- void cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability) ;
- void cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability) ;
- void cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume) ;
- void cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState) ;
- void cbSystemPropertyChanged(const am_SystemProperty_s& systemProperty) ;
- void cbTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time) ;
- void getInterfaceVersion(std::string& version) const ;
+ CAmCommandSenderDbus();
+ virtual ~CAmCommandSenderDbus();
+ am_Error_e startupInterface(IAmCommandReceive* commandreceiveinterface);
+ void setCommandReady(const uint16_t handle);
+ void setCommandRundown(const uint16_t handle);
+ void cbNewMainConnection(const am_MainConnectionType_s mainConnection);
+ void cbRemovedMainConnection(const am_mainConnectionID_t mainConnection);
+ void cbNewSink(const am_SinkType_s& sink);
+ void cbRemovedSink(const am_sinkID_t sinkID);
+ void cbNewSource(const am_SourceType_s& source);
+ void cbRemovedSource(const am_sourceID_t source);
+ void cbNumberOfSinkClassesChanged();
+ void cbNumberOfSourceClassesChanged();
+ void cbMainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState);
+ void cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty);
+ void cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty);
+ void cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability);
+ void cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability);
+ void cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume);
+ void cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState);
+ void cbSystemPropertyChanged(const am_SystemProperty_s& systemProperty);
+ void cbTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time);
+ void getInterfaceVersion(std::string& version) const;
#ifdef UNIT_TEST
- friend class DbusCommandInterfaceBackdoor;
+ friend class CAmCommandSenderDbusBackdoor;
#endif
private:
- DBusMessageHandler mDBUSMessageHandler;
- CommandReceiverShadow mCommandReceiverShadow;
- DBusWrapper* mDBusWrapper;
- CommandReceiveInterface* mCommandReceiveInterface;
- bool mReady; ///< ! if false, calls shall be ignored.
-
+ CAmDbusMessageHandler mCAmDbusMessageHandler; ///< ! instance of message handler
+ IAmCommandReceiverShadow mIAmCommandReceiverShadow; ///< ! instance of shadow
+ CAmDbusWrapper* mpCAmDbusWrapper; ///< ! pointer to dbus wrapper
+ IAmCommandReceive* mpIAmCommandReceive; ///< ! pointer to commandReceive Interface
+ bool mReady; ///< ! if false, calls shall be ignored.
/**
* list of sinks, needed to send out only deltas
diff --git a/PluginCommandInterfaceDbus/include/DBusMessageHandler.h b/PluginCommandInterfaceDbus/include/CAmDbusMessageHandler.h
index 71a4078..5431e2b 100644
--- a/PluginCommandInterfaceDbus/include/DBusMessageHandler.h
+++ b/PluginCommandInterfaceDbus/include/CAmDbusMessageHandler.h
@@ -26,12 +26,13 @@
#ifndef _DBUSMESSAGEHANDLER_H_
#define _DBUSMESSAGEHANDLER_H_
-#include <audiomanagertypes.h>
#include <dbus/dbus.h>
#include <vector>
#include <sstream>
#include <string>
#include <list>
+#include "audiomanagertypes.h"
+
namespace am
{
@@ -39,11 +40,11 @@ namespace am
/**
* handles DBus Messages, is used to extract & append parameters and send messages
*/
-class DBusMessageHandler
+class CAmDbusMessageHandler
{
public:
- DBusMessageHandler();
- ~DBusMessageHandler();
+ CAmDbusMessageHandler();
+ ~CAmDbusMessageHandler();
/**
* sets the DBus Connection
@@ -116,9 +117,9 @@ private:
dbus_uint32_t mSerial;
std::string mErrorName;
std::string mErrorMsg;
- DBusMessage* mDbusMessage;
- DBusMessage* mReveiveMessage;
- DBusConnection* mDBusConnection;
+ DBusMessage* mpDBusMessage;
+ DBusMessage* mpReveiveMessage;
+ DBusConnection* mpDBusConnection;
};
}
diff --git a/PluginCommandInterfaceDbus/include/CommandInterface.xml b/PluginCommandInterfaceDbus/include/CommandInterface.xml
new file mode 100644
index 0000000..f6f07a0
--- /dev/null
+++ b/PluginCommandInterfaceDbus/include/CommandInterface.xml
@@ -0,0 +1,174 @@
+<?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.CommandInterface">
+
+ <method name="Connect">
+ <arg type="q" name="sourceID" direction="in"/>
+ <arg type="q" name="sinkID" direction="in"/>
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ <arg type="q" name="mainConnectionID" direction="out"/>
+ </method>
+
+ <method name="Disconnect">
+ <arg type="q" name="mainConnectionID" direction="in"/>
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ </method>
+
+ <method name="SetVolume">
+ <arg type="q" name="sinkID" direction="in"/>
+ <arg type="n" name="volume" direction="in"/>
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ </method>
+
+ <method name="VolumeStep">
+ <arg type="q" name="sinkID" direction="in"/>
+ <arg type="n" name="volumeStep" direction="in"/>
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ </method>
+
+ <method name="SetSinkMuteState">
+ <arg type="q" name="sinkID" direction="in"/>
+ <arg type="n" name="muteState" direction="in"/>
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ </method>
+
+ <method name="SetMainSinkSoundProperty">
+ <arg type="q" name="sinkID" direction="in"/>
+ <arg type="(nn)" name="soundProperty" direction="in"/>
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ </method>
+
+ <method name="SetMainSourceSoundProperty">
+ <arg type="q" name="sourceID" direction="in"/>
+ <arg type="(nn)" name="soundProperty" direction="in"/>
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ </method>
+
+ <method name="SetSystemProperty">
+ <arg type="(nn)" name="property" direction="in"/>
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ </method>
+
+ <method name="GetListMainConnections">
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ <arg type="a(qqqnn)" name="listConnections" direction="out"/> <!-- am_mainConnectionID_t mainConnectionID; am_sourceID_t sourceID; am_sinkID_t sinkID; am_timeSync_t delay; am_ConnectionState_e connectionState; -->
+ </method>
+
+ <method name="GetListMainSinks">
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ <arg type="a(qs(nn)nnq)" name="listMainSinks" direction="out"/> <!-- am_sinkID_t sinkID; std::string name; am_Availability_s availability; am_mainVolume_t volume; am_MuteState_e muteState; am_sinkClass_t sinkClassID; -->
+ </method>
+
+ <method name="GetListMainSources">
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ <arg type="a(qs(nn)q)" name="listMainSources" direction="out"/> <!-- am_sourceID_t sourceID; std::string name; am_Availability_s availability; am_sourceClass_t sourceClassID; -->
+ </method>
+
+ <method name="GetListMainSinkSoundProperties">
+ <arg type="q" name="sinkID" direction="in"/>
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ <arg type="a(nn)" name="listSoundProperties" direction="out"/> <!-- am_MainSoundPropertyType_e type; int16_t value; -->
+ </method>
+
+ <method name="GetListMainSourceSoundProperties">
+ <arg type="q" name="sourceID" direction="in"/>
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ <arg type="a(nn)" name="listSourceProperties" direction="out"/> <!-- am_MainSoundPropertyType_e type; int16_t value; -->
+ </method>
+
+ <method name="GetListSourceClasses">
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ <arg type="a(qsa(nn))" name="listSourceClasses" direction="out"/> <!-- am_sourceClass_t SourceClassID; std::string name; std::vector<am_ClassProperty_s> listClassProperties; -->
+ </method>
+
+ <method name="GetListSinkClasses">
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ <arg type="a(qsa(nn))" name="listSinkClasses" direction="out"/> <!-- am_sourceClass_t SinkClassID; std::string name; std::vector<am_ClassProperty_s> listClassProperties; -->
+ </method>
+
+ <method name="GetListSystemProperties">
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ <arg type="a(nn)" name="listSystemProperties" direction="in"/> <!-- am_SystemProperty_e type; int16_t value; -->
+ </method>
+
+ <method name="GetTimingInformation">
+ <arg type="q" name="mainConnectionID" direction="in"/>
+ <arg type="n" name="result" direction="out"/> <!-- method return code (am_Error_e) -->
+ <arg type="n" name="delay" direction="out"/>
+ </method>
+
+ <signal name="NumberOfMainConnectionsChanged">
+ </signal>
+
+ <signal name="SinkAdded">
+ <arg type="(qs(nn)nnq)" name="newSink" direction="out"/><!-- am_sinkID_t sinkID; std::string name; am_Availability_s availability; am_mainVolume_t volume; am_MuteState_e muteState; am_sinkClass_t sinkClassID; -->
+ </signal>
+
+ <signal name="SinkRemoved">
+ <arg type="q" name="removedSinkID" direction="out"/>
+ </signal>
+
+ <signal name="SourceAdded">
+ <arg type="(qs(nn)q)" name="newSource" direction="out"/><!-- am_sourceID_t sourceID; std::string name; am_Availability_s availability; am_sourceClass_t sourceClassID; -->
+ </signal>
+
+ <signal name="SourceRemoved">
+ <arg type="q" name="removedSourceID" direction="out"/>
+ </signal>
+
+ <signal name="NumberOfSinkClassesChanged">
+ </signal>
+
+ <signal name="NumberOfSourceClassesChanged">
+ </signal>
+
+ <signal name="MainConnectionStateChanged">
+ <arg type="q" name="connectionID" direction="out"/>
+ <arg type="n" name="connectionState" direction="out"/>
+ </signal>
+
+ <signal name="MainSinkSoundPropertyChanged">
+ <arg type="q" name="sinkID" direction="out"/>
+ <arg type="(nn)" name="SoundProperty" direction="out"/>
+ </signal>
+
+ <signal name="MainSourceSoundPropertyChanged">
+ <arg type="q" name="sourceID" direction="out"/>
+ <arg type="(nn)" name="SoundProperty" direction="out"/>
+ </signal>
+
+ <signal name="SinkAvailabilityChanged">
+ <arg type="q" name="sinkID" direction="out"/>
+ <arg type="(nn)" name="availability" direction="out"/>
+ </signal>
+
+ <signal name="SourceAvailabilityChanged">
+ <arg type="q" name="sourceID" direction="out"/>
+ <arg type="(nn)" name="availability" direction="out"/>
+ </signal>
+
+ <signal name="VolumeChanged">
+ <arg type="q" name="sinkID" direction="out"/>
+ <arg type="n" name="volume" direction="out"/>
+ </signal>
+
+ <signal name="SinkMuteStateChanged">
+ <arg type="q" name="sinkID" direction="out"/>
+ <arg type="n" name="muteState" direction="out"/>
+ </signal>
+
+ <signal name="SystemPropertyChanged">
+ <arg type="(nn)" name="SystemProperty" direction="out"/>
+ </signal>
+
+ <signal name="TimingInformationChanged">
+ <arg type="q" name="mainConnection" direction="out"/>
+ <arg type="n" name="time" direction="out"/>
+ </signal>
+
+ </interface>
+</node>
diff --git a/PluginCommandInterfaceDbus/include/CommandReceiverShadow.h b/PluginCommandInterfaceDbus/include/IAmCommandReceiverShadow.h
index d2c63cb..dd5a23d 100644
--- a/PluginCommandInterfaceDbus/include/CommandReceiverShadow.h
+++ b/PluginCommandInterfaceDbus/include/IAmCommandReceiverShadow.h
@@ -26,28 +26,30 @@
#ifndef COMMANDRECEIVERSHADOW_H_
#define COMMANDRECEIVERSHADOW_H_
-#include <config.h>
-#include <command/CommandReceiveInterface.h>
-#include <dbus/DBusWrapper.h>
+
+
#include <dbus/dbus.h>
#include <map>
-#include "DBusMessageHandler.h"
+#include "config.h"
+#include "command/IAmCommandReceive.h"
+#include "CAmDbusMessageHandler.h"
+#include "shared/CAmDbusWrapper.h"
namespace am
{
-class CommandReceiverShadow;
+class IAmCommandReceiverShadow;
-typedef void (CommandReceiverShadow::*CallBackMethod)(DBusConnection *connection, DBusMessage *message);
+typedef void (IAmCommandReceiverShadow::*CallBackMethod)(DBusConnection *connection, DBusMessage *message);
/**
* receives the DBus Callbacks, marhsalls and demarshalls the parameters and calls CommandReceive
*/
-class CommandReceiverShadow
+class IAmCommandReceiverShadow
{
public:
- CommandReceiverShadow();
- virtual ~CommandReceiverShadow();
+ IAmCommandReceiverShadow();
+ virtual ~IAmCommandReceiverShadow();
void connect(DBusConnection *conn, DBusMessage *msg);
void disconnect(DBusConnection *conn, DBusMessage *msg);
void setVolume(DBusConnection *conn, DBusMessage *msg);
@@ -70,13 +72,13 @@ public:
* sets the pointer to the CommandReceiveInterface and registers Callback
* @param receiver
*/
- void setCommandReceiver(CommandReceiveInterface*& receiver);
+ void setCommandReceiver(IAmCommandReceive*& receiver);
private:
- CommandReceiveInterface* mCommandReceiveInterface;
- DBusWrapper* mDBusWrapper;
typedef std::map<std::string, CallBackMethod> functionMap_t;
functionMap_t mFunctionMap;
- DBusMessageHandler mDBUSMessageHandler;
+ CAmDbusMessageHandler mDBUSMessageHandler;
+ IAmCommandReceive* mpIAmCommandReceive;
+ CAmDbusWrapper* mpCAmDbusWrapper;
/**
* receives a callback whenever the path of the plugin is called
diff --git a/PluginCommandInterfaceDbus/include/mainpage.h b/PluginCommandInterfaceDbus/include/mainpage.h
deleted file mode 100644
index 8a2848c..0000000
--- a/PluginCommandInterfaceDbus/include/mainpage.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * \mainpage
- * \image html "Bild1.png"
- * Copyright Copyright (C) 2011, BMW AG
- *
- * \date 22.06.2011
- * \author Christian Müller (christian.ei.mueller@bmw.de)
- *
- * \section License
- * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
- * Copyright (C) 2011, BMW AG – Christian Müller Christian.ei.mueller@bmw.de
- *
- * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
- * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
- * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
- * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
- * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
- * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
- *
- * \section About About PluginInterfaceDBus
- * This plugin for the Genivi AudioManager serves as interface for DBus.
- *
- * \section Info More information
- * can be found at <https://collab.genivi.org/wiki/display/genivi/GENIVI+Home>
- *
- */
-
-#ifndef MAINPAGE_H_
-#define MAINPAGE_H_
-
-#endif /* MAINPAGE_H_ */
diff --git a/PluginCommandInterfaceDbus/src/CAmCommandSenderDbus.cpp b/PluginCommandInterfaceDbus/src/CAmCommandSenderDbus.cpp
new file mode 100644
index 0000000..cb5b838
--- /dev/null
+++ b/PluginCommandInterfaceDbus/src/CAmCommandSenderDbus.cpp
@@ -0,0 +1,331 @@
+/**
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger DbusPlugin
+ *
+ * \file CAmCommandSender.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
+
+#include "CAmCommandSenderDbus.h"
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <cassert>
+#include <set>
+#include "CAmDbusMessageHandler.h"
+#include "shared/CAmDltWrapper.h"
+#include "shared/CAmDbusWrapper.h"
+
+
+DLT_DECLARE_CONTEXT(commandDbus)
+
+using namespace am;
+
+/**
+ * factory for plugin loading
+ */
+extern "C" IAmCommandSend* PluginCommandInterfaceDbusFactory()
+{
+ return (new CAmCommandSenderDbus());
+}
+
+/**
+ * destroy instance of commandSendInterface
+ */
+extern "C" void destroyRoutingPluginInterfaceDbus(IAmCommandSend* commandSendInterface)
+{
+ delete commandSendInterface;
+}
+
+CAmCommandSenderDbus::CAmCommandSenderDbus() :
+ mCAmDbusMessageHandler(), //
+ mIAmCommandReceiverShadow(), //
+ mpCAmDbusWrapper(NULL), //
+ mpIAmCommandReceive(NULL), //
+ mReady(false)
+{
+ CAmDltWrapper::instance()->registerContext(commandDbus, "DBP", "DBus Plugin");
+ log(&commandDbus, DLT_LOG_INFO, "DbusCommandSender constructor called");
+}
+
+CAmCommandSenderDbus::~CAmCommandSenderDbus()
+{
+ log(&commandDbus, DLT_LOG_INFO, "DbusCommandSender destructed");
+ CAmDltWrapper::instance()->unregisterContext(commandDbus);
+}
+
+am_Error_e CAmCommandSenderDbus::startupInterface(IAmCommandReceive* commandreceiveinterface)
+{
+ log(&commandDbus, DLT_LOG_INFO, "startupInterface called");
+
+ mpIAmCommandReceive = commandreceiveinterface;
+ mIAmCommandReceiverShadow.setCommandReceiver(mpIAmCommandReceive);
+ mpIAmCommandReceive->getDBusConnectionWrapper(mpCAmDbusWrapper);
+ assert(mpCAmDbusWrapper!=NULL);
+ DBusConnection * connection;
+ mpCAmDbusWrapper->getDBusConnection(connection);
+ assert(connection!=NULL);
+ mCAmDbusMessageHandler.setDBusConnection(connection);
+ return (E_OK);
+}
+
+void CAmCommandSenderDbus::setCommandReady(const uint16_t handle)
+{
+ //todo:implement handle handling
+ log(&commandDbus, DLT_LOG_INFO, "cbCommunicationReady called");
+ mReady = true;
+ mpIAmCommandReceive->confirmCommandReady(handle);
+}
+
+void CAmCommandSenderDbus::setCommandRundown(const uint16_t handle)
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbCommunicationRundown called");
+ mReady = false;
+ mpIAmCommandReceive->confirmCommandRundown(handle);
+ /**
+ * todo: implement DbusCommandSender::cbCommunicationRundown()
+ */
+}
+
+void CAmCommandSenderDbus::cbNewMainConnection(const am_MainConnectionType_s mainConnection)
+{
+ (void)mainConnection;
+ //todo: change xml and interface to differetiate between new connection and removed one
+ log(&commandDbus, DLT_LOG_INFO, "cbNumberOfMainConnectionsChanged called");
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("NumberOfMainConnectionsChanged"));
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbRemovedMainConnection(const am_mainConnectionID_t mainConnection)
+{
+ (void)mainConnection;
+//todo: change xml and interface to differetiate between new connection and removed one
+ log(&commandDbus, DLT_LOG_INFO, "cbNumberOfMainConnectionsChanged called");
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("NumberOfMainConnectionsChanged"));
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbNewSink(const am_SinkType_s& sink)
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbNewSink called");
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), "SinkAdded");
+ mCAmDbusMessageHandler.append(sink);
+
+ log(&commandDbus, DLT_LOG_INFO, "send signal SinkAdded");
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbRemovedSink(const am_sinkID_t sinkID)
+{
+ //todo: check if this really works!
+ log(&commandDbus, DLT_LOG_INFO, "cbRemovedSink called");
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), "SinkRemoved");
+ mCAmDbusMessageHandler.append(sinkID);
+
+ log(&commandDbus, DLT_LOG_INFO, "send signal SinkAdded");
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbNewSource(const am_SourceType_s& source)
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbNumberOfSourcesChanged called");
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), "SourceAdded");
+ mCAmDbusMessageHandler.append(source);
+
+ log(&commandDbus, DLT_LOG_INFO, "send signal SourceAdded");
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void am::CAmCommandSenderDbus::cbRemovedSource(const am_sourceID_t source)
+{
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), "SourceRemoved");
+ mCAmDbusMessageHandler.append(source);
+
+ log(&commandDbus, DLT_LOG_INFO, "send signal SourceRemoved");
+
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbNumberOfSinkClassesChanged()
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbNumberOfSinkClassesChanged called");
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("NumberOfSinkClassesChanged"));
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbNumberOfSourceClassesChanged()
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbNumberOfSourceClassesChanged called");
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("NumberOfSourceClassesChanged"));
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbMainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbMainConnectionStateChanged called, connectionID=", connectionID, "connectionState=", connectionState);
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("MainConnectionStateChanged"));
+ mCAmDbusMessageHandler.append((dbus_uint16_t) connectionID);
+ mCAmDbusMessageHandler.append((dbus_int16_t) connectionState);
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s & soundProperty)
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbMainSinkSoundPropertyChanged called, sinkID", sinkID, "SoundProperty.type", soundProperty.type, "SoundProperty.value", soundProperty.value);
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("MainSinkSoundPropertyChanged"));
+ mCAmDbusMessageHandler.append((dbus_uint16_t) sinkID);
+ mCAmDbusMessageHandler.append(soundProperty);
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s & SoundProperty)
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbMainSourceSoundPropertyChanged called, sourceID", sourceID, "SoundProperty.type", SoundProperty.type, "SoundProperty.value", SoundProperty.value);
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("MainSourceSoundPropertyChanged"));
+ mCAmDbusMessageHandler.append((dbus_uint16_t) sourceID);
+ mCAmDbusMessageHandler.append(SoundProperty);
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s & availability)
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbSinkAvailabilityChanged called, sinkID", sinkID, "availability.availability", availability.availability, "SoundProperty.reason", availability.availabilityReason);
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("SinkAvailabilityChanged"));
+ mCAmDbusMessageHandler.append((dbus_uint16_t) sinkID);
+ mCAmDbusMessageHandler.append(availability);
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s & availability)
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbSourceAvailabilityChanged called, sourceID", sourceID, "availability.availability", availability.availability, "SoundProperty.reason", availability.availabilityReason);
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("SourceAvailabilityChanged"));
+ mCAmDbusMessageHandler.append((dbus_uint16_t) sourceID);
+ mCAmDbusMessageHandler.append(availability);
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbVolumeChanged called, sinkID", sinkID, "volume", volume);
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("VolumeChanged"));
+ mCAmDbusMessageHandler.append((dbus_uint16_t) sinkID);
+ mCAmDbusMessageHandler.append((dbus_int16_t) volume);
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbSinkMuteStateChanged called, sinkID", sinkID, "muteState", muteState);
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("SinkMuteStateChanged"));
+ mCAmDbusMessageHandler.append((dbus_uint16_t) sinkID);
+ mCAmDbusMessageHandler.append((dbus_int16_t) muteState);
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::cbSystemPropertyChanged(const am_SystemProperty_s & SystemProperty)
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbSystemPropertyChanged called, SystemProperty.type", SystemProperty.type, "SystemProperty.value", SystemProperty.value);
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("SystemPropertyChanged"));
+ mCAmDbusMessageHandler.append(SystemProperty);
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void am::CAmCommandSenderDbus::cbTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)
+{
+ log(&commandDbus, DLT_LOG_INFO, "cbTimingInformationChanged called, mainConnectionID=", mainConnectionID, "time=", time);
+
+ if (mReady)
+ {
+ mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("TimingInformationChanged"));
+ mCAmDbusMessageHandler.append((dbus_uint16_t) mainConnectionID);
+ mCAmDbusMessageHandler.append((dbus_int16_t) time);
+ mCAmDbusMessageHandler.sendMessage();
+ }
+}
+
+void CAmCommandSenderDbus::getInterfaceVersion(std::string & version) const
+{
+ version = CommandSendVersion;
+}
+
diff --git a/PluginCommandInterfaceDbus/src/DBusMessageHandler.cpp b/PluginCommandInterfaceDbus/src/CAmDbusMessageHandler.cpp
index 3dd9172..6b2dc3f 100644
--- a/PluginCommandInterfaceDbus/src/DBusMessageHandler.cpp
+++ b/PluginCommandInterfaceDbus/src/CAmDbusMessageHandler.cpp
@@ -22,40 +22,42 @@
*
* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
*/
-#include <config.h>
-#include "DBusMessageHandler.h"
-#include "DBusCommandSender.h"
-#include "DLTWrapper.h"
-#include <stdlib.h>
+
+#include "CAmDbusMessageHandler.h"
+#include "config.h"
+#include <cstdlib>
#include <cassert>
#include <vector>
+#include "CAmCommandSenderDbus.h"
+#include "shared/CAmDltWrapper.h"
DLT_IMPORT_CONTEXT(commandDbus)
-using namespace am;
+namespace am
+{
-DBusMessageHandler::DBusMessageHandler() :
+CAmDbusMessageHandler::CAmDbusMessageHandler() :
mDBusMessageIter(), //
mDBusError(), //
mSerial(0), //
mErrorName(""), //
mErrorMsg(""), //
- mDbusMessage(NULL), //
- mReveiveMessage(NULL), //
- mDBusConnection(NULL)
+ mpDBusMessage(NULL), //
+ mpReveiveMessage(NULL), //
+ mpDBusConnection(NULL)
{
log(&commandDbus, DLT_LOG_INFO, "DBusMessageHandler constructed");
}
-DBusMessageHandler::~DBusMessageHandler()
+CAmDbusMessageHandler::~CAmDbusMessageHandler()
{
log(&commandDbus, DLT_LOG_INFO, "DBUSMessageHandler destructed");
}
-void DBusMessageHandler::initReceive(DBusMessage* msg)
+void CAmDbusMessageHandler::initReceive(DBusMessage* msg)
{
assert(msg!=NULL);
- mReveiveMessage = msg;
+ mpReveiveMessage = msg;
if (!dbus_message_iter_init(msg, &mDBusMessageIter))
{
log(&commandDbus, DLT_LOG_INFO, "DBusMessageHandler::initReceive DBus Message has no arguments!");
@@ -64,39 +66,39 @@ void DBusMessageHandler::initReceive(DBusMessage* msg)
}
}
-void DBusMessageHandler::initReply(DBusMessage* msg)
+void CAmDbusMessageHandler::initReply(DBusMessage* msg)
{
assert(msg!=NULL);
- mDbusMessage = dbus_message_new_method_return(msg);
- if (mDbusMessage == NULL)
+ mpDBusMessage = dbus_message_new_method_return(msg);
+ if (mpDBusMessage == NULL)
{
log(&commandDbus, 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(mDbusMessage, &mDBusMessageIter);
+ dbus_message_iter_init_append(mpDBusMessage, &mDBusMessageIter);
}
-void DBusMessageHandler::initSignal(std::string path, std::string signalName)
+void CAmDbusMessageHandler::initSignal(std::string path, std::string signalName)
{
assert(!path.empty());
assert(!signalName.empty());
std::string completePath = std::string(DBUS_SERVICE_OBJECT_PATH) + "/" + path;
- mDbusMessage = dbus_message_new_signal(completePath.c_str(), DBUS_SERVICE_PREFIX, signalName.c_str());
+ mpDBusMessage = dbus_message_new_signal(completePath.c_str(), DBUS_SERVICE_PREFIX, signalName.c_str());
- if (mDbusMessage == NULL)
+ if (mpDBusMessage == NULL)
{
log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::initSignal Cannot allocate DBus message!");
}
- dbus_message_iter_init_append(mDbusMessage, &mDBusMessageIter);
+ dbus_message_iter_init_append(mpDBusMessage, &mDBusMessageIter);
}
-void DBusMessageHandler::sendMessage()
+void CAmDbusMessageHandler::sendMessage()
{
- assert(mDBusConnection!=NULL);
- if (mReveiveMessage != 0)
+ assert(mpDBusConnection!=NULL);
+ if (mpReveiveMessage != 0)
{
- mSerial = dbus_message_get_serial(mReveiveMessage);
+ mSerial = dbus_message_get_serial(mpReveiveMessage);
}
else
{
@@ -104,18 +106,18 @@ void DBusMessageHandler::sendMessage()
}
if (!mErrorName.empty())
{
- mDbusMessage = dbus_message_new_error(mReveiveMessage, mErrorName.c_str(), mErrorMsg.c_str());
+ mpDBusMessage = dbus_message_new_error(mpReveiveMessage, mErrorName.c_str(), mErrorMsg.c_str());
}
- if (!dbus_connection_send(mDBusConnection, mDbusMessage, &mSerial))
+ if (!dbus_connection_send(mpDBusConnection, mpDBusMessage, &mSerial))
{
log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::sendMessage cannot send message!");
}
- dbus_connection_flush(mDBusConnection);
- dbus_message_unref(mDbusMessage);
- mDbusMessage = NULL;
+ dbus_connection_flush(mpDBusConnection);
+ dbus_message_unref(mpDBusMessage);
+ mpDBusMessage = NULL;
}
-char* DBusMessageHandler::getString()
+char* CAmDbusMessageHandler::getString()
{
char* param = NULL;
@@ -133,7 +135,7 @@ char* DBusMessageHandler::getString()
return (param);
}
-dbus_bool_t DBusMessageHandler::getBool()
+dbus_bool_t CAmDbusMessageHandler::getBool()
{
dbus_bool_t boolparam = false;
@@ -151,7 +153,7 @@ dbus_bool_t DBusMessageHandler::getBool()
return (boolparam);
}
-char DBusMessageHandler::getByte()
+char CAmDbusMessageHandler::getByte()
{
char param;
@@ -169,7 +171,7 @@ char DBusMessageHandler::getByte()
return (param);
}
-dbus_uint16_t DBusMessageHandler::getUInt()
+dbus_uint16_t CAmDbusMessageHandler::getUInt()
{
dbus_uint16_t param;
@@ -191,7 +193,7 @@ dbus_uint16_t DBusMessageHandler::getUInt()
return (param);
}
-dbus_int16_t DBusMessageHandler::getInt()
+dbus_int16_t CAmDbusMessageHandler::getInt()
{
dbus_int16_t param;
@@ -213,7 +215,7 @@ dbus_int16_t DBusMessageHandler::getInt()
return (param);
}
-double DBusMessageHandler::getDouble()
+double CAmDbusMessageHandler::getDouble()
{
double param;
if (DBUS_TYPE_DOUBLE != dbus_message_iter_get_arg_type(&mDBusMessageIter))
@@ -230,7 +232,7 @@ double DBusMessageHandler::getDouble()
return (param);
}
-void DBusMessageHandler::getProperty(dbus_int16_t & type, dbus_int16_t & value)
+void CAmDbusMessageHandler::getProperty(dbus_int16_t & type, dbus_int16_t & value)
{
DBusMessageIter arrayIter;
if (DBUS_TYPE_STRUCT != dbus_message_iter_get_arg_type(&mDBusMessageIter))
@@ -249,7 +251,7 @@ void DBusMessageHandler::getProperty(dbus_int16_t & type, dbus_int16_t & value)
}
}
-void DBusMessageHandler::append(bool toAppend)
+void CAmDbusMessageHandler::append(bool toAppend)
{
dbus_bool_t mybool = toAppend;
if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_BOOLEAN, &mybool))
@@ -260,7 +262,7 @@ void DBusMessageHandler::append(bool toAppend)
}
}
-void DBusMessageHandler::append(double toAppend)
+void CAmDbusMessageHandler::append(double toAppend)
{
if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_DOUBLE, &toAppend))
{
@@ -270,7 +272,7 @@ void DBusMessageHandler::append(double toAppend)
}
}
-void DBusMessageHandler::append(char toAppend)
+void CAmDbusMessageHandler::append(char toAppend)
{
if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_BYTE, &toAppend))
{
@@ -280,7 +282,7 @@ void DBusMessageHandler::append(char toAppend)
}
}
-void DBusMessageHandler::append(dbus_int16_t toAppend)
+void CAmDbusMessageHandler::append(dbus_int16_t toAppend)
{
if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_INT16, &toAppend))
{
@@ -290,7 +292,7 @@ void DBusMessageHandler::append(dbus_int16_t toAppend)
}
}
-void DBusMessageHandler::append(dbus_uint16_t toAppend)
+void CAmDbusMessageHandler::append(dbus_uint16_t toAppend)
{
if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_UINT16, &toAppend))
{
@@ -300,13 +302,13 @@ void DBusMessageHandler::append(dbus_uint16_t toAppend)
}
}
-void DBusMessageHandler::setDBusConnection(DBusConnection *& connection)
+void CAmDbusMessageHandler::setDBusConnection(DBusConnection *& connection)
{
assert(connection!=NULL);
- mDBusConnection = connection;
+ mpDBusConnection = connection;
}
-void DBusMessageHandler::append(const am::am_SinkType_s& sinkType)
+void CAmDbusMessageHandler::append(const am::am_SinkType_s& sinkType)
{
DBusMessageIter structIter;
DBusMessageIter structAvailIter;
@@ -333,7 +335,7 @@ void DBusMessageHandler::append(const am::am_SinkType_s& sinkType)
}
}
-void DBusMessageHandler::append(const am::am_SourceType_s & sourceType)
+void CAmDbusMessageHandler::append(const am::am_SourceType_s & sourceType)
{
DBusMessageIter structIter;
DBusMessageIter structAvailIter;
@@ -358,7 +360,7 @@ void DBusMessageHandler::append(const am::am_SourceType_s & sourceType)
}
}
-void DBusMessageHandler::append(const am::am_MainSoundProperty_s mainSoundProperty)
+void CAmDbusMessageHandler::append(const am::am_MainSoundProperty_s mainSoundProperty)
{
DBusMessageIter structIter;
dbus_bool_t success = true;
@@ -375,7 +377,7 @@ void DBusMessageHandler::append(const am::am_MainSoundProperty_s mainSoundProper
}
}
-void DBusMessageHandler::append(const am::am_Availability_s & availability)
+void CAmDbusMessageHandler::append(const am::am_Availability_s & availability)
{
DBusMessageIter structAvailIter;
dbus_bool_t success = true;
@@ -392,7 +394,7 @@ void DBusMessageHandler::append(const am::am_Availability_s & availability)
}
}
-void DBusMessageHandler::append(const am::am_SystemProperty_s & SystemProperty)
+void CAmDbusMessageHandler::append(const am::am_SystemProperty_s & SystemProperty)
{
DBusMessageIter structIter;
dbus_bool_t success = true;
@@ -409,7 +411,7 @@ void DBusMessageHandler::append(const am::am_SystemProperty_s & SystemProperty)
}
}
-void DBusMessageHandler::append(const std::vector<am::am_MainConnectionType_s>& listMainConnections)
+void CAmDbusMessageHandler::append(const std::vector<am::am_MainConnectionType_s>& listMainConnections)
{
DBusMessageIter arrayIter;
DBusMessageIter structIter;
@@ -437,7 +439,7 @@ void DBusMessageHandler::append(const std::vector<am::am_MainConnectionType_s>&
}
}
-void DBusMessageHandler::append(const std::vector<am::am_SinkType_s> & listMainSinks)
+void CAmDbusMessageHandler::append(const std::vector<am::am_SinkType_s> & listMainSinks)
{
DBusMessageIter arrayIter;
DBusMessageIter structIter;
@@ -470,7 +472,7 @@ void DBusMessageHandler::append(const std::vector<am::am_SinkType_s> & listMainS
}
}
-void DBusMessageHandler::append(const std::vector<am::am_SourceType_s> & listMainSources)
+void CAmDbusMessageHandler::append(const std::vector<am::am_SourceType_s> & listMainSources)
{
DBusMessageIter arrayIter;
DBusMessageIter structIter;
@@ -501,7 +503,7 @@ void DBusMessageHandler::append(const std::vector<am::am_SourceType_s> & listMai
}
}
-void DBusMessageHandler::append(const std::vector<am::am_MainSoundProperty_s> & listMainSoundProperties)
+void CAmDbusMessageHandler::append(const std::vector<am::am_MainSoundProperty_s> & listMainSoundProperties)
{
DBusMessageIter arrayIter;
DBusMessageIter structIter;
@@ -526,7 +528,7 @@ void DBusMessageHandler::append(const std::vector<am::am_MainSoundProperty_s> &
}
}
-void DBusMessageHandler::append(const std::vector<am::am_SourceClass_s> & listSourceClasses)
+void CAmDbusMessageHandler::append(const std::vector<am::am_SourceClass_s> & listSourceClasses)
{
DBusMessageIter arrayIter;
DBusMessageIter structIter;
@@ -564,7 +566,7 @@ void DBusMessageHandler::append(const std::vector<am::am_SourceClass_s> & listSo
}
}
-void DBusMessageHandler::append(const std::vector<am::am_SinkClass_s> & listSinkClasses)
+void CAmDbusMessageHandler::append(const std::vector<am::am_SinkClass_s> & listSinkClasses)
{
DBusMessageIter arrayIter;
DBusMessageIter structIter;
@@ -602,7 +604,7 @@ void DBusMessageHandler::append(const std::vector<am::am_SinkClass_s> & listSink
}
}
-void DBusMessageHandler::append(const std::vector<am::am_SystemProperty_s> & listSystemProperties)
+void CAmDbusMessageHandler::append(const std::vector<am::am_SystemProperty_s> & listSystemProperties)
{
DBusMessageIter arrayIter;
DBusMessageIter structIter;
@@ -626,4 +628,4 @@ void DBusMessageHandler::append(const std::vector<am::am_SystemProperty_s> & lis
mErrorMsg = "Cannot create reply!";
}
}
-
+}
diff --git a/PluginCommandInterfaceDbus/src/DBusCommandSender.cpp b/PluginCommandInterfaceDbus/src/DBusCommandSender.cpp
deleted file mode 100644
index de577c9..0000000
--- a/PluginCommandInterfaceDbus/src/DBusCommandSender.cpp
+++ /dev/null
@@ -1,328 +0,0 @@
-/**
- * Copyright (C) 2011, BMW AG
- *
- * GeniviAudioMananger DbusPlugin
- *
- * \file CommandSender.cpp
- *
- * \date 20-Oct-2011 3:42:04 PM
- * \author Christian Mueller (christian.ei.mueller@bmw.de)
- *
- * \section License
- * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
- * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
- *
- * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
- * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
- * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
- * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
- * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
- * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
- *
- * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
- */
-
-#include <command/CommandReceiveInterface.h>
-#include <dbus/DBusWrapper.h>
-#include "DBusCommandSender.h"
-#include "DBusMessageHandler.h"
-#include "DLTWrapper.h"
-#include <algorithm>
-#include <string>
-#include <vector>
-#include <cassert>
-#include <set>
-
-DLT_DECLARE_CONTEXT(commandDbus)
-
-using namespace am;
-
-/**
- * factory for plugin loading
- */
-extern "C" CommandSendInterface* PluginCommandInterfaceDbusFactory()
-{
- return (new DbusCommandSender());
-}
-
-/**
- * destroy instance of commandSendInterface
- */
-extern "C" void destroyRoutingPluginInterfaceDbus(CommandSendInterface* commandSendInterface)
-{
- delete commandSendInterface;
-}
-
-DbusCommandSender::DbusCommandSender() :
- mDBUSMessageHandler(), //
- mCommandReceiverShadow(), //
- mDBusWrapper(NULL), //
- mCommandReceiveInterface(NULL), //
- mReady(false)
-{
- DLTWrapper::instance()->registerContext(commandDbus, "DBP", "DBus Plugin");
- log(&commandDbus, DLT_LOG_INFO, "DbusCommandSender constructor called");
-}
-
-DbusCommandSender::~DbusCommandSender()
-{
- log(&commandDbus, DLT_LOG_INFO, "DbusCommandSender destructed");
- DLTWrapper::instance()->unregisterContext(commandDbus);
-}
-
-am_Error_e DbusCommandSender::startupInterface(CommandReceiveInterface* commandreceiveinterface)
-{
- log(&commandDbus, DLT_LOG_INFO, "startupInterface called");
-
- mCommandReceiveInterface = commandreceiveinterface;
- mCommandReceiverShadow.setCommandReceiver(mCommandReceiveInterface);
- mCommandReceiveInterface->getDBusConnectionWrapper(mDBusWrapper);
- assert(mDBusWrapper!=NULL);
- DBusConnection * connection;
- mDBusWrapper->getDBusConnection(connection);
- assert(connection!=NULL);
- mDBUSMessageHandler.setDBusConnection(connection);
- return (E_OK);
-}
-
-void DbusCommandSender::setCommandReady(const uint16_t handle)
-{
- //todo:implement handle handling
- log(&commandDbus, DLT_LOG_INFO, "cbCommunicationReady called");
- mReady = true;
-}
-
-void DbusCommandSender::setCommandRundown(const uint16_t handle)
-{
- log(&commandDbus, DLT_LOG_INFO, "cbCommunicationRundown called");
- mReady = false;
- /**
- * todo: implement DbusCommandSender::cbCommunicationRundown()
- */
-}
-
-void DbusCommandSender::cbNewMainConnection(const am_MainConnectionType_s mainConnection)
-{
- (void)mainConnection;
- //todo: change xml and interface to differetiate between new connection and removed one
- log(&commandDbus, DLT_LOG_INFO, "cbNumberOfMainConnectionsChanged called");
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), std::string("NumberOfMainConnectionsChanged"));
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbRemovedMainConnection(const am_mainConnectionID_t mainConnection)
-{
-//todo: change xml and interface to differetiate between new connection and removed one
- log(&commandDbus, DLT_LOG_INFO, "cbNumberOfMainConnectionsChanged called");
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), std::string("NumberOfMainConnectionsChanged"));
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbNewSink(const am_SinkType_s& sink)
-{
- log(&commandDbus, DLT_LOG_INFO, "cbNewSink called");
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), "SinkAdded");
- mDBUSMessageHandler.append(sink);
-
- log(&commandDbus, DLT_LOG_INFO, "send signal SinkAdded");
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbRemovedSink(const am_sinkID_t sinkID)
-{
- //todo: check if this really works!
- log(&commandDbus, DLT_LOG_INFO, "cbRemovedSink called");
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), "SinkRemoved");
- mDBUSMessageHandler.append(sinkID);
-
- log(&commandDbus, DLT_LOG_INFO, "send signal SinkAdded");
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbNewSource(const am_SourceType_s& source)
-{
- log(&commandDbus, DLT_LOG_INFO, "cbNumberOfSourcesChanged called");
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), "SourceAdded");
- mDBUSMessageHandler.append(source);
-
- log(&commandDbus, DLT_LOG_INFO, "send signal SourceAdded");
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void am::DbusCommandSender::cbRemovedSource(const am_sourceID_t source)
-{
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), "SourceRemoved");
- mDBUSMessageHandler.append(source);
-
- log(&commandDbus, DLT_LOG_INFO, "send signal SourceRemoved");
-
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbNumberOfSinkClassesChanged()
-{
- log(&commandDbus, DLT_LOG_INFO, "cbNumberOfSinkClassesChanged called");
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), std::string("NumberOfSinkClassesChanged"));
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbNumberOfSourceClassesChanged()
-{
- log(&commandDbus, DLT_LOG_INFO, "cbNumberOfSourceClassesChanged called");
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), std::string("NumberOfSourceClassesChanged"));
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbMainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
-{
- log(&commandDbus, DLT_LOG_INFO, "cbMainConnectionStateChanged called, connectionID=", connectionID, "connectionState=", connectionState);
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), std::string("MainConnectionStateChanged"));
- mDBUSMessageHandler.append((dbus_uint16_t) connectionID);
- mDBUSMessageHandler.append((dbus_int16_t) connectionState);
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s & soundProperty)
-{
- log(&commandDbus, DLT_LOG_INFO, "cbMainSinkSoundPropertyChanged called, sinkID", sinkID, "SoundProperty.type", soundProperty.type, "SoundProperty.value", soundProperty.value);
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), std::string("MainSinkSoundPropertyChanged"));
- mDBUSMessageHandler.append((dbus_uint16_t) sinkID);
- mDBUSMessageHandler.append(soundProperty);
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s & SoundProperty)
-{
- log(&commandDbus, DLT_LOG_INFO, "cbMainSourceSoundPropertyChanged called, sourceID", sourceID, "SoundProperty.type", SoundProperty.type, "SoundProperty.value", SoundProperty.value);
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), std::string("MainSourceSoundPropertyChanged"));
- mDBUSMessageHandler.append((dbus_uint16_t) sourceID);
- mDBUSMessageHandler.append(SoundProperty);
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s & availability)
-{
- log(&commandDbus, DLT_LOG_INFO, "cbSinkAvailabilityChanged called, sinkID", sinkID, "availability.availability", availability.availability, "SoundProperty.reason", availability.availabilityReason);
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), std::string("SinkAvailabilityChanged"));
- mDBUSMessageHandler.append((dbus_uint16_t) sinkID);
- mDBUSMessageHandler.append(availability);
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s & availability)
-{
- log(&commandDbus, DLT_LOG_INFO, "cbSourceAvailabilityChanged called, sourceID", sourceID, "availability.availability", availability.availability, "SoundProperty.reason", availability.availabilityReason);
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), std::string("SourceAvailabilityChanged"));
- mDBUSMessageHandler.append((dbus_uint16_t) sourceID);
- mDBUSMessageHandler.append(availability);
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
-{
- log(&commandDbus, DLT_LOG_INFO, "cbVolumeChanged called, sinkID", sinkID, "volume", volume);
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), std::string("VolumeChanged"));
- mDBUSMessageHandler.append((dbus_uint16_t) sinkID);
- mDBUSMessageHandler.append((dbus_int16_t) volume);
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
-{
- log(&commandDbus, DLT_LOG_INFO, "cbSinkMuteStateChanged called, sinkID", sinkID, "muteState", muteState);
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), std::string("SinkMuteStateChanged"));
- mDBUSMessageHandler.append((dbus_uint16_t) sinkID);
- mDBUSMessageHandler.append((dbus_int16_t) muteState);
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::cbSystemPropertyChanged(const am_SystemProperty_s & SystemProperty)
-{
- log(&commandDbus, DLT_LOG_INFO, "cbSystemPropertyChanged called, SystemProperty.type", SystemProperty.type, "SystemProperty.value", SystemProperty.value);
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), std::string("SystemPropertyChanged"));
- mDBUSMessageHandler.append(SystemProperty);
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void am::DbusCommandSender::cbTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)
-{
- log(&commandDbus, DLT_LOG_INFO, "cbTimingInformationChanged called, mainConnectionID=", mainConnectionID, "time=", time);
-
- if (mReady)
- {
- mDBUSMessageHandler.initSignal(std::string(MY_NODE), std::string("TimingInformationChanged"));
- mDBUSMessageHandler.append((dbus_uint16_t) mainConnectionID);
- mDBUSMessageHandler.append((dbus_int16_t) time);
- mDBUSMessageHandler.sendMessage();
- }
-}
-
-void DbusCommandSender::getInterfaceVersion(std::string & version) const
-{
- version = CommandSendVersion;
-}
-
diff --git a/PluginCommandInterfaceDbus/src/CommandReceiverShadow.cpp b/PluginCommandInterfaceDbus/src/IAmCommandReceiverShadow.cpp
index 313818f..f43c9e6 100644
--- a/PluginCommandInterfaceDbus/src/CommandReceiverShadow.cpp
+++ b/PluginCommandInterfaceDbus/src/IAmCommandReceiverShadow.cpp
@@ -23,13 +23,14 @@
* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
*/
-#include <audiomanagertypes.h>
+#include "IAmCommandReceiverShadow.h"
#include <string>
#include <fstream>
+#include <stdexcept>
#include <cassert>
-#include "CommandReceiverShadow.h"
-#include "DBusCommandSender.h"
-#include "DLTWrapper.h"
+#include "audiomanagertypes.h"
+#include "CAmCommandSenderDbus.h"
+#include "shared/CAmDltWrapper.h"
using namespace am;
@@ -40,107 +41,107 @@ DLT_IMPORT_CONTEXT(commandDbus)
*/
static DBusObjectPathVTable gObjectPathVTable;
-CommandReceiverShadow::CommandReceiverShadow() :
- mCommandReceiveInterface(NULL), //
- mDBusWrapper(NULL), //
+IAmCommandReceiverShadow::IAmCommandReceiverShadow() :
mFunctionMap(createMap()), //
- mDBUSMessageHandler()
+ mDBUSMessageHandler(), //
+ mpIAmCommandReceive(NULL), //
+ mpCAmDbusWrapper(NULL)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow constructed");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow constructed");
}
-CommandReceiverShadow::~CommandReceiverShadow()
+IAmCommandReceiverShadow::~IAmCommandReceiverShadow()
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow destructed");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow destructed");
}
-void CommandReceiverShadow::connect(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::connect(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::connect called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::connect called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
mDBUSMessageHandler.initReceive(msg);
am_sourceID_t sourceID = (am_sourceID_t) mDBUSMessageHandler.getUInt();
am_sinkID_t sinkID = (am_sinkID_t) mDBUSMessageHandler.getUInt();
am_mainConnectionID_t mainConnectionID = 0;
- am_Error_e returnCode = mCommandReceiveInterface->connect(sourceID, sinkID, mainConnectionID);
+ am_Error_e returnCode = mpIAmCommandReceive->connect(sourceID, sinkID, mainConnectionID);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.append((dbus_uint16_t) mainConnectionID);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::disconnect(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::disconnect(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::disconnect called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::disconnect called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
mDBUSMessageHandler.initReceive(msg);
am_mainConnectionID_t mainConnnectionID = (am_mainConnectionID_t) mDBUSMessageHandler.getUInt();
- am_Error_e returnCode = mCommandReceiveInterface->disconnect(mainConnnectionID);
+ am_Error_e returnCode = mpIAmCommandReceive->disconnect(mainConnnectionID);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::setVolume(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::setVolume(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::setVolume called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::setVolume called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
mDBUSMessageHandler.initReceive(msg);
am_sinkID_t sinkID = (am_sinkID_t) mDBUSMessageHandler.getUInt();
am_volume_t volume = (am_volume_t) mDBUSMessageHandler.getInt();
- am_Error_e returnCode = mCommandReceiveInterface->setVolume(sinkID, volume);
+ am_Error_e returnCode = mpIAmCommandReceive->setVolume(sinkID, volume);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::volumeStep(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::volumeStep(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::volumeStep called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::volumeStep called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
mDBUSMessageHandler.initReceive(msg);
am_sinkID_t sinkID = (am_sinkID_t) mDBUSMessageHandler.getUInt();
int16_t volumeStep = (int16_t) mDBUSMessageHandler.getInt();
- am_Error_e returnCode = mCommandReceiveInterface->volumeStep(sinkID, volumeStep);
+ am_Error_e returnCode = mpIAmCommandReceive->volumeStep(sinkID, volumeStep);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::setSinkMuteState(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::setSinkMuteState(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::setSinkMuteState called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::setSinkMuteState called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
mDBUSMessageHandler.initReceive(msg);
am_sinkID_t sinkID = (am_sinkID_t) mDBUSMessageHandler.getUInt();
am_MuteState_e muteState = (am_MuteState_e) mDBUSMessageHandler.getInt();
- am_Error_e returnCode = mCommandReceiveInterface->setSinkMuteState(sinkID, muteState);
+ am_Error_e returnCode = mpIAmCommandReceive->setSinkMuteState(sinkID, muteState);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::setMainSinkSoundProperty(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::setMainSinkSoundProperty(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::setMainSinkSoundProperty called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::setMainSinkSoundProperty called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
mDBUSMessageHandler.initReceive(msg);
am_sinkID_t sinkID = (am_sinkID_t) mDBUSMessageHandler.getUInt();
@@ -150,18 +151,18 @@ void CommandReceiverShadow::setMainSinkSoundProperty(DBusConnection *conn, DBusM
am_MainSoundProperty_s mainSoundProperty;
mainSoundProperty.type = (am_MainSoundPropertyType_e) type;
mainSoundProperty.value = (int32_t) value;
- am_Error_e returnCode = mCommandReceiveInterface->setMainSinkSoundProperty(mainSoundProperty, sinkID);
+ am_Error_e returnCode = mpIAmCommandReceive->setMainSinkSoundProperty(mainSoundProperty, sinkID);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::setMainSourceSoundProperty(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::setMainSourceSoundProperty(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::setMainSourceSoundProperty called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::setMainSourceSoundProperty called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
mDBUSMessageHandler.initReceive(msg);
am_sourceID_t sourceID = (am_sinkID_t) mDBUSMessageHandler.getUInt();
@@ -171,18 +172,18 @@ void CommandReceiverShadow::setMainSourceSoundProperty(DBusConnection *conn, DBu
am_MainSoundProperty_s mainSoundProperty;
mainSoundProperty.type = (am_MainSoundPropertyType_e) type;
mainSoundProperty.value = (int32_t) value;
- am_Error_e returnCode = mCommandReceiveInterface->setMainSourceSoundProperty(mainSoundProperty, sourceID);
+ am_Error_e returnCode = mpIAmCommandReceive->setMainSourceSoundProperty(mainSoundProperty, sourceID);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::setSystemProperty(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::setSystemProperty(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::setSystemProperty called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::setSystemProperty called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
mDBUSMessageHandler.initReceive(msg);
dbus_int16_t type = 0;
@@ -191,157 +192,157 @@ void CommandReceiverShadow::setSystemProperty(DBusConnection *conn, DBusMessage
am_SystemProperty_s systemProperty;
systemProperty.type = (am_SystemPropertyType_e) type;
systemProperty.value = (int32_t) value;
- am_Error_e returnCode = mCommandReceiveInterface->setSystemProperty(systemProperty);
+ am_Error_e returnCode = mpIAmCommandReceive->setSystemProperty(systemProperty);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::getListMainConnections(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::getListMainConnections(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListMainConnections called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListMainConnections called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
std::vector<am_MainConnectionType_s> listMainConnections;
- am_Error_e returnCode = mCommandReceiveInterface->getListMainConnections(listMainConnections);
+ am_Error_e returnCode = mpIAmCommandReceive->getListMainConnections(listMainConnections);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.append(listMainConnections);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::getListMainSinks(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::getListMainSinks(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListMainSinks called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListMainSinks called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
std::vector<am_SinkType_s> listSinks;
- am_Error_e returnCode = mCommandReceiveInterface->getListMainSinks(listSinks);
+ am_Error_e returnCode = mpIAmCommandReceive->getListMainSinks(listSinks);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.append(listSinks);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::getListMainSources(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::getListMainSources(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListMainSources called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListMainSources called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
std::vector<am_SourceType_s> listSources;
- am_Error_e returnCode = mCommandReceiveInterface->getListMainSources(listSources);
+ am_Error_e returnCode = mpIAmCommandReceive->getListMainSources(listSources);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.append(listSources);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::getListMainSinkSoundProperties(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::getListMainSinkSoundProperties(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListMainSinkSoundProperties called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListMainSinkSoundProperties called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
mDBUSMessageHandler.initReceive(msg);
am_sinkID_t sinkID = (am_sinkID_t) mDBUSMessageHandler.getUInt();
std::vector<am_MainSoundProperty_s> listSinkSoundProperties;
- am_Error_e returnCode = mCommandReceiveInterface->getListMainSinkSoundProperties(sinkID, listSinkSoundProperties);
+ am_Error_e returnCode = mpIAmCommandReceive->getListMainSinkSoundProperties(sinkID, listSinkSoundProperties);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.append(listSinkSoundProperties);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::getListMainSourceSoundProperties(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::getListMainSourceSoundProperties(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListMainSourceSoundProperties called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListMainSourceSoundProperties called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
mDBUSMessageHandler.initReceive(msg);
am_sourceID_t sourceID = (am_sourceID_t) mDBUSMessageHandler.getUInt();
std::vector<am_MainSoundProperty_s> listSinkSoundProperties;
- am_Error_e returnCode = mCommandReceiveInterface->getListMainSourceSoundProperties(sourceID, listSinkSoundProperties);
+ am_Error_e returnCode = mpIAmCommandReceive->getListMainSourceSoundProperties(sourceID, listSinkSoundProperties);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.append(listSinkSoundProperties);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::getListSourceClasses(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::getListSourceClasses(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListSourceClasses called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListSourceClasses called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
std::vector<am_SourceClass_s> listSourceClasses;
- am_Error_e returnCode = mCommandReceiveInterface->getListSourceClasses(listSourceClasses);
+ am_Error_e returnCode = mpIAmCommandReceive->getListSourceClasses(listSourceClasses);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.append(listSourceClasses);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::getListSinkClasses(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::getListSinkClasses(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListSinkClasses called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListSinkClasses called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
std::vector<am_SinkClass_s> listSinkClasses;
- am_Error_e returnCode = mCommandReceiveInterface->getListSinkClasses(listSinkClasses);
+ am_Error_e returnCode = mpIAmCommandReceive->getListSinkClasses(listSinkClasses);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.append(listSinkClasses);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::getListSystemProperties(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::getListSystemProperties(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListSystemProperties called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListSystemProperties called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
std::vector<am_SystemProperty_s> listSystemProperties;
- am_Error_e returnCode = mCommandReceiveInterface->getListSystemProperties(listSystemProperties);
+ am_Error_e returnCode = mpIAmCommandReceive->getListSystemProperties(listSystemProperties);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.append(listSystemProperties);
mDBUSMessageHandler.sendMessage();
}
-void CommandReceiverShadow::getTimingInformation(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::getTimingInformation(DBusConnection *conn, DBusMessage *msg)
{
- log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getTimingInformation called");
+ log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getTimingInformation called");
(void) conn;
- assert(mCommandReceiveInterface!=NULL);
+ assert(mpIAmCommandReceive!=NULL);
mDBUSMessageHandler.initReceive(msg);
am_mainConnectionID_t mainConnectionID = (am_mainConnectionID_t) mDBUSMessageHandler.getUInt();
am_timeSync_t delay = 0;
- am_Error_e returnCode = mCommandReceiveInterface->getTimingInformation(mainConnectionID, delay);
+ am_Error_e returnCode = mpIAmCommandReceive->getTimingInformation(mainConnectionID, delay);
mDBUSMessageHandler.initReply(msg);
mDBUSMessageHandler.append((dbus_int16_t) returnCode);
mDBUSMessageHandler.append((dbus_int16_t) delay);
mDBUSMessageHandler.sendMessage();
}
-DBusHandlerResult CommandReceiverShadow::receiveCallback(DBusConnection *conn, DBusMessage *msg, void *user_data)
+DBusHandlerResult IAmCommandReceiverShadow::receiveCallback(DBusConnection *conn, DBusMessage *msg, void *user_data)
{
assert(conn!=NULL);
assert(msg!=NULL);
assert(user_data!=NULL);
- CommandReceiverShadow* reference = (CommandReceiverShadow*) user_data;
+ IAmCommandReceiverShadow* reference = (IAmCommandReceiverShadow*) user_data;
return (reference->receiveCallbackDelegate(conn, msg));
}
-void CommandReceiverShadow::sendIntrospection(DBusConnection *conn, DBusMessage *msg)
+void IAmCommandReceiverShadow::sendIntrospection(DBusConnection *conn, DBusMessage *msg)
{
assert(conn!=NULL);
assert(msg!=NULL);
@@ -351,8 +352,12 @@ void CommandReceiverShadow::sendIntrospection(DBusConnection *conn, DBusMessage
// create a reply from the message
reply = dbus_message_new_method_return(msg);
- std::ifstream in(INTROSPECTION_COMMAND_XML_FILE);
- assert(in!=NULL);
+ std::ifstream in("CommandInterface.xml", std::ifstream::in);
+ if (!in)
+ {
+ logError("IAmCommandReceiverShadow::sendIntrospection could not load xml file");
+ throw std::runtime_error("IAmCommandReceiverShadow::sendIntrospection Could not load introspecton XML");
+ }
std::string introspect((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
const char* string = introspect.c_str();
@@ -374,7 +379,7 @@ void CommandReceiverShadow::sendIntrospection(DBusConnection *conn, DBusMessage
dbus_message_unref(reply);
}
-DBusHandlerResult CommandReceiverShadow::receiveCallbackDelegate(DBusConnection *conn, DBusMessage *msg)
+DBusHandlerResult IAmCommandReceiverShadow::receiveCallbackDelegate(DBusConnection *conn, DBusMessage *msg)
{
//DLT_LOG(dMain, DLT_LOG_INFO, DLT_STRING("message received"));
@@ -398,45 +403,45 @@ DBusHandlerResult CommandReceiverShadow::receiveCallbackDelegate(DBusConnection
return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
}
-void CommandReceiverShadow::setCommandReceiver(CommandReceiveInterface*& receiver)
+void IAmCommandReceiverShadow::setCommandReceiver(IAmCommandReceive*& receiver)
{
assert(receiver!=NULL);
- mCommandReceiveInterface = receiver;
+ mpIAmCommandReceive = receiver;
- gObjectPathVTable.message_function = CommandReceiverShadow::receiveCallback;
+ gObjectPathVTable.message_function = IAmCommandReceiverShadow::receiveCallback;
DBusConnection* connection;
- mCommandReceiveInterface->getDBusConnectionWrapper(mDBusWrapper);
- assert(mDBusWrapper!=NULL);
+ mpIAmCommandReceive->getDBusConnectionWrapper(mpCAmDbusWrapper);
+ assert(mpCAmDbusWrapper!=NULL);
- mDBusWrapper->getDBusConnection(connection);
+ mpCAmDbusWrapper->getDBusConnection(connection);
assert(connection!=NULL);
mDBUSMessageHandler.setDBusConnection(connection);
std::string path(MY_NODE);
- mDBusWrapper->registerCallback(&gObjectPathVTable, path, this);
+ mpCAmDbusWrapper->registerCallback(&gObjectPathVTable, path, this);
}
-CommandReceiverShadow::functionMap_t CommandReceiverShadow::createMap()
+IAmCommandReceiverShadow::functionMap_t IAmCommandReceiverShadow::createMap()
{
functionMap_t m;
- m["Connect"] = &CommandReceiverShadow::connect;
- m["Disconnect"] = &CommandReceiverShadow::disconnect;
- m["SetVolume"] = &CommandReceiverShadow::setVolume;
- m["VolumeStep"] = &CommandReceiverShadow::volumeStep;
- m["SetSinkMuteState"] = &CommandReceiverShadow::setSinkMuteState;
- m["SetMainSinkSoundProperty"] = &CommandReceiverShadow::setMainSinkSoundProperty;
- m["SetMainSourceSoundProperty"] = &CommandReceiverShadow::setMainSourceSoundProperty;
- m["GetListMainConnections"] = &CommandReceiverShadow::getListMainConnections;
- m["GetListMainSinks"] = &CommandReceiverShadow::getListMainSinks;
- m["GetListMainSources"] = &CommandReceiverShadow::getListMainSources;
- m["GetListMainSinkSoundProperties"] = &CommandReceiverShadow::getListMainSinkSoundProperties;
- m["GetListMainSourceSoundProperties"] = &CommandReceiverShadow::getListMainSourceSoundProperties;
- m["GetListSourceClasses"] = &CommandReceiverShadow::getListSourceClasses;
- m["GetListSinkClasses"] = &CommandReceiverShadow::getListSinkClasses;
- m["GetListSystemProperties"] = &CommandReceiverShadow::getListSystemProperties;
- m["GetTimingInformation"] = &CommandReceiverShadow::getTimingInformation;
- m["SetSystemProperty"] = &CommandReceiverShadow::setSystemProperty;
+ m["Connect"] = &IAmCommandReceiverShadow::connect;
+ m["Disconnect"] = &IAmCommandReceiverShadow::disconnect;
+ m["SetVolume"] = &IAmCommandReceiverShadow::setVolume;
+ m["VolumeStep"] = &IAmCommandReceiverShadow::volumeStep;
+ m["SetSinkMuteState"] = &IAmCommandReceiverShadow::setSinkMuteState;
+ m["SetMainSinkSoundProperty"] = &IAmCommandReceiverShadow::setMainSinkSoundProperty;
+ m["SetMainSourceSoundProperty"] = &IAmCommandReceiverShadow::setMainSourceSoundProperty;
+ m["GetListMainConnections"] = &IAmCommandReceiverShadow::getListMainConnections;
+ m["GetListMainSinks"] = &IAmCommandReceiverShadow::getListMainSinks;
+ m["GetListMainSources"] = &IAmCommandReceiverShadow::getListMainSources;
+ m["GetListMainSinkSoundProperties"] = &IAmCommandReceiverShadow::getListMainSinkSoundProperties;
+ m["GetListMainSourceSoundProperties"] = &IAmCommandReceiverShadow::getListMainSourceSoundProperties;
+ m["GetListSourceClasses"] = &IAmCommandReceiverShadow::getListSourceClasses;
+ m["GetListSinkClasses"] = &IAmCommandReceiverShadow::getListSinkClasses;
+ m["GetListSystemProperties"] = &IAmCommandReceiverShadow::getListSystemProperties;
+ m["GetTimingInformation"] = &IAmCommandReceiverShadow::getTimingInformation;
+ m["SetSystemProperty"] = &IAmCommandReceiverShadow::setSystemProperty;
return (m);
}
diff --git a/PluginCommandInterfaceDbus/test/DbusCommandInterfaceBackdoor.cpp b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusBackdoor.cpp
index a61f693..c3f53e1 100644
--- a/PluginCommandInterfaceDbus/test/DbusCommandInterfaceBackdoor.cpp
+++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusBackdoor.cpp
@@ -23,35 +23,36 @@
* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
*/
-#include "DbusCommandInterfaceBackdoor.h"
+#include "CAmCommandSenderDbusBackdoor.h"
+#include "command/IAmCommandReceive.h"
using namespace am;
-DbusCommandInterfaceBackdoor::DbusCommandInterfaceBackdoor()
+CAmCommandSenderDbusBackdoor::CAmCommandSenderDbusBackdoor()
{
}
-DbusCommandInterfaceBackdoor::~DbusCommandInterfaceBackdoor()
+CAmCommandSenderDbusBackdoor::~CAmCommandSenderDbusBackdoor()
{
}
-void DbusCommandInterfaceBackdoor::setReceiveInterface(DbusCommandSender *sender, CommandReceiveInterface* interface)
+void CAmCommandSenderDbusBackdoor::setReceiveInterface(CAmCommandSenderDbus *sender, IAmCommandReceive* interface)
{
- sender->mCommandReceiveInterface=interface;
+ sender->mpIAmCommandReceive=interface;
}
-void DbusCommandInterfaceBackdoor::setDbusConnection(DbusCommandSender *sender, DBusConnection *conn)
+void CAmCommandSenderDbusBackdoor::setDbusConnection(CAmCommandSenderDbus *sender, DBusConnection *conn)
{
- sender->mDBUSMessageHandler.setDBusConnection(conn);
+ sender->mCAmDbusMessageHandler.setDBusConnection(conn);
}
-void DbusCommandInterfaceBackdoor::setListSinks(DbusCommandSender *sender, std::vector<am_SinkType_s> newList)
+void CAmCommandSenderDbusBackdoor::setListSinks(CAmCommandSenderDbus *sender, std::vector<am_SinkType_s> newList)
{
sender->mlistSinks=newList;
}
-void DbusCommandInterfaceBackdoor::setListSources(DbusCommandSender *sender, std::vector<am_SourceType_s> newList)
+void CAmCommandSenderDbusBackdoor::setListSources(CAmCommandSenderDbus *sender, std::vector<am_SourceType_s> newList)
{
sender->mlistSources=newList;
}
diff --git a/PluginCommandInterfaceDbus/test/DbusCommandInterfaceBackdoor.h b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusBackdoor.h
index 1549e65..bbbeda9 100644
--- a/PluginCommandInterfaceDbus/test/DbusCommandInterfaceBackdoor.h
+++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusBackdoor.h
@@ -3,7 +3,7 @@
*
* GeniviAudioMananger AudioManagerDaemon
*
-* \file DubsCommandInterfaceBackdoor.h
+* \file DubsIAmCommandBackdoor
*
* \date 20-Oct-2011 3:42:04 PM
* \author Christian Mueller (christian.ei.mueller@bmw.de)
@@ -26,24 +26,25 @@
#ifndef DBUSCOMMANDINTERFACEBACKDOOR_H_
#define DBUSCOMMANDINTERFACEBACKDOOR_H_
+#include "../include/CAmCommandSenderDbus.h"
+#include <vector>
#include <dbus/dbus.h>
-#include "../include/DBusCommandSender.h"
-#include "../include/DBusMessageHandler.h"
-#include "../include/CommandReceiverShadow.h"
+#include "audiomanagertypes.h"
+#include "command/IAmCommandReceive.h"
namespace am {
-class DbusCommandSender;
+class CAmCommandSenderDbus;
-class DbusCommandInterfaceBackdoor
+class CAmCommandSenderDbusBackdoor
{
public:
- DbusCommandInterfaceBackdoor();
- virtual ~DbusCommandInterfaceBackdoor();
- void setReceiveInterface(DbusCommandSender *sender, CommandReceiveInterface* interface);
- void setDbusConnection(DbusCommandSender *sender,DBusConnection *conn);
- void setListSinks(DbusCommandSender *sender, std::vector<am_SinkType_s> newList);
- void setListSources(DbusCommandSender *sender, std::vector<am_SourceType_s> newList);
+ CAmCommandSenderDbusBackdoor();
+ virtual ~CAmCommandSenderDbusBackdoor();
+ void setReceiveInterface(CAmCommandSenderDbus *sender, IAmCommandReceive* interface);
+ void setDbusConnection(CAmCommandSenderDbus *sender,DBusConnection *conn);
+ void setListSinks(CAmCommandSenderDbus *sender, std::vector<am_SinkType_s> newList);
+ void setListSources(CAmCommandSenderDbus *sender, std::vector<am_SourceType_s> newList);
};
}
diff --git a/PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.cpp b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.cpp
index 655a1f3..071af58 100644
--- a/PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.cpp
+++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.cpp
@@ -23,48 +23,47 @@
* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
*/
-#include "dbuscommaninterfacesignalsTest.h"
+#include "CAmCommandSenderDbusSignalTest.h"
+#include <python2.6/Python.h>
#include <iostream>
#include <fstream>
-#include <python2.6/Python.h>
-#include "../include/DBusCommandSender.h"
-#include "../include/DBusMessageHandler.h"
-#include "DbusCommandInterfaceBackdoor.h"
-#include "MockInterfaces.h"
-#include "DLTWrapper.h"
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <set>
+#include "CAmCommandSenderDbusBackdoor.h"
+#include "MockIAmCommandReceive.h"
+#include "../include/CAmCommandSenderDbus.h"
+#include "../include/CAmDbusMessageHandler.h"
+#include "../../AudioManagerDaemon/include/TAmPluginTemplate.h"
+#include "shared/CAmDltWrapper.h"
using namespace am;
using namespace testing;
-
-dbuscommaninterfacesignalsTest::dbuscommaninterfacesignalsTest()
+CAmCommandSenderDbusSignalTest::CAmCommandSenderDbusSignalTest()
{
- DLTWrapper::instance()->registerApp("dbusTest","dbusTest");
+ CAmDltWrapper::instance()->registerApp("dbusTest", "dbusTest");
logInfo("dbusCommandInterfaceSignalTest started");
}
-dbuscommaninterfacesignalsTest::~dbuscommaninterfacesignalsTest()
+CAmCommandSenderDbusSignalTest::~CAmCommandSenderDbusSignalTest()
{
}
-void* NumberOfMainConnectionsChanged(void*)
+void* NumberOfMainConnectionsChanged(void* ppCommandSend)
{
sleep(1);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
- sender.cbNumberOfMainConnectionsChanged();
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
+ am_MainConnectionType_s mainConnection;
+ sender->cbNewMainConnection(mainConnection);
return (NULL);
}
-void* cbSinkAdded(void*)
+void* cbSinkAdded(void* ppCommandSend)
{
sleep(1);
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
std::vector<am_SinkType_s> list;
am_SinkType_s mysink;
mysink.name = "MySink";
@@ -74,290 +73,191 @@ void* cbSinkAdded(void*)
mysink.muteState = MS_UNKNOWN;
mysink.sinkClassID = 3;
mysink.volume = 234;
- list.push_back(mysink);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- EXPECT_CALL(receiver,getListMainSinks(_)).WillOnce(DoAll(SetArgReferee<0>(list), Return(E_OK)));
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
- sender.cbNewSink(mysink);
+ sender->cbNewSink(mysink);
return (NULL);
}
-void* cbSourceAdded(void*)
+void* cbSourceAdded(void* ppCommandSend)
{
sleep(1);
- std::vector<am_SourceType_s> list;
- am_SourceType_s myource;
- myource.name = "MySink";
- myource.sourceID = 42;
- myource.availability.availability = A_MAX;
- myource.availability.availabilityReason = AR_UNKNOWN;
- myource.sourceClassID = 15;
- list.push_back(myource);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
- EXPECT_CALL(receiver,getListMainSources(_)).WillOnce(DoAll(SetArgReferee<0>(list), Return(E_OK)));
- sender.cbNumberOfSourcesChanged();
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
+ am_SourceType_s mysource;
+ mysource.name = "MySink";
+ mysource.sourceID = 42;
+ mysource.availability.availability = A_MAX;
+ mysource.availability.availabilityReason = AR_UNKNOWN;
+ mysource.sourceClassID = 15;
+ sender->cbNewSource(mysource);
return (NULL);
}
-void* cbSourceRemoved(void*)
+void* cbSourceRemoved(void* ppCommandSend)
{
sleep(1);
- std::vector<am_SourceType_s> list;
- am_SourceType_s myource;
- myource.name = "MySink";
- myource.sourceID = 42;
- myource.availability.availability = A_MAX;
- myource.availability.availabilityReason = AR_UNKNOWN;
- myource.sourceClassID = 15;
- list.push_back(myource);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- backdoor.setListSources(&sender, list);
- DBusError error;
- dbus_error_init(&error);
- list.clear();
- EXPECT_CALL(receiver,getListMainSources(_)).WillOnce(DoAll(SetArgReferee<0>(list), Return(E_OK)));
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
- sender.cbNumberOfSourcesChanged();
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
+ am_SourceType_s mysource;
+ mysource.name = "MySink";
+ mysource.sourceID = 42;
+ sender->cbRemovedSource(mysource.sourceID);
return (NULL);
}
-void* cbSinkRemoved(void*)
+void* cbSinkRemoved(void* ppCommandSend)
{
sleep(1);
- std::vector<am_SinkType_s> list;
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
am_SinkType_s mysink;
mysink.name = "MySink";
mysink.sinkID = 23;
- mysink.availability.availability = A_MAX;
- mysink.availability.availabilityReason = AR_UNKNOWN;
- mysink.muteState = MS_UNKNOWN;
- mysink.sinkClassID = 3;
- mysink.volume = 234;
- list.push_back(mysink);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- backdoor.setListSinks(&sender, list);
- DBusError error;
- dbus_error_init(&error);
- list.clear();
- EXPECT_CALL(receiver,getListMainSinks(_)).WillOnce(DoAll(SetArgReferee<0>(list), Return(E_OK)));
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
- sender.cbNumberOfSinksChanged();
+ sender->cbRemovedSink(mysink.sinkID);
return (NULL);
}
-void* NumberOfSinkClassesChanged(void*)
+void* NumberOfSinkClassesChanged(void* ppCommandSend)
{
sleep(1);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
- sender.cbNumberOfSinkClassesChanged();
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
+ sender->cbNumberOfSinkClassesChanged();
return (NULL);
}
-void* NumberOfSourceClassesChanged(void*)
+void* NumberOfSourceClassesChanged(void* ppCommandSend)
{
sleep(1);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
- sender.cbNumberOfSourceClassesChanged();
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
+ sender->cbNumberOfSourceClassesChanged();
return (NULL);
}
-void* MainConnectionStateChanged(void*)
+void* MainConnectionStateChanged(void* ppCommandSend)
{
sleep(1);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
am_connectionID_t id = 4;
am_ConnectionState_e state = CS_CONNECTING;
- sender.cbMainConnectionStateChanged(id, state);
+ sender->cbMainConnectionStateChanged(id, state);
return (NULL);
}
-void* MainSinkSoundPropertyChanged(void*)
+void* MainSinkSoundPropertyChanged(void* ppCommandSend)
{
sleep(1);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
am_sinkID_t sinkID = 3;
am_MainSoundProperty_s soundProperty;
soundProperty.type = MSP_UNKNOWN;
soundProperty.value = 23;
- sender.cbMainSinkSoundPropertyChanged(sinkID, soundProperty);
+ sender->cbMainSinkSoundPropertyChanged(sinkID, soundProperty);
return (NULL);
}
-void* MainSourceSoundPropertyChanged(void*)
+void* MainSourceSoundPropertyChanged(void* ppCommandSend)
{
sleep(1);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
am_sourceID_t sourceID = 35;
am_MainSoundProperty_s soundProperty;
soundProperty.type = MSP_UNKNOWN;
soundProperty.value = 233;
- sender.cbMainSourceSoundPropertyChanged(sourceID, soundProperty);
+ sender->cbMainSourceSoundPropertyChanged(sourceID, soundProperty);
return (NULL);
}
-void* cbSinkAvailabilityChangedLoop(void*)
+void* cbSinkAvailabilityChangedLoop(void* ppCommandSend)
{
sleep(1);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
am_Availability_s av;
av.availability = A_AVAILABLE;
av.availabilityReason = AR_UNKNOWN;
- sender.cbSinkAvailabilityChanged(4, av);
+ sender->cbSinkAvailabilityChanged(4, av);
return (NULL);
}
-void* VolumeChanged(void*)
+void* VolumeChanged(void* ppCommandSend)
{
sleep(1);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
am_volume_t volume = 344;
- sender.cbVolumeChanged(23, volume);
+ sender->cbVolumeChanged(23, volume);
return (NULL);
}
-void* cbSourceAvailabilityChangedLoop(void*)
+void* cbSourceAvailabilityChangedLoop(void* ppCommandSend)
{
sleep(1);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
am_Availability_s av;
av.availability = A_AVAILABLE;
av.availabilityReason = AR_UNKNOWN;
- sender.cbSourceAvailabilityChanged(2, av);
+ sender->cbSourceAvailabilityChanged(2, av);
return (NULL);
}
-void* SinkMuteStateChanged(void*)
+void* SinkMuteStateChanged(void* ppCommandSend)
{
sleep(1);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
- sender.cbSinkMuteStateChanged(42, MS_MUTED);
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
+ sender->cbSinkMuteStateChanged(42, MS_MUTED);
return (NULL);
}
-void* SystemPropertyChanged(void*)
+void* SystemPropertyChanged(void* ppCommandSend)
{
sleep(1);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
am_SystemProperty_s property;
property.type = SYP_UNKNOWN;
property.value = 355;
- sender.cbSystemPropertyChanged(property);
+ sender->cbSystemPropertyChanged(property);
return (NULL);
}
-void* TimingInformationChanged(void*)
+void* TimingInformationChanged(void* ppCommandSend)
{
sleep(1);
- DbusCommandSender sender;
- MockCommandReceiveInterface receiver;
- DbusCommandInterfaceBackdoor backdoor;
- backdoor.setReceiveInterface(&sender, &receiver);
- DBusError error;
- dbus_error_init(&error);
- DBusConnection* co = dbus_bus_get(DBUS_BUS_SESSION, &error);
- backdoor.setDbusConnection(&sender, co);
- sender.cbTimingInformationChanged(42, 233);
+ IAmCommandSend* sender=static_cast<IAmCommandSend*>(ppCommandSend);
+ sender->cbTimingInformationChanged(42, 233);
return (NULL);
}
-TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
+TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged)
{
//ok, now we want to test the signals. It did not work out that the python receiver worked in an own thread (as originally intended)
//so it is running in the main context and the signals are send from threads...
+ CAmSocketHandler pSocketHandler;
+ CAmDbusWrapper pDBusWrapper(&pSocketHandler);
+ MockIAmCommandReceive pReceiveInterface;
+
+ IAmCommandSend* (*createFunc)();
+ void* tempLibHandle = NULL;
+ std::string libname("../plugins/command/libPluginCommandInterfaceDbus.so");
+ createFunc = getCreateFunction<IAmCommandSend*()>(libname, tempLibHandle);
+
+ if (!createFunc)
+ {
+ logError("CommandSendInterface Test Entry point of RoutingPlugin not found");
+ exit(1);
+ }
+
+ ppCommandSend = createFunc();
+
+ if (!ppCommandSend)
+ {
+ logError("CommandSendInterface Test RoutingPlugin initialization failed. Entry Function not callable");
+ exit(1);
+ }
+
+ // ok, here we give the DBusWrapper pointer to the Plugin and start the interface
+ EXPECT_CALL(pReceiveInterface,getDBusConnectionWrapper(_)).WillRepeatedly(DoAll(SetArgReferee<0>(&pDBusWrapper), Return(E_OK)));
+ EXPECT_CALL(pReceiveInterface, confirmCommandReady(10));
+
+ ppCommandSend->startupInterface(&pReceiveInterface);
+ ppCommandSend->setCommandReady(10);
+
pthread_t pythonloop;
- pthread_create(&pythonloop, NULL, NumberOfMainConnectionsChanged, (void*) NULL);
+ pthread_create(&pythonloop, NULL, NumberOfMainConnectionsChanged, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -373,7 +273,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
"loop.run()\n", NULL);
pthread_join(pythonloop, NULL);
- pthread_create(&pythonloop, NULL, cbSinkAdded, (void*) NULL);
+ pthread_create(&pythonloop, NULL, cbSinkAdded, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -402,7 +302,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
}
ifs.close();
- pthread_create(&pythonloop, NULL, cbSinkRemoved, (void*) NULL);
+ pthread_create(&pythonloop, NULL, cbSinkRemoved, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -432,7 +332,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
}
ifs.close();
- pthread_create(&pythonloop, NULL, cbSourceAdded, (void*) NULL);
+ pthread_create(&pythonloop, NULL, cbSourceAdded, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -461,7 +361,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
}
ifs.close();
- pthread_create(&pythonloop, NULL, cbSourceRemoved, (void*) NULL);
+ pthread_create(&pythonloop, NULL, cbSourceRemoved, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -491,7 +391,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
}
ifs.close();
- pthread_create(&pythonloop, NULL, NumberOfSinkClassesChanged, (void*) NULL);
+ pthread_create(&pythonloop, NULL, NumberOfSinkClassesChanged, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -507,7 +407,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
"loop.run()\n", NULL);
pthread_join(pythonloop, NULL);
- pthread_create(&pythonloop, NULL, NumberOfSourceClassesChanged, (void*) NULL);
+ pthread_create(&pythonloop, NULL, NumberOfSourceClassesChanged, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -525,7 +425,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
//ok, now we want to test the signals. It did not work out that the python receiver worked in an own thread (as originally intended)
//so it is running in the main context and the signals are send from threads...
- pthread_create(&pythonloop, NULL, MainConnectionStateChanged, (void*) NULL);
+ pthread_create(&pythonloop, NULL, MainConnectionStateChanged, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -567,7 +467,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
//ok, now we want to test the signals. It did not work out that the python receiver worked in an own thread (as originally intended)
//so it is running in the main context and the signals are send from threads...
- pthread_create(&pythonloop, NULL, MainSinkSoundPropertyChanged, (void*) NULL);
+ pthread_create(&pythonloop, NULL, MainSinkSoundPropertyChanged, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -600,7 +500,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
}
else if (lineCounter == 1)
{
- ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(1), dbus.Int16(23)), signature=None)"), 0);
+ ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(0), dbus.Int16(23)), signature=None)"), 0);
}
lineCounter++;
}
@@ -608,7 +508,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
//ok, now we want to test the signals. It did not work out that the python receiver worked in an own thread (as originally intended)
//so it is running in the main context and the signals are send from threads...
- pthread_create(&pythonloop, NULL, MainSourceSoundPropertyChanged, (void*) NULL);
+ pthread_create(&pythonloop, NULL, MainSourceSoundPropertyChanged, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -641,7 +541,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
}
else if (lineCounter == 1)
{
- ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(1), dbus.Int16(233)), signature=None)"), 0);
+ ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(0), dbus.Int16(233)), signature=None)"), 0);
}
lineCounter++;
}
@@ -649,7 +549,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
//ok, now we want to test the signals. It did not work out that the python receiver worked in an own thread (as originally intended)
//so it is running in the main context and the signals are send from threads...
- pthread_create(&pythonloop, NULL, cbSinkAvailabilityChangedLoop, (void*) NULL);
+ pthread_create(&pythonloop, NULL, cbSinkAvailabilityChangedLoop, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -682,7 +582,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
}
else if (lineCounter == 1)
{
- ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(0), dbus.Int16(3)), signature=None)"), 0);
+ ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(1), dbus.Int16(0)), signature=None)"), 0);
}
lineCounter++;
}
@@ -690,7 +590,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
//ok, now we want to test the signals. It did not work out that the python receiver worked in an own thread (as originally intended)
//so it is running in the main context and the signals are send from threads...
- pthread_create(&pythonloop, NULL, cbSourceAvailabilityChangedLoop, (void*) NULL);
+ pthread_create(&pythonloop, NULL, cbSourceAvailabilityChangedLoop, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -723,7 +623,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
}
else if (lineCounter == 1)
{
- ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(0), dbus.Int16(3)), signature=None)"), 0);
+ ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(1), dbus.Int16(0)), signature=None)"), 0);
}
lineCounter++;
}
@@ -731,7 +631,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
//ok, now we want to test the signals. It did not work out that the python receiver worked in an own thread (as originally intended)
//so it is running in the main context and the signals are send from threads...
- pthread_create(&pythonloop, NULL, VolumeChanged, (void*) NULL);
+ pthread_create(&pythonloop, NULL, VolumeChanged, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -773,7 +673,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
//ok, now we want to test the signals. It did not work out that the python receiver worked in an own thread (as originally intended)
//so it is running in the main context and the signals are send from threads...
- pthread_create(&pythonloop, NULL, SinkMuteStateChanged, (void*) NULL);
+ pthread_create(&pythonloop, NULL, SinkMuteStateChanged, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -815,7 +715,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
//ok, now we want to test the signals. It did not work out that the python receiver worked in an own thread (as originally intended)
//so it is running in the main context and the signals are send from threads...
- pthread_create(&pythonloop, NULL, SystemPropertyChanged, (void*) NULL);
+ pthread_create(&pythonloop, NULL, SystemPropertyChanged, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -846,7 +746,7 @@ TEST_F(dbuscommaninterfacesignalsTest,cbSourceAvailabilityChanged)
//ok, now we want to test the signals. It did not work out that the python receiver worked in an own thread (as originally intended)
//so it is running in the main context and the signals are send from threads...
- pthread_create(&pythonloop, NULL, TimingInformationChanged, (void*) NULL);
+ pthread_create(&pythonloop, NULL, TimingInformationChanged, (void*) ppCommandSend);
PyRun_SimpleStringFlags("import sys\n"
"import traceback\n"
"import gobject\n"
@@ -894,12 +794,12 @@ int main(int argc, char **argv)
return RUN_ALL_TESTS();
}
-void dbuscommaninterfacesignalsTest::SetUp()
+void CAmCommandSenderDbusSignalTest::SetUp()
{
Py_Initialize();
}
-void dbuscommaninterfacesignalsTest::TearDown()
+void CAmCommandSenderDbusSignalTest::TearDown()
{
Py_Finalize();
}
diff --git a/PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.h b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.h
index 0f930d6..14ad9ef 100644
--- a/PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.h
+++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.h
@@ -25,25 +25,23 @@
#ifndef DBUSCOMMANINTERFACESIGNALSTEST_H_
#define DBUSCOMMANINTERFACESIGNALSTEST_H_
+
+
#include <gtest/gtest.h>
#include <gmock/gmock.h>
-#include <algorithm>
-#include <string>
-#include <vector>
-#include <set>
-#include "CommandReceiver.h"
-#include "CommandSender.h"
-#include "MockInterfaces.h"
#define UNIT_TEST 1
namespace am {
-class dbuscommaninterfacesignalsTest: public ::testing::Test
+class IAmCommandSend;
+
+class CAmCommandSenderDbusSignalTest: public ::testing::Test
{
public:
- dbuscommaninterfacesignalsTest();
- virtual ~dbuscommaninterfacesignalsTest();
+ IAmCommandSend *ppCommandSend;
+ CAmCommandSenderDbusSignalTest();
+ virtual ~CAmCommandSenderDbusSignalTest();
void SetUp();
void TearDown();
};
diff --git a/PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.cpp b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.cpp
index f4dab30..e1d0197 100644
--- a/PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.cpp
+++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.cpp
@@ -23,50 +23,51 @@
* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
*/
+#include "CAmCommandSenderDbusTest.h"
#include <python2.6/Python.h>
-#include <dbus/DBusWrapper.h>
-#include "dbuscommandpluginInterfaceTest.h"
#include <iostream>
#include <fstream>
-#include "../include/DBusCommandSender.h"
-#include "../include/DBusMessageHandler.h"
-#include "DbusCommandInterfaceBackdoor.h"
-#include "MockInterfaces.h"
-#include "DLTWrapper.h"
-#include "SocketHandler.h"
+#include <sstream>
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <set>
+#include "TAmPluginTemplate.h"
+#include "MockIAmCommandReceive.h"
+#include "shared/CAmDltWrapper.h"
+#include "shared/CAmSocketHandler.h"
+#include "shared/CAmDbusWrapper.h"
+#include "../include/CAmCommandSenderDbus.h"
+#include "../include/CAmDbusMessageHandler.h"
using namespace am;
using namespace testing;
-//DLT_DECLARE_CONTEXT(DLT_CONTEXT)
-
std::string DBUSCOMMAND = "dbus-send --session --print-reply --dest=org.genivi.audiomanager /org/genivi/audiomanager/CommandInterface org.genivi.audiomanager.CommandInterface.";
void* run_the_loop(void* wrapper)
{
- SocketHandler* wrap = (SocketHandler*) wrapper;
+ CAmSocketHandler* wrap = (CAmSocketHandler*) wrapper;
wrap->start_listenting();
return (NULL);
}
-dbuscommandpluginInterfaceTest::dbuscommandpluginInterfaceTest() :
- pDatabaseHandler(std::string(":memory:")), //
- pControlSender("") //
+CAmCommandSenderDbusTest::CAmCommandSenderDbusTest()
{
- DLTWrapper::instance()->registerApp("dbusTest", "dbusTest");
+ CAmDltWrapper::instance()->registerApp("dbusTest", "dbusTest");
}
-dbuscommandpluginInterfaceTest::~dbuscommandpluginInterfaceTest()
+CAmCommandSenderDbusTest::~CAmCommandSenderDbusTest()
{
}
-void dbuscommandpluginInterfaceTest::SetUp()
+void CAmCommandSenderDbusTest::SetUp()
{
}
-void dbuscommandpluginInterfaceTest::TearDown()
+void CAmCommandSenderDbusTest::TearDown()
{
}
@@ -172,26 +173,46 @@ am::am_timeSync_t time=23;
arg1=time;
}
-TEST_F(dbuscommandpluginInterfaceTest,Connect)
+TEST_F(CAmCommandSenderDbusTest, MessageTest)
{
Py_Initialize();
//unfortunatly we need to put all in one testcase because testing with the dbus loop caused problems...
- SocketHandler pSocketHandler;
- DBusWrapper pDBusWrapper(&pSocketHandler);
+ CAmSocketHandler pSocketHandler;
+ CAmDbusWrapper pDBusWrapper(&pSocketHandler);
pthread_t ptestThread;
std::vector<std::string> plistCommandPluginDirs;
plistCommandPluginDirs.push_back(std::string(DEFAULT_PLUGIN_COMMAND_DIR));
- CommandSender pCommandSender(plistCommandPluginDirs);
- MockCommandReceiveInterface pReceiveInterface;
+ MockIAmCommandReceive pReceiveInterface;
//this class just creates the thread that will handle the mainloop...
pthread_create(&ptestThread, NULL, run_the_loop, (void*) &pSocketHandler);
- CommandReceiver pCommandReceiver(&pDatabaseHandler, &pControlSender, &pSocketHandler, &pDBusWrapper);
+
+ IAmCommandSend* (*createFunc)();
+ void* tempLibHandle = NULL;
+ std::string libname("../plugins/command/libPluginCommandInterfaceDbus.so");
+ createFunc = getCreateFunction<IAmCommandSend*()>(libname, tempLibHandle);
+
+ if (!createFunc)
+ {
+ logError("CommandSendInterface Test Entry point of RoutingPlugin not found");
+ exit(1);
+ }
+
+ ppCommandSend = createFunc();
+
+ if (!ppCommandSend)
+ {
+ logError("CommandSendInterface Test RoutingPlugin initialization failed. Entry Function not callable");
+ exit(1);
+ }
// ok, here we give the DBusWrapper pointer to the Plugin and start the interface
EXPECT_CALL(pReceiveInterface,getDBusConnectionWrapper(_)).WillRepeatedly(DoAll(SetArgReferee<0>(&pDBusWrapper), Return(E_OK)));
- pCommandSender.startupInterfaces(&pCommandReceiver);
+ EXPECT_CALL(pReceiveInterface, confirmCommandReady(10));
+
+ ppCommandSend->startupInterface(&pReceiveInterface);
+ ppCommandSend->setCommandReady(10);
EXPECT_CALL(pReceiveInterface,connect(2,3,_)).WillRepeatedly(DoAll(SetArgReferee<2>(35), Return(E_OK)));
system((DBUSCOMMAND + std::string("Connect uint16:2 uint16:3 > /tmp/result.txt ")).c_str());
@@ -204,12 +225,12 @@ TEST_F(dbuscommandpluginInterfaceTest,Connect)
{
if (lineCounter == 1)
{
- std::stringstream(line.substr(line.find_first_not_of(" int16 "))) >> result;
+ std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result;
ASSERT_EQ(result, E_OK);
}
else if (lineCounter == 2)
{
- std::stringstream(line.substr(line.find_first_not_of(" uint16 "))) >> result;
+ std::stringstream(line.replace(line.begin(), line.begin() + 10, "")) >> result;
ASSERT_EQ(result, 35);
}
lineCounter++;
@@ -229,7 +250,7 @@ TEST_F(dbuscommandpluginInterfaceTest,Connect)
{
if (lineCounter == 1)
{
- std::stringstream(line.substr(line.find_first_not_of(" int16 "))) >> result;
+ std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result;
ASSERT_EQ(result, E_OK);
}
lineCounter++;
@@ -249,7 +270,7 @@ TEST_F(dbuscommandpluginInterfaceTest,Connect)
{
if (lineCounter == 1)
{
- std::stringstream(line.substr(line.find_first_not_of(" int16 "))) >> result;
+ std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result;
ASSERT_EQ(result, E_OK);
}
lineCounter++;
@@ -269,7 +290,7 @@ TEST_F(dbuscommandpluginInterfaceTest,Connect)
{
if (lineCounter == 1)
{
- std::stringstream(line.substr(line.find_first_not_of(" int16 "))) >> result;
+ std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result;
ASSERT_EQ(result, E_OK);
}
lineCounter++;
@@ -289,7 +310,7 @@ TEST_F(dbuscommandpluginInterfaceTest,Connect)
{
if (lineCounter == 1)
{
- std::stringstream(line.substr(line.find_first_not_of(" int16 "))) >> result;
+ std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result;
ASSERT_EQ(result, E_OK);
}
lineCounter++;
@@ -417,7 +438,7 @@ TEST_F(dbuscommandpluginInterfaceTest,Connect)
while (std::getline(ifs, line))
{
//we could parse here, but this is the fastest way....
- ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(24), dbus.String(u'mySink'), dbus.Struct((dbus.Int16(0), dbus.Int16(2)), signature=None), dbus.Int16(124), dbus.Int16(1), dbus.UInt16(34)), signature=None)], signature=dbus.Signature('(qs(nn)nnq)')))"), 0);
+ ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(24), dbus.String(u'mySink'), dbus.Struct((dbus.Int16(2), dbus.Int16(3)), signature=None), dbus.Int16(124), dbus.Int16(2), dbus.UInt16(34)), signature=None)], signature=dbus.Signature('(qs(nn)nnq)')))"), 0);
}
ifs.close();
@@ -442,7 +463,7 @@ TEST_F(dbuscommandpluginInterfaceTest,Connect)
while (std::getline(ifs, line))
{
//we could parse here, but this is the fastest way....
- ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(224), dbus.String(u'MySource'), dbus.Struct((dbus.Int16(3), dbus.Int16(1)), signature=None), dbus.UInt16(12)), signature=None), dbus.Struct((dbus.UInt16(22), dbus.String(u'NextSource'), dbus.Struct((dbus.Int16(3), dbus.Int16(1)), signature=None), dbus.UInt16(12)), signature=None)], signature=dbus.Signature('(qs(nn)q)')))"), 0);
+ ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(224), dbus.String(u'MySource'), dbus.Struct((dbus.Int16(3), dbus.Int16(2)), signature=None), dbus.UInt16(12)), signature=None), dbus.Struct((dbus.UInt16(22), dbus.String(u'NextSource'), dbus.Struct((dbus.Int16(3), dbus.Int16(2)), signature=None), dbus.UInt16(12)), signature=None)], signature=dbus.Signature('(qs(nn)q)')))"), 0);
}
ifs.close();
@@ -467,7 +488,7 @@ TEST_F(dbuscommandpluginInterfaceTest,Connect)
while (std::getline(ifs, line))
{
//we could parse here, but this is the fastest way....
- ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.Int16(2), dbus.Int16(223)), signature=None), dbus.Struct((dbus.Int16(0), dbus.Int16(2)), signature=None)], signature=dbus.Signature('(nn)')))"), 0);
+ ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.Int16(4), dbus.Int16(223)), signature=None), dbus.Struct((dbus.Int16(0), dbus.Int16(2)), signature=None)], signature=dbus.Signature('(nn)')))"), 0);
}
ifs.close();
@@ -492,7 +513,7 @@ TEST_F(dbuscommandpluginInterfaceTest,Connect)
while (std::getline(ifs, line))
{
//we could parse here, but this is the fastest way....
- ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.Int16(2), dbus.Int16(223)), signature=None), dbus.Struct((dbus.Int16(0), dbus.Int16(2)), signature=None)], signature=dbus.Signature('(nn)')))"), 0);
+ ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.Int16(4), dbus.Int16(223)), signature=None), dbus.Struct((dbus.Int16(0), dbus.Int16(2)), signature=None)], signature=dbus.Signature('(nn)')))"), 0);
}
ifs.close();
@@ -517,7 +538,7 @@ TEST_F(dbuscommandpluginInterfaceTest,Connect)
while (std::getline(ifs, line))
{
//we could parse here, but this is the fastest way....
- ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(23), dbus.String(u'FirstCLass'), dbus.Array([dbus.Struct((dbus.Int16(1), dbus.Int16(12)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None), dbus.Struct((dbus.UInt16(2), dbus.String(u'SecondCLass'), dbus.Array([dbus.Struct((dbus.Int16(1), dbus.Int16(12)), signature=None), dbus.Struct((dbus.Int16(1), dbus.Int16(12)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None)], signature=dbus.Signature('(qsa(nn))')))"), 0);
+ ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(23), dbus.String(u'FirstCLass'), dbus.Array([dbus.Struct((dbus.Int16(2), dbus.Int16(12)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None), dbus.Struct((dbus.UInt16(2), dbus.String(u'SecondCLass'), dbus.Array([dbus.Struct((dbus.Int16(2), dbus.Int16(12)), signature=None), dbus.Struct((dbus.Int16(2), dbus.Int16(12)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None)], signature=dbus.Signature('(qsa(nn))')))"), 0);
}
ifs.close();
@@ -542,7 +563,7 @@ TEST_F(dbuscommandpluginInterfaceTest,Connect)
while (std::getline(ifs, line))
{
//we could parse here, but this is the fastest way....
- ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(2123), dbus.String(u'FirstCLass'), dbus.Array([dbus.Struct((dbus.Int16(0), dbus.Int16(122)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None), dbus.Struct((dbus.UInt16(23), dbus.String(u'SecondCLass'), dbus.Array([dbus.Struct((dbus.Int16(0), dbus.Int16(122)), signature=None), dbus.Struct((dbus.Int16(0), dbus.Int16(122)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None)], signature=dbus.Signature('(qsa(nn))')))"), 0);
+ ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Array([dbus.Struct((dbus.UInt16(2123), dbus.String(u'FirstCLass'), dbus.Array([dbus.Struct((dbus.Int16(1), dbus.Int16(122)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None), dbus.Struct((dbus.UInt16(23), dbus.String(u'SecondCLass'), dbus.Array([dbus.Struct((dbus.Int16(1), dbus.Int16(122)), signature=None), dbus.Struct((dbus.Int16(1), dbus.Int16(122)), signature=None)], signature=dbus.Signature('(nn)'))), signature=None)], signature=dbus.Signature('(qsa(nn))')))"), 0);
}
ifs.close();
diff --git a/PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.h b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.h
index d45a107..a89affd 100644
--- a/PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.h
+++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.h
@@ -29,23 +29,13 @@
#include <gtest/gtest.h>
#include <gmock/gmock.h>
-#include <algorithm>
-#include <string>
-#include <vector>
-#include <set>
-#include "CommandReceiver.h"
-#include "CommandSender.h"
-#include "MockInterfaces.h"
-#include "DbusCommandInterfaceBackdoor.h"
-#include "DatabaseHandler.h"
-#include "ControlSender.h"
-
#define UNIT_TEST 1
namespace am {
-class DbusCommandInterfaceBackdoor;
+class CAmCommandSenderDbusBackdoor;
+class IAmCommandSend;
/*
* originally, I would want to have several tests, but there are problems implementing this with
@@ -55,13 +45,12 @@ class DbusCommandInterfaceBackdoor;
*/
-class dbuscommandpluginInterfaceTest :public ::testing::Test
+class CAmCommandSenderDbusTest :public ::testing::Test
{
public:
- DatabaseHandler pDatabaseHandler;
- ControlSender pControlSender;
- dbuscommandpluginInterfaceTest();
- ~dbuscommandpluginInterfaceTest();
+ IAmCommandSend *ppCommandSend;
+ CAmCommandSenderDbusTest();
+ ~CAmCommandSenderDbusTest();
void SetUp();
void TearDown();
diff --git a/PluginCommandInterfaceDbus/test/CMakeLists.txt b/PluginCommandInterfaceDbus/test/CMakeLists.txt
index 8745af8..d1eabbf 100644
--- a/PluginCommandInterfaceDbus/test/CMakeLists.txt
+++ b/PluginCommandInterfaceDbus/test/CMakeLists.txt
@@ -23,7 +23,7 @@
cmake_minimum_required(VERSION 2.6)
-PROJECT(controlInterfacetest)
+PROJECT(CAmCommandSenderDbusTests)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DUNIT_TEST=1 -DDLT_CONTEXT=AudioManager")
@@ -41,13 +41,13 @@ INCLUDE_DIRECTORIES(
${STD_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
- ${AUDIO_INCLUDES_FOLDER}
+ ${AUDIO_include_FOLDER}
${DBUS_ARCH_INCLUDE_DIR}
- ${DBUS_INCLUDES_FOLDER}
+ ${DBUS_include_FOLDER}
${CMAKE_SOURCE_DIR}
${DLT_INCLUDE_DIRS}
${DBUS_INCLUDE_DIR}
- ${INCLUDES_FOLDER}
+ ${include_FOLDER}
${PYTHON_INCLUDE_DIRS}
${GTEST_INCLUDE_DIR}
"../../AudioManagerDaemon/include"
@@ -55,31 +55,28 @@ INCLUDE_DIRECTORIES(
)
file(GLOB DBUS_PLUGIN_INTERFACE_SRCS_CXX
- "../../AudioManagerDaemon/src/DBusWrapper.cpp"
- "../../AudioManagerDaemon/src/CommandSender.cpp"
- "../../AudioManagerDaemon/src/SocketHandler.cpp"
- "../../AudioManagerDaemon/src/DLTWrapper.cpp"
+ "../../AudioManagerDaemon/src/CAmDbusWrapper.cpp"
+ "../../AudioManagerDaemon/src/CAmSocketHandler.cpp"
+ "../../AudioManagerDaemon/src/CAmDltWrapper.cpp"
"../src/*.cpp"
- "dbuscommandpluginInterfaceTest.cpp"
- "DbusCommanInterfaceBackdoor.cpp"
+ "CAmCommandSenderDbusBackdoor.cpp"
+ "CAmCommandSenderDbusTest.cpp"
+
)
file(GLOB DBUS_SIGNAL_INTERFACE_SRCS_CXX
- "../../AudioManagerDaemon/src/DBusWrapper.cpp"
- "../../AudioManagerDaemon/src/CommandSender.cpp"
- "../../AudioManagerDaemon/src/SocketHandler.cpp"
- "../../AudioManagerDaemon/src/DLTWrapper.cpp"
- "../../AudioManagerDaemon/src/DatabaseHandler.cpp"
- "../../AudioManagerDaemon/src/ControlSender.cpp"
- "../src/*.cpp"
- "dbuscommaninterfacesignalsTest.cpp"
- "DbusCommandInterfaceBackdoor.cpp"
+ "../../AudioManagerDaemon/src/CAmDbusWrapper.cpp"
+ "../../AudioManagerDaemon/src/CAmSocketHandler.cpp"
+ "../../AudioManagerDaemon/src/CAmDltWrapper.cpp"
+ "../src/*.cpp"
+ "CAmCommandSenderDbusBackdoor.cpp"
+ "CAmCommandSenderDbusSignalTest.cpp"
)
-ADD_EXECUTABLE(dbusCommandMessages ${DBUS_PLUGIN_INTERFACE_SRCS_CXX})
+ADD_EXECUTABLE(AmCommandSenderDbusTest ${DBUS_PLUGIN_INTERFACE_SRCS_CXX})
-ADD_EXECUTABLE(dbusCommandSignals ${DBUS_SIGNAL_INTERFACE_SRCS_CXX})
+ADD_EXECUTABLE(AmCommandSenderDbusSignalTest ${DBUS_SIGNAL_INTERFACE_SRCS_CXX})
-TARGET_LINK_LIBRARIES(dbusCommandMessages
+TARGET_LINK_LIBRARIES(AmCommandSenderDbusTest
${DLT_LIBRARIES}
${DBUS_LIBRARY}
${CMAKE_DL_LIBS}
@@ -90,7 +87,7 @@ TARGET_LINK_LIBRARIES(dbusCommandMessages
)
-TARGET_LINK_LIBRARIES(dbusCommandSignals
+TARGET_LINK_LIBRARIES(AmCommandSenderDbusSignalTest
${DLT_LIBRARIES}
${DBUS_LIBRARY}
${CMAKE_DL_LIBS}
@@ -100,13 +97,13 @@ TARGET_LINK_LIBRARIES(dbusCommandSignals
gmock
)
-INSTALL(TARGETS dbusCommandMessages
+INSTALL(TARGETS AmCommandSenderDbusTest
DESTINATION "~/AudioManagerTest/"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
COMPONENT tests
)
-INSTALL(TARGETS dbusCommandSignals
+INSTALL(TARGETS AmCommandSenderDbusSignalTest
DESTINATION "~/AudioManagerTest/"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
COMPONENT tests
diff --git a/PluginCommandInterfaceDbus/test/MockIAmCommandReceive.h b/PluginCommandInterfaceDbus/test/MockIAmCommandReceive.h
new file mode 100644
index 0000000..bb9e53f
--- /dev/null
+++ b/PluginCommandInterfaceDbus/test/MockIAmCommandReceive.h
@@ -0,0 +1,59 @@
+#ifndef MOCKCOMMANDRECEIVENTERFACE_H_
+#define MOCKCOMMANDRECEIVENTERFACE_H_
+
+#include "command/IAmCommandReceive.h"
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+namespace am {
+
+class MockIAmCommandReceive : public IAmCommandReceive {
+ public:
+ MOCK_METHOD3(connect,
+ am_Error_e(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID));
+ MOCK_METHOD1(disconnect,
+ am_Error_e(const am_mainConnectionID_t mainConnectionID));
+ MOCK_METHOD2(setVolume,
+ am_Error_e(const am_sinkID_t sinkID, const am_mainVolume_t volume));
+ MOCK_METHOD2(volumeStep,
+ am_Error_e(const am_sinkID_t sinkID, const int16_t volumeStep));
+ MOCK_METHOD2(setSinkMuteState,
+ am_Error_e(const am_sinkID_t sinkID, const am_MuteState_e muteState));
+ MOCK_METHOD2(setMainSinkSoundProperty,
+ am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID));
+ MOCK_METHOD2(setMainSourceSoundProperty,
+ am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID));
+ MOCK_METHOD1(setSystemProperty,
+ am_Error_e(const am_SystemProperty_s& property));
+ MOCK_CONST_METHOD1(getListMainConnections,
+ am_Error_e(std::vector<am_MainConnectionType_s>& listConnections));
+ MOCK_CONST_METHOD1(getListMainSinks,
+ am_Error_e(std::vector<am_SinkType_s>& listMainSinks));
+ MOCK_CONST_METHOD1(getListMainSources,
+ am_Error_e(std::vector<am_SourceType_s>& listMainSources));
+ MOCK_CONST_METHOD2(getListMainSinkSoundProperties,
+ am_Error_e(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundProperties));
+ MOCK_CONST_METHOD2(getListMainSourceSoundProperties,
+ am_Error_e(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSourceProperties));
+ MOCK_CONST_METHOD1(getListSourceClasses,
+ am_Error_e(std::vector<am_SourceClass_s>& listSourceClasses));
+ MOCK_CONST_METHOD1(getListSinkClasses,
+ am_Error_e(std::vector<am_SinkClass_s>& listSinkClasses));
+ MOCK_CONST_METHOD1(getListSystemProperties,
+ am_Error_e(std::vector<am_SystemProperty_s>& listSystemProperties));
+ MOCK_CONST_METHOD2(getTimingInformation,
+ am_Error_e(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay));
+ MOCK_CONST_METHOD1(getDBusConnectionWrapper,
+ am_Error_e(CAmDbusWrapper*& dbusConnectionWrapper));
+ MOCK_CONST_METHOD1(getSocketHandler,
+ am_Error_e(CAmSocketHandler*& socketHandler));
+ MOCK_CONST_METHOD1(getInterfaceVersion,
+ void(std::string& version));
+ MOCK_METHOD1(confirmCommandReady,
+ void(const uint16_t handle));
+ MOCK_METHOD1(confirmCommandRundown,
+ void(const uint16_t handle));
+};
+
+} // namespace am
+#endif /* MOCKCOMMANDRECEIVENTERFACE_H_ */
diff --git a/PluginCommandInterfaceDbus/test/MockInterfaces.h b/PluginCommandInterfaceDbus/test/MockInterfaces.h
deleted file mode 100644
index b4e7792..0000000
--- a/PluginCommandInterfaceDbus/test/MockInterfaces.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file MochInterfaces.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
-
-#ifndef MOCKINTERFACES_H_
-#define MOCKINTERFACES_H_
-
-namespace am {
-
-class MockCommandReceiveInterface : public CommandReceiveInterface {
- public:
- MOCK_METHOD3(connect,
- am_Error_e(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID));
- MOCK_METHOD1(disconnect,
- am_Error_e(const am_mainConnectionID_t mainConnectionID));
- MOCK_METHOD2(setVolume,
- am_Error_e(const am_sinkID_t sinkID, const am_mainVolume_t volume));
- MOCK_METHOD2(volumeStep,
- am_Error_e(const am_sinkID_t sinkID, const int16_t volumeStep));
- MOCK_METHOD2(setSinkMuteState,
- am_Error_e(const am_sinkID_t sinkID, const am_MuteState_e muteState));
- MOCK_METHOD2(setMainSinkSoundProperty,
- am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID));
- MOCK_METHOD2(setMainSourceSoundProperty,
- am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID));
- MOCK_METHOD1(setSystemProperty,
- am_Error_e(const am_SystemProperty_s& property));
- MOCK_CONST_METHOD1(getListMainConnections,
- am_Error_e(std::vector<am_MainConnectionType_s>& listConnections));
- MOCK_CONST_METHOD1(getListMainSinks,
- am_Error_e(std::vector<am_SinkType_s>& listMainSinks));
- MOCK_CONST_METHOD1(getListMainSources,
- am_Error_e(std::vector<am_SourceType_s>& listMainSources));
- MOCK_CONST_METHOD2(getListMainSinkSoundProperties,
- am_Error_e(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundProperties));
- MOCK_CONST_METHOD2(getListMainSourceSoundProperties,
- am_Error_e(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSourceProperties));
- MOCK_CONST_METHOD1(getListSourceClasses,
- am_Error_e(std::vector<am_SourceClass_s>& listSourceClasses));
- MOCK_CONST_METHOD1(getListSinkClasses,
- am_Error_e(std::vector<am_SinkClass_s>& listSinkClasses));
- MOCK_CONST_METHOD1(getListSystemProperties,
- am_Error_e(std::vector<am_SystemProperty_s>& listSystemProperties));
- MOCK_CONST_METHOD2(getTimingInformation,
- am_Error_e(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay));
- MOCK_CONST_METHOD1(getDBusConnectionWrapper,
- am_Error_e(DBusWrapper*& dbusConnectionWrapper));
- MOCK_CONST_METHOD1(getSocketHandler,
- am_Error_e(SocketHandler*& socketHandler));
- MOCK_CONST_METHOD1(getInterfaceVersion,
- void(std::string& version));
- MOCK_METHOD1(confirmCommandReady,
- void(const uint16_t handle));
- MOCK_METHOD1(confirmCommandRundown,
- void(const uint16_t handle));
-
-
-};
-
-} // namespace am
-
-
-
-#endif /* MOCKINTERFACES_H_ */