From dfcafbec34e0e454d9995551998af5d40a27c7ad Mon Sep 17 00:00:00 2001 From: christian mueller Date: Thu, 1 Mar 2012 19:12:55 +0100 Subject: * 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 --- PluginCommandInterfaceDbus/CMakeLists.txt | 12 +- .../include/CAmCommandSenderDbus.h | 123 +++ .../include/CAmDbusMessageHandler.h | 127 +++ .../include/CommandInterface.xml | 174 ++++ .../include/CommandReceiverShadow.h | 111 --- .../include/DBusCommandSender.h | 122 --- .../include/DBusMessageHandler.h | 126 --- .../include/IAmCommandReceiverShadow.h | 113 +++ PluginCommandInterfaceDbus/include/mainpage.h | 32 - .../src/CAmCommandSenderDbus.cpp | 331 ++++++++ .../src/CAmDbusMessageHandler.cpp | 631 ++++++++++++++ .../src/CommandReceiverShadow.cpp | 442 ---------- .../src/DBusCommandSender.cpp | 328 -------- .../src/DBusMessageHandler.cpp | 629 -------------- .../src/IAmCommandReceiverShadow.cpp | 447 ++++++++++ .../test/CAmCommandSenderDbusBackdoor.cpp | 71 ++ .../test/CAmCommandSenderDbusBackdoor.h | 52 ++ .../test/CAmCommandSenderDbusSignalTest.cpp | 806 ++++++++++++++++++ .../test/CAmCommandSenderDbusSignalTest.h | 51 ++ .../test/CAmCommandSenderDbusTest.cpp | 629 ++++++++++++++ .../test/CAmCommandSenderDbusTest.h | 61 ++ PluginCommandInterfaceDbus/test/CMakeLists.txt | 47 +- .../test/DbusCommandInterfaceBackdoor.cpp | 70 -- .../test/DbusCommandInterfaceBackdoor.h | 51 -- .../test/MockIAmCommandReceive.h | 59 ++ PluginCommandInterfaceDbus/test/MockInterfaces.h | 85 -- .../test/dbuscommandpluginInterfaceTest.cpp | 608 -------------- .../test/dbuscommandpluginInterfaceTest.h | 72 -- .../test/dbuscommaninterfacesignalsTest.cpp | 906 --------------------- .../test/dbuscommaninterfacesignalsTest.h | 53 -- 30 files changed, 3704 insertions(+), 3665 deletions(-) create mode 100644 PluginCommandInterfaceDbus/include/CAmCommandSenderDbus.h create mode 100644 PluginCommandInterfaceDbus/include/CAmDbusMessageHandler.h create mode 100644 PluginCommandInterfaceDbus/include/CommandInterface.xml delete mode 100644 PluginCommandInterfaceDbus/include/CommandReceiverShadow.h delete mode 100644 PluginCommandInterfaceDbus/include/DBusCommandSender.h delete mode 100644 PluginCommandInterfaceDbus/include/DBusMessageHandler.h create mode 100644 PluginCommandInterfaceDbus/include/IAmCommandReceiverShadow.h delete mode 100644 PluginCommandInterfaceDbus/include/mainpage.h create mode 100644 PluginCommandInterfaceDbus/src/CAmCommandSenderDbus.cpp create mode 100644 PluginCommandInterfaceDbus/src/CAmDbusMessageHandler.cpp delete mode 100644 PluginCommandInterfaceDbus/src/CommandReceiverShadow.cpp delete mode 100644 PluginCommandInterfaceDbus/src/DBusCommandSender.cpp delete mode 100644 PluginCommandInterfaceDbus/src/DBusMessageHandler.cpp create mode 100644 PluginCommandInterfaceDbus/src/IAmCommandReceiverShadow.cpp create mode 100644 PluginCommandInterfaceDbus/test/CAmCommandSenderDbusBackdoor.cpp create mode 100644 PluginCommandInterfaceDbus/test/CAmCommandSenderDbusBackdoor.h create mode 100644 PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.cpp create mode 100644 PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.h create mode 100644 PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.cpp create mode 100644 PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.h delete mode 100644 PluginCommandInterfaceDbus/test/DbusCommandInterfaceBackdoor.cpp delete mode 100644 PluginCommandInterfaceDbus/test/DbusCommandInterfaceBackdoor.h create mode 100644 PluginCommandInterfaceDbus/test/MockIAmCommandReceive.h delete mode 100644 PluginCommandInterfaceDbus/test/MockInterfaces.h delete mode 100644 PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.cpp delete mode 100644 PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.h delete mode 100644 PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.cpp delete mode 100644 PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.h (limited to 'PluginCommandInterfaceDbus') 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/CAmCommandSenderDbus.h b/PluginCommandInterfaceDbus/include/CAmCommandSenderDbus.h new file mode 100644 index 0000000..ad625dc --- /dev/null +++ b/PluginCommandInterfaceDbus/include/CAmCommandSenderDbus.h @@ -0,0 +1,123 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger DbusPlugin + * + * \file CommandSender.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 . + * 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 DBUSCOMMANDSENDER_H_ +#define DBUSCOMMANDSENDER_H_ + +#include +#include +#include "shared/CAmDbusWrapper.h" +#include "CAmDbusMessageHandler.h" +#include "IAmCommandReceiverShadow.h" +#include "command/IAmCommandSend.h" + +#ifdef UNIT_TEST +#include "../test/CAmCommandSenderDbusBackdoor.h" +#endif + + + +namespace am +{ + +const char MY_NODE[] = "CommandInterface"; + +/** + * Dbus Implementation of CommandSendInterface + */ +class CAmCommandSenderDbus: public IAmCommandSend +{ +public: + 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 CAmCommandSenderDbusBackdoor; +#endif +private: + 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 + */ + std::vector mlistSinks; + + /** + * list of sources, needed to send out only deltas + */ + std::vector mlistSources; + + /** + * used as comparison function for am_SinkType_s + */ + struct sortBySinkID + { + bool operator()(const am_SinkType_s & a, const am_SinkType_s & b) + { + return (a.sinkID < b.sinkID); + } + }; + + /** + * used as comparison function for am_SourceType_s + */ + struct sortBySourceID + { + bool operator()(const am_SourceType_s & a, const am_SourceType_s & b) + { + return (a.sourceID < b.sourceID); + } + }; + +}; + +} + +#endif /* DBUSCOMMANDSENDER_H_ */ diff --git a/PluginCommandInterfaceDbus/include/CAmDbusMessageHandler.h b/PluginCommandInterfaceDbus/include/CAmDbusMessageHandler.h new file mode 100644 index 0000000..5431e2b --- /dev/null +++ b/PluginCommandInterfaceDbus/include/CAmDbusMessageHandler.h @@ -0,0 +1,127 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger DbusPlugin + * + * \file DBusMessageHandler + * + * \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 . + * 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 _DBUSMESSAGEHANDLER_H_ +#define _DBUSMESSAGEHANDLER_H_ + +#include +#include +#include +#include +#include +#include "audiomanagertypes.h" + + +namespace am +{ + +/** + * handles DBus Messages, is used to extract & append parameters and send messages + */ +class CAmDbusMessageHandler +{ +public: + CAmDbusMessageHandler(); + ~CAmDbusMessageHandler(); + + /** + * sets the DBus Connection + * @param connection pointer to the DBus Connection + */ + void setDBusConnection(DBusConnection*& connection); + + /** + * is called to initiate the receiving of a message + * @param msg pointer to the message to be received + */ + void initReceive(DBusMessage* msg); + + /** + * is called to initiate the reply to a message + * @param msg pointer to the message the reply is for + */ + void initReply(DBusMessage* msg); + + /** + * inits a signal to be sent via dbus + * parameters can be added before sending the signal + * @param path the path + * @param signalName the signal name + */ + void initSignal(std::string path, std::string signalName); + + /** + * sends out the message + */ + void sendMessage(); + + /** + * the get functions return a value from the received dbus message + * @return + */ + dbus_uint16_t getUInt(); + dbus_int16_t getInt(); + dbus_bool_t getBool(); + char getByte(); + double getDouble(); + char* getString(); + void getProperty(dbus_int16_t& type, dbus_int16_t& value); + + /** + * the overloaded append function appends different datatypes to the dbusmessage + */ + void append(dbus_int16_t toAppend); + void append(dbus_uint16_t toAppend); + void append(char toAppend); + void append(bool toAppend); + void append(double toAppend); + void append(const am::am_SinkType_s& sinkType); + void append(const am::am_SourceType_s& sourceType); + void append(const am::am_MainSoundProperty_s mainSoundProperty); + void append(const am::am_Availability_s & availability); + void append(const am::am_SystemProperty_s & SystemProperty); + void append(const std::vector& listMainConnections); + void append(const std::vector& listMainSinks); + void append(const std::vector& listMainSources); + void append(const std::vector& listMainSoundProperties); + void append(const std::vector& listSourceClasses); + void append(const std::vector& listSinkClasses); + void append(const std::vector& listSystemProperties); + +private: + + DBusMessageIter mDBusMessageIter; + DBusError mDBusError; + dbus_uint32_t mSerial; + std::string mErrorName; + std::string mErrorMsg; + DBusMessage* mpDBusMessage; + DBusMessage* mpReveiveMessage; + DBusConnection* mpDBusConnection; +}; + +} + +#endif // _DBUSMESSAGEWRAPPER_H_ 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PluginCommandInterfaceDbus/include/CommandReceiverShadow.h b/PluginCommandInterfaceDbus/include/CommandReceiverShadow.h deleted file mode 100644 index d2c63cb..0000000 --- a/PluginCommandInterfaceDbus/include/CommandReceiverShadow.h +++ /dev/null @@ -1,111 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger DbusPlugin - * - * \file CommandReceiverShadow.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 . - * 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 COMMANDRECEIVERSHADOW_H_ -#define COMMANDRECEIVERSHADOW_H_ - -#include -#include -#include -#include -#include -#include "DBusMessageHandler.h" - -namespace am -{ - -class CommandReceiverShadow; - -typedef void (CommandReceiverShadow::*CallBackMethod)(DBusConnection *connection, DBusMessage *message); - -/** - * receives the DBus Callbacks, marhsalls and demarshalls the parameters and calls CommandReceive - */ -class CommandReceiverShadow -{ -public: - CommandReceiverShadow(); - virtual ~CommandReceiverShadow(); - void connect(DBusConnection *conn, DBusMessage *msg); - void disconnect(DBusConnection *conn, DBusMessage *msg); - void setVolume(DBusConnection *conn, DBusMessage *msg); - void volumeStep(DBusConnection *conn, DBusMessage *msg); - void setSinkMuteState(DBusConnection *conn, DBusMessage *msg); - void setMainSinkSoundProperty(DBusConnection *conn, DBusMessage *msg); - void setMainSourceSoundProperty(DBusConnection *conn, DBusMessage *msg); - void setSystemProperty(DBusConnection *conn, DBusMessage *msg); - void getListMainConnections(DBusConnection *conn, DBusMessage *msg); - void getListMainSinks(DBusConnection *conn, DBusMessage *msg); - void getListMainSources(DBusConnection *conn, DBusMessage *msg); - void getListMainSinkSoundProperties(DBusConnection *conn, DBusMessage *msg); - void getListMainSourceSoundProperties(DBusConnection *conn, DBusMessage *msg); - void getListSourceClasses(DBusConnection *conn, DBusMessage *msg); - void getListSinkClasses(DBusConnection *conn, DBusMessage *msg); - void getListSystemProperties(DBusConnection *conn, DBusMessage *msg); - void getTimingInformation(DBusConnection *conn, DBusMessage *msg); - - /** - * sets the pointer to the CommandReceiveInterface and registers Callback - * @param receiver - */ - void setCommandReceiver(CommandReceiveInterface*& receiver); -private: - CommandReceiveInterface* mCommandReceiveInterface; - DBusWrapper* mDBusWrapper; - typedef std::map functionMap_t; - functionMap_t mFunctionMap; - DBusMessageHandler mDBUSMessageHandler; - - /** - * receives a callback whenever the path of the plugin is called - */ - static DBusHandlerResult receiveCallback(DBusConnection *conn, DBusMessage *msg, void *user_data); - - /** - * dynamic delegate that handles the Callback of the static receiveCallback - * @param conn DBus connection - * @param msg DBus message - * @param user_data pointer to instance of CommandReceiverShadow - * @return - */ - DBusHandlerResult receiveCallbackDelegate(DBusConnection *conn, DBusMessage *msg); - - /** - * sends out introspectiondata read from an xml file. - * @param conn - * @param msg - */ - void sendIntrospection(DBusConnection* conn, DBusMessage* msg); - - /** - * creates the function map needed to combine DBus messages and function adresses - * @return the map - */ - functionMap_t createMap(); -}; - -} - -#endif /* COMMANDRECEIVERSHADOW_H_ */ diff --git a/PluginCommandInterfaceDbus/include/DBusCommandSender.h b/PluginCommandInterfaceDbus/include/DBusCommandSender.h deleted file mode 100644 index e64e6f6..0000000 --- a/PluginCommandInterfaceDbus/include/DBusCommandSender.h +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger DbusPlugin - * - * \file CommandSender.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 . - * 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 DBUSCOMMANDSENDER_H_ -#define DBUSCOMMANDSENDER_H_ - -#ifdef UNIT_TEST -#include "../test/DbusCommandInterfaceBackdoor.h" -#endif - -#include -#include -#include -#include -#include "DBusMessageHandler.h" -#include "CommandReceiverShadow.h" - -namespace am -{ - -const char MY_NODE[] = "CommandInterface"; - -/** - * Dbus Implementation of CommandSendInterface - */ -class DbusCommandSender: public CommandSendInterface -{ -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 ; - -#ifdef UNIT_TEST - friend class DbusCommandInterfaceBackdoor; -#endif -private: - DBusMessageHandler mDBUSMessageHandler; - CommandReceiverShadow mCommandReceiverShadow; - DBusWrapper* mDBusWrapper; - CommandReceiveInterface* mCommandReceiveInterface; - bool mReady; ///< ! if false, calls shall be ignored. - - - /** - * list of sinks, needed to send out only deltas - */ - std::vector mlistSinks; - - /** - * list of sources, needed to send out only deltas - */ - std::vector mlistSources; - - /** - * used as comparison function for am_SinkType_s - */ - struct sortBySinkID - { - bool operator()(const am_SinkType_s & a, const am_SinkType_s & b) - { - return (a.sinkID < b.sinkID); - } - }; - - /** - * used as comparison function for am_SourceType_s - */ - struct sortBySourceID - { - bool operator()(const am_SourceType_s & a, const am_SourceType_s & b) - { - return (a.sourceID < b.sourceID); - } - }; - -}; - -} - -#endif /* DBUSCOMMANDSENDER_H_ */ diff --git a/PluginCommandInterfaceDbus/include/DBusMessageHandler.h b/PluginCommandInterfaceDbus/include/DBusMessageHandler.h deleted file mode 100644 index 71a4078..0000000 --- a/PluginCommandInterfaceDbus/include/DBusMessageHandler.h +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger DbusPlugin - * - * \file DBusMessageHandler - * - * \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 . - * 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 _DBUSMESSAGEHANDLER_H_ -#define _DBUSMESSAGEHANDLER_H_ - -#include -#include -#include -#include -#include -#include - -namespace am -{ - -/** - * handles DBus Messages, is used to extract & append parameters and send messages - */ -class DBusMessageHandler -{ -public: - DBusMessageHandler(); - ~DBusMessageHandler(); - - /** - * sets the DBus Connection - * @param connection pointer to the DBus Connection - */ - void setDBusConnection(DBusConnection*& connection); - - /** - * is called to initiate the receiving of a message - * @param msg pointer to the message to be received - */ - void initReceive(DBusMessage* msg); - - /** - * is called to initiate the reply to a message - * @param msg pointer to the message the reply is for - */ - void initReply(DBusMessage* msg); - - /** - * inits a signal to be sent via dbus - * parameters can be added before sending the signal - * @param path the path - * @param signalName the signal name - */ - void initSignal(std::string path, std::string signalName); - - /** - * sends out the message - */ - void sendMessage(); - - /** - * the get functions return a value from the received dbus message - * @return - */ - dbus_uint16_t getUInt(); - dbus_int16_t getInt(); - dbus_bool_t getBool(); - char getByte(); - double getDouble(); - char* getString(); - void getProperty(dbus_int16_t& type, dbus_int16_t& value); - - /** - * the overloaded append function appends different datatypes to the dbusmessage - */ - void append(dbus_int16_t toAppend); - void append(dbus_uint16_t toAppend); - void append(char toAppend); - void append(bool toAppend); - void append(double toAppend); - void append(const am::am_SinkType_s& sinkType); - void append(const am::am_SourceType_s& sourceType); - void append(const am::am_MainSoundProperty_s mainSoundProperty); - void append(const am::am_Availability_s & availability); - void append(const am::am_SystemProperty_s & SystemProperty); - void append(const std::vector& listMainConnections); - void append(const std::vector& listMainSinks); - void append(const std::vector& listMainSources); - void append(const std::vector& listMainSoundProperties); - void append(const std::vector& listSourceClasses); - void append(const std::vector& listSinkClasses); - void append(const std::vector& listSystemProperties); - -private: - - DBusMessageIter mDBusMessageIter; - DBusError mDBusError; - dbus_uint32_t mSerial; - std::string mErrorName; - std::string mErrorMsg; - DBusMessage* mDbusMessage; - DBusMessage* mReveiveMessage; - DBusConnection* mDBusConnection; -}; - -} - -#endif // _DBUSMESSAGEWRAPPER_H_ diff --git a/PluginCommandInterfaceDbus/include/IAmCommandReceiverShadow.h b/PluginCommandInterfaceDbus/include/IAmCommandReceiverShadow.h new file mode 100644 index 0000000..dd5a23d --- /dev/null +++ b/PluginCommandInterfaceDbus/include/IAmCommandReceiverShadow.h @@ -0,0 +1,113 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger DbusPlugin + * + * \file CommandReceiverShadow.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 . + * 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 COMMANDRECEIVERSHADOW_H_ +#define COMMANDRECEIVERSHADOW_H_ + + + +#include +#include +#include "config.h" +#include "command/IAmCommandReceive.h" +#include "CAmDbusMessageHandler.h" +#include "shared/CAmDbusWrapper.h" + +namespace am +{ + +class IAmCommandReceiverShadow; + +typedef void (IAmCommandReceiverShadow::*CallBackMethod)(DBusConnection *connection, DBusMessage *message); + +/** + * receives the DBus Callbacks, marhsalls and demarshalls the parameters and calls CommandReceive + */ +class IAmCommandReceiverShadow +{ +public: + IAmCommandReceiverShadow(); + virtual ~IAmCommandReceiverShadow(); + void connect(DBusConnection *conn, DBusMessage *msg); + void disconnect(DBusConnection *conn, DBusMessage *msg); + void setVolume(DBusConnection *conn, DBusMessage *msg); + void volumeStep(DBusConnection *conn, DBusMessage *msg); + void setSinkMuteState(DBusConnection *conn, DBusMessage *msg); + void setMainSinkSoundProperty(DBusConnection *conn, DBusMessage *msg); + void setMainSourceSoundProperty(DBusConnection *conn, DBusMessage *msg); + void setSystemProperty(DBusConnection *conn, DBusMessage *msg); + void getListMainConnections(DBusConnection *conn, DBusMessage *msg); + void getListMainSinks(DBusConnection *conn, DBusMessage *msg); + void getListMainSources(DBusConnection *conn, DBusMessage *msg); + void getListMainSinkSoundProperties(DBusConnection *conn, DBusMessage *msg); + void getListMainSourceSoundProperties(DBusConnection *conn, DBusMessage *msg); + void getListSourceClasses(DBusConnection *conn, DBusMessage *msg); + void getListSinkClasses(DBusConnection *conn, DBusMessage *msg); + void getListSystemProperties(DBusConnection *conn, DBusMessage *msg); + void getTimingInformation(DBusConnection *conn, DBusMessage *msg); + + /** + * sets the pointer to the CommandReceiveInterface and registers Callback + * @param receiver + */ + void setCommandReceiver(IAmCommandReceive*& receiver); +private: + typedef std::map functionMap_t; + functionMap_t mFunctionMap; + CAmDbusMessageHandler mDBUSMessageHandler; + IAmCommandReceive* mpIAmCommandReceive; + CAmDbusWrapper* mpCAmDbusWrapper; + + /** + * receives a callback whenever the path of the plugin is called + */ + static DBusHandlerResult receiveCallback(DBusConnection *conn, DBusMessage *msg, void *user_data); + + /** + * dynamic delegate that handles the Callback of the static receiveCallback + * @param conn DBus connection + * @param msg DBus message + * @param user_data pointer to instance of CommandReceiverShadow + * @return + */ + DBusHandlerResult receiveCallbackDelegate(DBusConnection *conn, DBusMessage *msg); + + /** + * sends out introspectiondata read from an xml file. + * @param conn + * @param msg + */ + void sendIntrospection(DBusConnection* conn, DBusMessage* msg); + + /** + * creates the function map needed to combine DBus messages and function adresses + * @return the map + */ + functionMap_t createMap(); +}; + +} + +#endif /* COMMANDRECEIVERSHADOW_H_ */ 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 . - * 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 - * - */ - -#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 . + * 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 +#include +#include +#include +#include +#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/CAmDbusMessageHandler.cpp b/PluginCommandInterfaceDbus/src/CAmDbusMessageHandler.cpp new file mode 100644 index 0000000..6b2dc3f --- /dev/null +++ b/PluginCommandInterfaceDbus/src/CAmDbusMessageHandler.cpp @@ -0,0 +1,631 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger DbusPlugin + * + * \file DBusMessageHandler.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 . + * 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 "CAmDbusMessageHandler.h" +#include "config.h" +#include +#include +#include +#include "CAmCommandSenderDbus.h" +#include "shared/CAmDltWrapper.h" + +DLT_IMPORT_CONTEXT(commandDbus) + +namespace am +{ + +CAmDbusMessageHandler::CAmDbusMessageHandler() : + mDBusMessageIter(), // + mDBusError(), // + mSerial(0), // + mErrorName(""), // + mErrorMsg(""), // + mpDBusMessage(NULL), // + mpReveiveMessage(NULL), // + mpDBusConnection(NULL) +{ + log(&commandDbus, DLT_LOG_INFO, "DBusMessageHandler constructed"); +} + +CAmDbusMessageHandler::~CAmDbusMessageHandler() +{ + log(&commandDbus, DLT_LOG_INFO, "DBUSMessageHandler destructed"); +} + +void CAmDbusMessageHandler::initReceive(DBusMessage* msg) +{ + assert(msg!=NULL); + mpReveiveMessage = msg; + if (!dbus_message_iter_init(msg, &mDBusMessageIter)) + { + log(&commandDbus, DLT_LOG_INFO, "DBusMessageHandler::initReceive DBus Message has no arguments!"); + mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); + mErrorMsg = "DBUS Message has no arguments!"; + } +} + +void CAmDbusMessageHandler::initReply(DBusMessage* msg) +{ + assert(msg!=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(mpDBusMessage, &mDBusMessageIter); +} + +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; + mpDBusMessage = dbus_message_new_signal(completePath.c_str(), DBUS_SERVICE_PREFIX, signalName.c_str()); + + if (mpDBusMessage == NULL) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::initSignal Cannot allocate DBus message!"); + } + dbus_message_iter_init_append(mpDBusMessage, &mDBusMessageIter); +} + +void CAmDbusMessageHandler::sendMessage() +{ + assert(mpDBusConnection!=NULL); + if (mpReveiveMessage != 0) + { + mSerial = dbus_message_get_serial(mpReveiveMessage); + } + else + { + mSerial = 1; + } + if (!mErrorName.empty()) + { + mpDBusMessage = dbus_message_new_error(mpReveiveMessage, mErrorName.c_str(), mErrorMsg.c_str()); + } + if (!dbus_connection_send(mpDBusConnection, mpDBusMessage, &mSerial)) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::sendMessage cannot send message!"); + } + dbus_connection_flush(mpDBusConnection); + dbus_message_unref(mpDBusMessage); + mpDBusMessage = NULL; +} + +char* CAmDbusMessageHandler::getString() +{ + char* param = NULL; + + if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&mDBusMessageIter)) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getString DBUS handler argument is no String!"); + mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); + mErrorMsg = "DBus argument is no string"; + } + else + { + dbus_message_iter_get_basic(&mDBusMessageIter, ¶m); + dbus_message_iter_next(&mDBusMessageIter); + } + return (param); +} + +dbus_bool_t CAmDbusMessageHandler::getBool() +{ + dbus_bool_t boolparam = false; + + if (DBUS_TYPE_BOOLEAN != dbus_message_iter_get_arg_type(&mDBusMessageIter)) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getBool DBUS handler argument is no bool!"); + mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); + mErrorMsg = "DBus argument is no bool"; + } + else + { + dbus_message_iter_get_basic(&mDBusMessageIter, &boolparam); + dbus_message_iter_next(&mDBusMessageIter); + } + return (boolparam); +} + +char CAmDbusMessageHandler::getByte() +{ + char param; + + if (DBUS_TYPE_BYTE != dbus_message_iter_get_arg_type(&mDBusMessageIter)) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getByte DBUS handler argument is no byte!"); + mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); + mErrorMsg = "DBus argument is no byte"; + } + else + { + dbus_message_iter_get_basic(&mDBusMessageIter, ¶m); + dbus_message_iter_next(&mDBusMessageIter); + } + return (param); +} + +dbus_uint16_t CAmDbusMessageHandler::getUInt() +{ + dbus_uint16_t param; + +#ifdef GLIB_DBUS_TYPES_TOLERANT + if (DBUS_TYPE_UINT16 != dbus_message_iter_get_arg_type(&mDBusMessageIter) && DBUS_TYPE_UINT32 != dbus_message_iter_get_arg_type(&mDBusMessageIter)) +#else + if (DBUS_TYPE_UINT16 != dbus_message_iter_get_arg_type(&mDBusMessageIter)) +#endif + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getUInt DBUS handler argument is no uint16_t!"); + mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); + mErrorMsg = "DBus argument is no uint16_t"; + } + else + { + dbus_message_iter_get_basic(&mDBusMessageIter, ¶m); + dbus_message_iter_next(&mDBusMessageIter); + } + return (param); +} + +dbus_int16_t CAmDbusMessageHandler::getInt() +{ + dbus_int16_t param; + +#ifdef GLIB_DBUS_TYPES_TOLERANT + if (DBUS_TYPE_INT16 != dbus_message_iter_get_arg_type(&mDBusMessageIter) && DBUS_TYPE_INT32 != dbus_message_iter_get_arg_type(&mDBusMessageIter)) +#else + if (DBUS_TYPE_INT16 != dbus_message_iter_get_arg_type(&mDBusMessageIter)) +#endif + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getInt DBUS handler argument is no int16_t!"); + mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); + mErrorMsg = "DBus argument is no int16_t"; + } + else + { + dbus_message_iter_get_basic(&mDBusMessageIter, ¶m); + dbus_message_iter_next(&mDBusMessageIter); + } + return (param); +} + +double CAmDbusMessageHandler::getDouble() +{ + double param; + if (DBUS_TYPE_DOUBLE != dbus_message_iter_get_arg_type(&mDBusMessageIter)) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getDouble DBUS handler argument is no double!"); + mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); + mErrorMsg = "DBus argument is no double"; + } + else + { + dbus_message_iter_get_basic(&mDBusMessageIter, ¶m); + dbus_message_iter_next(&mDBusMessageIter); + } + return (param); +} + +void CAmDbusMessageHandler::getProperty(dbus_int16_t & type, dbus_int16_t & value) +{ + DBusMessageIter arrayIter; + if (DBUS_TYPE_STRUCT != dbus_message_iter_get_arg_type(&mDBusMessageIter)) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getProperty DBUS handler argument is no array!"); + mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); + mErrorMsg = "DBus argument is no array"; + } + else + { + dbus_message_iter_recurse(&mDBusMessageIter, &arrayIter); + dbus_message_iter_get_basic(&arrayIter, &type); + dbus_message_iter_next(&arrayIter); + dbus_message_iter_get_basic(&arrayIter, &value); + dbus_message_iter_next(&mDBusMessageIter); + } +} + +void CAmDbusMessageHandler::append(bool toAppend) +{ + dbus_bool_t mybool = toAppend; + if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_BOOLEAN, &mybool)) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(double toAppend) +{ + if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_DOUBLE, &toAppend)) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(char toAppend) +{ + if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_BYTE, &toAppend)) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(dbus_int16_t toAppend) +{ + if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_INT16, &toAppend)) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(dbus_uint16_t toAppend) +{ + if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_UINT16, &toAppend)) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::setDBusConnection(DBusConnection *& connection) +{ + assert(connection!=NULL); + mpDBusConnection = connection; +} + +void CAmDbusMessageHandler::append(const am::am_SinkType_s& sinkType) +{ + DBusMessageIter structIter; + DBusMessageIter structAvailIter; + dbus_bool_t success = true; + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sinkType.sinkID); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &sinkType.name); + + success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &structAvailIter); + success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sinkType.availability.availability); + success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sinkType.availability.availabilityReason); + success = success && dbus_message_iter_close_container(&structIter, &structAvailIter); + + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &sinkType.volume); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &sinkType.muteState); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sinkType.sinkClassID); + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(const am::am_SourceType_s & sourceType) +{ + DBusMessageIter structIter; + DBusMessageIter structAvailIter; + dbus_bool_t success = true; + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sourceType.sourceID); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &sourceType.name); + + success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &structAvailIter); + success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sourceType.availability.availability); + success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sourceType.availability.availabilityReason); + success = success && dbus_message_iter_close_container(&structIter, &structAvailIter); + + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sourceType.sourceClassID); + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(const am::am_MainSoundProperty_s mainSoundProperty) +{ + DBusMessageIter structIter; + dbus_bool_t success = true; + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &mainSoundProperty.type); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &mainSoundProperty.value); + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(const am::am_Availability_s & availability) +{ + DBusMessageIter structAvailIter; + dbus_bool_t success = true; + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structAvailIter); + success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &availability.availability); + success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &availability.availabilityReason); + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structAvailIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(const am::am_SystemProperty_s & SystemProperty) +{ + DBusMessageIter structIter; + dbus_bool_t success = true; + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &SystemProperty.type); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &SystemProperty.value); + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(const std::vector& listMainConnections) +{ + DBusMessageIter arrayIter; + DBusMessageIter structIter; + std::vector::const_iterator listIterator = listMainConnections.begin(); + dbus_bool_t success = true; + + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qqqnn)", &arrayIter); + for (; listIterator < listMainConnections.end(); ++listIterator) + { + success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->mainConnectionID); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceID); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkID); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->delay); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->connectionState); + success = success && dbus_message_iter_close_container(&arrayIter, &structIter); + } + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(const std::vector & listMainSinks) +{ + DBusMessageIter arrayIter; + DBusMessageIter structIter; + DBusMessageIter availIter; + std::vector::const_iterator listIterator = listMainSinks.begin(); + dbus_bool_t success = true; + + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qs(nn)nnq)", &arrayIter); + for (; listIterator < listMainSinks.end(); ++listIterator) + { + success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkID); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name); + success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &availIter); + success = success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availability); + success = success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availabilityReason); + success = success && dbus_message_iter_close_container(&structIter, &availIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->volume); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->muteState); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkClassID); + success = success && dbus_message_iter_close_container(&arrayIter, &structIter); + } + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(const std::vector & listMainSources) +{ + DBusMessageIter arrayIter; + DBusMessageIter structIter; + DBusMessageIter availIter; + std::vector::const_iterator listIterator = listMainSources.begin(); + dbus_bool_t success = true; + + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qs(nn)q)", &arrayIter); + for (; listIterator < listMainSources.end(); ++listIterator) + { + success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceID); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name); + success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &availIter); + success = success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availability); + success = success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availabilityReason); + success = success && dbus_message_iter_close_container(&structIter, &availIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceClassID); + success = success && dbus_message_iter_close_container(&arrayIter, &structIter); + } + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(const std::vector & listMainSoundProperties) +{ + DBusMessageIter arrayIter; + DBusMessageIter structIter; + std::vector::const_iterator listIterator = listMainSoundProperties.begin(); + dbus_bool_t success = true; + + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(nn)", &arrayIter); + for (; listIterator < listMainSoundProperties.end(); ++listIterator) + { + success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->type); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->value); + success = success && dbus_message_iter_close_container(&arrayIter, &structIter); + } + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(const std::vector & listSourceClasses) +{ + DBusMessageIter arrayIter; + DBusMessageIter structIter; + DBusMessageIter propIter; + DBusMessageIter innerIter; + std::vector::const_iterator listIterator = listSourceClasses.begin(); + dbus_bool_t success = true; + + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qsa(nn))", &arrayIter); + for (; listIterator < listSourceClasses.end(); ++listIterator) + { + success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceClassID); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name); + success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_ARRAY, "(nn)", &innerIter); + + std::vector::const_iterator listInnerIterator = listIterator->listClassProperties.begin(); + for (; listInnerIterator < listIterator->listClassProperties.end(); ++listInnerIterator) + { + success = success && dbus_message_iter_open_container(&innerIter, DBUS_TYPE_STRUCT, NULL, &propIter); + success = success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->classProperty); + success = success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->value); + success = success && dbus_message_iter_close_container(&innerIter, &propIter); + } + success = success && dbus_message_iter_close_container(&structIter, &innerIter); + success = success && dbus_message_iter_close_container(&arrayIter, &structIter); + } + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(const std::vector & listSinkClasses) +{ + DBusMessageIter arrayIter; + DBusMessageIter structIter; + DBusMessageIter propIter; + DBusMessageIter innerIter; + std::vector::const_iterator listIterator = listSinkClasses.begin(); + dbus_bool_t success = true; + + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qsa(nn))", &arrayIter); + for (; listIterator < listSinkClasses.end(); ++listIterator) + { + success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkClassID); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name); + success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_ARRAY, "(nn)", &innerIter); + + std::vector::const_iterator listInnerIterator = listIterator->listClassProperties.begin(); + for (; listInnerIterator < listIterator->listClassProperties.end(); ++listInnerIterator) + { + success = success && dbus_message_iter_open_container(&innerIter, DBUS_TYPE_STRUCT, NULL, &propIter); + success = success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->classProperty); + success = success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->value); + success = success && dbus_message_iter_close_container(&innerIter, &propIter); + } + success = success && dbus_message_iter_close_container(&structIter, &innerIter); + success = success && dbus_message_iter_close_container(&arrayIter, &structIter); + } + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(const std::vector & listSystemProperties) +{ + DBusMessageIter arrayIter; + DBusMessageIter structIter; + std::vector::const_iterator listIterator = listSystemProperties.begin(); + dbus_bool_t success = true; + + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(nn)", &arrayIter); + for (; listIterator < listSystemProperties.end(); ++listIterator) + { + success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->type); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->value); + success = success && dbus_message_iter_close_container(&arrayIter, &structIter); + } + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} +} diff --git a/PluginCommandInterfaceDbus/src/CommandReceiverShadow.cpp b/PluginCommandInterfaceDbus/src/CommandReceiverShadow.cpp deleted file mode 100644 index 313818f..0000000 --- a/PluginCommandInterfaceDbus/src/CommandReceiverShadow.cpp +++ /dev/null @@ -1,442 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger DbusPlugin - * - * \file CommandReceiverShadow.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 . - * 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 -#include -#include -#include -#include "CommandReceiverShadow.h" -#include "DBusCommandSender.h" -#include "DLTWrapper.h" - -using namespace am; - -DLT_IMPORT_CONTEXT(commandDbus) - -/** - * static ObjectPathTable is needed for DBus Callback handling - */ -static DBusObjectPathVTable gObjectPathVTable; - -CommandReceiverShadow::CommandReceiverShadow() : - mCommandReceiveInterface(NULL), // - mDBusWrapper(NULL), // - mFunctionMap(createMap()), // - mDBUSMessageHandler() -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow constructed"); -} - -CommandReceiverShadow::~CommandReceiverShadow() -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow destructed"); -} - -void CommandReceiverShadow::connect(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::connect called"); - - (void) conn; - assert(mCommandReceiveInterface!=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); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.append((dbus_uint16_t) mainConnectionID); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::disconnect(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::disconnect called"); - - (void) conn; - assert(mCommandReceiveInterface!=NULL); - - mDBUSMessageHandler.initReceive(msg); - am_mainConnectionID_t mainConnnectionID = (am_mainConnectionID_t) mDBUSMessageHandler.getUInt(); - am_Error_e returnCode = mCommandReceiveInterface->disconnect(mainConnnectionID); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::setVolume(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::setVolume called"); - - (void) conn; - assert(mCommandReceiveInterface!=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); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::volumeStep(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::volumeStep called"); - - (void) conn; - assert(mCommandReceiveInterface!=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); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::setSinkMuteState(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::setSinkMuteState called"); - - (void) conn; - assert(mCommandReceiveInterface!=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); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::setMainSinkSoundProperty(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::setMainSinkSoundProperty called"); - - (void) conn; - assert(mCommandReceiveInterface!=NULL); - - mDBUSMessageHandler.initReceive(msg); - am_sinkID_t sinkID = (am_sinkID_t) mDBUSMessageHandler.getUInt(); - dbus_int16_t type = 0; - dbus_int16_t value = 0; - mDBUSMessageHandler.getProperty(type, value); - am_MainSoundProperty_s mainSoundProperty; - mainSoundProperty.type = (am_MainSoundPropertyType_e) type; - mainSoundProperty.value = (int32_t) value; - am_Error_e returnCode = mCommandReceiveInterface->setMainSinkSoundProperty(mainSoundProperty, sinkID); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::setMainSourceSoundProperty(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::setMainSourceSoundProperty called"); - - (void) conn; - assert(mCommandReceiveInterface!=NULL); - - mDBUSMessageHandler.initReceive(msg); - am_sourceID_t sourceID = (am_sinkID_t) mDBUSMessageHandler.getUInt(); - dbus_int16_t type = 0; - dbus_int16_t value = 0; - mDBUSMessageHandler.getProperty(type, value); - am_MainSoundProperty_s mainSoundProperty; - mainSoundProperty.type = (am_MainSoundPropertyType_e) type; - mainSoundProperty.value = (int32_t) value; - am_Error_e returnCode = mCommandReceiveInterface->setMainSourceSoundProperty(mainSoundProperty, sourceID); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::setSystemProperty(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::setSystemProperty called"); - - (void) conn; - assert(mCommandReceiveInterface!=NULL); - - mDBUSMessageHandler.initReceive(msg); - dbus_int16_t type = 0; - dbus_int16_t value = 0; - mDBUSMessageHandler.getProperty(type, value); - am_SystemProperty_s systemProperty; - systemProperty.type = (am_SystemPropertyType_e) type; - systemProperty.value = (int32_t) value; - am_Error_e returnCode = mCommandReceiveInterface->setSystemProperty(systemProperty); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::getListMainConnections(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListMainConnections called"); - - (void) conn; - assert(mCommandReceiveInterface!=NULL); - std::vector listMainConnections; - am_Error_e returnCode = mCommandReceiveInterface->getListMainConnections(listMainConnections); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.append(listMainConnections); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::getListMainSinks(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListMainSinks called"); - - (void) conn; - assert(mCommandReceiveInterface!=NULL); - std::vector listSinks; - am_Error_e returnCode = mCommandReceiveInterface->getListMainSinks(listSinks); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.append(listSinks); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::getListMainSources(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListMainSources called"); - - (void) conn; - assert(mCommandReceiveInterface!=NULL); - std::vector listSources; - am_Error_e returnCode = mCommandReceiveInterface->getListMainSources(listSources); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.append(listSources); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::getListMainSinkSoundProperties(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListMainSinkSoundProperties called"); - - (void) conn; - assert(mCommandReceiveInterface!=NULL); - - mDBUSMessageHandler.initReceive(msg); - am_sinkID_t sinkID = (am_sinkID_t) mDBUSMessageHandler.getUInt(); - std::vector listSinkSoundProperties; - am_Error_e returnCode = mCommandReceiveInterface->getListMainSinkSoundProperties(sinkID, listSinkSoundProperties); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.append(listSinkSoundProperties); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::getListMainSourceSoundProperties(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListMainSourceSoundProperties called"); - - (void) conn; - assert(mCommandReceiveInterface!=NULL); - - mDBUSMessageHandler.initReceive(msg); - am_sourceID_t sourceID = (am_sourceID_t) mDBUSMessageHandler.getUInt(); - std::vector listSinkSoundProperties; - am_Error_e returnCode = mCommandReceiveInterface->getListMainSourceSoundProperties(sourceID, listSinkSoundProperties); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.append(listSinkSoundProperties); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::getListSourceClasses(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListSourceClasses called"); - - (void) conn; - assert(mCommandReceiveInterface!=NULL); - std::vector listSourceClasses; - am_Error_e returnCode = mCommandReceiveInterface->getListSourceClasses(listSourceClasses); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.append(listSourceClasses); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::getListSinkClasses(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListSinkClasses called"); - - (void) conn; - assert(mCommandReceiveInterface!=NULL); - std::vector listSinkClasses; - am_Error_e returnCode = mCommandReceiveInterface->getListSinkClasses(listSinkClasses); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.append(listSinkClasses); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::getListSystemProperties(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getListSystemProperties called"); - - (void) conn; - assert(mCommandReceiveInterface!=NULL); - std::vector listSystemProperties; - am_Error_e returnCode = mCommandReceiveInterface->getListSystemProperties(listSystemProperties); - mDBUSMessageHandler.initReply(msg); - mDBUSMessageHandler.append((dbus_int16_t) returnCode); - mDBUSMessageHandler.append(listSystemProperties); - mDBUSMessageHandler.sendMessage(); -} - -void CommandReceiverShadow::getTimingInformation(DBusConnection *conn, DBusMessage *msg) -{ - log(&commandDbus,DLT_LOG_INFO,"CommandReceiverShadow::getTimingInformation called"); - - (void) conn; - assert(mCommandReceiveInterface!=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); - 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) -{ - assert(conn!=NULL); - assert(msg!=NULL); - assert(user_data!=NULL); - CommandReceiverShadow* reference = (CommandReceiverShadow*) user_data; - return (reference->receiveCallbackDelegate(conn, msg)); -} - -void CommandReceiverShadow::sendIntrospection(DBusConnection *conn, DBusMessage *msg) -{ - assert(conn!=NULL); - assert(msg!=NULL); - DBusMessage* reply; - DBusMessageIter args; - dbus_uint32_t serial = 0; - - // create a reply from the message - reply = dbus_message_new_method_return(msg); - std::ifstream in(INTROSPECTION_COMMAND_XML_FILE); - assert(in!=NULL); - std::string introspect((std::istreambuf_iterator(in)), std::istreambuf_iterator()); - const char* string = introspect.c_str(); - - // add the arguments to the reply - dbus_message_iter_init_append(reply, &args); - if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &string)) - { - // DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); - } - - // send the reply && flush the connection - if (!dbus_connection_send(conn, reply, &serial)) - { - // DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); - } - dbus_connection_flush(conn); - - // free the reply - dbus_message_unref(reply); -} - -DBusHandlerResult CommandReceiverShadow::receiveCallbackDelegate(DBusConnection *conn, DBusMessage *msg) -{ - //DLT_LOG(dMain, DLT_LOG_INFO, DLT_STRING("message received")); - - if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) - { - sendIntrospection(conn, msg); - return (DBUS_HANDLER_RESULT_HANDLED); - } - - functionMap_t::iterator iter = mFunctionMap.begin(); - std::string k(dbus_message_get_member(msg)); - iter = mFunctionMap.find(k); - if (iter != mFunctionMap.end()) - { - std::string p(iter->first); - CallBackMethod cb = iter->second; - (this->*cb)(conn, msg); - return (DBUS_HANDLER_RESULT_HANDLED); - } - - return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED); -} - -void CommandReceiverShadow::setCommandReceiver(CommandReceiveInterface*& receiver) -{ - assert(receiver!=NULL); - mCommandReceiveInterface = receiver; - - gObjectPathVTable.message_function = CommandReceiverShadow::receiveCallback; - - DBusConnection* connection; - mCommandReceiveInterface->getDBusConnectionWrapper(mDBusWrapper); - assert(mDBusWrapper!=NULL); - - mDBusWrapper->getDBusConnection(connection); - assert(connection!=NULL); - mDBUSMessageHandler.setDBusConnection(connection); - - std::string path(MY_NODE); - mDBusWrapper->registerCallback(&gObjectPathVTable, path, this); -} - -CommandReceiverShadow::functionMap_t CommandReceiverShadow::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; - return (m); -} - 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 . - * 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 -#include -#include "DBusCommandSender.h" -#include "DBusMessageHandler.h" -#include "DLTWrapper.h" -#include -#include -#include -#include -#include - -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/DBusMessageHandler.cpp b/PluginCommandInterfaceDbus/src/DBusMessageHandler.cpp deleted file mode 100644 index 3dd9172..0000000 --- a/PluginCommandInterfaceDbus/src/DBusMessageHandler.cpp +++ /dev/null @@ -1,629 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger DbusPlugin - * - * \file DBusMessageHandler.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 . - * 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 -#include "DBusMessageHandler.h" -#include "DBusCommandSender.h" -#include "DLTWrapper.h" -#include -#include -#include - -DLT_IMPORT_CONTEXT(commandDbus) - -using namespace am; - -DBusMessageHandler::DBusMessageHandler() : - mDBusMessageIter(), // - mDBusError(), // - mSerial(0), // - mErrorName(""), // - mErrorMsg(""), // - mDbusMessage(NULL), // - mReveiveMessage(NULL), // - mDBusConnection(NULL) -{ - log(&commandDbus, DLT_LOG_INFO, "DBusMessageHandler constructed"); -} - -DBusMessageHandler::~DBusMessageHandler() -{ - log(&commandDbus, DLT_LOG_INFO, "DBUSMessageHandler destructed"); -} - -void DBusMessageHandler::initReceive(DBusMessage* msg) -{ - assert(msg!=NULL); - mReveiveMessage = msg; - if (!dbus_message_iter_init(msg, &mDBusMessageIter)) - { - log(&commandDbus, DLT_LOG_INFO, "DBusMessageHandler::initReceive DBus Message has no arguments!"); - mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); - mErrorMsg = "DBUS Message has no arguments!"; - } -} - -void DBusMessageHandler::initReply(DBusMessage* msg) -{ - assert(msg!=NULL); - mDbusMessage = dbus_message_new_method_return(msg); - if (mDbusMessage == 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); -} - -void DBusMessageHandler::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()); - - if (mDbusMessage == NULL) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::initSignal Cannot allocate DBus message!"); - } - dbus_message_iter_init_append(mDbusMessage, &mDBusMessageIter); -} - -void DBusMessageHandler::sendMessage() -{ - assert(mDBusConnection!=NULL); - if (mReveiveMessage != 0) - { - mSerial = dbus_message_get_serial(mReveiveMessage); - } - else - { - mSerial = 1; - } - if (!mErrorName.empty()) - { - mDbusMessage = dbus_message_new_error(mReveiveMessage, mErrorName.c_str(), mErrorMsg.c_str()); - } - if (!dbus_connection_send(mDBusConnection, mDbusMessage, &mSerial)) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::sendMessage cannot send message!"); - } - dbus_connection_flush(mDBusConnection); - dbus_message_unref(mDbusMessage); - mDbusMessage = NULL; -} - -char* DBusMessageHandler::getString() -{ - char* param = NULL; - - if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&mDBusMessageIter)) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getString DBUS handler argument is no String!"); - mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); - mErrorMsg = "DBus argument is no string"; - } - else - { - dbus_message_iter_get_basic(&mDBusMessageIter, ¶m); - dbus_message_iter_next(&mDBusMessageIter); - } - return (param); -} - -dbus_bool_t DBusMessageHandler::getBool() -{ - dbus_bool_t boolparam = false; - - if (DBUS_TYPE_BOOLEAN != dbus_message_iter_get_arg_type(&mDBusMessageIter)) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getBool DBUS handler argument is no bool!"); - mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); - mErrorMsg = "DBus argument is no bool"; - } - else - { - dbus_message_iter_get_basic(&mDBusMessageIter, &boolparam); - dbus_message_iter_next(&mDBusMessageIter); - } - return (boolparam); -} - -char DBusMessageHandler::getByte() -{ - char param; - - if (DBUS_TYPE_BYTE != dbus_message_iter_get_arg_type(&mDBusMessageIter)) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getByte DBUS handler argument is no byte!"); - mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); - mErrorMsg = "DBus argument is no byte"; - } - else - { - dbus_message_iter_get_basic(&mDBusMessageIter, ¶m); - dbus_message_iter_next(&mDBusMessageIter); - } - return (param); -} - -dbus_uint16_t DBusMessageHandler::getUInt() -{ - dbus_uint16_t param; - -#ifdef GLIB_DBUS_TYPES_TOLERANT - if (DBUS_TYPE_UINT16 != dbus_message_iter_get_arg_type(&mDBusMessageIter) && DBUS_TYPE_UINT32 != dbus_message_iter_get_arg_type(&mDBusMessageIter)) -#else - if (DBUS_TYPE_UINT16 != dbus_message_iter_get_arg_type(&mDBusMessageIter)) -#endif - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getUInt DBUS handler argument is no uint16_t!"); - mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); - mErrorMsg = "DBus argument is no uint16_t"; - } - else - { - dbus_message_iter_get_basic(&mDBusMessageIter, ¶m); - dbus_message_iter_next(&mDBusMessageIter); - } - return (param); -} - -dbus_int16_t DBusMessageHandler::getInt() -{ - dbus_int16_t param; - -#ifdef GLIB_DBUS_TYPES_TOLERANT - if (DBUS_TYPE_INT16 != dbus_message_iter_get_arg_type(&mDBusMessageIter) && DBUS_TYPE_INT32 != dbus_message_iter_get_arg_type(&mDBusMessageIter)) -#else - if (DBUS_TYPE_INT16 != dbus_message_iter_get_arg_type(&mDBusMessageIter)) -#endif - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getInt DBUS handler argument is no int16_t!"); - mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); - mErrorMsg = "DBus argument is no int16_t"; - } - else - { - dbus_message_iter_get_basic(&mDBusMessageIter, ¶m); - dbus_message_iter_next(&mDBusMessageIter); - } - return (param); -} - -double DBusMessageHandler::getDouble() -{ - double param; - if (DBUS_TYPE_DOUBLE != dbus_message_iter_get_arg_type(&mDBusMessageIter)) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getDouble DBUS handler argument is no double!"); - mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); - mErrorMsg = "DBus argument is no double"; - } - else - { - dbus_message_iter_get_basic(&mDBusMessageIter, ¶m); - dbus_message_iter_next(&mDBusMessageIter); - } - return (param); -} - -void DBusMessageHandler::getProperty(dbus_int16_t & type, dbus_int16_t & value) -{ - DBusMessageIter arrayIter; - if (DBUS_TYPE_STRUCT != dbus_message_iter_get_arg_type(&mDBusMessageIter)) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getProperty DBUS handler argument is no array!"); - mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); - mErrorMsg = "DBus argument is no array"; - } - else - { - dbus_message_iter_recurse(&mDBusMessageIter, &arrayIter); - dbus_message_iter_get_basic(&arrayIter, &type); - dbus_message_iter_next(&arrayIter); - dbus_message_iter_get_basic(&arrayIter, &value); - dbus_message_iter_next(&mDBusMessageIter); - } -} - -void DBusMessageHandler::append(bool toAppend) -{ - dbus_bool_t mybool = toAppend; - if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_BOOLEAN, &mybool)) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(double toAppend) -{ - if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_DOUBLE, &toAppend)) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(char toAppend) -{ - if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_BYTE, &toAppend)) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(dbus_int16_t toAppend) -{ - if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_INT16, &toAppend)) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(dbus_uint16_t toAppend) -{ - if (!dbus_message_iter_append_basic(&mDBusMessageIter, DBUS_TYPE_UINT16, &toAppend)) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::setDBusConnection(DBusConnection *& connection) -{ - assert(connection!=NULL); - mDBusConnection = connection; -} - -void DBusMessageHandler::append(const am::am_SinkType_s& sinkType) -{ - DBusMessageIter structIter; - DBusMessageIter structAvailIter; - dbus_bool_t success = true; - success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sinkType.sinkID); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &sinkType.name); - - success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &structAvailIter); - success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sinkType.availability.availability); - success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sinkType.availability.availabilityReason); - success = success && dbus_message_iter_close_container(&structIter, &structAvailIter); - - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &sinkType.volume); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &sinkType.muteState); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sinkType.sinkClassID); - success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter); - - if (!success) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(const am::am_SourceType_s & sourceType) -{ - DBusMessageIter structIter; - DBusMessageIter structAvailIter; - dbus_bool_t success = true; - success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sourceType.sourceID); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &sourceType.name); - - success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &structAvailIter); - success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sourceType.availability.availability); - success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &sourceType.availability.availabilityReason); - success = success && dbus_message_iter_close_container(&structIter, &structAvailIter); - - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &sourceType.sourceClassID); - success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter); - - if (!success) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(const am::am_MainSoundProperty_s mainSoundProperty) -{ - DBusMessageIter structIter; - dbus_bool_t success = true; - success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &mainSoundProperty.type); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &mainSoundProperty.value); - success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter); - - if (!success) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(const am::am_Availability_s & availability) -{ - DBusMessageIter structAvailIter; - dbus_bool_t success = true; - success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structAvailIter); - success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &availability.availability); - success = success && dbus_message_iter_append_basic(&structAvailIter, DBUS_TYPE_INT16, &availability.availabilityReason); - success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structAvailIter); - - if (!success) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(const am::am_SystemProperty_s & SystemProperty) -{ - DBusMessageIter structIter; - dbus_bool_t success = true; - success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &SystemProperty.type); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &SystemProperty.value); - success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter); - - if (!success) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(const std::vector& listMainConnections) -{ - DBusMessageIter arrayIter; - DBusMessageIter structIter; - std::vector::const_iterator listIterator = listMainConnections.begin(); - dbus_bool_t success = true; - - success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qqqnn)", &arrayIter); - for (; listIterator < listMainConnections.end(); ++listIterator) - { - success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->mainConnectionID); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceID); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkID); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->delay); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->connectionState); - success = success && dbus_message_iter_close_container(&arrayIter, &structIter); - } - success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); - - if (!success) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(const std::vector & listMainSinks) -{ - DBusMessageIter arrayIter; - DBusMessageIter structIter; - DBusMessageIter availIter; - std::vector::const_iterator listIterator = listMainSinks.begin(); - dbus_bool_t success = true; - - success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qs(nn)nnq)", &arrayIter); - for (; listIterator < listMainSinks.end(); ++listIterator) - { - success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkID); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name); - success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &availIter); - success = success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availability); - success = success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availabilityReason); - success = success && dbus_message_iter_close_container(&structIter, &availIter); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->volume); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->muteState); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkClassID); - success = success && dbus_message_iter_close_container(&arrayIter, &structIter); - } - success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); - - if (!success) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(const std::vector & listMainSources) -{ - DBusMessageIter arrayIter; - DBusMessageIter structIter; - DBusMessageIter availIter; - std::vector::const_iterator listIterator = listMainSources.begin(); - dbus_bool_t success = true; - - success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qs(nn)q)", &arrayIter); - for (; listIterator < listMainSources.end(); ++listIterator) - { - success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceID); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name); - success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_STRUCT, NULL, &availIter); - success = success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availability); - success = success && dbus_message_iter_append_basic(&availIter, DBUS_TYPE_INT16, &listIterator->availability.availabilityReason); - success = success && dbus_message_iter_close_container(&structIter, &availIter); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceClassID); - success = success && dbus_message_iter_close_container(&arrayIter, &structIter); - } - success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); - - if (!success) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(const std::vector & listMainSoundProperties) -{ - DBusMessageIter arrayIter; - DBusMessageIter structIter; - std::vector::const_iterator listIterator = listMainSoundProperties.begin(); - dbus_bool_t success = true; - - success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(nn)", &arrayIter); - for (; listIterator < listMainSoundProperties.end(); ++listIterator) - { - success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->type); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->value); - success = success && dbus_message_iter_close_container(&arrayIter, &structIter); - } - success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); - - if (!success) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(const std::vector & listSourceClasses) -{ - DBusMessageIter arrayIter; - DBusMessageIter structIter; - DBusMessageIter propIter; - DBusMessageIter innerIter; - std::vector::const_iterator listIterator = listSourceClasses.begin(); - dbus_bool_t success = true; - - success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qsa(nn))", &arrayIter); - for (; listIterator < listSourceClasses.end(); ++listIterator) - { - success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sourceClassID); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name); - success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_ARRAY, "(nn)", &innerIter); - - std::vector::const_iterator listInnerIterator = listIterator->listClassProperties.begin(); - for (; listInnerIterator < listIterator->listClassProperties.end(); ++listInnerIterator) - { - success = success && dbus_message_iter_open_container(&innerIter, DBUS_TYPE_STRUCT, NULL, &propIter); - success = success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->classProperty); - success = success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->value); - success = success && dbus_message_iter_close_container(&innerIter, &propIter); - } - success = success && dbus_message_iter_close_container(&structIter, &innerIter); - success = success && dbus_message_iter_close_container(&arrayIter, &structIter); - } - success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); - - if (!success) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(const std::vector & listSinkClasses) -{ - DBusMessageIter arrayIter; - DBusMessageIter structIter; - DBusMessageIter propIter; - DBusMessageIter innerIter; - std::vector::const_iterator listIterator = listSinkClasses.begin(); - dbus_bool_t success = true; - - success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(qsa(nn))", &arrayIter); - for (; listIterator < listSinkClasses.end(); ++listIterator) - { - success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_UINT16, &listIterator->sinkClassID); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_STRING, &listIterator->name); - success = success && dbus_message_iter_open_container(&structIter, DBUS_TYPE_ARRAY, "(nn)", &innerIter); - - std::vector::const_iterator listInnerIterator = listIterator->listClassProperties.begin(); - for (; listInnerIterator < listIterator->listClassProperties.end(); ++listInnerIterator) - { - success = success && dbus_message_iter_open_container(&innerIter, DBUS_TYPE_STRUCT, NULL, &propIter); - success = success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->classProperty); - success = success && dbus_message_iter_append_basic(&propIter, DBUS_TYPE_INT16, &listInnerIterator->value); - success = success && dbus_message_iter_close_container(&innerIter, &propIter); - } - success = success && dbus_message_iter_close_container(&structIter, &innerIter); - success = success && dbus_message_iter_close_container(&arrayIter, &structIter); - } - success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); - - if (!success) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - -void DBusMessageHandler::append(const std::vector & listSystemProperties) -{ - DBusMessageIter arrayIter; - DBusMessageIter structIter; - std::vector::const_iterator listIterator = listSystemProperties.begin(); - dbus_bool_t success = true; - - success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(nn)", &arrayIter); - for (; listIterator < listSystemProperties.end(); ++listIterator) - { - success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->type); - success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->value); - success = success && dbus_message_iter_close_container(&arrayIter, &structIter); - } - success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); - - if (!success) - { - log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); - mErrorName = std::string(DBUS_ERROR_NO_MEMORY); - mErrorMsg = "Cannot create reply!"; - } -} - diff --git a/PluginCommandInterfaceDbus/src/IAmCommandReceiverShadow.cpp b/PluginCommandInterfaceDbus/src/IAmCommandReceiverShadow.cpp new file mode 100644 index 0000000..f43c9e6 --- /dev/null +++ b/PluginCommandInterfaceDbus/src/IAmCommandReceiverShadow.cpp @@ -0,0 +1,447 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger DbusPlugin + * + * \file CommandReceiverShadow.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 . + * 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 "IAmCommandReceiverShadow.h" +#include +#include +#include +#include +#include "audiomanagertypes.h" +#include "CAmCommandSenderDbus.h" +#include "shared/CAmDltWrapper.h" + +using namespace am; + +DLT_IMPORT_CONTEXT(commandDbus) + +/** + * static ObjectPathTable is needed for DBus Callback handling + */ +static DBusObjectPathVTable gObjectPathVTable; + +IAmCommandReceiverShadow::IAmCommandReceiverShadow() : + mFunctionMap(createMap()), // + mDBUSMessageHandler(), // + mpIAmCommandReceive(NULL), // + mpCAmDbusWrapper(NULL) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow constructed"); +} + +IAmCommandReceiverShadow::~IAmCommandReceiverShadow() +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow destructed"); +} + +void IAmCommandReceiverShadow::connect(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::connect called"); + + (void) conn; + 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 = mpIAmCommandReceive->connect(sourceID, sinkID, mainConnectionID); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.append((dbus_uint16_t) mainConnectionID); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::disconnect(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::disconnect called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + + mDBUSMessageHandler.initReceive(msg); + am_mainConnectionID_t mainConnnectionID = (am_mainConnectionID_t) mDBUSMessageHandler.getUInt(); + am_Error_e returnCode = mpIAmCommandReceive->disconnect(mainConnnectionID); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::setVolume(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::setVolume called"); + + (void) conn; + 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 = mpIAmCommandReceive->setVolume(sinkID, volume); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::volumeStep(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::volumeStep called"); + + (void) conn; + 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 = mpIAmCommandReceive->volumeStep(sinkID, volumeStep); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::setSinkMuteState(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::setSinkMuteState called"); + + (void) conn; + 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 = mpIAmCommandReceive->setSinkMuteState(sinkID, muteState); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::setMainSinkSoundProperty(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::setMainSinkSoundProperty called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + + mDBUSMessageHandler.initReceive(msg); + am_sinkID_t sinkID = (am_sinkID_t) mDBUSMessageHandler.getUInt(); + dbus_int16_t type = 0; + dbus_int16_t value = 0; + mDBUSMessageHandler.getProperty(type, value); + am_MainSoundProperty_s mainSoundProperty; + mainSoundProperty.type = (am_MainSoundPropertyType_e) type; + mainSoundProperty.value = (int32_t) value; + am_Error_e returnCode = mpIAmCommandReceive->setMainSinkSoundProperty(mainSoundProperty, sinkID); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::setMainSourceSoundProperty(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::setMainSourceSoundProperty called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + + mDBUSMessageHandler.initReceive(msg); + am_sourceID_t sourceID = (am_sinkID_t) mDBUSMessageHandler.getUInt(); + dbus_int16_t type = 0; + dbus_int16_t value = 0; + mDBUSMessageHandler.getProperty(type, value); + am_MainSoundProperty_s mainSoundProperty; + mainSoundProperty.type = (am_MainSoundPropertyType_e) type; + mainSoundProperty.value = (int32_t) value; + am_Error_e returnCode = mpIAmCommandReceive->setMainSourceSoundProperty(mainSoundProperty, sourceID); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::setSystemProperty(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::setSystemProperty called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + + mDBUSMessageHandler.initReceive(msg); + dbus_int16_t type = 0; + dbus_int16_t value = 0; + mDBUSMessageHandler.getProperty(type, value); + am_SystemProperty_s systemProperty; + systemProperty.type = (am_SystemPropertyType_e) type; + systemProperty.value = (int32_t) value; + am_Error_e returnCode = mpIAmCommandReceive->setSystemProperty(systemProperty); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::getListMainConnections(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListMainConnections called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + std::vector listMainConnections; + am_Error_e returnCode = mpIAmCommandReceive->getListMainConnections(listMainConnections); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.append(listMainConnections); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::getListMainSinks(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListMainSinks called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + std::vector listSinks; + am_Error_e returnCode = mpIAmCommandReceive->getListMainSinks(listSinks); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.append(listSinks); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::getListMainSources(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListMainSources called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + std::vector listSources; + am_Error_e returnCode = mpIAmCommandReceive->getListMainSources(listSources); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.append(listSources); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::getListMainSinkSoundProperties(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListMainSinkSoundProperties called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + + mDBUSMessageHandler.initReceive(msg); + am_sinkID_t sinkID = (am_sinkID_t) mDBUSMessageHandler.getUInt(); + std::vector listSinkSoundProperties; + am_Error_e returnCode = mpIAmCommandReceive->getListMainSinkSoundProperties(sinkID, listSinkSoundProperties); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.append(listSinkSoundProperties); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::getListMainSourceSoundProperties(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListMainSourceSoundProperties called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + + mDBUSMessageHandler.initReceive(msg); + am_sourceID_t sourceID = (am_sourceID_t) mDBUSMessageHandler.getUInt(); + std::vector listSinkSoundProperties; + am_Error_e returnCode = mpIAmCommandReceive->getListMainSourceSoundProperties(sourceID, listSinkSoundProperties); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.append(listSinkSoundProperties); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::getListSourceClasses(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListSourceClasses called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + std::vector listSourceClasses; + am_Error_e returnCode = mpIAmCommandReceive->getListSourceClasses(listSourceClasses); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.append(listSourceClasses); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::getListSinkClasses(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListSinkClasses called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + std::vector listSinkClasses; + am_Error_e returnCode = mpIAmCommandReceive->getListSinkClasses(listSinkClasses); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.append(listSinkClasses); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::getListSystemProperties(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListSystemProperties called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + std::vector listSystemProperties; + am_Error_e returnCode = mpIAmCommandReceive->getListSystemProperties(listSystemProperties); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.append(listSystemProperties); + mDBUSMessageHandler.sendMessage(); +} + +void IAmCommandReceiverShadow::getTimingInformation(DBusConnection *conn, DBusMessage *msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getTimingInformation called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + + mDBUSMessageHandler.initReceive(msg); + am_mainConnectionID_t mainConnectionID = (am_mainConnectionID_t) mDBUSMessageHandler.getUInt(); + am_timeSync_t delay = 0; + 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 IAmCommandReceiverShadow::receiveCallback(DBusConnection *conn, DBusMessage *msg, void *user_data) +{ + assert(conn!=NULL); + assert(msg!=NULL); + assert(user_data!=NULL); + IAmCommandReceiverShadow* reference = (IAmCommandReceiverShadow*) user_data; + return (reference->receiveCallbackDelegate(conn, msg)); +} + +void IAmCommandReceiverShadow::sendIntrospection(DBusConnection *conn, DBusMessage *msg) +{ + assert(conn!=NULL); + assert(msg!=NULL); + DBusMessage* reply; + DBusMessageIter args; + dbus_uint32_t serial = 0; + + // create a reply from the message + reply = dbus_message_new_method_return(msg); + std::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(in)), std::istreambuf_iterator()); + const char* string = introspect.c_str(); + + // add the arguments to the reply + dbus_message_iter_init_append(reply, &args); + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &string)) + { + // DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + } + + // send the reply && flush the connection + if (!dbus_connection_send(conn, reply, &serial)) + { + // DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + } + dbus_connection_flush(conn); + + // free the reply + dbus_message_unref(reply); +} + +DBusHandlerResult IAmCommandReceiverShadow::receiveCallbackDelegate(DBusConnection *conn, DBusMessage *msg) +{ + //DLT_LOG(dMain, DLT_LOG_INFO, DLT_STRING("message received")); + + if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) + { + sendIntrospection(conn, msg); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + functionMap_t::iterator iter = mFunctionMap.begin(); + std::string k(dbus_message_get_member(msg)); + iter = mFunctionMap.find(k); + if (iter != mFunctionMap.end()) + { + std::string p(iter->first); + CallBackMethod cb = iter->second; + (this->*cb)(conn, msg); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED); +} + +void IAmCommandReceiverShadow::setCommandReceiver(IAmCommandReceive*& receiver) +{ + assert(receiver!=NULL); + mpIAmCommandReceive = receiver; + + gObjectPathVTable.message_function = IAmCommandReceiverShadow::receiveCallback; + + DBusConnection* connection; + mpIAmCommandReceive->getDBusConnectionWrapper(mpCAmDbusWrapper); + assert(mpCAmDbusWrapper!=NULL); + + mpCAmDbusWrapper->getDBusConnection(connection); + assert(connection!=NULL); + mDBUSMessageHandler.setDBusConnection(connection); + + std::string path(MY_NODE); + mpCAmDbusWrapper->registerCallback(&gObjectPathVTable, path, this); +} + +IAmCommandReceiverShadow::functionMap_t IAmCommandReceiverShadow::createMap() +{ + functionMap_t m; + 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/CAmCommandSenderDbusBackdoor.cpp b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusBackdoor.cpp new file mode 100644 index 0000000..c3f53e1 --- /dev/null +++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusBackdoor.cpp @@ -0,0 +1,71 @@ +/** +* Copyright (C) 2011, BMW AG +* +* GeniviAudioMananger AudioManagerDaemon +* +* \file DbusCommandInterfaceBackdoor.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 . +* 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 "CAmCommandSenderDbusBackdoor.h" +#include "command/IAmCommandReceive.h" + + +using namespace am; + +CAmCommandSenderDbusBackdoor::CAmCommandSenderDbusBackdoor() +{ +} + +CAmCommandSenderDbusBackdoor::~CAmCommandSenderDbusBackdoor() +{ +} + +void CAmCommandSenderDbusBackdoor::setReceiveInterface(CAmCommandSenderDbus *sender, IAmCommandReceive* interface) +{ + sender->mpIAmCommandReceive=interface; +} + +void CAmCommandSenderDbusBackdoor::setDbusConnection(CAmCommandSenderDbus *sender, DBusConnection *conn) +{ + sender->mCAmDbusMessageHandler.setDBusConnection(conn); +} + +void CAmCommandSenderDbusBackdoor::setListSinks(CAmCommandSenderDbus *sender, std::vector newList) +{ + sender->mlistSinks=newList; +} + +void CAmCommandSenderDbusBackdoor::setListSources(CAmCommandSenderDbus *sender, std::vector newList) +{ + sender->mlistSources=newList; +} + + + + + + + + + + + + + diff --git a/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusBackdoor.h b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusBackdoor.h new file mode 100644 index 0000000..bbbeda9 --- /dev/null +++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusBackdoor.h @@ -0,0 +1,52 @@ +/** +* Copyright (C) 2011, BMW AG +* +* GeniviAudioMananger AudioManagerDaemon +* +* \file DubsIAmCommandBackdoor +* +* \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 . +* 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 DBUSCOMMANDINTERFACEBACKDOOR_H_ +#define DBUSCOMMANDINTERFACEBACKDOOR_H_ + +#include "../include/CAmCommandSenderDbus.h" +#include +#include +#include "audiomanagertypes.h" +#include "command/IAmCommandReceive.h" + +namespace am { + +class CAmCommandSenderDbus; + +class CAmCommandSenderDbusBackdoor +{ +public: + CAmCommandSenderDbusBackdoor(); + virtual ~CAmCommandSenderDbusBackdoor(); + void setReceiveInterface(CAmCommandSenderDbus *sender, IAmCommandReceive* interface); + void setDbusConnection(CAmCommandSenderDbus *sender,DBusConnection *conn); + void setListSinks(CAmCommandSenderDbus *sender, std::vector newList); + void setListSources(CAmCommandSenderDbus *sender, std::vector newList); +}; + +} + +#endif /* DBUSCOMMANDINTERFACEBACKDOOR_H_ */ diff --git a/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.cpp b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.cpp new file mode 100644 index 0000000..071af58 --- /dev/null +++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.cpp @@ -0,0 +1,806 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger AudioManagerDaemon + * + * \file dbuscommandinterfacesignalsTest.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 . + * 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 "CAmCommandSenderDbusSignalTest.h" +#include +#include +#include +#include +#include +#include +#include +#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; + +CAmCommandSenderDbusSignalTest::CAmCommandSenderDbusSignalTest() +{ + CAmDltWrapper::instance()->registerApp("dbusTest", "dbusTest"); + logInfo("dbusCommandInterfaceSignalTest started"); +} + +CAmCommandSenderDbusSignalTest::~CAmCommandSenderDbusSignalTest() +{ +} + +void* NumberOfMainConnectionsChanged(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + am_MainConnectionType_s mainConnection; + sender->cbNewMainConnection(mainConnection); + return (NULL); +} + +void* cbSinkAdded(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + std::vector list; + 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; + sender->cbNewSink(mysink); + return (NULL); +} + +void* cbSourceAdded(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(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* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + am_SourceType_s mysource; + mysource.name = "MySink"; + mysource.sourceID = 42; + sender->cbRemovedSource(mysource.sourceID); + return (NULL); +} + +void* cbSinkRemoved(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + am_SinkType_s mysink; + mysink.name = "MySink"; + mysink.sinkID = 23; + sender->cbRemovedSink(mysink.sinkID); + return (NULL); +} + +void* NumberOfSinkClassesChanged(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + sender->cbNumberOfSinkClassesChanged(); + return (NULL); +} + +void* NumberOfSourceClassesChanged(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + sender->cbNumberOfSourceClassesChanged(); + return (NULL); +} + +void* MainConnectionStateChanged(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + am_connectionID_t id = 4; + am_ConnectionState_e state = CS_CONNECTING; + sender->cbMainConnectionStateChanged(id, state); + return (NULL); +} + +void* MainSinkSoundPropertyChanged(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + am_sinkID_t sinkID = 3; + am_MainSoundProperty_s soundProperty; + soundProperty.type = MSP_UNKNOWN; + soundProperty.value = 23; + sender->cbMainSinkSoundPropertyChanged(sinkID, soundProperty); + return (NULL); +} + +void* MainSourceSoundPropertyChanged(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + am_sourceID_t sourceID = 35; + am_MainSoundProperty_s soundProperty; + soundProperty.type = MSP_UNKNOWN; + soundProperty.value = 233; + sender->cbMainSourceSoundPropertyChanged(sourceID, soundProperty); + return (NULL); +} + +void* cbSinkAvailabilityChangedLoop(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + am_Availability_s av; + av.availability = A_AVAILABLE; + av.availabilityReason = AR_UNKNOWN; + sender->cbSinkAvailabilityChanged(4, av); + return (NULL); +} + +void* VolumeChanged(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + am_volume_t volume = 344; + sender->cbVolumeChanged(23, volume); + return (NULL); +} + +void* cbSourceAvailabilityChangedLoop(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + am_Availability_s av; + av.availability = A_AVAILABLE; + av.availabilityReason = AR_UNKNOWN; + sender->cbSourceAvailabilityChanged(2, av); + return (NULL); +} + +void* SinkMuteStateChanged(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + sender->cbSinkMuteStateChanged(42, MS_MUTED); + return (NULL); +} + +void* SystemPropertyChanged(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + am_SystemProperty_s property; + property.type = SYP_UNKNOWN; + property.value = 355; + sender->cbSystemPropertyChanged(property); + return (NULL); +} + +void* TimingInformationChanged(void* ppCommandSend) +{ + sleep(1); + IAmCommandSend* sender=static_cast(ppCommandSend); + sender->cbTimingInformationChanged(42, 233); + return (NULL); +} + +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(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*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchsignal(*arg, **kwarg):\n" + " print ('Caught NumberOfMainConnectionsChanged') \n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchsignal, signal_name='NumberOfMainConnectionsChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + pthread_create(&pythonloop, NULL, cbSinkAdded, (void*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchSinkAdded(*arg, **karg):\n" + " print ('Caught signal (in SinkAdded handler) ') \n" + " print (arg[0])\n" + " f = open('/tmp/result.txt','w')\n" + " f.write(str(arg[0]));\n" + " f.close()\n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchSinkAdded, signal_name='SinkAdded', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + std::ifstream ifs("/tmp/result.txt"); + std::string line; + int lineCounter = 0, result = 0; + while (std::getline(ifs, line)) + { + ASSERT_EQ(line.compare("dbus.Struct((dbus.UInt16(23), dbus.String(u'MySink'), dbus.Struct((dbus.Int16(3), dbus.Int16(0)), signature=None), dbus.Int16(234), dbus.Int16(0), dbus.UInt16(3)), signature=None)"), 0); + } + ifs.close(); + + pthread_create(&pythonloop, NULL, cbSinkRemoved, (void*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchSinkRemoved(*arg, **karg):\n" + " print ('Caught signal (in SinkRemoved handler) ') \n" + " print (arg[0])\n" + " f = open('/tmp/result.txt','w')\n" + " f.write(str(arg[0]));\n" + " f.close()\n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchSinkRemoved, signal_name='SinkRemoved', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + ifs.open("/tmp/result.txt"); + lineCounter = 0; + result = 0; + while (std::getline(ifs, line)) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, 23); + } + ifs.close(); + + pthread_create(&pythonloop, NULL, cbSourceAdded, (void*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchSourceAdded(*arg, **karg):\n" + " print ('Caught signal (in SourceAdded handler) ') \n" + " print (arg[0])\n" + " f = open('/tmp/result.txt','w')\n" + " f.write(str(arg[0]));\n" + " f.close()\n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchSourceAdded, signal_name='SourceAdded', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + ifs.open("/tmp/result.txt"); + lineCounter = 0; + result = 0; + while (std::getline(ifs, line)) + { + ASSERT_EQ(line.compare("dbus.Struct((dbus.UInt16(42), dbus.String(u'MySink'), dbus.Struct((dbus.Int16(3), dbus.Int16(0)), signature=None), dbus.UInt16(15)), signature=None)"), 0); + } + ifs.close(); + + pthread_create(&pythonloop, NULL, cbSourceRemoved, (void*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchSourceRemoved(*arg, **karg):\n" + " print ('Caught signal (in SinkRemoved handler) ') \n" + " print (arg[0])\n" + " f = open('/tmp/result.txt','w')\n" + " f.write(str(arg[0]));\n" + " f.close()\n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchSourceRemoved, signal_name='SourceRemoved', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + ifs.open("/tmp/result.txt"); + lineCounter = 0; + result = 0; + while (std::getline(ifs, line)) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, 42); + } + ifs.close(); + + pthread_create(&pythonloop, NULL, NumberOfSinkClassesChanged, (void*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchNumberOfSinkClassesChanged(*arg, **kwarg):\n" + " print ('Caught catchNumberOfSinkClassesChanged') \n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchNumberOfSinkClassesChanged, signal_name='NumberOfSinkClassesChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + pthread_create(&pythonloop, NULL, NumberOfSourceClassesChanged, (void*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def CatchNumberOfSourceClassesChanged(*arg, **kwarg):\n" + " print ('Caught CatchNumberOfSourceClassesChanged') \n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(CatchNumberOfSourceClassesChanged, signal_name='NumberOfSourceClassesChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + //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*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchMainConnectionStateChanged(*arg, **karg):\n" + " print ('Caught signal (in catchMainConnectionStateChanged handler) ') \n" + " print (arg[0])\n" + " print (arg[1])\n" + " f = open('/tmp/result.txt','w')\n" + " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" + " f.close()\n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchMainConnectionStateChanged, signal_name='MainConnectionStateChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + ifs.open("/tmp/result.txt"); + lineCounter = 0; + result = 0; + while (std::getline(ifs, line)) + { + if (lineCounter == 0) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, 4); + } + else if (lineCounter == 1) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, CS_CONNECTING); + } + lineCounter++; + } + ifs.close(); + + //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*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchMainSinkSoundPropertyChanged(*arg, **karg):\n" + " print ('Caught signal (in catchMainSinkSoundPropertyChanged handler) ') \n" + " print (arg[0])\n" + " print (arg[1])\n" + " f = open('/tmp/result.txt','w')\n" + " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" + " f.close()\n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchMainSinkSoundPropertyChanged, signal_name='MainSinkSoundPropertyChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + ifs.open("/tmp/result.txt"); + lineCounter = 0; + result = 0; + while (std::getline(ifs, line)) + { + if (lineCounter == 0) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, 3); + } + else if (lineCounter == 1) + { + ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(0), dbus.Int16(23)), signature=None)"), 0); + } + lineCounter++; + } + ifs.close(); + + //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*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchMainSourceSoundPropertyChanged(*arg, **karg):\n" + " print ('Caught signal (in catchMainSourceSoundPropertyChanged handler) ') \n" + " print (arg[0])\n" + " print (arg[1])\n" + " f = open('/tmp/result.txt','w')\n" + " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" + " f.close()\n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchMainSourceSoundPropertyChanged, signal_name='MainSourceSoundPropertyChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + ifs.open("/tmp/result.txt"); + lineCounter = 0; + result = 0; + while (std::getline(ifs, line)) + { + if (lineCounter == 0) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, 35); + } + else if (lineCounter == 1) + { + ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(0), dbus.Int16(233)), signature=None)"), 0); + } + lineCounter++; + } + ifs.close(); + + //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*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchSinkAvailabilityChanged(*arg, **karg):\n" + " print ('Caught signal (in catchSinkAvailabilityChanged handler) ') \n" + " print (arg[0])\n" + " print (arg[1])\n" + " f = open('/tmp/result.txt','w')\n" + " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" + " f.close()\n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchSinkAvailabilityChanged, signal_name='SinkAvailabilityChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + ifs.open("/tmp/result.txt"); + lineCounter = 0; + result = 0; + while (std::getline(ifs, line)) + { + if (lineCounter == 0) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, 4); + } + else if (lineCounter == 1) + { + ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(1), dbus.Int16(0)), signature=None)"), 0); + } + lineCounter++; + } + ifs.close(); + + //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*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchSourceAvailability(*arg, **karg):\n" + " print ('Caught signal (in catchSourceAvailability handler) ') \n" + " print (arg[0])\n" + " print (arg[1])\n" + " f = open('/tmp/result.txt','w')\n" + " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" + " f.close()\n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchSourceAvailability, signal_name='SourceAvailabilityChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + ifs.open("/tmp/result.txt"); + lineCounter = 0; + result = 0; + while (std::getline(ifs, line)) + { + if (lineCounter == 0) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, 2); + } + else if (lineCounter == 1) + { + ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(1), dbus.Int16(0)), signature=None)"), 0); + } + lineCounter++; + } + ifs.close(); + + //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*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchVolumeChanged(*arg, **karg):\n" + " print ('Caught signal (in catchVolumeChanged handler) ') \n" + " print (arg[0])\n" + " print (arg[1])\n" + " f = open('/tmp/result.txt','w')\n" + " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" + " f.close()\n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchVolumeChanged, signal_name='VolumeChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + ifs.open("/tmp/result.txt"); + lineCounter = 0; + result = 0; + while (std::getline(ifs, line)) + { + if (lineCounter == 0) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, 23); + } + else if (lineCounter == 1) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, 344); + } + lineCounter++; + } + ifs.close(); + + //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*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchSinkMuteStateChanged(*arg, **karg):\n" + " print ('Caught signal (in catchSinkMuteStateChanged handler) ') \n" + " print (arg[0])\n" + " print (arg[1])\n" + " f = open('/tmp/result.txt','w')\n" + " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" + " f.close()\n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchSinkMuteStateChanged, signal_name='SinkMuteStateChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + ifs.open("/tmp/result.txt"); + lineCounter = 0; + result = 0; + while (std::getline(ifs, line)) + { + if (lineCounter == 0) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, 42); + } + else if (lineCounter == 1) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, MS_MUTED); + } + lineCounter++; + } + ifs.close(); + + //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*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchSystemPropertyChanged(*arg, **karg):\n" + " print ('Caught signal (in catchSystemPropertyChanged handler) ') \n" + " print (arg[0])\n" + " f = open('/tmp/result.txt','w')\n" + " f.write(str(arg[0]));\n" + " f.close()\n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchSystemPropertyChanged, signal_name='SystemPropertyChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + ifs.open("/tmp/result.txt"); + lineCounter = 0; + result = 0; + while (std::getline(ifs, line)) + { + ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(0), dbus.Int16(355)), signature=None)"), 0); + } + ifs.close(); + + //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*) ppCommandSend); + PyRun_SimpleStringFlags("import sys\n" + "import traceback\n" + "import gobject\n" + "import dbus\n" + "import dbus.mainloop.glib\n" + "loop = gobject.MainLoop()\n" + "def catchTimingInformationChanged(*arg, **karg):\n" + " print ('Caught signal (in catchTimingInformationChanged handler) ') \n" + " print (arg[0])\n" + " print (arg[1])\n" + " f = open('/tmp/result.txt','w')\n" + " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" + " f.close()\n" + " loop.quit()\n" + "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" + "bus = dbus.SessionBus()\n" + "bus.add_signal_receiver(catchTimingInformationChanged, signal_name='TimingInformationChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "loop.run()\n", NULL); + pthread_join(pythonloop, NULL); + + ifs.open("/tmp/result.txt"); + lineCounter = 0; + result = 0; + while (std::getline(ifs, line)) + { + if (lineCounter == 0) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, 42); + } + else if (lineCounter == 1) + { + std::stringstream(line) >> result; + ASSERT_EQ(result, 233); + } + lineCounter++; + } + ifs.close(); + +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + +void CAmCommandSenderDbusSignalTest::SetUp() +{ + Py_Initialize(); +} + +void CAmCommandSenderDbusSignalTest::TearDown() +{ + Py_Finalize(); +} + diff --git a/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.h b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.h new file mode 100644 index 0000000..14ad9ef --- /dev/null +++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.h @@ -0,0 +1,51 @@ +/** +* Copyright (C) 2011, BMW AG +* +* GeniviAudioMananger AudioManagerDaemon +* +* \file dbuscommandinterfacesignalsTest.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 . +* 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 DBUSCOMMANINTERFACESIGNALSTEST_H_ +#define DBUSCOMMANINTERFACESIGNALSTEST_H_ + + +#include +#include + +#define UNIT_TEST 1 + +namespace am { + +class IAmCommandSend; + +class CAmCommandSenderDbusSignalTest: public ::testing::Test +{ +public: + IAmCommandSend *ppCommandSend; + CAmCommandSenderDbusSignalTest(); + virtual ~CAmCommandSenderDbusSignalTest(); + void SetUp(); + void TearDown(); +}; + +} + +#endif /* DBUSCOMMANINTERFACESIGNALSTEST_H_ */ diff --git a/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.cpp b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.cpp new file mode 100644 index 0000000..e1d0197 --- /dev/null +++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.cpp @@ -0,0 +1,629 @@ +/** + * Copyright (C) 2011, BMW AG + * + * GeniviAudioMananger AudioManagerDaemon + * + * \file dbuscommandpluginInterfaceTest.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 . + * 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 "CAmCommandSenderDbusTest.h" +#include +#include +#include +#include +#include +#include +#include +#include +#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; + +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) +{ + CAmSocketHandler* wrap = (CAmSocketHandler*) wrapper; + wrap->start_listenting(); + return (NULL); +} + +CAmCommandSenderDbusTest::CAmCommandSenderDbusTest() +{ + CAmDltWrapper::instance()->registerApp("dbusTest", "dbusTest"); +} + +CAmCommandSenderDbusTest::~CAmCommandSenderDbusTest() +{ + +} + +void CAmCommandSenderDbusTest::SetUp() +{ + +} + +void CAmCommandSenderDbusTest::TearDown() +{ + +} + +ACTION(returnListConnections){ +std::vector list; +am::am_MainConnectionType_s listItem; +listItem.mainConnectionID=15; +listItem.sinkID=4; +listItem.sourceID=3; +listItem.connectionState=CS_UNKNOWN; +listItem.delay=34; +list.push_back(listItem); +arg0=list; +} + +ACTION(returnListSinks){ +std::vector list; +am::am_SinkType_s listItem; +listItem.availability.availability=A_UNAVAILABLE; +listItem.availability.availabilityReason=AR_GENIVI_NOMEDIA; +listItem.muteState=MS_UNMUTED; +listItem.name="mySink"; +listItem.sinkClassID=34; +listItem.sinkID=24; +listItem.volume=124; +list.push_back(listItem); +arg0=list; +} + +ACTION(returnListSources){ +std::vector list; +am::am_SourceType_s listItem; +listItem.availability.availability=A_MAX; +listItem.availability.availabilityReason=AR_GENIVI_SAMEMEDIA; +listItem.name="MySource"; +listItem.sourceClassID=12; +listItem.sourceID=224; +list.push_back(listItem); +listItem.name="NextSource"; +listItem.sourceID=22; +list.push_back(listItem); +arg0=list; +} + +ACTION(returnListMainSinkSoundProperties){ +std::vector list; +am::am_MainSoundProperty_s listItem; +listItem.type=MSP_MAX; +listItem.value=223; +list.push_back(listItem); +listItem.type=MSP_UNKNOWN; +listItem.value=2; +list.push_back(listItem); +arg1=list; +} + +ACTION(returnListSourceClasses){ +std::vector list; +am::am_SourceClass_s listItem; +am::am_ClassProperty_s property; +property.classProperty=CP_GENIVI_SINK_TYPE; +property.value=12; +listItem.name="FirstCLass"; +listItem.sourceClassID=23; +listItem.listClassProperties.push_back(property); +list.push_back(listItem); +listItem.name="SecondCLass"; +listItem.sourceClassID=2; +listItem.listClassProperties.push_back(property); +list.push_back(listItem); +arg0=list; +} + +ACTION(returnListSinkClasses){ +std::vector list; +am::am_SinkClass_s listItem; +am::am_ClassProperty_s property; +property.classProperty=CP_GENIVI_SOURCE_TYPE; +property.value=122; +listItem.name="FirstCLass"; +listItem.sinkClassID=2123; +listItem.listClassProperties.push_back(property); +list.push_back(listItem); +listItem.name="SecondCLass"; +listItem.sinkClassID=23; +listItem.listClassProperties.push_back(property); +list.push_back(listItem); +arg0=list; +} + +ACTION(returnListSystemProperties){ +std::vector list; +am::am_SystemProperty_s listItem; +listItem.type=SYP_UNKNOWN; +listItem.value=-2245; +list.push_back(listItem); +arg0=list; +} + +ACTION(returnTimingInfo){ +am::am_timeSync_t time=23; +arg1=time; +} + +TEST_F(CAmCommandSenderDbusTest, MessageTest) +{ + Py_Initialize(); + //unfortunatly we need to put all in one testcase because testing with the dbus loop caused problems... + CAmSocketHandler pSocketHandler; + CAmDbusWrapper pDBusWrapper(&pSocketHandler); + pthread_t ptestThread; + std::vector plistCommandPluginDirs; + plistCommandPluginDirs.push_back(std::string(DEFAULT_PLUGIN_COMMAND_DIR)); + + MockIAmCommandReceive pReceiveInterface; + + //this class just creates the thread that will handle the mainloop... + pthread_create(&ptestThread, NULL, run_the_loop, (void*) &pSocketHandler); + + IAmCommandSend* (*createFunc)(); + void* tempLibHandle = NULL; + std::string libname("../plugins/command/libPluginCommandInterfaceDbus.so"); + createFunc = getCreateFunction(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); + + 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()); + + //check the results + std::ifstream ifs("/tmp/result.txt"); + std::string line; + int lineCounter = 0, result = 0; + while (std::getline(ifs, line)) + { + if (lineCounter == 1) + { + std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result; + ASSERT_EQ(result, E_OK); + } + else if (lineCounter == 2) + { + std::stringstream(line.replace(line.begin(), line.begin() + 10, "")) >> result; + ASSERT_EQ(result, 35); + } + lineCounter++; + } + ifs.close(); + + std::cout << "[connect ]" << std::endl; + + EXPECT_CALL(pReceiveInterface,disconnect(2)).WillOnce(Return(E_OK)); + system((DBUSCOMMAND + std::string("Disconnect uint16:2 > /tmp/result.txt ")).c_str()); + + //check the results + lineCounter = 0; + result = 0; + ifs.open("/tmp/result.txt"); + while (std::getline(ifs, line)) + { + if (lineCounter == 1) + { + std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result; + ASSERT_EQ(result, E_OK); + } + lineCounter++; + } + ifs.close(); + + std::cout << "[disconnect]" << std::endl; + + EXPECT_CALL(pReceiveInterface,setVolume(22,12)).WillOnce(Return(E_OK)); + system((DBUSCOMMAND + std::string("SetVolume uint16:22 int16:12 > /tmp/result.txt ")).c_str()); + + //check the results + lineCounter = 0; + result = 0; + ifs.open("/tmp/result.txt"); + while (std::getline(ifs, line)) + { + if (lineCounter == 1) + { + std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result; + ASSERT_EQ(result, E_OK); + } + lineCounter++; + } + ifs.close(); + + std::cout << "[setVolume ]" << std::endl; + + EXPECT_CALL(pReceiveInterface,volumeStep(2,1)).WillOnce(Return(E_OK)); + system((DBUSCOMMAND + std::string("VolumeStep uint16:2 int16:1 > /tmp/result.txt ")).c_str()); + + //check the results + lineCounter = 0; + result = 0; + ifs.open("/tmp/result.txt"); + while (std::getline(ifs, line)) + { + if (lineCounter == 1) + { + std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result; + ASSERT_EQ(result, E_OK); + } + lineCounter++; + } + ifs.close(); + + std::cout << "[volumeStep]" << std::endl; + + EXPECT_CALL(pReceiveInterface,setSinkMuteState(1,MS_UNKNOWN)).WillOnce(Return(E_OK)); + system((DBUSCOMMAND + std::string("SetSinkMuteState uint16:1 int16:0 > /tmp/result.txt ")).c_str()); + + //check the results + lineCounter = 0; + result = 0; + ifs.open("/tmp/result.txt"); + while (std::getline(ifs, line)) + { + if (lineCounter == 1) + { + std::stringstream(line.replace(line.begin(), line.begin() + 9, "")) >> result; + ASSERT_EQ(result, E_OK); + } + lineCounter++; + } + ifs.close(); + + std::cout << "[sinkmutest]" << std::endl; + + EXPECT_CALL(pReceiveInterface,setMainSinkSoundProperty(AllOf(Field(&am_MainSoundProperty_s::value, 3), + Field(&am_MainSoundProperty_s::type,MSP_UNKNOWN)),1)).WillOnce(Return(E_ABORTED)); + + PyRun_SimpleStringFlags("import dbus\n" + "f = open('/tmp/result.txt','w')\n" + "bus = dbus.SessionBus()\n" + "retVal=dbus.Bus().call_blocking(\n" + "bus_name='org.genivi.audiomanager',\n" + "object_path='/org/genivi/audiomanager/CommandInterface',\n" + "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" + "method='SetMainSinkSoundProperty',\n" + "signature='q(nn)',\n" + "args=[1,(0,3)],) \n" + "f.write(str(retVal));\n" + "f.close()", NULL); + result = 0; + ifs.open("/tmp/result.txt"); + while (std::getline(ifs, line)) + { + std::stringstream(line) >> result; + }ASSERT_EQ(result, E_ABORTED); + ifs.close(); + + std::cout << "[sinksound ]" << std::endl; + + EXPECT_CALL(pReceiveInterface,setMainSourceSoundProperty(AllOf(Field(&am_MainSoundProperty_s::value, 3), + Field(&am_MainSoundProperty_s::type,MSP_UNKNOWN)),1)).WillOnce(Return(E_ABORTED)); + + PyRun_SimpleStringFlags("import dbus\n" + "f = open('/tmp/result.txt','w')\n" + "bus = dbus.SessionBus()\n" + "retVal=dbus.Bus().call_blocking(\n" + "bus_name='org.genivi.audiomanager',\n" + "object_path='/org/genivi/audiomanager/CommandInterface',\n" + "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" + "method='SetMainSourceSoundProperty',\n" + "signature='q(nn)',\n" + "args=[1,(0,3)],) \n" + "f.write(str(retVal));\n" + "f.close()", NULL); + result = 0; + ifs.open("/tmp/result.txt"); + while (std::getline(ifs, line)) + { + std::stringstream(line) >> result; + }ASSERT_EQ(result, E_ABORTED); + ifs.close(); + + std::cout << "[sourcesnd ]" << std::endl; + + EXPECT_CALL(pReceiveInterface,setSystemProperty(Field(&am_SystemProperty_s::value,2))).WillOnce(Return(E_DATABASE_ERROR)); + + PyRun_SimpleStringFlags("import dbus\n" + "f = open('/tmp/result.txt','w')\n" + "bus = dbus.SessionBus()\n" + "retVal=dbus.Bus().call_blocking(\n" + "bus_name='org.genivi.audiomanager',\n" + "object_path='/org/genivi/audiomanager/CommandInterface',\n" + "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" + "method='SetSystemProperty',\n" + "signature='(nn)',\n" + "args=[(2,2)],) \n" + "f.write(str(retVal));\n" + "f.close()", NULL); + + result = 0; + ifs.open("/tmp/result.txt"); + while (std::getline(ifs, line)) + { + std::stringstream(line) >> result; + }ASSERT_EQ(result, E_DATABASE_ERROR); + ifs.close(); + + std::cout << "[systemprop]" << std::endl; + + EXPECT_CALL(pReceiveInterface,getListMainConnections(_)).WillOnce(DoAll(returnListConnections(), Return(E_ABORTED))); + + PyRun_SimpleStringFlags("import dbus\n" + "f = open('/tmp/result.txt','w')\n" + "bus = dbus.SessionBus()\n" + "retVal=dbus.Bus().call_blocking(\n" + "bus_name='org.genivi.audiomanager',\n" + "object_path='/org/genivi/audiomanager/CommandInterface',\n" + "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" + "method='GetListMainConnections',\n" + "signature='',\n" + "args=[],) \n" + "f.write(str(retVal));\n" + "f.close()", NULL); + result = 0; + ifs.open("/tmp/result.txt"); + 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(15), dbus.UInt16(3), dbus.UInt16(4), dbus.Int16(34), dbus.Int16(0)), signature=None)], signature=dbus.Signature('(qqqnn)')))"), 0); + } + ifs.close(); + + std::cout << "[listmainc ]" << std::endl; + + EXPECT_CALL(pReceiveInterface,getListMainSinks(_)).WillOnce(DoAll(returnListSinks(), Return(E_ABORTED))); + + PyRun_SimpleStringFlags("import dbus\n" + "f = open('/tmp/result.txt','w')\n" + "bus = dbus.SessionBus()\n" + "retVal=dbus.Bus().call_blocking(\n" + "bus_name='org.genivi.audiomanager',\n" + "object_path='/org/genivi/audiomanager/CommandInterface',\n" + "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" + "method='GetListMainSinks',\n" + "signature='',\n" + "args=[],) \n" + "f.write(str(retVal));\n" + "f.close()", NULL); + result = 0; + ifs.open("/tmp/result.txt"); + 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(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(); + + std::cout << "[listsinks ]" << std::endl; + + EXPECT_CALL(pReceiveInterface,getListMainSources(_)).WillOnce(DoAll(returnListSources(), Return(E_ABORTED))); + + PyRun_SimpleStringFlags("import dbus\n" + "f = open('/tmp/result.txt','w')\n" + "bus = dbus.SessionBus()\n" + "retVal=dbus.Bus().call_blocking(\n" + "bus_name='org.genivi.audiomanager',\n" + "object_path='/org/genivi/audiomanager/CommandInterface',\n" + "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" + "method='GetListMainSources',\n" + "signature='',\n" + "args=[],) \n" + "f.write(str(retVal));\n" + "f.close()", NULL); + result = 0; + ifs.open("/tmp/result.txt"); + 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(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(); + + std::cout << "[listsource]" << std::endl; + + EXPECT_CALL(pReceiveInterface,getListMainSinkSoundProperties(1,_)).WillOnce(DoAll(returnListMainSinkSoundProperties(), Return(E_ABORTED))); + + PyRun_SimpleStringFlags("import dbus\n" + "f = open('/tmp/result.txt','w')\n" + "bus = dbus.SessionBus()\n" + "retVal=dbus.Bus().call_blocking(\n" + "bus_name='org.genivi.audiomanager',\n" + "object_path='/org/genivi/audiomanager/CommandInterface',\n" + "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" + "method='GetListMainSinkSoundProperties',\n" + "signature='q',\n" + "args=[1],) \n" + "f.write(str(retVal));\n" + "f.close()", NULL); + result = 0; + ifs.open("/tmp/result.txt"); + 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(4), dbus.Int16(223)), signature=None), dbus.Struct((dbus.Int16(0), dbus.Int16(2)), signature=None)], signature=dbus.Signature('(nn)')))"), 0); + } + ifs.close(); + + std::cout << "[lMainSiPro]" << std::endl; + + EXPECT_CALL(pReceiveInterface,getListMainSourceSoundProperties(1,_)).WillOnce(DoAll(returnListMainSinkSoundProperties(), Return(E_ABORTED))); + + PyRun_SimpleStringFlags("import dbus\n" + "f = open('/tmp/result.txt','w')\n" + "bus = dbus.SessionBus()\n" + "retVal=dbus.Bus().call_blocking(\n" + "bus_name='org.genivi.audiomanager',\n" + "object_path='/org/genivi/audiomanager/CommandInterface',\n" + "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" + "method='GetListMainSourceSoundProperties',\n" + "signature='q',\n" + "args=[1],) \n" + "f.write(str(retVal));\n" + "f.close()", NULL); + result = 0; + ifs.open("/tmp/result.txt"); + 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(4), dbus.Int16(223)), signature=None), dbus.Struct((dbus.Int16(0), dbus.Int16(2)), signature=None)], signature=dbus.Signature('(nn)')))"), 0); + } + ifs.close(); + + std::cout << "[lMainSoPro]" << std::endl; + + EXPECT_CALL(pReceiveInterface,getListSourceClasses(_)).WillOnce(DoAll(returnListSourceClasses(), Return(E_ABORTED))); + + PyRun_SimpleStringFlags("import dbus\n" + "f = open('/tmp/result.txt','w')\n" + "bus = dbus.SessionBus()\n" + "retVal=dbus.Bus().call_blocking(\n" + "bus_name='org.genivi.audiomanager',\n" + "object_path='/org/genivi/audiomanager/CommandInterface',\n" + "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" + "method='GetListSourceClasses',\n" + "signature='',\n" + "args=[],) \n" + "f.write(str(retVal));\n" + "f.close()", NULL); + result = 0; + ifs.open("/tmp/result.txt"); + 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(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(); + + std::cout << "[lSourceCla]" << std::endl; + + EXPECT_CALL(pReceiveInterface,getListSinkClasses(_)).WillOnce(DoAll(returnListSinkClasses(), Return(E_ABORTED))); + + PyRun_SimpleStringFlags("import dbus\n" + "f = open('/tmp/result.txt','w')\n" + "bus = dbus.SessionBus()\n" + "retVal=dbus.Bus().call_blocking(\n" + "bus_name='org.genivi.audiomanager',\n" + "object_path='/org/genivi/audiomanager/CommandInterface',\n" + "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" + "method='GetListSinkClasses',\n" + "signature='',\n" + "args=[],) \n" + "f.write(str(retVal));\n" + "f.close()", NULL); + result = 0; + ifs.open("/tmp/result.txt"); + 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(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(); + + std::cout << "[lSinkClass]" << std::endl; + + EXPECT_CALL(pReceiveInterface,getListSystemProperties(_)).WillOnce(DoAll(returnListSystemProperties(), Return(E_ABORTED))); + + PyRun_SimpleStringFlags("import dbus\n" + "f = open('/tmp/result.txt','w')\n" + "bus = dbus.SessionBus()\n" + "retVal=dbus.Bus().call_blocking(\n" + "bus_name='org.genivi.audiomanager',\n" + "object_path='/org/genivi/audiomanager/CommandInterface',\n" + "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" + "method='GetListSystemProperties',\n" + "signature='',\n" + "args=[],) \n" + "f.write(str(retVal));\n" + "f.close()", NULL); + result = 0; + ifs.open("/tmp/result.txt"); + 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(0), dbus.Int16(-2245)), signature=None)], signature=dbus.Signature('(nn)')))"), 0); + } + ifs.close(); + + std::cout << "[lSysProp ]" << std::endl; + + EXPECT_CALL(pReceiveInterface,getTimingInformation(2,_)).WillOnce(DoAll(returnTimingInfo(), Return(E_ABORTED))); + + PyRun_SimpleStringFlags("import dbus\n" + "f = open('/tmp/result.txt','w')\n" + "bus = dbus.SessionBus()\n" + "retVal=dbus.Bus().call_blocking(\n" + "bus_name='org.genivi.audiomanager',\n" + "object_path='/org/genivi/audiomanager/CommandInterface',\n" + "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" + "method='GetTimingInformation',\n" + "signature='q',\n" + "args=[2],) \n" + "f.write(str(retVal));\n" + "f.close()", NULL); + result = 0; + ifs.open("/tmp/result.txt"); + while (std::getline(ifs, line)) + { + //we could parse here, but this is the fastest way.... + ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Int16(23))"), 0); + } + ifs.close(); + + std::cout << "[timingInfo]" << std::endl; + Py_Finalize(); +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + diff --git a/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.h b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.h new file mode 100644 index 0000000..a89affd --- /dev/null +++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.h @@ -0,0 +1,61 @@ +/** +* Copyright (C) 2011, BMW AG +* +* GeniviAudioMananger AudioManagerDaemon +* +* \file dbuscommandpluginInterfaceTest.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 . +* 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 DBUSCOMMANDPLUGININTERFACETEST_H_ +#define DBUSCOMMANDPLUGININTERFACETEST_H_ + +#include +#include + +#define UNIT_TEST 1 + +namespace am { + +class CAmCommandSenderDbusBackdoor; +class IAmCommandSend; + +/* + * originally, I would want to have several tests, but there are problems implementing this with + * Dbus. + * I use python to send put the messages and to check the returns I get from the Plugin. + * + */ + + +class CAmCommandSenderDbusTest :public ::testing::Test +{ +public: + IAmCommandSend *ppCommandSend; + CAmCommandSenderDbusTest(); + ~CAmCommandSenderDbusTest(); + + void SetUp(); + void TearDown(); +}; + +} + +#endif /* DBUSCOMMANDPLUGININTERFACETEST_H_ */ 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/DbusCommandInterfaceBackdoor.cpp b/PluginCommandInterfaceDbus/test/DbusCommandInterfaceBackdoor.cpp deleted file mode 100644 index a61f693..0000000 --- a/PluginCommandInterfaceDbus/test/DbusCommandInterfaceBackdoor.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/** -* Copyright (C) 2011, BMW AG -* -* GeniviAudioMananger AudioManagerDaemon -* -* \file DbusCommandInterfaceBackdoor.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 . -* 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 "DbusCommandInterfaceBackdoor.h" - - -using namespace am; - -DbusCommandInterfaceBackdoor::DbusCommandInterfaceBackdoor() -{ -} - -DbusCommandInterfaceBackdoor::~DbusCommandInterfaceBackdoor() -{ -} - -void DbusCommandInterfaceBackdoor::setReceiveInterface(DbusCommandSender *sender, CommandReceiveInterface* interface) -{ - sender->mCommandReceiveInterface=interface; -} - -void DbusCommandInterfaceBackdoor::setDbusConnection(DbusCommandSender *sender, DBusConnection *conn) -{ - sender->mDBUSMessageHandler.setDBusConnection(conn); -} - -void DbusCommandInterfaceBackdoor::setListSinks(DbusCommandSender *sender, std::vector newList) -{ - sender->mlistSinks=newList; -} - -void DbusCommandInterfaceBackdoor::setListSources(DbusCommandSender *sender, std::vector newList) -{ - sender->mlistSources=newList; -} - - - - - - - - - - - - - diff --git a/PluginCommandInterfaceDbus/test/DbusCommandInterfaceBackdoor.h b/PluginCommandInterfaceDbus/test/DbusCommandInterfaceBackdoor.h deleted file mode 100644 index 1549e65..0000000 --- a/PluginCommandInterfaceDbus/test/DbusCommandInterfaceBackdoor.h +++ /dev/null @@ -1,51 +0,0 @@ -/** -* Copyright (C) 2011, BMW AG -* -* GeniviAudioMananger AudioManagerDaemon -* -* \file DubsCommandInterfaceBackdoor.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 . -* 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 DBUSCOMMANDINTERFACEBACKDOOR_H_ -#define DBUSCOMMANDINTERFACEBACKDOOR_H_ - -#include -#include "../include/DBusCommandSender.h" -#include "../include/DBusMessageHandler.h" -#include "../include/CommandReceiverShadow.h" - -namespace am { - -class DbusCommandSender; - -class DbusCommandInterfaceBackdoor -{ -public: - DbusCommandInterfaceBackdoor(); - virtual ~DbusCommandInterfaceBackdoor(); - void setReceiveInterface(DbusCommandSender *sender, CommandReceiveInterface* interface); - void setDbusConnection(DbusCommandSender *sender,DBusConnection *conn); - void setListSinks(DbusCommandSender *sender, std::vector newList); - void setListSources(DbusCommandSender *sender, std::vector newList); -}; - -} - -#endif /* DBUSCOMMANDINTERFACEBACKDOOR_H_ */ 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 +#include + +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& listConnections)); + MOCK_CONST_METHOD1(getListMainSinks, + am_Error_e(std::vector& listMainSinks)); + MOCK_CONST_METHOD1(getListMainSources, + am_Error_e(std::vector& listMainSources)); + MOCK_CONST_METHOD2(getListMainSinkSoundProperties, + am_Error_e(const am_sinkID_t sinkID, std::vector& listSoundProperties)); + MOCK_CONST_METHOD2(getListMainSourceSoundProperties, + am_Error_e(const am_sourceID_t sourceID, std::vector& listSourceProperties)); + MOCK_CONST_METHOD1(getListSourceClasses, + am_Error_e(std::vector& listSourceClasses)); + MOCK_CONST_METHOD1(getListSinkClasses, + am_Error_e(std::vector& listSinkClasses)); + MOCK_CONST_METHOD1(getListSystemProperties, + am_Error_e(std::vector& 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 . -* 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& listConnections)); - MOCK_CONST_METHOD1(getListMainSinks, - am_Error_e(std::vector& listMainSinks)); - MOCK_CONST_METHOD1(getListMainSources, - am_Error_e(std::vector& listMainSources)); - MOCK_CONST_METHOD2(getListMainSinkSoundProperties, - am_Error_e(const am_sinkID_t sinkID, std::vector& listSoundProperties)); - MOCK_CONST_METHOD2(getListMainSourceSoundProperties, - am_Error_e(const am_sourceID_t sourceID, std::vector& listSourceProperties)); - MOCK_CONST_METHOD1(getListSourceClasses, - am_Error_e(std::vector& listSourceClasses)); - MOCK_CONST_METHOD1(getListSinkClasses, - am_Error_e(std::vector& listSinkClasses)); - MOCK_CONST_METHOD1(getListSystemProperties, - am_Error_e(std::vector& 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_ */ diff --git a/PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.cpp b/PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.cpp deleted file mode 100644 index f4dab30..0000000 --- a/PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.cpp +++ /dev/null @@ -1,608 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger AudioManagerDaemon - * - * \file dbuscommandpluginInterfaceTest.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 . - * 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 -#include -#include "dbuscommandpluginInterfaceTest.h" -#include -#include -#include "../include/DBusCommandSender.h" -#include "../include/DBusMessageHandler.h" -#include "DbusCommandInterfaceBackdoor.h" -#include "MockInterfaces.h" -#include "DLTWrapper.h" -#include "SocketHandler.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; - wrap->start_listenting(); - return (NULL); -} - -dbuscommandpluginInterfaceTest::dbuscommandpluginInterfaceTest() : - pDatabaseHandler(std::string(":memory:")), // - pControlSender("") // -{ - DLTWrapper::instance()->registerApp("dbusTest", "dbusTest"); -} - -dbuscommandpluginInterfaceTest::~dbuscommandpluginInterfaceTest() -{ - -} - -void dbuscommandpluginInterfaceTest::SetUp() -{ - -} - -void dbuscommandpluginInterfaceTest::TearDown() -{ - -} - -ACTION(returnListConnections){ -std::vector list; -am::am_MainConnectionType_s listItem; -listItem.mainConnectionID=15; -listItem.sinkID=4; -listItem.sourceID=3; -listItem.connectionState=CS_UNKNOWN; -listItem.delay=34; -list.push_back(listItem); -arg0=list; -} - -ACTION(returnListSinks){ -std::vector list; -am::am_SinkType_s listItem; -listItem.availability.availability=A_UNAVAILABLE; -listItem.availability.availabilityReason=AR_GENIVI_NOMEDIA; -listItem.muteState=MS_UNMUTED; -listItem.name="mySink"; -listItem.sinkClassID=34; -listItem.sinkID=24; -listItem.volume=124; -list.push_back(listItem); -arg0=list; -} - -ACTION(returnListSources){ -std::vector list; -am::am_SourceType_s listItem; -listItem.availability.availability=A_MAX; -listItem.availability.availabilityReason=AR_GENIVI_SAMEMEDIA; -listItem.name="MySource"; -listItem.sourceClassID=12; -listItem.sourceID=224; -list.push_back(listItem); -listItem.name="NextSource"; -listItem.sourceID=22; -list.push_back(listItem); -arg0=list; -} - -ACTION(returnListMainSinkSoundProperties){ -std::vector list; -am::am_MainSoundProperty_s listItem; -listItem.type=MSP_MAX; -listItem.value=223; -list.push_back(listItem); -listItem.type=MSP_UNKNOWN; -listItem.value=2; -list.push_back(listItem); -arg1=list; -} - -ACTION(returnListSourceClasses){ -std::vector list; -am::am_SourceClass_s listItem; -am::am_ClassProperty_s property; -property.classProperty=CP_GENIVI_SINK_TYPE; -property.value=12; -listItem.name="FirstCLass"; -listItem.sourceClassID=23; -listItem.listClassProperties.push_back(property); -list.push_back(listItem); -listItem.name="SecondCLass"; -listItem.sourceClassID=2; -listItem.listClassProperties.push_back(property); -list.push_back(listItem); -arg0=list; -} - -ACTION(returnListSinkClasses){ -std::vector list; -am::am_SinkClass_s listItem; -am::am_ClassProperty_s property; -property.classProperty=CP_GENIVI_SOURCE_TYPE; -property.value=122; -listItem.name="FirstCLass"; -listItem.sinkClassID=2123; -listItem.listClassProperties.push_back(property); -list.push_back(listItem); -listItem.name="SecondCLass"; -listItem.sinkClassID=23; -listItem.listClassProperties.push_back(property); -list.push_back(listItem); -arg0=list; -} - -ACTION(returnListSystemProperties){ -std::vector list; -am::am_SystemProperty_s listItem; -listItem.type=SYP_UNKNOWN; -listItem.value=-2245; -list.push_back(listItem); -arg0=list; -} - -ACTION(returnTimingInfo){ -am::am_timeSync_t time=23; -arg1=time; -} - -TEST_F(dbuscommandpluginInterfaceTest,Connect) -{ - Py_Initialize(); - //unfortunatly we need to put all in one testcase because testing with the dbus loop caused problems... - SocketHandler pSocketHandler; - DBusWrapper pDBusWrapper(&pSocketHandler); - pthread_t ptestThread; - std::vector plistCommandPluginDirs; - plistCommandPluginDirs.push_back(std::string(DEFAULT_PLUGIN_COMMAND_DIR)); - - CommandSender pCommandSender(plistCommandPluginDirs); - MockCommandReceiveInterface 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); - -// 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,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()); - - //check the results - std::ifstream ifs("/tmp/result.txt"); - std::string line; - int lineCounter = 0, result = 0; - while (std::getline(ifs, line)) - { - if (lineCounter == 1) - { - std::stringstream(line.substr(line.find_first_not_of(" int16 "))) >> result; - ASSERT_EQ(result, E_OK); - } - else if (lineCounter == 2) - { - std::stringstream(line.substr(line.find_first_not_of(" uint16 "))) >> result; - ASSERT_EQ(result, 35); - } - lineCounter++; - } - ifs.close(); - - std::cout << "[connect ]" << std::endl; - - EXPECT_CALL(pReceiveInterface,disconnect(2)).WillOnce(Return(E_OK)); - system((DBUSCOMMAND + std::string("Disconnect uint16:2 > /tmp/result.txt ")).c_str()); - - //check the results - lineCounter = 0; - result = 0; - ifs.open("/tmp/result.txt"); - while (std::getline(ifs, line)) - { - if (lineCounter == 1) - { - std::stringstream(line.substr(line.find_first_not_of(" int16 "))) >> result; - ASSERT_EQ(result, E_OK); - } - lineCounter++; - } - ifs.close(); - - std::cout << "[disconnect]" << std::endl; - - EXPECT_CALL(pReceiveInterface,setVolume(22,12)).WillOnce(Return(E_OK)); - system((DBUSCOMMAND + std::string("SetVolume uint16:22 int16:12 > /tmp/result.txt ")).c_str()); - - //check the results - lineCounter = 0; - result = 0; - ifs.open("/tmp/result.txt"); - while (std::getline(ifs, line)) - { - if (lineCounter == 1) - { - std::stringstream(line.substr(line.find_first_not_of(" int16 "))) >> result; - ASSERT_EQ(result, E_OK); - } - lineCounter++; - } - ifs.close(); - - std::cout << "[setVolume ]" << std::endl; - - EXPECT_CALL(pReceiveInterface,volumeStep(2,1)).WillOnce(Return(E_OK)); - system((DBUSCOMMAND + std::string("VolumeStep uint16:2 int16:1 > /tmp/result.txt ")).c_str()); - - //check the results - lineCounter = 0; - result = 0; - ifs.open("/tmp/result.txt"); - while (std::getline(ifs, line)) - { - if (lineCounter == 1) - { - std::stringstream(line.substr(line.find_first_not_of(" int16 "))) >> result; - ASSERT_EQ(result, E_OK); - } - lineCounter++; - } - ifs.close(); - - std::cout << "[volumeStep]" << std::endl; - - EXPECT_CALL(pReceiveInterface,setSinkMuteState(1,MS_UNKNOWN)).WillOnce(Return(E_OK)); - system((DBUSCOMMAND + std::string("SetSinkMuteState uint16:1 int16:0 > /tmp/result.txt ")).c_str()); - - //check the results - lineCounter = 0; - result = 0; - ifs.open("/tmp/result.txt"); - while (std::getline(ifs, line)) - { - if (lineCounter == 1) - { - std::stringstream(line.substr(line.find_first_not_of(" int16 "))) >> result; - ASSERT_EQ(result, E_OK); - } - lineCounter++; - } - ifs.close(); - - std::cout << "[sinkmutest]" << std::endl; - - EXPECT_CALL(pReceiveInterface,setMainSinkSoundProperty(AllOf(Field(&am_MainSoundProperty_s::value, 3), - Field(&am_MainSoundProperty_s::type,MSP_UNKNOWN)),1)).WillOnce(Return(E_ABORTED)); - - PyRun_SimpleStringFlags("import dbus\n" - "f = open('/tmp/result.txt','w')\n" - "bus = dbus.SessionBus()\n" - "retVal=dbus.Bus().call_blocking(\n" - "bus_name='org.genivi.audiomanager',\n" - "object_path='/org/genivi/audiomanager/CommandInterface',\n" - "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" - "method='SetMainSinkSoundProperty',\n" - "signature='q(nn)',\n" - "args=[1,(0,3)],) \n" - "f.write(str(retVal));\n" - "f.close()", NULL); - result = 0; - ifs.open("/tmp/result.txt"); - while (std::getline(ifs, line)) - { - std::stringstream(line) >> result; - }ASSERT_EQ(result, E_ABORTED); - ifs.close(); - - std::cout << "[sinksound ]" << std::endl; - - EXPECT_CALL(pReceiveInterface,setMainSourceSoundProperty(AllOf(Field(&am_MainSoundProperty_s::value, 3), - Field(&am_MainSoundProperty_s::type,MSP_UNKNOWN)),1)).WillOnce(Return(E_ABORTED)); - - PyRun_SimpleStringFlags("import dbus\n" - "f = open('/tmp/result.txt','w')\n" - "bus = dbus.SessionBus()\n" - "retVal=dbus.Bus().call_blocking(\n" - "bus_name='org.genivi.audiomanager',\n" - "object_path='/org/genivi/audiomanager/CommandInterface',\n" - "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" - "method='SetMainSourceSoundProperty',\n" - "signature='q(nn)',\n" - "args=[1,(0,3)],) \n" - "f.write(str(retVal));\n" - "f.close()", NULL); - result = 0; - ifs.open("/tmp/result.txt"); - while (std::getline(ifs, line)) - { - std::stringstream(line) >> result; - }ASSERT_EQ(result, E_ABORTED); - ifs.close(); - - std::cout << "[sourcesnd ]" << std::endl; - - EXPECT_CALL(pReceiveInterface,setSystemProperty(Field(&am_SystemProperty_s::value,2))).WillOnce(Return(E_DATABASE_ERROR)); - - PyRun_SimpleStringFlags("import dbus\n" - "f = open('/tmp/result.txt','w')\n" - "bus = dbus.SessionBus()\n" - "retVal=dbus.Bus().call_blocking(\n" - "bus_name='org.genivi.audiomanager',\n" - "object_path='/org/genivi/audiomanager/CommandInterface',\n" - "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" - "method='SetSystemProperty',\n" - "signature='(nn)',\n" - "args=[(2,2)],) \n" - "f.write(str(retVal));\n" - "f.close()", NULL); - - result = 0; - ifs.open("/tmp/result.txt"); - while (std::getline(ifs, line)) - { - std::stringstream(line) >> result; - }ASSERT_EQ(result, E_DATABASE_ERROR); - ifs.close(); - - std::cout << "[systemprop]" << std::endl; - - EXPECT_CALL(pReceiveInterface,getListMainConnections(_)).WillOnce(DoAll(returnListConnections(), Return(E_ABORTED))); - - PyRun_SimpleStringFlags("import dbus\n" - "f = open('/tmp/result.txt','w')\n" - "bus = dbus.SessionBus()\n" - "retVal=dbus.Bus().call_blocking(\n" - "bus_name='org.genivi.audiomanager',\n" - "object_path='/org/genivi/audiomanager/CommandInterface',\n" - "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" - "method='GetListMainConnections',\n" - "signature='',\n" - "args=[],) \n" - "f.write(str(retVal));\n" - "f.close()", NULL); - result = 0; - ifs.open("/tmp/result.txt"); - 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(15), dbus.UInt16(3), dbus.UInt16(4), dbus.Int16(34), dbus.Int16(0)), signature=None)], signature=dbus.Signature('(qqqnn)')))"), 0); - } - ifs.close(); - - std::cout << "[listmainc ]" << std::endl; - - EXPECT_CALL(pReceiveInterface,getListMainSinks(_)).WillOnce(DoAll(returnListSinks(), Return(E_ABORTED))); - - PyRun_SimpleStringFlags("import dbus\n" - "f = open('/tmp/result.txt','w')\n" - "bus = dbus.SessionBus()\n" - "retVal=dbus.Bus().call_blocking(\n" - "bus_name='org.genivi.audiomanager',\n" - "object_path='/org/genivi/audiomanager/CommandInterface',\n" - "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" - "method='GetListMainSinks',\n" - "signature='',\n" - "args=[],) \n" - "f.write(str(retVal));\n" - "f.close()", NULL); - result = 0; - ifs.open("/tmp/result.txt"); - 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); - } - ifs.close(); - - std::cout << "[listsinks ]" << std::endl; - - EXPECT_CALL(pReceiveInterface,getListMainSources(_)).WillOnce(DoAll(returnListSources(), Return(E_ABORTED))); - - PyRun_SimpleStringFlags("import dbus\n" - "f = open('/tmp/result.txt','w')\n" - "bus = dbus.SessionBus()\n" - "retVal=dbus.Bus().call_blocking(\n" - "bus_name='org.genivi.audiomanager',\n" - "object_path='/org/genivi/audiomanager/CommandInterface',\n" - "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" - "method='GetListMainSources',\n" - "signature='',\n" - "args=[],) \n" - "f.write(str(retVal));\n" - "f.close()", NULL); - result = 0; - ifs.open("/tmp/result.txt"); - 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); - } - ifs.close(); - - std::cout << "[listsource]" << std::endl; - - EXPECT_CALL(pReceiveInterface,getListMainSinkSoundProperties(1,_)).WillOnce(DoAll(returnListMainSinkSoundProperties(), Return(E_ABORTED))); - - PyRun_SimpleStringFlags("import dbus\n" - "f = open('/tmp/result.txt','w')\n" - "bus = dbus.SessionBus()\n" - "retVal=dbus.Bus().call_blocking(\n" - "bus_name='org.genivi.audiomanager',\n" - "object_path='/org/genivi/audiomanager/CommandInterface',\n" - "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" - "method='GetListMainSinkSoundProperties',\n" - "signature='q',\n" - "args=[1],) \n" - "f.write(str(retVal));\n" - "f.close()", NULL); - result = 0; - ifs.open("/tmp/result.txt"); - 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); - } - ifs.close(); - - std::cout << "[lMainSiPro]" << std::endl; - - EXPECT_CALL(pReceiveInterface,getListMainSourceSoundProperties(1,_)).WillOnce(DoAll(returnListMainSinkSoundProperties(), Return(E_ABORTED))); - - PyRun_SimpleStringFlags("import dbus\n" - "f = open('/tmp/result.txt','w')\n" - "bus = dbus.SessionBus()\n" - "retVal=dbus.Bus().call_blocking(\n" - "bus_name='org.genivi.audiomanager',\n" - "object_path='/org/genivi/audiomanager/CommandInterface',\n" - "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" - "method='GetListMainSourceSoundProperties',\n" - "signature='q',\n" - "args=[1],) \n" - "f.write(str(retVal));\n" - "f.close()", NULL); - result = 0; - ifs.open("/tmp/result.txt"); - 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); - } - ifs.close(); - - std::cout << "[lMainSoPro]" << std::endl; - - EXPECT_CALL(pReceiveInterface,getListSourceClasses(_)).WillOnce(DoAll(returnListSourceClasses(), Return(E_ABORTED))); - - PyRun_SimpleStringFlags("import dbus\n" - "f = open('/tmp/result.txt','w')\n" - "bus = dbus.SessionBus()\n" - "retVal=dbus.Bus().call_blocking(\n" - "bus_name='org.genivi.audiomanager',\n" - "object_path='/org/genivi/audiomanager/CommandInterface',\n" - "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" - "method='GetListSourceClasses',\n" - "signature='',\n" - "args=[],) \n" - "f.write(str(retVal));\n" - "f.close()", NULL); - result = 0; - ifs.open("/tmp/result.txt"); - 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); - } - ifs.close(); - - std::cout << "[lSourceCla]" << std::endl; - - EXPECT_CALL(pReceiveInterface,getListSinkClasses(_)).WillOnce(DoAll(returnListSinkClasses(), Return(E_ABORTED))); - - PyRun_SimpleStringFlags("import dbus\n" - "f = open('/tmp/result.txt','w')\n" - "bus = dbus.SessionBus()\n" - "retVal=dbus.Bus().call_blocking(\n" - "bus_name='org.genivi.audiomanager',\n" - "object_path='/org/genivi/audiomanager/CommandInterface',\n" - "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" - "method='GetListSinkClasses',\n" - "signature='',\n" - "args=[],) \n" - "f.write(str(retVal));\n" - "f.close()", NULL); - result = 0; - ifs.open("/tmp/result.txt"); - 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); - } - ifs.close(); - - std::cout << "[lSinkClass]" << std::endl; - - EXPECT_CALL(pReceiveInterface,getListSystemProperties(_)).WillOnce(DoAll(returnListSystemProperties(), Return(E_ABORTED))); - - PyRun_SimpleStringFlags("import dbus\n" - "f = open('/tmp/result.txt','w')\n" - "bus = dbus.SessionBus()\n" - "retVal=dbus.Bus().call_blocking(\n" - "bus_name='org.genivi.audiomanager',\n" - "object_path='/org/genivi/audiomanager/CommandInterface',\n" - "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" - "method='GetListSystemProperties',\n" - "signature='',\n" - "args=[],) \n" - "f.write(str(retVal));\n" - "f.close()", NULL); - result = 0; - ifs.open("/tmp/result.txt"); - 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(0), dbus.Int16(-2245)), signature=None)], signature=dbus.Signature('(nn)')))"), 0); - } - ifs.close(); - - std::cout << "[lSysProp ]" << std::endl; - - EXPECT_CALL(pReceiveInterface,getTimingInformation(2,_)).WillOnce(DoAll(returnTimingInfo(), Return(E_ABORTED))); - - PyRun_SimpleStringFlags("import dbus\n" - "f = open('/tmp/result.txt','w')\n" - "bus = dbus.SessionBus()\n" - "retVal=dbus.Bus().call_blocking(\n" - "bus_name='org.genivi.audiomanager',\n" - "object_path='/org/genivi/audiomanager/CommandInterface',\n" - "dbus_interface='org.genivi.audiomanager.CommandInterface',\n" - "method='GetTimingInformation',\n" - "signature='q',\n" - "args=[2],) \n" - "f.write(str(retVal));\n" - "f.close()", NULL); - result = 0; - ifs.open("/tmp/result.txt"); - while (std::getline(ifs, line)) - { - //we could parse here, but this is the fastest way.... - ASSERT_EQ(line.compare("(dbus.Int16(9), dbus.Int16(23))"), 0); - } - ifs.close(); - - std::cout << "[timingInfo]" << std::endl; - Py_Finalize(); -} - -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} - diff --git a/PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.h b/PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.h deleted file mode 100644 index d45a107..0000000 --- a/PluginCommandInterfaceDbus/test/dbuscommandpluginInterfaceTest.h +++ /dev/null @@ -1,72 +0,0 @@ -/** -* Copyright (C) 2011, BMW AG -* -* GeniviAudioMananger AudioManagerDaemon -* -* \file dbuscommandpluginInterfaceTest.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 . -* 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 DBUSCOMMANDPLUGININTERFACETEST_H_ -#define DBUSCOMMANDPLUGININTERFACETEST_H_ - -#include -#include -#include -#include -#include -#include -#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; - -/* - * originally, I would want to have several tests, but there are problems implementing this with - * Dbus. - * I use python to send put the messages and to check the returns I get from the Plugin. - * - */ - - -class dbuscommandpluginInterfaceTest :public ::testing::Test -{ -public: - DatabaseHandler pDatabaseHandler; - ControlSender pControlSender; - dbuscommandpluginInterfaceTest(); - ~dbuscommandpluginInterfaceTest(); - - void SetUp(); - void TearDown(); -}; - -} - -#endif /* DBUSCOMMANDPLUGININTERFACETEST_H_ */ diff --git a/PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.cpp b/PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.cpp deleted file mode 100644 index 655a1f3..0000000 --- a/PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.cpp +++ /dev/null @@ -1,906 +0,0 @@ -/** - * Copyright (C) 2011, BMW AG - * - * GeniviAudioMananger AudioManagerDaemon - * - * \file dbuscommandinterfacesignalsTest.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 . - * 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 "dbuscommaninterfacesignalsTest.h" -#include -#include -#include -#include "../include/DBusCommandSender.h" -#include "../include/DBusMessageHandler.h" -#include "DbusCommandInterfaceBackdoor.h" -#include "MockInterfaces.h" -#include "DLTWrapper.h" - -using namespace am; -using namespace testing; - - -dbuscommaninterfacesignalsTest::dbuscommaninterfacesignalsTest() -{ - DLTWrapper::instance()->registerApp("dbusTest","dbusTest"); - logInfo("dbusCommandInterfaceSignalTest started"); -} - -dbuscommaninterfacesignalsTest::~dbuscommaninterfacesignalsTest() -{ -} - -void* NumberOfMainConnectionsChanged(void*) -{ - 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(); - return (NULL); -} - -void* cbSinkAdded(void*) -{ - sleep(1); - std::vector list; - 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; - 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); - return (NULL); -} - -void* cbSourceAdded(void*) -{ - sleep(1); - std::vector 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(); - return (NULL); -} - -void* cbSourceRemoved(void*) -{ - sleep(1); - std::vector 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(); - return (NULL); -} - -void* cbSinkRemoved(void*) -{ - sleep(1); - std::vector list; - 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(); - return (NULL); -} - -void* NumberOfSinkClassesChanged(void*) -{ - 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(); - return (NULL); -} - -void* NumberOfSourceClassesChanged(void*) -{ - 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(); - return (NULL); -} - -void* MainConnectionStateChanged(void*) -{ - 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); - am_connectionID_t id = 4; - am_ConnectionState_e state = CS_CONNECTING; - sender.cbMainConnectionStateChanged(id, state); - return (NULL); -} - -void* MainSinkSoundPropertyChanged(void*) -{ - 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); - am_sinkID_t sinkID = 3; - am_MainSoundProperty_s soundProperty; - soundProperty.type = MSP_UNKNOWN; - soundProperty.value = 23; - sender.cbMainSinkSoundPropertyChanged(sinkID, soundProperty); - return (NULL); -} - -void* MainSourceSoundPropertyChanged(void*) -{ - 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); - am_sourceID_t sourceID = 35; - am_MainSoundProperty_s soundProperty; - soundProperty.type = MSP_UNKNOWN; - soundProperty.value = 233; - sender.cbMainSourceSoundPropertyChanged(sourceID, soundProperty); - return (NULL); -} - -void* cbSinkAvailabilityChangedLoop(void*) -{ - 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); - am_Availability_s av; - av.availability = A_AVAILABLE; - av.availabilityReason = AR_UNKNOWN; - sender.cbSinkAvailabilityChanged(4, av); - return (NULL); -} - -void* VolumeChanged(void*) -{ - 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); - am_volume_t volume = 344; - sender.cbVolumeChanged(23, volume); - return (NULL); -} - -void* cbSourceAvailabilityChangedLoop(void*) -{ - 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); - am_Availability_s av; - av.availability = A_AVAILABLE; - av.availabilityReason = AR_UNKNOWN; - sender.cbSourceAvailabilityChanged(2, av); - return (NULL); -} - -void* SinkMuteStateChanged(void*) -{ - 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); - return (NULL); -} - -void* SystemPropertyChanged(void*) -{ - 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); - am_SystemProperty_s property; - property.type = SYP_UNKNOWN; - property.value = 355; - sender.cbSystemPropertyChanged(property); - return (NULL); -} - -void* TimingInformationChanged(void*) -{ - 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); - return (NULL); -} - -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_t pythonloop; - pthread_create(&pythonloop, NULL, NumberOfMainConnectionsChanged, (void*) NULL); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchsignal(*arg, **kwarg):\n" - " print ('Caught NumberOfMainConnectionsChanged') \n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchsignal, signal_name='NumberOfMainConnectionsChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - pthread_create(&pythonloop, NULL, cbSinkAdded, (void*) NULL); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchSinkAdded(*arg, **karg):\n" - " print ('Caught signal (in SinkAdded handler) ') \n" - " print (arg[0])\n" - " f = open('/tmp/result.txt','w')\n" - " f.write(str(arg[0]));\n" - " f.close()\n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSinkAdded, signal_name='SinkAdded', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - std::ifstream ifs("/tmp/result.txt"); - std::string line; - int lineCounter = 0, result = 0; - while (std::getline(ifs, line)) - { - ASSERT_EQ(line.compare("dbus.Struct((dbus.UInt16(23), dbus.String(u'MySink'), dbus.Struct((dbus.Int16(3), dbus.Int16(0)), signature=None), dbus.Int16(234), dbus.Int16(0), dbus.UInt16(3)), signature=None)"), 0); - } - ifs.close(); - - pthread_create(&pythonloop, NULL, cbSinkRemoved, (void*) NULL); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchSinkRemoved(*arg, **karg):\n" - " print ('Caught signal (in SinkRemoved handler) ') \n" - " print (arg[0])\n" - " f = open('/tmp/result.txt','w')\n" - " f.write(str(arg[0]));\n" - " f.close()\n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSinkRemoved, signal_name='SinkRemoved', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - ifs.open("/tmp/result.txt"); - lineCounter = 0; - result = 0; - while (std::getline(ifs, line)) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, 23); - } - ifs.close(); - - pthread_create(&pythonloop, NULL, cbSourceAdded, (void*) NULL); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchSourceAdded(*arg, **karg):\n" - " print ('Caught signal (in SourceAdded handler) ') \n" - " print (arg[0])\n" - " f = open('/tmp/result.txt','w')\n" - " f.write(str(arg[0]));\n" - " f.close()\n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSourceAdded, signal_name='SourceAdded', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - ifs.open("/tmp/result.txt"); - lineCounter = 0; - result = 0; - while (std::getline(ifs, line)) - { - ASSERT_EQ(line.compare("dbus.Struct((dbus.UInt16(42), dbus.String(u'MySink'), dbus.Struct((dbus.Int16(3), dbus.Int16(0)), signature=None), dbus.UInt16(15)), signature=None)"), 0); - } - ifs.close(); - - pthread_create(&pythonloop, NULL, cbSourceRemoved, (void*) NULL); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchSourceRemoved(*arg, **karg):\n" - " print ('Caught signal (in SinkRemoved handler) ') \n" - " print (arg[0])\n" - " f = open('/tmp/result.txt','w')\n" - " f.write(str(arg[0]));\n" - " f.close()\n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSourceRemoved, signal_name='SourceRemoved', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - ifs.open("/tmp/result.txt"); - lineCounter = 0; - result = 0; - while (std::getline(ifs, line)) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, 42); - } - ifs.close(); - - pthread_create(&pythonloop, NULL, NumberOfSinkClassesChanged, (void*) NULL); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchNumberOfSinkClassesChanged(*arg, **kwarg):\n" - " print ('Caught catchNumberOfSinkClassesChanged') \n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchNumberOfSinkClassesChanged, signal_name='NumberOfSinkClassesChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - pthread_create(&pythonloop, NULL, NumberOfSourceClassesChanged, (void*) NULL); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def CatchNumberOfSourceClassesChanged(*arg, **kwarg):\n" - " print ('Caught CatchNumberOfSourceClassesChanged') \n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(CatchNumberOfSourceClassesChanged, signal_name='NumberOfSourceClassesChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - //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); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchMainConnectionStateChanged(*arg, **karg):\n" - " print ('Caught signal (in catchMainConnectionStateChanged handler) ') \n" - " print (arg[0])\n" - " print (arg[1])\n" - " f = open('/tmp/result.txt','w')\n" - " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" - " f.close()\n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchMainConnectionStateChanged, signal_name='MainConnectionStateChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - ifs.open("/tmp/result.txt"); - lineCounter = 0; - result = 0; - while (std::getline(ifs, line)) - { - if (lineCounter == 0) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, 4); - } - else if (lineCounter == 1) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, CS_CONNECTING); - } - lineCounter++; - } - ifs.close(); - - //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); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchMainSinkSoundPropertyChanged(*arg, **karg):\n" - " print ('Caught signal (in catchMainSinkSoundPropertyChanged handler) ') \n" - " print (arg[0])\n" - " print (arg[1])\n" - " f = open('/tmp/result.txt','w')\n" - " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" - " f.close()\n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchMainSinkSoundPropertyChanged, signal_name='MainSinkSoundPropertyChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - ifs.open("/tmp/result.txt"); - lineCounter = 0; - result = 0; - while (std::getline(ifs, line)) - { - if (lineCounter == 0) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, 3); - } - else if (lineCounter == 1) - { - ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(1), dbus.Int16(23)), signature=None)"), 0); - } - lineCounter++; - } - ifs.close(); - - //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); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchMainSourceSoundPropertyChanged(*arg, **karg):\n" - " print ('Caught signal (in catchMainSourceSoundPropertyChanged handler) ') \n" - " print (arg[0])\n" - " print (arg[1])\n" - " f = open('/tmp/result.txt','w')\n" - " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" - " f.close()\n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchMainSourceSoundPropertyChanged, signal_name='MainSourceSoundPropertyChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - ifs.open("/tmp/result.txt"); - lineCounter = 0; - result = 0; - while (std::getline(ifs, line)) - { - if (lineCounter == 0) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, 35); - } - else if (lineCounter == 1) - { - ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(1), dbus.Int16(233)), signature=None)"), 0); - } - lineCounter++; - } - ifs.close(); - - //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); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchSinkAvailabilityChanged(*arg, **karg):\n" - " print ('Caught signal (in catchSinkAvailabilityChanged handler) ') \n" - " print (arg[0])\n" - " print (arg[1])\n" - " f = open('/tmp/result.txt','w')\n" - " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" - " f.close()\n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSinkAvailabilityChanged, signal_name='SinkAvailabilityChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - ifs.open("/tmp/result.txt"); - lineCounter = 0; - result = 0; - while (std::getline(ifs, line)) - { - if (lineCounter == 0) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, 4); - } - else if (lineCounter == 1) - { - ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(0), dbus.Int16(3)), signature=None)"), 0); - } - lineCounter++; - } - ifs.close(); - - //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); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchSourceAvailability(*arg, **karg):\n" - " print ('Caught signal (in catchSourceAvailability handler) ') \n" - " print (arg[0])\n" - " print (arg[1])\n" - " f = open('/tmp/result.txt','w')\n" - " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" - " f.close()\n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSourceAvailability, signal_name='SourceAvailabilityChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - ifs.open("/tmp/result.txt"); - lineCounter = 0; - result = 0; - while (std::getline(ifs, line)) - { - if (lineCounter == 0) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, 2); - } - else if (lineCounter == 1) - { - ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(0), dbus.Int16(3)), signature=None)"), 0); - } - lineCounter++; - } - ifs.close(); - - //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); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchVolumeChanged(*arg, **karg):\n" - " print ('Caught signal (in catchVolumeChanged handler) ') \n" - " print (arg[0])\n" - " print (arg[1])\n" - " f = open('/tmp/result.txt','w')\n" - " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" - " f.close()\n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchVolumeChanged, signal_name='VolumeChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - ifs.open("/tmp/result.txt"); - lineCounter = 0; - result = 0; - while (std::getline(ifs, line)) - { - if (lineCounter == 0) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, 23); - } - else if (lineCounter == 1) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, 344); - } - lineCounter++; - } - ifs.close(); - - //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); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchSinkMuteStateChanged(*arg, **karg):\n" - " print ('Caught signal (in catchSinkMuteStateChanged handler) ') \n" - " print (arg[0])\n" - " print (arg[1])\n" - " f = open('/tmp/result.txt','w')\n" - " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" - " f.close()\n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSinkMuteStateChanged, signal_name='SinkMuteStateChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - ifs.open("/tmp/result.txt"); - lineCounter = 0; - result = 0; - while (std::getline(ifs, line)) - { - if (lineCounter == 0) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, 42); - } - else if (lineCounter == 1) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, MS_MUTED); - } - lineCounter++; - } - ifs.close(); - - //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); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchSystemPropertyChanged(*arg, **karg):\n" - " print ('Caught signal (in catchSystemPropertyChanged handler) ') \n" - " print (arg[0])\n" - " f = open('/tmp/result.txt','w')\n" - " f.write(str(arg[0]));\n" - " f.close()\n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSystemPropertyChanged, signal_name='SystemPropertyChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - ifs.open("/tmp/result.txt"); - lineCounter = 0; - result = 0; - while (std::getline(ifs, line)) - { - ASSERT_EQ(line.compare("dbus.Struct((dbus.Int16(0), dbus.Int16(355)), signature=None)"), 0); - } - ifs.close(); - - //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); - PyRun_SimpleStringFlags("import sys\n" - "import traceback\n" - "import gobject\n" - "import dbus\n" - "import dbus.mainloop.glib\n" - "loop = gobject.MainLoop()\n" - "def catchTimingInformationChanged(*arg, **karg):\n" - " print ('Caught signal (in catchTimingInformationChanged handler) ') \n" - " print (arg[0])\n" - " print (arg[1])\n" - " f = open('/tmp/result.txt','w')\n" - " f.write(str(arg[0]) + '\\n' + str (arg[1]));\n" - " f.close()\n" - " loop.quit()\n" - "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" - "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchTimingInformationChanged, signal_name='TimingInformationChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" - "loop.run()\n", NULL); - pthread_join(pythonloop, NULL); - - ifs.open("/tmp/result.txt"); - lineCounter = 0; - result = 0; - while (std::getline(ifs, line)) - { - if (lineCounter == 0) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, 42); - } - else if (lineCounter == 1) - { - std::stringstream(line) >> result; - ASSERT_EQ(result, 233); - } - lineCounter++; - } - ifs.close(); - -} - -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} - -void dbuscommaninterfacesignalsTest::SetUp() -{ - Py_Initialize(); -} - -void dbuscommaninterfacesignalsTest::TearDown() -{ - Py_Finalize(); -} - diff --git a/PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.h b/PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.h deleted file mode 100644 index 0f930d6..0000000 --- a/PluginCommandInterfaceDbus/test/dbuscommaninterfacesignalsTest.h +++ /dev/null @@ -1,53 +0,0 @@ -/** -* Copyright (C) 2011, BMW AG -* -* GeniviAudioMananger AudioManagerDaemon -* -* \file dbuscommandinterfacesignalsTest.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 . -* 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 DBUSCOMMANINTERFACESIGNALSTEST_H_ -#define DBUSCOMMANINTERFACESIGNALSTEST_H_ -#include -#include -#include -#include -#include -#include -#include "CommandReceiver.h" -#include "CommandSender.h" -#include "MockInterfaces.h" - -#define UNIT_TEST 1 - -namespace am { - -class dbuscommaninterfacesignalsTest: public ::testing::Test -{ -public: - dbuscommaninterfacesignalsTest(); - virtual ~dbuscommaninterfacesignalsTest(); - void SetUp(); - void TearDown(); -}; - -} - -#endif /* DBUSCOMMANINTERFACESIGNALSTEST_H_ */ -- cgit v1.2.1