summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon
diff options
context:
space:
mode:
authorchristian mueller <christian.ei.mueller@bmw.de>2012-01-24 17:04:42 +0100
committerchristian mueller <christian.ei.mueller@bmw.de>2012-01-24 17:04:42 +0100
commit4fe50302a695c625d5161b538da771b2c36bd33e (patch)
tree79d9fb949d626b19ac0d933a637b4881af31114e /AudioManagerDaemon
parent80213f17291e5b58c733de09f06439d71640d2e2 (diff)
downloadaudiomanager-4fe50302a695c625d5161b538da771b2c36bd33e.tar.gz
* formatting all the source code with eclipse source code style
* added used xml to the project
Diffstat (limited to 'AudioManagerDaemon')
-rw-r--r--AudioManagerDaemon/include/CommandReceiver.h106
-rw-r--r--AudioManagerDaemon/include/CommandSender.h100
-rw-r--r--AudioManagerDaemon/include/ControlReceiver.h195
-rw-r--r--AudioManagerDaemon/include/ControlSender.h145
-rw-r--r--AudioManagerDaemon/include/DatabaseHandler.h449
-rw-r--r--AudioManagerDaemon/include/DatabaseObserver.h106
-rw-r--r--AudioManagerDaemon/include/PluginTemplate.h142
-rw-r--r--AudioManagerDaemon/include/RoutingReceiver.h142
-rw-r--r--AudioManagerDaemon/include/RoutingSender.h307
-rw-r--r--AudioManagerDaemon/include/TelnetServer.h122
-rw-r--r--AudioManagerDaemon/src/CommandReceiver.cpp196
-rw-r--r--AudioManagerDaemon/src/CommandSender.cpp233
-rw-r--r--AudioManagerDaemon/src/ControlReceiver.cpp444
-rw-r--r--AudioManagerDaemon/src/ControlSender.cpp251
-rw-r--r--AudioManagerDaemon/src/DBusWrapper.cpp517
-rw-r--r--AudioManagerDaemon/src/DatabaseHandler.cpp6494
-rw-r--r--AudioManagerDaemon/src/DatabaseObserver.cpp180
-rw-r--r--AudioManagerDaemon/src/RoutingReceiver.cpp412
-rw-r--r--AudioManagerDaemon/src/RoutingSender.cpp525
-rw-r--r--AudioManagerDaemon/src/SocketHandler.cpp679
-rw-r--r--AudioManagerDaemon/src/TelnetServer.cpp388
-rw-r--r--AudioManagerDaemon/src/main.cpp425
-rw-r--r--AudioManagerDaemon/test/CommandInterfaceBackdoor.h60
-rw-r--r--AudioManagerDaemon/test/CommonFunctions.cpp636
-rw-r--r--AudioManagerDaemon/test/CommonFunctions.h141
-rw-r--r--AudioManagerDaemon/test/ControlInterfaceBackdoor.h58
-rw-r--r--AudioManagerDaemon/test/RoutingInterfaceBackdoor.h60
-rw-r--r--AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp857
-rw-r--r--AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h91
-rw-r--r--AudioManagerDaemon/test/database/databaseTest.cpp2920
-rw-r--r--AudioManagerDaemon/test/database/databaseTest.h85
-rw-r--r--AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp584
-rw-r--r--AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h83
-rw-r--r--AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp377
-rw-r--r--AudioManagerDaemon/test/sockethandler/sockethandlerTest.h72
35 files changed, 8995 insertions, 9587 deletions
diff --git a/AudioManagerDaemon/include/CommandReceiver.h b/AudioManagerDaemon/include/CommandReceiver.h
index 114d075..1d00216 100644
--- a/AudioManagerDaemon/include/CommandReceiver.h
+++ b/AudioManagerDaemon/include/CommandReceiver.h
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file CommandReveiver.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file CommandReveiver.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#ifndef COMMANDRECEIVER_H_
#define COMMANDRECEIVER_H_
@@ -28,7 +28,8 @@
#include <command/CommandReceiveInterface.h>
#include <config.h>
-namespace am {
+namespace am
+{
class DatabaseHandler;
class ControlSender;
@@ -38,38 +39,39 @@ class SocketHandler;
/**
* This class realizes the command Interface
*/
-class CommandReceiver: public CommandReceiveInterface {
+class CommandReceiver: public CommandReceiveInterface
+{
public:
- CommandReceiver(DatabaseHandler* iDatabaseHandler, ControlSender* iControlSender,DBusWrapper* iDBusWrapper);
- CommandReceiver(DatabaseHandler* iDatabaseHandler, ControlSender* iControlSender,SocketHandler* iSocketHandler);
- CommandReceiver(DatabaseHandler* iDatabaseHandler, ControlSender* iControlSender,SocketHandler* iSocketHandler,DBusWrapper* iDBusWrapper);
- virtual ~CommandReceiver();
- am_Error_e connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID) ;
- am_Error_e disconnect(const am_mainConnectionID_t mainConnectionID) ;
- am_Error_e setVolume(const am_sinkID_t sinkID, const am_mainVolume_t volume) ;
- am_Error_e volumeStep(const am_sinkID_t sinkID, const int16_t volumeStep) ;
- am_Error_e setSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState) ;
- am_Error_e setMainSinkSoundProperty(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID) ;
- am_Error_e setMainSourceSoundProperty(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID) ;
- am_Error_e setSystemProperty(const am_SystemProperty_s& property) ;
- am_Error_e getListMainConnections(std::vector<am_MainConnectionType_s>& listConnections) const ;
- am_Error_e getListMainSinks(std::vector<am_SinkType_s>& listMainSinks) const ;
- am_Error_e getListMainSources(std::vector<am_SourceType_s>& listMainSources) const ;
- am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundProperties) const ;
- am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSourceProperties) const ;
- am_Error_e getListSourceClasses(std::vector<am_SourceClass_s>& listSourceClasses) const ;
- am_Error_e getListSinkClasses(std::vector<am_SinkClass_s>& listSinkClasses) const ;
- am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s>& listSystemProperties) const ;
- am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const ;
- am_Error_e getDBusConnectionWrapper(DBusWrapper*& dbusConnectionWrapper) const ;
- am_Error_e getSocketHandler(SocketHandler*& socketHandler) const;
- uint16_t getInterfaceVersion() const;
+ CommandReceiver(DatabaseHandler* iDatabaseHandler, ControlSender* iControlSender, DBusWrapper* iDBusWrapper);
+ CommandReceiver(DatabaseHandler* iDatabaseHandler, ControlSender* iControlSender, SocketHandler* iSocketHandler);
+ CommandReceiver(DatabaseHandler* iDatabaseHandler, ControlSender* iControlSender, SocketHandler* iSocketHandler, DBusWrapper* iDBusWrapper);
+ virtual ~CommandReceiver();
+ am_Error_e connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID);
+ am_Error_e disconnect(const am_mainConnectionID_t mainConnectionID);
+ am_Error_e setVolume(const am_sinkID_t sinkID, const am_mainVolume_t volume);
+ am_Error_e volumeStep(const am_sinkID_t sinkID, const int16_t volumeStep);
+ am_Error_e setSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState);
+ am_Error_e setMainSinkSoundProperty(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID);
+ am_Error_e setMainSourceSoundProperty(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID);
+ am_Error_e setSystemProperty(const am_SystemProperty_s& property);
+ am_Error_e getListMainConnections(std::vector<am_MainConnectionType_s>& listConnections) const;
+ am_Error_e getListMainSinks(std::vector<am_SinkType_s>& listMainSinks) const;
+ am_Error_e getListMainSources(std::vector<am_SourceType_s>& listMainSources) const;
+ am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundProperties) const;
+ am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSourceProperties) const;
+ am_Error_e getListSourceClasses(std::vector<am_SourceClass_s>& listSourceClasses) const;
+ am_Error_e getListSinkClasses(std::vector<am_SinkClass_s>& listSinkClasses) const;
+ am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s>& listSystemProperties) const;
+ am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const;
+ am_Error_e getDBusConnectionWrapper(DBusWrapper*& dbusConnectionWrapper) const;
+ am_Error_e getSocketHandler(SocketHandler*& socketHandler) const;
+ uint16_t getInterfaceVersion() const;
private:
- DatabaseHandler* mDatabaseHandler; //!< pointer to the databasehandler
- ControlSender* mControlSender; //!< pointer to the control sender
- DBusWrapper* mDBusWrapper; //!< pointer to the dbuswrapper
- SocketHandler* mSocketHandler; //!< pointer to the SocketHandler
+ DatabaseHandler* mDatabaseHandler; //!< pointer to the databasehandler
+ ControlSender* mControlSender; //!< pointer to the control sender
+ DBusWrapper* mDBusWrapper; //!< pointer to the dbuswrapper
+ SocketHandler* mSocketHandler; //!< pointer to the SocketHandler
};
}
diff --git a/AudioManagerDaemon/include/CommandSender.h b/AudioManagerDaemon/include/CommandSender.h
index 5a412f3..a3898dc 100644
--- a/AudioManagerDaemon/include/CommandSender.h
+++ b/AudioManagerDaemon/include/CommandSender.h
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#ifndef COMMANDSENDER_H_
#define COMMANDSENDER_H_
@@ -31,42 +31,44 @@
#include "command/CommandSendInterface.h"
-namespace am {
+namespace am
+{
/**
* This class is used to send data to the CommandInterface.
* All loaded plugins will be called when a callback is invoked.
*/
-class CommandSender {
+class CommandSender
+{
public:
- CommandSender(const std::vector<std::string>& listOfPluginDirectories);
- virtual ~CommandSender();
- am_Error_e startupInterface(CommandReceiveInterface* commandreceiveinterface) ;
- am_Error_e stopInterface() ;
- void cbCommunicationReady() ;
- void cbCommunicationRundown() ;
- void cbNumberOfMainConnectionsChanged() ;
- void cbNumberOfSinksChanged() ;
- void cbNumberOfSourcesChanged() ;
- 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 mainConnection, const am_timeSync_t time) ;
- uint16_t getInterfaceVersion() const;
+ CommandSender(const std::vector<std::string>& listOfPluginDirectories);
+ virtual ~CommandSender();
+ am_Error_e startupInterface(CommandReceiveInterface* commandreceiveinterface);
+ am_Error_e stopInterface();
+ void cbCommunicationReady();
+ void cbCommunicationRundown();
+ void cbNumberOfMainConnectionsChanged();
+ void cbNumberOfSinksChanged();
+ void cbNumberOfSourcesChanged();
+ 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 mainConnection, const am_timeSync_t time);
+ uint16_t getInterfaceVersion() const;
#ifdef UNIT_TEST
- friend class CommandInterfaceBackdoor; //this is to get access to the loaded plugins and be able to exchange the interfaces
+ friend class CommandInterfaceBackdoor; //this is to get access to the loaded plugins and be able to exchange the interfaces
#endif
private:
- void unloadLibraries(void); //!< unload the shared libraries
- std::vector<CommandSendInterface*> mListInterfaces; //!< list of all interfaces
- std::vector<void*> mListLibraryHandles; //!< list of all library handles. This information is used to unload the plugins correctly.
+ void unloadLibraries(void); //!< unload the shared libraries
+ std::vector<CommandSendInterface*> mListInterfaces; //!< list of all interfaces
+ std::vector<void*> mListLibraryHandles; //!< list of all library handles. This information is used to unload the plugins correctly.
};
}
diff --git a/AudioManagerDaemon/include/ControlReceiver.h b/AudioManagerDaemon/include/ControlReceiver.h
index a8afb79..ac2168c 100644
--- a/AudioManagerDaemon/include/ControlReceiver.h
+++ b/AudioManagerDaemon/include/ControlReceiver.h
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file ControlReceiver.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file ControlReceiver.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#ifndef CONTRONLRECEIVER_H_
#define CONTRONLRECEIVER_H_
@@ -28,8 +28,8 @@
#include <control/ControlReceiveInterface.h>
#include <config.h>
-
-namespace am {
+namespace am
+{
class SocketHandler;
class DatabaseHandler;
@@ -39,82 +39,83 @@ class CommandSender;
/**
* This class is used to receive all commands from the control interface
*/
-class ControlReceiver: public ControlReceiveInterface {
+class ControlReceiver: public ControlReceiveInterface
+{
public:
- ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender, SocketHandler *iSocketHandler);
- ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender);
- virtual ~ControlReceiver();
- am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s>& returnList) ;
- am_Error_e connect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID) ;
- am_Error_e disconnect(am_Handle_s& handle, const am_connectionID_t connectionID) ;
- am_Error_e crossfade(am_Handle_s& handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_RampType_e rampType, const am_time_t rampTime) ;
- am_Error_e setSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state) ;
- am_Error_e setSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) ;
- am_Error_e setSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e rampType, const am_time_t time) ;
- am_Error_e setSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty) ;
- am_Error_e setSinkSoundProperties(am_Handle_s& handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s>& soundProperty) ;
- am_Error_e setSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty) ;
- am_Error_e setSourceSoundProperties(am_Handle_s& handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s>& soundProperty) ;
- am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState) ;
- am_Error_e abortAction(const am_Handle_s handle) ;
- am_Error_e enterDomainDB(const am_Domain_s& domainData, am_domainID_t& domainID) ;
- am_Error_e enterMainConnectionDB(const am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID) ;
- am_Error_e enterSinkDB(const am_Sink_s& sinkData, am_sinkID_t& sinkID) ;
- am_Error_e enterCrossfaderDB(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ;
- am_Error_e enterGatewayDB(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) ;
- am_Error_e enterSourceDB(const am_Source_s& sourceData, am_sourceID_t& sourceID) ;
- am_Error_e enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID) ;
- am_Error_e enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass) ;
- am_Error_e enterSystemPropertiesListDB(const std::vector<am_SystemProperty_s>& listSystemProperties) ;
- am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const am_Route_s& route) ;
- am_Error_e changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState) ;
- am_Error_e changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID) ;
- am_Error_e changeSinkAvailabilityDB(const am_Availability_s& availability, const am_sinkID_t sinkID) ;
- am_Error_e changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID) ;
- am_Error_e changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID) ;
- am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID) ;
- am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID) ;
- am_Error_e changeSourceAvailabilityDB(const am_Availability_s& availability, const am_sourceID_t sourceID) ;
- am_Error_e changeSystemPropertyDB(const am_SystemProperty_s& property) ;
- am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& classInfo) ;
- am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& classInfo) ;
- am_Error_e removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID) ;
- am_Error_e removeSinkDB(const am_sinkID_t sinkID) ;
- am_Error_e removeSourceDB(const am_sourceID_t sourceID) ;
- am_Error_e removeGatewayDB(const am_gatewayID_t gatewayID) ;
- am_Error_e removeCrossfaderDB(const am_crossfaderID_t crossfaderID) ;
- am_Error_e removeDomainDB(const am_domainID_t domainID) ;
- am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID) ;
- am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID) ;
- am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const ;
- am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const ;
- am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const ;
- am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const ;
- am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID) const ;
- am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID) const ;
- am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t>& listGatewaysID) const ;
- am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t>& listGatewaysID) const ;
- am_Error_e getListMainConnections(std::vector<am_MainConnection_s>& listMainConnections) const ;
- am_Error_e getListDomains(std::vector<am_Domain_s>& listDomains) const ;
- am_Error_e getListConnections(std::vector<am_Connection_s>& listConnections) const ;
- am_Error_e getListSinks(std::vector<am_Sink_s>& listSinks) const ;
- am_Error_e getListSources(std::vector<am_Source_s>& lisSources) const ;
- am_Error_e getListSourceClasses(std::vector<am_SourceClass_s>& listSourceClasses) const ;
- am_Error_e getListHandles(std::vector<am_Handle_s>& listHandles) const ;
- am_Error_e getListCrossfaders(std::vector<am_Crossfader_s>& listCrossfaders) const ;
- am_Error_e getListGateways(std::vector<am_Gateway_s>& listGateways) const ;
- am_Error_e getListSinkClasses(std::vector<am_SinkClass_s>& listSinkClasses) const ;
- am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s>& listSystemProperties) const ;
- void setRoutingReady() ;
- void setCommandReady() ;
- am_Error_e getSocketHandler(SocketHandler*& socketHandler);
- uint16_t getInterfaceVersion() const;
+ ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender, SocketHandler *iSocketHandler);
+ ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender);
+ virtual ~ControlReceiver();
+ am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s>& returnList);
+ am_Error_e connect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID);
+ am_Error_e disconnect(am_Handle_s& handle, const am_connectionID_t connectionID);
+ am_Error_e crossfade(am_Handle_s& handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_RampType_e rampType, const am_time_t rampTime);
+ am_Error_e setSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state);
+ am_Error_e setSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time);
+ am_Error_e setSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e rampType, const am_time_t time);
+ am_Error_e setSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty);
+ am_Error_e setSinkSoundProperties(am_Handle_s& handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s>& soundProperty);
+ am_Error_e setSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty);
+ am_Error_e setSourceSoundProperties(am_Handle_s& handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s>& soundProperty);
+ am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState);
+ am_Error_e abortAction(const am_Handle_s handle);
+ am_Error_e enterDomainDB(const am_Domain_s& domainData, am_domainID_t& domainID);
+ am_Error_e enterMainConnectionDB(const am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID);
+ am_Error_e enterSinkDB(const am_Sink_s& sinkData, am_sinkID_t& sinkID);
+ am_Error_e enterCrossfaderDB(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID);
+ am_Error_e enterGatewayDB(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID);
+ am_Error_e enterSourceDB(const am_Source_s& sourceData, am_sourceID_t& sourceID);
+ am_Error_e enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID);
+ am_Error_e enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass);
+ am_Error_e enterSystemPropertiesListDB(const std::vector<am_SystemProperty_s>& listSystemProperties);
+ am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const am_Route_s& route);
+ am_Error_e changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState);
+ am_Error_e changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID);
+ am_Error_e changeSinkAvailabilityDB(const am_Availability_s& availability, const am_sinkID_t sinkID);
+ am_Error_e changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID);
+ am_Error_e changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID);
+ am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID);
+ am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID);
+ am_Error_e changeSourceAvailabilityDB(const am_Availability_s& availability, const am_sourceID_t sourceID);
+ am_Error_e changeSystemPropertyDB(const am_SystemProperty_s& property);
+ am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& classInfo);
+ am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& classInfo);
+ am_Error_e removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID);
+ am_Error_e removeSinkDB(const am_sinkID_t sinkID);
+ am_Error_e removeSourceDB(const am_sourceID_t sourceID);
+ am_Error_e removeGatewayDB(const am_gatewayID_t gatewayID);
+ am_Error_e removeCrossfaderDB(const am_crossfaderID_t crossfaderID);
+ am_Error_e removeDomainDB(const am_domainID_t domainID);
+ am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID);
+ am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID);
+ am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const;
+ am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const;
+ am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const;
+ am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const;
+ am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID) const;
+ am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID) const;
+ am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t>& listGatewaysID) const;
+ am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t>& listGatewaysID) const;
+ am_Error_e getListMainConnections(std::vector<am_MainConnection_s>& listMainConnections) const;
+ am_Error_e getListDomains(std::vector<am_Domain_s>& listDomains) const;
+ am_Error_e getListConnections(std::vector<am_Connection_s>& listConnections) const;
+ am_Error_e getListSinks(std::vector<am_Sink_s>& listSinks) const;
+ am_Error_e getListSources(std::vector<am_Source_s>& lisSources) const;
+ am_Error_e getListSourceClasses(std::vector<am_SourceClass_s>& listSourceClasses) const;
+ am_Error_e getListHandles(std::vector<am_Handle_s>& listHandles) const;
+ am_Error_e getListCrossfaders(std::vector<am_Crossfader_s>& listCrossfaders) const;
+ am_Error_e getListGateways(std::vector<am_Gateway_s>& listGateways) const;
+ am_Error_e getListSinkClasses(std::vector<am_SinkClass_s>& listSinkClasses) const;
+ am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s>& listSystemProperties) const;
+ void setRoutingReady();
+ void setCommandReady();
+ am_Error_e getSocketHandler(SocketHandler*& socketHandler);
+ uint16_t getInterfaceVersion() const;
private:
- DatabaseHandler* mDatabaseHandler; //!< pointer tto the databasehandler
- RoutingSender* mRoutingSender; //!< pointer to the routing send interface.
- CommandSender* mCommandSender; //!< pointer to the command send interface
- SocketHandler* mSocketHandler; //!< pointer to the socketHandler
+ DatabaseHandler* mDatabaseHandler; //!< pointer tto the databasehandler
+ RoutingSender* mRoutingSender; //!< pointer to the routing send interface.
+ CommandSender* mCommandSender; //!< pointer to the command send interface
+ SocketHandler* mSocketHandler; //!< pointer to the socketHandler
};
}
diff --git a/AudioManagerDaemon/include/ControlSender.h b/AudioManagerDaemon/include/ControlSender.h
index 2134fa6..3021c3c 100644
--- a/AudioManagerDaemon/include/ControlSender.h
+++ b/AudioManagerDaemon/include/ControlSender.h
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file ControlSender.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file ControlSender.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#ifndef CONTROLSENDER_H_
#define CONTROLSENDER_H_
@@ -31,64 +31,67 @@
#include "control/ControlSendInterface.h"
-namespace am {
+namespace am
+{
/**
* sends data to the commandInterface, takes the file of the library that needs to be loaded
*/
-class ControlSender {
+class ControlSender
+{
public:
- ControlSender(std::string controlPluginFile);
- virtual ~ControlSender();
- am_Error_e startupController(ControlReceiveInterface* controlreceiveinterface) ;
- am_Error_e stopController() ;
- am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID) ;
- am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID) ;
- am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty) ;
- am_Error_e hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty) ;
- am_Error_e hookUserSetSystemProperty(const am_SystemProperty_s& property) ;
- am_Error_e hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume) ;
- am_Error_e hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment) ;
- am_Error_e hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState) ;
- am_Error_e hookSystemRegisterDomain(const am_Domain_s& domainData, am_domainID_t& domainID) ;
- am_Error_e hookSystemDeregisterDomain(const am_domainID_t domainID) ;
- am_Error_e hookSystemRegisterSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID) ;
- am_Error_e hookSystemDeregisterSink(const am_sinkID_t sinkID) ;
- am_Error_e hookSystemRegisterSource(const am_Source_s& sourceData, am_sourceID_t& sourceID) ;
- am_Error_e hookSystemDeregisterSource(const am_sourceID_t sourceID) ;
- am_Error_e hookSystemRegisterGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) ;
- am_Error_e hookSystemDeregisterGateway(const am_gatewayID_t gatewayID) ;
- am_Error_e hookSystemRegisterCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ;
- am_Error_e hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID) ;
- void hookAllPluginsLoaded() ;
- void hookSystemDomainRegistrationComplete(const am_domainID_t domainID) ;
- void hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume) ;
- void hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume) ;
- void hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState) ;
- void hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s& availability) ;
- void hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s& availability) ;
- void hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state) ;
- void hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s>& data) ;
- void hookSystemSpeedChange(const am_speed_t speed) ;
- void hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time) ;
- void cbAckConnect(const am_Handle_s handle, const am_Error_e errorID) ;
- void cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID) ;
- void cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error) ;
- void cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error) ;
- void cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error) ;
- void cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error) ;
- void cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error) ;
- void cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error) ;
- void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error) ;
- void cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error) ;
- uint16_t getInterfaceVersion() const;
+ ControlSender(std::string controlPluginFile);
+ virtual ~ControlSender();
+ am_Error_e startupController(ControlReceiveInterface* controlreceiveinterface);
+ am_Error_e stopController();
+ am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID);
+ am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID);
+ am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty);
+ am_Error_e hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty);
+ am_Error_e hookUserSetSystemProperty(const am_SystemProperty_s& property);
+ am_Error_e hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume);
+ am_Error_e hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment);
+ am_Error_e hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState);
+ am_Error_e hookSystemRegisterDomain(const am_Domain_s& domainData, am_domainID_t& domainID);
+ am_Error_e hookSystemDeregisterDomain(const am_domainID_t domainID);
+ am_Error_e hookSystemRegisterSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID);
+ am_Error_e hookSystemDeregisterSink(const am_sinkID_t sinkID);
+ am_Error_e hookSystemRegisterSource(const am_Source_s& sourceData, am_sourceID_t& sourceID);
+ am_Error_e hookSystemDeregisterSource(const am_sourceID_t sourceID);
+ am_Error_e hookSystemRegisterGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID);
+ am_Error_e hookSystemDeregisterGateway(const am_gatewayID_t gatewayID);
+ am_Error_e hookSystemRegisterCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID);
+ am_Error_e hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID);
+ void hookAllPluginsLoaded();
+ void hookSystemDomainRegistrationComplete(const am_domainID_t domainID);
+ void hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume);
+ void hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume);
+ void hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState);
+ void hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s& availability);
+ void hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s& availability);
+ void hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state);
+ void hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s>& data);
+ void hookSystemSpeedChange(const am_speed_t speed);
+ void hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time);
+ void cbAckConnect(const am_Handle_s handle, const am_Error_e errorID);
+ void cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID);
+ void cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error);
+ void cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error);
+ void cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error);
+ void cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error);
+ void cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error);
+ void cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error);
+ void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error);
+ void cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error);
+ am_Error_e getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const std::vector<am_ConnectionFormat_e> listPossibleConnectionFormats, std::vector<am_ConnectionFormat_e>& listPrioConnectionFormats);
+ uint16_t getInterfaceVersion() const;
#ifdef UNIT_TEST
- friend class ControlInterfaceBackdoor;
+ friend class ControlInterfaceBackdoor;
#endif
private:
- void* mlibHandle; //!< pointer to the loaded control plugin interface
- ControlSendInterface* mController; //!< pointer to the ControlSend interface
+ void* mlibHandle; //!< pointer to the loaded control plugin interface
+ ControlSendInterface* mController; //!< pointer to the ControlSend interface
};
}
diff --git a/AudioManagerDaemon/include/DatabaseHandler.h b/AudioManagerDaemon/include/DatabaseHandler.h
index 65f4a64..5d1cac7 100644
--- a/AudioManagerDaemon/include/DatabaseHandler.h
+++ b/AudioManagerDaemon/include/DatabaseHandler.h
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file Databasehandler.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file Databasehandler.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#ifndef DATABASEHANDLER_H_
#define DATABASEHANDLER_H_
@@ -29,14 +29,14 @@
#include <sqlite3.h>
#include <map>
-namespace am {
+namespace am
+{
class DatabaseObserver;
class RoutingTree;
class RoutingTreeItem;
#define DYNAMIC_ID_BOUNDARY 100 //!< the value below is reserved for staticIDs, the value above will be assigned to dynamically registered items
-
//todo: we do not have to create MainSoundProperty tables if visible = false.
//todo: check the enum values before entering & changing in the database.
//todo: change asserts for dynamic boundary checks into failure answers.#
@@ -50,223 +50,224 @@ class RoutingTreeItem;
/**
* This class handles and abstracts the database
*/
-class DatabaseHandler {
+class DatabaseHandler
+{
public:
- DatabaseHandler(std::string databasePath);
- virtual ~DatabaseHandler();
- am_Error_e enterDomainDB(const am_Domain_s& domainData, am_domainID_t& domainID) ;
- am_Error_e enterMainConnectionDB(const am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID) ;
- am_Error_e enterSinkDB(const am_Sink_s& sinkData, am_sinkID_t& sinkID) ;
- am_Error_e enterCrossfaderDB(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ;
- am_Error_e enterGatewayDB(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) ;
- am_Error_e enterSourceDB(const am_Source_s& sourceData, am_sourceID_t& sourceID) ;
- am_Error_e enterConnectionDB(const am_Connection_s& connection, am_connectionID_t& connectionID);
- am_Error_e enterSinkClassDB(const am_SinkClass_s& sinkClass, am_sinkClass_t& sinkClassID) ;
- am_Error_e enterSourceClassDB(am_sourceClass_t& sourceClassID, const am_SourceClass_s& sourceClass) ;
- am_Error_e enterSystemProperties(const std::vector<am_SystemProperty_s>& listSystemProperties) ;
- am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const am_Route_s& route) ;
- am_Error_e changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState) ;
- am_Error_e changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID) ;
- am_Error_e changeSinkAvailabilityDB(const am_Availability_s& availability, const am_sinkID_t sinkID) ;
- am_Error_e changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID) ;
- am_Error_e changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID) ;
- am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID) ;
- am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID) ;
- am_Error_e changeSourceSoundPropertyDB(const am_SoundProperty_s& soundProperty, const am_sourceID_t sourceID) ;
- am_Error_e changeSinkSoundPropertyDB(const am_SoundProperty_s& soundProperty, const am_sinkID_t sinkID) ;
- am_Error_e changeSourceAvailabilityDB(const am_Availability_s& availability, const am_sourceID_t sourceID) ;
- am_Error_e changeSystemPropertyDB(const am_SystemProperty_s& property) ;
- am_Error_e changeDelayMainConnection(const am_timeSync_t & delay, const am_mainConnectionID_t & connectionID) ;
- am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& sinkClass) ;
- am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& sourceClass) ;
- am_Error_e changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay) ;
- am_Error_e changeConnectionFinal(const am_connectionID_t connectionID) ;
- am_Error_e changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState);
- am_Error_e changeSinkVolume(const am_sinkID_t sinkID, const am_volume_t volume);
- am_Error_e changeSourceVolume(const am_sourceID_t sourceID, const am_volume_t volume);
- am_Error_e changeCrossFaderHotSink(const am_crossfaderID_t crossfaderID,const am_HotSink_e hotsink);
- am_Error_e removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID) ;
- am_Error_e removeSinkDB(const am_sinkID_t sinkID) ;
- am_Error_e removeSourceDB(const am_sourceID_t sourceID) ;
- am_Error_e removeGatewayDB(const am_gatewayID_t gatewayID) ;
- am_Error_e removeCrossfaderDB(const am_crossfaderID_t crossfaderID) ;
- am_Error_e removeDomainDB(const am_domainID_t domainID) ;
- am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID) ;
- am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID) ;
- am_Error_e removeConnection(const am_connectionID_t connectionID) ;
- am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const ;
- am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const ;
- am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const ;
- am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const ;
- am_Error_e getSinkVolume(const am_sinkID_t sinkID, am_volume_t& volume) const;
- am_Error_e getSourceVolume(const am_sourceID_t sourceID, am_volume_t& volume) const;
- am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_SoundPropertyType_e propertyType, uint16_t& value) const ;
- am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_SoundPropertyType_e propertyType, uint16_t& value) const ;
- am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID) const ;
- am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID) const ;
- am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t>& listGatewaysID) const ;
- am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t>& listGatewaysID) const ;
- am_Error_e getListMainConnections(std::vector<am_MainConnection_s>& listMainConnections) const ;
- am_Error_e getListDomains(std::vector<am_Domain_s>& listDomains) const ;
- am_Error_e getListConnections(std::vector<am_Connection_s>& listConnections) const ;
- am_Error_e getListSinks(std::vector<am_Sink_s>& listSinks) const ;
- am_Error_e getListSources(std::vector<am_Source_s>& lisSources) const ;
- am_Error_e getListSourceClasses(std::vector<am_SourceClass_s>& listSourceClasses) const ;
- am_Error_e getListCrossfaders(std::vector<am_Crossfader_s>& listCrossfaders) const ;
- am_Error_e getListGateways(std::vector<am_Gateway_s>& listGateways) const ;
- am_Error_e getListSinkClasses(std::vector<am_SinkClass_s>& listSinkClasses) const ;
- am_Error_e getListVisibleMainConnections(std::vector<am_MainConnectionType_s>& listConnections) const ;
- am_Error_e getListMainSinks(std::vector<am_SinkType_s>& listMainSinks) const ;
- am_Error_e getListMainSources(std::vector<am_SourceType_s>& listMainSources) const ;
- am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundProperties) const ;
- am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSourceProperties) const ;
- am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s>& listSystemProperties) const ;
- am_Error_e getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const ;
- am_Error_e getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const ;
- am_Error_e getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector<bool> & listConnectionFormat) const;
- am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const ;
- am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t& domainID) const;
- am_Error_e getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t& domainID) const;
- am_Error_e getSoureState(const am_sourceID_t sourceID, am_SourceState_e& sourceState) const;
- am_Error_e getDomainState(const am_domainID_t domainID, am_DomainState_e state) const;
- am_Error_e getRoutingTree(bool onlyfree, RoutingTree* tree, std::vector<RoutingTreeItem*>* flatTree);
- am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID);
- am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID);
- am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID);
- /**
- * checks for a certain mainConnection
- * @param mainConnectionID to be checked for
- * @return true if it exists
- */
- bool existMainConnection(const am_mainConnectionID_t mainConnectionID) const;
+ DatabaseHandler(std::string databasePath);
+ virtual ~DatabaseHandler();
+ am_Error_e enterDomainDB(const am_Domain_s& domainData, am_domainID_t& domainID);
+ am_Error_e enterMainConnectionDB(const am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID);
+ am_Error_e enterSinkDB(const am_Sink_s& sinkData, am_sinkID_t& sinkID);
+ am_Error_e enterCrossfaderDB(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID);
+ am_Error_e enterGatewayDB(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID);
+ am_Error_e enterSourceDB(const am_Source_s& sourceData, am_sourceID_t& sourceID);
+ am_Error_e enterConnectionDB(const am_Connection_s& connection, am_connectionID_t& connectionID);
+ am_Error_e enterSinkClassDB(const am_SinkClass_s& sinkClass, am_sinkClass_t& sinkClassID);
+ am_Error_e enterSourceClassDB(am_sourceClass_t& sourceClassID, const am_SourceClass_s& sourceClass);
+ am_Error_e enterSystemProperties(const std::vector<am_SystemProperty_s>& listSystemProperties);
+ am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const am_Route_s& route);
+ am_Error_e changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState);
+ am_Error_e changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID);
+ am_Error_e changeSinkAvailabilityDB(const am_Availability_s& availability, const am_sinkID_t sinkID);
+ am_Error_e changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID);
+ am_Error_e changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID);
+ am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID);
+ am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID);
+ am_Error_e changeSourceSoundPropertyDB(const am_SoundProperty_s& soundProperty, const am_sourceID_t sourceID);
+ am_Error_e changeSinkSoundPropertyDB(const am_SoundProperty_s& soundProperty, const am_sinkID_t sinkID);
+ am_Error_e changeSourceAvailabilityDB(const am_Availability_s& availability, const am_sourceID_t sourceID);
+ am_Error_e changeSystemPropertyDB(const am_SystemProperty_s& property);
+ am_Error_e changeDelayMainConnection(const am_timeSync_t & delay, const am_mainConnectionID_t & connectionID);
+ am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& sinkClass);
+ am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& sourceClass);
+ am_Error_e changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay);
+ am_Error_e changeConnectionFinal(const am_connectionID_t connectionID);
+ am_Error_e changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState);
+ am_Error_e changeSinkVolume(const am_sinkID_t sinkID, const am_volume_t volume);
+ am_Error_e changeSourceVolume(const am_sourceID_t sourceID, const am_volume_t volume);
+ am_Error_e changeCrossFaderHotSink(const am_crossfaderID_t crossfaderID, const am_HotSink_e hotsink);
+ am_Error_e removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID);
+ am_Error_e removeSinkDB(const am_sinkID_t sinkID);
+ am_Error_e removeSourceDB(const am_sourceID_t sourceID);
+ am_Error_e removeGatewayDB(const am_gatewayID_t gatewayID);
+ am_Error_e removeCrossfaderDB(const am_crossfaderID_t crossfaderID);
+ am_Error_e removeDomainDB(const am_domainID_t domainID);
+ am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID);
+ am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID);
+ am_Error_e removeConnection(const am_connectionID_t connectionID);
+ am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const;
+ am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const;
+ am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const;
+ am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const;
+ am_Error_e getSinkVolume(const am_sinkID_t sinkID, am_volume_t& volume) const;
+ am_Error_e getSourceVolume(const am_sourceID_t sourceID, am_volume_t& volume) const;
+ am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_SoundPropertyType_e propertyType, uint16_t& value) const;
+ am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_SoundPropertyType_e propertyType, uint16_t& value) const;
+ am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID) const;
+ am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID) const;
+ am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t>& listGatewaysID) const;
+ am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t>& listGatewaysID) const;
+ am_Error_e getListMainConnections(std::vector<am_MainConnection_s>& listMainConnections) const;
+ am_Error_e getListDomains(std::vector<am_Domain_s>& listDomains) const;
+ am_Error_e getListConnections(std::vector<am_Connection_s>& listConnections) const;
+ am_Error_e getListSinks(std::vector<am_Sink_s>& listSinks) const;
+ am_Error_e getListSources(std::vector<am_Source_s>& lisSources) const;
+ am_Error_e getListSourceClasses(std::vector<am_SourceClass_s>& listSourceClasses) const;
+ am_Error_e getListCrossfaders(std::vector<am_Crossfader_s>& listCrossfaders) const;
+ am_Error_e getListGateways(std::vector<am_Gateway_s>& listGateways) const;
+ am_Error_e getListSinkClasses(std::vector<am_SinkClass_s>& listSinkClasses) const;
+ am_Error_e getListVisibleMainConnections(std::vector<am_MainConnectionType_s>& listConnections) const;
+ am_Error_e getListMainSinks(std::vector<am_SinkType_s>& listMainSinks) const;
+ am_Error_e getListMainSources(std::vector<am_SourceType_s>& listMainSources) const;
+ am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundProperties) const;
+ am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSourceProperties) const;
+ am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s>& listSystemProperties) const;
+ am_Error_e getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const;
+ am_Error_e getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const;
+ am_Error_e getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector<bool> & listConnectionFormat) const;
+ am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const;
+ am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t& domainID) const;
+ am_Error_e getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t& domainID) const;
+ am_Error_e getSoureState(const am_sourceID_t sourceID, am_SourceState_e& sourceState) const;
+ am_Error_e getDomainState(const am_domainID_t domainID, am_DomainState_e state) const;
+ am_Error_e getRoutingTree(bool onlyfree, RoutingTree* tree, std::vector<RoutingTreeItem*>* flatTree);
+ am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID);
+ am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID);
+ am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID);
+ /**
+ * checks for a certain mainConnection
+ * @param mainConnectionID to be checked for
+ * @return true if it exists
+ */
+ bool existMainConnection(const am_mainConnectionID_t mainConnectionID) const;
- /**
- * checks if a CrossFader exists
- * @param crossfaderID the ID of the crossfader to be checked
- * @return true if exists
- */
- bool existcrossFader(const am_crossfaderID_t crossfaderID) const;
+ /**
+ * checks if a CrossFader exists
+ * @param crossfaderID the ID of the crossfader to be checked
+ * @return true if exists
+ */
+ bool existcrossFader(const am_crossfaderID_t crossfaderID) const;
- /**
- * checks if a connection already exists.
- * Only takes sink, source and format information for search!
- * @param connection the connection to be checked
- * @return true if connections exists
- */
- bool existConnection(const am_Connection_s connection);
+ /**
+ * checks if a connection already exists.
+ * Only takes sink, source and format information for search!
+ * @param connection the connection to be checked
+ * @return true if connections exists
+ */
+ bool existConnection(const am_Connection_s connection);
- /**
- * checks if a connection with the given ID exists
- * @param connectionID
- * @return true if connection exits
- */
- bool existConnectionID(const am_connectionID_t connectionID);
- /**
- * checks for a certain Source
- * @param sourceID to be checked for
- * @return true if it exists
- */
- bool existSource(const am_sourceID_t sourceID) const;
+ /**
+ * checks if a connection with the given ID exists
+ * @param connectionID
+ * @return true if connection exits
+ */
+ bool existConnectionID(const am_connectionID_t connectionID);
+ /**
+ * checks for a certain Source
+ * @param sourceID to be checked for
+ * @return true if it exists
+ */
+ bool existSource(const am_sourceID_t sourceID) const;
- /**
- * checks if a source name or ID exists
- * @param sourceID the sourceID
- * @param name the name
- * @return true if it exits
- */
- bool existSourceNameOrID(const am_sourceID_t sourceID, const std::string& name) const;
+ /**
+ * checks if a source name or ID exists
+ * @param sourceID the sourceID
+ * @param name the name
+ * @return true if it exits
+ */
+ bool existSourceNameOrID(const am_sourceID_t sourceID, const std::string& name) const;
- /**
- * checks if a name exits
- * @param name the name
- * @return true if it exits
- */
- bool existSourceName(const std::string& name) const;
- /**
- * checks for a certain Sink
- * @param sinkID to be checked for
- * @return true if it exists
- */
- bool existSink(const am_sinkID_t sinkID) const;
+ /**
+ * checks if a name exits
+ * @param name the name
+ * @return true if it exits
+ */
+ bool existSourceName(const std::string& name) const;
+ /**
+ * checks for a certain Sink
+ * @param sinkID to be checked for
+ * @return true if it exists
+ */
+ bool existSink(const am_sinkID_t sinkID) const;
- /**
- * checks if a sink with the ID or the name exists
- * @param sinkID the ID
- * @param name the name
- * @return true if it exists.
- */
- bool existSinkNameOrID(const am_sinkID_t sinkID, const std::string& name) const;
+ /**
+ * checks if a sink with the ID or the name exists
+ * @param sinkID the ID
+ * @param name the name
+ * @return true if it exists.
+ */
+ bool existSinkNameOrID(const am_sinkID_t sinkID, const std::string& name) const;
- /**
- * checks if a sink with the name exists
- * @param name the name
- * @return true if it exists
- */
- bool existSinkName(const std::string& name) const;
+ /**
+ * checks if a sink with the name exists
+ * @param name the name
+ * @return true if it exists
+ */
+ bool existSinkName(const std::string& name) const;
- /**
- * checks for a certain domain
- * @param domainID to be checked for
- * @return true if it exists
- */
- bool existDomain(const am_domainID_t domainID) const;
+ /**
+ * checks for a certain domain
+ * @param domainID to be checked for
+ * @return true if it exists
+ */
+ bool existDomain(const am_domainID_t domainID) const;
- /**
- * checks for certain gateway
- * @param gatewayID to be checked for
- * @return true if it exists
- */
- bool existGateway(const am_gatewayID_t gatewayID) const;
+ /**
+ * checks for certain gateway
+ * @param gatewayID to be checked for
+ * @return true if it exists
+ */
+ bool existGateway(const am_gatewayID_t gatewayID) const;
- /**
- * checks for certain SinkClass
- * @param sinkClassID
- * @return true if it exists
- */
- bool existSinkClass(const am_sinkClass_t sinkClassID) const;
+ /**
+ * checks for certain SinkClass
+ * @param sinkClassID
+ * @return true if it exists
+ */
+ bool existSinkClass(const am_sinkClass_t sinkClassID) const;
- /**
- * checks for certain sourceClass
- * @param sourceClassID
- * @return true if it exists
- */
- bool existSourceClass(const am_sourceClass_t sourceClassID) const;
+ /**
+ * checks for certain sourceClass
+ * @param sourceClassID
+ * @return true if it exists
+ */
+ bool existSourceClass(const am_sourceClass_t sourceClassID) const;
- /**
- * registers the Observer at the Database
- * @param iObserver pointer to the observer
- */
- void registerObserver(DatabaseObserver *iObserver);
+ /**
+ * registers the Observer at the Database
+ * @param iObserver pointer to the observer
+ */
+ void registerObserver(DatabaseObserver *iObserver);
- /**
- * gives information about the visibility of a source
- * @param sourceID the sourceID
- * @return true if source is visible
- */
- bool sourceVisible(const am_sourceID_t sourceID) const;
+ /**
+ * gives information about the visibility of a source
+ * @param sourceID the sourceID
+ * @return true if source is visible
+ */
+ bool sourceVisible(const am_sourceID_t sourceID) const;
- /**
- * gives information about the visibility of a sink
- * @param sinkID the sinkID
- * @return true if source is visible
- */
- bool sinkVisible(const am_sinkID_t sinkID) const;
+ /**
+ * gives information about the visibility of a sink
+ * @param sinkID the sinkID
+ * @return true if source is visible
+ */
+ bool sinkVisible(const am_sinkID_t sinkID) const;
private:
- am_timeSync_t calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const;
- bool sqQuery(const std::string& query);
- bool openDatabase(); //!< opens the database
- void createTables(); //!< creates all tables from the static table
- sqlite3 *mDatabase; //!< pointer to the database
- std::string mPath; //!< path to the database
- DatabaseObserver *mDatabaseObserver; //!< pointer to the Observer
- bool mFirstStaticSink;
- bool mFirstStaticSource;
- bool mFirstStaticGateway;
- bool mFirstStaticSinkClass;
- bool mFirstStaticSourceClass;
- typedef std::map<am_gatewayID_t,std::vector<bool> > ListConnectionFormat; //!< type for list of connection formats
- ListConnectionFormat mListConnectionFormat; //!< list of connection formats
+ am_timeSync_t calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const;
+ bool sqQuery(const std::string& query);
+ bool openDatabase(); //!< opens the database
+ void createTables(); //!< creates all tables from the static table
+ sqlite3 *mDatabase; //!< pointer to the database
+ std::string mPath; //!< path to the database
+ DatabaseObserver *mDatabaseObserver; //!< pointer to the Observer
+ bool mFirstStaticSink;
+ bool mFirstStaticSource;
+ bool mFirstStaticGateway;
+ bool mFirstStaticSinkClass;
+ bool mFirstStaticSourceClass;
+ typedef std::map<am_gatewayID_t, std::vector<bool> > ListConnectionFormat; //!< type for list of connection formats
+ ListConnectionFormat mListConnectionFormat; //!< list of connection formats
};
}
diff --git a/AudioManagerDaemon/include/DatabaseObserver.h b/AudioManagerDaemon/include/DatabaseObserver.h
index f35defe..3ccdc0d 100644
--- a/AudioManagerDaemon/include/DatabaseObserver.h
+++ b/AudioManagerDaemon/include/DatabaseObserver.h
@@ -1,33 +1,34 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file DatabaseObserver.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file DatabaseObserver.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#ifndef DATABASEOBSERVER_H_
#define DATABASEOBSERVER_H_
#include <audiomanagertypes.h>
-namespace am {
+namespace am
+{
class TelnetServer;
class CommandSender;
@@ -35,37 +36,38 @@ class RoutingSender;
/**
* This class observes the Database and notifies other classes about important events, mainly the CommandSender.
*/
-class DatabaseObserver {
+class DatabaseObserver
+{
public:
- DatabaseObserver(CommandSender *iCommandSender, RoutingSender *iRoutingSender);
- DatabaseObserver(CommandSender *iCommandSender, RoutingSender *iRoutingSender,TelnetServer *iTelnetServer);
- virtual ~DatabaseObserver();
- void numberOfMainConnectionsChanged() ;
- void numberOfSinkClassesChanged() ;
- void numberOfSourceClassesChanged() ;
- void newSink(am_Sink_s sink);
- void newSource(am_Source_s source);
- void newDomain(am_Domain_s domain);
- void newGateway(am_Gateway_s gateway);
- void newCrossfader(am_Crossfader_s crossfader);
- void removedSink(am_sinkID_t sinkID);
- void removedSource(am_sourceID_t sourceID);
- void removeDomain(am_domainID_t domainID);
- void removeGateway(am_gatewayID_t gatewayID);
- void removeCrossfader(am_crossfaderID_t crossfaderID);
- void mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState) ;
- void mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s SoundProperty) ;
- void mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& SoundProperty) ;
- void sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability) ;
- void sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability) ;
- void volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume) ;
- void sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState) ;
- void systemPropertyChanged(const am_SystemProperty_s& SystemProperty) ;
- void timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time) ;
+ DatabaseObserver(CommandSender *iCommandSender, RoutingSender *iRoutingSender);
+ DatabaseObserver(CommandSender *iCommandSender, RoutingSender *iRoutingSender, TelnetServer *iTelnetServer);
+ virtual ~DatabaseObserver();
+ void numberOfMainConnectionsChanged();
+ void numberOfSinkClassesChanged();
+ void numberOfSourceClassesChanged();
+ void newSink(am_Sink_s sink);
+ void newSource(am_Source_s source);
+ void newDomain(am_Domain_s domain);
+ void newGateway(am_Gateway_s gateway);
+ void newCrossfader(am_Crossfader_s crossfader);
+ void removedSink(am_sinkID_t sinkID);
+ void removedSource(am_sourceID_t sourceID);
+ void removeDomain(am_domainID_t domainID);
+ void removeGateway(am_gatewayID_t gatewayID);
+ void removeCrossfader(am_crossfaderID_t crossfaderID);
+ void mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState);
+ void mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s SoundProperty);
+ void mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& SoundProperty);
+ void sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability);
+ void sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability);
+ void volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume);
+ void sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState);
+ void systemPropertyChanged(const am_SystemProperty_s& SystemProperty);
+ void timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time);
private:
- CommandSender *mCommandSender; //!< pointer to the comandSender
- RoutingSender* mRoutingSender; //!< pointer to the routingSender
- TelnetServer* mTelnetServer; //!< pointer to the telnetserver
+ CommandSender *mCommandSender; //!< pointer to the comandSender
+ RoutingSender* mRoutingSender; //!< pointer to the routingSender
+ TelnetServer* mTelnetServer; //!< pointer to the telnetserver
};
}
diff --git a/AudioManagerDaemon/include/PluginTemplate.h b/AudioManagerDaemon/include/PluginTemplate.h
index cb5aa06..e677acf 100644
--- a/AudioManagerDaemon/include/PluginTemplate.h
+++ b/AudioManagerDaemon/include/PluginTemplate.h
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file pluginTemplate.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file pluginTemplate.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#ifndef PLUGINTEMPLATE_H_
#define PLUGINTEMPLATE_H_
@@ -31,60 +31,62 @@
DLT_IMPORT_CONTEXT(AudioManager)
-namespace am {
+namespace am
+{
/**
* This template tries to load a library and cast ot to a class
* @param libname the full path to the library to be loaded
* @return returns the pointer to the class to be loaded
*/
-template<class T>T* getCreateFunction(const std::string& libname, void*& libraryHandle) {
-
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Trying to load libray with name: "),DLT_STRING(libname.c_str()));
-
- // cut off directories
- char* fileWithPath = const_cast<char*>(libname.c_str());
- std::string libFileName = basename(fileWithPath);
-
- // cut off "lib" in front and cut off .so end"
- std::string createFunctionName = libFileName.substr(3, libFileName.length() - 6) + "Factory";
-
- // open library
- dlerror(); // Clear any existing error
- libraryHandle = dlopen(libname.c_str(), RTLD_LAZY);
- const char* dlopen_error = dlerror();
- if (!libraryHandle || dlopen_error)
- {
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("dlopen failed"),DLT_STRING(dlopen_error));
- return 0;
- }
-
- // get entry point from shared lib
- dlerror(); // Clear any existing error
-
- union
- {
- void* voidPointer;
- T* typedPointer;
- } functionPointer;
-
- // Note: direct cast is not allowed by ISO C++. e.g.
- // T* createFunction = reinterpret_cast<T*>(dlsym(libraryHandle, createFunctionName.c_str()));
- // compiler warning: "forbids casting between pointer-to-function and pointer-to-object"
-
- functionPointer.voidPointer = dlsym(libraryHandle, createFunctionName.c_str());
- T* createFunction = functionPointer.typedPointer;
-
- const char* dlsym_error = dlerror();
- if (!createFunction || dlsym_error)
- {
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("Failed to load shared lib entry point"),DLT_STRING(dlsym_error));
- }
- else
- {
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("loaded successfully plugin"),DLT_STRING(createFunctionName.c_str()));
- }
- return createFunction;
+template<class T> T* getCreateFunction(const std::string& libname, void*& libraryHandle)
+{
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("Trying to load libray with name: "), DLT_STRING(libname.c_str()));
+
+ // cut off directories
+ char* fileWithPath = const_cast<char*>(libname.c_str());
+ std::string libFileName = basename(fileWithPath);
+
+ // cut off "lib" in front and cut off .so end"
+ std::string createFunctionName = libFileName.substr(3, libFileName.length() - 6) + "Factory";
+
+ // open library
+ dlerror(); // Clear any existing error
+ libraryHandle = dlopen(libname.c_str(), RTLD_LAZY);
+ const char* dlopen_error = dlerror();
+ if (!libraryHandle || dlopen_error)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("dlopen failed"), DLT_STRING(dlopen_error));
+ return 0;
+ }
+
+ // get entry point from shared lib
+ dlerror(); // Clear any existing error
+
+ union
+ {
+ void* voidPointer;
+ T* typedPointer;
+ } functionPointer;
+
+ // Note: direct cast is not allowed by ISO C++. e.g.
+ // T* createFunction = reinterpret_cast<T*>(dlsym(libraryHandle, createFunctionName.c_str()));
+ // compiler warning: "forbids casting between pointer-to-function and pointer-to-object"
+
+ functionPointer.voidPointer = dlsym(libraryHandle, createFunctionName.c_str());
+ T* createFunction = functionPointer.typedPointer;
+
+ const char* dlsym_error = dlerror();
+ if (!createFunction || dlsym_error)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("Failed to load shared lib entry point"), DLT_STRING(dlsym_error));
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("loaded successfully plugin"), DLT_STRING(createFunctionName.c_str()));
+ }
+ return createFunction;
}
}
diff --git a/AudioManagerDaemon/include/RoutingReceiver.h b/AudioManagerDaemon/include/RoutingReceiver.h
index a53a4ea..7c59978 100644
--- a/AudioManagerDaemon/include/RoutingReceiver.h
+++ b/AudioManagerDaemon/include/RoutingReceiver.h
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file RoutingReceiver.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file RoutingReceiver.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#ifndef ROUTINGRECEIVER_H_
#define ROUTINGRECEIVER_H_
@@ -28,7 +28,8 @@
#include <routing/RoutingReceiveInterface.h>
#include <config.h>
-namespace am {
+namespace am
+{
class SocketHandler;
class DBusWrapper;
@@ -39,56 +40,57 @@ class ControlSender;
/**
* Implements the Receiving side of the RoutingPlugins.
*/
-class RoutingReceiver : public RoutingReceiveInterface {
+class RoutingReceiver: public RoutingReceiveInterface
+{
public:
- RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, SocketHandler *iSocketHandler);
- RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, DBusWrapper *iDBusWrapper);
- RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender,SocketHandler *iSocketHandler,DBusWrapper *iDBusWrapper);
- virtual ~RoutingReceiver();
- void ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error) ;
- void ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error) ;
- void ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error) ;
- void ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error) ;
- void ackSetSourceState(const am_Handle_s handle, const am_Error_e error) ;
- void ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error) ;
- void ackSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error) ;
- void ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error) ;
- void ackSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error) ;
- void ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error) ;
- void ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume) ;
- void ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume) ;
- am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID) ;
- am_Error_e registerDomain(const am_Domain_s& domainData, am_domainID_t& domainID) ;
- am_Error_e deregisterDomain(const am_domainID_t domainID) ;
- am_Error_e registerGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) ;
- am_Error_e deregisterGateway(const am_gatewayID_t gatewayID) ;
- am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID) ;
- am_Error_e registerSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID) ;
- am_Error_e deregisterSink(const am_sinkID_t sinkID) ;
- am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID) ;
- am_Error_e registerSource(const am_Source_s& sourceData, am_sourceID_t& sourceID) ;
- am_Error_e deregisterSource(const am_sourceID_t sourceID) ;
- am_Error_e registerCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ;
- am_Error_e deregisterCrossfader(const am_crossfaderID_t crossfaderID) ;
- am_Error_e peekSinkClassID(const std::string name, const am_sinkClass_t& sinkClassID) ;
- am_Error_e peekSourceClassID(const std::string name, const am_sourceClass_t& sourceClassID) ;
- void hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState) ;
- void hookDomainRegistrationComplete(const am_domainID_t domainID) ;
- void hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s& availability) ;
- void hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s& availability) ;
- void hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState) ;
- void hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay) ;
- am_Error_e sendChangedData(const std::vector<am_EarlyData_s>& earlyData) ;
- am_Error_e getDBusConnectionWrapper(DBusWrapper*& dbusConnectionWrapper) const ;
- am_Error_e getSocketHandler(SocketHandler*& socketHandler) const;
- uint16_t getInterfaceVersion() const;
+ RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, SocketHandler *iSocketHandler);
+ RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, DBusWrapper *iDBusWrapper);
+ RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, SocketHandler *iSocketHandler, DBusWrapper *iDBusWrapper);
+ virtual ~RoutingReceiver();
+ void ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error);
+ void ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error);
+ void ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error);
+ void ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error);
+ void ackSetSourceState(const am_Handle_s handle, const am_Error_e error);
+ void ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error);
+ void ackSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error);
+ void ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error);
+ void ackSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error);
+ void ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error);
+ void ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume);
+ void ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume);
+ am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID);
+ am_Error_e registerDomain(const am_Domain_s& domainData, am_domainID_t& domainID);
+ am_Error_e deregisterDomain(const am_domainID_t domainID);
+ am_Error_e registerGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID);
+ am_Error_e deregisterGateway(const am_gatewayID_t gatewayID);
+ am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID);
+ am_Error_e registerSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID);
+ am_Error_e deregisterSink(const am_sinkID_t sinkID);
+ am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID);
+ am_Error_e registerSource(const am_Source_s& sourceData, am_sourceID_t& sourceID);
+ am_Error_e deregisterSource(const am_sourceID_t sourceID);
+ am_Error_e registerCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID);
+ am_Error_e deregisterCrossfader(const am_crossfaderID_t crossfaderID);
+ am_Error_e peekSinkClassID(const std::string name, const am_sinkClass_t& sinkClassID);
+ am_Error_e peekSourceClassID(const std::string name, const am_sourceClass_t& sourceClassID);
+ void hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState);
+ void hookDomainRegistrationComplete(const am_domainID_t domainID);
+ void hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s& availability);
+ void hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s& availability);
+ void hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState);
+ void hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay);
+ am_Error_e sendChangedData(const std::vector<am_EarlyData_s>& earlyData);
+ am_Error_e getDBusConnectionWrapper(DBusWrapper*& dbusConnectionWrapper) const;
+ am_Error_e getSocketHandler(SocketHandler*& socketHandler) const;
+ uint16_t getInterfaceVersion() const;
private:
- DatabaseHandler *mDatabaseHandler; //!< pointer to the databaseHandler
- RoutingSender *mRoutingSender; //!< pointer to the routingSender
- ControlSender *mControlSender; //!< pointer to the controlSender
- SocketHandler *mSocketHandler; //!< pointer to sockethandler
- DBusWrapper *mDBusWrapper; //!< pointer to dbuswrapper
+ DatabaseHandler *mDatabaseHandler; //!< pointer to the databaseHandler
+ RoutingSender *mRoutingSender; //!< pointer to the routingSender
+ ControlSender *mControlSender; //!< pointer to the controlSender
+ SocketHandler *mSocketHandler; //!< pointer to sockethandler
+ DBusWrapper *mDBusWrapper; //!< pointer to dbuswrapper
};
diff --git a/AudioManagerDaemon/include/RoutingSender.h b/AudioManagerDaemon/include/RoutingSender.h
index 459fe84..0888b6a 100644
--- a/AudioManagerDaemon/include/RoutingSender.h
+++ b/AudioManagerDaemon/include/RoutingSender.h
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file RoutingSender.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file RoutingSender.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#ifndef ROUTINGSENDER_H_
#define ROUTINGSENDER_H_
@@ -32,146 +32,147 @@
#include "../test/RoutingInterfaceBackdoor.h"
#endif
-namespace am {
+namespace am
+{
/**
* Implements the RoutingSendInterface. Loads all plugins and dispatches calls to the plugins
*/
-class RoutingSender {
+class RoutingSender
+{
public:
- RoutingSender(const std::vector<std::string>& listOfPluginDirectories);
- virtual ~RoutingSender();
-
- /**
- * removes a handle from the list
- * @param handle to be removed
- * @return E_OK in case of success
- */
- am_Error_e removeHandle(const am_Handle_s& handle);
-
- /**
- * @author Christian
- * this adds the domain to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
- * This must be done whenever a domain is registered.
- */
- am_Error_e addDomainLookup(const am_Domain_s& domainData);
- /**
- * @author Christian
- * this adds the Source to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
- * This must be done whenever a Source is registered.
- */
- am_Error_e addSourceLookup(const am_Source_s& sourceData);
- /**
- * @author Christian
- * this adds the Sink to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
- * This must be done whenever a Sink is registered.
- */
- am_Error_e addSinkLookup(const am_Sink_s& sinkData);
- /**
- * @author Christian
- * this adds the Crossfader to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
- * This must be done whenever a Crossfader is registered.
- */
- am_Error_e addCrossfaderLookup(const am_Crossfader_s& crossfaderData);
- /**
- * @author Christian
- * this removes the Domain to the lookup table of the Router. This must be done everytime a domain is deregistered.
- */
- am_Error_e removeDomainLookup(const am_domainID_t domainID);
- /**
- * @author Christian
- * this removes the Source to the lookup table of the Router. This must be done everytime a source is deregistered.
- */
- am_Error_e removeSourceLookup(const am_sourceID_t sourceID);
- /**
- * @author Christian
- * this removes the Sink to the lookup table of the Router. This must be done everytime a sink is deregistered.
- */
- am_Error_e removeSinkLookup(const am_sinkID_t sinkID);
- /**
- * @author Christian
- * this removes the Crossfader to the lookup table of the Router. This must be done everytime a crossfader is deregistered.
- */
- am_Error_e removeCrossfaderLookup(const am_crossfaderID_t crossfaderID);
- void startupRoutingInterface(RoutingReceiveInterface* routingreceiveinterface) ;
- void routingInterfacesReady() ;
- void routingInterfacesRundown() ;
- am_Error_e asyncAbort(const am_Handle_s& handle) ;
- am_Error_e asyncConnect(am_Handle_s& handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat) ;
- am_Error_e asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID) ;
- am_Error_e asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) ;
- am_Error_e asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) ;
- am_Error_e asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state) ;
- am_Error_e asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty) ;
- am_Error_e asyncSetSourceSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sourceID_t sourceID) ;
- am_Error_e asyncSetSinkSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sinkID_t sinkID) ;
- am_Error_e asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty) ;
- am_Error_e asyncCrossFade(am_Handle_s& handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time) ;
- am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState) ;
- am_Error_e getListHandles(std::vector<am_Handle_s> & listHandles) const ;
- am_Error_e getListPlugins(std::vector<std::string>& interfaces) const;
- uint16_t getInterfaceVersion() const;
-
- //!< is used to pair interfaces with busnames
- struct InterfaceNamePairs
- {
- RoutingSendInterface* routingInterface;
- std::string busName;
- };
-
- //!< is used to store data related to handles
- class am_handleData_c
- {
- public:
- union
- {
- am_sinkID_t sinkID;
- am_sourceID_t sourceID;
- am_crossfaderID_t crossfaderID;
- am_connectionID_t connectionID;
- };
- union
- {
- am_SoundProperty_s soundPropery;
- am_SourceState_e sourceState;
- am_volume_t volume;
- am_HotSink_e hotSink;
- std::vector<am_SoundProperty_s>* soundProperties;
- };
-
- };
-
+ RoutingSender(const std::vector<std::string>& listOfPluginDirectories);
+ virtual ~RoutingSender();
+
+ /**
+ * removes a handle from the list
+ * @param handle to be removed
+ * @return E_OK in case of success
+ */
+ am_Error_e removeHandle(const am_Handle_s& handle);
+
+ /**
+ * @author Christian
+ * this adds the domain to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
+ * This must be done whenever a domain is registered.
+ */
+ am_Error_e addDomainLookup(const am_Domain_s& domainData);
+ /**
+ * @author Christian
+ * this adds the Source to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
+ * This must be done whenever a Source is registered.
+ */
+ am_Error_e addSourceLookup(const am_Source_s& sourceData);
+ /**
+ * @author Christian
+ * this adds the Sink to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
+ * This must be done whenever a Sink is registered.
+ */
+ am_Error_e addSinkLookup(const am_Sink_s& sinkData);
+ /**
+ * @author Christian
+ * this adds the Crossfader to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
+ * This must be done whenever a Crossfader is registered.
+ */
+ am_Error_e addCrossfaderLookup(const am_Crossfader_s& crossfaderData);
+ /**
+ * @author Christian
+ * this removes the Domain to the lookup table of the Router. This must be done everytime a domain is deregistered.
+ */
+ am_Error_e removeDomainLookup(const am_domainID_t domainID);
+ /**
+ * @author Christian
+ * this removes the Source to the lookup table of the Router. This must be done everytime a source is deregistered.
+ */
+ am_Error_e removeSourceLookup(const am_sourceID_t sourceID);
+ /**
+ * @author Christian
+ * this removes the Sink to the lookup table of the Router. This must be done everytime a sink is deregistered.
+ */
+ am_Error_e removeSinkLookup(const am_sinkID_t sinkID);
+ /**
+ * @author Christian
+ * this removes the Crossfader to the lookup table of the Router. This must be done everytime a crossfader is deregistered.
+ */
+ am_Error_e removeCrossfaderLookup(const am_crossfaderID_t crossfaderID);
+ void startupRoutingInterface(RoutingReceiveInterface* routingreceiveinterface);
+ void routingInterfacesReady();
+ void routingInterfacesRundown();
+ am_Error_e asyncAbort(const am_Handle_s& handle);
+ am_Error_e asyncConnect(am_Handle_s& handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat);
+ am_Error_e asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID);
+ am_Error_e asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time);
+ am_Error_e asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time);
+ am_Error_e asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state);
+ am_Error_e asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty);
+ am_Error_e asyncSetSourceSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sourceID_t sourceID);
+ am_Error_e asyncSetSinkSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sinkID_t sinkID);
+ am_Error_e asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty);
+ am_Error_e asyncCrossFade(am_Handle_s& handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time);
+ am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState);
+ am_Error_e getListHandles(std::vector<am_Handle_s> & listHandles) const;
+ am_Error_e getListPlugins(std::vector<std::string>& interfaces) const;
+ uint16_t getInterfaceVersion() const;
+
+ //!< is used to pair interfaces with busnames
+ struct InterfaceNamePairs
+ {
+ RoutingSendInterface* routingInterface;
+ std::string busName;
+ };
+
+ //!< is used to store data related to handles
+ class am_handleData_c
+ {
+ public:
+ union
+ {
+ am_sinkID_t sinkID;
+ am_sourceID_t sourceID;
+ am_crossfaderID_t crossfaderID;
+ am_connectionID_t connectionID;
+ };
+ union
+ {
+ am_SoundProperty_s soundPropery;
+ am_SourceState_e sourceState;
+ am_volume_t volume;
+ am_HotSink_e hotSink;
+ std::vector<am_SoundProperty_s>* soundProperties;
+ };
+
+ };
#ifdef UNIT_TEST //this is needed to test RoutingSender
- friend class RoutingInterfaceBackdoor;
+ friend class RoutingInterfaceBackdoor;
#endif
- /**
- * returns the data that belong to handles
- * @param handle the handle
- * @return a class holding the handle data
- */
- am_handleData_c returnHandleData(const am_Handle_s handle) const;
+ /**
+ * returns the data that belong to handles
+ * @param handle the handle
+ * @return a class holding the handle data
+ */
+ am_handleData_c returnHandleData(const am_Handle_s handle) const;
private:
- //!< is needed to sort the handles in the map
- struct comparator
- {
- bool operator()(const am_Handle_s& a, const am_Handle_s& b) const
- {
- return (a.handle < b.handle);
- }
- };
-
- /**
- * creates a handle and adds it to the list of handles
- * @param handleData the data that should be saves together with the handle
- * @param type the type of handle to be created
- * @return the handle
- */
- am_Handle_s createHandle(const am_handleData_c& handleData, const am_Handle_e type);
- void unloadLibraries(void); //!< unloads all loaded plugins
+ //!< is needed to sort the handles in the map
+ struct comparator
+ {
+ bool operator()(const am_Handle_s& a, const am_Handle_s& b) const
+ {
+ return (a.handle < b.handle);
+ }
+ };
+
+ /**
+ * creates a handle and adds it to the list of handles
+ * @param handleData the data that should be saves together with the handle
+ * @param type the type of handle to be created
+ * @return the handle
+ */
+ am_Handle_s createHandle(const am_handleData_c& handleData, const am_Handle_e type);
+ void unloadLibraries(void); //!< unloads all loaded plugins
typedef std::map<am_domainID_t, RoutingSendInterface*> DomainInterfaceMap; //!< maps domains to interfaces
typedef std::map<am_sinkID_t, RoutingSendInterface*> SinkInterfaceMap; //!< maps sinks to interfaces
@@ -179,12 +180,12 @@ private:
typedef std::map<am_crossfaderID_t, RoutingSendInterface*> CrossfaderInterfaceMap; //!< maps crossfaders to interfaces
typedef std::map<am_connectionID_t, RoutingSendInterface*> ConnectionInterfaceMap; //!< maps connections to interfaces
typedef std::map<uint16_t, RoutingSendInterface*> HandleInterfaceMap; //!< maps handles to interfaces
- typedef std::map<am_Handle_s,am_handleData_c,comparator> HandlesMap; //!< maps handleData to handles
+ typedef std::map<am_Handle_s, am_handleData_c, comparator> HandlesMap; //!< maps handleData to handles
int16_t mHandleCount; //!< is used to create handles
HandlesMap mlistActiveHandles; //!< list of all currently "running" handles.
- std::vector<void*> mListLibraryHandles; //!< list of all loaded pluginInterfaces
- std::vector<InterfaceNamePairs> mListInterfaces; //!< list of busname/interface relation
+ std::vector<void*> mListLibraryHandles; //!< list of all loaded pluginInterfaces
+ std::vector<InterfaceNamePairs> mListInterfaces; //!< list of busname/interface relation
ConnectionInterfaceMap mMapConnectionInterface; //!< map of connection to interfaces
CrossfaderInterfaceMap mMapCrossfaderInterface; //!< map of crossfaders to interface
DomainInterfaceMap mMapDomainInterface; //!< map of domains to interfaces
diff --git a/AudioManagerDaemon/include/TelnetServer.h b/AudioManagerDaemon/include/TelnetServer.h
index 9b7d097..b4ea078 100644
--- a/AudioManagerDaemon/include/TelnetServer.h
+++ b/AudioManagerDaemon/include/TelnetServer.h
@@ -1,27 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file TelnetServer.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
-
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file TelnetServer.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#ifndef TELNETSERVER_H_
#define TELNETSERVER_H_
@@ -30,7 +29,8 @@
#include <queue>
#include <map>
-namespace am {
+namespace am
+{
class DatabaseHandler;
class CommandSender;
@@ -43,45 +43,45 @@ class ControlReceiver;
class TelnetServer
{
public:
- TelnetServer(SocketHandler *iSocketHandler,CommandSender *iCommandSender,CommandReceiver *iCommandReceiver, RoutingSender *iRoutingSender,RoutingReceiver *iRoutingReceiver,ControlSender *iControlSender, ControlReceiver *iControlReceiver,DatabaseHandler *iDatabasehandler,unsigned int servPort, unsigned int maxConnections);
- virtual ~TelnetServer();
- void connectSocket(const pollfd pfd,const sh_pollHandle_t handle, void* userData);
- void receiveData(const pollfd pfd,const sh_pollHandle_t handle, void* userData);
- bool dispatchData(const sh_pollHandle_t handle, void* userData);
- bool check(const sh_pollHandle_t handle, void* userData);
- shPollFired_T<TelnetServer> telnetConnectFiredCB;
- shPollFired_T<TelnetServer> telnetReceiveFiredCB;
- shPollDispatch_T<TelnetServer> telnetDispatchCB;
- shPollCheck_T<TelnetServer> telnetCheckCB;
+ TelnetServer(SocketHandler *iSocketHandler, CommandSender *iCommandSender, CommandReceiver *iCommandReceiver, RoutingSender *iRoutingSender, RoutingReceiver *iRoutingReceiver, ControlSender *iControlSender, ControlReceiver *iControlReceiver, DatabaseHandler *iDatabasehandler, unsigned int servPort, unsigned int maxConnections);
+ virtual ~TelnetServer();
+ void connectSocket(const pollfd pfd, const sh_pollHandle_t handle, void* userData);
+ void receiveData(const pollfd pfd, const sh_pollHandle_t handle, void* userData);
+ bool dispatchData(const sh_pollHandle_t handle, void* userData);
+ bool check(const sh_pollHandle_t handle, void* userData);
+ shPollFired_T<TelnetServer> telnetConnectFiredCB;
+ shPollFired_T<TelnetServer> telnetReceiveFiredCB;
+ shPollDispatch_T<TelnetServer> telnetDispatchCB;
+ shPollCheck_T<TelnetServer> telnetCheckCB;
private:
- typedef void (*CommandPrototype)(std::vector<std::string>& msg,int filedescriptor);
- typedef std::map<std::string,CommandPrototype> mMapCommand_t;
- static void listCommand(std::vector<std::string>& msg,int filedescriptor);
- void listCommandShadow(std::vector<std::string>& msg,int filedescriptor);
- void sliceCommand(const std::string& string,std::string& command,std::vector<std::string>& msg);
- mMapCommand_t createCommandMap();
- struct connection_s
- {
- int filedescriptor;
- sh_pollHandle_t handle;
- };
+ typedef void (*CommandPrototype)(std::vector<std::string>& msg, int filedescriptor);
+ typedef std::map<std::string, CommandPrototype> mMapCommand_t;
+ static void listCommand(std::vector<std::string>& msg, int filedescriptor);
+ void listCommandShadow(std::vector<std::string>& msg, int filedescriptor);
+ void sliceCommand(const std::string& string, std::string& command, std::vector<std::string>& msg);
+ mMapCommand_t createCommandMap();
+ struct connection_s
+ {
+ int filedescriptor;
+ sh_pollHandle_t handle;
+ };
- static TelnetServer* instance;
- SocketHandler *mSocketHandler;
- CommandSender *mCommandSender;
- CommandReceiver *mCommandReceiver;
- RoutingSender *mRoutingSender;
- RoutingReceiver *mRoutingReceiver;
- ControlSender *mControlSender;
- ControlReceiver *mControlReceiver;
- DatabaseHandler *mDatabasehandler;
- sh_pollHandle_t mConnecthandle;
- std::queue<std::string> msgList;
- std::vector<connection_s> mListConnections;
- int mConnectFD;
- unsigned int mServerPort;
- unsigned int mMaxConnections;
- mMapCommand_t mMapCommands;
+ static TelnetServer* instance;
+ SocketHandler *mSocketHandler;
+ CommandSender *mCommandSender;
+ CommandReceiver *mCommandReceiver;
+ RoutingSender *mRoutingSender;
+ RoutingReceiver *mRoutingReceiver;
+ ControlSender *mControlSender;
+ ControlReceiver *mControlReceiver;
+ DatabaseHandler *mDatabasehandler;
+ sh_pollHandle_t mConnecthandle;
+ std::queue<std::string> msgList;
+ std::vector<connection_s> mListConnections;
+ int mConnectFD;
+ unsigned int mServerPort;
+ unsigned int mMaxConnections;
+ mMapCommand_t mMapCommands;
};
diff --git a/AudioManagerDaemon/src/CommandReceiver.cpp b/AudioManagerDaemon/src/CommandReceiver.cpp
index 15d2430..46d1714 100644
--- a/AudioManagerDaemon/src/CommandReceiver.cpp
+++ b/AudioManagerDaemon/src/CommandReceiver.cpp
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file CommandReveiver.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file CommandReveiver.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#include "CommandReceiver.h"
#include "DatabaseHandler.h"
@@ -34,36 +34,36 @@ DLT_IMPORT_CONTEXT(AudioManager)
using namespace am;
-am::CommandReceiver::CommandReceiver(DatabaseHandler *iDatabaseHandler, ControlSender *iControlSender, DBusWrapper *iDBusWrapper)
-: mDatabaseHandler(iDatabaseHandler),
- mControlSender(iControlSender),
- mDBusWrapper(iDBusWrapper)
+CommandReceiver::CommandReceiver(DatabaseHandler *iDatabaseHandler, ControlSender *iControlSender, DBusWrapper *iDBusWrapper) :
+ mDatabaseHandler(iDatabaseHandler), //
+ mControlSender(iControlSender), //
+ mDBusWrapper(iDBusWrapper)
{
-assert(mDatabaseHandler!=NULL);
-assert(mDBusWrapper!=NULL);
-assert(mControlSender!=NULL);
+ assert(mDatabaseHandler!=NULL);
+ assert(mDBusWrapper!=NULL);
+ assert(mControlSender!=NULL);
}
-am::CommandReceiver::CommandReceiver(DatabaseHandler *iDatabaseHandler, ControlSender *iControlSender, SocketHandler *iSocketHandler)
-: mDatabaseHandler(iDatabaseHandler),
- mControlSender(iControlSender),
- mSocketHandler(iSocketHandler)
+CommandReceiver::CommandReceiver(DatabaseHandler *iDatabaseHandler, ControlSender *iControlSender, SocketHandler *iSocketHandler) :
+ mDatabaseHandler(iDatabaseHandler), //
+ mControlSender(iControlSender), //
+ mSocketHandler(iSocketHandler)
{
-assert(mDatabaseHandler!=NULL);
-assert(mSocketHandler!=NULL);
-assert(mControlSender!=NULL);
+ assert(mDatabaseHandler!=NULL);
+ assert(mSocketHandler!=NULL);
+ assert(mControlSender!=NULL);
}
-am::CommandReceiver::CommandReceiver(DatabaseHandler *iDatabaseHandler, ControlSender *iControlSender, SocketHandler *iSocketHandler, DBusWrapper *iDBusWrapper)
-: mDatabaseHandler(iDatabaseHandler),
- mControlSender(iControlSender),
- mDBusWrapper(iDBusWrapper),
- mSocketHandler(iSocketHandler)
+CommandReceiver::CommandReceiver(DatabaseHandler *iDatabaseHandler, ControlSender *iControlSender, SocketHandler *iSocketHandler, DBusWrapper *iDBusWrapper) :
+ mDatabaseHandler(iDatabaseHandler), //
+ mControlSender(iControlSender), //
+ mDBusWrapper(iDBusWrapper), //
+ mSocketHandler(iSocketHandler)
{
-assert(mDatabaseHandler!=NULL);
-assert(mSocketHandler!=NULL);
-assert(mControlSender!=NULL);
-assert(mDBusWrapper!=NULL);
+ assert(mDatabaseHandler!=NULL);
+ assert(mSocketHandler!=NULL);
+ assert(mControlSender!=NULL);
+ assert(mDBusWrapper!=NULL);
}
CommandReceiver::~CommandReceiver()
@@ -72,162 +72,120 @@ CommandReceiver::~CommandReceiver()
am_Error_e CommandReceiver::connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t & mainConnectionID)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::connect got called:"),DLT_STRING("sourceID"),DLT_INT(sourceID), DLT_STRING("sinkID"), DLT_INT(sinkID));
- return mControlSender->hookUserConnectionRequest(sourceID,sinkID,mainConnectionID);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("CommandReceiver::connect got called:"), DLT_STRING("sourceID"), DLT_INT(sourceID), DLT_STRING("sinkID"), DLT_INT(sinkID));
+ return mControlSender->hookUserConnectionRequest(sourceID, sinkID, mainConnectionID);
}
-
-
am_Error_e CommandReceiver::disconnect(const am_mainConnectionID_t mainConnectionID)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::disconnect got called, mainConnectionID="),DLT_INT(mainConnectionID));
- return mControlSender->hookUserDisconnectionRequest(mainConnectionID);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("CommandReceiver::disconnect got called, mainConnectionID="), DLT_INT(mainConnectionID));
+ return mControlSender->hookUserDisconnectionRequest(mainConnectionID);
}
-
-
am_Error_e CommandReceiver::setVolume(const am_sinkID_t sinkID, const am_mainVolume_t volume)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::setVolume got called, sinkID="),DLT_INT(sinkID),DLT_STRING("volume="),DLT_INT(volume));
- return mControlSender->hookUserVolumeChange(sinkID,volume);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("CommandReceiver::setVolume got called, sinkID="), DLT_INT(sinkID), DLT_STRING("volume="), DLT_INT(volume));
+ return mControlSender->hookUserVolumeChange(sinkID, volume);
}
-
-
am_Error_e CommandReceiver::volumeStep(const am_sinkID_t sinkID, const int16_t volumeStep)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::volumeStep got called, sinkID="),DLT_INT(sinkID),DLT_STRING("volumeStep="),DLT_INT(volumeStep));
- return mControlSender->hookUserVolumeStep(sinkID,volumeStep);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("CommandReceiver::volumeStep got called, sinkID="), DLT_INT(sinkID), DLT_STRING("volumeStep="), DLT_INT(volumeStep));
+ return mControlSender->hookUserVolumeStep(sinkID, volumeStep);
}
-
-
am_Error_e CommandReceiver::setSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::setSinkMuteState got called, sinkID="),DLT_INT(sinkID),DLT_STRING("muteState="),DLT_INT(muteState));
- return mControlSender->hookUserSetSinkMuteState(sinkID,muteState);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("CommandReceiver::setSinkMuteState got called, sinkID="), DLT_INT(sinkID), DLT_STRING("muteState="), DLT_INT(muteState));
+ return mControlSender->hookUserSetSinkMuteState(sinkID, muteState);
}
-
-
am_Error_e CommandReceiver::setMainSinkSoundProperty(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::setMainSinkSoundProperty got called, sinkID="),DLT_INT(sinkID),DLT_STRING("soundPropertyType="),DLT_INT(soundProperty.type),DLT_STRING("soundPropertyValue="),DLT_INT(soundProperty.value));
- return mControlSender->hookUserSetMainSinkSoundProperty(sinkID,soundProperty);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("CommandReceiver::setMainSinkSoundProperty got called, sinkID="), DLT_INT(sinkID), DLT_STRING("soundPropertyType="), DLT_INT(soundProperty.type), DLT_STRING("soundPropertyValue="), DLT_INT(soundProperty.value));
+ return mControlSender->hookUserSetMainSinkSoundProperty(sinkID, soundProperty);
}
-
-
am_Error_e CommandReceiver::setMainSourceSoundProperty(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::setMainSourceSoundProperty got called, sourceID="),DLT_INT(sourceID),DLT_STRING("soundPropertyType="),DLT_INT(soundProperty.type),DLT_STRING("soundPropertyValue="),DLT_INT(soundProperty.value));
- return mControlSender->hookUserSetMainSourceSoundProperty(sourceID,soundProperty);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("CommandReceiver::setMainSourceSoundProperty got called, sourceID="), DLT_INT(sourceID), DLT_STRING("soundPropertyType="), DLT_INT(soundProperty.type), DLT_STRING("soundPropertyValue="), DLT_INT(soundProperty.value));
+ return mControlSender->hookUserSetMainSourceSoundProperty(sourceID, soundProperty);
}
-
-
am_Error_e CommandReceiver::setSystemProperty(const am_SystemProperty_s & property)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::setSystemProperty got called"),DLT_STRING("type="),DLT_INT(property.type),DLT_STRING("soundPropertyValue="),DLT_INT(property.value));
- return mControlSender->hookUserSetSystemProperty(property);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("CommandReceiver::setSystemProperty got called"), DLT_STRING("type="), DLT_INT(property.type), DLT_STRING("soundPropertyValue="), DLT_INT(property.value));
+ return mControlSender->hookUserSetSystemProperty(property);
}
-
-
am_Error_e CommandReceiver::getListMainConnections(std::vector<am_MainConnectionType_s> & listConnections) const
{
- return mDatabaseHandler->getListVisibleMainConnections(listConnections);
+ return mDatabaseHandler->getListVisibleMainConnections(listConnections);
}
-
-
am_Error_e CommandReceiver::getListMainSinks(std::vector<am_SinkType_s>& listMainSinks) const
{
- return mDatabaseHandler->getListMainSinks(listMainSinks);
+ return mDatabaseHandler->getListMainSinks(listMainSinks);
}
-
-
am_Error_e CommandReceiver::getListMainSources(std::vector<am_SourceType_s>& listMainSources) const
{
- return mDatabaseHandler->getListMainSources(listMainSources);
+ return mDatabaseHandler->getListMainSources(listMainSources);
}
-
-
am_Error_e CommandReceiver::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> & listSoundProperties) const
{
- return mDatabaseHandler->getListMainSinkSoundProperties(sinkID,listSoundProperties);
+ return mDatabaseHandler->getListMainSinkSoundProperties(sinkID, listSoundProperties);
}
-
-
am_Error_e CommandReceiver::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> & listSourceProperties) const
{
- return mDatabaseHandler->getListMainSourceSoundProperties(sourceID,listSourceProperties);
+ return mDatabaseHandler->getListMainSourceSoundProperties(sourceID, listSourceProperties);
}
-
-
am_Error_e CommandReceiver::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const
{
- return mDatabaseHandler->getListSourceClasses(listSourceClasses);
+ return mDatabaseHandler->getListSourceClasses(listSourceClasses);
}
-
-
am_Error_e CommandReceiver::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const
{
- return mDatabaseHandler->getListSinkClasses(listSinkClasses);
+ return mDatabaseHandler->getListSinkClasses(listSinkClasses);
}
-
-
am_Error_e CommandReceiver::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const
{
- return mDatabaseHandler->getListSystemProperties(listSystemProperties);
+ return mDatabaseHandler->getListSystemProperties(listSystemProperties);
}
-
-
am_Error_e CommandReceiver::getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t & delay) const
{
- return mDatabaseHandler->getTimingInformation(mainConnectionID,delay);
+ return mDatabaseHandler->getTimingInformation(mainConnectionID, delay);
}
am_Error_e CommandReceiver::getDBusConnectionWrapper(DBusWrapper*& dbusConnectionWrapper) const
{
#ifdef WITH_DBUS_WRAPPER
- dbusConnectionWrapper=mDBusWrapper;
- return E_OK;
+ dbusConnectionWrapper = mDBusWrapper;
+ return E_OK;
#else
- return E_UNKNOWN;
+ return E_UNKNOWN;
#endif /*WITH_DBUS_WRAPPER*/
}
am_Error_e CommandReceiver::getSocketHandler(SocketHandler *& socketHandler) const
{
#ifdef WITH_SOCKETHANDLER_LOOP
- socketHandler=mSocketHandler;
- return E_OK;
+ socketHandler = mSocketHandler;
+ return E_OK;
#else
- return E_UNKNOWN;
+ return E_UNKNOWN;
#endif /*WITH_SOCKETHANDLER_LOOP*/
}
uint16_t CommandReceiver::getInterfaceVersion() const
{
- return CommandReceiveVersion;
+ return CommandReceiveVersion;
}
-
-
-
-
-
-
-
-
-
-
diff --git a/AudioManagerDaemon/src/CommandSender.cpp b/AudioManagerDaemon/src/CommandSender.cpp
index a481317..a02d3f8 100644
--- a/AudioManagerDaemon/src/CommandSender.cpp
+++ b/AudioManagerDaemon/src/CommandSender.cpp
@@ -1,27 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file CommandSender.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
-
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file CommandSender.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#include "CommandSender.h"
#include "command/CommandReceiveInterface.h"
@@ -43,44 +42,44 @@ DLT_IMPORT_CONTEXT(AudioManager)
(*iter)->__VA_ARGS__; \
}
-CommandSender::CommandSender(const std::vector<std::string>& listOfPluginDirectories)
- :mListInterfaces(),
- mListLibraryHandles()
+CommandSender::CommandSender(const std::vector<std::string>& listOfPluginDirectories) :
+ mListInterfaces(), //
+ mListLibraryHandles()
{
- std::vector<std::string> sharedLibraryNameList;
+ std::vector<std::string> sharedLibraryNameList;
std::vector<std::string>::const_iterator dirIter = listOfPluginDirectories.begin();
std::vector<std::string>::const_iterator dirIterEnd = listOfPluginDirectories.end();
// search communicator plugins in configured directories
for (; dirIter < dirIterEnd; ++dirIter)
{
- const char* directoryName = dirIter->c_str();
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Searching for CommandPlugins in"),DLT_STRING(directoryName));
- DIR *directory = opendir(directoryName);
-
- if (!directory)
- {
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Error opening directory "),DLT_STRING(directoryName));
- continue;
- }
+ const char* directoryName = dirIter->c_str();
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("Searching for CommandPlugins in"), DLT_STRING(directoryName));
+ DIR *directory = opendir(directoryName);
+
+ if (!directory)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("Error opening directory "), DLT_STRING(directoryName));
+ continue;
+ }
// iterate content of directory
struct dirent *itemInDirectory = 0;
while ((itemInDirectory = readdir(directory)))
{
- unsigned char entryType = itemInDirectory->d_type;
- std::string entryName = itemInDirectory->d_name;
+ unsigned char entryType = itemInDirectory->d_type;
+ std::string entryName = itemInDirectory->d_name;
- bool regularFile = (entryType == DT_REG || entryType== DT_LNK);
- bool sharedLibExtension = ("so" == entryName.substr(entryName.find_last_of(".") + 1));
+ bool regularFile = (entryType == DT_REG || entryType == DT_LNK);
+ bool sharedLibExtension = ("so" == entryName.substr(entryName.find_last_of(".") + 1));
- if (regularFile && sharedLibExtension)
- {
- std::string name(directoryName);
- sharedLibraryNameList.push_back(name + "/" + entryName);
- }
+ if (regularFile && sharedLibExtension)
+ {
+ std::string name(directoryName);
+ sharedLibraryNameList.push_back(name + "/" + entryName);
+ }
}
- closedir(directory);
+ closedir(directory);
}
// iterate all communicator plugins and start them
@@ -89,14 +88,14 @@ CommandSender::CommandSender(const std::vector<std::string>& listOfPluginDirecto
for (; iter < iterEnd; ++iter)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Loading CommandSender plugin"),DLT_STRING(iter->c_str()));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("Loading CommandSender plugin"), DLT_STRING(iter->c_str()));
CommandSendInterface* (*createFunc)();
- void* tempLibHandle=NULL;
- createFunc = getCreateFunction<CommandSendInterface*()>(*iter,tempLibHandle);
+ void* tempLibHandle = NULL;
+ createFunc = getCreateFunction<CommandSendInterface*()>(*iter, tempLibHandle);
if (!createFunc)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Entry point of CommandPlugin not found"),DLT_STRING(iter->c_str()));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("Entry point of CommandPlugin not found"), DLT_STRING(iter->c_str()));
continue;
}
@@ -104,15 +103,15 @@ CommandSender::CommandSender(const std::vector<std::string>& listOfPluginDirecto
if (!commander)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandPlugin initialization failed. Entry Function not callable"));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("CommandPlugin initialization failed. Entry Function not callable"));
continue;
}
//check libversion
- if (commander->getInterfaceVersion()<REQUIRED_INTERFACE_VERSION)
+ if (commander->getInterfaceVersion() < REQUIRED_INTERFACE_VERSION)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingPlugin initialization failed. Version of Interface to old"));
- continue;
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("RoutingPlugin initialization failed. Version of Interface to old"));
+ continue;
}
mListInterfaces.push_back(commander);
@@ -122,161 +121,135 @@ CommandSender::CommandSender(const std::vector<std::string>& listOfPluginDirecto
CommandSender::~CommandSender()
{
- unloadLibraries();
+ unloadLibraries();
}
-
am_Error_e CommandSender::stopInterface()
{
- am_Error_e returnError=E_OK;
-
- std::vector<CommandSendInterface*>::iterator iter = mListInterfaces.begin();
- std::vector<CommandSendInterface*>::iterator iterEnd = mListInterfaces.end();
- for (; iter<iterEnd;++iter)
- {
- am_Error_e error=(*iter)->stopInterface();
- if (error!= E_OK)
- {
- returnError=error;
- }
- }
- return returnError;
-}
+ am_Error_e returnError = E_OK;
+ std::vector<CommandSendInterface*>::iterator iter = mListInterfaces.begin();
+ std::vector<CommandSendInterface*>::iterator iterEnd = mListInterfaces.end();
+ for (; iter < iterEnd; ++iter)
+ {
+ am_Error_e error = (*iter)->stopInterface();
+ if (error != E_OK)
+ {
+ returnError = error;
+ }
+ }
+ return returnError;
+}
am_Error_e CommandSender::startupInterface(CommandReceiveInterface *commandreceiveinterface)
{
- am_Error_e returnError=E_OK;
-
- std::vector<CommandSendInterface*>::iterator iter = mListInterfaces.begin();
- std::vector<CommandSendInterface*>::iterator iterEnd = mListInterfaces.end();
- for (; iter<iterEnd;++iter)
- {
- am_Error_e error=(*iter)->startupInterface(commandreceiveinterface);
- if (error!= E_OK)
- {
- returnError=error;
- }
- }
- return returnError;
-}
+ am_Error_e returnError = E_OK;
+ std::vector<CommandSendInterface*>::iterator iter = mListInterfaces.begin();
+ std::vector<CommandSendInterface*>::iterator iterEnd = mListInterfaces.end();
+ for (; iter < iterEnd; ++iter)
+ {
+ am_Error_e error = (*iter)->startupInterface(commandreceiveinterface);
+ if (error != E_OK)
+ {
+ returnError = error;
+ }
+ }
+ return returnError;
+}
void CommandSender::cbCommunicationReady()
{
- CALL_ALL_INTERFACES(cbCommunicationReady())
+ CALL_ALL_INTERFACES(cbCommunicationReady())
}
void CommandSender::cbCommunicationRundown()
{
- CALL_ALL_INTERFACES(cbCommunicationRundown())
+ CALL_ALL_INTERFACES(cbCommunicationRundown())
}
void CommandSender::cbNumberOfMainConnectionsChanged()
{
- CALL_ALL_INTERFACES(cbNumberOfMainConnectionsChanged())
+ CALL_ALL_INTERFACES(cbNumberOfMainConnectionsChanged())
}
void CommandSender::cbNumberOfSinksChanged()
{
- CALL_ALL_INTERFACES(cbNumberOfSinksChanged())
+ CALL_ALL_INTERFACES(cbNumberOfSinksChanged())
}
void CommandSender::cbNumberOfSourcesChanged()
{
- CALL_ALL_INTERFACES(cbNumberOfSourcesChanged())
+ CALL_ALL_INTERFACES(cbNumberOfSourcesChanged())
}
void CommandSender::cbNumberOfSinkClassesChanged()
{
- CALL_ALL_INTERFACES(cbNumberOfSinkClassesChanged())
+ CALL_ALL_INTERFACES(cbNumberOfSinkClassesChanged())
}
void CommandSender::cbNumberOfSourceClassesChanged()
{
- CALL_ALL_INTERFACES(cbNumberOfSourceClassesChanged())
+ CALL_ALL_INTERFACES(cbNumberOfSourceClassesChanged())
}
-
void CommandSender::cbMainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
{
- CALL_ALL_INTERFACES(cbMainConnectionStateChanged(connectionID,connectionState))
+ CALL_ALL_INTERFACES(cbMainConnectionStateChanged(connectionID,connectionState))
}
-
-
void CommandSender::cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s SoundProperty)
{
- CALL_ALL_INTERFACES(cbMainSinkSoundPropertyChanged(sinkID,SoundProperty))
+ CALL_ALL_INTERFACES(cbMainSinkSoundPropertyChanged(sinkID,SoundProperty))
}
-
-
void CommandSender::cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s & SoundProperty)
{
- CALL_ALL_INTERFACES(cbMainSourceSoundPropertyChanged(sourceID,SoundProperty))
+ CALL_ALL_INTERFACES(cbMainSourceSoundPropertyChanged(sourceID,SoundProperty))
}
-
-
void CommandSender::cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s & availability)
{
- CALL_ALL_INTERFACES(cbSinkAvailabilityChanged(sinkID,availability))
+ CALL_ALL_INTERFACES(cbSinkAvailabilityChanged(sinkID,availability))
}
-
-
void CommandSender::cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s & availability)
{
- CALL_ALL_INTERFACES(cbSourceAvailabilityChanged(sourceID,availability))
+ CALL_ALL_INTERFACES(cbSourceAvailabilityChanged(sourceID,availability))
}
-
-
void CommandSender::cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
{
- CALL_ALL_INTERFACES(cbVolumeChanged(sinkID,volume))
+ CALL_ALL_INTERFACES(cbVolumeChanged(sinkID,volume))
}
-
-
void CommandSender::cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
{
- CALL_ALL_INTERFACES(cbSinkMuteStateChanged(sinkID,muteState))
+ CALL_ALL_INTERFACES(cbSinkMuteStateChanged(sinkID,muteState))
}
-
-
void CommandSender::cbSystemPropertyChanged(const am_SystemProperty_s & SystemProperty)
{
- CALL_ALL_INTERFACES(cbSystemPropertyChanged(SystemProperty))
+ CALL_ALL_INTERFACES(cbSystemPropertyChanged(SystemProperty))
}
-
-
void CommandSender::cbTimingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time)
{
- CALL_ALL_INTERFACES(cbTimingInformationChanged(mainConnection,time))
+ CALL_ALL_INTERFACES(cbTimingInformationChanged(mainConnection,time))
}
void CommandSender::unloadLibraries(void)
{
- std::vector<void*>::iterator iterator=mListLibraryHandles.begin();
- for(;iterator<mListLibraryHandles.end();++iterator)
- {
- dlclose(*iterator);
- }
- mListLibraryHandles.clear();
+ std::vector<void*>::iterator iterator = mListLibraryHandles.begin();
+ for (; iterator < mListLibraryHandles.end(); ++iterator)
+ {
+ dlclose(*iterator);
+ }
+ mListLibraryHandles.clear();
}
uint16_t CommandSender::getInterfaceVersion() const
{
- return CommandSendVersion;
+ return CommandSendVersion;
}
-
-
-
-
-
-
diff --git a/AudioManagerDaemon/src/ControlReceiver.cpp b/AudioManagerDaemon/src/ControlReceiver.cpp
index 763bf2c..4900ce7 100644
--- a/AudioManagerDaemon/src/ControlReceiver.cpp
+++ b/AudioManagerDaemon/src/ControlReceiver.cpp
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file ControlReceiver.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file ControlReceiver.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#include <config.h>
#include <SocketHandler.h>
@@ -35,540 +35,434 @@ DLT_IMPORT_CONTEXT(AudioManager)
using namespace am;
-ControlReceiver::ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender, SocketHandler *iSocketHandler)
- : mDatabaseHandler(iDatabaseHandler),
- mRoutingSender(iRoutingSender),
- mCommandSender(iCommandSender),
- mSocketHandler(iSocketHandler)
+ControlReceiver::ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender, SocketHandler *iSocketHandler) :
+ mDatabaseHandler(iDatabaseHandler), //
+ mRoutingSender(iRoutingSender), //
+ mCommandSender(iCommandSender), //
+ mSocketHandler(iSocketHandler)
{
- assert(mDatabaseHandler!=NULL);
- assert(mRoutingSender!=NULL);
- assert(mCommandSender!=NULL);
- assert(mSocketHandler!=NULL);
+ assert(mDatabaseHandler!=NULL);
+ assert(mRoutingSender!=NULL);
+ assert(mCommandSender!=NULL);
+ assert(mSocketHandler!=NULL);
}
-ControlReceiver::ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender)
- : mDatabaseHandler(iDatabaseHandler),
- mRoutingSender(iRoutingSender),
- mCommandSender(iCommandSender)
+ControlReceiver::ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender) :
+ mDatabaseHandler(iDatabaseHandler), //
+ mRoutingSender(iRoutingSender), //
+ mCommandSender(iCommandSender)
{
-assert(mDatabaseHandler!=NULL);
-assert(mRoutingSender!=NULL);
-assert(mCommandSender!=NULL);
+ assert(mDatabaseHandler!=NULL);
+ assert(mRoutingSender!=NULL);
+ assert(mCommandSender!=NULL);
}
-
ControlReceiver::~ControlReceiver()
{
}
am_Error_e ControlReceiver::getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & returnList)
{
- //todo: implement routing algorithm
- return E_NOT_USED;
+ //todo: implement routing algorithm
+ return E_NOT_USED;
}
-
-
am_Error_e ControlReceiver::connect(am_Handle_s & handle, am_connectionID_t & connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::connect got called, connectionFormat"),DLT_INT(format),DLT_STRING("sourceID"),DLT_INT(sourceID),DLT_STRING("sinkID"),DLT_INT(sinkID));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::connect got called, connectionFormat"), DLT_INT(format), DLT_STRING("sourceID"), DLT_INT(sourceID), DLT_STRING("sinkID"), DLT_INT(sinkID));
- am_Connection_s tempConnection;
- tempConnection.sinkID=sinkID;
- tempConnection.sourceID=sourceID;
- tempConnection.connectionFormat=format;
- tempConnection.connectionID=0;
+ am_Connection_s tempConnection;
+ tempConnection.sinkID = sinkID;
+ tempConnection.sourceID = sourceID;
+ tempConnection.connectionFormat = format;
+ tempConnection.connectionID = 0;
- //todo: enter function to find out what happends if the same connection is in the course of being build up.
- if (mDatabaseHandler->existConnection(tempConnection)) return E_ALREADY_EXISTS; //todo:enter the correct connectionID here?
+ //todo: enter function to find out what happends if the same connection is in the course of being build up.
+ if (mDatabaseHandler->existConnection(tempConnection)) return E_ALREADY_EXISTS; //todo:enter the correct connectionID here?
- mDatabaseHandler->enterConnectionDB(tempConnection,connectionID);
- return mRoutingSender->asyncConnect(handle,connectionID,sourceID,sinkID,format);
+ mDatabaseHandler->enterConnectionDB(tempConnection, connectionID);
+ return mRoutingSender->asyncConnect(handle, connectionID, sourceID, sinkID, format);
}
-
-
am_Error_e ControlReceiver::disconnect(am_Handle_s & handle, const am_connectionID_t connectionID)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::disconnect got called, connectionID="),DLT_INT(connectionID));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::disconnect got called, connectionID="), DLT_INT(connectionID));
- if (!mDatabaseHandler->existConnectionID(connectionID)) return E_NON_EXISTENT; //todo: check with EA model and correct
- return mRoutingSender->asyncDisconnect(handle,connectionID);
+ if (!mDatabaseHandler->existConnectionID(connectionID)) return E_NON_EXISTENT; //todo: check with EA model and correct
+ return mRoutingSender->asyncDisconnect(handle, connectionID);
}
-
-
am_Error_e ControlReceiver::crossfade(am_Handle_s & handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_RampType_e rampType, const am_time_t rampTime)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::crossfade got called, hotSource="),DLT_INT(hotSource),DLT_STRING("crossfaderID="),DLT_INT(crossfaderID),DLT_STRING("rampType="),DLT_INT(rampType),DLT_STRING("rampTime="),DLT_INT(rampTime));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::crossfade got called, hotSource="), DLT_INT(hotSource), DLT_STRING("crossfaderID="), DLT_INT(crossfaderID), DLT_STRING("rampType="), DLT_INT(rampType), DLT_STRING("rampTime="), DLT_INT(rampTime));
- if (!mDatabaseHandler->existcrossFader(crossfaderID)) return E_NON_EXISTENT;
- return mRoutingSender->asyncCrossFade(handle,crossfaderID,hotSource,rampType,rampTime);
+ if (!mDatabaseHandler->existcrossFader(crossfaderID)) return E_NON_EXISTENT;
+ return mRoutingSender->asyncCrossFade(handle, crossfaderID, hotSource, rampType, rampTime);
}
-
-
am_Error_e ControlReceiver::setSourceState(am_Handle_s & handle, const am_sourceID_t sourceID, const am_SourceState_e state)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceState got called, sourceID="),DLT_INT(sourceID),DLT_STRING("state="),DLT_INT(state));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceState got called, sourceID="), DLT_INT(sourceID), DLT_STRING("state="), DLT_INT(state));
- am_SourceState_e sourceState;
- if(mDatabaseHandler->getSoureState(sourceID,sourceState)!=E_OK) return E_UNKNOWN;
- if(sourceState==state) return E_NO_CHANGE;
- return mRoutingSender->asyncSetSourceState(handle,sourceID,state);
+ am_SourceState_e sourceState;
+ if (mDatabaseHandler->getSoureState(sourceID, sourceState) != E_OK) return E_UNKNOWN;
+ if (sourceState == state) return E_NO_CHANGE;
+ return mRoutingSender->asyncSetSourceState(handle, sourceID, state);
}
-
-
am_Error_e ControlReceiver::setSinkVolume(am_Handle_s & handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSinkVolume got called, sinkID="),DLT_INT(sinkID),DLT_STRING("volume="),DLT_INT(volume),DLT_STRING("ramp="),DLT_INT(ramp),DLT_STRING("time="),DLT_INT(time));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSinkVolume got called, sinkID="), DLT_INT(sinkID), DLT_STRING("volume="), DLT_INT(volume), DLT_STRING("ramp="), DLT_INT(ramp), DLT_STRING("time="), DLT_INT(time));
- am_volume_t tempVolume;
- if(mDatabaseHandler->getSinkVolume(sinkID,tempVolume)!=E_OK) return E_UNKNOWN;
- if(tempVolume==volume) return E_NO_CHANGE;
- return mRoutingSender->asyncSetSinkVolume(handle,sinkID,volume,ramp,time);
+ am_volume_t tempVolume;
+ if (mDatabaseHandler->getSinkVolume(sinkID, tempVolume) != E_OK) return E_UNKNOWN;
+ if (tempVolume == volume) return E_NO_CHANGE;
+ return mRoutingSender->asyncSetSinkVolume(handle, sinkID, volume, ramp, time);
}
-
-
am_Error_e ControlReceiver::setSourceVolume(am_Handle_s & handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e rampType, const am_time_t time)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceVolume got called, sourceID="),DLT_INT(sourceID),DLT_STRING("volume="),DLT_INT(volume),DLT_STRING("ramp="),DLT_INT(rampType),DLT_STRING("time="),DLT_INT(time));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceVolume got called, sourceID="), DLT_INT(sourceID), DLT_STRING("volume="), DLT_INT(volume), DLT_STRING("ramp="), DLT_INT(rampType), DLT_STRING("time="), DLT_INT(time));
- am_volume_t tempVolume;
- if(mDatabaseHandler->getSourceVolume(sourceID,tempVolume)!=E_OK) return E_UNKNOWN;
- if(tempVolume==volume) return E_NO_CHANGE;
- return mRoutingSender->asyncSetSourceVolume(handle,sourceID,volume,rampType,time);
+ am_volume_t tempVolume;
+ if (mDatabaseHandler->getSourceVolume(sourceID, tempVolume) != E_OK) return E_UNKNOWN;
+ if (tempVolume == volume) return E_NO_CHANGE;
+ return mRoutingSender->asyncSetSourceVolume(handle, sourceID, volume, rampType, time);
}
-
-
am_Error_e ControlReceiver::setSinkSoundProperty(am_Handle_s & handle, const am_sinkID_t sinkID, const am_SoundProperty_s & soundProperty)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSinkSoundProperty got called, sinkID="),DLT_INT(sinkID),DLT_STRING("soundProperty.Type="),DLT_INT(soundProperty.type),DLT_STRING("soundProperty.value="),DLT_INT(soundProperty.value));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSinkSoundProperty got called, sinkID="), DLT_INT(sinkID), DLT_STRING("soundProperty.Type="), DLT_INT(soundProperty.type), DLT_STRING("soundProperty.value="), DLT_INT(soundProperty.value));
- uint16_t value;
- if(mDatabaseHandler->getSinkSoundPropertyValue(sinkID,soundProperty.type,value)!=E_OK) return E_UNKNOWN;
- if(value==soundProperty.value) return E_NO_CHANGE;
- return mRoutingSender->asyncSetSinkSoundProperty(handle,sinkID,soundProperty);
+ uint16_t value;
+ if (mDatabaseHandler->getSinkSoundPropertyValue(sinkID, soundProperty.type, value) != E_OK) return E_UNKNOWN;
+ if (value == soundProperty.value) return E_NO_CHANGE;
+ return mRoutingSender->asyncSetSinkSoundProperty(handle, sinkID, soundProperty);
}
-am_Error_e am::ControlReceiver::setSinkSoundProperties(am_Handle_s & handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s> & listSoundProperties)
+am_Error_e ControlReceiver::setSinkSoundProperties(am_Handle_s & handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s> & listSoundProperties)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSinkSoundProperties got called, sinkID="),DLT_INT(sinkID));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSinkSoundProperties got called, sinkID="), DLT_INT(sinkID));
- uint16_t value;
- bool noChange=true;
- std::vector<am_SoundProperty_s>::const_iterator it=listSoundProperties.begin();
- for(;it!=listSoundProperties.end();++it)
- {
- if(mDatabaseHandler->getSinkSoundPropertyValue(sinkID,it->type,value)!=E_OK) return (E_UNKNOWN);
- if(value!=it->value) noChange=false;
- }
- if (noChange) return (E_NO_CHANGE);
- return (mRoutingSender->asyncSetSinkSoundProperties(handle,listSoundProperties,sinkID));
+ uint16_t value;
+ bool noChange = true;
+ std::vector<am_SoundProperty_s>::const_iterator it = listSoundProperties.begin();
+ for (; it != listSoundProperties.end(); ++it)
+ {
+ if (mDatabaseHandler->getSinkSoundPropertyValue(sinkID, it->type, value) != E_OK) return (E_UNKNOWN);
+ if (value != it->value) noChange = false;
+ }
+ if (noChange) return (E_NO_CHANGE);
+ return (mRoutingSender->asyncSetSinkSoundProperties(handle, listSoundProperties, sinkID));
}
am_Error_e ControlReceiver::setSourceSoundProperty(am_Handle_s & handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceSoundProperty got called, sourceID="),DLT_INT(sourceID),DLT_STRING("soundProperty.Type="),DLT_INT(soundProperty.type),DLT_STRING("soundProperty.value="),DLT_INT(soundProperty.value));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceSoundProperty got called, sourceID="), DLT_INT(sourceID), DLT_STRING("soundProperty.Type="), DLT_INT(soundProperty.type), DLT_STRING("soundProperty.value="), DLT_INT(soundProperty.value));
- uint16_t value;
- if(mDatabaseHandler->getSourceSoundPropertyValue(sourceID,soundProperty.type,value)!=E_OK) return E_UNKNOWN;
- if(value==soundProperty.value) return E_NO_CHANGE;
- return mRoutingSender->asyncSetSourceSoundProperty(handle,sourceID,soundProperty);
+ uint16_t value;
+ if (mDatabaseHandler->getSourceSoundPropertyValue(sourceID, soundProperty.type, value) != E_OK) return E_UNKNOWN;
+ if (value == soundProperty.value) return E_NO_CHANGE;
+ return mRoutingSender->asyncSetSourceSoundProperty(handle, sourceID, soundProperty);
}
-am_Error_e am::ControlReceiver::setSourceSoundProperties(am_Handle_s & handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s> & listSoundProperties)
+am_Error_e ControlReceiver::setSourceSoundProperties(am_Handle_s & handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s> & listSoundProperties)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceSoundProperties got called, sourceID="),DLT_INT(sourceID));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceSoundProperties got called, sourceID="), DLT_INT(sourceID));
- uint16_t value;
- bool noChange=true;
- std::vector<am_SoundProperty_s>::const_iterator it=listSoundProperties.begin();
- for(;it!=listSoundProperties.end();++it)
- {
- if(mDatabaseHandler->getSourceSoundPropertyValue(sourceID,it->type,value)!=E_OK) return (E_UNKNOWN);
- if(value!=it->value) noChange=false;
- }
- if (noChange) return (E_NO_CHANGE);
- return (mRoutingSender->asyncSetSourceSoundProperties(handle,listSoundProperties,sourceID));
+ uint16_t value;
+ bool noChange = true;
+ std::vector<am_SoundProperty_s>::const_iterator it = listSoundProperties.begin();
+ for (; it != listSoundProperties.end(); ++it)
+ {
+ if (mDatabaseHandler->getSourceSoundPropertyValue(sourceID, it->type, value) != E_OK) return (E_UNKNOWN);
+ if (value != it->value) noChange = false;
+ }
+ if (noChange) return (E_NO_CHANGE);
+ return (mRoutingSender->asyncSetSourceSoundProperties(handle, listSoundProperties, sourceID));
}
-
am_Error_e ControlReceiver::setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setDomainState got called, domainID="),DLT_INT(domainID),DLT_STRING("domainState="),DLT_INT(domainState));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::setDomainState got called, domainID="), DLT_INT(domainID), DLT_STRING("domainState="), DLT_INT(domainState));
- am_DomainState_e tempState=DS_MIN;
- if(mDatabaseHandler->getDomainState(domainID,tempState)!=E_OK) return E_UNKNOWN;
- if(tempState==domainState) return E_NO_CHANGE;
- return mRoutingSender->setDomainState(domainID,domainState);
+ am_DomainState_e tempState = DS_MIN;
+ if (mDatabaseHandler->getDomainState(domainID, tempState) != E_OK) return E_UNKNOWN;
+ if (tempState == domainState) return E_NO_CHANGE;
+ return mRoutingSender->setDomainState(domainID, domainState);
}
-
-
am_Error_e ControlReceiver::abortAction(const am_Handle_s handle)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::abortAction got called, handle.type="),DLT_INT(handle.handle),DLT_STRING("handle.handleType="),DLT_INT(handle.handleType));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::abortAction got called, handle.type="), DLT_INT(handle.handle), DLT_STRING("handle.handleType="), DLT_INT(handle.handleType));
- return mRoutingSender->asyncAbort(handle);
+ return mRoutingSender->asyncAbort(handle);
}
-
-
am_Error_e ControlReceiver::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID)
{
- return mDatabaseHandler->enterDomainDB(domainData,domainID);
+ return mDatabaseHandler->enterDomainDB(domainData, domainID);
}
-
-
am_Error_e ControlReceiver::enterMainConnectionDB(const am_MainConnection_s & mainConnectionData, am_mainConnectionID_t & connectionID)
{
- return mDatabaseHandler->enterMainConnectionDB(mainConnectionData,connectionID);
+ return mDatabaseHandler->enterMainConnectionDB(mainConnectionData, connectionID);
}
-
-
am_Error_e ControlReceiver::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
{
- return mDatabaseHandler->enterSinkDB(sinkData,sinkID);
+ return mDatabaseHandler->enterSinkDB(sinkData, sinkID);
}
-
-
am_Error_e ControlReceiver::enterCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
{
- return mDatabaseHandler->enterCrossfaderDB(crossfaderData,crossfaderID);
+ return mDatabaseHandler->enterCrossfaderDB(crossfaderData, crossfaderID);
}
-
-
am_Error_e ControlReceiver::enterGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
{
- return mDatabaseHandler->enterGatewayDB(gatewayData,gatewayID);
+ return mDatabaseHandler->enterGatewayDB(gatewayData, gatewayID);
}
-
-
am_Error_e ControlReceiver::enterSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID)
{
- return mDatabaseHandler->enterSourceDB(sourceData,sourceID);
+ return mDatabaseHandler->enterSourceDB(sourceData, sourceID);
}
am_Error_e ControlReceiver::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID)
{
- return mDatabaseHandler->enterSinkClassDB(sinkClass,sinkClassID);
+ return mDatabaseHandler->enterSinkClassDB(sinkClass, sinkClassID);
}
am_Error_e ControlReceiver::enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass)
{
- return mDatabaseHandler->enterSourceClassDB(sourceClassID,sourceClass);
+ return mDatabaseHandler->enterSourceClassDB(sourceClassID, sourceClass);
}
-
am_Error_e ControlReceiver::enterSystemPropertiesListDB(const std::vector<am_SystemProperty_s> & listSystemProperties)
{
- return mDatabaseHandler->enterSystemProperties(listSystemProperties);
+ return mDatabaseHandler->enterSystemProperties(listSystemProperties);
}
-
am_Error_e ControlReceiver::changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const am_Route_s & route)
{
- return mDatabaseHandler->changeMainConnectionRouteDB(mainconnectionID,route);
+ return mDatabaseHandler->changeMainConnectionRouteDB(mainconnectionID, route);
}
-
-
am_Error_e ControlReceiver::changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState)
{
- return mDatabaseHandler->changeMainConnectionStateDB(mainconnectionID,connectionState);
+ return mDatabaseHandler->changeMainConnectionStateDB(mainconnectionID, connectionState);
}
-
-
am_Error_e ControlReceiver::changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID)
{
- return mDatabaseHandler->changeSinkMainVolumeDB(mainVolume,sinkID);
+ return mDatabaseHandler->changeSinkMainVolumeDB(mainVolume, sinkID);
}
-
-
am_Error_e ControlReceiver::changeSinkAvailabilityDB(const am_Availability_s & availability, const am_sinkID_t sinkID)
{
- return mDatabaseHandler->changeSinkAvailabilityDB(availability,sinkID);
+ return mDatabaseHandler->changeSinkAvailabilityDB(availability, sinkID);
}
-
-
am_Error_e ControlReceiver::changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID)
{
- return mDatabaseHandler->changDomainStateDB(domainState,domainID);
+ return mDatabaseHandler->changDomainStateDB(domainState, domainID);
}
-
-
am_Error_e ControlReceiver::changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID)
{
- return mDatabaseHandler->changeSinkMuteStateDB(muteState,sinkID);
+ return mDatabaseHandler->changeSinkMuteStateDB(muteState, sinkID);
}
-
-
am_Error_e ControlReceiver::changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID)
{
- return mDatabaseHandler->changeMainSinkSoundPropertyDB(soundProperty,sinkID);
+ return mDatabaseHandler->changeMainSinkSoundPropertyDB(soundProperty, sinkID);
}
-
-
am_Error_e ControlReceiver::changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID)
{
- return mDatabaseHandler->changeMainSinkSoundPropertyDB(soundProperty,sourceID);
+ return mDatabaseHandler->changeMainSinkSoundPropertyDB(soundProperty, sourceID);
}
-
-
am_Error_e ControlReceiver::changeSourceAvailabilityDB(const am_Availability_s & availability, const am_sourceID_t sourceID)
{
- return mDatabaseHandler->changeSourceAvailabilityDB(availability,sourceID);
+ return mDatabaseHandler->changeSourceAvailabilityDB(availability, sourceID);
}
-
-
am_Error_e ControlReceiver::changeSystemPropertyDB(const am_SystemProperty_s & property)
{
- return mDatabaseHandler->changeSystemPropertyDB(property);
+ return mDatabaseHandler->changeSystemPropertyDB(property);
}
-
-
am_Error_e ControlReceiver::removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID)
{
- return mDatabaseHandler->removeMainConnectionDB(mainConnectionID);
+ return mDatabaseHandler->removeMainConnectionDB(mainConnectionID);
}
-
-
am_Error_e ControlReceiver::removeSinkDB(const am_sinkID_t sinkID)
{
- return mDatabaseHandler->removeSinkDB(sinkID);
+ return mDatabaseHandler->removeSinkDB(sinkID);
}
-
-
am_Error_e ControlReceiver::removeSourceDB(const am_sourceID_t sourceID)
{
- return mDatabaseHandler->removeSourceDB(sourceID);
+ return mDatabaseHandler->removeSourceDB(sourceID);
}
-
-
am_Error_e ControlReceiver::removeGatewayDB(const am_gatewayID_t gatewayID)
{
- return mDatabaseHandler->removeGatewayDB(gatewayID);
+ return mDatabaseHandler->removeGatewayDB(gatewayID);
}
-
-
am_Error_e ControlReceiver::removeCrossfaderDB(const am_crossfaderID_t crossfaderID)
{
- return mDatabaseHandler->removeCrossfaderDB(crossfaderID);
+ return mDatabaseHandler->removeCrossfaderDB(crossfaderID);
}
-
-
am_Error_e ControlReceiver::removeDomainDB(const am_domainID_t domainID)
{
- return mDatabaseHandler->removeDomainDB(domainID);
+ return mDatabaseHandler->removeDomainDB(domainID);
}
-
-
am_Error_e ControlReceiver::getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s & classInfo) const
{
- return mDatabaseHandler->getSourceClassInfoDB(sourceID,classInfo);
+ return mDatabaseHandler->getSourceClassInfoDB(sourceID, classInfo);
}
-
am_Error_e ControlReceiver::getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s & sinkClass) const
{
- return mDatabaseHandler->getSinkClassInfoDB(sinkID,sinkClass);
+ return mDatabaseHandler->getSinkClassInfoDB(sinkID, sinkClass);
}
-
-
am_Error_e ControlReceiver::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s & gatewayData) const
{
- return mDatabaseHandler->getGatewayInfoDB(gatewayID,gatewayData);
+ return mDatabaseHandler->getGatewayInfoDB(gatewayID, gatewayData);
}
-
-
am_Error_e ControlReceiver::getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s & crossfaderData) const
{
- return mDatabaseHandler->getCrossfaderInfoDB(crossfaderID,crossfaderData);
+ return mDatabaseHandler->getCrossfaderInfoDB(crossfaderID, crossfaderData);
}
-
-
am_Error_e ControlReceiver::getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> & listSinkID) const
{
- return mDatabaseHandler->getListSinksOfDomain(domainID,listSinkID);
+ return mDatabaseHandler->getListSinksOfDomain(domainID, listSinkID);
}
-
-
am_Error_e ControlReceiver::getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> & listSourceID) const
{
- return mDatabaseHandler->getListSourcesOfDomain(domainID,listSourceID);
+ return mDatabaseHandler->getListSourcesOfDomain(domainID, listSourceID);
}
-
-
am_Error_e ControlReceiver::getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> & listGatewaysID) const
{
- return mDatabaseHandler->getListCrossfadersOfDomain(domainID,listGatewaysID);
+ return mDatabaseHandler->getListCrossfadersOfDomain(domainID, listGatewaysID);
}
-
-
am_Error_e ControlReceiver::getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> & listGatewaysID) const
{
- return mDatabaseHandler->getListGatewaysOfDomain(domainID,listGatewaysID);
+ return mDatabaseHandler->getListGatewaysOfDomain(domainID, listGatewaysID);
}
-
-
am_Error_e ControlReceiver::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections) const
{
- return mDatabaseHandler->getListMainConnections(listMainConnections);
+ return mDatabaseHandler->getListMainConnections(listMainConnections);
}
-
-
am_Error_e ControlReceiver::getListDomains(std::vector<am_Domain_s> & listDomains) const
{
- return mDatabaseHandler->getListDomains(listDomains);
+ return mDatabaseHandler->getListDomains(listDomains);
}
-
-
am_Error_e ControlReceiver::getListConnections(std::vector<am_Connection_s> & listConnections) const
{
- return mDatabaseHandler->getListConnections(listConnections);
+ return mDatabaseHandler->getListConnections(listConnections);
}
-
-
am_Error_e ControlReceiver::getListSinks(std::vector<am_Sink_s> & listSinks) const
{
- return mDatabaseHandler->getListSinks(listSinks);
+ return mDatabaseHandler->getListSinks(listSinks);
}
-
-
am_Error_e ControlReceiver::getListSources(std::vector<am_Source_s> & listSources) const
{
- return mDatabaseHandler->getListSources(listSources);
+ return mDatabaseHandler->getListSources(listSources);
}
-
-
am_Error_e ControlReceiver::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const
{
- return mDatabaseHandler->getListSourceClasses(listSourceClasses);
+ return mDatabaseHandler->getListSourceClasses(listSourceClasses);
}
-
-
am_Error_e ControlReceiver::getListHandles(std::vector<am_Handle_s> & listHandles) const
{
- return mRoutingSender->getListHandles(listHandles);
+ return mRoutingSender->getListHandles(listHandles);
}
-
-
am_Error_e ControlReceiver::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders) const
{
- return mDatabaseHandler->getListCrossfaders(listCrossfaders);
+ return mDatabaseHandler->getListCrossfaders(listCrossfaders);
}
-
-
am_Error_e ControlReceiver::getListGateways(std::vector<am_Gateway_s> & listGateways) const
{
- return mDatabaseHandler->getListGateways(listGateways);
+ return mDatabaseHandler->getListGateways(listGateways);
}
-
-
am_Error_e ControlReceiver::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const
{
- return mDatabaseHandler->getListSinkClasses(listSinkClasses);
+ return mDatabaseHandler->getListSinkClasses(listSinkClasses);
}
-
am_Error_e ControlReceiver::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const
{
- return mDatabaseHandler->getListSystemProperties(listSystemProperties);
+ return mDatabaseHandler->getListSystemProperties(listSystemProperties);
}
-
am_Error_e ControlReceiver::changeSinkClassInfoDB(const am_SinkClass_s & classInfo)
{
- return mDatabaseHandler->changeSinkClassInfoDB(classInfo);
+ return mDatabaseHandler->changeSinkClassInfoDB(classInfo);
}
am_Error_e ControlReceiver::changeSourceClassInfoDB(const am_SourceClass_s & classInfo)
{
- return mDatabaseHandler->changeSourceClassInfoDB(classInfo);
+ return mDatabaseHandler->changeSourceClassInfoDB(classInfo);
}
am_Error_e ControlReceiver::removeSinkClassDB(const am_sinkClass_t sinkClassID)
{
- return mDatabaseHandler->removeSinkClassDB(sinkClassID);
+ return mDatabaseHandler->removeSinkClassDB(sinkClassID);
}
am_Error_e ControlReceiver::removeSourceClassDB(const am_sourceClass_t sourceClassID)
{
- return mDatabaseHandler->removeSourceClassDB(sourceClassID);
+ return mDatabaseHandler->removeSourceClassDB(sourceClassID);
}
void ControlReceiver::setCommandReady()
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setCommandReady got called"));
- mCommandSender->cbCommunicationReady();
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::setCommandReady got called"));
+ mCommandSender->cbCommunicationReady();
}
void ControlReceiver::setRoutingReady()
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setRoutingReady got called"));
- mRoutingSender->routingInterfacesReady();
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("ControlReceiver::setRoutingReady got called"));
+ mRoutingSender->routingInterfacesReady();
}
-am_Error_e am::ControlReceiver::getSocketHandler(SocketHandler *& socketHandler)
+am_Error_e ControlReceiver::getSocketHandler(SocketHandler *& socketHandler)
{
#ifdef WITH_SOCKETHANDLER_LOOP
- socketHandler=mSocketHandler;
- return E_OK;
+ socketHandler = mSocketHandler;
+ return E_OK;
#else
- return E_UNKNOWN;
+ return E_UNKNOWN;
#endif
}
-
uint16_t ControlReceiver::getInterfaceVersion() const
{
- return ControlReceiveVersion;
+ return ControlReceiveVersion;
}
-
-
-
-
-
-
diff --git a/AudioManagerDaemon/src/ControlSender.cpp b/AudioManagerDaemon/src/ControlSender.cpp
index 3371fb2..ca7ce3a 100644
--- a/AudioManagerDaemon/src/ControlSender.cpp
+++ b/AudioManagerDaemon/src/ControlSender.cpp
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file ControlSender.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file ControlSender.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#include "ControlSender.h"
#include <assert.h>
@@ -34,319 +34,248 @@ using namespace am;
#define REQUIRED_MIN_INTERFACE_VERSION 1
-ControlSender::ControlSender(std::string controlPluginFile)
- :mlibHandle(NULL),
- mController(NULL)
-{
- std::ifstream isfile(controlPluginFile.c_str());
- if (!isfile)
- {
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("ControlSender::ControlSender: Controller plugin not found:"),DLT_STRING(controlPluginFile.c_str()));
- }
- else if (!controlPluginFile.empty())
- {
- ControlSendInterface* (*createFunc)();
- createFunc = getCreateFunction<ControlSendInterface*()>(controlPluginFile,mlibHandle);
- assert(createFunc!=NULL);
- mController = createFunc();
+ControlSender::ControlSender(std::string controlPluginFile) :
+ mlibHandle(NULL), //
+ mController(NULL)
+{
+ std::ifstream isfile(controlPluginFile.c_str());
+ if (!isfile)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("ControlSender::ControlSender: Controller plugin not found:"), DLT_STRING(controlPluginFile.c_str()));
+ }
+ else if (!controlPluginFile.empty())
+ {
+ ControlSendInterface* (*createFunc)();
+ createFunc = getCreateFunction<ControlSendInterface*()>(controlPluginFile, mlibHandle);
+ assert(createFunc!=NULL);
+ mController = createFunc();
//check libversion
assert(REQUIRED_MIN_INTERFACE_VERSION<=mController->getInterfaceVersion());
- }
- else
- {
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("ControlSender::ControlSender: No controller loaded !"));
- }
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("ControlSender::ControlSender: No controller loaded !"));
+ }
}
ControlSender::~ControlSender()
{
- if (mlibHandle) dlclose(mlibHandle);
+ if (mlibHandle) dlclose(mlibHandle);
}
void ControlSender::hookAllPluginsLoaded()
{
- mController->hookAllPluginsLoaded();
+ mController->hookAllPluginsLoaded();
}
-
-
am_Error_e ControlSender::hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t & mainConnectionID)
{
- return mController->hookUserConnectionRequest(sourceID,sinkID,mainConnectionID);
+ return mController->hookUserConnectionRequest(sourceID, sinkID, mainConnectionID);
}
-
-
am_Error_e ControlSender::hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID)
{
- return mController->hookUserDisconnectionRequest(connectionID);
+ return mController->hookUserDisconnectionRequest(connectionID);
}
-
-
am_Error_e ControlSender::hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s & soundProperty)
{
- return mController->hookUserSetMainSinkSoundProperty(sinkID,soundProperty);
+ return mController->hookUserSetMainSinkSoundProperty(sinkID, soundProperty);
}
-
-
am_Error_e ControlSender::hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s & soundProperty)
{
- return mController->hookUserSetMainSourceSoundProperty(sourceID,soundProperty);
+ return mController->hookUserSetMainSourceSoundProperty(sourceID, soundProperty);
}
-
-
am_Error_e ControlSender::hookUserSetSystemProperty(const am_SystemProperty_s & property)
{
- return mController->hookUserSetSystemProperty(property);
+ return mController->hookUserSetSystemProperty(property);
}
-
-
am_Error_e ControlSender::hookUserVolumeChange(const am_sinkID_t sinkID, const am_mainVolume_t newVolume)
{
- return mController->hookUserVolumeChange(sinkID,newVolume);
+ return mController->hookUserVolumeChange(sinkID, newVolume);
}
-
-
am_Error_e ControlSender::hookUserVolumeStep(const am_sinkID_t sinkID, const int16_t increment)
{
- return mController->hookUserVolumeStep(sinkID,increment);
+ return mController->hookUserVolumeStep(sinkID, increment);
}
-
-
am_Error_e ControlSender::hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState)
{
- return mController->hookUserSetSinkMuteState(sinkID,muteState);
+ return mController->hookUserSetSinkMuteState(sinkID, muteState);
}
-
-
am_Error_e ControlSender::hookSystemRegisterDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
{
- return mController->hookSystemRegisterDomain(domainData,domainID);
+ return mController->hookSystemRegisterDomain(domainData, domainID);
}
-
-
am_Error_e ControlSender::hookSystemDeregisterDomain(const am_domainID_t domainID)
{
- return mController->hookSystemDeregisterDomain(domainID);
+ return mController->hookSystemDeregisterDomain(domainID);
}
-
-
void ControlSender::hookSystemDomainRegistrationComplete(const am_domainID_t domainID)
{
- return mController->hookSystemDomainRegistrationComplete(domainID);
+ return mController->hookSystemDomainRegistrationComplete(domainID);
}
-
-
am_Error_e ControlSender::hookSystemRegisterSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
{
- return mController->hookSystemRegisterSink(sinkData,sinkID);
+ return mController->hookSystemRegisterSink(sinkData, sinkID);
}
-
-
am_Error_e ControlSender::hookSystemDeregisterSink(const am_sinkID_t sinkID)
{
- return mController->hookSystemDeregisterSink(sinkID);
+ return mController->hookSystemDeregisterSink(sinkID);
}
-
-
am_Error_e ControlSender::hookSystemRegisterSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
{
- return mController->hookSystemRegisterSource(sourceData,sourceID);
+ return mController->hookSystemRegisterSource(sourceData, sourceID);
}
-
-
am_Error_e ControlSender::hookSystemDeregisterSource(const am_sourceID_t sourceID)
{
- return mController->hookSystemDeregisterSource(sourceID);
+ return mController->hookSystemDeregisterSource(sourceID);
}
-
-
am_Error_e ControlSender::hookSystemRegisterGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
{
- return mController->hookSystemRegisterGateway(gatewayData,gatewayID);
+ return mController->hookSystemRegisterGateway(gatewayData, gatewayID);
}
-
-
am_Error_e ControlSender::hookSystemDeregisterGateway(const am_gatewayID_t gatewayID)
{
- return mController->hookSystemDeregisterGateway(gatewayID);
+ return mController->hookSystemDeregisterGateway(gatewayID);
}
-
-
am_Error_e ControlSender::hookSystemRegisterCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
{
- return mController->hookSystemRegisterCrossfader(crossfaderData,crossfaderID);
+ return mController->hookSystemRegisterCrossfader(crossfaderData, crossfaderID);
}
-
-
am_Error_e ControlSender::hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID)
{
- return mController->hookSystemDeregisterCrossfader(crossfaderID);
+ return mController->hookSystemDeregisterCrossfader(crossfaderID);
}
-
-
void ControlSender::hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
{
- return mController->hookSystemSinkVolumeTick(handle,sinkID,volume);
+ mController->hookSystemSinkVolumeTick(handle, sinkID, volume);
}
-
-
void ControlSender::hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
{
- return mController->hookSystemSourceVolumeTick(handle,sourceID,volume);
+ mController->hookSystemSourceVolumeTick(handle, sourceID, volume);
}
-
-
void ControlSender::hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
{
- return mController->hookSystemInterruptStateChange(sourceID,interruptState);
+ mController->hookSystemInterruptStateChange(sourceID, interruptState);
}
-
-
void ControlSender::hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
{
- return mController->hookSystemSinkAvailablityStateChange(sinkID,availability);
+ mController->hookSystemSinkAvailablityStateChange(sinkID, availability);
}
-
-
void ControlSender::hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
{
- return mController->hookSystemSourceAvailablityStateChange(sourceID,availability);
+ mController->hookSystemSourceAvailablityStateChange(sourceID, availability);
}
-
-
void ControlSender::hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state)
{
- return mController->hookSystemDomainStateChange(domainID,state);
+ mController->hookSystemDomainStateChange(domainID, state);
}
-
-
void ControlSender::hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s> & data)
{
- return mController->hookSystemReceiveEarlyData(data);
+ mController->hookSystemReceiveEarlyData(data);
}
-
-
void ControlSender::hookSystemSpeedChange(const am_speed_t speed)
{
- return mController->hookSystemSpeedChange(speed);
+ mController->hookSystemSpeedChange(speed);
}
-
-
void ControlSender::hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)
{
- return mController->hookSystemTimingInformationChanged(mainConnectionID,time);
+ mController->hookSystemTimingInformationChanged(mainConnectionID, time);
}
-
-
void ControlSender::cbAckConnect(const am_Handle_s handle, const am_Error_e errorID)
{
- return mController->cbAckConnect(handle,errorID);
+ mController->cbAckConnect(handle, errorID);
}
-
-
void ControlSender::cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID)
{
- return mController->cbAckDisconnect(handle,errorID);
+ mController->cbAckDisconnect(handle, errorID);
}
-
-
void ControlSender::cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error)
{
- return mController->cbAckCrossFade(handle,hostsink,error);
+ mController->cbAckCrossFade(handle, hostsink, error);
}
-
-
void ControlSender::cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
{
- return mController->cbAckSetSinkVolumeChange(handle,volume,error);
+ mController->cbAckSetSinkVolumeChange(handle, volume, error);
}
-
-
void ControlSender::cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
{
- return mController->cbAckSetSourceVolumeChange(handle,volume,error);
+ mController->cbAckSetSourceVolumeChange(handle, volume, error);
}
-
-
void ControlSender::cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error)
{
- return mController->cbAckSetSourceState(handle,error);
+ mController->cbAckSetSourceState(handle, error);
}
-
-
void ControlSender::cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
{
- return mController->cbAckSetSourceSoundProperty(handle,error);
+ mController->cbAckSetSourceSoundProperty(handle, error);
}
-
-
am_Error_e ControlSender::startupController(ControlReceiveInterface *controlreceiveinterface)
{
- return mController->startupController(controlreceiveinterface);
+ return mController->startupController(controlreceiveinterface);
}
am_Error_e ControlSender::stopController()
{
- return mController->stopController();
+ return mController->stopController();
}
void ControlSender::cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
{
- return mController->cbAckSetSinkSoundProperty(handle,error);
+ mController->cbAckSetSinkSoundProperty(handle, error);
}
void ControlSender::cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error)
{
- return mController->cbAckSetSinkSoundProperties(handle,error);
+ mController->cbAckSetSinkSoundProperties(handle, error);
}
void ControlSender::cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error)
{
- return mController->cbAckSetSourceSoundProperties(handle,error);
+ mController->cbAckSetSourceSoundProperties(handle, error);
}
-uint16_t ControlSender::getInterfaceVersion() const
+am_Error_e ControlSender::getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const std::vector<am_ConnectionFormat_e> listPossibleConnectionFormats, std::vector<am_ConnectionFormat_e> & listPrioConnectionFormats)
{
- return ControlSendVersion;
+ return mController->getConnectionFormatChoice(sourceID, sinkID, listPossibleConnectionFormats, listPrioConnectionFormats);
}
-
-
-
+uint16_t ControlSender::getInterfaceVersion() const
+{
+ return ControlSendVersion;
+}
diff --git a/AudioManagerDaemon/src/DBusWrapper.cpp b/AudioManagerDaemon/src/DBusWrapper.cpp
index cb332ef..5b81792 100644
--- a/AudioManagerDaemon/src/DBusWrapper.cpp
+++ b/AudioManagerDaemon/src/DBusWrapper.cpp
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file SocketHandler.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file SocketHandler.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#include <dbus/DBusWrapper.h>
#include <SocketHandler.h>
@@ -47,71 +47,71 @@ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
DBusWrapper* DBusWrapper::mReference = NULL;
-DBusWrapper::DBusWrapper()
- : pDbusDispatchCallback(this,&DBusWrapper::dbusDispatchCallback),
- pDbusFireCallback(this,&DBusWrapper::dbusFireCallback),
- pDbusCheckCallback(this,&DBusWrapper::dbusCheckCallback),
- pDbusTimerCallback(this,&DBusWrapper::dbusTimerCallback),
- mDbusConnection(0),
- mDBusError(),
- mNodesList(),
- mListTimerhandlePointer()
+DBusWrapper::DBusWrapper() :
+ pDbusDispatchCallback(this, &DBusWrapper::dbusDispatchCallback), //
+ pDbusFireCallback(this, &DBusWrapper::dbusFireCallback), //
+ pDbusCheckCallback(this, &DBusWrapper::dbusCheckCallback), //
+ pDbusTimerCallback(this, &DBusWrapper::dbusTimerCallback), //
+ mDbusConnection(0), //
+ mDBusError(), //
+ mNodesList(), //
+ mListTimerhandlePointer()
{
- dbus_error_init(&mDBusError);
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::DBusWrapper Opening DBus connection"));
- mDbusConnection=dbus_bus_get(DBUS_BUS_SESSION, &mDBusError);
+ dbus_error_init(&mDBusError);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::DBusWrapper Opening DBus connection"));
+ mDbusConnection = dbus_bus_get(DBUS_BUS_SESSION, &mDBusError);
if (dbus_error_is_set(&mDBusError))
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Error while getting the DBus"));
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Error while getting the DBus"));
dbus_error_free(&mDBusError);
}
if (NULL == mDbusConnection)
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper DBus Connection is null"));
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper DBus Connection is null"));
}
//first, we are old enought to live longer then the connection:
dbus_connection_set_exit_on_disconnect(mDbusConnection, FALSE);
- mObjectPathVTable.message_function=DBusWrapper::cbRootIntrospection;
- dbus_connection_register_object_path(mDbusConnection,DBUS_SERVICE_OBJECT_PATH , &mObjectPathVTable, this);
- int ret = dbus_bus_request_name(mDbusConnection,DBUS_SERVICE_PREFIX,DBUS_NAME_FLAG_DO_NOT_QUEUE, &mDBusError);
+ mObjectPathVTable.message_function = DBusWrapper::cbRootIntrospection;
+ dbus_connection_register_object_path(mDbusConnection, DBUS_SERVICE_OBJECT_PATH, &mObjectPathVTable, this);
+ int ret = dbus_bus_request_name(mDbusConnection, DBUS_SERVICE_PREFIX, DBUS_NAME_FLAG_DO_NOT_QUEUE, &mDBusError);
if (dbus_error_is_set(&mDBusError))
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Name Error"),DLT_STRING(mDBusError.message));
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Name Error"), DLT_STRING(mDBusError.message));
dbus_error_free(&mDBusError);
}
if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret)
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Wrapper is not the Primary Owner"), DLT_INT(ret));
- exit(1);
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Wrapper is not the Primary Owner"), DLT_INT(ret));
+ exit(1);
}
}
-DBusWrapper::DBusWrapper(SocketHandler* socketHandler)
- : pDbusDispatchCallback(this,&DBusWrapper::dbusDispatchCallback),
- pDbusFireCallback(this,&DBusWrapper::dbusFireCallback),
- pDbusCheckCallback(this,&DBusWrapper::dbusCheckCallback),
- pDbusTimerCallback(this,&DBusWrapper::dbusTimerCallback),
- mDbusConnection(0),
- mDBusError(),
- mNodesList(),
- mListTimerhandlePointer(),
- mSocketHandler(socketHandler)
+DBusWrapper::DBusWrapper(SocketHandler* socketHandler) :
+ pDbusDispatchCallback(this, &DBusWrapper::dbusDispatchCallback), //
+ pDbusFireCallback(this, &DBusWrapper::dbusFireCallback), //
+ pDbusCheckCallback(this, &DBusWrapper::dbusCheckCallback), //
+ pDbusTimerCallback(this, &DBusWrapper::dbusTimerCallback), //
+ mDbusConnection(0), //
+ mDBusError(), //
+ mNodesList(), //
+ mListTimerhandlePointer(), //
+ mSocketHandler(socketHandler)
{
- assert(mSocketHandler!=0);
+ assert(mSocketHandler!=0);
- dbus_error_init(&mDBusError);
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::DBusWrapper Opening DBus connection"));
- mDbusConnection=dbus_bus_get(DBUS_BUS_SESSION, &mDBusError);
+ dbus_error_init(&mDBusError);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::DBusWrapper Opening DBus connection"));
+ mDbusConnection = dbus_bus_get(DBUS_BUS_SESSION, &mDBusError);
if (dbus_error_is_set(&mDBusError))
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Error while getting the DBus"));
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Error while getting the DBus"));
dbus_error_free(&mDBusError);
}
if (NULL == mDbusConnection)
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper DBus Connection is null"));
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper DBus Connection is null"));
}
//then we need to adopt the dbus to our mainloop:
@@ -122,351 +122,338 @@ DBusWrapper::DBusWrapper(SocketHandler* socketHandler)
//dbus_connection_set_dispatch_status_function
//add watch functions:
- dbus_bool_t watch=dbus_connection_set_watch_functions(mDbusConnection, addWatch, removeWatch, toogleWatch , this, NULL);
+ dbus_bool_t watch = dbus_connection_set_watch_functions(mDbusConnection, addWatch, removeWatch, toogleWatch, this, NULL);
if (!watch)
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Registering of watch functions failed"));
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Registering of watch functions failed"));
}
//add timer functions:
- dbus_bool_t timer=dbus_connection_set_timeout_functions(mDbusConnection, addTimeout, removeTimeout, toggleTimeout, this, NULL);
- if(!timer)
+ dbus_bool_t timer = dbus_connection_set_timeout_functions(mDbusConnection, addTimeout, removeTimeout, toggleTimeout, this, NULL);
+ if (!timer)
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Registering of timer functions failed"));
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Registering of timer functions failed"));
}
//register callback for Introspectio
- mObjectPathVTable.message_function=DBusWrapper::cbRootIntrospection;
- dbus_connection_register_object_path(mDbusConnection,DBUS_SERVICE_OBJECT_PATH , &mObjectPathVTable, this);
- int ret = dbus_bus_request_name(mDbusConnection,DBUS_SERVICE_PREFIX,DBUS_NAME_FLAG_DO_NOT_QUEUE, &mDBusError);
+ mObjectPathVTable.message_function = DBusWrapper::cbRootIntrospection;
+ dbus_connection_register_object_path(mDbusConnection, DBUS_SERVICE_OBJECT_PATH, &mObjectPathVTable, this);
+ int ret = dbus_bus_request_name(mDbusConnection, DBUS_SERVICE_PREFIX, DBUS_NAME_FLAG_DO_NOT_QUEUE, &mDBusError);
if (dbus_error_is_set(&mDBusError))
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Name Error"),DLT_STRING(mDBusError.message));
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Name Error"), DLT_STRING(mDBusError.message));
dbus_error_free(&mDBusError);
}
if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret)
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Wrapper is not the Primary Owner"), DLT_INT(ret));
- exit(1);
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Wrapper is not the Primary Owner"), DLT_INT(ret));
+ exit(1);
}
}
DBusWrapper::~DBusWrapper()
{
- //close the connection again
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::~DBusWrapper Closing DBus connection"));
- dbus_connection_unref(mDbusConnection);
-
- //clean up all timerhandles we created but did not delete before
- std::vector<sh_timerHandle_t*>::iterator it=mListTimerhandlePointer.begin();
- for(;it!=mListTimerhandlePointer.end();++it)
- {
- delete *it;
- }
+ //close the connection again
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::~DBusWrapper Closing DBus connection"));
+ dbus_connection_unref(mDbusConnection);
+
+ //clean up all timerhandles we created but did not delete before
+ std::vector<sh_timerHandle_t*>::iterator it = mListTimerhandlePointer.begin();
+ for (; it != mListTimerhandlePointer.end(); ++it)
+ {
+ delete *it;
+ }
}
void DBusWrapper::registerCallback(const DBusObjectPathVTable* vtable, const std::string& path, void* userdata)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::~registerCallback register callback:"),DLT_STRING(path.c_str()));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::~registerCallback register callback:"), DLT_STRING(path.c_str()));
- std::string completePath=std::string(DBUS_SERVICE_OBJECT_PATH)+"/"+path;
- dbus_error_init(&mDBusError);
- mDbusConnection=dbus_bus_get(DBUS_BUS_SESSION, &mDBusError);
- dbus_connection_register_object_path(mDbusConnection,completePath.c_str(), vtable, userdata);
+ std::string completePath = std::string(DBUS_SERVICE_OBJECT_PATH) + "/" + path;
+ dbus_error_init(&mDBusError);
+ mDbusConnection = dbus_bus_get(DBUS_BUS_SESSION, &mDBusError);
+ dbus_connection_register_object_path(mDbusConnection, completePath.c_str(), vtable, userdata);
if (dbus_error_is_set(&mDBusError))
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::registerCallack error: "),DLT_STRING(mDBusError.message));
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::registerCallack error: "), DLT_STRING(mDBusError.message));
dbus_error_free(&mDBusError);
}
- mNodesList.push_back(path);
+ mNodesList.push_back(path);
}
DBusHandlerResult DBusWrapper::cbRootIntrospection(DBusConnection *conn, DBusMessage *msg, void *reference)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::~cbRootIntrospection called:"));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::~cbRootIntrospection called:"));
- mReference=(DBusWrapper*)reference;
- std::list<std::string>nodesList=mReference->mNodesList;
- DBusMessage * reply;
+ mReference = (DBusWrapper*) reference;
+ std::list<std::string> nodesList = mReference->mNodesList;
+ DBusMessage * reply;
DBusMessageIter args;
dbus_uint32_t serial = 0;
- if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
- {
- std::list<std::string>::iterator nodeIter=nodesList.begin();
- const char *xml=ROOT_INTROSPECT_XML;
- std::stringstream introspect;
- introspect << std::string(xml);
- for(;nodeIter!=nodesList.end();++nodeIter)
- {
- introspect<<"<node name='"<<nodeIter->c_str()<<"'/>";
- }
- introspect<<"</node>";
-
- reply = dbus_message_new_method_return(msg);
- std::string s = introspect.str();
- const char* string=s.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(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::~cbRootIntrospection DBUS Out Of Memory!"));
- }
-
- // send the reply && flush the connection
- if (!dbus_connection_send(conn, reply, &serial))
- {
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::~cbRootIntrospection DBUS Out Of Memory!"));
- }
- dbus_connection_flush(conn);
- // free the reply
- dbus_message_unref(reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- else
- {
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
+ if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
+ {
+ std::list<std::string>::iterator nodeIter = nodesList.begin();
+ const char *xml = ROOT_INTROSPECT_XML;
+ std::stringstream introspect;
+ introspect << std::string(xml);
+ for (; nodeIter != nodesList.end(); ++nodeIter)
+ {
+ introspect << "<node name='" << nodeIter->c_str() << "'/>";
+ }
+ introspect << "</node>";
+
+ reply = dbus_message_new_method_return(msg);
+ std::string s = introspect.str();
+ const char* string = s.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(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::~cbRootIntrospection DBUS Out Of Memory!"));
+ }
+
+ // send the reply && flush the connection
+ if (!dbus_connection_send(conn, reply, &serial))
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::~cbRootIntrospection DBUS Out Of Memory!"));
+ }
+ dbus_connection_flush(conn);
+ // free the reply
+ dbus_message_unref(reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ else
+ {
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
}
void DBusWrapper::dbusMainLoop()
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::dbusMainLoop Entering MainLoop"));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::dbusMainLoop Entering MainLoop"));
- while (dbus_connection_read_write_dispatch(mDbusConnection, -1))
- {
+ while (dbus_connection_read_write_dispatch(mDbusConnection, -1))
+ {
- }
+ }
}
void DBusWrapper::getDBusConnection(DBusConnection *& connection) const
{
- connection=mDbusConnection;
+ connection = mDbusConnection;
}
dbus_bool_t DBusWrapper::addWatch(DBusWatch *watch, void *userData)
{
- mReference=(DBusWrapper*)userData;
- assert(mReference!=0);
- return mReference->addWatchDelegate(watch,userData);
+ mReference = (DBusWrapper*) userData;
+ assert(mReference!=0);
+ return mReference->addWatchDelegate(watch, userData);
}
dbus_bool_t DBusWrapper::addWatchDelegate(DBusWatch * watch, void* userData)
{
- int16_t event=0;
- sh_pollHandle_t handle=0;
- uint flags=dbus_watch_get_flags(watch);
+ int16_t event = 0;
+ sh_pollHandle_t handle = 0;
+ uint flags = dbus_watch_get_flags(watch);
- /* no watch flags for disabled watches */
+ /* no watch flags for disabled watches */
if (dbus_watch_get_enabled(watch))
{
if (flags & DBUS_WATCH_READABLE) event |= POLLIN;
if (flags & DBUS_WATCH_WRITABLE) event |= POLLOUT;
}
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::addWatchDelegate entered new watch, fd="),DLT_INT(dbus_watch_get_unix_fd(watch)),DLT_STRING("event flag="),DLT_INT(event));
- am_Error_e error=mSocketHandler->addFDPoll(dbus_watch_get_unix_fd(watch),event,NULL,&pDbusFireCallback,&pDbusCheckCallback,&pDbusDispatchCallback,watch,handle);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::addWatchDelegate entered new watch, fd="), DLT_INT(dbus_watch_get_unix_fd(watch)), DLT_STRING("event flag="), DLT_INT(event));
+ am_Error_e error = mSocketHandler->addFDPoll(dbus_watch_get_unix_fd(watch), event, NULL, &pDbusFireCallback, &pDbusCheckCallback, &pDbusDispatchCallback, watch, handle);
- //if everything is alright, add the watch and the handle to our map so we know this relationship
- if (error==E_OK && handle!=0)
- {
- mMapHandleWatch.insert(std::make_pair(watch,handle));
- return true;
- }
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::addWatchDelegate entering watch failed"));
+ //if everything is alright, add the watch and the handle to our map so we know this relationship
+ if (error == E_OK && handle != 0)
+ {
+ mMapHandleWatch.insert(std::make_pair(watch, handle));
+ return true;
+ }DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::addWatchDelegate entering watch failed"));
}
void DBusWrapper::removeWatch(DBusWatch *watch, void *userData)
{
- mReference=(DBusWrapper*)userData;
- assert(mReference!=0);
- mReference->removeWatchDelegate(watch,userData);
+ mReference = (DBusWrapper*) userData;
+ assert(mReference!=0);
+ mReference->removeWatchDelegate(watch, userData);
}
void DBusWrapper::removeWatchDelegate(DBusWatch *watch, void *userData)
{
- std::map<DBusWatch*,sh_pollHandle_t>::iterator iterator=mMapHandleWatch.begin();
- iterator=mMapHandleWatch.find(watch);
- if (iterator!=mMapHandleWatch.end()) mSocketHandler->removeFDPoll(iterator->second);
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::removeWatch removed watch with handle"),DLT_INT(iterator->second));
- mMapHandleWatch.erase(iterator);
+ std::map<DBusWatch*, sh_pollHandle_t>::iterator iterator = mMapHandleWatch.begin();
+ iterator = mMapHandleWatch.find(watch);
+ if (iterator != mMapHandleWatch.end()) mSocketHandler->removeFDPoll(iterator->second);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::removeWatch removed watch with handle"), DLT_INT(iterator->second));
+ mMapHandleWatch.erase(iterator);
}
void DBusWrapper::toogleWatch(DBusWatch *watch, void *userData)
{
- mReference=(DBusWrapper*)userData;
- assert(mReference!=0);
- mReference->toogleWatchDelegate(watch,userData);
+ mReference = (DBusWrapper*) userData;
+ assert(mReference!=0);
+ mReference->toogleWatchDelegate(watch, userData);
}
void DBusWrapper::toogleWatchDelegate(DBusWatch *watch, void *userData)
{
- int16_t event=0;
- int watchFD=dbus_watch_get_unix_fd(watch);
- uint flags=dbus_watch_get_flags(watch);
- /* no watch flags for disabled watches */
- if (dbus_watch_get_enabled(watch))
- {
- if (flags & DBUS_WATCH_READABLE) event |= POLLIN;
- if (flags & DBUS_WATCH_WRITABLE) event |= POLLOUT;
- }
- std::map<DBusWatch*,sh_pollHandle_t>::iterator iterator=mMapHandleWatch.begin();
- iterator=mMapHandleWatch.find(watch);
- if (iterator!=mMapHandleWatch.end()) mSocketHandler->updateEventFlags(iterator->second,event);
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::toogleWatchDelegate watch was toggeled"));
+ int16_t event = 0;
+ int watchFD = dbus_watch_get_unix_fd(watch);
+ uint flags = dbus_watch_get_flags(watch);
+ /* no watch flags for disabled watches */
+ if (dbus_watch_get_enabled(watch))
+ {
+ if (flags & DBUS_WATCH_READABLE) event |= POLLIN;
+ if (flags & DBUS_WATCH_WRITABLE) event |= POLLOUT;
+ }
+ std::map<DBusWatch*, sh_pollHandle_t>::iterator iterator = mMapHandleWatch.begin();
+ iterator = mMapHandleWatch.find(watch);
+ if (iterator != mMapHandleWatch.end()) mSocketHandler->updateEventFlags(iterator->second, event);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::toogleWatchDelegate watch was toggeled"));
}
dbus_bool_t DBusWrapper::addTimeout(DBusTimeout *timeout, void* userData)
{
- mReference=(DBusWrapper*)userData;
- assert(mReference!=0);
- return mReference->addTimeoutDelegate(timeout,userData);
+ mReference = (DBusWrapper*) userData;
+ assert(mReference!=0);
+ return mReference->addTimeoutDelegate(timeout, userData);
}
-dbus_bool_t DBusWrapper::addTimeoutDelegate(DBusTimeout *timeout,void* userData)
+dbus_bool_t DBusWrapper::addTimeoutDelegate(DBusTimeout *timeout, void* userData)
{
if (!dbus_timeout_get_enabled(timeout)) return false;
//calculate the timeout in timeval
timespec pollTimeout;
- int localTimeout=dbus_timeout_get_interval(timeout);
- pollTimeout.tv_sec=localTimeout/1000;
- pollTimeout.tv_nsec=(localTimeout%1000)*1000000;
+ int localTimeout = dbus_timeout_get_interval(timeout);
+ pollTimeout.tv_sec = localTimeout / 1000;
+ pollTimeout.tv_nsec = (localTimeout % 1000) * 1000000;
//prepare handle and callback. new is eval, but there is no other choice because we need the pointer!
- sh_timerHandle_t* handle=new sh_timerHandle_t;
+ sh_timerHandle_t* handle = new sh_timerHandle_t;
mListTimerhandlePointer.push_back(handle);
- shTimerCallBack* buffer=&pDbusTimerCallback;
+ shTimerCallBack* buffer = &pDbusTimerCallback;
//add the timer to the pollLoop
- mSocketHandler->addTimer(pollTimeout,buffer,*handle,timeout);
+ mSocketHandler->addTimer(pollTimeout, buffer, *handle, timeout);
//save the handle with dbus context
dbus_timeout_set_data(timeout, handle, NULL);
//save timeout in Socket context
- userData=timeout;
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::addTimeoutDelegate a timeout was added"));
+ userData = timeout;
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::addTimeoutDelegate a timeout was added"));
return true;
}
void DBusWrapper::removeTimeout(DBusTimeout *timeout, void* userData)
{
- mReference=(DBusWrapper*)userData;
- assert(mReference!=0);
- mReference->removeTimeoutDelegate(timeout,userData);
+ mReference = (DBusWrapper*) userData;
+ assert(mReference!=0);
+ mReference->removeTimeoutDelegate(timeout, userData);
}
void DBusWrapper::removeTimeoutDelegate(DBusTimeout *timeout, void* userData)
{
- //get the pointer to the handle and remove the timer
- sh_timerHandle_t* handle=(sh_timerHandle_t*)dbus_timeout_get_data(timeout);
- mSocketHandler->removeTimer(*handle);
-
- //now go throught the timerlist and remove the pointer, free memory
- std::vector<sh_timerHandle_t*>::iterator it=mListTimerhandlePointer.begin();
- for(;it!=mListTimerhandlePointer.end();++it)
- {
- if (*it==handle)
- {
- mListTimerhandlePointer.erase(it);
- break;
- }
- }
- delete handle;
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::removeTimeoutDelegate a timeout was removed"));
+ //get the pointer to the handle and remove the timer
+ sh_timerHandle_t* handle = (sh_timerHandle_t*) dbus_timeout_get_data(timeout);
+ mSocketHandler->removeTimer(*handle);
+
+ //now go throught the timerlist and remove the pointer, free memory
+ std::vector<sh_timerHandle_t*>::iterator it = mListTimerhandlePointer.begin();
+ for (; it != mListTimerhandlePointer.end(); ++it)
+ {
+ if (*it == handle)
+ {
+ mListTimerhandlePointer.erase(it);
+ break;
+ }
+ }
+ delete handle;
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::removeTimeoutDelegate a timeout was removed"));
}
void DBusWrapper::toggleTimeout(DBusTimeout *timeout, void* userData)
{
- mReference=(DBusWrapper*)userData;
- assert(mReference!=0);
- mReference->toggleTimeoutDelegate(timeout,userData);
+ mReference = (DBusWrapper*) userData;
+ assert(mReference!=0);
+ mReference->toggleTimeoutDelegate(timeout, userData);
}
bool am::DBusWrapper::dbusDispatchCallback(const sh_pollHandle_t handle, void *userData)
{
- bool returnVal=true;
- dbus_connection_ref(mDbusConnection);
- if (dbus_connection_dispatch(mDbusConnection)==DBUS_DISPATCH_COMPLETE) returnVal=false;
+ bool returnVal = true;
+ dbus_connection_ref(mDbusConnection);
+ if (dbus_connection_dispatch(mDbusConnection) == DBUS_DISPATCH_COMPLETE) returnVal = false;
dbus_connection_unref(mDbusConnection);
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::dbusDispatchCallback was called"));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::dbusDispatchCallback was called"));
return returnVal;
}
bool am::DBusWrapper::dbusCheckCallback(const sh_pollHandle_t handle, void *userData)
{
- bool returnVal=false;
- dbus_connection_ref(mDbusConnection);
- if (dbus_connection_get_dispatch_status(mDbusConnection) == DBUS_DISPATCH_DATA_REMAINS) returnVal=true;
+ bool returnVal = false;
+ dbus_connection_ref(mDbusConnection);
+ if (dbus_connection_get_dispatch_status(mDbusConnection) == DBUS_DISPATCH_DATA_REMAINS) returnVal = true;
dbus_connection_unref(mDbusConnection);
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::dbusCheckCallback was called"));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::dbusCheckCallback was called"));
return returnVal;
}
void am::DBusWrapper::dbusFireCallback(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
{
- assert(userData!=NULL);
- uint flags=0;
+ assert(userData!=NULL);
+ uint flags = 0;
- if (pollfd.revents & POLLIN) flags |= DBUS_WATCH_READABLE;
- if (pollfd.revents & POLLOUT) flags |= DBUS_WATCH_WRITABLE;
- if (pollfd.revents & POLLHUP) flags |= DBUS_WATCH_HANGUP;
- if (pollfd.revents & POLLERR) flags |= DBUS_WATCH_ERROR;
+ if (pollfd.revents & POLLIN) flags |= DBUS_WATCH_READABLE;
+ if (pollfd.revents & POLLOUT) flags |= DBUS_WATCH_WRITABLE;
+ if (pollfd.revents & POLLHUP) flags |= DBUS_WATCH_HANGUP;
+ if (pollfd.revents & POLLERR) flags |= DBUS_WATCH_ERROR;
- DBusWatch *watch=(DBusWatch*)userData;
+ DBusWatch *watch = (DBusWatch*) userData;
- dbus_connection_ref(mDbusConnection);
- bool ok=dbus_watch_handle(watch, flags);
- dbus_connection_unref(mDbusConnection);
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::dbusFireCallback was called"));
+ dbus_connection_ref(mDbusConnection);
+ bool ok = dbus_watch_handle(watch, flags);
+ dbus_connection_unref(mDbusConnection);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::dbusFireCallback was called"));
}
void DBusWrapper::toggleTimeoutDelegate(DBusTimeout *timeout, void* userData)
{
- //get the pointer to the handle and remove the timer
- sh_timerHandle_t* handle=(sh_timerHandle_t*)dbus_timeout_get_data(timeout);
-
- //stop or restart?
- if (dbus_timeout_get_enabled(timeout))
- {
- //calculate the timeout in timeval
- timespec pollTimeout;
- int localTimeout=dbus_timeout_get_interval(timeout);
- pollTimeout.tv_sec=localTimeout/1000;
- pollTimeout.tv_nsec=(localTimeout%1000)*1000000;
- mSocketHandler->restartTimer(*handle,pollTimeout);
- }
- else
- {
- mSocketHandler->stopTimer(*handle);
- }
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::toggleTimeoutDelegate was called"));
+ //get the pointer to the handle and remove the timer
+ sh_timerHandle_t* handle = (sh_timerHandle_t*) dbus_timeout_get_data(timeout);
+
+ //stop or restart?
+ if (dbus_timeout_get_enabled(timeout))
+ {
+ //calculate the timeout in timeval
+ timespec pollTimeout;
+ int localTimeout = dbus_timeout_get_interval(timeout);
+ pollTimeout.tv_sec = localTimeout / 1000;
+ pollTimeout.tv_nsec = (localTimeout % 1000) * 1000000;
+ mSocketHandler->restartTimer(*handle, pollTimeout);
+ }
+ else
+ {
+ mSocketHandler->stopTimer(*handle);
+ }DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::toggleTimeoutDelegate was called"));
}
void DBusWrapper::dbusTimerCallback(sh_timerHandle_t handle, void *userData)
{
- assert(userData!=NULL);
- if (dbus_timeout_get_enabled((DBusTimeout*)userData))
- {
- timespec ts;
- ts.tv_nsec=-1;
- ts.tv_sec=-1;
- mSocketHandler->restartTimer(handle,ts);
- }
- dbus_timeout_handle((DBusTimeout*)userData);
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::dbusTimerCallback was called"));
+ assert(userData!=NULL);
+ if (dbus_timeout_get_enabled((DBusTimeout*) userData))
+ {
+ timespec ts;
+ ts.tv_nsec = -1;
+ ts.tv_sec = -1;
+ mSocketHandler->restartTimer(handle, ts);
+ }
+ dbus_timeout_handle((DBusTimeout*) userData);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::dbusTimerCallback was called"));
}
-
-
-
-
-
-
-
-
-
-
-
diff --git a/AudioManagerDaemon/src/DatabaseHandler.cpp b/AudioManagerDaemon/src/DatabaseHandler.cpp
index c712fbd..6a17b2b 100644
--- a/AudioManagerDaemon/src/DatabaseHandler.cpp
+++ b/AudioManagerDaemon/src/DatabaseHandler.cpp
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file Databasehandler.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file Databasehandler.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#include "DatabaseHandler.h"
#include "DatabaseObserver.h"
@@ -49,18 +49,13 @@ DLT_IMPORT_CONTEXT(AudioManager)
using namespace am;
-const std::string databaseTables[]={
- " Domains (domainID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), busname VARCHAR(50), nodename VARCHAR(50), early BOOL, complete BOOL, state INTEGER, reserved BOOL);",
- " SourceClasses (sourceClassID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50));",
- " SinkClasses (sinkClassID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50));",
- " Sources (sourceID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, domainID INTEGER, name VARCHAR(50), sourceClassID INTEGER, sourceState INTEGER, volume INTEGER, visible BOOL, availability INTEGER, availabilityReason INTEGER, interruptState INTEGER, reserved BOOL);",
- " Sinks (sinkID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), domainID INTEGER, sinkClassID INTEGER, volume INTEGER, visible BOOL, availability INTEGER, availabilityReason INTEGER, muteState INTEGER, mainVolume INTEGER, reserved BOOL);",
- " Gateways (gatewayID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), sinkID INTEGER, sourceID INTEGER, domainSinkID INTEGER, domainSourceID INTEGER, controlDomainID INTEGER, inUse BOOL);",
- " Crossfaders (crossfaderID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), sinkID_A INTEGER, sinkID_B INTEGER, sourceID INTEGER, hotSink INTEGER);",
- " Connections (connectionID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, sourceID INTEGER, sinkID INTEGER, delay INTEGER, connectionFormat INTEGER, reserved BOOL);",
- " MainConnections (mainConnectionID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, sourceID INTEGER, sinkID INTEGER, connectionState INTEGER, delay INTEGER);",
- " SystemProperties (type INTEGER PRIMARY KEY, value INTEGER);"
-};
+const std::string databaseTables[] =
+{ //
+ " Domains (domainID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), busname VARCHAR(50), nodename VARCHAR(50), early BOOL, complete BOOL, state INTEGER, reserved BOOL);", " SourceClasses (sourceClassID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50));", " SinkClasses (sinkClassID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50));",
+ " Sources (sourceID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, domainID INTEGER, name VARCHAR(50), sourceClassID INTEGER, sourceState INTEGER, volume INTEGER, visible BOOL, availability INTEGER, availabilityReason INTEGER, interruptState INTEGER, reserved BOOL);", //
+ " Sinks (sinkID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), domainID INTEGER, sinkClassID INTEGER, volume INTEGER, visible BOOL, availability INTEGER, availabilityReason INTEGER, muteState INTEGER, mainVolume INTEGER, reserved BOOL);", " Gateways (gatewayID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), sinkID INTEGER, sourceID INTEGER, domainSinkID INTEGER, domainSourceID INTEGER, controlDomainID INTEGER, inUse BOOL);", " Crossfaders (crossfaderID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), sinkID_A INTEGER, sinkID_B INTEGER, sourceID INTEGER, hotSink INTEGER);",
+ " Connections (connectionID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, sourceID INTEGER, sinkID INTEGER, delay INTEGER, connectionFormat INTEGER, reserved BOOL);", //
+ " MainConnections (mainConnectionID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, sourceID INTEGER, sinkID INTEGER, connectionState INTEGER, delay INTEGER);", " SystemProperties (type INTEGER PRIMARY KEY, value INTEGER);" };
/**
* template to converts T to std::string
@@ -70,3843 +65,3708 @@ const std::string databaseTables[]={
template<typename T>
inline std::string i2s(T const& x)
{
- std::ostringstream o;
- o << x;
- return o.str();
+ std::ostringstream o;
+ o << x;
+ return o.str();
}
-DatabaseHandler::DatabaseHandler(std::string databasePath)
- : mDatabase(NULL),
- mPath(databasePath),
- mDatabaseObserver(NULL),
- mFirstStaticSink(true),
- mFirstStaticSource(true),
- mFirstStaticGateway(true),
- mFirstStaticSinkClass(true),
- mFirstStaticSourceClass(true),
- mListConnectionFormat()
+DatabaseHandler::DatabaseHandler(std::string databasePath) :
+ mDatabase(NULL), //
+ mPath(databasePath), //
+ mDatabaseObserver(NULL), //
+ mFirstStaticSink(true), //
+ mFirstStaticSource(true), //
+ mFirstStaticGateway(true), //
+ mFirstStaticSinkClass(true), //
+ mFirstStaticSourceClass(true), //
+ mListConnectionFormat()
{
- /**
- *\todo: this erases the database. just for testing!
- */
- std::ifstream infile(mPath.c_str());
+ /**
+ *\todo: this erases the database. just for testing!
+ */
+ std::ifstream infile(mPath.c_str());
- if (infile)
- {
- remove(mPath.c_str());
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::DatabaseHandler Knocked down database"));
- }
+ if (infile)
+ {
+ remove(mPath.c_str());
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::DatabaseHandler Knocked down database"));
+ }
- bool dbOpen=openDatabase();
- if (!dbOpen)
- {
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::DatabaseHandler problems opening the database!"));
- assert(!dbOpen);
- }
+ bool dbOpen = openDatabase();
+ if (!dbOpen)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::DatabaseHandler problems opening the database!"));
+ assert(!dbOpen);
+ }
- createTables();
+ createTables();
}
-
-
DatabaseHandler::~DatabaseHandler()
{
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("Closed Database"));
- sqlite3_close(mDatabase);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("Closed Database"));
+ sqlite3_close(mDatabase);
}
am_Error_e DatabaseHandler::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID)
{
- assert(domainData.domainID==0);
- assert(!domainData.name.empty());
- assert(!domainData.busname.empty());
- assert(domainData.state>=DS_CONTROLLED && domainData.state<=DS_INDEPENDENT_RUNDOWN);
-
- //first check for a reserved domain
- sqlite3_stmt* query=NULL, *queryFinal;
- int eCode=0;
- std::string command="SELECT domainID FROM "+ std::string(DOMAIN_TABLE) + " WHERE name=?";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1, domainData.name.c_str(),domainData.name.size(),SQLITE_STATIC);
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- command= "UPDATE " + std::string(DOMAIN_TABLE) + " SET name=?, busname=?, nodename=?, early=?, complete=?, state=?, reserved=? WHERE domainID=" +i2s(sqlite3_column_int(query,0));
- }
- else if (eCode==SQLITE_DONE)
- {
-
- command= "INSERT INTO " + std::string(DOMAIN_TABLE) + " (name, busname, nodename, early, complete, state, reserved) VALUES (?,?,?,?,?,?,?)";
- }
- else
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterDomainDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterDomainDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&queryFinal,NULL);
- sqlite3_bind_text(queryFinal,1, domainData.name.c_str(),domainData.name.size(),SQLITE_STATIC);
- sqlite3_bind_text(queryFinal,2, domainData.busname.c_str(),domainData.busname.size(),SQLITE_STATIC);
- sqlite3_bind_text(queryFinal,3, domainData.nodename.c_str(),domainData.nodename.size(),SQLITE_STATIC);
- sqlite3_bind_int(queryFinal,4, domainData.early);
- sqlite3_bind_int(queryFinal,5, domainData.complete);
- sqlite3_bind_int(queryFinal,6, domainData.state);
- sqlite3_bind_int(queryFinal,7, 0);
-
- if((eCode=sqlite3_step(queryFinal))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterDomainDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(queryFinal))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterDomainDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- domainID=sqlite3_last_insert_rowid(mDatabase);
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterDomainDB entered new domain with name"), DLT_STRING(domainData.name.c_str()),
- DLT_STRING("busname:"),DLT_STRING(domainData.busname.c_str()),
- DLT_STRING("nodename:"),DLT_STRING(domainData.nodename.c_str()),
- DLT_STRING("early:"), DLT_BOOL(domainData.early),
- DLT_STRING("complete:"),DLT_BOOL(domainData.complete),
- DLT_STRING("state:"),DLT_INT(domainData.state),
- DLT_STRING("assigned ID:"),DLT_INT16(domainID));
-
- am_Domain_s domain=domainData;
- domain.domainID=domainID;
- if(mDatabaseObserver) mDatabaseObserver->newDomain(domain);
-
- return E_OK;
+ assert(domainData.domainID==0);
+ assert(!domainData.name.empty());
+ assert(!domainData.busname.empty());
+ assert(domainData.state>=DS_CONTROLLED && domainData.state<=DS_INDEPENDENT_RUNDOWN);
+
+ //first check for a reserved domain
+ sqlite3_stmt* query = NULL, *queryFinal;
+ int eCode = 0;
+ std::string command = "SELECT domainID FROM " + std::string(DOMAIN_TABLE) + " WHERE name=?";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, domainData.name.c_str(), domainData.name.size(), SQLITE_STATIC);
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ command = "UPDATE " + std::string(DOMAIN_TABLE) + " SET name=?, busname=?, nodename=?, early=?, complete=?, state=?, reserved=? WHERE domainID=" + i2s(sqlite3_column_int(query, 0));
+ }
+ else if (eCode == SQLITE_DONE)
+ {
+
+ command = "INSERT INTO " + std::string(DOMAIN_TABLE) + " (name, busname, nodename, early, complete, state, reserved) VALUES (?,?,?,?,?,?,?)";
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterDomainDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterDomainDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &queryFinal, NULL);
+ sqlite3_bind_text(queryFinal, 1, domainData.name.c_str(), domainData.name.size(), SQLITE_STATIC);
+ sqlite3_bind_text(queryFinal, 2, domainData.busname.c_str(), domainData.busname.size(), SQLITE_STATIC);
+ sqlite3_bind_text(queryFinal, 3, domainData.nodename.c_str(), domainData.nodename.size(), SQLITE_STATIC);
+ sqlite3_bind_int(queryFinal, 4, domainData.early);
+ sqlite3_bind_int(queryFinal, 5, domainData.complete);
+ sqlite3_bind_int(queryFinal, 6, domainData.state);
+ sqlite3_bind_int(queryFinal, 7, 0);
+
+ if ((eCode = sqlite3_step(queryFinal)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterDomainDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(queryFinal)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterDomainDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ domainID = sqlite3_last_insert_rowid(mDatabase);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterDomainDB entered new domain with name"), DLT_STRING(domainData.name.c_str()), DLT_STRING("busname:"), DLT_STRING(domainData.busname.c_str()), DLT_STRING("nodename:"), DLT_STRING(domainData.nodename.c_str()), DLT_STRING("early:"), DLT_BOOL(domainData.early), DLT_STRING("complete:"), DLT_BOOL(domainData.complete), DLT_STRING("state:"), DLT_INT(domainData.state), DLT_STRING("assigned ID:"), DLT_INT16(domainID));
+
+ am_Domain_s domain = domainData;
+ domain.domainID = domainID;
+ if (mDatabaseObserver) mDatabaseObserver->newDomain(domain);
+
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::enterMainConnectionDB(const am_MainConnection_s & mainConnectionData, am_mainConnectionID_t & connectionID)
{
- assert(mainConnectionData.connectionID==0);
- assert(mainConnectionData.connectionState>=CS_CONNECTING && mainConnectionData.connectionState<=CS_SUSPENDED);
- assert(mainConnectionData.route.sinkID!=0);
- assert(mainConnectionData.route.sourceID!=0);
-
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command= "INSERT INTO " + std::string(MAINCONNECTION_TABLE) + "(sourceID, sinkID, connectionState, delay) VALUES (?,?,?,-1)";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, mainConnectionData.route.sourceID);
- sqlite3_bind_int(query,2, mainConnectionData.route.sinkID);
- sqlite3_bind_int(query,3, mainConnectionData.connectionState);
-
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- connectionID=sqlite3_last_insert_rowid(mDatabase);
-
- //now check the connectionTable for all connections in the route. IF a particular route is not found, we return with error
- std::vector<uint16_t> listOfConnections;
- int16_t delay=0;
- command="SELECT connectionID, delay FROM "+std::string(CONNECTION_TABLE)+(" WHERE sourceID=? AND sinkID=? AND connectionFormat=?");
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<am_RoutingElement_s>::const_iterator elementIterator=mainConnectionData.route.route.begin();
- for (;elementIterator<mainConnectionData.route.route.end();++elementIterator)
- {
- sqlite3_bind_int(query,1, elementIterator->sourceID);
- sqlite3_bind_int(query,2, elementIterator->sinkID);
- sqlite3_bind_int(query,3, elementIterator->connectionFormat);
-
- if((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- listOfConnections.push_back(sqlite3_column_int(query,0));
- int16_t temp_delay=sqlite3_column_int(query,1);
- if (temp_delay!=-1 && delay!=-1) delay+=temp_delay;
- else delay=-1;
- }
- else
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB did not find route for MainConnection:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- //now we create a table with references to the connections;
- command="CREATE TABLE MainConnectionRoute" + i2s(connectionID) + std::string("(connectionID INTEGER)");
- assert(this->sqQuery(command));
-
- command= "INSERT INTO MainConnectionRoute" + i2s(connectionID) + "(connectionID) VALUES (?)";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<uint16_t>::iterator listConnectionIterator=listOfConnections.begin();
- for(;listConnectionIterator<listOfConnections.end();++listConnectionIterator)
- {
- sqlite3_bind_int(query,1, *listConnectionIterator);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterMainConnectionDB entered new mainConnection with sourceID"), DLT_INT(mainConnectionData.route.sourceID),
- DLT_STRING("sinkID:"),DLT_INT16(mainConnectionData.route.sinkID),
- DLT_STRING("delay:"),DLT_INT16(delay),
- DLT_STRING("assigned ID:"),DLT_INT16(connectionID));
-
- if (mDatabaseObserver)
- {
- mDatabaseObserver->numberOfMainConnectionsChanged();
- mDatabaseObserver->mainConnectionStateChanged(connectionID,mainConnectionData.connectionState);
- }
-
- //finally, we update the delay value for the maintable
- if (delay==0) delay=-1;
- return changeDelayMainConnection(delay,connectionID);
+ assert(mainConnectionData.connectionID==0);
+ assert(mainConnectionData.connectionState>=CS_CONNECTING && mainConnectionData.connectionState<=CS_SUSPENDED);
+ assert(mainConnectionData.route.sinkID!=0);
+ assert(mainConnectionData.route.sourceID!=0);
+
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command = "INSERT INTO " + std::string(MAINCONNECTION_TABLE) + "(sourceID, sinkID, connectionState, delay) VALUES (?,?,?,-1)";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, mainConnectionData.route.sourceID);
+ sqlite3_bind_int(query, 2, mainConnectionData.route.sinkID);
+ sqlite3_bind_int(query, 3, mainConnectionData.connectionState);
+
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ connectionID = sqlite3_last_insert_rowid(mDatabase);
+
+ //now check the connectionTable for all connections in the route. IF a particular route is not found, we return with error
+ std::vector<uint16_t> listOfConnections;
+ int16_t delay = 0;
+ command = "SELECT connectionID, delay FROM " + std::string(CONNECTION_TABLE) + (" WHERE sourceID=? AND sinkID=? AND connectionFormat=?");
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<am_RoutingElement_s>::const_iterator elementIterator = mainConnectionData.route.route.begin();
+ for (; elementIterator < mainConnectionData.route.route.end(); ++elementIterator)
+ {
+ sqlite3_bind_int(query, 1, elementIterator->sourceID);
+ sqlite3_bind_int(query, 2, elementIterator->sinkID);
+ sqlite3_bind_int(query, 3, elementIterator->connectionFormat);
+
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ listOfConnections.push_back(sqlite3_column_int(query, 0));
+ int16_t temp_delay = sqlite3_column_int(query, 1);
+ if (temp_delay != -1 && delay != -1)
+ delay += temp_delay;
+ else
+ delay = -1;
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB did not find route for MainConnection:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //now we create a table with references to the connections;
+ command = "CREATE TABLE MainConnectionRoute" + i2s(connectionID) + std::string("(connectionID INTEGER)");
+ assert(this->sqQuery(command));
+
+ command = "INSERT INTO MainConnectionRoute" + i2s(connectionID) + "(connectionID) VALUES (?)";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<uint16_t>::iterator listConnectionIterator = listOfConnections.begin();
+ for (; listConnectionIterator < listOfConnections.end(); ++listConnectionIterator)
+ {
+ sqlite3_bind_int(query, 1, *listConnectionIterator);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterMainConnectionDB entered new mainConnection with sourceID"), DLT_INT(mainConnectionData.route.sourceID), DLT_STRING("sinkID:"), DLT_INT16(mainConnectionData.route.sinkID), DLT_STRING("delay:"), DLT_INT16(delay), DLT_STRING("assigned ID:"), DLT_INT16(connectionID));
+
+ if (mDatabaseObserver)
+ {
+ mDatabaseObserver->numberOfMainConnectionsChanged();
+ mDatabaseObserver->mainConnectionStateChanged(connectionID, mainConnectionData.connectionState);
+ }
+
+ //finally, we update the delay value for the maintable
+ if (delay == 0) delay = -1;
+ return changeDelayMainConnection(delay, connectionID);
}
-
-
am_Error_e DatabaseHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
{
- assert(sinkData.sinkID<DYNAMIC_ID_BOUNDARY);
- assert(sinkData.domainID!=0);
- assert(!sinkData.name.empty());
- assert(sinkData.sinkClassID!=0); // \todo: need to check if class exists?
- assert(!sinkData.listConnectionFormats.empty());
- assert(sinkData.muteState>=MS_MUTED && sinkData.muteState<=MS_UNMUTED);
-
- sqlite3_stmt *query=NULL, *queryFinal=NULL;
- int eCode=0;
- std::string command="SELECT sinkID FROM "+ std::string(SINK_TABLE) + " WHERE name=? AND reserved=1";
-
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1, sinkData.name.c_str(),sinkData.name.size(),SQLITE_STATIC);
-
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- command= "UPDATE " + std::string(SINK_TABLE) + " SET name=?, domainID=?, sinkClassID=?, volume=?, visible=?, availability=?, availabilityReason=?, muteState=?, mainVolume=?, reserved=? WHERE sinkID=" +i2s(sqlite3_column_int(query,0));
- }
- else if (eCode==SQLITE_DONE)
- {
- //if sinkID is zero and the first Static Sink was already entered, the ID is created
- if (sinkData.sinkID==0 && !mFirstStaticSink && !existSinkName(sinkData.name))
- {
- command= "INSERT INTO " + std::string(SINK_TABLE) + "(name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, reserved) VALUES (?,?,?,?,?,?,?,?,?,?)";
- }
- else
- {
- //check if the ID already exists
- if(existSinkNameOrID(sinkData.sinkID,sinkData.name))
- {
- sqlite3_finalize(query);
- return E_ALREADY_EXISTS;
- }
- command= "INSERT INTO " + std::string(SINK_TABLE) + "(name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, reserved, sinkID) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
- }
- }
- else
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
- sqlite3_finalize(query);
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&queryFinal,NULL);
- sqlite3_bind_text(queryFinal,1, sinkData.name.c_str(),sinkData.name.size(),SQLITE_STATIC);
- sqlite3_bind_int(queryFinal,2, sinkData.domainID);
- sqlite3_bind_int(queryFinal,3, sinkData.sinkClassID);
- sqlite3_bind_int(queryFinal,4, sinkData.volume);
- sqlite3_bind_int(queryFinal,5, sinkData.visible);
- sqlite3_bind_int(queryFinal,6, sinkData.available.availability);
- sqlite3_bind_int(queryFinal,7, sinkData.available.availabilityReason);
- sqlite3_bind_int(queryFinal,8, sinkData.muteState);
- sqlite3_bind_int(queryFinal,9, sinkData.mainVolume);
- sqlite3_bind_int(queryFinal,10, 0);
-
- //if the ID is not created, we add it to the query
- if(sinkData.sinkID!=0)
- {
- sqlite3_bind_int(queryFinal,11, sinkData.sinkID);
- }
-
- //if the first static sink is entered, we need to set it onto the boundary
- else if(mFirstStaticSink)
- {
- sqlite3_bind_int(queryFinal,11, DYNAMIC_ID_BOUNDARY);
- mFirstStaticSink=false;
- }
-
- if((eCode=sqlite3_step(queryFinal))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
- sqlite3_finalize(queryFinal);
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(queryFinal))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- //now read back the sinkID
- command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE name=?";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1,sinkData.name.c_str(),sinkData.name.size(),SQLITE_STATIC);
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- sinkID=sqlite3_column_int(query,0);
- }
- else
- {
- sinkID=0;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
- sqlite3_finalize(query);
- return E_DATABASE_ERROR;
- }
- sqlite3_finalize(query);
-
- //now we need to create the additional tables:
- command="CREATE TABLE SinkConnectionFormat" + i2s(sinkID) + std::string("(soundFormat INTEGER)");
- assert(this->sqQuery(command));
- command="CREATE TABLE SinkMainSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
- assert(this->sqQuery(command));
- command="CREATE TABLE SinkSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
- assert(this->sqQuery(command));
-
- //fill ConnectionFormats
- command="INSERT INTO SinkConnectionFormat" + i2s(sinkID) + std::string("(soundFormat) VALUES (?)");
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<am_ConnectionFormat_e>::const_iterator connectionFormatIterator=sinkData.listConnectionFormats.begin();
- for(;connectionFormatIterator<sinkData.listConnectionFormats.end();++connectionFormatIterator)
- {
- sqlite3_bind_int(query,1, *connectionFormatIterator);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
- sqlite3_finalize(query);
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- //Fill MainSinkSoundProperties
- command="INSERT INTO SinkMainSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType,value) VALUES (?,?)");
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<am_MainSoundProperty_s>::const_iterator mainSoundPropertyIterator=sinkData.listMainSoundProperties.begin();
- for(;mainSoundPropertyIterator<sinkData.listMainSoundProperties.end();++mainSoundPropertyIterator)
- {
- sqlite3_bind_int(query,1, mainSoundPropertyIterator->type);
- sqlite3_bind_int(query,2, mainSoundPropertyIterator->value);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
- sqlite3_finalize(query);
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- //Fill SinkSoundProperties
- command="INSERT INTO SinkSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType,value) VALUES (?,?)");
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<am_SoundProperty_s>::const_iterator SoundPropertyIterator=sinkData.listSoundProperties.begin();
- for(;SoundPropertyIterator<sinkData.listSoundProperties.end();++SoundPropertyIterator)
- {
- sqlite3_bind_int(query,1, SoundPropertyIterator->type);
- sqlite3_bind_int(query,2, SoundPropertyIterator->value);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
- sqlite3_finalize(query);
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSinkDB entered new sink with name"), DLT_STRING(sinkData.name.c_str()),
- DLT_STRING("domainID:"),DLT_INT(sinkData.domainID),
- DLT_STRING("classID:"),DLT_INT(sinkData.sinkClassID),
- DLT_STRING("volume:"),DLT_INT(sinkData.volume),
- DLT_STRING("visible:"),DLT_BOOL(sinkData.visible),
- DLT_STRING("available.availability:"),DLT_INT(sinkData.available.availability),
- DLT_STRING("available.availabilityReason:"),DLT_INT(sinkData.available.availabilityReason),
- DLT_STRING("muteState:"),DLT_INT(sinkData.muteState),
- DLT_STRING("mainVolume:"),DLT_INT(sinkData.mainVolume),
- DLT_STRING("assigned ID:"),DLT_INT16(sinkID));
-
- am_Sink_s sink=sinkData;
- sink.sinkID=sinkID;
- if (mDatabaseObserver!=NULL) mDatabaseObserver->newSink(sink);
-
- return E_OK;
+ assert(sinkData.sinkID<DYNAMIC_ID_BOUNDARY);
+ assert(sinkData.domainID!=0);
+ assert(!sinkData.name.empty());
+ assert(sinkData.sinkClassID!=0);
+ // \todo: need to check if class exists?
+ assert(!sinkData.listConnectionFormats.empty());
+ assert(sinkData.muteState>=MS_MUTED && sinkData.muteState<=MS_UNMUTED);
+
+ sqlite3_stmt *query = NULL, *queryFinal = NULL;
+ int eCode = 0;
+ std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE name=? AND reserved=1";
+
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, sinkData.name.c_str(), sinkData.name.size(), SQLITE_STATIC);
+
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ command = "UPDATE " + std::string(SINK_TABLE) + " SET name=?, domainID=?, sinkClassID=?, volume=?, visible=?, availability=?, availabilityReason=?, muteState=?, mainVolume=?, reserved=? WHERE sinkID=" + i2s(sqlite3_column_int(query, 0));
+ }
+ else if (eCode == SQLITE_DONE)
+ {
+ //if sinkID is zero and the first Static Sink was already entered, the ID is created
+ if (sinkData.sinkID == 0 && !mFirstStaticSink && !existSinkName(sinkData.name))
+ {
+ command = "INSERT INTO " + std::string(SINK_TABLE) + "(name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, reserved) VALUES (?,?,?,?,?,?,?,?,?,?)";
+ }
+ else
+ {
+ //check if the ID already exists
+ if (existSinkNameOrID(sinkData.sinkID, sinkData.name))
+ {
+ sqlite3_finalize(query);
+ return E_ALREADY_EXISTS;
+ }
+ command = "INSERT INTO " + std::string(SINK_TABLE) + "(name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, reserved, sinkID) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+ }
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"), DLT_INT(eCode));
+ sqlite3_finalize(query);
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &queryFinal, NULL);
+ sqlite3_bind_text(queryFinal, 1, sinkData.name.c_str(), sinkData.name.size(), SQLITE_STATIC);
+ sqlite3_bind_int(queryFinal, 2, sinkData.domainID);
+ sqlite3_bind_int(queryFinal, 3, sinkData.sinkClassID);
+ sqlite3_bind_int(queryFinal, 4, sinkData.volume);
+ sqlite3_bind_int(queryFinal, 5, sinkData.visible);
+ sqlite3_bind_int(queryFinal, 6, sinkData.available.availability);
+ sqlite3_bind_int(queryFinal, 7, sinkData.available.availabilityReason);
+ sqlite3_bind_int(queryFinal, 8, sinkData.muteState);
+ sqlite3_bind_int(queryFinal, 9, sinkData.mainVolume);
+ sqlite3_bind_int(queryFinal, 10, 0);
+
+ //if the ID is not created, we add it to the query
+ if (sinkData.sinkID != 0)
+ {
+ sqlite3_bind_int(queryFinal, 11, sinkData.sinkID);
+ }
+
+ //if the first static sink is entered, we need to set it onto the boundary
+ else if (mFirstStaticSink)
+ {
+ sqlite3_bind_int(queryFinal, 11, DYNAMIC_ID_BOUNDARY);
+ mFirstStaticSink = false;
+ }
+
+ if ((eCode = sqlite3_step(queryFinal)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"), DLT_INT(eCode));
+ sqlite3_finalize(queryFinal);
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(queryFinal)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //now read back the sinkID
+ command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE name=?";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, sinkData.name.c_str(), sinkData.name.size(), SQLITE_STATIC);
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ sinkID = sqlite3_column_int(query, 0);
+ }
+ else
+ {
+ sinkID = 0;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
+ sqlite3_finalize(query);
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_finalize(query);
+
+ //now we need to create the additional tables:
+ command = "CREATE TABLE SinkConnectionFormat" + i2s(sinkID) + std::string("(soundFormat INTEGER)");
+ assert(this->sqQuery(command));
+ command = "CREATE TABLE SinkMainSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
+ assert(this->sqQuery(command));
+ command = "CREATE TABLE SinkSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
+ assert(this->sqQuery(command));
+
+ //fill ConnectionFormats
+ command = "INSERT INTO SinkConnectionFormat" + i2s(sinkID) + std::string("(soundFormat) VALUES (?)");
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<am_ConnectionFormat_e>::const_iterator connectionFormatIterator = sinkData.listConnectionFormats.begin();
+ for (; connectionFormatIterator < sinkData.listConnectionFormats.end(); ++connectionFormatIterator)
+ {
+ sqlite3_bind_int(query, 1, *connectionFormatIterator);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"), DLT_INT(eCode));
+ sqlite3_finalize(query);
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ //Fill MainSinkSoundProperties
+ command = "INSERT INTO SinkMainSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType,value) VALUES (?,?)");
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<am_MainSoundProperty_s>::const_iterator mainSoundPropertyIterator = sinkData.listMainSoundProperties.begin();
+ for (; mainSoundPropertyIterator < sinkData.listMainSoundProperties.end(); ++mainSoundPropertyIterator)
+ {
+ sqlite3_bind_int(query, 1, mainSoundPropertyIterator->type);
+ sqlite3_bind_int(query, 2, mainSoundPropertyIterator->value);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"), DLT_INT(eCode));
+ sqlite3_finalize(query);
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ //Fill SinkSoundProperties
+ command = "INSERT INTO SinkSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType,value) VALUES (?,?)");
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<am_SoundProperty_s>::const_iterator SoundPropertyIterator = sinkData.listSoundProperties.begin();
+ for (; SoundPropertyIterator < sinkData.listSoundProperties.end(); ++SoundPropertyIterator)
+ {
+ sqlite3_bind_int(query, 1, SoundPropertyIterator->type);
+ sqlite3_bind_int(query, 2, SoundPropertyIterator->value);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"), DLT_INT(eCode));
+ sqlite3_finalize(query);
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSinkDB entered new sink with name"), DLT_STRING(sinkData.name.c_str()), DLT_STRING("domainID:"), DLT_INT(sinkData.domainID), DLT_STRING("classID:"), DLT_INT(sinkData.sinkClassID), DLT_STRING("volume:"), DLT_INT(sinkData.volume), DLT_STRING("visible:"), DLT_BOOL(sinkData.visible), DLT_STRING("available.availability:"), DLT_INT(sinkData.available.availability), DLT_STRING("available.availabilityReason:"), DLT_INT(sinkData.available.availabilityReason), DLT_STRING("muteState:"), DLT_INT(sinkData.muteState), DLT_STRING("mainVolume:"), DLT_INT(sinkData.mainVolume), DLT_STRING("assigned ID:"), DLT_INT16(sinkID));
+
+ am_Sink_s sink = sinkData;
+ sink.sinkID = sinkID;
+ if (mDatabaseObserver != NULL) mDatabaseObserver->newSink(sink);
+
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::enterCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
{
- //todo: implement crossfader
- (void)crossfaderData;
- (void)crossfaderID;
- return E_UNKNOWN;
+ //todo: implement crossfader
+ (void) crossfaderData;
+ (void) crossfaderID;
+ return E_UNKNOWN;
}
-
-
am_Error_e DatabaseHandler::enterGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
{
- assert(gatewayData.gatewayID<DYNAMIC_ID_BOUNDARY);
- assert(gatewayData.sinkID!=0);
- assert(gatewayData.sourceID!=0);
- assert(gatewayData.controlDomainID!=0);
- assert(gatewayData.domainSinkID!=0);
- assert(gatewayData.domainSourceID!=0);
- assert(!gatewayData.name.empty());
- assert(!gatewayData.convertionMatrix.empty());
- assert(!gatewayData.listSinkFormats.empty());
- assert(!gatewayData.listSourceFormats.empty());
-
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
-
- //if sinkID is zero and the first Static Sink was already entered, the ID is created
- if (gatewayData.gatewayID==0 && !mFirstStaticGateway)
- {
- command= "INSERT INTO " + std::string(GATEWAY_TABLE) + "(name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID) VALUES (?,?,?,?,?,?)";
- }
- else
- {
- //check if the ID already exists
- if (existGateway(gatewayData.gatewayID)) return E_ALREADY_EXISTS;
- command= "INSERT INTO " + std::string(GATEWAY_TABLE) + "(name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID, gatewayID) VALUES (?,?,?,?,?,?,?)";
- }
-
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1, gatewayData.name.c_str(),gatewayData.name.size(),SQLITE_STATIC);
- sqlite3_bind_int(query,2, gatewayData.sinkID);
- sqlite3_bind_int(query,3, gatewayData.sourceID);
- sqlite3_bind_int(query,4, gatewayData.domainSinkID);
- sqlite3_bind_int(query,5, gatewayData.domainSourceID);
- sqlite3_bind_int(query,6, gatewayData.controlDomainID);
-
- //if the ID is not created, we add it to the query
- if(gatewayData.gatewayID!=0)
- {
- sqlite3_bind_int(query,7, gatewayData.gatewayID);
- }
-
- //if the first static sink is entered, we need to set it onto the boundary
- else if(mFirstStaticGateway)
- {
- sqlite3_bind_int(query,7, DYNAMIC_ID_BOUNDARY);
- mFirstStaticGateway=false;
- }
-
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterGatewayDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterGatewayDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- gatewayID=sqlite3_last_insert_rowid(mDatabase);
-
- //now the convertion matrix todo: change the map implementation sometimes to blob in sqlite
- mListConnectionFormat.insert(std::make_pair(gatewayID,gatewayData.convertionMatrix));
-
- command="CREATE TABLE GatewaySourceFormat" + i2s(gatewayID) + std::string("(soundFormat INTEGER)");
- assert(this->sqQuery(command));
- command="CREATE TABLE GatewaySinkFormat" + i2s(gatewayID) + std::string("(soundFormat INTEGER)");
- assert(this->sqQuery(command));
-
- //fill ConnectionFormats
- command="INSERT INTO GatewaySourceFormat" + i2s(gatewayID) + std::string("(soundFormat) VALUES (?)");
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<am_ConnectionFormat_e>::const_iterator connectionFormatIterator=gatewayData.listSourceFormats.begin();
- for(;connectionFormatIterator<gatewayData.listSourceFormats.end();++connectionFormatIterator)
- {
- sqlite3_bind_int(query,1, *connectionFormatIterator);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterGatewayDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- command="INSERT INTO GatewaySinkFormat" + i2s(gatewayID) + std::string("(soundFormat) VALUES (?)");
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- connectionFormatIterator=gatewayData.listSinkFormats.begin();
- for(;connectionFormatIterator<gatewayData.listSinkFormats.end();++connectionFormatIterator)
- {
- sqlite3_bind_int(query,1, *connectionFormatIterator);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterGatewayDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
-
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterGatewayDB entered new gateway with name"), DLT_STRING(gatewayData.name.c_str()),
- DLT_STRING("sourceID:"),DLT_INT(gatewayData.sourceID),
- DLT_STRING("sinkID:"),DLT_INT(gatewayData.sinkID),
- DLT_STRING("domainSinkID:"),DLT_INT(gatewayData.domainSinkID),
- DLT_STRING("domainSourceID:"),DLT_BOOL(gatewayData.domainSourceID),
- DLT_STRING("controlDomainID:"),DLT_INT(gatewayData.controlDomainID),
- DLT_STRING("assigned ID:"),DLT_INT16(gatewayID));
-
- am_Gateway_s gateway=gatewayData;
- gateway.gatewayID=gatewayID;
- if(mDatabaseObserver) mDatabaseObserver->newGateway(gateway);
- return E_OK;
+ assert(gatewayData.gatewayID<DYNAMIC_ID_BOUNDARY);
+ assert(gatewayData.sinkID!=0);
+ assert(gatewayData.sourceID!=0);
+ assert(gatewayData.controlDomainID!=0);
+ assert(gatewayData.domainSinkID!=0);
+ assert(gatewayData.domainSourceID!=0);
+ assert(!gatewayData.name.empty());
+ assert(!gatewayData.convertionMatrix.empty());
+ assert(!gatewayData.listSinkFormats.empty());
+ assert(!gatewayData.listSourceFormats.empty());
+
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
+
+ //if sinkID is zero and the first Static Sink was already entered, the ID is created
+ if (gatewayData.gatewayID == 0 && !mFirstStaticGateway)
+ {
+ command = "INSERT INTO " + std::string(GATEWAY_TABLE) + "(name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID, inUse) VALUES (?,?,?,?,?,?,0)";
+ }
+ else
+ {
+ //check if the ID already exists
+ if (existGateway(gatewayData.gatewayID)) return E_ALREADY_EXISTS;
+ command = "INSERT INTO " + std::string(GATEWAY_TABLE) + "(name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID, gatewayID, inUse) VALUES (?,?,?,?,?,?,?,0)";
+ }
+
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, gatewayData.name.c_str(), gatewayData.name.size(), SQLITE_STATIC);
+ sqlite3_bind_int(query, 2, gatewayData.sinkID);
+ sqlite3_bind_int(query, 3, gatewayData.sourceID);
+ sqlite3_bind_int(query, 4, gatewayData.domainSinkID);
+ sqlite3_bind_int(query, 5, gatewayData.domainSourceID);
+ sqlite3_bind_int(query, 6, gatewayData.controlDomainID);
+
+ //if the ID is not created, we add it to the query
+ if (gatewayData.gatewayID != 0)
+ {
+ sqlite3_bind_int(query, 7, gatewayData.gatewayID);
+ }
+
+ //if the first static sink is entered, we need to set it onto the boundary
+ else if (mFirstStaticGateway)
+ {
+ sqlite3_bind_int(query, 7, DYNAMIC_ID_BOUNDARY);
+ mFirstStaticGateway = false;
+ }
+
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterGatewayDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterGatewayDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ gatewayID = sqlite3_last_insert_rowid(mDatabase);
+
+ //now the convertion matrix todo: change the map implementation sometimes to blob in sqlite
+ mListConnectionFormat.insert(std::make_pair(gatewayID, gatewayData.convertionMatrix));
+
+ command = "CREATE TABLE GatewaySourceFormat" + i2s(gatewayID) + std::string("(soundFormat INTEGER)");
+ assert(this->sqQuery(command));
+ command = "CREATE TABLE GatewaySinkFormat" + i2s(gatewayID) + std::string("(soundFormat INTEGER)");
+ assert(this->sqQuery(command));
+
+ //fill ConnectionFormats
+ command = "INSERT INTO GatewaySourceFormat" + i2s(gatewayID) + std::string("(soundFormat) VALUES (?)");
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<am_ConnectionFormat_e>::const_iterator connectionFormatIterator = gatewayData.listSourceFormats.begin();
+ for (; connectionFormatIterator < gatewayData.listSourceFormats.end(); ++connectionFormatIterator)
+ {
+ sqlite3_bind_int(query, 1, *connectionFormatIterator);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterGatewayDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ command = "INSERT INTO GatewaySinkFormat" + i2s(gatewayID) + std::string("(soundFormat) VALUES (?)");
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ connectionFormatIterator = gatewayData.listSinkFormats.begin();
+ for (; connectionFormatIterator < gatewayData.listSinkFormats.end(); ++connectionFormatIterator)
+ {
+ sqlite3_bind_int(query, 1, *connectionFormatIterator);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterGatewayDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterGatewayDB entered new gateway with name"), DLT_STRING(gatewayData.name.c_str()), DLT_STRING("sourceID:"), DLT_INT(gatewayData.sourceID), DLT_STRING("sinkID:"), DLT_INT(gatewayData.sinkID), DLT_STRING("domainSinkID:"), DLT_INT(gatewayData.domainSinkID), DLT_STRING("domainSourceID:"), DLT_BOOL(gatewayData.domainSourceID), DLT_STRING("controlDomainID:"), DLT_INT(gatewayData.controlDomainID), DLT_STRING("assigned ID:"), DLT_INT16(gatewayID));
+
+ am_Gateway_s gateway = gatewayData;
+ gateway.gatewayID = gatewayID;
+ if (mDatabaseObserver) mDatabaseObserver->newGateway(gateway);
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::enterSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID)
{
- assert(sourceData.sourceID<DYNAMIC_ID_BOUNDARY);
- assert(sourceData.domainID!=0);
- assert(!sourceData.name.empty());
- assert(sourceData.sourceClassID!=0); // \todo: need to check if class exists?
- assert(!sourceData.listConnectionFormats.empty());
- assert(sourceData.sourceState>=SS_ON && sourceData.sourceState<=SS_PAUSED);
-
- sqlite3_stmt* query=NULL, *queryFinal=NULL;;
- int eCode=0;
- std::string command="SELECT sourceID FROM "+ std::string(SOURCE_TABLE) + " WHERE name=? AND reserved=1";
-
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1, sourceData.name.c_str(),sourceData.name.size(),SQLITE_STATIC);
-
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- command= "UPDATE " + std::string(SOURCE_TABLE) + " SET name=?, domainID=?, sourceClassID=?, sourceState=?, volume=?, visible=?, availability=?, availabilityReason=?, interruptState=?, reserved=? WHERE sourceID=" +i2s(sqlite3_column_int(query,0));
- }
- else if (eCode==SQLITE_DONE)
- {
- //if sinkID is zero and the first Static Sink was already entered, the ID is created
- if (sourceData.sourceID==0 && !mFirstStaticSource && !existSourceName(sourceData.name))
- {
- command= "INSERT INTO " + std::string(SOURCE_TABLE) + "(name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState, reserved) VALUES (?,?,?,?,?,?,?,?,?,?)";
- }
- else
- {
- //check if the ID already exists
- if (existSourceNameOrID(sourceData.sourceID,sourceData.name))
- {
- sqlite3_finalize(query);
- return E_ALREADY_EXISTS;
- }
- command= "INSERT INTO " + std::string(SOURCE_TABLE) + "(name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState, reserved, sourceID) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
- }
- }
- else
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"),DLT_INT(eCode));
- sqlite3_finalize(query);
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&queryFinal,NULL);
- sqlite3_bind_text(queryFinal,1, sourceData.name.c_str(),sourceData.name.size(),SQLITE_STATIC);
- sqlite3_bind_int(queryFinal,2, sourceData.domainID);
- sqlite3_bind_int(queryFinal,3, sourceData.sourceClassID);
- sqlite3_bind_int(queryFinal,4, sourceData.sourceState);
- sqlite3_bind_int(queryFinal,5, sourceData.volume);
- sqlite3_bind_int(queryFinal,6, sourceData.visible);
- sqlite3_bind_int(queryFinal,7, sourceData.available.availability);
- sqlite3_bind_int(queryFinal,8, sourceData.available.availabilityReason);
- sqlite3_bind_int(queryFinal,9, sourceData.interruptState);
- sqlite3_bind_int(queryFinal,10, 0);
-
- //if the ID is not created, we add it to the query
- if(sourceData.sourceID!=0)
- {
- sqlite3_bind_int(queryFinal,11, sourceData.sourceID);
- }
-
- //if the first static sink is entered, we need to set it onto the boundary
- else if(mFirstStaticSource)
- {
- sqlite3_bind_int(queryFinal,11, DYNAMIC_ID_BOUNDARY);
- mFirstStaticSource=false;
- }
-
- if((eCode=sqlite3_step(queryFinal))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"),DLT_INT(eCode));
- sqlite3_finalize(queryFinal);
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(queryFinal))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Finalize error code:"),DLT_INT(eCode));
- sqlite3_finalize(queryFinal);
- return E_DATABASE_ERROR;
- }
-
- //now read back the sinkID
- command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE name=?";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1,sourceData.name.c_str(),sourceData.name.size(),SQLITE_STATIC);
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- sourceID=sqlite3_column_int(query,0);
- }
- else
- {
- sourceID=0;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
- sqlite3_finalize(query);
- return E_DATABASE_ERROR;
- }
- sqlite3_finalize(query);
-
-
- //now we need to create the additional tables:
- command="CREATE TABLE SourceConnectionFormat" + i2s(sourceID) + std::string("(soundFormat INTEGER)");
- assert(this->sqQuery(command));
- command="CREATE TABLE SourceMainSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
- assert(this->sqQuery(command));
- command="CREATE TABLE SourceSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
- assert(this->sqQuery(command));
-
- //fill ConnectionFormats
- command="INSERT INTO SourceConnectionFormat" + i2s(sourceID) + std::string("(soundFormat) VALUES (?)");
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<am_ConnectionFormat_e>::const_iterator connectionFormatIterator=sourceData.listConnectionFormats.begin();
- for(;connectionFormatIterator<sourceData.listConnectionFormats.end();++connectionFormatIterator)
- {
- sqlite3_bind_int(query,1, *connectionFormatIterator);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"),DLT_INT(eCode));
- sqlite3_finalize(query);
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- //Fill MainSinkSoundProperties
- command="INSERT INTO SourceMainSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType,value) VALUES (?,?)");
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<am_MainSoundProperty_s>::const_iterator mainSoundPropertyIterator=sourceData.listMainSoundProperties.begin();
- for(;mainSoundPropertyIterator<sourceData.listMainSoundProperties.end();++mainSoundPropertyIterator)
- {
- sqlite3_bind_int(query,1, mainSoundPropertyIterator->type);
- sqlite3_bind_int(query,2, mainSoundPropertyIterator->value);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"),DLT_INT(eCode));
- sqlite3_finalize(query);
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- //Fill SinkSoundProperties
- command="INSERT INTO SourceSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType,value) VALUES (?,?)");
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<am_SoundProperty_s>::const_iterator SoundPropertyIterator=sourceData.listSoundProperties.begin();
- for(;SoundPropertyIterator<sourceData.listSoundProperties.end();++SoundPropertyIterator)
- {
- sqlite3_bind_int(query,1, SoundPropertyIterator->type);
- sqlite3_bind_int(query,2, SoundPropertyIterator->value);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
- sqlite3_finalize(query);
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSinkDB entered new source with name"), DLT_STRING(sourceData.name.c_str()),
- DLT_STRING("domainID:"),DLT_INT(sourceData.domainID),
- DLT_STRING("classID:"),DLT_INT(sourceData.sourceClassID),
- DLT_STRING("volume:"),DLT_INT(sourceData.volume),
- DLT_STRING("visible:"),DLT_BOOL(sourceData.visible),
- DLT_STRING("available.availability:"),DLT_INT(sourceData.available.availability),
- DLT_STRING("available.availabilityReason:"),DLT_INT(sourceData.available.availabilityReason),
- DLT_STRING("interruptState:"),DLT_INT(sourceData.interruptState),
- DLT_STRING("assigned ID:"),DLT_INT16(sourceID));
-
- am_Source_s source=sourceData;
- source.sourceID=sourceID;
- if(mDatabaseObserver) mDatabaseObserver->newSource(source);
- return E_OK;
+ assert(sourceData.sourceID<DYNAMIC_ID_BOUNDARY);
+ assert(sourceData.domainID!=0);
+ assert(!sourceData.name.empty());
+ assert(sourceData.sourceClassID!=0);
+ // \todo: need to check if class exists?
+ assert(!sourceData.listConnectionFormats.empty());
+ assert(sourceData.sourceState>=SS_ON && sourceData.sourceState<=SS_PAUSED);
+
+ sqlite3_stmt* query = NULL, *queryFinal = NULL;
+ ;
+ int eCode = 0;
+ std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE name=? AND reserved=1";
+
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, sourceData.name.c_str(), sourceData.name.size(), SQLITE_STATIC);
+
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ command = "UPDATE " + std::string(SOURCE_TABLE) + " SET name=?, domainID=?, sourceClassID=?, sourceState=?, volume=?, visible=?, availability=?, availabilityReason=?, interruptState=?, reserved=? WHERE sourceID=" + i2s(sqlite3_column_int(query, 0));
+ }
+ else if (eCode == SQLITE_DONE)
+ {
+ //if sinkID is zero and the first Static Sink was already entered, the ID is created
+ if (sourceData.sourceID == 0 && !mFirstStaticSource && !existSourceName(sourceData.name))
+ {
+ command = "INSERT INTO " + std::string(SOURCE_TABLE) + "(name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState, reserved) VALUES (?,?,?,?,?,?,?,?,?,?)";
+ }
+ else
+ {
+ //check if the ID already exists
+ if (existSourceNameOrID(sourceData.sourceID, sourceData.name))
+ {
+ sqlite3_finalize(query);
+ return E_ALREADY_EXISTS;
+ }
+ command = "INSERT INTO " + std::string(SOURCE_TABLE) + "(name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState, reserved, sourceID) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+ }
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"), DLT_INT(eCode));
+ sqlite3_finalize(query);
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &queryFinal, NULL);
+ sqlite3_bind_text(queryFinal, 1, sourceData.name.c_str(), sourceData.name.size(), SQLITE_STATIC);
+ sqlite3_bind_int(queryFinal, 2, sourceData.domainID);
+ sqlite3_bind_int(queryFinal, 3, sourceData.sourceClassID);
+ sqlite3_bind_int(queryFinal, 4, sourceData.sourceState);
+ sqlite3_bind_int(queryFinal, 5, sourceData.volume);
+ sqlite3_bind_int(queryFinal, 6, sourceData.visible);
+ sqlite3_bind_int(queryFinal, 7, sourceData.available.availability);
+ sqlite3_bind_int(queryFinal, 8, sourceData.available.availabilityReason);
+ sqlite3_bind_int(queryFinal, 9, sourceData.interruptState);
+ sqlite3_bind_int(queryFinal, 10, 0);
+
+ //if the ID is not created, we add it to the query
+ if (sourceData.sourceID != 0)
+ {
+ sqlite3_bind_int(queryFinal, 11, sourceData.sourceID);
+ }
+
+ //if the first static sink is entered, we need to set it onto the boundary
+ else if (mFirstStaticSource)
+ {
+ sqlite3_bind_int(queryFinal, 11, DYNAMIC_ID_BOUNDARY);
+ mFirstStaticSource = false;
+ }
+
+ if ((eCode = sqlite3_step(queryFinal)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"), DLT_INT(eCode));
+ sqlite3_finalize(queryFinal);
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(queryFinal)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ sqlite3_finalize(queryFinal);
+ return E_DATABASE_ERROR;
+ }
+
+ //now read back the sinkID
+ command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE name=?";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, sourceData.name.c_str(), sourceData.name.size(), SQLITE_STATIC);
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ sourceID = sqlite3_column_int(query, 0);
+ }
+ else
+ {
+ sourceID = 0;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
+ sqlite3_finalize(query);
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_finalize(query);
+
+ //now we need to create the additional tables:
+ command = "CREATE TABLE SourceConnectionFormat" + i2s(sourceID) + std::string("(soundFormat INTEGER)");
+ assert(this->sqQuery(command));
+ command = "CREATE TABLE SourceMainSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
+ assert(this->sqQuery(command));
+ command = "CREATE TABLE SourceSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
+ assert(this->sqQuery(command));
+
+ //fill ConnectionFormats
+ command = "INSERT INTO SourceConnectionFormat" + i2s(sourceID) + std::string("(soundFormat) VALUES (?)");
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<am_ConnectionFormat_e>::const_iterator connectionFormatIterator = sourceData.listConnectionFormats.begin();
+ for (; connectionFormatIterator < sourceData.listConnectionFormats.end(); ++connectionFormatIterator)
+ {
+ sqlite3_bind_int(query, 1, *connectionFormatIterator);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"), DLT_INT(eCode));
+ sqlite3_finalize(query);
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ //Fill MainSinkSoundProperties
+ command = "INSERT INTO SourceMainSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType,value) VALUES (?,?)");
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<am_MainSoundProperty_s>::const_iterator mainSoundPropertyIterator = sourceData.listMainSoundProperties.begin();
+ for (; mainSoundPropertyIterator < sourceData.listMainSoundProperties.end(); ++mainSoundPropertyIterator)
+ {
+ sqlite3_bind_int(query, 1, mainSoundPropertyIterator->type);
+ sqlite3_bind_int(query, 2, mainSoundPropertyIterator->value);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"), DLT_INT(eCode));
+ sqlite3_finalize(query);
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ //Fill SinkSoundProperties
+ command = "INSERT INTO SourceSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType,value) VALUES (?,?)");
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<am_SoundProperty_s>::const_iterator SoundPropertyIterator = sourceData.listSoundProperties.begin();
+ for (; SoundPropertyIterator < sourceData.listSoundProperties.end(); ++SoundPropertyIterator)
+ {
+ sqlite3_bind_int(query, 1, SoundPropertyIterator->type);
+ sqlite3_bind_int(query, 2, SoundPropertyIterator->value);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"), DLT_INT(eCode));
+ sqlite3_finalize(query);
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSinkDB entered new source with name"), DLT_STRING(sourceData.name.c_str()), DLT_STRING("domainID:"), DLT_INT(sourceData.domainID), DLT_STRING("classID:"), DLT_INT(sourceData.sourceClassID), DLT_STRING("volume:"), DLT_INT(sourceData.volume), DLT_STRING("visible:"), DLT_BOOL(sourceData.visible), DLT_STRING("available.availability:"), DLT_INT(sourceData.available.availability), DLT_STRING("available.availabilityReason:"), DLT_INT(sourceData.available.availabilityReason), DLT_STRING("interruptState:"), DLT_INT(sourceData.interruptState), DLT_STRING("assigned ID:"), DLT_INT16(sourceID));
+
+ am_Source_s source = sourceData;
+ source.sourceID = sourceID;
+ if (mDatabaseObserver) mDatabaseObserver->newSource(source);
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const am_Route_s & route)
{
- assert(mainconnectionID!=0);
- if(!existMainConnection(mainconnectionID))
- {
- return E_NON_EXISTENT;
- }
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
-
- std::vector<uint16_t> listOfConnections;
- int16_t delay=0;
- command="SELECT connectionID, delay FROM "+std::string(CONNECTION_TABLE)+(" WHERE sourceID=? AND sinkID=? AND connectionFormat=?");
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<am_RoutingElement_s>::const_iterator elementIterator=route.route.begin();
- for (;elementIterator<route.route.end();++elementIterator)
- {
- sqlite3_bind_int(query,1, elementIterator->sourceID);
- sqlite3_bind_int(query,2, elementIterator->sinkID);
- sqlite3_bind_int(query,3, elementIterator->connectionFormat);
-
- if((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- listOfConnections.push_back(sqlite3_column_int(query,0));
- int16_t temp_delay=sqlite3_column_int(query,1);
- if (temp_delay!=-1 && delay!=-1) delay+=temp_delay;
- else delay=-1;
- }
- else
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB did not find route for MainConnection:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- //now we delete the data in the table
- command="DELETE from MainConnectionRoute" + i2s(mainconnectionID);
- assert(this->sqQuery(command));
-
- command= "INSERT INTO MainConnectionRoute" + i2s(mainconnectionID) + "(connectionID) VALUES (?)";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<uint16_t>::iterator listConnectionIterator=listOfConnections.begin();
- for(;listConnectionIterator<listOfConnections.end();++listConnectionIterator)
- {
- sqlite3_bind_int(query,1, *listConnectionIterator);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB entered new route:"),DLT_INT(mainconnectionID));
- return E_OK;
+ assert(mainconnectionID!=0);
+ if (!existMainConnection(mainconnectionID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
+
+ std::vector<uint16_t> listOfConnections;
+ int16_t delay = 0;
+ command = "SELECT connectionID, delay FROM " + std::string(CONNECTION_TABLE) + (" WHERE sourceID=? AND sinkID=? AND connectionFormat=?");
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<am_RoutingElement_s>::const_iterator elementIterator = route.route.begin();
+ for (; elementIterator < route.route.end(); ++elementIterator)
+ {
+ sqlite3_bind_int(query, 1, elementIterator->sourceID);
+ sqlite3_bind_int(query, 2, elementIterator->sinkID);
+ sqlite3_bind_int(query, 3, elementIterator->connectionFormat);
+
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ listOfConnections.push_back(sqlite3_column_int(query, 0));
+ int16_t temp_delay = sqlite3_column_int(query, 1);
+ if (temp_delay != -1 && delay != -1)
+ delay += temp_delay;
+ else
+ delay = -1;
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB did not find route for MainConnection:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //now we delete the data in the table
+ command = "DELETE from MainConnectionRoute" + i2s(mainconnectionID);
+ assert(this->sqQuery(command));
+
+ command = "INSERT INTO MainConnectionRoute" + i2s(mainconnectionID) + "(connectionID) VALUES (?)";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<uint16_t>::iterator listConnectionIterator = listOfConnections.begin();
+ for (; listConnectionIterator < listOfConnections.end(); ++listConnectionIterator)
+ {
+ sqlite3_bind_int(query, 1, *listConnectionIterator);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB entered new route:"), DLT_INT(mainconnectionID));
+ return E_OK;
}
am_Error_e DatabaseHandler::changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState)
{
- assert(mainconnectionID!=0);
-
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
-
- if (!existMainConnection(mainconnectionID))
- {
- return E_NON_EXISTENT;
- }
- command = "UPDATE " + std::string(MAINCONNECTION_TABLE) + " SET connectionState=? WHERE mainConnectionID=" + i2s(mainconnectionID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, connectionState);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionStateDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionStateDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainConnectionStateDB changed mainConnectionState of MainConnection:"),DLT_INT(mainconnectionID),DLT_STRING("to:"),DLT_INT(connectionState));
-
- if (mDatabaseObserver) mDatabaseObserver->mainConnectionStateChanged(mainconnectionID,connectionState);
- return E_OK;
+ assert(mainconnectionID!=0);
+
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
+
+ if (!existMainConnection(mainconnectionID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(MAINCONNECTION_TABLE) + " SET connectionState=? WHERE mainConnectionID=" + i2s(mainconnectionID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, connectionState);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionStateDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionStateDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainConnectionStateDB changed mainConnectionState of MainConnection:"), DLT_INT(mainconnectionID), DLT_STRING("to:"), DLT_INT(connectionState));
+
+ if (mDatabaseObserver) mDatabaseObserver->mainConnectionStateChanged(mainconnectionID, connectionState);
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID)
{
- assert(sinkID!=0);
+ assert(sinkID!=0);
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
- if (!existSink(sinkID))
- {
- return E_NON_EXISTENT;
- }
- command = "UPDATE " + std::string(SINK_TABLE) + " SET mainVolume=? WHERE sinkID=" + i2s(sinkID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, mainVolume);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkMainVolumeDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkMainVolumeDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(SINK_TABLE) + " SET mainVolume=? WHERE sinkID=" + i2s(sinkID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, mainVolume);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkMainVolumeDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkMainVolumeDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkMainVolumeDB changed mainVolume of sink:"),DLT_INT(sinkID),DLT_STRING("to:"),DLT_INT(mainVolume));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkMainVolumeDB changed mainVolume of sink:"), DLT_INT(sinkID), DLT_STRING("to:"), DLT_INT(mainVolume));
- if(mDatabaseObserver) mDatabaseObserver->volumeChanged(sinkID,mainVolume);
+ if (mDatabaseObserver) mDatabaseObserver->volumeChanged(sinkID, mainVolume);
- return E_OK;
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::changeSinkAvailabilityDB(const am_Availability_s & availability, const am_sinkID_t sinkID)
{
- assert(sinkID!=0);
+ assert(sinkID!=0);
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
- if (!existSink(sinkID))
- {
- return E_NON_EXISTENT;
- }
- command = "UPDATE " + std::string(SINK_TABLE) + " SET availability=?, availabilityReason=? WHERE sinkID=" + i2s(sinkID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, availability.availability);
- sqlite3_bind_int(query,2, availability.availabilityReason);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkAvailabilityDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- } assert(sinkID!=0);
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(SINK_TABLE) + " SET availability=?, availabilityReason=? WHERE sinkID=" + i2s(sinkID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, availability.availability);
+ sqlite3_bind_int(query, 2, availability.availabilityReason);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkAvailabilityDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }assert(sinkID!=0);
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkAvailabilityDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkAvailabilityDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkAvailabilityDB changed sinkAvailability of sink:"),DLT_INT(sinkID),DLT_STRING("to:"),DLT_INT(availability.availability), DLT_STRING("Reason:"),DLT_INT(availability.availabilityReason));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkAvailabilityDB changed sinkAvailability of sink:"), DLT_INT(sinkID), DLT_STRING("to:"), DLT_INT(availability.availability), DLT_STRING("Reason:"), DLT_INT(availability.availabilityReason));
- if (mDatabaseObserver && sourceVisible(sinkID)) mDatabaseObserver->sinkAvailabilityChanged(sinkID,availability);
- return E_OK;
+ if (mDatabaseObserver && sourceVisible(sinkID)) mDatabaseObserver->sinkAvailabilityChanged(sinkID, availability);
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID)
{
- assert(domainID!=0);
+ assert(domainID!=0);
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
- if (!existDomain(domainID))
- {
- return E_NON_EXISTENT;
- }
- command = "UPDATE " + std::string(DOMAIN_TABLE) + " SET state=? WHERE domainID=" + i2s(domainID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, domainState);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changDomainStateDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (!existDomain(domainID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(DOMAIN_TABLE) + " SET state=? WHERE domainID=" + i2s(domainID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, domainState);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changDomainStateDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changDomainStateDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changDomainStateDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changDomainStateDB changed domainState of domain:"),DLT_INT(domainID),DLT_STRING("to:"),DLT_INT(domainState));
- return E_OK;
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changDomainStateDB changed domainState of domain:"), DLT_INT(domainID), DLT_STRING("to:"), DLT_INT(domainState));
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID)
{
- assert(sinkID!=0);
+ assert(sinkID!=0);
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
- if (!existSink(sinkID))
- {
- return E_NON_EXISTENT;
- }
- command = "UPDATE " + std::string(SINK_TABLE) + " SET muteState=? WHERE sinkID=" + i2s(sinkID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, muteState);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkMuteStateDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- } assert(sinkID!=0);
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(SINK_TABLE) + " SET muteState=? WHERE sinkID=" + i2s(sinkID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, muteState);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkMuteStateDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }assert(sinkID!=0);
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkMuteStateDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkMuteStateDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkMuteStateDB changed sinkMuteState of sink:"),DLT_INT(sinkID),DLT_STRING("to:"),DLT_INT(muteState));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkMuteStateDB changed sinkMuteState of sink:"), DLT_INT(sinkID), DLT_STRING("to:"), DLT_INT(muteState));
- if(mDatabaseObserver) mDatabaseObserver->sinkMuteStateChanged(sinkID,muteState);
+ if (mDatabaseObserver) mDatabaseObserver->sinkMuteStateChanged(sinkID, muteState);
- return E_OK;
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID)
{
- //todo: add checks if soundproperty exists!
- assert(sinkID!=0);
-
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
-
- if (!existSink(sinkID))
- {
- return E_NON_EXISTENT;
- }
- command = "UPDATE SinkMainSoundProperty" + i2s(sinkID)+ " SET value=? WHERE soundPropertyType=" + i2s(soundProperty.type);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, soundProperty.value);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainSinkSoundPropertyDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- } assert(sinkID!=0);
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainSinkSoundPropertyDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainSinkSoundPropertyDB changed MainSinkSoundProperty of sink:"),DLT_INT(sinkID),DLT_STRING("type:"),DLT_INT(soundProperty.type),DLT_STRING("to:"),DLT_INT(soundProperty.value));
- if (mDatabaseObserver) mDatabaseObserver->mainSinkSoundPropertyChanged(sinkID,soundProperty);
- return E_OK;
+ //todo: add checks if soundproperty exists!
+ assert(sinkID!=0);
+
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
+
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE SinkMainSoundProperty" + i2s(sinkID) + " SET value=? WHERE soundPropertyType=" + i2s(soundProperty.type);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, soundProperty.value);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainSinkSoundPropertyDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }assert(sinkID!=0);
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainSinkSoundPropertyDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainSinkSoundPropertyDB changed MainSinkSoundProperty of sink:"), DLT_INT(sinkID), DLT_STRING("type:"), DLT_INT(soundProperty.type), DLT_STRING("to:"), DLT_INT(soundProperty.value));
+ if (mDatabaseObserver) mDatabaseObserver->mainSinkSoundPropertyChanged(sinkID, soundProperty);
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID)
{
- //todo: add checks if soundproperty exists!
- assert(sourceID!=0);
+ //todo: add checks if soundproperty exists!
+ assert(sourceID!=0);
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
- if (!existSource(sourceID))
- {
- return E_NON_EXISTENT;
- }
- command = "UPDATE SourceMainSoundProperty" + i2s(sourceID)+ " SET value=? WHERE soundPropertyType=" + i2s(soundProperty.type);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, soundProperty.value);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainSourceSoundPropertyDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (!existSource(sourceID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE SourceMainSoundProperty" + i2s(sourceID) + " SET value=? WHERE soundPropertyType=" + i2s(soundProperty.type);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, soundProperty.value);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainSourceSoundPropertyDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainSourceSoundPropertyDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainSourceSoundPropertyDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainSourceSoundPropertyDB changed MainSinkSoundProperty of source:"),DLT_INT(sourceID),DLT_STRING("type:"),DLT_INT(soundProperty.type),DLT_STRING("to:"),DLT_INT(soundProperty.value));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainSourceSoundPropertyDB changed MainSinkSoundProperty of source:"), DLT_INT(sourceID), DLT_STRING("type:"), DLT_INT(soundProperty.type), DLT_STRING("to:"), DLT_INT(soundProperty.value));
- if(mDatabaseObserver) mDatabaseObserver->mainSourceSoundPropertyChanged(sourceID,soundProperty);
- return E_OK;
+ if (mDatabaseObserver) mDatabaseObserver->mainSourceSoundPropertyChanged(sourceID, soundProperty);
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::changeSourceAvailabilityDB(const am_Availability_s & availability, const am_sourceID_t sourceID)
{
- assert(sourceID!=0);
+ assert(sourceID!=0);
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
- if (!existSource(sourceID))
- {
- return E_NON_EXISTENT;
- }
- command = "UPDATE " + std::string(SOURCE_TABLE) + " SET availability=?, availabilityReason=? WHERE sourceID=" + i2s(sourceID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, availability.availability);
- sqlite3_bind_int(query,2, availability.availabilityReason);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceAvailabilityDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (!existSource(sourceID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(SOURCE_TABLE) + " SET availability=?, availabilityReason=? WHERE sourceID=" + i2s(sourceID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, availability.availability);
+ sqlite3_bind_int(query, 2, availability.availabilityReason);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceAvailabilityDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceAvailabilityDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceAvailabilityDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSourceAvailabilityDB changed changeSourceAvailabilityDB of source:"),DLT_INT(sourceID),DLT_STRING("to:"),DLT_INT(availability.availability), DLT_STRING("Reason:"),DLT_INT(availability.availabilityReason));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSourceAvailabilityDB changed changeSourceAvailabilityDB of source:"), DLT_INT(sourceID), DLT_STRING("to:"), DLT_INT(availability.availability), DLT_STRING("Reason:"), DLT_INT(availability.availabilityReason));
- if (mDatabaseObserver && sourceVisible(sourceID)) mDatabaseObserver->sourceAvailabilityChanged(sourceID,availability);
- return E_OK;
+ if (mDatabaseObserver && sourceVisible(sourceID)) mDatabaseObserver->sourceAvailabilityChanged(sourceID, availability);
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::changeSystemPropertyDB(const am_SystemProperty_s & property)
{
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command="UPDATE " + std::string(SYSTEM_TABLE) + " set value=? WHERE type=?";
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command = "UPDATE " + std::string(SYSTEM_TABLE) + " set value=? WHERE type=?";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, property.value);
- sqlite3_bind_int(query,2, property.type);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, property.value);
+ sqlite3_bind_int(query, 2, property.type);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSystemPropertyDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSystemPropertyDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSystemPropertyDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSystemPropertyDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSystemPropertyDB changed system property"));
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSystemPropertyDB changed system property"));
+ if (mDatabaseObserver) mDatabaseObserver->systemPropertyChanged(property);
- if(mDatabaseObserver) mDatabaseObserver->systemPropertyChanged(property);
-
- return E_OK;
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID)
{
- assert(mainConnectionID!=0);
+ assert(mainConnectionID!=0);
- if (!existMainConnection(mainConnectionID))
- {
- return E_NON_EXISTENT;
- }
- std::string command = "DELETE from " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + i2s(mainConnectionID);
- std::string command1 = "DROP table MainConnectionRoute" + i2s(mainConnectionID);
- if(!sqQuery(command)) return E_DATABASE_ERROR;
- if(!sqQuery(command1)) return E_DATABASE_ERROR;
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeMainConnectionDB removed:"),DLT_INT(mainConnectionID));
- if (mDatabaseObserver) {
- mDatabaseObserver->mainConnectionStateChanged(mainConnectionID,CS_DISCONNECTED);
- mDatabaseObserver->numberOfMainConnectionsChanged();
- }
- return E_OK;
+ if (!existMainConnection(mainConnectionID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + i2s(mainConnectionID);
+ std::string command1 = "DROP table MainConnectionRoute" + i2s(mainConnectionID);
+ if (!sqQuery(command)) return E_DATABASE_ERROR;
+ if (!sqQuery(command1)) return E_DATABASE_ERROR;DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeMainConnectionDB removed:"), DLT_INT(mainConnectionID));
+ if (mDatabaseObserver)
+ {
+ mDatabaseObserver->mainConnectionStateChanged(mainConnectionID, CS_DISCONNECTED);
+ mDatabaseObserver->numberOfMainConnectionsChanged();
+ }
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::removeSinkDB(const am_sinkID_t sinkID)
{
- assert(sinkID!=0);
+ assert(sinkID!=0);
- if (!existSink(sinkID))
- {
- return E_NON_EXISTENT;
- }
- std::string command = "DELETE from " + std::string(SINK_TABLE) + " WHERE sinkID=" + i2s(sinkID);
- std::string command1 = "DROP table SinkConnectionFormat" + i2s(sinkID);
- std::string command2 = "DROP table SinkMainSoundProperty" + i2s(sinkID);
- std::string command3 = "DROP table SinkSoundProperty" + i2s(sinkID);
- if(!sqQuery(command)) return E_DATABASE_ERROR;
- if(!sqQuery(command1)) return E_DATABASE_ERROR;
- if(!sqQuery(command2)) return E_DATABASE_ERROR;
- if(!sqQuery(command3)) return E_DATABASE_ERROR;
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSinkDB removed:"),DLT_INT(sinkID));
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(SINK_TABLE) + " WHERE sinkID=" + i2s(sinkID);
+ std::string command1 = "DROP table SinkConnectionFormat" + i2s(sinkID);
+ std::string command2 = "DROP table SinkMainSoundProperty" + i2s(sinkID);
+ std::string command3 = "DROP table SinkSoundProperty" + i2s(sinkID);
+ if (!sqQuery(command)) return E_DATABASE_ERROR;
+ if (!sqQuery(command1)) return E_DATABASE_ERROR;
+ if (!sqQuery(command2)) return E_DATABASE_ERROR;
+ if (!sqQuery(command3)) return E_DATABASE_ERROR;DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSinkDB removed:"), DLT_INT(sinkID));
- if (mDatabaseObserver!=NULL) mDatabaseObserver->removedSink(sinkID);
+ if (mDatabaseObserver != NULL) mDatabaseObserver->removedSink(sinkID);
- return E_OK;
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::removeSourceDB(const am_sourceID_t sourceID)
{
- assert(sourceID!=0);
+ assert(sourceID!=0);
- if (!existSource(sourceID))
- {
- return E_NON_EXISTENT;
- }
- std::string command = "DELETE from " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + i2s(sourceID);
- std::string command1 = "DROP table SourceConnectionFormat" + i2s(sourceID);
- std::string command2 = "DROP table SourceMainSoundProperty" + i2s(sourceID);
- std::string command3 = "DROP table SourceSoundProperty" + i2s(sourceID);
- if(!sqQuery(command)) return E_DATABASE_ERROR;
- if(!sqQuery(command1)) return E_DATABASE_ERROR;
- if(!sqQuery(command2)) return E_DATABASE_ERROR;
- if(!sqQuery(command3)) return E_DATABASE_ERROR;
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSourceDB removed:"),DLT_INT(sourceID));
- if(mDatabaseObserver) mDatabaseObserver->removedSource(sourceID);
- return E_OK;
+ if (!existSource(sourceID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + i2s(sourceID);
+ std::string command1 = "DROP table SourceConnectionFormat" + i2s(sourceID);
+ std::string command2 = "DROP table SourceMainSoundProperty" + i2s(sourceID);
+ std::string command3 = "DROP table SourceSoundProperty" + i2s(sourceID);
+ if (!sqQuery(command)) return E_DATABASE_ERROR;
+ if (!sqQuery(command1)) return E_DATABASE_ERROR;
+ if (!sqQuery(command2)) return E_DATABASE_ERROR;
+ if (!sqQuery(command3)) return E_DATABASE_ERROR;DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSourceDB removed:"), DLT_INT(sourceID));
+ if (mDatabaseObserver) mDatabaseObserver->removedSource(sourceID);
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::removeGatewayDB(const am_gatewayID_t gatewayID)
{
- assert(gatewayID!=0);
+ assert(gatewayID!=0);
- if (!existGateway(gatewayID))
- {
- return E_NON_EXISTENT;
- }
- std::string command = "DELETE from " + std::string(GATEWAY_TABLE) + " WHERE gatewayID=" + i2s(gatewayID);
- if(!sqQuery(command)) return E_DATABASE_ERROR;
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeGatewayDB removed:"),DLT_INT(gatewayID));
- if(mDatabaseObserver) mDatabaseObserver->removeGateway(gatewayID);
- return E_OK;
+ if (!existGateway(gatewayID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(GATEWAY_TABLE) + " WHERE gatewayID=" + i2s(gatewayID);
+ if (!sqQuery(command)) return E_DATABASE_ERROR;DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeGatewayDB removed:"), DLT_INT(gatewayID));
+ if (mDatabaseObserver) mDatabaseObserver->removeGateway(gatewayID);
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::removeCrossfaderDB(const am_crossfaderID_t crossfaderID)
{
- //todo: implement crossdfader
- (void)crossfaderID;
- return E_UNKNOWN;
+ //todo: implement crossdfader
+ (void) crossfaderID;
+ return E_UNKNOWN;
}
-
-
am_Error_e DatabaseHandler::removeDomainDB(const am_domainID_t domainID)
{
- assert(domainID!=0);
+ assert(domainID!=0);
- if (!existDomain(domainID))
- {
- return E_NON_EXISTENT;
- }
- std::string command = "DELETE from " + std::string(DOMAIN_TABLE) + " WHERE domainID=" + i2s(domainID);
- if(!sqQuery(command)) return E_DATABASE_ERROR;
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeDomainDB removed:"),DLT_INT(domainID));
- if(mDatabaseObserver) mDatabaseObserver->removeDomain(domainID);
- return E_OK;
+ if (!existDomain(domainID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(DOMAIN_TABLE) + " WHERE domainID=" + i2s(domainID);
+ if (!sqQuery(command)) return E_DATABASE_ERROR;DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeDomainDB removed:"), DLT_INT(domainID));
+ if (mDatabaseObserver) mDatabaseObserver->removeDomain(domainID);
+ return E_OK;
}
am_Error_e DatabaseHandler::removeSinkClassDB(const am_sinkClass_t sinkClassID)
{
- assert(sinkClassID!=0);
+ assert(sinkClassID!=0);
- if (!existSinkClass(sinkClassID))
- {
- return E_NON_EXISTENT;
- }
- std::string command = "DELETE from " + std::string(SINK_CLASS_TABLE) + " WHERE sinkClassID=" + i2s(sinkClassID);
- std::string command1 = "DROP table SinkClassProperties" + i2s(sinkClassID);
- if(!sqQuery(command)) return E_DATABASE_ERROR;
- if(!sqQuery(command1)) return E_DATABASE_ERROR;
+ if (!existSinkClass(sinkClassID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(SINK_CLASS_TABLE) + " WHERE sinkClassID=" + i2s(sinkClassID);
+ std::string command1 = "DROP table SinkClassProperties" + i2s(sinkClassID);
+ if (!sqQuery(command)) return E_DATABASE_ERROR;
+ if (!sqQuery(command1)) return E_DATABASE_ERROR;
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSinkClassDB removed:"),DLT_INT(sinkClassID));
- if (mDatabaseObserver) mDatabaseObserver->numberOfSinkClassesChanged();
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSinkClassDB removed:"), DLT_INT(sinkClassID));
+ if (mDatabaseObserver) mDatabaseObserver->numberOfSinkClassesChanged();
- return E_OK;
+ return E_OK;
}
am_Error_e DatabaseHandler::removeSourceClassDB(const am_sourceClass_t sourceClassID)
{
- assert(sourceClassID!=0);
+ assert(sourceClassID!=0);
- if (!existSourceClass(sourceClassID))
- {
- return E_NON_EXISTENT;
- }
- std::string command = "DELETE from " + std::string(SOURCE_CLASS_TABLE) + " WHERE sourceClassID=" + i2s(sourceClassID);
- std::string command1 = "DROP table SourceClassProperties" + i2s(sourceClassID);
- if(!sqQuery(command)) return E_DATABASE_ERROR;
- if(!sqQuery(command1)) return E_DATABASE_ERROR;
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSourceClassDB removed:"),DLT_INT(sourceClassID));
+ if (!existSourceClass(sourceClassID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(SOURCE_CLASS_TABLE) + " WHERE sourceClassID=" + i2s(sourceClassID);
+ std::string command1 = "DROP table SourceClassProperties" + i2s(sourceClassID);
+ if (!sqQuery(command)) return E_DATABASE_ERROR;
+ if (!sqQuery(command1)) return E_DATABASE_ERROR;DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSourceClassDB removed:"), DLT_INT(sourceClassID));
- if (mDatabaseObserver) mDatabaseObserver->numberOfSourceClassesChanged();
- return E_OK;
+ if (mDatabaseObserver) mDatabaseObserver->numberOfSourceClassesChanged();
+ return E_OK;
}
am_Error_e DatabaseHandler::removeConnection(const am_connectionID_t connectionID)
{
- assert(connectionID!=0);
+ assert(connectionID!=0);
- std::string command = "DELETE from " + std::string(CONNECTION_TABLE) + " WHERE connectionID=" + i2s(connectionID);
- std::string command1 = "DROP table SourceClassProperties" + i2s(connectionID);
- if(!sqQuery(command)) return E_DATABASE_ERROR;
- if(!sqQuery(command1)) return E_DATABASE_ERROR;
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeConnection removed:"),DLT_INT(connectionID));
+ std::string command = "DELETE from " + std::string(CONNECTION_TABLE) + " WHERE connectionID=" + i2s(connectionID);
+ std::string command1 = "DROP table SourceClassProperties" + i2s(connectionID);
+ if (!sqQuery(command)) return E_DATABASE_ERROR;
+ if (!sqQuery(command1)) return E_DATABASE_ERROR;DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeConnection removed:"), DLT_INT(connectionID));
- return E_OK;
+ return E_OK;
}
-
am_Error_e DatabaseHandler::getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s & classInfo) const
{
- assert(sourceID!=0);
-
- if (!existSource(sourceID))
- {
- return E_NON_EXISTENT;
- }
- sqlite3_stmt* query=NULL;
- int eCode=0;
- am_ClassProperty_s propertyTemp;
- std::string command= "SELECT sourceClassID FROM " + std::string(SOURCE_TABLE)+ " WHERE sourceID=" + (i2s(sourceID));
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- if((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- classInfo.sourceClassID=sqlite3_column_int(query,0);
- }
-
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- command= "SELECT name FROM " + std::string(SOURCE_CLASS_TABLE)+ " WHERE sourceClassID=" + (i2s(classInfo.sourceClassID));
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- if((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- classInfo.name=std::string((const char*)sqlite3_column_text(query,0));
- }
-
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- //read out Properties
- command= "SELECT classProperty, value FROM SourceClassProperties"+ i2s(classInfo.sourceClassID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- propertyTemp.classProperty=(am_ClassProperty_e)sqlite3_column_int(query,0);
- propertyTemp.value=sqlite3_column_int(query,1);
- classInfo.listClassProperties.push_back(propertyTemp);
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- return E_OK;
+ assert(sourceID!=0);
+
+ if (!existSource(sourceID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ am_ClassProperty_s propertyTemp;
+ std::string command = "SELECT sourceClassID FROM " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + (i2s(sourceID));
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ classInfo.sourceClassID = sqlite3_column_int(query, 0);
+ }
+
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ command = "SELECT name FROM " + std::string(SOURCE_CLASS_TABLE) + " WHERE sourceClassID=" + (i2s(classInfo.sourceClassID));
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ classInfo.name = std::string((const char*) sqlite3_column_text(query, 0));
+ }
+
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out Properties
+ command = "SELECT classProperty, value FROM SourceClassProperties" + i2s(classInfo.sourceClassID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ propertyTemp.classProperty = (am_ClassProperty_e) sqlite3_column_int(query, 0);
+ propertyTemp.value = sqlite3_column_int(query, 1);
+ classInfo.listClassProperties.push_back(propertyTemp);
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::changeSinkClassInfoDB(const am_SinkClass_s& sinkClass)
{
- assert(sinkClass.sinkClassID!=0);
- assert(!sinkClass.listClassProperties.empty());
-
-
- sqlite3_stmt* query=NULL;
- int eCode=0;
-
- //check if the ID already exists
- if(!existSinkClass(sinkClass.sinkClassID)) return E_NON_EXISTENT;
-
- //fill ConnectionFormats
- std::string command="UPDATE SinkClassProperties" + i2s(sinkClass.sinkClassID) + " set value=? WHERE classProperty=?;";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<am_ClassProperty_s>::const_iterator Iterator=sinkClass.listClassProperties.begin();
- for(;Iterator<sinkClass.listClassProperties.end();++Iterator)
- {
- sqlite3_bind_int(query,1, Iterator->value);
- sqlite3_bind_int(query,2, Iterator->classProperty);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::setSinkClassInfoDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::setSinkClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::setSinkClassInfoDB set setSinkClassInfo"));
- return E_OK;
+ assert(sinkClass.sinkClassID!=0);
+ assert(!sinkClass.listClassProperties.empty());
+
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+
+ //check if the ID already exists
+ if (!existSinkClass(sinkClass.sinkClassID)) return E_NON_EXISTENT;
+
+ //fill ConnectionFormats
+ std::string command = "UPDATE SinkClassProperties" + i2s(sinkClass.sinkClassID) + " set value=? WHERE classProperty=?;";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<am_ClassProperty_s>::const_iterator Iterator = sinkClass.listClassProperties.begin();
+ for (; Iterator < sinkClass.listClassProperties.end(); ++Iterator)
+ {
+ sqlite3_bind_int(query, 1, Iterator->value);
+ sqlite3_bind_int(query, 2, Iterator->classProperty);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::setSinkClassInfoDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::setSinkClassInfoDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::setSinkClassInfoDB set setSinkClassInfo"));
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::changeSourceClassInfoDB(const am_SourceClass_s& sourceClass)
{
- assert(sourceClass.sourceClassID!=0);
- assert(!sourceClass.listClassProperties.empty());
-
-
- sqlite3_stmt* query=NULL;
- int eCode=0;
-
- //check if the ID already exists
- if(!existSourceClass(sourceClass.sourceClassID)) return E_NON_EXISTENT;
-
- //fill ConnectionFormats
- std::string command="UPDATE SourceClassProperties" + i2s(sourceClass.sourceClassID) + " set value=? WHERE classProperty=?;";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<am_ClassProperty_s>::const_iterator Iterator=sourceClass.listClassProperties.begin();
- for(;Iterator<sourceClass.listClassProperties.end();++Iterator)
- {
- sqlite3_bind_int(query,1, Iterator->value);
- sqlite3_bind_int(query,2, Iterator->classProperty);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::setSinkClassInfoDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::setSinkClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::setSinkClassInfoDB set setSinkClassInfo"));
- return E_OK;
+ assert(sourceClass.sourceClassID!=0);
+ assert(!sourceClass.listClassProperties.empty());
+
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+
+ //check if the ID already exists
+ if (!existSourceClass(sourceClass.sourceClassID)) return E_NON_EXISTENT;
+
+ //fill ConnectionFormats
+ std::string command = "UPDATE SourceClassProperties" + i2s(sourceClass.sourceClassID) + " set value=? WHERE classProperty=?;";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<am_ClassProperty_s>::const_iterator Iterator = sourceClass.listClassProperties.begin();
+ for (; Iterator < sourceClass.listClassProperties.end(); ++Iterator)
+ {
+ sqlite3_bind_int(query, 1, Iterator->value);
+ sqlite3_bind_int(query, 2, Iterator->classProperty);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::setSinkClassInfoDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::setSinkClassInfoDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::setSinkClassInfoDB set setSinkClassInfo"));
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s & sinkClass) const
{
- assert(sinkID!=0);
-
- if (!existSink(sinkID))
- {
- return E_NON_EXISTENT;
- }
- sqlite3_stmt* query=NULL;
- int eCode=0;
- am_ClassProperty_s propertyTemp;
- std::string command= "SELECT sinkClassID FROM " + std::string(SINK_TABLE)+ " WHERE sinkID=" + (i2s(sinkID));
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- if((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- sinkClass.sinkClassID=sqlite3_column_int(query,0);
- }
-
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- command= "SELECT name FROM " + std::string(SINK_CLASS_TABLE)+ " WHERE sinkClassID=" + (i2s(sinkClass.sinkClassID));
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- if((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- sinkClass.name=std::string((const char*)sqlite3_column_text(query,0));
- }
-
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- //read out Properties
- command= "SELECT classProperty, value FROM SinkClassProperties"+ i2s(sinkClass.sinkClassID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- propertyTemp.classProperty=(am_ClassProperty_e)sqlite3_column_int(query,0);
- propertyTemp.value=sqlite3_column_int(query,1);
- sinkClass.listClassProperties.push_back(propertyTemp);
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- return E_OK;
+ assert(sinkID!=0);
+
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ am_ClassProperty_s propertyTemp;
+ std::string command = "SELECT sinkClassID FROM " + std::string(SINK_TABLE) + " WHERE sinkID=" + (i2s(sinkID));
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ sinkClass.sinkClassID = sqlite3_column_int(query, 0);
+ }
+
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ command = "SELECT name FROM " + std::string(SINK_CLASS_TABLE) + " WHERE sinkClassID=" + (i2s(sinkClass.sinkClassID));
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ sinkClass.name = std::string((const char*) sqlite3_column_text(query, 0));
+ }
+
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out Properties
+ command = "SELECT classProperty, value FROM SinkClassProperties" + i2s(sinkClass.sinkClassID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ propertyTemp.classProperty = (am_ClassProperty_e) sqlite3_column_int(query, 0);
+ propertyTemp.value = sqlite3_column_int(query, 1);
+ sinkClass.listClassProperties.push_back(propertyTemp);
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s & gatewayData) const
{
- assert(gatewayID!=0);
- if (!existGateway(gatewayID))
- {
- return E_NON_EXISTENT;
- }
- sqlite3_stmt* query=NULL, *qSinkConnectionFormat=NULL, *qSourceConnectionFormat=NULL;
- int eCode=0;
- am_ConnectionFormat_e tempConnectionFormat;
- std::string command= "SELECT name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID, gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE gatewayID="+i2s(gatewayID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- gatewayData.name=std::string((const char*)sqlite3_column_text(query,0));
- gatewayData.sinkID=sqlite3_column_int(query,1);
- gatewayData.sourceID=sqlite3_column_int(query,2);
- gatewayData.domainSinkID=sqlite3_column_int(query,3);
- gatewayData.domainSourceID=sqlite3_column_int(query,4);
- gatewayData.controlDomainID=sqlite3_column_int(query,5);
- gatewayData.gatewayID=sqlite3_column_int(query,6);
-
- //convertionMatrix:
- ListConnectionFormat::const_iterator iter=mListConnectionFormat.begin();
- iter=mListConnectionFormat.find(gatewayData.gatewayID);
- if (iter == mListConnectionFormat.end())
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB database error with convertionFormat"));
- return E_DATABASE_ERROR;
- }
- gatewayData.convertionMatrix=iter->second;
-
- //read out the connectionFormats
- std::string commandConnectionFormat= "SELECT soundFormat FROM GatewaySourceFormat" + i2s(gatewayData.gatewayID);
- sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qSourceConnectionFormat,NULL);
- while((eCode=sqlite3_step(qSourceConnectionFormat))==SQLITE_ROW)
- {
- tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qSourceConnectionFormat,0);
- gatewayData.listSourceFormats.push_back(tempConnectionFormat);
- }
-
- if((eCode=sqlite3_finalize(qSourceConnectionFormat))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- //read out sound properties
- commandConnectionFormat= "SELECT soundFormat FROM GatewaySinkFormat" + i2s(gatewayData.gatewayID);
- sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qSinkConnectionFormat,NULL);
- while((eCode=sqlite3_step(qSinkConnectionFormat))==SQLITE_ROW)
- {
- tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qSinkConnectionFormat,0);
- gatewayData.listSinkFormats.push_back(tempConnectionFormat);
- }
-
- if((eCode=sqlite3_finalize(qSinkConnectionFormat))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- return E_OK;
+ assert(gatewayID!=0);
+ if (!existGateway(gatewayID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query = NULL, *qSinkConnectionFormat = NULL, *qSourceConnectionFormat = NULL;
+ int eCode = 0;
+ am_ConnectionFormat_e tempConnectionFormat;
+ std::string command = "SELECT name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID, gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE gatewayID=" + i2s(gatewayID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ gatewayData.name = std::string((const char*) sqlite3_column_text(query, 0));
+ gatewayData.sinkID = sqlite3_column_int(query, 1);
+ gatewayData.sourceID = sqlite3_column_int(query, 2);
+ gatewayData.domainSinkID = sqlite3_column_int(query, 3);
+ gatewayData.domainSourceID = sqlite3_column_int(query, 4);
+ gatewayData.controlDomainID = sqlite3_column_int(query, 5);
+ gatewayData.gatewayID = sqlite3_column_int(query, 6);
+
+ //convertionMatrix:
+ ListConnectionFormat::const_iterator iter = mListConnectionFormat.begin();
+ iter = mListConnectionFormat.find(gatewayData.gatewayID);
+ if (iter == mListConnectionFormat.end())
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB database error with convertionFormat"));
+ return E_DATABASE_ERROR;
+ }
+ gatewayData.convertionMatrix = iter->second;
+
+ //read out the connectionFormats
+ std::string commandConnectionFormat = "SELECT soundFormat FROM GatewaySourceFormat" + i2s(gatewayData.gatewayID);
+ sqlite3_prepare_v2(mDatabase, commandConnectionFormat.c_str(), -1, &qSourceConnectionFormat, NULL);
+ while ((eCode = sqlite3_step(qSourceConnectionFormat)) == SQLITE_ROW)
+ {
+ tempConnectionFormat = (am_ConnectionFormat_e) sqlite3_column_int(qSourceConnectionFormat, 0);
+ gatewayData.listSourceFormats.push_back(tempConnectionFormat);
+ }
+
+ if ((eCode = sqlite3_finalize(qSourceConnectionFormat)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out sound properties
+ commandConnectionFormat = "SELECT soundFormat FROM GatewaySinkFormat" + i2s(gatewayData.gatewayID);
+ sqlite3_prepare_v2(mDatabase, commandConnectionFormat.c_str(), -1, &qSinkConnectionFormat, NULL);
+ while ((eCode = sqlite3_step(qSinkConnectionFormat)) == SQLITE_ROW)
+ {
+ tempConnectionFormat = (am_ConnectionFormat_e) sqlite3_column_int(qSinkConnectionFormat, 0);
+ gatewayData.listSinkFormats.push_back(tempConnectionFormat);
+ }
+
+ if ((eCode = sqlite3_finalize(qSinkConnectionFormat)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s & crossfaderData) const
{
- //todo: implement crossfader
- (void)crossfaderID;
- (void)crossfaderData;
- return E_UNKNOWN;
+ //todo: implement crossfader
+ (void) crossfaderID;
+ (void) crossfaderData;
+ return E_UNKNOWN;
}
-
-
am_Error_e DatabaseHandler::getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> & listSinkID) const
{
- assert(domainID!=0);
- listSinkID.clear();
- if (!existDomain(domainID))
- {
- return E_NON_EXISTENT;
- }
- sqlite3_stmt* query=NULL;
- int eCode=0;
- am_sinkID_t temp;
- std::string command= "SELECT sinkID FROM " + std::string(SINK_TABLE)+ " WHERE reserved=0 AND domainID=" + (i2s(domainID));
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp=sqlite3_column_int(query,0);
- listSinkID.push_back(temp);
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinksOfDomain SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinksOfDomain SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- return E_OK;
+ assert(domainID!=0);
+ listSinkID.clear();
+ if (!existDomain(domainID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ am_sinkID_t temp;
+ std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND domainID=" + (i2s(domainID));
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp = sqlite3_column_int(query, 0);
+ listSinkID.push_back(temp);
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinksOfDomain SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinksOfDomain SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> & listSourceID) const
{
- assert(domainID!=0);
- listSourceID.clear();
- if (!existDomain(domainID))
- {
- return E_NON_EXISTENT;
- }
- sqlite3_stmt* query=NULL;
- int eCode=0;
- am_sourceID_t temp;
- std::string command= "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND domainID=" + i2s(domainID);
+ assert(domainID!=0);
+ listSourceID.clear();
+ if (!existDomain(domainID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ am_sourceID_t temp;
+ std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND domainID=" + i2s(domainID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp=sqlite3_column_int(query,0);
- listSourceID.push_back(temp);
- }
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp = sqlite3_column_int(query, 0);
+ listSourceID.push_back(temp);
+ }
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourcesOfDomain SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourcesOfDomain SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourcesOfDomain SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourcesOfDomain SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- return E_OK;
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> & listGatewaysID) const
{
- //todo: implement crossfader
- (void)listGatewaysID;
- (void)domainID;
- return E_UNKNOWN;
+ //todo: implement crossfader
+ (void) listGatewaysID;
+ (void) domainID;
+ return E_UNKNOWN;
}
-
-
am_Error_e DatabaseHandler::getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> & listGatewaysID) const
{
- assert(domainID!=0);
- listGatewaysID.clear();
- if (!existDomain(domainID))
- {
- return E_NON_EXISTENT;
- }
- sqlite3_stmt* query=NULL;
- int eCode=0;
- am_gatewayID_t temp;
+ assert(domainID!=0);
+ listGatewaysID.clear();
+ if (!existDomain(domainID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ am_gatewayID_t temp;
- std::string command= "SELECT gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE controlDomainID=" +i2s(domainID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::string command = "SELECT gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE controlDomainID=" + i2s(domainID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp=sqlite3_column_int(query,0);
- listGatewaysID.push_back(temp);
- }
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp = sqlite3_column_int(query, 0);
+ listGatewaysID.push_back(temp);
+ }
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGatewaysOfDomain SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGatewaysOfDomain SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGatewaysOfDomain SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGatewaysOfDomain SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- return E_OK;
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections) const
{
- listMainConnections.clear();
- sqlite3_stmt *query=NULL, *query1=NULL, *query2=NULL;
- int eCode=0;
- am_MainConnection_s temp;
- am_RoutingElement_s tempRoute;
-
- std::string command= "SELECT mainConnectionID, sourceID, sinkID, connectionState, delay FROM " + std::string(MAINCONNECTION_TABLE);
- std::string command1= "SELECT connectionID FROM MainConnectionRoute";
- std::string command2= "SELECT sourceID, sinkID, connectionFormat FROM " + std::string(CONNECTION_TABLE) + " WHERE connectionID=?";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_prepare_v2(mDatabase,command2.c_str(),-1,&query2,NULL);
-
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp.connectionID=sqlite3_column_int(query,0);
- temp.route.sourceID=sqlite3_column_int(query,1);
- temp.route.sinkID=sqlite3_column_int(query,2);
- temp.connectionState=(am_ConnectionState_e)sqlite3_column_int(query,3);
- temp.delay=sqlite3_column_int(query,4);
- std::string statement=command1 + i2s(temp.connectionID);
- sqlite3_prepare_v2(mDatabase,statement.c_str(),-1,&query1,NULL);
- while((eCode=sqlite3_step(query1))==SQLITE_ROW) //todo: check results of eCode1, eCode2
- {
- int k=sqlite3_column_int(query1,0);
- sqlite3_bind_int(query2,1,k);
- while((eCode=sqlite3_step(query2))==SQLITE_ROW)
- {
- tempRoute.sourceID=sqlite3_column_int(query2,0);
- tempRoute.sinkID=sqlite3_column_int(query2,1);
- tempRoute.connectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(query2,2);
- getDomainOfSource(tempRoute.sourceID,tempRoute.domainID);
- temp.route.route.push_back(tempRoute);
- }
- sqlite3_reset(query2);
- }
- listMainConnections.push_back(temp);
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainConnections SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainConnections SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- return E_OK;
+ listMainConnections.clear();
+ sqlite3_stmt *query = NULL, *query1 = NULL, *query2 = NULL;
+ int eCode = 0;
+ am_MainConnection_s temp;
+ am_RoutingElement_s tempRoute;
+
+ std::string command = "SELECT mainConnectionID, sourceID, sinkID, connectionState, delay FROM " + std::string(MAINCONNECTION_TABLE);
+ std::string command1 = "SELECT connectionID FROM MainConnectionRoute";
+ std::string command2 = "SELECT sourceID, sinkID, connectionFormat FROM " + std::string(CONNECTION_TABLE) + " WHERE connectionID=?";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_prepare_v2(mDatabase, command2.c_str(), -1, &query2, NULL);
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.connectionID = sqlite3_column_int(query, 0);
+ temp.route.sourceID = sqlite3_column_int(query, 1);
+ temp.route.sinkID = sqlite3_column_int(query, 2);
+ temp.connectionState = (am_ConnectionState_e) sqlite3_column_int(query, 3);
+ temp.delay = sqlite3_column_int(query, 4);
+ std::string statement = command1 + i2s(temp.connectionID);
+ sqlite3_prepare_v2(mDatabase, statement.c_str(), -1, &query1, NULL);
+ while ((eCode = sqlite3_step(query1)) == SQLITE_ROW) //todo: check results of eCode1, eCode2
+ {
+ int k = sqlite3_column_int(query1, 0);
+ sqlite3_bind_int(query2, 1, k);
+ while ((eCode = sqlite3_step(query2)) == SQLITE_ROW)
+ {
+ tempRoute.sourceID = sqlite3_column_int(query2, 0);
+ tempRoute.sinkID = sqlite3_column_int(query2, 1);
+ tempRoute.connectionFormat = (am_ConnectionFormat_e) sqlite3_column_int(query2, 2);
+ getDomainOfSource(tempRoute.sourceID, tempRoute.domainID);
+ temp.route.route.push_back(tempRoute);
+ }
+ sqlite3_reset(query2);
+ }
+ listMainConnections.push_back(temp);
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainConnections SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainConnections SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListDomains(std::vector<am_Domain_s> & listDomains) const
{
- listDomains.clear();
- sqlite3_stmt* query=NULL;
- int eCode=0;
- am_Domain_s temp;
- std::string command= "SELECT domainID, name, busname, nodename, early, complete, state FROM " + std::string(DOMAIN_TABLE) + " WHERE reserved=0";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp.domainID=sqlite3_column_int(query,0);
- temp.name=std::string((const char*)sqlite3_column_text(query,1));
- temp.busname=std::string((const char*)sqlite3_column_text(query,2));
- temp.nodename=std::string((const char*)sqlite3_column_text(query,3));
- temp.early=sqlite3_column_int(query,4);
- temp.complete=sqlite3_column_int(query,5);
- temp.state=(am_DomainState_e)sqlite3_column_int(query,6);
- listDomains.push_back(temp);
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListDomains SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListDomains SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- return E_OK;
+ listDomains.clear();
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ am_Domain_s temp;
+ std::string command = "SELECT domainID, name, busname, nodename, early, complete, state FROM " + std::string(DOMAIN_TABLE) + " WHERE reserved=0";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.domainID = sqlite3_column_int(query, 0);
+ temp.name = std::string((const char*) sqlite3_column_text(query, 1));
+ temp.busname = std::string((const char*) sqlite3_column_text(query, 2));
+ temp.nodename = std::string((const char*) sqlite3_column_text(query, 3));
+ temp.early = sqlite3_column_int(query, 4);
+ temp.complete = sqlite3_column_int(query, 5);
+ temp.state = (am_DomainState_e) sqlite3_column_int(query, 6);
+ listDomains.push_back(temp);
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListDomains SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListDomains SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListConnections(std::vector<am_Connection_s> & listConnections) const
{
- listConnections.clear();
- sqlite3_stmt* query=NULL;
- int eCode=0;
- am_Connection_s temp;
- std::string command= "SELECT connectionID, sourceID, sinkID, delay, connectionFormat FROM " + std::string(CONNECTION_TABLE)+" WHERE reserved=0";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp.connectionID=sqlite3_column_int(query,0);
- temp.sourceID=sqlite3_column_int(query,1);
- temp.sinkID=sqlite3_column_int(query,2);
- temp.delay=sqlite3_column_int(query,3);
- temp.connectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(query,4);
- listConnections.push_back(temp);
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListConnections SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListConnections SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- return E_OK;
+ listConnections.clear();
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ am_Connection_s temp;
+ std::string command = "SELECT connectionID, sourceID, sinkID, delay, connectionFormat FROM " + std::string(CONNECTION_TABLE) + " WHERE reserved=0";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.connectionID = sqlite3_column_int(query, 0);
+ temp.sourceID = sqlite3_column_int(query, 1);
+ temp.sinkID = sqlite3_column_int(query, 2);
+ temp.delay = sqlite3_column_int(query, 3);
+ temp.connectionFormat = (am_ConnectionFormat_e) sqlite3_column_int(query, 4);
+ listConnections.push_back(temp);
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListConnections SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListConnections SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListSinks(std::vector<am_Sink_s> & listSinks) const
{
- listSinks.clear();
- sqlite3_stmt* query=NULL, *qConnectionFormat=NULL, *qSoundProperty=NULL, *qMAinSoundProperty=NULL;
- int eCode=0;
- am_Sink_s temp;
- am_ConnectionFormat_e tempConnectionFormat;
- am_SoundProperty_s tempSoundProperty;
- am_MainSoundProperty_s tempMainSoundProperty;
- std::string command= "SELECT name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, sinkID FROM " + std::string(SINK_TABLE)+ " WHERE reserved=0";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp.name=std::string((const char*)sqlite3_column_text(query,0));
- temp.domainID=sqlite3_column_int(query,1);
- temp.sinkClassID=sqlite3_column_int(query,2);
- temp.volume=sqlite3_column_int(query,3);
- temp.visible=sqlite3_column_int(query,4);
- temp.available.availability=(am_Availablility_e)sqlite3_column_int(query,5);
- temp.available.availabilityReason=(am_AvailabilityReason_e)sqlite3_column_int(query,6);
- temp.muteState=(am_MuteState_e)sqlite3_column_int(query,7);
- temp.mainVolume=sqlite3_column_int(query,8);
- temp.sinkID=sqlite3_column_int(query,9);
-
- //read out the connectionFormats
- std::string commandConnectionFormat= "SELECT soundFormat FROM SinkConnectionFormat"+ i2s(temp.sinkID);
- sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qConnectionFormat,NULL);
- while((eCode=sqlite3_step(qConnectionFormat))==SQLITE_ROW)
- {
- tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qConnectionFormat,0);
- temp.listConnectionFormats.push_back(tempConnectionFormat);
- }
-
- if((eCode=sqlite3_finalize(qConnectionFormat))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- //read out sound properties
- std::string commandSoundProperty= "SELECT soundPropertyType, value FROM SinkSoundProperty" + i2s(temp.sinkID);
- sqlite3_prepare_v2(mDatabase,commandSoundProperty.c_str(),-1,&qSoundProperty,NULL);
- while((eCode=sqlite3_step(qSoundProperty))==SQLITE_ROW)
- {
- tempSoundProperty.type=(am_SoundPropertyType_e)sqlite3_column_int(qSoundProperty,0);
- tempSoundProperty.value=sqlite3_column_int(qSoundProperty,1);
- temp.listSoundProperties.push_back(tempSoundProperty);
- }
-
- if((eCode=sqlite3_finalize(qSoundProperty))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- //read out MainSoundProperties
- std::string commandMainSoundProperty= "SELECT soundPropertyType, value FROM SinkMainSoundProperty"+ i2s(temp.sinkID);
- sqlite3_prepare_v2(mDatabase,commandMainSoundProperty.c_str(),-1,&qMAinSoundProperty,NULL);
- while((eCode=sqlite3_step(qMAinSoundProperty))==SQLITE_ROW)
- {
- tempMainSoundProperty.type=(am_MainSoundPropertyType_e)sqlite3_column_int(qMAinSoundProperty,0);
- tempMainSoundProperty.value=sqlite3_column_int(qMAinSoundProperty,1);
- temp.listMainSoundProperties.push_back(tempMainSoundProperty);
- }
-
- if((eCode=sqlite3_finalize(qMAinSoundProperty))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- listSinks.push_back(temp);
- temp.listConnectionFormats.clear();
- temp.listMainSoundProperties.clear();
- temp.listSoundProperties.clear();
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- return E_OK;
+ listSinks.clear();
+ sqlite3_stmt* query = NULL, *qConnectionFormat = NULL, *qSoundProperty = NULL, *qMAinSoundProperty = NULL;
+ int eCode = 0;
+ am_Sink_s temp;
+ am_ConnectionFormat_e tempConnectionFormat;
+ am_SoundProperty_s tempSoundProperty;
+ am_MainSoundProperty_s tempMainSoundProperty;
+ std::string command = "SELECT name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.name = std::string((const char*) sqlite3_column_text(query, 0));
+ temp.domainID = sqlite3_column_int(query, 1);
+ temp.sinkClassID = sqlite3_column_int(query, 2);
+ temp.volume = sqlite3_column_int(query, 3);
+ temp.visible = sqlite3_column_int(query, 4);
+ temp.available.availability = (am_Availablility_e) sqlite3_column_int(query, 5);
+ temp.available.availabilityReason = (am_AvailabilityReason_e) sqlite3_column_int(query, 6);
+ temp.muteState = (am_MuteState_e) sqlite3_column_int(query, 7);
+ temp.mainVolume = sqlite3_column_int(query, 8);
+ temp.sinkID = sqlite3_column_int(query, 9);
+
+ //read out the connectionFormats
+ std::string commandConnectionFormat = "SELECT soundFormat FROM SinkConnectionFormat" + i2s(temp.sinkID);
+ sqlite3_prepare_v2(mDatabase, commandConnectionFormat.c_str(), -1, &qConnectionFormat, NULL);
+ while ((eCode = sqlite3_step(qConnectionFormat)) == SQLITE_ROW)
+ {
+ tempConnectionFormat = (am_ConnectionFormat_e) sqlite3_column_int(qConnectionFormat, 0);
+ temp.listConnectionFormats.push_back(tempConnectionFormat);
+ }
+
+ if ((eCode = sqlite3_finalize(qConnectionFormat)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out sound properties
+ std::string commandSoundProperty = "SELECT soundPropertyType, value FROM SinkSoundProperty" + i2s(temp.sinkID);
+ sqlite3_prepare_v2(mDatabase, commandSoundProperty.c_str(), -1, &qSoundProperty, NULL);
+ while ((eCode = sqlite3_step(qSoundProperty)) == SQLITE_ROW)
+ {
+ tempSoundProperty.type = (am_SoundPropertyType_e) sqlite3_column_int(qSoundProperty, 0);
+ tempSoundProperty.value = sqlite3_column_int(qSoundProperty, 1);
+ temp.listSoundProperties.push_back(tempSoundProperty);
+ }
+
+ if ((eCode = sqlite3_finalize(qSoundProperty)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out MainSoundProperties
+ std::string commandMainSoundProperty = "SELECT soundPropertyType, value FROM SinkMainSoundProperty" + i2s(temp.sinkID);
+ sqlite3_prepare_v2(mDatabase, commandMainSoundProperty.c_str(), -1, &qMAinSoundProperty, NULL);
+ while ((eCode = sqlite3_step(qMAinSoundProperty)) == SQLITE_ROW)
+ {
+ tempMainSoundProperty.type = (am_MainSoundPropertyType_e) sqlite3_column_int(qMAinSoundProperty, 0);
+ tempMainSoundProperty.value = sqlite3_column_int(qMAinSoundProperty, 1);
+ temp.listMainSoundProperties.push_back(tempMainSoundProperty);
+ }
+
+ if ((eCode = sqlite3_finalize(qMAinSoundProperty)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ listSinks.push_back(temp);
+ temp.listConnectionFormats.clear();
+ temp.listMainSoundProperties.clear();
+ temp.listSoundProperties.clear();
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListSources(std::vector<am_Source_s> & listSources) const
{
- listSources.clear();
- sqlite3_stmt* query=NULL, *qConnectionFormat=NULL, *qSoundProperty=NULL, *qMAinSoundProperty=NULL;
- int eCode=0;
- am_Source_s temp;
- am_ConnectionFormat_e tempConnectionFormat;
- am_SoundProperty_s tempSoundProperty;
- am_MainSoundProperty_s tempMainSoundProperty;
- std::string command= "SELECT name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState, sourceID FROM " + std::string(SOURCE_TABLE) +" WHERE reserved=0";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp.name=std::string((const char*)sqlite3_column_text(query,0));
- temp.domainID=sqlite3_column_int(query,1);
- temp.sourceClassID=sqlite3_column_int(query,2);
- temp.sourceState=(am_SourceState_e)sqlite3_column_int(query,3);
- temp.volume=sqlite3_column_int(query,4);
- temp.visible=sqlite3_column_int(query,5);
- temp.available.availability=(am_Availablility_e)sqlite3_column_int(query,6);
- temp.available.availabilityReason=(am_AvailabilityReason_e)sqlite3_column_int(query,7);
- temp.interruptState=(am_InterruptState_e)sqlite3_column_int(query,8);
- temp.sourceID=sqlite3_column_int(query,9);
-
- //read out the connectionFormats
- std::string commandConnectionFormat= "SELECT soundFormat FROM SourceConnectionFormat"+ i2s(temp.sourceID);
- sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qConnectionFormat,NULL);
- while((eCode=sqlite3_step(qConnectionFormat))==SQLITE_ROW)
- {
- tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qConnectionFormat,0);
- temp.listConnectionFormats.push_back(tempConnectionFormat);
- }
-
- if((eCode=sqlite3_finalize(qConnectionFormat))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- //read out sound properties
- std::string commandSoundProperty= "SELECT soundPropertyType, value FROM SourceSoundProperty" + i2s(temp.sourceID);
- sqlite3_prepare_v2(mDatabase,commandSoundProperty.c_str(),-1,&qSoundProperty,NULL);
- while((eCode=sqlite3_step(qSoundProperty))==SQLITE_ROW)
- {
- tempSoundProperty.type=(am_SoundPropertyType_e)sqlite3_column_int(qSoundProperty,0);
- tempSoundProperty.value=sqlite3_column_int(qSoundProperty,1);
- temp.listSoundProperties.push_back(tempSoundProperty);
- }
-
- if((eCode=sqlite3_finalize(qSoundProperty))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- //read out MainSoundProperties
- std::string commandMainSoundProperty= "SELECT soundPropertyType, value FROM SourceMainSoundProperty"+ i2s(temp.sourceID);
- sqlite3_prepare_v2(mDatabase,commandMainSoundProperty.c_str(),-1,&qMAinSoundProperty,NULL);
- while((eCode=sqlite3_step(qMAinSoundProperty))==SQLITE_ROW)
- {
- tempMainSoundProperty.type=(am_MainSoundPropertyType_e)sqlite3_column_int(qMAinSoundProperty,0);
- tempMainSoundProperty.value=sqlite3_column_int(qMAinSoundProperty,1);
- temp.listMainSoundProperties.push_back(tempMainSoundProperty);
- }
-
- if((eCode=sqlite3_finalize(qMAinSoundProperty))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- listSources.push_back(temp);
- temp.listConnectionFormats.clear();
- temp.listMainSoundProperties.clear();
- temp.listSoundProperties.clear();
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- return E_OK;
+ listSources.clear();
+ sqlite3_stmt* query = NULL, *qConnectionFormat = NULL, *qSoundProperty = NULL, *qMAinSoundProperty = NULL;
+ int eCode = 0;
+ am_Source_s temp;
+ am_ConnectionFormat_e tempConnectionFormat;
+ am_SoundProperty_s tempSoundProperty;
+ am_MainSoundProperty_s tempMainSoundProperty;
+ std::string command = "SELECT name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState, sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.name = std::string((const char*) sqlite3_column_text(query, 0));
+ temp.domainID = sqlite3_column_int(query, 1);
+ temp.sourceClassID = sqlite3_column_int(query, 2);
+ temp.sourceState = (am_SourceState_e) sqlite3_column_int(query, 3);
+ temp.volume = sqlite3_column_int(query, 4);
+ temp.visible = sqlite3_column_int(query, 5);
+ temp.available.availability = (am_Availablility_e) sqlite3_column_int(query, 6);
+ temp.available.availabilityReason = (am_AvailabilityReason_e) sqlite3_column_int(query, 7);
+ temp.interruptState = (am_InterruptState_e) sqlite3_column_int(query, 8);
+ temp.sourceID = sqlite3_column_int(query, 9);
+
+ //read out the connectionFormats
+ std::string commandConnectionFormat = "SELECT soundFormat FROM SourceConnectionFormat" + i2s(temp.sourceID);
+ sqlite3_prepare_v2(mDatabase, commandConnectionFormat.c_str(), -1, &qConnectionFormat, NULL);
+ while ((eCode = sqlite3_step(qConnectionFormat)) == SQLITE_ROW)
+ {
+ tempConnectionFormat = (am_ConnectionFormat_e) sqlite3_column_int(qConnectionFormat, 0);
+ temp.listConnectionFormats.push_back(tempConnectionFormat);
+ }
+
+ if ((eCode = sqlite3_finalize(qConnectionFormat)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out sound properties
+ std::string commandSoundProperty = "SELECT soundPropertyType, value FROM SourceSoundProperty" + i2s(temp.sourceID);
+ sqlite3_prepare_v2(mDatabase, commandSoundProperty.c_str(), -1, &qSoundProperty, NULL);
+ while ((eCode = sqlite3_step(qSoundProperty)) == SQLITE_ROW)
+ {
+ tempSoundProperty.type = (am_SoundPropertyType_e) sqlite3_column_int(qSoundProperty, 0);
+ tempSoundProperty.value = sqlite3_column_int(qSoundProperty, 1);
+ temp.listSoundProperties.push_back(tempSoundProperty);
+ }
+
+ if ((eCode = sqlite3_finalize(qSoundProperty)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out MainSoundProperties
+ std::string commandMainSoundProperty = "SELECT soundPropertyType, value FROM SourceMainSoundProperty" + i2s(temp.sourceID);
+ sqlite3_prepare_v2(mDatabase, commandMainSoundProperty.c_str(), -1, &qMAinSoundProperty, NULL);
+ while ((eCode = sqlite3_step(qMAinSoundProperty)) == SQLITE_ROW)
+ {
+ tempMainSoundProperty.type = (am_MainSoundPropertyType_e) sqlite3_column_int(qMAinSoundProperty, 0);
+ tempMainSoundProperty.value = sqlite3_column_int(qMAinSoundProperty, 1);
+ temp.listMainSoundProperties.push_back(tempMainSoundProperty);
+ }
+
+ if ((eCode = sqlite3_finalize(qMAinSoundProperty)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ listSources.push_back(temp);
+ temp.listConnectionFormats.clear();
+ temp.listMainSoundProperties.clear();
+ temp.listSoundProperties.clear();
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const
{
- listSourceClasses.clear();
-
- sqlite3_stmt* query=NULL, *subQuery=NULL;
- int eCode=0, eCode1;
- am_SourceClass_s classTemp;
- am_ClassProperty_s propertyTemp;
-
- std::string command= "SELECT sourceClassID, name FROM " + std::string(SOURCE_CLASS_TABLE);
- std::string command2;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- classTemp.sourceClassID=sqlite3_column_int(query,0);
- classTemp.name=std::string((const char*)sqlite3_column_text(query,1));
-
- //read out Properties
- command2="SELECT classProperty, value FROM SourceClassProperties"+ i2s(classTemp.sourceClassID);
- sqlite3_prepare_v2(mDatabase,command2.c_str(),-1,&subQuery,NULL);
-
- while((eCode1=sqlite3_step(subQuery))==SQLITE_ROW)
- {
- propertyTemp.classProperty=(am_ClassProperty_e)sqlite3_column_int(subQuery,0);
- propertyTemp.value=sqlite3_column_int(subQuery,1);
- classTemp.listClassProperties.push_back(propertyTemp);
- }
-
- if(eCode1!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE error code:"),DLT_INT(eCode1));
- return E_DATABASE_ERROR;
- }
-
- if((eCode1=sqlite3_finalize(subQuery))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE Finalize error code:"),DLT_INT(eCode1));
- return E_DATABASE_ERROR;
- }
- listSourceClasses.push_back(classTemp);
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- return E_OK;
+ listSourceClasses.clear();
+
+ sqlite3_stmt* query = NULL, *subQuery = NULL;
+ int eCode = 0, eCode1;
+ am_SourceClass_s classTemp;
+ am_ClassProperty_s propertyTemp;
+
+ std::string command = "SELECT sourceClassID, name FROM " + std::string(SOURCE_CLASS_TABLE);
+ std::string command2;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ classTemp.sourceClassID = sqlite3_column_int(query, 0);
+ classTemp.name = std::string((const char*) sqlite3_column_text(query, 1));
+
+ //read out Properties
+ command2 = "SELECT classProperty, value FROM SourceClassProperties" + i2s(classTemp.sourceClassID);
+ sqlite3_prepare_v2(mDatabase, command2.c_str(), -1, &subQuery, NULL);
+
+ while ((eCode1 = sqlite3_step(subQuery)) == SQLITE_ROW)
+ {
+ propertyTemp.classProperty = (am_ClassProperty_e) sqlite3_column_int(subQuery, 0);
+ propertyTemp.value = sqlite3_column_int(subQuery, 1);
+ classTemp.listClassProperties.push_back(propertyTemp);
+ }
+
+ if (eCode1 != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE error code:"), DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode1 = sqlite3_finalize(subQuery)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE Finalize error code:"), DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+ listSourceClasses.push_back(classTemp);
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders) const
{
- //todo: implement crossfaders
- (void)listCrossfaders;
- return E_UNKNOWN;
+ //todo: implement crossfaders
+ (void) listCrossfaders;
+ return E_UNKNOWN;
}
-
-
am_Error_e DatabaseHandler::getListGateways(std::vector<am_Gateway_s> & listGateways) const
{
- listGateways.clear();
- sqlite3_stmt* query=NULL, *qSinkConnectionFormat=NULL, *qSourceConnectionFormat=NULL;
- int eCode=0;
- am_Gateway_s temp;
- am_ConnectionFormat_e tempConnectionFormat;
-
- std::string command= "SELECT name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID, gatewayID FROM " + std::string(GATEWAY_TABLE);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp.name=std::string((const char*)sqlite3_column_text(query,0));
- temp.sinkID=sqlite3_column_int(query,1);
- temp.sourceID=sqlite3_column_int(query,2);
- temp.domainSinkID=sqlite3_column_int(query,3);
- temp.domainSourceID=sqlite3_column_int(query,4);
- temp.controlDomainID=sqlite3_column_int(query,5);
- temp.gatewayID=sqlite3_column_int(query,6);
-
- //convertionMatrix:
- ListConnectionFormat::const_iterator iter=mListConnectionFormat.begin();
- iter=mListConnectionFormat.find(temp.gatewayID);
- if (iter == mListConnectionFormat.end())
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways database error with convertionFormat"));
- return E_DATABASE_ERROR;
- }
- temp.convertionMatrix=iter->second;
-
- //read out the connectionFormats
- std::string commandConnectionFormat= "SELECT soundFormat FROM GatewaySourceFormat" + i2s(temp.gatewayID);
- sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qSourceConnectionFormat,NULL);
- while((eCode=sqlite3_step(qSourceConnectionFormat))==SQLITE_ROW)
- {
- tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qSourceConnectionFormat,0);
- temp.listSourceFormats.push_back(tempConnectionFormat);
- }
-
- if((eCode=sqlite3_finalize(qSourceConnectionFormat))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- //read out sound properties
- commandConnectionFormat= "SELECT soundFormat FROM GatewaySinkFormat" + i2s(temp.gatewayID);
- sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qSinkConnectionFormat,NULL);
- while((eCode=sqlite3_step(qSinkConnectionFormat))==SQLITE_ROW)
- {
- tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qSinkConnectionFormat,0);
- temp.listSinkFormats.push_back(tempConnectionFormat);
- }
-
- if((eCode=sqlite3_finalize(qSinkConnectionFormat))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- listGateways.push_back(temp);
- temp.listSinkFormats.clear();
- temp.listSourceFormats.clear();
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- return E_OK;
+ listGateways.clear();
+ sqlite3_stmt* query = NULL, *qSinkConnectionFormat = NULL, *qSourceConnectionFormat = NULL;
+ int eCode = 0;
+ am_Gateway_s temp;
+ am_ConnectionFormat_e tempConnectionFormat;
+
+ std::string command = "SELECT name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID, gatewayID FROM " + std::string(GATEWAY_TABLE);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.name = std::string((const char*) sqlite3_column_text(query, 0));
+ temp.sinkID = sqlite3_column_int(query, 1);
+ temp.sourceID = sqlite3_column_int(query, 2);
+ temp.domainSinkID = sqlite3_column_int(query, 3);
+ temp.domainSourceID = sqlite3_column_int(query, 4);
+ temp.controlDomainID = sqlite3_column_int(query, 5);
+ temp.gatewayID = sqlite3_column_int(query, 6);
+
+ //convertionMatrix:
+ ListConnectionFormat::const_iterator iter = mListConnectionFormat.begin();
+ iter = mListConnectionFormat.find(temp.gatewayID);
+ if (iter == mListConnectionFormat.end())
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways database error with convertionFormat"));
+ return E_DATABASE_ERROR;
+ }
+ temp.convertionMatrix = iter->second;
+
+ //read out the connectionFormats
+ std::string commandConnectionFormat = "SELECT soundFormat FROM GatewaySourceFormat" + i2s(temp.gatewayID);
+ sqlite3_prepare_v2(mDatabase, commandConnectionFormat.c_str(), -1, &qSourceConnectionFormat, NULL);
+ while ((eCode = sqlite3_step(qSourceConnectionFormat)) == SQLITE_ROW)
+ {
+ tempConnectionFormat = (am_ConnectionFormat_e) sqlite3_column_int(qSourceConnectionFormat, 0);
+ temp.listSourceFormats.push_back(tempConnectionFormat);
+ }
+
+ if ((eCode = sqlite3_finalize(qSourceConnectionFormat)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out sound properties
+ commandConnectionFormat = "SELECT soundFormat FROM GatewaySinkFormat" + i2s(temp.gatewayID);
+ sqlite3_prepare_v2(mDatabase, commandConnectionFormat.c_str(), -1, &qSinkConnectionFormat, NULL);
+ while ((eCode = sqlite3_step(qSinkConnectionFormat)) == SQLITE_ROW)
+ {
+ tempConnectionFormat = (am_ConnectionFormat_e) sqlite3_column_int(qSinkConnectionFormat, 0);
+ temp.listSinkFormats.push_back(tempConnectionFormat);
+ }
+
+ if ((eCode = sqlite3_finalize(qSinkConnectionFormat)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ listGateways.push_back(temp);
+ temp.listSinkFormats.clear();
+ temp.listSourceFormats.clear();
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const
{
- listSinkClasses.clear();
-
- sqlite3_stmt* query=NULL, *subQuery=NULL;
- int eCode=0;
- am_SinkClass_s classTemp;
- am_ClassProperty_s propertyTemp;
-
- std::string command= "SELECT sinkClassID, name FROM " + std::string(SINK_CLASS_TABLE);
- std::string command2;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- classTemp.sinkClassID=sqlite3_column_int(query,0);
- classTemp.name=std::string((const char*)sqlite3_column_text(query,1));
-
- //read out Properties
- command2="SELECT classProperty, value FROM SinkClassProperties"+ i2s(classTemp.sinkClassID);
- sqlite3_prepare_v2(mDatabase,command2.c_str(),-1,&subQuery,NULL);
-
- while((eCode=sqlite3_step(subQuery))==SQLITE_ROW)
- {
- propertyTemp.classProperty=(am_ClassProperty_e)sqlite3_column_int(subQuery,0);
- propertyTemp.value=sqlite3_column_int(subQuery,1);
- classTemp.listClassProperties.push_back(propertyTemp);
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(subQuery))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- listSinkClasses.push_back(classTemp);
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- return E_OK;
+ listSinkClasses.clear();
+
+ sqlite3_stmt* query = NULL, *subQuery = NULL;
+ int eCode = 0;
+ am_SinkClass_s classTemp;
+ am_ClassProperty_s propertyTemp;
+
+ std::string command = "SELECT sinkClassID, name FROM " + std::string(SINK_CLASS_TABLE);
+ std::string command2;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ classTemp.sinkClassID = sqlite3_column_int(query, 0);
+ classTemp.name = std::string((const char*) sqlite3_column_text(query, 1));
+
+ //read out Properties
+ command2 = "SELECT classProperty, value FROM SinkClassProperties" + i2s(classTemp.sinkClassID);
+ sqlite3_prepare_v2(mDatabase, command2.c_str(), -1, &subQuery, NULL);
+
+ while ((eCode = sqlite3_step(subQuery)) == SQLITE_ROW)
+ {
+ propertyTemp.classProperty = (am_ClassProperty_e) sqlite3_column_int(subQuery, 0);
+ propertyTemp.value = sqlite3_column_int(subQuery, 1);
+ classTemp.listClassProperties.push_back(propertyTemp);
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(subQuery)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ listSinkClasses.push_back(classTemp);
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListVisibleMainConnections(std::vector<am_MainConnectionType_s> & listConnections) const
{
- listConnections.clear();
- sqlite3_stmt *query=NULL;
- int eCode=0;
- am_MainConnectionType_s temp;
+ listConnections.clear();
+ sqlite3_stmt *query = NULL;
+ int eCode = 0;
+ am_MainConnectionType_s temp;
- std::string command= "SELECT mainConnectionID, sourceID, sinkID, connectionState, delay FROM " + std::string(MAINCONNECTION_TABLE);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::string command = "SELECT mainConnectionID, sourceID, sinkID, connectionState, delay FROM " + std::string(MAINCONNECTION_TABLE);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp.mainConnectionID=sqlite3_column_int(query,0);
- temp.sourceID=sqlite3_column_int(query,1);
- temp.sinkID=sqlite3_column_int(query,2);
- temp.connectionState=(am_ConnectionState_e)sqlite3_column_int(query,3);
- temp.delay=sqlite3_column_int(query,4);
- listConnections.push_back(temp);
- }
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.mainConnectionID = sqlite3_column_int(query, 0);
+ temp.sourceID = sqlite3_column_int(query, 1);
+ temp.sinkID = sqlite3_column_int(query, 2);
+ temp.connectionState = (am_ConnectionState_e) sqlite3_column_int(query, 3);
+ temp.delay = sqlite3_column_int(query, 4);
+ listConnections.push_back(temp);
+ }
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListVisibleMainConnections SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListVisibleMainConnections SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListVisibleMainConnections SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListVisibleMainConnections SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- return E_OK;
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListMainSinks(std::vector<am_SinkType_s> & listMainSinks) const
{
- listMainSinks.clear();
- sqlite3_stmt* query=NULL;
- int eCode=0;
- am_SinkType_s temp;
-
- std::string command= "SELECT name, sinkID, availability, availabilityReason, muteState, mainVolume, sinkClassID FROM " + std::string(SINK_TABLE) + " WHERE visible=1 AND reserved=0";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
-
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp.name=std::string((const char*)sqlite3_column_text(query,0));
- temp.sinkID=sqlite3_column_int(query,1);
- temp.availability.availability=(am_Availablility_e)sqlite3_column_int(query,2);
- temp.availability.availabilityReason=(am_AvailabilityReason_e)sqlite3_column_int(query,3);
- temp.muteState=(am_MuteState_e)sqlite3_column_int(query,4);
- temp.volume=sqlite3_column_int(query,5);
- temp.sinkClassID=sqlite3_column_int(query,6);
- listMainSinks.push_back(temp);
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- return E_OK;
+ listMainSinks.clear();
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ am_SinkType_s temp;
+
+ std::string command = "SELECT name, sinkID, availability, availabilityReason, muteState, mainVolume, sinkClassID FROM " + std::string(SINK_TABLE) + " WHERE visible=1 AND reserved=0";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.name = std::string((const char*) sqlite3_column_text(query, 0));
+ temp.sinkID = sqlite3_column_int(query, 1);
+ temp.availability.availability = (am_Availablility_e) sqlite3_column_int(query, 2);
+ temp.availability.availabilityReason = (am_AvailabilityReason_e) sqlite3_column_int(query, 3);
+ temp.muteState = (am_MuteState_e) sqlite3_column_int(query, 4);
+ temp.volume = sqlite3_column_int(query, 5);
+ temp.sinkClassID = sqlite3_column_int(query, 6);
+ listMainSinks.push_back(temp);
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListMainSources(std::vector<am_SourceType_s> & listMainSources) const
{
- listMainSources.clear();
- sqlite3_stmt* query=NULL;
- int eCode=0;
- am_SourceType_s temp;
- std::string command= "SELECT name, sourceClassID, availability, availabilityReason, sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE visible=1";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ listMainSources.clear();
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ am_SourceType_s temp;
+ std::string command = "SELECT name, sourceClassID, availability, availabilityReason, sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE visible=1";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp.name=std::string((const char*)sqlite3_column_text(query,0));
- temp.sourceClassID=sqlite3_column_int(query,1);
- temp.availability.availability=(am_Availablility_e)sqlite3_column_int(query,2);
- temp.availability.availabilityReason=(am_AvailabilityReason_e)sqlite3_column_int(query,3);
- temp.sourceID=sqlite3_column_int(query,4);
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.name = std::string((const char*) sqlite3_column_text(query, 0));
+ temp.sourceClassID = sqlite3_column_int(query, 1);
+ temp.availability.availability = (am_Availablility_e) sqlite3_column_int(query, 2);
+ temp.availability.availabilityReason = (am_AvailabilityReason_e) sqlite3_column_int(query, 3);
+ temp.sourceID = sqlite3_column_int(query, 4);
- listMainSources.push_back(temp);
- }
+ listMainSources.push_back(temp);
+ }
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- return E_OK;
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> & listSoundProperties) const
{
- assert(sinkID!=0);
- if (!existSink(sinkID)) return E_DATABASE_ERROR; // todo: here we could change to non existen, but not shown in sequences
- listSoundProperties.clear();
+ assert(sinkID!=0);
+ if (!existSink(sinkID)) return E_DATABASE_ERROR; // todo: here we could change to non existen, but not shown in sequences
+ listSoundProperties.clear();
- sqlite3_stmt* query=NULL;
- int eCode=0;
- am_MainSoundProperty_s temp;
- std::string command= "SELECT soundPropertyType, value FROM SinkMainSoundProperty" + i2s(sinkID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ am_MainSoundProperty_s temp;
+ std::string command = "SELECT soundPropertyType, value FROM SinkMainSoundProperty" + i2s(sinkID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp.type=(am_MainSoundPropertyType_e)sqlite3_column_int(query,0);
- temp.value=sqlite3_column_int(query,1);
- listSoundProperties.push_back(temp);
- }
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.type = (am_MainSoundPropertyType_e) sqlite3_column_int(query, 0);
+ temp.value = sqlite3_column_int(query, 1);
+ listSoundProperties.push_back(temp);
+ }
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainSinkSoundProperties SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainSinkSoundProperties SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainSinkSoundProperties SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainSinkSoundProperties SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- return E_OK;
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> & listSourceProperties) const
{
- assert(sourceID!=0);
- if (!existSource(sourceID)) return E_DATABASE_ERROR; // todo: here we could change to non existen, but not shown in sequences
- listSourceProperties.clear();
+ assert(sourceID!=0);
+ if (!existSource(sourceID)) return E_DATABASE_ERROR; // todo: here we could change to non existen, but not shown in sequences
+ listSourceProperties.clear();
- sqlite3_stmt* query=NULL;
- int eCode=0;
- am_MainSoundProperty_s temp;
- std::string command= "SELECT soundPropertyType, value FROM SourceMainSoundProperty" + i2s(sourceID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ am_MainSoundProperty_s temp;
+ std::string command = "SELECT soundPropertyType, value FROM SourceMainSoundProperty" + i2s(sourceID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp.type=(am_MainSoundPropertyType_e)sqlite3_column_int(query,0);
- temp.value=sqlite3_column_int(query,1);
- listSourceProperties.push_back(temp);
- }
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.type = (am_MainSoundPropertyType_e) sqlite3_column_int(query, 0);
+ temp.value = sqlite3_column_int(query, 1);
+ listSourceProperties.push_back(temp);
+ }
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainSinkSoundProperties SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainSinkSoundProperties SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainSinkSoundProperties SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainSinkSoundProperties SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- return E_OK;
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const
{
- listSystemProperties.clear();
+ listSystemProperties.clear();
- sqlite3_stmt* query=NULL;
- int eCode=0;
- am_SystemProperty_s temp;
- std::string command= "SELECT type, value FROM " + std::string(SYSTEM_TABLE);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ am_SystemProperty_s temp;
+ std::string command = "SELECT type, value FROM " + std::string(SYSTEM_TABLE);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- temp.type=(am_SystemPropertyType_e)sqlite3_column_int(query,0);
- temp.value=sqlite3_column_int(query,1);
- listSystemProperties.push_back(temp);
- }
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.type = (am_SystemPropertyType_e) sqlite3_column_int(query, 0);
+ temp.value = sqlite3_column_int(query, 1);
+ listSystemProperties.push_back(temp);
+ }
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSystemProperties SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSystemProperties SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSystemProperties SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSystemProperties SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- return E_OK;
+ return E_OK;
}
am_Error_e am::DatabaseHandler::getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const
{
- listConnectionFormats.clear();
- sqlite3_stmt *qConnectionFormat=NULL;
- int eCode=0;
- am_ConnectionFormat_e tempConnectionFormat;
- std::string commandConnectionFormat= "SELECT soundFormat FROM SinkConnectionFormat"+ i2s(sinkID);
- sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qConnectionFormat,NULL);
- while((eCode=sqlite3_step(qConnectionFormat))==SQLITE_ROW)
- {
- tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qConnectionFormat,0);
- listConnectionFormats.push_back(tempConnectionFormat);
- }
+ listConnectionFormats.clear();
+ sqlite3_stmt *qConnectionFormat = NULL;
+ int eCode = 0;
+ am_ConnectionFormat_e tempConnectionFormat;
+ std::string commandConnectionFormat = "SELECT soundFormat FROM SinkConnectionFormat" + i2s(sinkID);
+ sqlite3_prepare_v2(mDatabase, commandConnectionFormat.c_str(), -1, &qConnectionFormat, NULL);
+ while ((eCode = sqlite3_step(qConnectionFormat)) == SQLITE_ROW)
+ {
+ tempConnectionFormat = (am_ConnectionFormat_e) sqlite3_column_int(qConnectionFormat, 0);
+ listConnectionFormats.push_back(tempConnectionFormat);
+ }
- if((eCode=sqlite3_finalize(qConnectionFormat))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinkConnectionFormats SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(qConnectionFormat)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinkConnectionFormats SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- return E_OK;
+ return E_OK;
}
-
-
am_Error_e am::DatabaseHandler::getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const
{
- listConnectionFormats.clear();
- sqlite3_stmt* query=NULL, *qConnectionFormat=NULL, *qSoundProperty=NULL, *qMAinSoundProperty=NULL;
- int eCode=0;
- am_ConnectionFormat_e tempConnectionFormat;
+ listConnectionFormats.clear();
+ sqlite3_stmt* query = NULL, *qConnectionFormat = NULL, *qSoundProperty = NULL, *qMAinSoundProperty = NULL;
+ int eCode = 0;
+ am_ConnectionFormat_e tempConnectionFormat;
- //read out the connectionFormats
- std::string commandConnectionFormat= "SELECT soundFormat FROM SourceConnectionFormat"+ i2s(sourceID);
- sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qConnectionFormat,NULL);
- while((eCode=sqlite3_step(qConnectionFormat))==SQLITE_ROW)
- {
- tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qConnectionFormat,0);
- listConnectionFormats.push_back(tempConnectionFormat);
- }
+ //read out the connectionFormats
+ std::string commandConnectionFormat = "SELECT soundFormat FROM SourceConnectionFormat" + i2s(sourceID);
+ sqlite3_prepare_v2(mDatabase, commandConnectionFormat.c_str(), -1, &qConnectionFormat, NULL);
+ while ((eCode = sqlite3_step(qConnectionFormat)) == SQLITE_ROW)
+ {
+ tempConnectionFormat = (am_ConnectionFormat_e) sqlite3_column_int(qConnectionFormat, 0);
+ listConnectionFormats.push_back(tempConnectionFormat);
+ }
- if((eCode=sqlite3_finalize(qConnectionFormat))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(qConnectionFormat)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- return E_OK;
+ return E_OK;
}
am_Error_e am::DatabaseHandler::getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector<bool> & listConnectionFormat) const
{
- ListConnectionFormat::const_iterator iter=mListConnectionFormat.begin();
- iter=mListConnectionFormat.find(gatewayID);
- if (iter == mListConnectionFormat.end())
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGatewayConnectionFormats database error with convertionFormat"));
- return (E_DATABASE_ERROR);
- }
- listConnectionFormat=iter->second;
+ ListConnectionFormat::const_iterator iter = mListConnectionFormat.begin();
+ iter = mListConnectionFormat.find(gatewayID);
+ if (iter == mListConnectionFormat.end())
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGatewayConnectionFormats database error with convertionFormat"));
+ return (E_DATABASE_ERROR);
+ }
+ listConnectionFormat = iter->second;
- return (E_OK);
+ return (E_OK);
}
-
-
am_Error_e DatabaseHandler::getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t & delay) const
{
- assert(mainConnectionID!=0);
- delay=-1;
- sqlite3_stmt *query=NULL;
- int eCode=0;
+ assert(mainConnectionID!=0);
+ delay = -1;
+ sqlite3_stmt *query = NULL;
+ int eCode = 0;
- std::string command= "SELECT delay FROM " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + i2s(mainConnectionID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::string command = "SELECT delay FROM " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + i2s(mainConnectionID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- delay=sqlite3_column_int(query,0);
- }
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ delay = sqlite3_column_int(query, 0);
+ }
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getTimingInformation SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getTimingInformation SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getTimingInformation SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getTimingInformation SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if (delay==-1) return E_NOT_POSSIBLE;
+ if (delay == -1) return E_NOT_POSSIBLE;
- return E_OK;
+ return E_OK;
}
bool DatabaseHandler::sqQuery(const std::string& query)
{
- sqlite3_stmt* statement;
- int eCode=0;
- if ((eCode=sqlite3_exec(mDatabase,query.c_str(),NULL,&statement,NULL))!= SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::sqQuery SQL Query failed:"), DLT_STRING(query.c_str()), DLT_STRING("error code:"),DLT_INT(eCode));
- return false;
- }
- return true;
+ sqlite3_stmt* statement;
+ int eCode = 0;
+ if ((eCode = sqlite3_exec(mDatabase, query.c_str(), NULL, &statement, NULL)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::sqQuery SQL Query failed:"), DLT_STRING(query.c_str()), DLT_STRING("error code:"), DLT_INT(eCode));
+ return false;
+ }
+ return true;
}
bool DatabaseHandler::openDatabase()
{
- if (sqlite3_open_v2(mPath.c_str(),&mDatabase,SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, NULL) == SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::openDatabase opened database"));
- return true;
- }
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::openDatabase failed to open database"));
- return false;
+ if (sqlite3_open_v2(mPath.c_str(), &mDatabase, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, NULL) == SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::openDatabase opened database"));
+ return true;
+ }DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::openDatabase failed to open database"));
+ return false;
}
am_Error_e DatabaseHandler::changeDelayMainConnection(const am_timeSync_t & delay, const am_mainConnectionID_t & connectionID)
{
- assert(connectionID!=0);
-
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command ="SELECT mainConnectionID FROM "+ std::string(MAINCONNECTION_TABLE) +" WHERE delay=? AND mainConnectionID=?";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, delay);
- sqlite3_bind_int(query,2, connectionID);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- sqlite3_finalize(query);
- return E_OK;
- }
- command="UPDATE " + std::string(MAINCONNECTION_TABLE) + " SET delay=? WHERE mainConnectionID=?;";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, delay);
- sqlite3_bind_int(query,2, connectionID);
-
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeDelayMainConnection SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeDelayMainConnection SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if(mDatabaseObserver) mDatabaseObserver->timingInformationChanged(connectionID,delay);
-
- return E_OK;
+ assert(connectionID!=0);
+
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command = "SELECT mainConnectionID FROM " + std::string(MAINCONNECTION_TABLE) + " WHERE delay=? AND mainConnectionID=?";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, delay);
+ sqlite3_bind_int(query, 2, connectionID);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ sqlite3_finalize(query);
+ return E_OK;
+ }
+ command = "UPDATE " + std::string(MAINCONNECTION_TABLE) + " SET delay=? WHERE mainConnectionID=?;";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, delay);
+ sqlite3_bind_int(query, 2, connectionID);
+
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeDelayMainConnection SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeDelayMainConnection SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if (mDatabaseObserver) mDatabaseObserver->timingInformationChanged(connectionID, delay);
+
+ return E_OK;
}
am_Error_e DatabaseHandler::enterConnectionDB(const am_Connection_s& connection, am_connectionID_t& connectionID)
{
- assert(connection.connectionID==0);
- assert(connection.sinkID!=0);
- assert(connection.sourceID!=0);
- //connection format is not checked, because it's project specific
-
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command= "INSERT INTO " + std::string(CONNECTION_TABLE) + "(sinkID, sourceID, delay, connectionFormat, reserved) VALUES (?,?,?,?,?)";
-
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, connection.sinkID);
- sqlite3_bind_int(query,2, connection.sourceID);
- sqlite3_bind_int(query,3, connection.delay);
- sqlite3_bind_int(query,4, connection.connectionFormat);
- sqlite3_bind_int(query,5, true);
-
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterConnectionDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterConnectionDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- connectionID=sqlite3_last_insert_rowid(mDatabase);
-
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterConnectionDB entered new connection sourceID:"), DLT_INT16(connection.sourceID),
- DLT_STRING("sinkID:"),DLT_INT16(connection.sinkID),
- DLT_STRING("sourceID:"),DLT_INT16(connection.sourceID),
- DLT_STRING("delay:"), DLT_INT16(connection.delay),
- DLT_STRING("connectionFormat:"),DLT_INT16(connection.connectionFormat),
- DLT_STRING("assigned ID:"),DLT_INT16(connectionID));
- return E_OK;
+ assert(connection.connectionID==0);
+ assert(connection.sinkID!=0);
+ assert(connection.sourceID!=0);
+ //connection format is not checked, because it's project specific
+
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command = "INSERT INTO " + std::string(CONNECTION_TABLE) + "(sinkID, sourceID, delay, connectionFormat, reserved) VALUES (?,?,?,?,?)";
+
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, connection.sinkID);
+ sqlite3_bind_int(query, 2, connection.sourceID);
+ sqlite3_bind_int(query, 3, connection.delay);
+ sqlite3_bind_int(query, 4, connection.connectionFormat);
+ sqlite3_bind_int(query, 5, true);
+
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterConnectionDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterConnectionDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ connectionID = sqlite3_last_insert_rowid(mDatabase);
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterConnectionDB entered new connection sourceID:"), DLT_INT16(connection.sourceID), DLT_STRING("sinkID:"), DLT_INT16(connection.sinkID), DLT_STRING("sourceID:"), DLT_INT16(connection.sourceID), DLT_STRING("delay:"), DLT_INT16(connection.delay), DLT_STRING("connectionFormat:"), DLT_INT16(connection.connectionFormat), DLT_STRING("assigned ID:"), DLT_INT16(connectionID));
+ return E_OK;
}
am_Error_e DatabaseHandler::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID)
{
- assert(sinkClass.sinkClassID<DYNAMIC_ID_BOUNDARY);
- assert(!sinkClass.listClassProperties.empty());
- assert(!sinkClass.name.empty());
-
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
-
- //if sinkID is zero and the first Static Sink was already entered, the ID is created
- if (sinkClass.sinkClassID==0 && !mFirstStaticSinkClass)
- {
- command= "INSERT INTO " + std::string(SINK_CLASS_TABLE) + "(name) VALUES (?)";
- }
- else
- {
- //check if the ID already exists
- if(existSinkClass(sinkClass.sinkClassID)) return E_ALREADY_EXISTS;
- command= "INSERT INTO " + std::string(SINK_CLASS_TABLE) + "(name, sinkClassID) VALUES (?,?)";
- }
-
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1, sinkClass.name.c_str(),sinkClass.name.size(),SQLITE_STATIC);
-
- //if the ID is not created, we add it to the query
- if(sinkClass.sinkClassID!=0)
- {
- sqlite3_bind_int(query,2, sinkClass.sinkClassID);
- }
-
- //if the first static sink is entered, we need to set it onto the boundary
- else if(mFirstStaticSinkClass)
- {
- sqlite3_bind_int(query,2, DYNAMIC_ID_BOUNDARY);
- mFirstStaticSinkClass=false;
- }
-
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkClassDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkClassDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- sinkClassID=sqlite3_last_insert_rowid(mDatabase); //todo:change last_insert implementations for mulithread usage...
-
- //now we need to create the additional tables:
- command="CREATE TABLE SinkClassProperties" + i2s(sinkClassID) + std::string("(classProperty INTEGER, value INTEGER)");
- assert(this->sqQuery(command));
-
- //fill ConnectionFormats
- command="INSERT INTO SinkClassProperties" + i2s(sinkClassID) + std::string("(classProperty,value) VALUES (?,?)");
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<am_ClassProperty_s>::const_iterator Iterator=sinkClass.listClassProperties.begin();
- for(;Iterator<sinkClass.listClassProperties.end();++Iterator)
- {
- sqlite3_bind_int(query,1, Iterator->classProperty);
- sqlite3_bind_int(query,2, Iterator->value);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkClassDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkClassDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSinkClassDB entered new sinkClass"));
- if (mDatabaseObserver) mDatabaseObserver->numberOfSinkClassesChanged();
- return E_OK;
+ assert(sinkClass.sinkClassID<DYNAMIC_ID_BOUNDARY);
+ assert(!sinkClass.listClassProperties.empty());
+ assert(!sinkClass.name.empty());
+
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
+
+ //if sinkID is zero and the first Static Sink was already entered, the ID is created
+ if (sinkClass.sinkClassID == 0 && !mFirstStaticSinkClass)
+ {
+ command = "INSERT INTO " + std::string(SINK_CLASS_TABLE) + "(name) VALUES (?)";
+ }
+ else
+ {
+ //check if the ID already exists
+ if (existSinkClass(sinkClass.sinkClassID)) return E_ALREADY_EXISTS;
+ command = "INSERT INTO " + std::string(SINK_CLASS_TABLE) + "(name, sinkClassID) VALUES (?,?)";
+ }
+
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, sinkClass.name.c_str(), sinkClass.name.size(), SQLITE_STATIC);
+
+ //if the ID is not created, we add it to the query
+ if (sinkClass.sinkClassID != 0)
+ {
+ sqlite3_bind_int(query, 2, sinkClass.sinkClassID);
+ }
+
+ //if the first static sink is entered, we need to set it onto the boundary
+ else if (mFirstStaticSinkClass)
+ {
+ sqlite3_bind_int(query, 2, DYNAMIC_ID_BOUNDARY);
+ mFirstStaticSinkClass = false;
+ }
+
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkClassDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkClassDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ sinkClassID = sqlite3_last_insert_rowid(mDatabase); //todo:change last_insert implementations for mulithread usage...
+
+ //now we need to create the additional tables:
+ command = "CREATE TABLE SinkClassProperties" + i2s(sinkClassID) + std::string("(classProperty INTEGER, value INTEGER)");
+ assert(this->sqQuery(command));
+
+ //fill ConnectionFormats
+ command = "INSERT INTO SinkClassProperties" + i2s(sinkClassID) + std::string("(classProperty,value) VALUES (?,?)");
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<am_ClassProperty_s>::const_iterator Iterator = sinkClass.listClassProperties.begin();
+ for (; Iterator < sinkClass.listClassProperties.end(); ++Iterator)
+ {
+ sqlite3_bind_int(query, 1, Iterator->classProperty);
+ sqlite3_bind_int(query, 2, Iterator->value);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkClassDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkClassDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSinkClassDB entered new sinkClass"));
+ if (mDatabaseObserver) mDatabaseObserver->numberOfSinkClassesChanged();
+ return E_OK;
}
am_Error_e DatabaseHandler::enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass)
{
- assert(sourceClass.sourceClassID<DYNAMIC_ID_BOUNDARY);
- assert(!sourceClass.listClassProperties.empty());
- assert(!sourceClass.name.empty());
-
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
-
- //if sinkID is zero and the first Static Sink was already entered, the ID is created
- if (sourceClass.sourceClassID==0 && !mFirstStaticSourceClass)
- {
- command= "INSERT INTO " + std::string(SOURCE_CLASS_TABLE) + "(name) VALUES (?)";
- }
- else
- {
- //check if the ID already exists
- if(existSourceClass(sourceClass.sourceClassID)) return E_ALREADY_EXISTS;
- command= "INSERT INTO " + std::string(SOURCE_CLASS_TABLE) + "(name, sourceClassID) VALUES (?,?)";
- }
-
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1, sourceClass.name.c_str(),sourceClass.name.size(),SQLITE_STATIC);
-
- //if the ID is not created, we add it to the query
- if(sourceClass.sourceClassID!=0)
- {
- sqlite3_bind_int(query,2, sourceClass.sourceClassID);
- }
-
- //if the first static sink is entered, we need to set it onto the boundary
- else if(mFirstStaticSourceClass)
- {
- sqlite3_bind_int(query,2, DYNAMIC_ID_BOUNDARY);
- mFirstStaticSourceClass=false;
- }
-
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceClassDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceClassDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- sourceClassID=sqlite3_last_insert_rowid(mDatabase); //todo:change last_insert implementations for mulithread usage...
-
- //now we need to create the additional tables:
- command="CREATE TABLE SourceClassProperties" + i2s(sourceClassID) + std::string("(classProperty INTEGER, value INTEGER)");
- assert(sqQuery(command));
-
- //fill ConnectionFormats
- command="INSERT INTO SourceClassProperties" + i2s(sourceClassID) + std::string("(classProperty,value) VALUES (?,?)");
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- std::vector<am_ClassProperty_s>::const_iterator Iterator=sourceClass.listClassProperties.begin();
- for(;Iterator<sourceClass.listClassProperties.end();++Iterator)
- {
- sqlite3_bind_int(query,1, Iterator->classProperty);
- sqlite3_bind_int(query,2, Iterator->value);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceClassDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- sqlite3_reset(query);
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceClassDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSourceClassDB entered new sourceClass"));
-
- if (mDatabaseObserver) mDatabaseObserver->numberOfSourceClassesChanged();
- return E_OK;
+ assert(sourceClass.sourceClassID<DYNAMIC_ID_BOUNDARY);
+ assert(!sourceClass.listClassProperties.empty());
+ assert(!sourceClass.name.empty());
+
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
+
+ //if sinkID is zero and the first Static Sink was already entered, the ID is created
+ if (sourceClass.sourceClassID == 0 && !mFirstStaticSourceClass)
+ {
+ command = "INSERT INTO " + std::string(SOURCE_CLASS_TABLE) + "(name) VALUES (?)";
+ }
+ else
+ {
+ //check if the ID already exists
+ if (existSourceClass(sourceClass.sourceClassID)) return E_ALREADY_EXISTS;
+ command = "INSERT INTO " + std::string(SOURCE_CLASS_TABLE) + "(name, sourceClassID) VALUES (?,?)";
+ }
+
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, sourceClass.name.c_str(), sourceClass.name.size(), SQLITE_STATIC);
+
+ //if the ID is not created, we add it to the query
+ if (sourceClass.sourceClassID != 0)
+ {
+ sqlite3_bind_int(query, 2, sourceClass.sourceClassID);
+ }
+
+ //if the first static sink is entered, we need to set it onto the boundary
+ else if (mFirstStaticSourceClass)
+ {
+ sqlite3_bind_int(query, 2, DYNAMIC_ID_BOUNDARY);
+ mFirstStaticSourceClass = false;
+ }
+
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceClassDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceClassDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ sourceClassID = sqlite3_last_insert_rowid(mDatabase); //todo:change last_insert implementations for mulithread usage...
+
+ //now we need to create the additional tables:
+ command = "CREATE TABLE SourceClassProperties" + i2s(sourceClassID) + std::string("(classProperty INTEGER, value INTEGER)");
+ assert(sqQuery(command));
+
+ //fill ConnectionFormats
+ command = "INSERT INTO SourceClassProperties" + i2s(sourceClassID) + std::string("(classProperty,value) VALUES (?,?)");
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ std::vector<am_ClassProperty_s>::const_iterator Iterator = sourceClass.listClassProperties.begin();
+ for (; Iterator < sourceClass.listClassProperties.end(); ++Iterator)
+ {
+ sqlite3_bind_int(query, 1, Iterator->classProperty);
+ sqlite3_bind_int(query, 2, Iterator->value);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceClassDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceClassDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSourceClassDB entered new sourceClass"));
+
+ if (mDatabaseObserver) mDatabaseObserver->numberOfSourceClassesChanged();
+ return E_OK;
}
am_Error_e DatabaseHandler::enterSystemProperties(const std::vector<am_SystemProperty_s> & listSystemProperties)
{
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::vector<am_SystemProperty_s>::const_iterator listIterator =listSystemProperties.begin();
- std::string command= "DELETE * FROM " + std::string(SYSTEM_TABLE);
- sqQuery(command);
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::vector<am_SystemProperty_s>::const_iterator listIterator = listSystemProperties.begin();
+ std::string command = "DELETE * FROM " + std::string(SYSTEM_TABLE);
+ sqQuery(command);
- command="INSERT INTO " + std::string(SYSTEM_TABLE) + " (type, value) VALUES (?,?)";
+ command = "INSERT INTO " + std::string(SYSTEM_TABLE) + " (type, value) VALUES (?,?)";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- for(;listIterator<listSystemProperties.end();++listIterator)
- {
- sqlite3_bind_int(query,1, listIterator->type);
- sqlite3_bind_int(query,2, listIterator->value);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ for (; listIterator < listSystemProperties.end(); ++listIterator)
+ {
+ sqlite3_bind_int(query, 1, listIterator->type);
+ sqlite3_bind_int(query, 2, listIterator->value);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSystemProperties SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSystemProperties SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- sqlite3_reset(query);
- }
+ sqlite3_reset(query);
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSystemProperties SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSystemProperties SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSystemProperties entered system properties"));
- return E_OK;
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSystemProperties entered system properties"));
+ return E_OK;
}
bool DatabaseHandler::existMainConnection(const am_mainConnectionID_t mainConnectionID) const
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT mainConnectionID FROM " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + i2s(mainConnectionID);
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existMainConnection database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT mainConnectionID FROM " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + i2s(mainConnectionID);
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existMainConnection database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
bool DatabaseHandler::existSource(const am_sourceID_t sourceID) const
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND sourceID=" + i2s(sourceID);
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSource database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND sourceID=" + i2s(sourceID);
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSource database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
bool DatabaseHandler::existSourceNameOrID(const am_sourceID_t sourceID, const std::string & name) const
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND (name=? OR sourceID=?)";
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
- sqlite3_bind_int(query,2,sourceID);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSource database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND (name=? OR sourceID=?)";
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, name.c_str(), name.size(), SQLITE_STATIC);
+ sqlite3_bind_int(query, 2, sourceID);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSource database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
bool DatabaseHandler::existSourceName(const std::string & name) const
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND name=?";
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSource database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND name=?";
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, name.c_str(), name.size(), SQLITE_STATIC);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSource database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
bool DatabaseHandler::existSink(const am_sinkID_t sinkID) const
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND sinkID=" + i2s(sinkID);
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND sinkID=" + i2s(sinkID);
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
bool DatabaseHandler::existSinkNameOrID(const am_sinkID_t sinkID, const std::string & name) const
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND (name=? OR sinkID=?)";
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
- sqlite3_bind_int(query,2,sinkID);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND (name=? OR sinkID=?)";
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, name.c_str(), name.size(), SQLITE_STATIC);
+ sqlite3_bind_int(query, 2, sinkID);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
bool DatabaseHandler::existSinkName(const std::string & name) const
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND name=?";
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND name=?";
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, name.c_str(), name.size(), SQLITE_STATIC);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
bool DatabaseHandler::existDomain(const am_domainID_t domainID) const
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT domainID FROM " + std::string(DOMAIN_TABLE) + " WHERE reserved=0 AND domainID=" + i2s(domainID);
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existDomain database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT domainID FROM " + std::string(DOMAIN_TABLE) + " WHERE reserved=0 AND domainID=" + i2s(domainID);
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existDomain database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
bool DatabaseHandler::existGateway(const am_gatewayID_t gatewayID) const
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE gatewayID=" + i2s(gatewayID);
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existGateway database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE gatewayID=" + i2s(gatewayID);
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existGateway database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
am_Error_e DatabaseHandler::getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t & domainID) const
{
- assert(sourceID!=0);
-
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT domainID FROM " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + i2s(sourceID);
- int eCode=0;
- am_Error_e returnVal=E_DATABASE_ERROR;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- domainID=sqlite3_column_int(query,0);
- returnVal=E_OK;
- }
- else
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getDomainOfSource database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return (returnVal);
+ assert(sourceID!=0);
+
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT domainID FROM " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + i2s(sourceID);
+ int eCode = 0;
+ am_Error_e returnVal = E_DATABASE_ERROR;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ domainID = sqlite3_column_int(query, 0);
+ returnVal = E_OK;
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getDomainOfSource database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return (returnVal);
}
am_Error_e am::DatabaseHandler::getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t & domainID) const
{
- assert(sinkID!=0);
-
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT domainID FROM " + std::string(SINK_TABLE) + " WHERE sinkID=" + i2s(sinkID);
- int eCode=0;
- am_Error_e returnVal=E_DATABASE_ERROR;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- domainID=sqlite3_column_int(query,0);
- returnVal=E_OK;
- }
- else
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getDomainOfSink database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return (returnVal);
+ assert(sinkID!=0);
+
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT domainID FROM " + std::string(SINK_TABLE) + " WHERE sinkID=" + i2s(sinkID);
+ int eCode = 0;
+ am_Error_e returnVal = E_DATABASE_ERROR;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ domainID = sqlite3_column_int(query, 0);
+ returnVal = E_OK;
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getDomainOfSink database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return (returnVal);
}
-
bool DatabaseHandler::existSinkClass(const am_sinkClass_t sinkClassID) const
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT sinkClassID FROM " + std::string(SINK_CLASS_TABLE) + " WHERE sinkClassID=" + i2s(sinkClassID);
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSinkClass database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT sinkClassID FROM " + std::string(SINK_CLASS_TABLE) + " WHERE sinkClassID=" + i2s(sinkClassID);
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSinkClass database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
bool DatabaseHandler::existSourceClass(const am_sourceClass_t sourceClassID) const
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT sourceClassID FROM " + std::string(SOURCE_CLASS_TABLE) + " WHERE sourceClassID=" + i2s(sourceClassID);
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSinkClass database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT sourceClassID FROM " + std::string(SOURCE_CLASS_TABLE) + " WHERE sourceClassID=" + i2s(sourceClassID);
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSinkClass database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
am_Error_e DatabaseHandler::changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay)
{
- assert(connectionID!=0);
-
- sqlite3_stmt *query=NULL, *queryMainConnections, *queryMainConnectionSubIDs;
- int eCode=0, eCode1=0;
- std::string command= "UPDATE " + std::string(CONNECTION_TABLE) + " set delay=? WHERE connectionID=?";
-
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, delay);
- sqlite3_bind_int(query,2, connectionID);
-
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionTimingInformation SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionTimingInformation SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- //now we need to find all mainConnections that use the changed connection and update their timing
- am_timeSync_t tempDelay=0;
- am_Error_e error;
-
- int tempMainConnectionID;
- //first get all route tables for all mainconnections
- command= "SELECT name FROM sqlite_master WHERE type ='table' and name LIKE 'MainConnectionRoute%'";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&queryMainConnections,NULL);
-
- while((eCode=sqlite3_step(queryMainConnections))==SQLITE_ROW)
- {
- //now check if the connection ID is in this table
- std::string tablename=std::string((const char*)sqlite3_column_text(queryMainConnections,0));
- std::string command2="SELECT connectionID FROM " + tablename + " WHERE connectionID="+i2s(connectionID);
- sqlite3_prepare_v2(mDatabase,command2.c_str(),-1,&queryMainConnectionSubIDs,NULL);
- if((eCode1=sqlite3_step(queryMainConnectionSubIDs))==SQLITE_ROW)
- {
- //if the connection ID is in, recalculate the mainconnection delay
- std::stringstream(tablename.substr(tablename.find_first_not_of("MainConnectionRoute"))) >> tempMainConnectionID;
- changeDelayMainConnection(calculateMainConnectionDelay(tempMainConnectionID),tempMainConnectionID);
- }
- else if(eCode1!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionTimingInformation SQLITE error code:"),DLT_INT(eCode1));
- return E_DATABASE_ERROR;
- }
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionTimingInformation SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(queryMainConnections))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionTimingInformation SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- return E_OK;
+ assert(connectionID!=0);
+
+ sqlite3_stmt *query = NULL, *queryMainConnections, *queryMainConnectionSubIDs;
+ int eCode = 0, eCode1 = 0;
+ std::string command = "UPDATE " + std::string(CONNECTION_TABLE) + " set delay=? WHERE connectionID=?";
+
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, delay);
+ sqlite3_bind_int(query, 2, connectionID);
+
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionTimingInformation SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionTimingInformation SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //now we need to find all mainConnections that use the changed connection and update their timing
+ am_timeSync_t tempDelay = 0;
+ am_Error_e error;
+
+ int tempMainConnectionID;
+ //first get all route tables for all mainconnections
+ command = "SELECT name FROM sqlite_master WHERE type ='table' and name LIKE 'MainConnectionRoute%'";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &queryMainConnections, NULL);
+
+ while ((eCode = sqlite3_step(queryMainConnections)) == SQLITE_ROW)
+ {
+ //now check if the connection ID is in this table
+ std::string tablename = std::string((const char*) sqlite3_column_text(queryMainConnections, 0));
+ std::string command2 = "SELECT connectionID FROM " + tablename + " WHERE connectionID=" + i2s(connectionID);
+ sqlite3_prepare_v2(mDatabase, command2.c_str(), -1, &queryMainConnectionSubIDs, NULL);
+ if ((eCode1 = sqlite3_step(queryMainConnectionSubIDs)) == SQLITE_ROW)
+ {
+ //if the connection ID is in, recalculate the mainconnection delay
+ std::stringstream(tablename.substr(tablename.find_first_not_of("MainConnectionRoute"))) >> tempMainConnectionID;
+ changeDelayMainConnection(calculateMainConnectionDelay(tempMainConnectionID), tempMainConnectionID);
+ }
+ else if (eCode1 != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionTimingInformation SQLITE error code:"), DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionTimingInformation SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(queryMainConnections)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionTimingInformation SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
}
am_Error_e DatabaseHandler::changeConnectionFinal(const am_connectionID_t connectionID)
{
- assert(connectionID!=0);
+ assert(connectionID!=0);
- sqlite3_stmt *query=NULL;
- int eCode=0;
- std::string command= "UPDATE " + std::string(CONNECTION_TABLE) + " set reserved=0 WHERE connectionID=?";
+ sqlite3_stmt *query = NULL;
+ int eCode = 0;
+ std::string command = "UPDATE " + std::string(CONNECTION_TABLE) + " set reserved=0 WHERE connectionID=?";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, connectionID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, connectionID);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionFinal SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionFinal SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionFinal SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- return E_OK;
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionFinal SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ return E_OK;
}
am_timeSync_t DatabaseHandler::calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const
{
- assert (mainConnectionID!=0);
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT sum(Connections.delay),min(Connections.delay) FROM "+ std::string(CONNECTION_TABLE)+",MainConnectionRoute"+ i2s(mainConnectionID)+" WHERE MainConnectionRoute"+ i2s(mainConnectionID)+".connectionID = Connections.connectionID" ;
- int eCode=0;
- am_timeSync_t delay=0;
- am_timeSync_t min=0;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- delay=sqlite3_column_int(query,0);
- min=sqlite3_column_int(query,1);
- }
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::calculateMainConnectionDelay SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::calculateMainConnectionDelay SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- if (min<0) delay=-1;
- return delay;
+ assert(mainConnectionID!=0);
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT sum(Connections.delay),min(Connections.delay) FROM " + std::string(CONNECTION_TABLE) + ",MainConnectionRoute" + i2s(mainConnectionID) + " WHERE MainConnectionRoute" + i2s(mainConnectionID) + ".connectionID = Connections.connectionID";
+ int eCode = 0;
+ am_timeSync_t delay = 0;
+ am_timeSync_t min = 0;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ delay = sqlite3_column_int(query, 0);
+ min = sqlite3_column_int(query, 1);
+ }
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::calculateMainConnectionDelay SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::calculateMainConnectionDelay SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ if (min < 0) delay = -1;
+ return delay;
}
void DatabaseHandler::registerObserver(DatabaseObserver *iObserver)
{
- assert(iObserver!=NULL);
- mDatabaseObserver=iObserver;
+ assert(iObserver!=NULL);
+ mDatabaseObserver = iObserver;
}
bool DatabaseHandler::sourceVisible(const am_sourceID_t sourceID) const
{
- assert(sourceID!=0);
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT visible FROM "+ std::string(SOURCE_TABLE) +" WHERE sourceID="+ i2s(sourceID);
- int eCode=0;
- bool returnVal=false;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE)
- {
- returnVal=(bool)sqlite3_column_int(query,0);
- }
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::sourceVisible database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ assert(sourceID!=0);
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT visible FROM " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + i2s(sourceID);
+ int eCode = 0;
+ bool returnVal = false;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ {
+ returnVal = (bool) sqlite3_column_int(query, 0);
+ }
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::sourceVisible database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
bool DatabaseHandler::sinkVisible(const am_sinkID_t sinkID) const
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT visible FROM "+ std::string(SINK_TABLE) +" WHERE reserved=0 AND sinkID="+ i2s(sinkID);
- int eCode=0;
- bool returnVal=false;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE)
- {
- returnVal=sqlite3_column_int(query,0);
- }
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::sinkVisible database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT visible FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND sinkID=" + i2s(sinkID);
+ int eCode = 0;
+ bool returnVal = false;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ {
+ returnVal = sqlite3_column_int(query, 0);
+ }
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::sinkVisible database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
bool DatabaseHandler::existConnection(const am_Connection_s connection)
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT connectionID FROM " + std::string(CONNECTION_TABLE) + " WHERE sinkID=? AND sourceID=? AND connectionFormat=? AND reserved=0";
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, connection.sinkID);
- sqlite3_bind_int(query,2, connection.sourceID);
- sqlite3_bind_int(query,3, connection.connectionFormat);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existMainConnection database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT connectionID FROM " + std::string(CONNECTION_TABLE) + " WHERE sinkID=? AND sourceID=? AND connectionFormat=? AND reserved=0";
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, connection.sinkID);
+ sqlite3_bind_int(query, 2, connection.sourceID);
+ sqlite3_bind_int(query, 3, connection.connectionFormat);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existMainConnection database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
-
bool DatabaseHandler::existConnectionID(const am_connectionID_t connectionID)
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT connectionID FROM " + std::string(CONNECTION_TABLE) + " WHERE connectionID=? AND reserved=0";
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, connectionID);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existMainConnection database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT connectionID FROM " + std::string(CONNECTION_TABLE) + " WHERE connectionID=? AND reserved=0";
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, connectionID);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existMainConnection database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
bool DatabaseHandler::existcrossFader(const am_crossfaderID_t crossfaderID) const
{
- sqlite3_stmt* query=NULL;
- std::string command = "SELECT crossfaderID FROM " + std::string(CROSSFADER_TABLE) + " WHERE crossfaderID=?";
- int eCode=0;
- bool returnVal=true;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, crossfaderID);
- if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
- else if (eCode!=SQLITE_ROW)
- {
- returnVal=false;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existMainConnection database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return returnVal;
+ sqlite3_stmt* query = NULL;
+ std::string command = "SELECT crossfaderID FROM " + std::string(CROSSFADER_TABLE) + " WHERE crossfaderID=?";
+ int eCode = 0;
+ bool returnVal = true;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, crossfaderID);
+ if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ returnVal = false;
+ else if (eCode != SQLITE_ROW)
+ {
+ returnVal = false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existMainConnection database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
}
am_Error_e DatabaseHandler::getSoureState(const am_sourceID_t sourceID, am_SourceState_e & sourceState) const
{
- assert(sourceID!=0);
- sqlite3_stmt* query=NULL;
- sourceState=SS_MIN;
- std::string command = "SELECT sourceState FROM "+ std::string(SOURCE_TABLE) +" WHERE sourceID="+ i2s(sourceID);
- int eCode=0;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- sourceState=(am_SourceState_e)sqlite3_column_int(query,0);
- }
- else if ((eCode=sqlite3_step(query))==SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSoureState database error!:"), DLT_INT(eCode))
-
- }
- sqlite3_finalize(query);
- return E_OK;
+ assert(sourceID!=0);
+ sqlite3_stmt* query = NULL;
+ sourceState = SS_MIN;
+ std::string command = "SELECT sourceState FROM " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + i2s(sourceID);
+ int eCode = 0;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ sourceState = (am_SourceState_e) sqlite3_column_int(query, 0);
+ }
+ else if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSoureState database error!:"), DLT_INT(eCode))
+
+ }
+ sqlite3_finalize(query);
+ return E_OK;
}
am_Error_e DatabaseHandler::changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState)
{
- assert(sourceID!=0);
- sqlite3_stmt* query=NULL;
- std::string command = "UPDATE " + std::string(SOURCE_TABLE) +" SET sourceState=? WHERE sourceID="+ i2s(sourceID);
- int eCode=0;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1,sourceState);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceState SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceState SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- return E_OK;
+ assert(sourceID!=0);
+ sqlite3_stmt* query = NULL;
+ std::string command = "UPDATE " + std::string(SOURCE_TABLE) + " SET sourceState=? WHERE sourceID=" + i2s(sourceID);
+ int eCode = 0;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, sourceState);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceState SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceState SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ return E_OK;
}
am_Error_e DatabaseHandler::getSinkVolume(const am_sinkID_t sinkID, am_volume_t & volume) const
{
- assert(sinkID!=0);
- sqlite3_stmt* query=NULL;
- volume=-1;
- std::string command = "SELECT volume FROM "+ std::string(SINK_TABLE) +" WHERE sinkID="+ i2s(sinkID);
- int eCode=0;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- volume=sqlite3_column_int(query,0);
- }
- else if ((eCode=sqlite3_step(query))==SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkVolume database error!:"), DLT_INT(eCode))
-
- }
- sqlite3_finalize(query);
- return E_OK;
+ assert(sinkID!=0);
+ sqlite3_stmt* query = NULL;
+ volume = -1;
+ std::string command = "SELECT volume FROM " + std::string(SINK_TABLE) + " WHERE sinkID=" + i2s(sinkID);
+ int eCode = 0;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ volume = sqlite3_column_int(query, 0);
+ }
+ else if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkVolume database error!:"), DLT_INT(eCode))
+
+ }
+ sqlite3_finalize(query);
+ return E_OK;
}
am_Error_e DatabaseHandler::getSourceVolume(const am_sourceID_t sourceID, am_volume_t & volume) const
{
- assert(sourceID!=0);
- sqlite3_stmt* query=NULL;
- volume=-1;
- std::string command = "SELECT volume FROM "+ std::string(SOURCE_TABLE) +" WHERE sourceID="+ i2s(sourceID);
- int eCode=0;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- volume=sqlite3_column_int(query,0);
- }
- else if ((eCode=sqlite3_step(query))==SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceVolume database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return E_OK;
+ assert(sourceID!=0);
+ sqlite3_stmt* query = NULL;
+ volume = -1;
+ std::string command = "SELECT volume FROM " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + i2s(sourceID);
+ int eCode = 0;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ volume = sqlite3_column_int(query, 0);
+ }
+ else if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceVolume database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return E_OK;
}
-
am_Error_e DatabaseHandler::getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_SoundPropertyType_e propertyType, uint16_t & value) const
{
- assert(sinkID!=0);
- if (!existSink(sinkID)) return E_DATABASE_ERROR; // todo: here we could change to non existent, but not shown in sequences
+ assert(sinkID!=0);
+ if (!existSink(sinkID)) return E_DATABASE_ERROR; // todo: here we could change to non existent, but not shown in sequences
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command= "SELECT value FROM SinkSoundProperty" + i2s(sinkID) +" WHERE soundPropertyType=" +i2s(propertyType);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command = "SELECT value FROM SinkSoundProperty" + i2s(sinkID) + " WHERE soundPropertyType=" + i2s(propertyType);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- value=sqlite3_column_int(query,0);
- }
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ value = sqlite3_column_int(query, 0);
+ }
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkSoundPropertyValue SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkSoundPropertyValue SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkSoundPropertyValue SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkSoundPropertyValue SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- return E_OK;
+ return E_OK;
}
am_Error_e DatabaseHandler::getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_SoundPropertyType_e propertyType, uint16_t & value) const
{
- assert(sourceID!=0);
- if (!existSource(sourceID)) return E_DATABASE_ERROR; // todo: here we could change to non existent, but not shown in sequences
+ assert(sourceID!=0);
+ if (!existSource(sourceID)) return E_DATABASE_ERROR; // todo: here we could change to non existent, but not shown in sequences
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command= "SELECT value FROM SourceSoundProperty" + i2s(sourceID) +" WHERE soundPropertyType=" +i2s(propertyType);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command = "SELECT value FROM SourceSoundProperty" + i2s(sourceID) + " WHERE soundPropertyType=" + i2s(propertyType);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- value=sqlite3_column_int(query,0);
- }
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ value = sqlite3_column_int(query, 0);
+ }
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkSoundPropertyValue SQLITE error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkSoundPropertyValue SQLITE error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkSoundPropertyValue SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkSoundPropertyValue SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- return E_OK;
+ return E_OK;
}
am_Error_e DatabaseHandler::getDomainState(const am_domainID_t domainID, am_DomainState_e state) const
{
- assert(domainID!=0);
- sqlite3_stmt* query=NULL;
- state=DS_MIN;
- std::string command = "SELECT domainState FROM "+ std::string(DOMAIN_TABLE) +" WHERE domainID="+ i2s(domainID);
- int eCode=0;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- state=(am_DomainState_e)sqlite3_column_int(query,0);
- }
- else if ((eCode=sqlite3_step(query))==SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getDomainState database error!:"), DLT_INT(eCode))
+ assert(domainID!=0);
+ sqlite3_stmt* query = NULL;
+ state = DS_MIN;
+ std::string command = "SELECT domainState FROM " + std::string(DOMAIN_TABLE) + " WHERE domainID=" + i2s(domainID);
+ int eCode = 0;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ state = (am_DomainState_e) sqlite3_column_int(query, 0);
+ }
+ else if ((eCode = sqlite3_step(query)) == SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getDomainState database error!:"), DLT_INT(eCode))
- }
- sqlite3_finalize(query);
- return E_OK;
+ }
+ sqlite3_finalize(query);
+ return E_OK;
}
am_Error_e DatabaseHandler::peekDomain(const std::string & name, am_domainID_t & domainID)
{
- sqlite3_stmt* query=NULL, *queryInsert=NULL;
- std::string command = "SELECT domainID FROM " + std::string(DOMAIN_TABLE) + " WHERE name=?";
- int eCode=0, eCode1=0;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- domainID=sqlite3_column_int(query,0);
- }
- else if (eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain database error!:"), DLT_INT(eCode))
- return E_DATABASE_ERROR;
- }
- else
- {
- command= "INSERT INTO " + std::string(DOMAIN_TABLE) + " (name,reserved) VALUES (?,?)";
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&queryInsert,NULL);
- sqlite3_bind_text(queryInsert,1,name.c_str(),name.size(),SQLITE_STATIC);
- sqlite3_bind_int(queryInsert,2,1); //reservation flag
- if((eCode1=sqlite3_step(queryInsert))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain SQLITE Step error code:"),DLT_INT(eCode1));
- return E_DATABASE_ERROR;
- }
-
- if((eCode1=sqlite3_finalize(queryInsert))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain SQLITE Finalize error code:"),DLT_INT(eCode1));
- return E_DATABASE_ERROR;
- }
- domainID=sqlite3_last_insert_rowid(mDatabase);
- }
- sqlite3_finalize(query);
- return E_OK;
+ sqlite3_stmt* query = NULL, *queryInsert = NULL;
+ std::string command = "SELECT domainID FROM " + std::string(DOMAIN_TABLE) + " WHERE name=?";
+ int eCode = 0, eCode1 = 0;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, name.c_str(), name.size(), SQLITE_STATIC);
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ domainID = sqlite3_column_int(query, 0);
+ }
+ else if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain database error!:"), DLT_INT(eCode))
+ return E_DATABASE_ERROR;
+ }
+ else
+ {
+ command = "INSERT INTO " + std::string(DOMAIN_TABLE) + " (name,reserved) VALUES (?,?)";
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &queryInsert, NULL);
+ sqlite3_bind_text(queryInsert, 1, name.c_str(), name.size(), SQLITE_STATIC);
+ sqlite3_bind_int(queryInsert, 2, 1); //reservation flag
+ if ((eCode1 = sqlite3_step(queryInsert)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain SQLITE Step error code:"), DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode1 = sqlite3_finalize(queryInsert)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain SQLITE Finalize error code:"), DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+ domainID = sqlite3_last_insert_rowid(mDatabase);
+ }
+ sqlite3_finalize(query);
+ return E_OK;
}
am_Error_e DatabaseHandler::peekSink(const std::string & name, am_sinkID_t & sinkID)
{
- sqlite3_stmt* query=NULL, *queryInsert=NULL;
- std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE name=?";
- int eCode=0, eCode1=0;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- sinkID=sqlite3_column_int(query,0);
- }
- else if (eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekSink database error!:"), DLT_INT(eCode))
- return E_DATABASE_ERROR;
- }
- else
- {
- if (mFirstStaticSink)
- {
- command= "INSERT INTO " + std::string(SINK_TABLE) + " (name,reserved,sinkID) VALUES (?,?," + i2s(DYNAMIC_ID_BOUNDARY) + ")";
- mFirstStaticSink=false;
- }
- else
- {
- command= "INSERT INTO " + std::string(SINK_TABLE) + " (name,reserved) VALUES (?,?)";
- }
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&queryInsert,NULL);
- sqlite3_bind_text(queryInsert,1,name.c_str(),name.size(),SQLITE_STATIC);
- sqlite3_bind_int(queryInsert,2,1); //reservation flag
- if((eCode1=sqlite3_step(queryInsert))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekSink SQLITE Step error code:"),DLT_INT(eCode1));
- return E_DATABASE_ERROR;
- }
-
- if((eCode1=sqlite3_finalize(queryInsert))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain SQLITE Finalize error code:"),DLT_INT(eCode1));
- return E_DATABASE_ERROR;
- }
- sinkID=sqlite3_last_insert_rowid(mDatabase);
- }
- sqlite3_finalize(query);
- return E_OK;
+ sqlite3_stmt* query = NULL, *queryInsert = NULL;
+ std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE name=?";
+ int eCode = 0, eCode1 = 0;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, name.c_str(), name.size(), SQLITE_STATIC);
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ sinkID = sqlite3_column_int(query, 0);
+ }
+ else if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekSink database error!:"), DLT_INT(eCode))
+ return E_DATABASE_ERROR;
+ }
+ else
+ {
+ if (mFirstStaticSink)
+ {
+ command = "INSERT INTO " + std::string(SINK_TABLE) + " (name,reserved,sinkID) VALUES (?,?," + i2s(DYNAMIC_ID_BOUNDARY) + ")";
+ mFirstStaticSink = false;
+ }
+ else
+ {
+ command = "INSERT INTO " + std::string(SINK_TABLE) + " (name,reserved) VALUES (?,?)";
+ }
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &queryInsert, NULL);
+ sqlite3_bind_text(queryInsert, 1, name.c_str(), name.size(), SQLITE_STATIC);
+ sqlite3_bind_int(queryInsert, 2, 1); //reservation flag
+ if ((eCode1 = sqlite3_step(queryInsert)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekSink SQLITE Step error code:"), DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode1 = sqlite3_finalize(queryInsert)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain SQLITE Finalize error code:"), DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+ sinkID = sqlite3_last_insert_rowid(mDatabase);
+ }
+ sqlite3_finalize(query);
+ return E_OK;
}
-
-
am_Error_e DatabaseHandler::peekSource(const std::string & name, am_sourceID_t & sourceID)
{
- sqlite3_stmt* query=NULL, *queryInsert=NULL;
- std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE name=?";
- int eCode=0, eCode1=0;
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
- if ((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- sourceID=sqlite3_column_int(query,0);
- }
- else if (eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekSink database error!:"), DLT_INT(eCode))
- return E_DATABASE_ERROR;
- }
- else
- {
- if (mFirstStaticSource)
- {
- command= "INSERT INTO " + std::string(SOURCE_TABLE) + " (name,reserved,sourceID) VALUES (?,?," + i2s(DYNAMIC_ID_BOUNDARY) + ")";
- mFirstStaticSource=false;
- }
- else
- {
- command= "INSERT INTO " + std::string(SOURCE_TABLE) + " (name,reserved) VALUES (?,?)";
- }
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&queryInsert,NULL);
- sqlite3_bind_text(queryInsert,1,name.c_str(),name.size(),SQLITE_STATIC);
- sqlite3_bind_int(queryInsert,2,1); //reservation flag
- if((eCode1=sqlite3_step(queryInsert))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekSink SQLITE Step error code:"),DLT_INT(eCode1));
- return E_DATABASE_ERROR;
- }
-
- if((eCode1=sqlite3_finalize(queryInsert))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain SQLITE Finalize error code:"),DLT_INT(eCode1));
- return E_DATABASE_ERROR;
- }
- sourceID=sqlite3_last_insert_rowid(mDatabase);
- }
- sqlite3_finalize(query);
- return E_OK;
+ sqlite3_stmt* query = NULL, *queryInsert = NULL;
+ std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE name=?";
+ int eCode = 0, eCode1 = 0;
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_text(query, 1, name.c_str(), name.size(), SQLITE_STATIC);
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ sourceID = sqlite3_column_int(query, 0);
+ }
+ else if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekSink database error!:"), DLT_INT(eCode))
+ return E_DATABASE_ERROR;
+ }
+ else
+ {
+ if (mFirstStaticSource)
+ {
+ command = "INSERT INTO " + std::string(SOURCE_TABLE) + " (name,reserved,sourceID) VALUES (?,?," + i2s(DYNAMIC_ID_BOUNDARY) + ")";
+ mFirstStaticSource = false;
+ }
+ else
+ {
+ command = "INSERT INTO " + std::string(SOURCE_TABLE) + " (name,reserved) VALUES (?,?)";
+ }
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &queryInsert, NULL);
+ sqlite3_bind_text(queryInsert, 1, name.c_str(), name.size(), SQLITE_STATIC);
+ sqlite3_bind_int(queryInsert, 2, 1); //reservation flag
+ if ((eCode1 = sqlite3_step(queryInsert)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekSink SQLITE Step error code:"), DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+
+ if ((eCode1 = sqlite3_finalize(queryInsert)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain SQLITE Finalize error code:"), DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+ sourceID = sqlite3_last_insert_rowid(mDatabase);
+ }
+ sqlite3_finalize(query);
+ return E_OK;
}
am_Error_e DatabaseHandler::changeSinkVolume(const am_sinkID_t sinkID, const am_volume_t volume)
{
- assert(sinkID!=0);
+ assert(sinkID!=0);
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
- if (!existSink(sinkID))
- {
- return E_NON_EXISTENT;
- }
- command = "UPDATE " + std::string(SINK_TABLE) + " SET volume=? WHERE sinkID=" + i2s(sinkID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, volume);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkVolume SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkVolume SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(SINK_TABLE) + " SET volume=? WHERE sinkID=" + i2s(sinkID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, volume);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkVolume SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkVolume SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkVolume changed volume of sink:"),DLT_INT(sinkID),DLT_STRING("to:"),DLT_INT(volume));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkVolume changed volume of sink:"), DLT_INT(sinkID), DLT_STRING("to:"), DLT_INT(volume));
- return E_OK;
+ return E_OK;
}
am_Error_e DatabaseHandler::changeSourceVolume(const am_sourceID_t sourceID, const am_volume_t volume)
{
- assert(sourceID!=0);
+ assert(sourceID!=0);
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
- if (!existSource(sourceID))
- {
- return E_NON_EXISTENT;
- }
- command = "UPDATE " + std::string(SOURCE_TABLE) + " SET volume=? WHERE sourceID=" + i2s(sourceID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, volume);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceVolume SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceVolume SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (!existSource(sourceID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(SOURCE_TABLE) + " SET volume=? WHERE sourceID=" + i2s(sourceID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, volume);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceVolume SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceVolume SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSourceVolume changed volume of source=:"),DLT_INT(sourceID),DLT_STRING("to:"),DLT_INT(volume));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSourceVolume changed volume of source=:"), DLT_INT(sourceID), DLT_STRING("to:"), DLT_INT(volume));
- return E_OK;
+ return E_OK;
}
am_Error_e DatabaseHandler::changeSourceSoundPropertyDB(const am_SoundProperty_s & soundProperty, const am_sourceID_t sourceID)
{
- //todo: add checks if soundproperty exists!
- assert(sourceID!=0);
+ //todo: add checks if soundproperty exists!
+ assert(sourceID!=0);
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
- if (!existSource(sourceID))
- {
- return E_NON_EXISTENT;
- }
- command = "UPDATE SourceSoundProperty" + i2s(sourceID)+ " SET value=? WHERE soundPropertyType=" + i2s(soundProperty.type);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, soundProperty.value);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceSoundPropertyDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (!existSource(sourceID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE SourceSoundProperty" + i2s(sourceID) + " SET value=? WHERE soundPropertyType=" + i2s(soundProperty.type);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, soundProperty.value);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceSoundPropertyDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceSoundPropertyDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceSoundPropertyDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSourceSoundPropertyDB changed SourceSoundProperty of source:"),DLT_INT(sourceID),DLT_STRING("type:"),DLT_INT(soundProperty.type),DLT_STRING("to:"),DLT_INT(soundProperty.value));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSourceSoundPropertyDB changed SourceSoundProperty of source:"), DLT_INT(sourceID), DLT_STRING("type:"), DLT_INT(soundProperty.type), DLT_STRING("to:"), DLT_INT(soundProperty.value));
- return E_OK;
+ return E_OK;
}
am_Error_e DatabaseHandler::changeSinkSoundPropertyDB(const am_SoundProperty_s & soundProperty, const am_sinkID_t sinkID)
{
- //todo: add checks if soundproperty exists!
- assert(sinkID!=0);
+ //todo: add checks if soundproperty exists!
+ assert(sinkID!=0);
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
- if (!existSink(sinkID))
- {
- return E_NON_EXISTENT;
- }
- command = "UPDATE SinkSoundProperty" + i2s(sinkID)+ " SET value=? WHERE soundPropertyType=" + i2s(soundProperty.type);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, soundProperty.value);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkSoundPropertyDB SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- } assert(sinkID!=0);
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE SinkSoundProperty" + i2s(sinkID) + " SET value=? WHERE soundPropertyType=" + i2s(soundProperty.type);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, soundProperty.value);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkSoundPropertyDB SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }assert(sinkID!=0);
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkSoundPropertyDB SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkSoundPropertyDB SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkSoundPropertyDB changed MainSinkSoundProperty of sink:"),DLT_INT(sinkID),DLT_STRING("type:"),DLT_INT(soundProperty.type),DLT_STRING("to:"),DLT_INT(soundProperty.value));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkSoundPropertyDB changed MainSinkSoundProperty of sink:"), DLT_INT(sinkID), DLT_STRING("type:"), DLT_INT(soundProperty.type), DLT_STRING("to:"), DLT_INT(soundProperty.value));
- return E_OK;
+ return E_OK;
}
am_Error_e DatabaseHandler::changeCrossFaderHotSink(const am_crossfaderID_t crossfaderID, const am_HotSink_e hotsink)
{
- assert(crossfaderID!=0);
+ assert(crossfaderID!=0);
- sqlite3_stmt* query=NULL;
- int eCode=0;
- std::string command;
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command;
- if (!existcrossFader(crossfaderID))
- {
- return E_NON_EXISTENT;
- }
- command = "UPDATE " + std::string(CROSSFADER_TABLE) + " SET hotsink=? WHERE crossfaderID=" + i2s(crossfaderID);
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_int(query,1, hotsink);
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeCrossFaderHotSink SQLITE Step error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeCrossFaderHotSink SQLITE Finalize error code:"),DLT_INT(eCode));
- return E_DATABASE_ERROR;
- }
+ if (!existcrossFader(crossfaderID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(CROSSFADER_TABLE) + " SET hotsink=? WHERE crossfaderID=" + i2s(crossfaderID);
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ sqlite3_bind_int(query, 1, hotsink);
+ if ((eCode = sqlite3_step(query)) != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeCrossFaderHotSink SQLITE Step error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeCrossFaderHotSink SQLITE Finalize error code:"), DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeCrossFaderHotSink changed hotsink of crossfader="),DLT_INT(crossfaderID),DLT_STRING("to:"),DLT_INT(hotsink));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeCrossFaderHotSink changed hotsink of crossfader="), DLT_INT(crossfaderID), DLT_STRING("to:"), DLT_INT(hotsink));
- return E_OK;
+ return E_OK;
}
am_Error_e am::DatabaseHandler::getRoutingTree(bool onlyfree, RoutingTree *tree, std::vector<RoutingTreeItem*> *flatTree)
{
- sqlite3_stmt* query=NULL;
- int eCode=0;
- size_t i=0;
- std::string command;
- am_domainID_t rootID = tree->returnRootDomainID();
- RoutingTreeItem *parent = tree->returnRootItem();
-
- command="SELECT domainSourceID,gatewayID FROM " + std::string(GATEWAY_TABLE)+ " WHERE domainSinkID=? AND IsBlocked=?";
-
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- do {
- sqlite3_bind_int(query,1, rootID);
- sqlite3_bind_int(query,2, onlyfree);
- while((eCode=sqlite3_step(query))==SQLITE_ROW)
- {
- flatTree->push_back(tree->insertItem(sqlite3_column_int(query,0),sqlite3_column_int(query,1),parent));
- }
-
- if(eCode!=SQLITE_DONE)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getRoutingTree SQLITE error code:"),DLT_INT(eCode));
- return (E_DATABASE_ERROR);
- }
- parent = flatTree->at(i);
- rootID = parent->returnDomainID();
- i++;
- } while (flatTree->size() > i);
-
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getRoutingTree SQLITE Finalize error code:"),DLT_INT(eCode));
- return (E_DATABASE_ERROR);
- }
-
- return (E_OK);
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ size_t i = 0;
+ std::string command;
+ am_domainID_t rootID = tree->returnRootDomainID();
+ RoutingTreeItem *parent = tree->returnRootItem();
+
+ command = "SELECT domainSourceID,gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE domainSinkID=? AND inUse=?";
+
+ sqlite3_prepare_v2(mDatabase, command.c_str(), -1, &query, NULL);
+ do
+ {
+ sqlite3_bind_int(query, 1, rootID);
+ sqlite3_bind_int(query, 2, onlyfree);
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ flatTree->push_back(tree->insertItem(sqlite3_column_int(query, 0), sqlite3_column_int(query, 1), parent));
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getRoutingTree SQLITE error code:"), DLT_INT(eCode));
+ return (E_DATABASE_ERROR);
+ }
+ parent = flatTree->at(i);
+ rootID = parent->returnDomainID();
+ i++;
+ } while (flatTree->size() > i);
+
+ if ((eCode = sqlite3_finalize(query)) != SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getRoutingTree SQLITE Finalize error code:"), DLT_INT(eCode));
+ return (E_DATABASE_ERROR);
+ }
+
+ return (E_OK);
}
void DatabaseHandler::createTables()
{
- for(uint16_t i=0;i<sizeof(databaseTables)/sizeof(databaseTables[0]);i++)
- {
- assert(sqQuery("CREATE TABLE " + databaseTables[i]));
- }
+ for (uint16_t i = 0; i < sizeof(databaseTables) / sizeof(databaseTables[0]); i++)
+ {
+ assert(sqQuery("CREATE TABLE " + databaseTables[i]));
+ }
}
-
-
-
-
-
diff --git a/AudioManagerDaemon/src/DatabaseObserver.cpp b/AudioManagerDaemon/src/DatabaseObserver.cpp
index 63f3b02..b09aee8 100644
--- a/AudioManagerDaemon/src/DatabaseObserver.cpp
+++ b/AudioManagerDaemon/src/DatabaseObserver.cpp
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file DatabaseObserver.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file DatabaseObserver.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#include "DatabaseObserver.h"
#include "CommandSender.h"
@@ -30,193 +30,141 @@
using namespace am;
-DatabaseObserver::DatabaseObserver(CommandSender *iCommandSender, RoutingSender *iRoutingSender)
- :mCommandSender(iCommandSender),
- mRoutingSender(iRoutingSender)
+DatabaseObserver::DatabaseObserver(CommandSender *iCommandSender, RoutingSender *iRoutingSender) :
+ mCommandSender(iCommandSender), //
+ mRoutingSender(iRoutingSender)
{
- assert(mCommandSender!=0);
- assert(mRoutingSender!=0);
+ assert(mCommandSender!=0);
+ assert(mRoutingSender!=0);
}
-DatabaseObserver::DatabaseObserver(CommandSender *iCommandSender, RoutingSender *iRoutingSender, TelnetServer *iTelnetServer)
- :mCommandSender(iCommandSender),
- mRoutingSender(iRoutingSender),
- mTelnetServer(iTelnetServer)
+DatabaseObserver::DatabaseObserver(CommandSender *iCommandSender, RoutingSender *iRoutingSender, TelnetServer *iTelnetServer) :
+ mCommandSender(iCommandSender), //
+ mRoutingSender(iRoutingSender), //
+ mTelnetServer(iTelnetServer)
{
- assert(mCommandSender!=0);
- assert(mRoutingSender!=0);
- assert(mTelnetServer!=0);
+ assert(mCommandSender!=0);
+ assert(mRoutingSender!=0);
+ assert(mTelnetServer!=0);
}
-DatabaseObserver::~DatabaseObserver() {
- // TODO Auto-generated destructor stub
+DatabaseObserver::~DatabaseObserver()
+{
+ // TODO Auto-generated destructor stub
}
void DatabaseObserver::newSink(am_Sink_s sink)
{
- mRoutingSender->addSinkLookup(sink);
- mCommandSender->cbNumberOfSinksChanged();
+ mRoutingSender->addSinkLookup(sink);
+ mCommandSender->cbNumberOfSinksChanged();
}
-
-
void DatabaseObserver::newSource(am_Source_s source)
{
- mRoutingSender->addSourceLookup(source);
- mCommandSender->cbNumberOfSourcesChanged();
+ mRoutingSender->addSourceLookup(source);
+ mCommandSender->cbNumberOfSourcesChanged();
}
-
-
void DatabaseObserver::newDomain(am_Domain_s domain)
{
- mRoutingSender->addDomainLookup(domain);
+ mRoutingSender->addDomainLookup(domain);
}
-
-
void DatabaseObserver::newGateway(am_Gateway_s gateway)
{
- //todo: implement something
+ //todo: implement something
}
-
-
void DatabaseObserver::newCrossfader(am_Crossfader_s crossfader)
{
- mRoutingSender->addCrossfaderLookup(crossfader);
+ mRoutingSender->addCrossfaderLookup(crossfader);
}
-
-
void DatabaseObserver::removedSink(am_sinkID_t sinkID)
{
- mRoutingSender->removeSinkLookup(sinkID);
- mCommandSender->cbNumberOfSinksChanged();
+ mRoutingSender->removeSinkLookup(sinkID);
+ mCommandSender->cbNumberOfSinksChanged();
}
-
-
void DatabaseObserver::removedSource(am_sourceID_t sourceID)
{
- mRoutingSender->removeSourceLookup(sourceID);
- mCommandSender->cbNumberOfSourcesChanged();
+ mRoutingSender->removeSourceLookup(sourceID);
+ mCommandSender->cbNumberOfSourcesChanged();
}
-
-
void DatabaseObserver::removeDomain(am_domainID_t domainID)
{
- mRoutingSender->removeDomainLookup(domainID);
+ mRoutingSender->removeDomainLookup(domainID);
}
-
-
void DatabaseObserver::removeGateway(am_gatewayID_t gatewayID)
{
- //todo: implement something
+ //todo: implement something
}
-
-
void DatabaseObserver::removeCrossfader(am_crossfaderID_t crossfaderID)
{
- mRoutingSender->removeCrossfaderLookup(crossfaderID);
+ mRoutingSender->removeCrossfaderLookup(crossfaderID);
}
-
void DatabaseObserver::numberOfMainConnectionsChanged()
{
- mCommandSender->cbNumberOfMainConnectionsChanged();
+ mCommandSender->cbNumberOfMainConnectionsChanged();
}
void DatabaseObserver::numberOfSinkClassesChanged()
{
- mCommandSender->cbNumberOfSinkClassesChanged();
+ mCommandSender->cbNumberOfSinkClassesChanged();
}
-
-
void DatabaseObserver::numberOfSourceClassesChanged()
{
- mCommandSender->cbNumberOfSourceClassesChanged();
+ mCommandSender->cbNumberOfSourceClassesChanged();
}
-
-
void DatabaseObserver::mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
{
- mCommandSender->cbMainConnectionStateChanged(connectionID,connectionState);
+ mCommandSender->cbMainConnectionStateChanged(connectionID, connectionState);
}
-
-
void DatabaseObserver::mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s SoundProperty)
{
- mCommandSender->cbMainSinkSoundPropertyChanged(sinkID,SoundProperty);
+ mCommandSender->cbMainSinkSoundPropertyChanged(sinkID, SoundProperty);
}
-
-
void DatabaseObserver::mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s & SoundProperty)
{
- mCommandSender->cbMainSourceSoundPropertyChanged(sourceID,SoundProperty);
+ mCommandSender->cbMainSourceSoundPropertyChanged(sourceID, SoundProperty);
}
-
-
void DatabaseObserver::sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s & availability)
{
- mCommandSender->cbSinkAvailabilityChanged(sinkID,availability);
+ mCommandSender->cbSinkAvailabilityChanged(sinkID, availability);
}
-
-
void DatabaseObserver::sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s & availability)
{
- mCommandSender->cbSourceAvailabilityChanged(sourceID,availability);
+ mCommandSender->cbSourceAvailabilityChanged(sourceID, availability);
}
-
-
void DatabaseObserver::volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
{
- mCommandSender->cbVolumeChanged(sinkID,volume);
+ mCommandSender->cbVolumeChanged(sinkID, volume);
}
-
-
void DatabaseObserver::sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
{
- mCommandSender->cbSinkMuteStateChanged(sinkID,muteState);
+ mCommandSender->cbSinkMuteStateChanged(sinkID, muteState);
}
-
-
void DatabaseObserver::systemPropertyChanged(const am_SystemProperty_s & SystemProperty)
{
- mCommandSender->cbSystemPropertyChanged(SystemProperty);
+ mCommandSender->cbSystemPropertyChanged(SystemProperty);
}
-
-
void DatabaseObserver::timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time)
{
- mCommandSender->cbTimingInformationChanged(mainConnection,time);
- //todo:inform the controller via controlsender
+ mCommandSender->cbTimingInformationChanged(mainConnection, time);
+ //todo:inform the controller via controlsender
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/AudioManagerDaemon/src/RoutingReceiver.cpp b/AudioManagerDaemon/src/RoutingReceiver.cpp
index 93fd925..9a7263d 100644
--- a/AudioManagerDaemon/src/RoutingReceiver.cpp
+++ b/AudioManagerDaemon/src/RoutingReceiver.cpp
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file RoutingReceiver.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section LicenseRoutingReceiver.h
-*
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file RoutingReceiver.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section LicenseRoutingReceiver.h
+ *
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#include "RoutingReceiver.h"
#include <SocketHandler.h>
@@ -35,388 +35,322 @@
using namespace am;
-am::RoutingReceiver::RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, SocketHandler *iSocketHandler)
- :mDatabaseHandler(iDatabaseHandler),
- mRoutingSender(iRoutingSender),
- mControlSender(iControlSender),
- mSocketHandler(iSocketHandler)
+am::RoutingReceiver::RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, SocketHandler *iSocketHandler) :
+ mDatabaseHandler(iDatabaseHandler), //
+ mRoutingSender(iRoutingSender), //
+ mControlSender(iControlSender), //
+ mSocketHandler(iSocketHandler) //
{
-assert(mDatabaseHandler!=NULL);
-assert(mRoutingSender!=NULL);
-assert(mControlSender!=NULL);
-assert(mSocketHandler!=NULL);
+ assert(mDatabaseHandler!=NULL);
+ assert(mRoutingSender!=NULL);
+ assert(mControlSender!=NULL);
+ assert(mSocketHandler!=NULL);
}
-am::RoutingReceiver::RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, DBusWrapper *iDBusWrapper)
- :mDatabaseHandler(iDatabaseHandler),
- mRoutingSender(iRoutingSender),
- mControlSender(iControlSender),
- mDBusWrapper(iDBusWrapper)
+am::RoutingReceiver::RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, DBusWrapper *iDBusWrapper) :
+ mDatabaseHandler(iDatabaseHandler), //
+ mRoutingSender(iRoutingSender), //
+ mControlSender(iControlSender), //
+ mDBusWrapper(iDBusWrapper) //
{
-assert(mDatabaseHandler!=NULL);
-assert(mRoutingSender!=NULL);
-assert(mControlSender!=NULL);
-assert(mDBusWrapper!=NULL);
+ assert(mDatabaseHandler!=NULL);
+ assert(mRoutingSender!=NULL);
+ assert(mControlSender!=NULL);
+ assert(mDBusWrapper!=NULL);
}
-am::RoutingReceiver::RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, SocketHandler *iSocketHandler, DBusWrapper *iDBusWrapper)
- :mDatabaseHandler(iDatabaseHandler),
- mRoutingSender(iRoutingSender),
- mControlSender(iControlSender),
- mSocketHandler(iSocketHandler),
- mDBusWrapper(iDBusWrapper)
+am::RoutingReceiver::RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender, SocketHandler *iSocketHandler, DBusWrapper *iDBusWrapper) :
+ mDatabaseHandler(iDatabaseHandler), //
+ mRoutingSender(iRoutingSender), //
+ mControlSender(iControlSender), //
+ mSocketHandler(iSocketHandler), //
+ mDBusWrapper(iDBusWrapper) //
{
-assert(mDatabaseHandler!=NULL);
-assert(mRoutingSender!=NULL);
-assert(mControlSender!=NULL);
-assert(mSocketHandler!=NULL);
-assert(mDBusWrapper!=NULL);
+ assert(mDatabaseHandler!=NULL);
+ assert(mRoutingSender!=NULL);
+ assert(mControlSender!=NULL);
+ assert(mSocketHandler!=NULL);
+ assert(mDBusWrapper!=NULL);
}
-
-
RoutingReceiver::~RoutingReceiver()
{
}
-
-
void RoutingReceiver::ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
{
- mRoutingSender->removeHandle(handle);
- if (error==E_OK)
- {
- mDatabaseHandler->changeConnectionFinal(connectionID);
- }
- else
- {
- mDatabaseHandler->removeConnection(connectionID);
- }
- mControlSender->cbAckConnect(handle,error);
+ mRoutingSender->removeHandle(handle);
+ if (error == E_OK)
+ {
+ mDatabaseHandler->changeConnectionFinal(connectionID);
+ }
+ else
+ {
+ mDatabaseHandler->removeConnection(connectionID);
+ }
+ mControlSender->cbAckConnect(handle, error);
}
-
-
void RoutingReceiver::ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
{
- mRoutingSender->removeHandle(handle);
- if (error==E_OK)
- {
- mDatabaseHandler->removeConnection(connectionID);
- }
- mControlSender->cbAckDisconnect(handle,error);
+ mRoutingSender->removeHandle(handle);
+ if (error == E_OK)
+ {
+ mDatabaseHandler->removeConnection(connectionID);
+ }
+ mControlSender->cbAckDisconnect(handle, error);
}
-
-
void RoutingReceiver::ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
{
- RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
- if(error==E_OK && handleData.sinkID!=0)
- {
- //todo: check if volume in handleData is same than volume. React to it.
- mDatabaseHandler->changeSinkVolume(handleData.sinkID,volume);
- }
- mRoutingSender->removeHandle(handle);
- mControlSender->cbAckSetSinkVolumeChange(handle,volume,error);
+ RoutingSender::am_handleData_c handleData = mRoutingSender->returnHandleData(handle);
+ if (error == E_OK && handleData.sinkID != 0)
+ {
+ //todo: check if volume in handleData is same than volume. React to it.
+ mDatabaseHandler->changeSinkVolume(handleData.sinkID, volume);
+ }
+ mRoutingSender->removeHandle(handle);
+ mControlSender->cbAckSetSinkVolumeChange(handle, volume, error);
}
-
-
void RoutingReceiver::ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
{
- RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
- if(error==E_OK && handleData.sourceID!=0)
- {
- //todo: check if volume in handleData is same than volume. React to it.
- mDatabaseHandler->changeSourceVolume(handleData.sourceID,volume);
- }
- mRoutingSender->removeHandle(handle);
- mControlSender->cbAckSetSourceVolumeChange(handle,volume,error);
+ RoutingSender::am_handleData_c handleData = mRoutingSender->returnHandleData(handle);
+ if (error == E_OK && handleData.sourceID != 0)
+ {
+ //todo: check if volume in handleData is same than volume. React to it.
+ mDatabaseHandler->changeSourceVolume(handleData.sourceID, volume);
+ }
+ mRoutingSender->removeHandle(handle);
+ mControlSender->cbAckSetSourceVolumeChange(handle, volume, error);
}
-
-
void RoutingReceiver::ackSetSourceState(const am_Handle_s handle, const am_Error_e error)
{
- RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
- if(error==E_OK && handleData.sourceID!=0)
- {
- //todo: check if volume in handleData is same than volume. React to it.
- mDatabaseHandler->changeSourceState(handleData.sourceID,handleData.sourceState);
- }
- mRoutingSender->removeHandle(handle);
- mControlSender->cbAckSetSourceState(handle,error);
+ RoutingSender::am_handleData_c handleData = mRoutingSender->returnHandleData(handle);
+ if (error == E_OK && handleData.sourceID != 0)
+ {
+ //todo: check if volume in handleData is same than volume. React to it.
+ mDatabaseHandler->changeSourceState(handleData.sourceID, handleData.sourceState);
+ }
+ mRoutingSender->removeHandle(handle);
+ mControlSender->cbAckSetSourceState(handle, error);
}
-
-
void RoutingReceiver::ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
{
- RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
- if(error==E_OK && handleData.sinkID!=0)
- {
- mDatabaseHandler->changeSinkSoundPropertyDB(handleData.soundPropery,handleData.sinkID);
- }
- mRoutingSender->removeHandle(handle);
- mControlSender->cbAckSetSinkSoundProperty(handle,error);
+ RoutingSender::am_handleData_c handleData = mRoutingSender->returnHandleData(handle);
+ if (error == E_OK && handleData.sinkID != 0)
+ {
+ mDatabaseHandler->changeSinkSoundPropertyDB(handleData.soundPropery, handleData.sinkID);
+ }
+ mRoutingSender->removeHandle(handle);
+ mControlSender->cbAckSetSinkSoundProperty(handle, error);
}
void am::RoutingReceiver::ackSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error)
{
- RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
- if(error==E_OK && handleData.sinkID!=0)
- {
- std::vector<am_SoundProperty_s>::const_iterator it=handleData.soundProperties->begin();
- for(;it!=handleData.soundProperties->end();++it)
- {
- mDatabaseHandler->changeSinkSoundPropertyDB(*it,handleData.sinkID);
- }
- delete handleData.soundProperties;
- }
- mRoutingSender->removeHandle(handle);
- mControlSender->cbAckSetSinkSoundProperties(handle,error);
+ RoutingSender::am_handleData_c handleData = mRoutingSender->returnHandleData(handle);
+ if (error == E_OK && handleData.sinkID != 0)
+ {
+ std::vector<am_SoundProperty_s>::const_iterator it = handleData.soundProperties->begin();
+ for (; it != handleData.soundProperties->end(); ++it)
+ {
+ mDatabaseHandler->changeSinkSoundPropertyDB(*it, handleData.sinkID);
+ }
+ delete handleData.soundProperties;
+ }
+ mRoutingSender->removeHandle(handle);
+ mControlSender->cbAckSetSinkSoundProperties(handle, error);
}
-
void RoutingReceiver::ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
{
- RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
- if(error==E_OK && handleData.sourceID!=0)
- {
- mDatabaseHandler->changeSourceSoundPropertyDB(handleData.soundPropery,handleData.sourceID);
- }
- mRoutingSender->removeHandle(handle);
- mControlSender->cbAckSetSourceSoundProperty(handle,error);
+ RoutingSender::am_handleData_c handleData = mRoutingSender->returnHandleData(handle);
+ if (error == E_OK && handleData.sourceID != 0)
+ {
+ mDatabaseHandler->changeSourceSoundPropertyDB(handleData.soundPropery, handleData.sourceID);
+ }
+ mRoutingSender->removeHandle(handle);
+ mControlSender->cbAckSetSourceSoundProperty(handle, error);
}
-
void am::RoutingReceiver::ackSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error)
{
- RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
- if(error==E_OK && handleData.sourceID!=0)
- {
- std::vector<am_SoundProperty_s>::const_iterator it=handleData.soundProperties->begin();
- for(;it!=handleData.soundProperties->end();++it)
- {
- mDatabaseHandler->changeSourceSoundPropertyDB(*it,handleData.sourceID);
- }
- delete handleData.soundProperties;
- }
- mRoutingSender->removeHandle(handle);
- mControlSender->cbAckSetSourceSoundProperties(handle,error);
+ RoutingSender::am_handleData_c handleData = mRoutingSender->returnHandleData(handle);
+ if (error == E_OK && handleData.sourceID != 0)
+ {
+ std::vector<am_SoundProperty_s>::const_iterator it = handleData.soundProperties->begin();
+ for (; it != handleData.soundProperties->end(); ++it)
+ {
+ mDatabaseHandler->changeSourceSoundPropertyDB(*it, handleData.sourceID);
+ }
+ delete handleData.soundProperties;
+ }
+ mRoutingSender->removeHandle(handle);
+ mControlSender->cbAckSetSourceSoundProperties(handle, error);
}
void RoutingReceiver::ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error)
{
- RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle);
- if(error==E_OK && handleData.crossfaderID!=0)
- {
- //todo: check if volume in handleData is same than volume. React to it.
- mDatabaseHandler->changeCrossFaderHotSink(handleData.crossfaderID,hotSink);
- }
- mRoutingSender->removeHandle(handle);
- mControlSender->cbAckCrossFade(handle,hotSink,error);
+ RoutingSender::am_handleData_c handleData = mRoutingSender->returnHandleData(handle);
+ if (error == E_OK && handleData.crossfaderID != 0)
+ {
+ //todo: check if volume in handleData is same than volume. React to it.
+ mDatabaseHandler->changeCrossFaderHotSink(handleData.crossfaderID, hotSink);
+ }
+ mRoutingSender->removeHandle(handle);
+ mControlSender->cbAckCrossFade(handle, hotSink, error);
}
-
-
void RoutingReceiver::ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
{
- mControlSender->hookSystemSourceVolumeTick(handle,sourceID,volume);
+ mControlSender->hookSystemSourceVolumeTick(handle, sourceID, volume);
}
-
-
void RoutingReceiver::ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
{
- mControlSender->hookSystemSinkVolumeTick(handle,sinkID,volume);
+ mControlSender->hookSystemSinkVolumeTick(handle, sinkID, volume);
}
-
-
am_Error_e RoutingReceiver::peekDomain(const std::string & name, am_domainID_t & domainID)
{
- return mDatabaseHandler->peekDomain(name,domainID);
+ return mDatabaseHandler->peekDomain(name, domainID);
}
-
am_Error_e RoutingReceiver::registerDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
{
- return mControlSender->hookSystemRegisterDomain(domainData,domainID);
+ return mControlSender->hookSystemRegisterDomain(domainData, domainID);
}
-
-
am_Error_e RoutingReceiver::deregisterDomain(const am_domainID_t domainID)
{
- return mControlSender->hookSystemDeregisterDomain(domainID);
+ return mControlSender->hookSystemDeregisterDomain(domainID);
}
-
-
am_Error_e RoutingReceiver::registerGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
{
- return mControlSender->hookSystemRegisterGateway(gatewayData,gatewayID);
+ return mControlSender->hookSystemRegisterGateway(gatewayData, gatewayID);
}
-
-
am_Error_e RoutingReceiver::deregisterGateway(const am_gatewayID_t gatewayID)
{
- return mControlSender->hookSystemDeregisterGateway(gatewayID);
+ return mControlSender->hookSystemDeregisterGateway(gatewayID);
}
-
-
am_Error_e RoutingReceiver::peekSink(const std::string& name, am_sinkID_t & sinkID)
{
- return mDatabaseHandler->peekSink(name,sinkID);
+ return mDatabaseHandler->peekSink(name, sinkID);
}
-
-
am_Error_e RoutingReceiver::registerSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
{
- return mControlSender->hookSystemRegisterSink(sinkData,sinkID);
+ return mControlSender->hookSystemRegisterSink(sinkData, sinkID);
}
-
-
am_Error_e RoutingReceiver::deregisterSink(const am_sinkID_t sinkID)
{
- return mControlSender->hookSystemDeregisterSink(sinkID);
+ return mControlSender->hookSystemDeregisterSink(sinkID);
}
-
-
am_Error_e RoutingReceiver::peekSource(const std::string & name, am_sourceID_t & sourceID)
{
- return mDatabaseHandler->peekSource(name,sourceID);
+ return mDatabaseHandler->peekSource(name, sourceID);
}
-
-
am_Error_e RoutingReceiver::registerSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
{
- return mControlSender->hookSystemRegisterSource(sourceData,sourceID);
+ return mControlSender->hookSystemRegisterSource(sourceData, sourceID);
}
-
-
am_Error_e RoutingReceiver::deregisterSource(const am_sourceID_t sourceID)
{
- return mControlSender->hookSystemDeregisterSource(sourceID);
+ return mControlSender->hookSystemDeregisterSource(sourceID);
}
-
-
am_Error_e RoutingReceiver::registerCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
{
- return mControlSender->hookSystemRegisterCrossfader(crossfaderData,crossfaderID);
+ return mControlSender->hookSystemRegisterCrossfader(crossfaderData, crossfaderID);
}
-
-
am_Error_e RoutingReceiver::deregisterCrossfader(const am_crossfaderID_t crossfaderID)
{
- return mControlSender->hookSystemDeregisterCrossfader(crossfaderID);
+ return mControlSender->hookSystemDeregisterCrossfader(crossfaderID);
}
-
-
void RoutingReceiver::hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
{
- return mControlSender->hookSystemInterruptStateChange(sourceID,interruptState);
+ return mControlSender->hookSystemInterruptStateChange(sourceID, interruptState);
}
-
-
void RoutingReceiver::hookDomainRegistrationComplete(const am_domainID_t domainID)
{
- mControlSender->hookSystemDomainRegistrationComplete(domainID);
+ mControlSender->hookSystemDomainRegistrationComplete(domainID);
}
-
-
void RoutingReceiver::hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
{
- mControlSender->hookSystemSinkAvailablityStateChange(sinkID,availability);
+ mControlSender->hookSystemSinkAvailablityStateChange(sinkID, availability);
}
-
-
void RoutingReceiver::hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
{
- mControlSender->hookSystemSourceAvailablityStateChange(sourceID,availability);
+ mControlSender->hookSystemSourceAvailablityStateChange(sourceID, availability);
}
-
-
void RoutingReceiver::hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState)
{
- mControlSender->hookSystemDomainStateChange(domainID,domainState);
+ mControlSender->hookSystemDomainStateChange(domainID, domainState);
}
-
-
void RoutingReceiver::hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay)
{
- mDatabaseHandler->changeConnectionTimingInformation(connectionID,delay);
+ mDatabaseHandler->changeConnectionTimingInformation(connectionID, delay);
}
-
-
am_Error_e RoutingReceiver::sendChangedData(const std::vector<am_EarlyData_s> & earlyData)
{
- mControlSender->hookSystemReceiveEarlyData(earlyData);
- return E_OK;
- //todo: change return type to void in EA model
+ mControlSender->hookSystemReceiveEarlyData(earlyData);
+ return E_OK;
+//todo: change return type to void in EA model
}
-
-
am_Error_e RoutingReceiver::peekSinkClassID(const std::string name, const am_sinkClass_t& sinkClassID)
{
- //todo: implement
- return E_NOT_USED;
+//todo: implement
+ return E_NOT_USED;
}
am_Error_e RoutingReceiver::peekSourceClassID(const std::string name, const am_sourceClass_t& sourceClassID)
{
- //todo: implement
- return E_NOT_USED;
+//todo: implement
+ return E_NOT_USED;
}
am_Error_e RoutingReceiver::getDBusConnectionWrapper(DBusWrapper *& dbusConnectionWrapper) const
{
#ifdef WITH_DBUS_WRAPPER
- dbusConnectionWrapper=mDBusWrapper;
- return E_OK;
+ dbusConnectionWrapper = mDBusWrapper;
+ return E_OK;
#else
- return E_UNKNOWN;
+ return E_UNKNOWN;
#endif
}
-
am_Error_e RoutingReceiver::getSocketHandler(SocketHandler *& socketHandler) const
{
#ifdef WITH_SOCKETHANDLER_LOOP
- socketHandler=mSocketHandler;
- return E_OK;
+ socketHandler = mSocketHandler;
+ return E_OK;
#else
- return E_UNKNOWN;
+ return E_UNKNOWN;
#endif
}
uint16_t RoutingReceiver::getInterfaceVersion() const
{
- return RoutingReceiveVersion;
+ return RoutingReceiveVersion;
}
-
-
-
-
diff --git a/AudioManagerDaemon/src/RoutingSender.cpp b/AudioManagerDaemon/src/RoutingSender.cpp
index 46263ec..acdb32f 100644
--- a/AudioManagerDaemon/src/RoutingSender.cpp
+++ b/AudioManagerDaemon/src/RoutingSender.cpp
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file RoutingSender.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file RoutingSender.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#include "RoutingSender.h"
#include <utility>
@@ -37,63 +37,62 @@ using namespace am;
#define CALL_ALL_INTERFACES(...) \
std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin(); \
std::vector<InterfaceNamePairs>::iterator iterEnd = mListInterfaces.end(); \
- for (; iter<iterEnd;++iter) \
+ for (; iter<iterEnd;++iter) \
{ \
(*iter).routingInterface->__VA_ARGS__; \
}
-RoutingSender::RoutingSender(const std::vector<std::string>& listOfPluginDirectories)
-
- :mHandleCount(0),
- mlistActiveHandles(),
- mListInterfaces(),
- mMapConnectionInterface(),
- mMapCrossfaderInterface(),
- mMapDomainInterface(),
- mMapSinkInterface(),
- mMapSourceInterface(),
- mMapHandleInterface()
-{
- std::vector<std::string> sharedLibraryNameList;
+RoutingSender::RoutingSender(const std::vector<std::string>& listOfPluginDirectories) :
+ mHandleCount(0), //
+ mlistActiveHandles(), //
+ mListInterfaces(), //
+ mMapConnectionInterface(), //
+ mMapCrossfaderInterface(), //
+ mMapDomainInterface(), //
+ mMapSinkInterface(), //
+ mMapSourceInterface(), //
+ mMapHandleInterface() //
+{
+ std::vector<std::string> sharedLibraryNameList;
std::vector<std::string>::const_iterator dirIter = listOfPluginDirectories.begin();
std::vector<std::string>::const_iterator dirIterEnd = listOfPluginDirectories.end();
// search communicator plugins in configured directories
for (; dirIter < dirIterEnd; ++dirIter)
{
- const char* directoryName = dirIter->c_str();
- //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Searching for HookPlugins in"),DLT_STRING(directoryName));
- DIR *directory = opendir(directoryName);
-
- if (!directory)
- {
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("RoutingSender::RoutingSender Error opening directory "),DLT_STRING(directoryName));
- continue;
- }
+ const char* directoryName = dirIter->c_str();
+ //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Searching for HookPlugins in"),DLT_STRING(directoryName));
+ DIR *directory = opendir(directoryName);
+
+ if (!directory)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("RoutingSender::RoutingSender Error opening directory "), DLT_STRING(directoryName));
+ continue;
+ }
// iterate content of directory
struct dirent *itemInDirectory = 0;
while ((itemInDirectory = readdir(directory)))
{
- unsigned char entryType = itemInDirectory->d_type;
- std::string entryName = itemInDirectory->d_name;
-
- bool regularFile = (entryType == DT_REG || entryType == DT_LNK);
- bool sharedLibExtension = ("so" == entryName.substr(entryName.find_last_of(".") + 1));
-
- if (regularFile && sharedLibExtension)
- {
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingSender::RoutingSender adding file "),DLT_STRING(entryName.c_str()));
- std::string name(directoryName);
- sharedLibraryNameList.push_back(name + "/" + entryName);
- }
- else
- {
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingSender::RoutingSender PluginSearch ignoring file "),DLT_STRING(entryName.c_str()));
- }
+ unsigned char entryType = itemInDirectory->d_type;
+ std::string entryName = itemInDirectory->d_name;
+
+ bool regularFile = (entryType == DT_REG || entryType == DT_LNK);
+ bool sharedLibExtension = ("so" == entryName.substr(entryName.find_last_of(".") + 1));
+
+ if (regularFile && sharedLibExtension)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("RoutingSender::RoutingSender adding file "), DLT_STRING(entryName.c_str()));
+ std::string name(directoryName);
+ sharedLibraryNameList.push_back(name + "/" + entryName);
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("RoutingSender::RoutingSender PluginSearch ignoring file "), DLT_STRING(entryName.c_str()));
+ }
}
- closedir(directory);
+ closedir(directory);
}
// iterate all communicator plugins and start them
@@ -102,15 +101,15 @@ RoutingSender::RoutingSender(const std::vector<std::string>& listOfPluginDirecto
for (; iter != iterEnd; ++iter)
{
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingSender::RoutingSender try loading "),DLT_STRING(iter->c_str()));
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("RoutingSender::RoutingSender try loading "), DLT_STRING(iter->c_str()));
- RoutingSendInterface* (*createFunc)();
- void* tempLibHandle=NULL;
- createFunc = getCreateFunction<RoutingSendInterface*()>(*iter,tempLibHandle);
+ RoutingSendInterface* (*createFunc)();
+ void* tempLibHandle = NULL;
+ createFunc = getCreateFunction<RoutingSendInterface*()>(*iter, tempLibHandle);
if (!createFunc)
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("RoutingSender::RoutingSender Entry point of RoutingPlugin not found"));
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("RoutingSender::RoutingSender Entry point of RoutingPlugin not found"));
continue;
}
@@ -118,7 +117,7 @@ RoutingSender::RoutingSender(const std::vector<std::string>& listOfPluginDirecto
if (!router)
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("RoutingSender::RoutingSender RoutingPlugin initialization failed. Entry Function not callable"));
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("RoutingSender::RoutingSender RoutingPlugin initialization failed. Entry Function not callable"));
continue;
}
@@ -126,13 +125,12 @@ RoutingSender::RoutingSender(const std::vector<std::string>& listOfPluginDirecto
routerInterface.routingInterface = router;
//check libversion
- if (router->getInterfaceVersion()<REQUIRED_INTERFACE_VERSION)
+ if (router->getInterfaceVersion() < REQUIRED_INTERFACE_VERSION)
{
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("RoutingSender::RoutingSender RoutingPlugin initialization failed. Version of Interface to old"));
- continue;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("RoutingSender::RoutingSender RoutingPlugin initialization failed. Version of Interface to old"));
+ continue;
}
-
//here, the busname is saved together with the interface. Later The domains will register with the name and sinks, sources etc with the domain....
router->returnBusName(routerInterface.busName);
assert(!routerInterface.busName.empty());
@@ -143,275 +141,253 @@ RoutingSender::RoutingSender(const std::vector<std::string>& listOfPluginDirecto
RoutingSender::~RoutingSender()
{
- unloadLibraries();
- HandlesMap::iterator it=mlistActiveHandles.begin();
+ unloadLibraries();
+ HandlesMap::iterator it = mlistActiveHandles.begin();
- //clean up heap if existent
- for(;it!=mlistActiveHandles.end();++it)
- {
- if (it->first.handleType==H_SETSINKSOUNDPROPERTIES || it->first.handleType==H_SETSOURCESOUNDPROPERTIES)
- {
- delete it->second.soundProperties;
- }
- }
+ //clean up heap if existent
+ for (; it != mlistActiveHandles.end(); ++it)
+ {
+ if (it->first.handleType == H_SETSINKSOUNDPROPERTIES || it->first.handleType == H_SETSOURCESOUNDPROPERTIES)
+ {
+ delete it->second.soundProperties;
+ }
+ }
}
void RoutingSender::routingInterfacesReady()
{
- CALL_ALL_INTERFACES(routingInterfacesReady())
+ CALL_ALL_INTERFACES(routingInterfacesReady())
}
void RoutingSender::routingInterfacesRundown()
{
- CALL_ALL_INTERFACES(routingInterfacesRundown())
+ CALL_ALL_INTERFACES(routingInterfacesRundown())
}
void RoutingSender::startupRoutingInterface(RoutingReceiveInterface *routingreceiveinterface)
{
- CALL_ALL_INTERFACES(startupRoutingInterface(routingreceiveinterface))
+ CALL_ALL_INTERFACES(startupRoutingInterface(routingreceiveinterface))
}
am_Error_e RoutingSender::asyncAbort(const am_Handle_s& handle)
{
- HandleInterfaceMap::iterator iter = mMapHandleInterface.begin();
- iter=mMapHandleInterface.find(handle.handle);
+ HandleInterfaceMap::iterator iter = mMapHandleInterface.begin();
+ iter = mMapHandleInterface.find(handle.handle);
if (iter != mMapHandleInterface.end())
{
- return iter->second->asyncAbort(handle);
+ return iter->second->asyncAbort(handle);
}
return E_NON_EXISTENT;
}
-
-
am_Error_e RoutingSender::asyncConnect(am_Handle_s& handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat)
{
- am_handleData_c handleData;
- SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
- iter=mMapSinkInterface.find(sinkID);
+ am_handleData_c handleData;
+ SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
+ iter = mMapSinkInterface.find(sinkID);
if (iter != mMapSinkInterface.end())
{
- handleData.connectionID=connectionID;
- handle=createHandle(handleData,H_CONNECT);
- mMapConnectionInterface.insert(std::make_pair(connectionID,iter->second));
- mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
- return iter->second->asyncConnect(handle,connectionID,sourceID,sinkID,connectionFormat);
+ handleData.connectionID = connectionID;
+ handle = createHandle(handleData, H_CONNECT);
+ mMapConnectionInterface.insert(std::make_pair(connectionID, iter->second));
+ mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
+ return iter->second->asyncConnect(handle, connectionID, sourceID, sinkID, connectionFormat);
}
return E_NON_EXISTENT;
}
-
-
am_Error_e RoutingSender::asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID)
{
- am_handleData_c handleData;
- ConnectionInterfaceMap::iterator iter = mMapConnectionInterface.begin();
- mMapConnectionInterface.find(connectionID);
+ am_handleData_c handleData;
+ ConnectionInterfaceMap::iterator iter = mMapConnectionInterface.begin();
+ mMapConnectionInterface.find(connectionID);
if (iter != mMapConnectionInterface.end())
{
- handleData.connectionID=connectionID;
- handle=createHandle(handleData,H_DISCONNECT);
- mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
- am_Error_e returnVal=iter->second->asyncDisconnect(handle,connectionID);
- mMapConnectionInterface.erase(iter);
- return returnVal;
+ handleData.connectionID = connectionID;
+ handle = createHandle(handleData, H_DISCONNECT);
+ mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
+ am_Error_e returnVal = iter->second->asyncDisconnect(handle, connectionID);
+ mMapConnectionInterface.erase(iter);
+ return returnVal;
}
return E_NON_EXISTENT;
}
-
-
am_Error_e RoutingSender::asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)
{
- am_handleData_c handleData;
- SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
- iter=mMapSinkInterface.find(sinkID);
+ am_handleData_c handleData;
+ SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
+ iter = mMapSinkInterface.find(sinkID);
if (iter != mMapSinkInterface.end())
- handleData.sinkID=sinkID;
- handleData.volume=volume;
- handle=createHandle(handleData,H_SETSINKVOLUME);
- mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
- return iter->second->asyncSetSinkVolume(handle,sinkID,volume,ramp,time);
+ handleData.sinkID = sinkID;
+ handleData.volume = volume;
+ handle = createHandle(handleData, H_SETSINKVOLUME);
+ mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
+ return iter->second->asyncSetSinkVolume(handle, sinkID, volume, ramp, time);
return E_NON_EXISTENT;
}
-
-
am_Error_e RoutingSender::asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)
{
- am_handleData_c handleData;
- SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
- iter=mMapSourceInterface.find(sourceID);
+ am_handleData_c handleData;
+ SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
+ iter = mMapSourceInterface.find(sourceID);
if (iter != mMapSourceInterface.end())
- handleData.sourceID=sourceID;
- handleData.volume=volume;
- handle=createHandle(handleData,H_SETSOURCEVOLUME);
- mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
- return iter->second->asyncSetSourceVolume(handle,sourceID,volume,ramp,time);
+ handleData.sourceID = sourceID;
+ handleData.volume = volume;
+ handle = createHandle(handleData, H_SETSOURCEVOLUME);
+ mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
+ return iter->second->asyncSetSourceVolume(handle, sourceID, volume, ramp, time);
return E_NON_EXISTENT;
}
-
-
am_Error_e RoutingSender::asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state)
{
- am_handleData_c handleData;
- SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
- iter=mMapSourceInterface.find(sourceID);
+ am_handleData_c handleData;
+ SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
+ iter = mMapSourceInterface.find(sourceID);
if (iter != mMapSourceInterface.end())
- handleData.sourceID=sourceID;
- handleData.sourceState=state;
- handle=createHandle(handleData,H_SETSOURCESTATE);
- mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
- return iter->second->asyncSetSourceState(handle,sourceID,state);
+ handleData.sourceID = sourceID;
+ handleData.sourceState = state;
+ handle = createHandle(handleData, H_SETSOURCESTATE);
+ mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
+ return iter->second->asyncSetSourceState(handle, sourceID, state);
return E_NON_EXISTENT;
}
-
-
am_Error_e RoutingSender::asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s & soundProperty)
{
- am_handleData_c handleData;
- SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
- iter=mMapSinkInterface.find(sinkID);
+ am_handleData_c handleData;
+ SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
+ iter = mMapSinkInterface.find(sinkID);
if (iter != mMapSinkInterface.end())
- handleData.sinkID=sinkID;
- handleData.soundPropery=soundProperty;
- handle=createHandle(handleData,H_SETSINKSOUNDPROPERTY);
- mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
- return iter->second->asyncSetSinkSoundProperty(handle,soundProperty,sinkID);
+ handleData.sinkID = sinkID;
+ handleData.soundPropery = soundProperty;
+ handle = createHandle(handleData, H_SETSINKSOUNDPROPERTY);
+ mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
+ return iter->second->asyncSetSinkSoundProperty(handle, soundProperty, sinkID);
return (E_NON_EXISTENT);
}
-
am_Error_e RoutingSender::asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty)
{
- am_handleData_c handleData;
- SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
- iter=mMapSourceInterface.find(sourceID);
+ am_handleData_c handleData;
+ SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
+ iter = mMapSourceInterface.find(sourceID);
if (iter != mMapSourceInterface.end())
- handleData.sourceID=sourceID;
- handleData.soundPropery=soundProperty;
- handle=createHandle(handleData,H_SETSOURCESOUNDPROPERTY);
- mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
- return iter->second->asyncSetSourceSoundProperty(handle,soundProperty,sourceID);
+ handleData.sourceID = sourceID;
+ handleData.soundPropery = soundProperty;
+ handle = createHandle(handleData, H_SETSOURCESOUNDPROPERTY);
+ mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
+ return iter->second->asyncSetSourceSoundProperty(handle, soundProperty, sourceID);
return (E_NON_EXISTENT);
}
am_Error_e am::RoutingSender::asyncSetSourceSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s> & listSoundProperties, const am_sourceID_t sourceID)
{
- am_handleData_c handleData;
- SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
- iter=mMapSourceInterface.find(sourceID);
+ am_handleData_c handleData;
+ SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
+ iter = mMapSourceInterface.find(sourceID);
if (iter != mMapSourceInterface.end())
- handleData.sourceID=sourceID;
- handleData.soundProperties=new std::vector<am_SoundProperty_s>(listSoundProperties);
- handle=createHandle(handleData,H_SETSOURCESOUNDPROPERTIES);
- mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
- return iter->second->asyncSetSourceSoundProperties(handle,listSoundProperties,sourceID);
+ handleData.sourceID = sourceID;
+ handleData.soundProperties = new std::vector<am_SoundProperty_s>(listSoundProperties);
+ handle = createHandle(handleData, H_SETSOURCESOUNDPROPERTIES);
+ mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
+ return iter->second->asyncSetSourceSoundProperties(handle, listSoundProperties, sourceID);
return (E_NON_EXISTENT);
}
-
am_Error_e am::RoutingSender::asyncSetSinkSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s> & listSoundProperties, const am_sinkID_t sinkID)
{
- am_handleData_c handleData;
- SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
- iter=mMapSinkInterface.find(sinkID);
+ am_handleData_c handleData;
+ SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
+ iter = mMapSinkInterface.find(sinkID);
if (iter != mMapSinkInterface.end())
- handleData.sinkID=sinkID;
- handleData.soundProperties=new std::vector<am_SoundProperty_s>(listSoundProperties);
- handle=createHandle(handleData,H_SETSINKSOUNDPROPERTIES);
- mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
- return iter->second->asyncSetSinkSoundProperties(handle,listSoundProperties,sinkID);
+ handleData.sinkID = sinkID;
+ handleData.soundProperties = new std::vector<am_SoundProperty_s>(listSoundProperties);
+ handle = createHandle(handleData, H_SETSINKSOUNDPROPERTIES);
+ mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
+ return iter->second->asyncSetSinkSoundProperties(handle, listSoundProperties, sinkID);
return (E_NON_EXISTENT);
}
am_Error_e RoutingSender::asyncCrossFade(am_Handle_s& handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time)
{
- am_handleData_c handleData;
- CrossfaderInterfaceMap::iterator iter = mMapCrossfaderInterface.begin();
- iter=mMapCrossfaderInterface.find(crossfaderID);
+ am_handleData_c handleData;
+ CrossfaderInterfaceMap::iterator iter = mMapCrossfaderInterface.begin();
+ iter = mMapCrossfaderInterface.find(crossfaderID);
if (iter != mMapCrossfaderInterface.end())
- handleData.crossfaderID=crossfaderID;
- handleData.hotSink=hotSink;
- handle=createHandle(handleData,H_CROSSFADE);
- mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
- return iter->second->asyncCrossFade(handle,crossfaderID,hotSink,rampType,time);
+ handleData.crossfaderID = crossfaderID;
+ handleData.hotSink = hotSink;
+ handle = createHandle(handleData, H_CROSSFADE);
+ mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
+ return iter->second->asyncCrossFade(handle, crossfaderID, hotSink, rampType, time);
return E_NON_EXISTENT;
}
-
-
am_Error_e RoutingSender::setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState)
{
- DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
- iter=mMapDomainInterface.find(domainID);
+ DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
+ iter = mMapDomainInterface.find(domainID);
if (iter != mMapDomainInterface.end())
- return iter->second->setDomainState(domainID,domainState);
+ return iter->second->setDomainState(domainID, domainState);
return E_NON_EXISTENT;
}
am_Error_e RoutingSender::addDomainLookup(const am_Domain_s& domainData)
{
- std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin();
- std::vector<InterfaceNamePairs>::iterator iterEnd = mListInterfaces.end();
- for (; iter<iterEnd;++iter)
- {
- if((*iter).busName.compare(domainData.busname) == 0)
- {
- mMapDomainInterface.insert(std::make_pair(domainData.domainID,(*iter).routingInterface));
- return E_OK;
- }
- }
+ std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin();
+ std::vector<InterfaceNamePairs>::iterator iterEnd = mListInterfaces.end();
+ for (; iter < iterEnd; ++iter)
+ {
+ if ((*iter).busName.compare(domainData.busname) == 0)
+ {
+ mMapDomainInterface.insert(std::make_pair(domainData.domainID, (*iter).routingInterface));
+ return E_OK;
+ }
+ }
- return E_UNKNOWN;
+ return E_UNKNOWN;
}
-
-
am_Error_e RoutingSender::addSourceLookup(const am_Source_s& sourceData)
{
- DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
- iter=mMapDomainInterface.find(sourceData.domainID);
+ DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
+ iter = mMapDomainInterface.find(sourceData.domainID);
if (iter != mMapDomainInterface.end())
{
- mMapSourceInterface.insert(std::make_pair(sourceData.sourceID,iter->second));
- return E_OK;
+ mMapSourceInterface.insert(std::make_pair(sourceData.sourceID, iter->second));
+ return E_OK;
}
return E_UNKNOWN;
}
-
-
am_Error_e RoutingSender::addSinkLookup(const am_Sink_s& sinkData)
{
- DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
- iter=mMapDomainInterface.find(sinkData.domainID);
+ DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
+ iter = mMapDomainInterface.find(sinkData.domainID);
if (iter != mMapDomainInterface.end())
{
- mMapSinkInterface.insert(std::make_pair(sinkData.sinkID,iter->second));
- return E_OK;
+ mMapSinkInterface.insert(std::make_pair(sinkData.sinkID, iter->second));
+ return E_OK;
}
return E_UNKNOWN;
}
-
-
am_Error_e RoutingSender::addCrossfaderLookup(const am_Crossfader_s& crossfaderData)
{
- DomainInterfaceMap::iterator iter = mMapSourceInterface.begin();
- iter=mMapSourceInterface.find(crossfaderData.sourceID);
+ DomainInterfaceMap::iterator iter = mMapSourceInterface.begin();
+ iter = mMapSourceInterface.find(crossfaderData.sourceID);
if (iter != mMapSourceInterface.end())
{
- mMapSourceInterface.insert(std::make_pair(crossfaderData.crossfaderID,iter->second));
- return E_OK;
+ mMapSourceInterface.insert(std::make_pair(crossfaderData.crossfaderID, iter->second));
+ return E_OK;
}
return E_UNKNOWN;
@@ -419,133 +395,112 @@ am_Error_e RoutingSender::addCrossfaderLookup(const am_Crossfader_s& crossfaderD
am_Error_e RoutingSender::removeDomainLookup(const am_domainID_t domainID)
{
- DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
- iter=mMapDomainInterface.find(domainID);
+ DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
+ iter = mMapDomainInterface.find(domainID);
if (iter != mMapDomainInterface.end())
{
- mMapDomainInterface.erase(iter);
- return E_OK;
+ mMapDomainInterface.erase(iter);
+ return E_OK;
}
return E_NON_EXISTENT;
}
-
-
am_Error_e RoutingSender::removeSourceLookup(const am_sourceID_t sourceID)
{
- SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
- iter=mMapSourceInterface.find(sourceID);
+ SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
+ iter = mMapSourceInterface.find(sourceID);
if (iter != mMapSourceInterface.end())
{
- mMapSourceInterface.erase(iter);
- return E_OK;
+ mMapSourceInterface.erase(iter);
+ return E_OK;
}
return E_NON_EXISTENT;
}
-
-
am_Error_e RoutingSender::removeSinkLookup(const am_sinkID_t sinkID)
{
- SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
- iter=mMapSinkInterface.find(sinkID);
+ SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
+ iter = mMapSinkInterface.find(sinkID);
if (iter != mMapSinkInterface.end())
{
- mMapSinkInterface.erase(iter);
- return E_OK;
+ mMapSinkInterface.erase(iter);
+ return E_OK;
}
return E_NON_EXISTENT;
}
-
-
am_Error_e RoutingSender::removeCrossfaderLookup(const am_crossfaderID_t crossfaderID)
{
- CrossfaderInterfaceMap::iterator iter = mMapCrossfaderInterface.begin();
- iter=mMapCrossfaderInterface.find(crossfaderID);
+ CrossfaderInterfaceMap::iterator iter = mMapCrossfaderInterface.begin();
+ iter = mMapCrossfaderInterface.find(crossfaderID);
if (iter != mMapCrossfaderInterface.end())
{
- mMapCrossfaderInterface.erase(iter);
- return E_OK;
+ mMapCrossfaderInterface.erase(iter);
+ return E_OK;
}
return E_NON_EXISTENT;
}
-
am_Error_e RoutingSender::removeHandle(const am_Handle_s& handle)
{
- if(mlistActiveHandles.erase(handle)) return E_OK;
- return E_UNKNOWN;
+ if (mlistActiveHandles.erase(handle))
+ return E_OK;
+ return E_UNKNOWN;
}
am_Error_e RoutingSender::getListHandles(std::vector<am_Handle_s> & listHandles) const
{
- listHandles.clear();
- HandlesMap::const_iterator it=mlistActiveHandles.begin();
- for(;it!=mlistActiveHandles.end();++it)
- {
- listHandles.push_back(it->first);
- }
- return E_OK;
+ listHandles.clear();
+ HandlesMap::const_iterator it = mlistActiveHandles.begin();
+ for (; it != mlistActiveHandles.end(); ++it)
+ {
+ listHandles.push_back(it->first);
+ }
+ return E_OK;
}
am_Handle_s RoutingSender::createHandle(const am_handleData_c& handleData, const am_Handle_e type)
{
- am_Handle_s handle;
- handle.handle=++mHandleCount; //todo: handle overflows here...
- handle.handleType=type;
- mlistActiveHandles.insert(std::make_pair(handle,handleData));
- return handle;
+ am_Handle_s handle;
+ handle.handle = ++mHandleCount; //todo: handle overflows here...
+ handle.handleType = type;
+ mlistActiveHandles.insert(std::make_pair(handle, handleData));
+ return handle;
}
RoutingSender::am_handleData_c RoutingSender::returnHandleData(const am_Handle_s handle) const
{
- HandlesMap::const_iterator it=mlistActiveHandles.begin();
- it=mlistActiveHandles.find(handle);
- return (it->second);
+ HandlesMap::const_iterator it = mlistActiveHandles.begin();
+ it = mlistActiveHandles.find(handle);
+ return (it->second);
}
void RoutingSender::unloadLibraries(void)
{
- std::vector<void*>::iterator iterator=mListLibraryHandles.begin();
- for(;iterator<mListLibraryHandles.end();++iterator)
- {
- dlclose(*iterator);
- }
- mListLibraryHandles.clear();
+ std::vector<void*>::iterator iterator = mListLibraryHandles.begin();
+ for (; iterator < mListLibraryHandles.end(); ++iterator)
+ {
+ dlclose(*iterator);
+ }
+ mListLibraryHandles.clear();
}
am_Error_e am::RoutingSender::getListPlugins(std::vector<std::string>& interfaces) const
{
- std::vector<InterfaceNamePairs>::const_iterator it=mListInterfaces.begin();
- for(;it!=mListInterfaces.end();++it)
- {
- interfaces.push_back(it->busName);
- }
- return E_OK;
+ std::vector<InterfaceNamePairs>::const_iterator it = mListInterfaces.begin();
+ for (; it != mListInterfaces.end(); ++it)
+ {
+ interfaces.push_back(it->busName);
+ }
+ return E_OK;
}
-
uint16_t RoutingSender::getInterfaceVersion() const
{
- return (RoutingSendVersion);
+ return (RoutingSendVersion);
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/AudioManagerDaemon/src/SocketHandler.cpp b/AudioManagerDaemon/src/SocketHandler.cpp
index b749fbb..dbff14c 100644
--- a/AudioManagerDaemon/src/SocketHandler.cpp
+++ b/AudioManagerDaemon/src/SocketHandler.cpp
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file DBusWrapper.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file DBusWrapper.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#include "SocketHandler.h"
#include <config.h>
@@ -34,7 +34,6 @@
#include <dlt/dlt.h>
#include <signal.h>
-
#include <iostream>
//todo: implement time correction if timer was interrupted by call
@@ -42,164 +41,163 @@ DLT_IMPORT_CONTEXT(AudioManager)
using namespace am;
-SocketHandler::SocketHandler()
- :mListPoll(),
- mListTimer(),
- mListActiveTimer(),
- mNextTimer(),
- mLastInsertedHandle(0),
- mLastInsertedPollHandle(0),
- mRecreatePollfds(true),
- mTimeout()
+SocketHandler::SocketHandler() :
+ mListPoll(), //
+ mListTimer(), //
+ mListActiveTimer(), //
+ mNextTimer(), //
+ mLastInsertedHandle(0), //
+ mLastInsertedPollHandle(0), //
+ mRecreatePollfds(true), //
+ mTimeout()
{
- mTimeout.tv_nsec=-1;
- mTimeout.tv_sec=-1;
- gDispatchDone=0;
+ mTimeout.tv_nsec = -1;
+ mTimeout.tv_sec = -1;
+ gDispatchDone = 0;
}
SocketHandler::~SocketHandler()
{
}
-
//todo: maybe have some: give me more time returned?
/**
* start the block listening for filedescriptors. This is the mainloop.
*/
void SocketHandler::start_listenting()
{
- int16_t pollStatus;
- std::list<int16_t>hitList;
-
- //init the timer
- initTimer();
-
- //prepare the signalmask
- sigset_t sigmask;
- sigemptyset(&sigmask);
- sigaddset(&sigmask, SIGINT);
- sigaddset(&sigmask, SIGQUIT);
- sigaddset(&sigmask, SIGTERM);
- sigaddset(&sigmask, SIGHUP);
- sigaddset(&sigmask, SIGQUIT);
-
- while (!gDispatchDone)
- {
- //first we go through the registered filedescriptors and check if someone needs preparation:
- mListPoll_t::iterator prepIter=mListPoll.begin();
- shPollPrepare *prep=NULL;
- for(;prepIter!=mListPoll.end();++prepIter)
- {
- if((prep=prepIter->prepareCB)!=NULL) prep->Call(prepIter->handle,prepIter->userData);
- }
-
- if(mRecreatePollfds)
- {
- mfdPollingArray.clear();
- //there was a change in the setup, so we need to recreate the fdarray from the list
- std::for_each(mListPoll.begin(),mListPoll.end(),CopyPollfd(mfdPollingArray));
- mRecreatePollfds=false;
- }
-
- //block until something is on a filedescriptor
+ int16_t pollStatus;
+ std::list<int16_t> hitList;
+
+ //init the timer
+ initTimer();
+
+ //prepare the signalmask
+ sigset_t sigmask;
+ sigemptyset(&sigmask);
+ sigaddset(&sigmask, SIGINT);
+ sigaddset(&sigmask, SIGQUIT);
+ sigaddset(&sigmask, SIGTERM);
+ sigaddset(&sigmask, SIGHUP);
+ sigaddset(&sigmask, SIGQUIT);
+
+ while (!gDispatchDone)
+ {
+ //first we go through the registered filedescriptors and check if someone needs preparation:
+ mListPoll_t::iterator prepIter = mListPoll.begin();
+ shPollPrepare *prep = NULL;
+ for (; prepIter != mListPoll.end(); ++prepIter)
+ {
+ if ((prep = prepIter->prepareCB) != NULL) prep->Call(prepIter->handle, prepIter->userData);
+ }
+
+ if (mRecreatePollfds)
+ {
+ mfdPollingArray.clear();
+ //there was a change in the setup, so we need to recreate the fdarray from the list
+ std::for_each(mListPoll.begin(), mListPoll.end(), CopyPollfd(mfdPollingArray));
+ mRecreatePollfds = false;
+ }
+
+ //block until something is on a filedescriptor
#ifdef WITH_PPOLL
- timespec buffertime;
- if((pollStatus=ppoll(&mfdPollingArray.front(),mfdPollingArray.size(),insertTime(buffertime),&sigmask))<0)
- {
- if(errno==EINTR)
- {
- //a signal was received, that means it's time to go...
- pollStatus=0;
- }
- else
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("SocketHandler::start_listenting ppoll returned with error"),DLT_INT(errno));
- exit(0);
- }
- }
+ timespec buffertime;
+ if ((pollStatus = ppoll(&mfdPollingArray.front(), mfdPollingArray.size(), insertTime(buffertime), &sigmask)) < 0)
+ {
+ if (errno == EINTR)
+ {
+ //a signal was received, that means it's time to go...
+ pollStatus = 0;
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("SocketHandler::start_listenting ppoll returned with error"), DLT_INT(errno));
+ exit(0);
+ }
+ }
#else
- //sigprocmask (SIG_SETMASK, &mask, &oldmask);
- if((pollStatus=poll(&mfdPollingArray.front(),mfdPollingArray.size(),timespec2ms(mTimeout)))<0)
- {
-
- if(errno==EINTR)
- {
- //a signal was received, that means it's time to go...
- //todo: add things to do here before going to sleep
- exit(0);
- }
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("SocketHandler::start_listenting poll returned with error"),DLT_INT(errno));
- exit(0);
- }
- //sigprocmask (SIG_SETMASK, &oldmask, NULL);
+ //sigprocmask (SIG_SETMASK, &mask, &oldmask);
+ if((pollStatus=poll(&mfdPollingArray.front(),mfdPollingArray.size(),timespec2ms(mTimeout)))<0)
+ {
+
+ if(errno==EINTR)
+ {
+ //a signal was received, that means it's time to go...
+ //todo: add things to do here before going to sleep
+ exit(0);
+ }
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("SocketHandler::start_listenting poll returned with error"),DLT_INT(errno));
+ exit(0);
+ }
+ //sigprocmask (SIG_SETMASK, &oldmask, NULL);
#endif
- if (pollStatus!=0) //only check filedescriptors if there was a change
- {
- //todo: here could be a timer that makes sure naughty plugins return!
-
- //get all indexes of the fired events and save them int hitList
- hitList.clear();
- std::vector<pollfd>::iterator it=mfdPollingArray.begin();
- do
- {
- it=std::find_if(it,mfdPollingArray.end(),onlyFiredEvents);
- if (it!=mfdPollingArray.end()) hitList.push_back(std::distance(mfdPollingArray.begin(), it++));
-
- } while (it!=mfdPollingArray.end());
-
- //stage 1, call firedCB for all matched events, but only if callback is not zero!
- std::list<int16_t>::iterator hListIt=hitList.begin();
- for(;hListIt!=hitList.end();++hListIt)
- {
- shPollFired* fire=NULL;
- if ((fire=mListPoll.at(*hListIt).firedCB)!=NULL) fire->Call(mfdPollingArray.at(*hListIt),mListPoll.at(*hListIt).handle,mListPoll.at(*hListIt).userData);
- }
-
- //stage 2, lets ask around if some dispatching is necessary, if not, they are taken from the hitlist
- hListIt=hitList.begin();
- for(;hListIt!=hitList.end();++hListIt)
- {
- shPollCheck* check=NULL;
- if ((check=mListPoll.at(*hListIt).checkCB)!=NULL)
- {
- if (!check->Call(mListPoll.at(*hListIt).handle,mListPoll.at(*hListIt).userData))
- {
- hListIt=hitList.erase(hListIt);
- }
- }
- }
-
- //stage 3, the ones left need to dispatch, we do this as long as there is something to dispatch..
- do
- {
- hListIt=hitList.begin();
- for(;hListIt!=hitList.end();++hListIt)
- {
- shPollDispatch *dispatch=NULL;
- if((dispatch=mListPoll.at(*hListIt).dispatchCB)!=NULL)
- {
- if (!dispatch->Call(mListPoll.at(*hListIt).handle,mListPoll.at(*hListIt).userData))
- {
- hListIt=hitList.erase(hListIt);
- }
- }
- else //there is no dispatch function, so we just remove the file from the list...
- {
- hListIt=hitList.erase(hListIt);
- }
- }
- } while (!hitList.empty());
-
- }
- else //Timerevent
- {
- //this was a timer event, we need to take care about the timers
- timerUp();
- }
- }
+ if (pollStatus != 0) //only check filedescriptors if there was a change
+ {
+ //todo: here could be a timer that makes sure naughty plugins return!
+
+ //get all indexes of the fired events and save them int hitList
+ hitList.clear();
+ std::vector<pollfd>::iterator it = mfdPollingArray.begin();
+ do
+ {
+ it = std::find_if(it, mfdPollingArray.end(), onlyFiredEvents);
+ if (it != mfdPollingArray.end()) hitList.push_back(std::distance(mfdPollingArray.begin(), it++));
+
+ } while (it != mfdPollingArray.end());
+
+ //stage 1, call firedCB for all matched events, but only if callback is not zero!
+ std::list<int16_t>::iterator hListIt = hitList.begin();
+ for (; hListIt != hitList.end(); ++hListIt)
+ {
+ shPollFired* fire = NULL;
+ if ((fire = mListPoll.at(*hListIt).firedCB) != NULL) fire->Call(mfdPollingArray.at(*hListIt), mListPoll.at(*hListIt).handle, mListPoll.at(*hListIt).userData);
+ }
+
+ //stage 2, lets ask around if some dispatching is necessary, if not, they are taken from the hitlist
+ hListIt = hitList.begin();
+ for (; hListIt != hitList.end(); ++hListIt)
+ {
+ shPollCheck* check = NULL;
+ if ((check = mListPoll.at(*hListIt).checkCB) != NULL)
+ {
+ if (!check->Call(mListPoll.at(*hListIt).handle, mListPoll.at(*hListIt).userData))
+ {
+ hListIt = hitList.erase(hListIt);
+ }
+ }
+ }
+
+ //stage 3, the ones left need to dispatch, we do this as long as there is something to dispatch..
+ do
+ {
+ hListIt = hitList.begin();
+ for (; hListIt != hitList.end(); ++hListIt)
+ {
+ shPollDispatch *dispatch = NULL;
+ if ((dispatch = mListPoll.at(*hListIt).dispatchCB) != NULL)
+ {
+ if (!dispatch->Call(mListPoll.at(*hListIt).handle, mListPoll.at(*hListIt).userData))
+ {
+ hListIt = hitList.erase(hListIt);
+ }
+ }
+ else //there is no dispatch function, so we just remove the file from the list...
+ {
+ hListIt = hitList.erase(hListIt);
+ }
+ }
+ } while (!hitList.empty());
+
+ }
+ else //Timerevent
+ {
+ //this was a timer event, we need to take care about the timers
+ timerUp();
+ }
+ }
}
/**
@@ -207,7 +205,7 @@ void SocketHandler::start_listenting()
*/
void SocketHandler::stop_listening()
{
- gDispatchDone=1;
+ gDispatchDone = 1;
}
/**
@@ -217,28 +215,28 @@ void SocketHandler::stop_listening()
* @param callback the callback that shall be called if the filedescriptor poll succeeded
* @return E_OK if the descriptor was added, E_NON_EXISTENT if the fd is not valid
*/
-am_Error_e SocketHandler::addFDPoll(const int fd,const int16_t event, shPollPrepare *prepare,shPollFired *fired,shPollCheck *check,shPollDispatch *dispatch, void* userData,sh_pollHandle_t& handle)
+am_Error_e SocketHandler::addFDPoll(const int fd, const int16_t event, shPollPrepare *prepare, shPollFired *fired, shPollCheck *check, shPollDispatch *dispatch, void* userData, sh_pollHandle_t& handle)
{
- if (!fdIsValid(fd)) return E_NON_EXISTENT;
-
- sh_poll_s pollData;
- pollData.pollfdValue.fd=fd;
- pollData.handle=++mLastInsertedPollHandle;
- pollData.pollfdValue.events=event;
- pollData.pollfdValue.revents=0;
- pollData.userData=userData;
- pollData.prepareCB=prepare;
- pollData.firedCB=fired;
- pollData.checkCB=check;
- pollData.dispatchCB=dispatch;
-
- //add new data to the list
- mListPoll.push_back(pollData);
-
- mRecreatePollfds=true;
-
- handle=pollData.handle;
- return E_OK;
+ if (!fdIsValid(fd)) return E_NON_EXISTENT;
+
+ sh_poll_s pollData;
+ pollData.pollfdValue.fd = fd;
+ pollData.handle = ++mLastInsertedPollHandle;
+ pollData.pollfdValue.events = event;
+ pollData.pollfdValue.revents = 0;
+ pollData.userData = userData;
+ pollData.prepareCB = prepare;
+ pollData.firedCB = fired;
+ pollData.checkCB = check;
+ pollData.dispatchCB = dispatch;
+
+ //add new data to the list
+ mListPoll.push_back(pollData);
+
+ mRecreatePollfds = true;
+
+ handle = pollData.handle;
+ return E_OK;
}
/**
@@ -248,18 +246,18 @@ am_Error_e SocketHandler::addFDPoll(const int fd,const int16_t event, shPollPrep
*/
am_Error_e SocketHandler::removeFDPoll(const sh_pollHandle_t handle)
{
- mListPoll_t::iterator iterator=mListPoll.begin();
-
- for (;iterator!=mListPoll.end();++iterator)
- {
- if(iterator->handle==handle)
- {
- iterator=mListPoll.erase(iterator);
- mRecreatePollfds=true;
- return E_OK;
- }
- }
- return E_UNKNOWN;
+ mListPoll_t::iterator iterator = mListPoll.begin();
+
+ for (; iterator != mListPoll.end(); ++iterator)
+ {
+ if (iterator->handle == handle)
+ {
+ iterator = mListPoll.erase(iterator);
+ mRecreatePollfds = true;
+ return E_OK;
+ }
+ }
+ return E_UNKNOWN;
}
/**
@@ -272,29 +270,29 @@ am_Error_e SocketHandler::removeFDPoll(const sh_pollHandle_t handle)
* @param handle the handle that is created for the timer is returned. Can be used to remove the timer
* @return E_OK in case of success
*/
-am_Error_e SocketHandler::addTimer(const timespec timeouts,shTimerCallBack*& callback,sh_timerHandle_t& handle, void * userData)
+am_Error_e SocketHandler::addTimer(const timespec timeouts, shTimerCallBack*& callback, sh_timerHandle_t& handle, void * userData)
{
- assert(!((timeouts.tv_sec==0) && (timeouts.tv_nsec==0)));
- assert(callback!=NULL);
-
- timer_s timerItem;
-
- //create a new handle for the timer
- handle=++mLastInsertedHandle; //todo: overflow ruling !
- timerItem.handle=handle;
- timerItem.countdown=timeouts;
- timerItem.timeout=timeouts;
- timerItem.callback=callback;
- timerItem.userData=userData;
-
- //add timer to the list
- mListActiveTimer.push_back(timerItem);
- mListTimer.push_back(timerItem);
-
- //very important: sort the list so that the smallest value is front
- mListActiveTimer.sort(compareCountdown);
- mTimeout=mListActiveTimer.front().countdown;
- return E_OK;
+ assert(!((timeouts.tv_sec==0) && (timeouts.tv_nsec==0)));
+ assert(callback!=NULL);
+
+ timer_s timerItem;
+
+ //create a new handle for the timer
+ handle = ++mLastInsertedHandle; //todo: overflow ruling !
+ timerItem.handle = handle;
+ timerItem.countdown = timeouts;
+ timerItem.timeout = timeouts;
+ timerItem.callback = callback;
+ timerItem.userData = userData;
+
+ //add timer to the list
+ mListActiveTimer.push_back(timerItem);
+ mListTimer.push_back(timerItem);
+
+ //very important: sort the list so that the smallest value is front
+ mListActiveTimer.sort(compareCountdown);
+ mTimeout = mListActiveTimer.front().countdown;
+ return E_OK;
}
/**
@@ -304,21 +302,21 @@ am_Error_e SocketHandler::addTimer(const timespec timeouts,shTimerCallBack*& cal
*/
am_Error_e SocketHandler::removeTimer(const sh_timerHandle_t handle)
{
- assert(handle!=0);
-
- //stop the current timer
- stopTimer(handle);
-
- std::list<timer_s>::iterator it=mListTimer.begin();
- for(;it!=mListTimer.end();++it)
- {
- if(it->handle==handle)
- {
- it=mListTimer.erase(it);
- return E_OK;
- }
- }
- return E_UNKNOWN;
+ assert(handle!=0);
+
+ //stop the current timer
+ stopTimer(handle);
+
+ std::list<timer_s>::iterator it = mListTimer.begin();
+ for (; it != mListTimer.end(); ++it)
+ {
+ if (it->handle == handle)
+ {
+ it = mListTimer.erase(it);
+ return E_OK;
+ }
+ }
+ return E_UNKNOWN;
}
/**
@@ -329,52 +327,52 @@ am_Error_e SocketHandler::removeTimer(const sh_timerHandle_t handle)
*/
am_Error_e SocketHandler::restartTimer(const sh_timerHandle_t handle, const timespec timeouts)
{
- timer_s timerItem;
- std::list<timer_s>::iterator it=mListTimer.begin();
- for(;it!=mListTimer.end();++it)
- {
- if (it->handle==handle)
- {
- timerItem=*it;
- break;
- }
- }
-
- if (timeouts.tv_nsec!=-1 && timeouts.tv_sec!=-1)
- {
- timerItem.timeout=timeouts;
- }
-
- mListActiveTimer.push_back(timerItem);
-
- //very important: sort the list so that the smallest value is front
- mListActiveTimer.sort(compareCountdown);
- mTimeout=mListActiveTimer.front().countdown;
- return E_OK;
+ timer_s timerItem;
+ std::list<timer_s>::iterator it = mListTimer.begin();
+ for (; it != mListTimer.end(); ++it)
+ {
+ if (it->handle == handle)
+ {
+ timerItem = *it;
+ break;
+ }
+ }
+
+ if (timeouts.tv_nsec != -1 && timeouts.tv_sec != -1)
+ {
+ timerItem.timeout = timeouts;
+ }
+
+ mListActiveTimer.push_back(timerItem);
+
+ //very important: sort the list so that the smallest value is front
+ mListActiveTimer.sort(compareCountdown);
+ mTimeout = mListActiveTimer.front().countdown;
+ return E_OK;
}
am_Error_e SocketHandler::stopTimer(const sh_timerHandle_t handle)
{
- //go through the list and remove the timer with the handle
- std::list<timer_s>::iterator it=mListActiveTimer.begin();
- for(;it!=mListActiveTimer.end();++it)
- {
- if(it->handle==handle)
- {
- it=mListActiveTimer.erase(it);
- if (!mListActiveTimer.empty())
- {
- mTimeout=mListActiveTimer.front().countdown;
- }
- else
- {
- mTimeout.tv_nsec=-1;
- mTimeout.tv_sec=-1;
- }
- return E_OK;
- }
- }
- return E_NON_EXISTENT;
+ //go through the list and remove the timer with the handle
+ std::list<timer_s>::iterator it = mListActiveTimer.begin();
+ for (; it != mListActiveTimer.end(); ++it)
+ {
+ if (it->handle == handle)
+ {
+ it = mListActiveTimer.erase(it);
+ if (!mListActiveTimer.empty())
+ {
+ mTimeout = mListActiveTimer.front().countdown;
+ }
+ else
+ {
+ mTimeout.tv_nsec = -1;
+ mTimeout.tv_sec = -1;
+ }
+ return E_OK;
+ }
+ }
+ return E_NON_EXISTENT;
}
/**
@@ -383,20 +381,20 @@ am_Error_e SocketHandler::stopTimer(const sh_timerHandle_t handle)
* @param event the event flags
* @return E_OK on succsess, E_NON_EXISTENT if fd was not found
*/
-am_Error_e SocketHandler::updateEventFlags(const sh_pollHandle_t handle, const int16_t events)
+am_Error_e SocketHandler::updateEventFlags(const sh_pollHandle_t handle, const int16_t events)
{
- mListPoll_t::iterator iterator=mListPoll.begin();
-
- for (;iterator!=mListPoll.end();++iterator)
- {
- if(iterator->handle==handle)
- {
- iterator->pollfdValue.events=events;
- mRecreatePollfds=true;
- return E_OK;
- }
- }
- return E_UNKNOWN;
+ mListPoll_t::iterator iterator = mListPoll.begin();
+
+ for (; iterator != mListPoll.end(); ++iterator)
+ {
+ if (iterator->handle == handle)
+ {
+ iterator->pollfdValue.events = events;
+ mRecreatePollfds = true;
+ return E_OK;
+ }
+ }
+ return E_UNKNOWN;
}
/**
@@ -406,7 +404,7 @@ am_Error_e SocketHandler::updateEventFlags(const sh_pollHandle_t handle, const i
*/
bool SocketHandler::fdIsValid(const int fd) const
{
- return (fcntl(fd, F_GETFL) != -1 || errno != EBADF);
+ return (fcntl(fd, F_GETFL) != -1 || errno != EBADF);
}
/**
@@ -415,22 +413,22 @@ bool SocketHandler::fdIsValid(const int fd) const
*/
void SocketHandler::timerUp()
{
- //first fire the event
- mListActiveTimer.front().callback->Call(mListActiveTimer.front().handle,mListActiveTimer.front().userData);
-
- //then remove the first timer, the one who fired
- mListActiveTimer.pop_front();
- if(!mListActiveTimer.empty())
- {
- //substract the old value from all timers in the list
- std::for_each(mListActiveTimer.begin(),mListActiveTimer.end(),SubstractTime(mTimeout));
- mTimeout=mListActiveTimer.front().countdown;
- }
- else
- {
- mTimeout.tv_nsec=-1;
- mTimeout.tv_sec=-1;
- }
+ //first fire the event
+ mListActiveTimer.front().callback->Call(mListActiveTimer.front().handle, mListActiveTimer.front().userData);
+
+ //then remove the first timer, the one who fired
+ mListActiveTimer.pop_front();
+ if (!mListActiveTimer.empty())
+ {
+ //substract the old value from all timers in the list
+ std::for_each(mListActiveTimer.begin(), mListActiveTimer.end(), SubstractTime(mTimeout));
+ mTimeout = mListActiveTimer.front().countdown;
+ }
+ else
+ {
+ mTimeout.tv_nsec = -1;
+ mTimeout.tv_sec = -1;
+ }
}
/**
@@ -438,60 +436,57 @@ void SocketHandler::timerUp()
*/
void SocketHandler::initTimer()
{
- if(!mListActiveTimer.empty())
- {
- mTimeout=mListActiveTimer.front().countdown;
- }
- else
- {
- mTimeout.tv_nsec=-1;
- mTimeout.tv_sec=-1;
- }
+ if (!mListActiveTimer.empty())
+ {
+ mTimeout = mListActiveTimer.front().countdown;
+ }
+ else
+ {
+ mTimeout.tv_nsec = -1;
+ mTimeout.tv_sec = -1;
+ }
}
-
/**
-* convert timespec to milliseconds
-* @param time time in timespec
-* @return time in milliseconds
-*/
+ * convert timespec to milliseconds
+ * @param time time in timespec
+ * @return time in milliseconds
+ */
inline int SocketHandler::timespec2ms(const timespec & time)
{
- return (time.tv_nsec == -1 && time.tv_sec == -1) ? -1 : time.tv_sec * 1000 + time.tv_nsec / 1000000;
+ return (time.tv_nsec == -1 && time.tv_sec == -1) ? -1 : time.tv_sec * 1000 + time.tv_nsec / 1000000;
}
inline timespec* am::SocketHandler::insertTime(timespec& buffertime)
{
- buffertime.tv_nsec=mTimeout.tv_nsec;
- buffertime.tv_sec=mTimeout.tv_sec;
- return (mTimeout.tv_nsec == -1 && mTimeout.tv_sec == -1) ? NULL : &buffertime;
+ buffertime.tv_nsec = mTimeout.tv_nsec;
+ buffertime.tv_sec = mTimeout.tv_sec;
+ return (mTimeout.tv_nsec == -1 && mTimeout.tv_sec == -1) ? NULL : &buffertime;
}
/**
-* functor to easy substract from each countdown
-* @param t value to substract from
-*/
+ * functor to easy substract from each countdown
+ * @param t value to substract from
+ */
void SocketHandler::SubstractTime::operator ()(timer_s & t) const
{
- int val = 0;
- if((val = t.countdown.tv_nsec - param.tv_nsec) < 0){
- t.countdown.tv_nsec = 1000000000 + val;
- t.countdown.tv_sec--;
- }else{
- t.countdown.tv_nsec = val;
- }
- (t.countdown.tv_sec - param.tv_sec) < 0 ? 0 : (t.countdown.tv_sec -= param.tv_sec);
+ int val = 0;
+ if ((val = t.countdown.tv_nsec - param.tv_nsec) < 0)
+ {
+ t.countdown.tv_nsec = 1000000000 + val;
+ t.countdown.tv_sec--;
+ }
+ else
+ {
+ t.countdown.tv_nsec = val;
+ }
+ (t.countdown.tv_sec - param.tv_sec) < 0 ? 0 : (t.countdown.tv_sec -= param.tv_sec);
}
void SocketHandler::CopyPollfd::operator ()(const sh_poll_s & row)
{
- pollfd temp=row.pollfdValue;
- temp.revents=0;
- mArray.push_back(temp);
+ pollfd temp = row.pollfdValue;
+ temp.revents = 0;
+ mArray.push_back(temp);
}
-
-
-
-
-
diff --git a/AudioManagerDaemon/src/TelnetServer.cpp b/AudioManagerDaemon/src/TelnetServer.cpp
index 3e77b0b..36eac28 100644
--- a/AudioManagerDaemon/src/TelnetServer.cpp
+++ b/AudioManagerDaemon/src/TelnetServer.cpp
@@ -1,31 +1,31 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file TelnetServer.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file TelnetServer.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#include "TelnetServer.h"
#include <assert.h>
-#include <sys/socket.h> /* for socket(), connect(), (), and recv() */
-#include <arpa/inet.h> /* for sockaddr_in and inet_addr() */
+#include <sys/socket.h>
+#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <string.h>
#include <netdb.h>
@@ -43,69 +43,68 @@ using namespace am;
DLT_IMPORT_CONTEXT(AudioManager)
-TelnetServer* TelnetServer::instance=NULL;
+TelnetServer* TelnetServer::instance = NULL;
#define PRINT_BOOL(var) var ? output+="true\t\t" : output+="false\t\t";
-TelnetServer::TelnetServer(SocketHandler *iSocketHandler, CommandSender *iCommandSender, CommandReceiver *iCommandReceiver, RoutingSender *iRoutingSender, RoutingReceiver *iRoutingReceiver, ControlSender *iControlSender, ControlReceiver *iControlReceiver, DatabaseHandler *iDatabasehandler, unsigned int servPort, unsigned int maxConnections)
- :telnetConnectFiredCB(this,&TelnetServer::connectSocket),
- telnetReceiveFiredCB(this,&TelnetServer::receiveData),
- telnetDispatchCB(this,&TelnetServer::dispatchData),
- telnetCheckCB(this,&TelnetServer::check),
- mSocketHandler(iSocketHandler),
- mCommandSender(iCommandSender),
- mCommandReceiver(iCommandReceiver),
- mRoutingSender(iRoutingSender),
- mRoutingReceiver(iRoutingReceiver),
- mControlSender(iControlSender),
- mControlReceiver(iControlReceiver),
- mDatabasehandler(iDatabasehandler),
- mConnecthandle(),
- msgList(),
- mListConnections(),
- mConnectFD(NULL),
- mServerPort(servPort),
- mMaxConnections(maxConnections),
- mMapCommands(createCommandMap())
+TelnetServer::TelnetServer(SocketHandler *iSocketHandler, CommandSender *iCommandSender, CommandReceiver *iCommandReceiver, RoutingSender *iRoutingSender, RoutingReceiver *iRoutingReceiver, ControlSender *iControlSender, ControlReceiver *iControlReceiver, DatabaseHandler *iDatabasehandler, unsigned int servPort, unsigned int maxConnections) :
+ telnetConnectFiredCB(this, &TelnetServer::connectSocket), //
+ telnetReceiveFiredCB(this, &TelnetServer::receiveData), //
+ telnetDispatchCB(this, &TelnetServer::dispatchData), //
+ telnetCheckCB(this, &TelnetServer::check), //
+ mSocketHandler(iSocketHandler), //
+ mCommandSender(iCommandSender), //
+ mCommandReceiver(iCommandReceiver), //
+ mRoutingSender(iRoutingSender), //
+ mRoutingReceiver(iRoutingReceiver), //
+ mControlSender(iControlSender), //
+ mControlReceiver(iControlReceiver), //
+ mDatabasehandler(iDatabasehandler), //
+ mConnecthandle(), //
+ msgList(), //
+ mListConnections(), //
+ mConnectFD(NULL), //
+ mServerPort(servPort), //
+ mMaxConnections(maxConnections), //
+ mMapCommands(createCommandMap())
{
- assert(mSocketHandler!=NULL);
- assert(mCommandReceiver!=NULL);
- assert(mCommandSender!=NULL);
- assert(mControlSender!=NULL);
- assert(mControlReceiver!=NULL);
- assert(mRoutingSender!=NULL);
- assert(mRoutingReceiver!=NULL);
- assert(mDatabasehandler!=NULL);
- assert(servPort!=0);
- assert(mMaxConnections!=0);
-
- instance=this;
-
- int yes =1;
- struct sockaddr_in servAddr;
-
- //setup the port Listener
- mConnectFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
- setsockopt(mConnectFD, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
- memset(&servAddr, 0, sizeof(servAddr));
- servAddr.sin_family = AF_INET;
- servAddr.sin_addr.s_addr = INADDR_ANY;
- servAddr.sin_port = htons(servPort);
+ assert(mSocketHandler!=NULL);
+ assert(mCommandReceiver!=NULL);
+ assert(mCommandSender!=NULL);
+ assert(mControlSender!=NULL);
+ assert(mControlReceiver!=NULL);
+ assert(mRoutingSender!=NULL);
+ assert(mRoutingReceiver!=NULL);
+ assert(mDatabasehandler!=NULL);
+ assert(servPort!=0);
+ assert(mMaxConnections!=0);
+
+ instance = this;
+
+ int yes = 1;
+ struct sockaddr_in servAddr;
+
+ //setup the port Listener
+ mConnectFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ setsockopt(mConnectFD, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
+ memset(&servAddr, 0, sizeof(servAddr));
+ servAddr.sin_family = AF_INET;
+ servAddr.sin_addr.s_addr = INADDR_ANY;
+ servAddr.sin_port = htons(servPort);
bind(mConnectFD, (struct sockaddr *) &servAddr, sizeof(servAddr));
- if (listen(mConnectFD,mMaxConnections) < 0)
- {
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("TelnetServer::TelnetServerk cannot listen "),DLT_INT(errno));
- }
- DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("TelnetServer::TelnetServerk started listening on port"),DLT_INT(mServerPort));
+ if (listen(mConnectFD, mMaxConnections) < 0)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("TelnetServer::TelnetServerk cannot listen "), DLT_INT(errno));
+ }DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("TelnetServer::TelnetServerk started listening on port"), DLT_INT(mServerPort));
- int a=1;
- ioctl (mConnectFD, FIONBIO, (char *) &a);
- setsockopt (mConnectFD, SOL_SOCKET, SO_KEEPALIVE, (char *) &a, sizeof (a));
+ int a = 1;
+ ioctl(mConnectFD, FIONBIO, (char *) &a);
+ setsockopt(mConnectFD, SOL_SOCKET, SO_KEEPALIVE, (char *) &a, sizeof(a));
- short events=0;
- events |= POLLIN;
- mSocketHandler->addFDPoll(mConnectFD,events,NULL,&telnetConnectFiredCB,NULL,NULL,NULL,mConnecthandle);
+ short events = 0;
+ events |= POLLIN;
+ mSocketHandler->addFDPoll(mConnectFD, events, NULL, &telnetConnectFiredCB, NULL, NULL, NULL, mConnecthandle);
}
TelnetServer::~TelnetServer()
@@ -114,157 +113,144 @@ TelnetServer::~TelnetServer()
void TelnetServer::connectSocket(const pollfd pfd, const sh_pollHandle_t handle, void *userData)
{
- //first, accept the connection, create a new filedescriptor
- struct sockaddr answer;
- socklen_t len=sizeof(answer);
- connection_s connection;
- connection.filedescriptor = accept(pfd.fd, (struct sockaddr*)&answer, &len);
+ //first, accept the connection, create a new filedescriptor
+ struct sockaddr answer;
+ socklen_t len = sizeof(answer);
+ connection_s connection;
+ connection.filedescriptor = accept(pfd.fd, (struct sockaddr*) &answer, &len);
- mListConnections.push_back(connection);
+ mListConnections.push_back(connection);
- //set the correct event:
- short event = 0;
- event |=POLLIN;
+ //set the correct event:
+ short event = 0;
+ event |= POLLIN;
- //aded the filedescriptor to the sockethandler and register the callbacks for receiving the data
- mSocketHandler->addFDPoll(mListConnections.back().filedescriptor,event,NULL,&telnetReceiveFiredCB,&telnetCheckCB,&telnetDispatchCB,NULL,mListConnections.back().handle);
+ //aded the filedescriptor to the sockethandler and register the callbacks for receiving the data
+ mSocketHandler->addFDPoll(mListConnections.back().filedescriptor, event, NULL, &telnetReceiveFiredCB, &telnetCheckCB, &telnetDispatchCB, NULL, mListConnections.back().handle);
}
-
-
void TelnetServer::receiveData(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
{
- //initialize buffer
- char buffer[100];
- //read until buffer is full or no more data is there
- int read=recv(pollfd.fd,buffer,100,NULL);
- if (read>1)
- {
- //read the message and store it in a queue - its a telnet connection so data will be sent on enter !
- std::string msg=std::string(buffer,read);
- msgList.push(msg);
- }
+ //initialize buffer
+ char buffer[100];
+ //read until buffer is full or no more data is there
+ int read = recv(pollfd.fd, buffer, 100, NULL);
+ if (read > 1)
+ {
+ //read the message and store it in a queue - its a telnet connection so data will be sent on enter !
+ std::string msg = std::string(buffer, read);
+ msgList.push(msg);
+ }
}
-
-
bool TelnetServer::dispatchData(const sh_pollHandle_t handle, void *userData)
{
- std::vector<connection_s>::iterator iterator=mListConnections.begin();
- for(;iterator!=mListConnections.end();++iterator)
- {
- if(iterator->handle==handle) break;
- }
- if (iterator==mListConnections.end()) return false;
-
- std::string command;
- std::vector<std::string> msg;
- sliceCommand(msgList.front(),command,msg);
- msgList.pop();
- mMapCommand_t::iterator commandIter=mMapCommands.find(command);
- if (commandIter==mMapCommands.end())
- {
- send(iterator->filedescriptor,"Command not found!\n",20,0);
- }
- else
- {
- (*commandIter).second(msg,iterator->filedescriptor);
- }
-
- //remove the message from the queue and return false if there is no more message to read.
- if (msgList.size()!=0) return true;
- return false;
+ std::vector<connection_s>::iterator iterator = mListConnections.begin();
+ for (; iterator != mListConnections.end(); ++iterator)
+ {
+ if (iterator->handle == handle) break;
+ }
+ if (iterator == mListConnections.end()) return false;
+
+ std::string command;
+ std::vector<std::string> msg;
+ sliceCommand(msgList.front(), command, msg);
+ msgList.pop();
+ mMapCommand_t::iterator commandIter = mMapCommands.find(command);
+ if (commandIter == mMapCommands.end())
+ {
+ send(iterator->filedescriptor, "Command not found!\n", 20, 0);
+ }
+ else
+ {
+ (*commandIter).second(msg, iterator->filedescriptor);
+ }
+
+ //remove the message from the queue and return false if there is no more message to read.
+ if (msgList.size() != 0) return true;
+ return false;
}
-
-
-
bool TelnetServer::check(const sh_pollHandle_t handle, void *userData)
{
- if (msgList.size()!=0) return true;
- return false;
+ if (msgList.size() != 0) return true;
+ return false;
}
void TelnetServer::listCommand(std::vector<std::string>& msg, int filedescriptor)
{
- instance->listCommandShadow(msg,filedescriptor);
+ instance->listCommandShadow(msg, filedescriptor);
}
-void am::TelnetServer::listCommandShadow(std::vector<std::string> & msg, int filedescriptor)
+void TelnetServer::listCommandShadow(std::vector<std::string> & msg, int filedescriptor)
{
- std::string output;
- if(msg.empty())
- {
- output+="No second parameter given after list, please enter\n";
- }
- else if(msg.front().compare("plugins")==0)
- {
- std::vector<std::string> plugins;
- mRoutingSender->getListPlugins(plugins);
- std::vector<std::string>::iterator it=plugins.begin();
- output="\n\nrouting plugins:\n-------------------------\n";
- for(;it!=plugins.end();++it)
- {
- output+=*it+"\n";
- }
- }
- else if(msg.front().compare("domains")==0)
- {
- output="domainID\t\tdomainName\t\tbusName\t\tnodeName\t\tearly\t\tstate\t\tcomplete\n";
- output+="-------------------------------------------------------------------------------------\n";
- std::vector<am_Domain_s> domainList;
- mDatabasehandler->getListDomains(domainList);
- std::vector<am_Domain_s>::iterator it=domainList.begin();
- for(;it!=domainList.end();++it)
- {
- output+=it->domainID + "\t\t";
- output+=it->name + "\t\t";
- output+=it->busname + "\t\t";
- output+=it->nodename + "\t\t";
- PRINT_BOOL(it->early);
- switch (it->state)
- {
- case DS_CONTROLLED:
- output+="DS_CONTROLLED\t\t";
- break;
- case DS_INDEPENDENT_STARTUP:
- output+="DS_INDEPENDENT_STARTUP\t\t";
- break;
- case DS_INDEPENDENT_RUNDOWN:
- output+="DS_INDEPENDENT_RUNDOWN\t\t";
- break;
- default:
- output+="undefined\t\t";
- break;
- }
- PRINT_BOOL(it->complete);
- }
- }
- else
- {
- output="did not recognize parameter: " + msg.front()+"\n";
- }
- send(filedescriptor,output.c_str(),output.size(),0);
+ std::string output;
+ if (msg.empty())
+ {
+ output += "No second parameter given after list, please enter\n";
+ }
+ else if (msg.front().compare("plugins") == 0)
+ {
+ std::vector<std::string> plugins;
+ mRoutingSender->getListPlugins(plugins);
+ std::vector<std::string>::iterator it = plugins.begin();
+ output = "\n\nrouting plugins:\n-------------------------\n";
+ for (; it != plugins.end(); ++it)
+ {
+ output += *it + "\n";
+ }
+ }
+ else if (msg.front().compare("domains") == 0)
+ {
+ output = "domainID\t\tdomainName\t\tbusName\t\tnodeName\t\tearly\t\tstate\t\tcomplete\n";
+ output += "-------------------------------------------------------------------------------------\n";
+ std::vector<am_Domain_s> domainList;
+ mDatabasehandler->getListDomains(domainList);
+ std::vector<am_Domain_s>::iterator it = domainList.begin();
+ for (; it != domainList.end(); ++it)
+ {
+ output += it->domainID + "\t\t";
+ output += it->name + "\t\t";
+ output += it->busname + "\t\t";
+ output += it->nodename + "\t\t";
+ PRINT_BOOL(it->early);
+ switch (it->state)
+ {
+ case DS_CONTROLLED:
+ output += "DS_CONTROLLED\t\t";
+ break;
+ case DS_INDEPENDENT_STARTUP:
+ output += "DS_INDEPENDENT_STARTUP\t\t";
+ break;
+ case DS_INDEPENDENT_RUNDOWN:
+ output += "DS_INDEPENDENT_RUNDOWN\t\t";
+ break;
+ default:
+ output += "undefined\t\t";
+ break;
+ }PRINT_BOOL(it->complete);
+ }
+ }
+ else
+ {
+ output = "did not recognize parameter: " + msg.front() + "\n";
+ }
+ send(filedescriptor, output.c_str(), output.size(), 0);
}
-
void am::TelnetServer::sliceCommand(const std::string & string, std::string & command, std::vector<std::string> & msg)
{
- std::stringstream stream(string);
- std::istream_iterator<std::string> begin(stream);
- std::istream_iterator<std::string> end;
- command=*begin++;
- msg=std::vector<std::string>(begin, end);
+ std::stringstream stream(string);
+ std::istream_iterator<std::string> begin(stream);
+ std::istream_iterator<std::string> end;
+ command = *begin++;
+ msg = std::vector<std::string>(begin, end);
}
TelnetServer::mMapCommand_t TelnetServer::createCommandMap()
{
- mMapCommand_t commands;
- commands.insert(std::make_pair("list",&TelnetServer::listCommand));
- return commands;
+ mMapCommand_t commands;
+ commands.insert(std::make_pair("list", &TelnetServer::listCommand));
+ return commands;
}
-
-
-
-
diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp
index 3d940f6..d2ff042 100644
--- a/AudioManagerDaemon/src/main.cpp
+++ b/AudioManagerDaemon/src/main.cpp
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file main.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file main.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
/**
* Please make sure to have read the documentation on genivi.org!
@@ -34,7 +34,6 @@
//todo: there is a bug in the visible flags of sinks and sources. fix it.
//todo: make sure that iterators have a fixed end to prevent crashed while adding vectors while iterating on critical vectors
//todo: make sure all configurations are tested
-
#include <config.h>
#include <SocketHandler.h>
#ifdef WITH_DBUS_WRAPPER
@@ -67,252 +66,246 @@ DLT_DECLARE_CONTEXT(AudioManager)
using namespace am;
const char* USAGE_DESCRIPTION = "Usage:\tAudioManagerDaemon [options]\n"
- "options:\t\n"
- "\t-h: print this message\t\n"
- "\t-i: info about current settings \t\n"
- "\t-v: print version\t\n"
- "\t-d: daemonize AudioManager \t\n"
- "\t-p<path> path for sqlite database (default is in memory)\t\n"
- "\t-t<port> port for telnetconnection\t\n"
- "\t-m<max> number of max telnetconnections\t\n"
- "\t-c<Name> use controllerPlugin <Name> (full path with .so ending)\t\n"
- "\t-l<Name> replace command plugin directory with <Name> (full path)\t\n"
- "\t-r<Name> replace routing plugin directory with <Name> (full path)\t\n"
- "\t-L<Name> add command plugin directory with <Name> (full path)\t\n"
- "\t-R<Name> add routing plugin directory with <Name> (full path)\t\n";
-
-std::string controllerPlugin=std::string(CONTROLLER_PLUGIN);
+ "options:\t\n"
+ "\t-h: print this message\t\n"
+ "\t-i: info about current settings \t\n"
+ "\t-v: print version\t\n"
+ "\t-d: daemonize AudioManager \t\n"
+ "\t-p<path> path for sqlite database (default is in memory)\t\n"
+ "\t-t<port> port for telnetconnection\t\n"
+ "\t-m<max> number of max telnetconnections\t\n"
+ "\t-c<Name> use controllerPlugin <Name> (full path with .so ending)\t\n"
+ "\t-l<Name> replace command plugin directory with <Name> (full path)\t\n"
+ "\t-r<Name> replace routing plugin directory with <Name> (full path)\t\n"
+ "\t-L<Name> add command plugin directory with <Name> (full path)\t\n"
+ "\t-R<Name> add routing plugin directory with <Name> (full path)\t\n";
+
+std::string controllerPlugin = std::string(CONTROLLER_PLUGIN);
std::vector<std::string> listCommandPluginDirs;
std::vector<std::string> listRoutingPluginDirs;
-std::string databasePath=std::string(":memory:");
-unsigned int telnetport=DEFAULT_TELNETPORT;
-unsigned int maxConnections=MAX_TELNETCONNECTIONS;
+std::string databasePath = std::string(":memory:");
+unsigned int telnetport = DEFAULT_TELNETPORT;
+unsigned int maxConnections = MAX_TELNETCONNECTIONS;
-void daemonize ()
+void daemonize()
{
- umask(0);
- std::string dir="/";
-
- rlimit rl;
- if (getrlimit(RLIMIT_NOFILE, &rl) < 0)
- {
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("can't get file limit "));
- }
-
- pid_t pid;
- if ((pid = fork()) < 0)
- {
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("cannot fork!"));
- }
- else if (pid != 0)
- {
- exit(0);
- }
-
- setsid();
-
- if (!dir.empty() && chdir(dir.c_str()) < 0)
- {
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("couldn't chdir to the new directory"));
- }
-
- if (rl.rlim_max == RLIM_INFINITY)
- {
- rl.rlim_max = 1024;
- }
-
-
- for (unsigned int i = 0; i < rl.rlim_max; i++)
- {
- close(i);
- }
-
- int fd0 = open("/dev/null", O_RDONLY);
- int fd1 = open("/dev/null",O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR);
- int fd2 = open("/dev/null", O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR);
-
- if (fd0 != STDIN_FILENO || fd1 != STDOUT_FILENO || fd2 != STDERR_FILENO)
- {
- DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("new standard file descriptors were not opened"));
- }
+ umask(0);
+ std::string dir = "/";
+
+ rlimit rl;
+ if (getrlimit(RLIMIT_NOFILE, &rl) < 0)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("can't get file limit "));
+ }
+
+ pid_t pid;
+ if ((pid = fork()) < 0)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("cannot fork!"));
+ }
+ else if (pid != 0)
+ {
+ exit(0);
+ }
+
+ setsid();
+
+ if (!dir.empty() && chdir(dir.c_str()) < 0)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("couldn't chdir to the new directory"));
+ }
+
+ if (rl.rlim_max == RLIM_INFINITY)
+ {
+ rl.rlim_max = 1024;
+ }
+
+ for (unsigned int i = 0; i < rl.rlim_max; i++)
+ {
+ close(i);
+ }
+
+ int fd0 = open("/dev/null", O_RDONLY);
+ int fd1 = open("/dev/null", O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
+ int fd2 = open("/dev/null", O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
+
+ if (fd0 != STDIN_FILENO || fd1 != STDOUT_FILENO || fd2 != STDERR_FILENO)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("new standard file descriptors were not opened"));
+ }
}
void parseCommandLine(int argc, char **argv)
{
- while (optind < argc)
- {
- int option = getopt (argc, argv, "h::v::c::l::r::L::R::d::t::m::i::p::");
-
- switch (option)
- {
- case 'i':
- printf("Current settings:\n");
- printf("\tAudioManagerDaemon Version:\t\t%s\n",DAEMONVERSION);
- printf("\tTelnet portNumber:\t\t\t%i\n",telnetport);
- printf("\tTelnet maxConnections:\t\t\t%i\n",maxConnections);
- printf("\tSqlite Database path:\t\t\t%s\n",databasePath.c_str());
- printf("\tControllerPlugin: \t\t\t%s\n",controllerPlugin.c_str());
- printf("\tDirectory of CommandPlugins: \t\t%s\n",listCommandPluginDirs.front().c_str());
- printf("\tDirectory of RoutingPlugins: \t\t%s\n",listRoutingPluginDirs.front().c_str());
- exit(0);
- break;
- case 't':
- assert(atoi(optarg)!=0);
- telnetport=atoi(optarg);
- break;
- case 'm':
- assert(atoi(optarg)!=0);
- maxConnections=atoi(optarg);
- break;
- case 'p':
- assert(!controllerPlugin.empty());
- databasePath=std::string(optarg);
- break;
- case 'd':
- daemonize();
- break;
- case 'l':
- listCommandPluginDirs.clear();
- listCommandPluginDirs.push_back(std::string(optarg));
- break;
- case 'r':
- listRoutingPluginDirs.clear();
- listRoutingPluginDirs.push_back(std::string(optarg));
- break;
- case 'L':
- listCommandPluginDirs.push_back(std::string(optarg));
- break;
- case 'R':
- listRoutingPluginDirs.push_back(std::string(optarg));
- break;
- case 'c':
- controllerPlugin=std::string(optarg);
- assert(!controllerPlugin.empty());
- assert(controllerPlugin.find(".so")!=std::string::npos);
- break;
- case 'v':
- printf("AudioManagerDaemon Version: %s\n",DAEMONVERSION);
- exit(-1);
- break;
- case 'h':
+ while (optind < argc)
+ {
+ int option = getopt(argc, argv, "h::v::c::l::r::L::R::d::t::m::i::p::");
+
+ switch (option)
+ {
+ case 'i':
+ printf("Current settings:\n");
+ printf("\tAudioManagerDaemon Version:\t\t%s\n", DAEMONVERSION);
+ printf("\tTelnet portNumber:\t\t\t%i\n", telnetport);
+ printf("\tTelnet maxConnections:\t\t\t%i\n", maxConnections);
+ printf("\tSqlite Database path:\t\t\t%s\n", databasePath.c_str());
+ printf("\tControllerPlugin: \t\t\t%s\n", controllerPlugin.c_str());
+ printf("\tDirectory of CommandPlugins: \t\t%s\n", listCommandPluginDirs.front().c_str());
+ printf("\tDirectory of RoutingPlugins: \t\t%s\n", listRoutingPluginDirs.front().c_str());
+ exit(0);
+ break;
+ case 't':
+ assert(atoi(optarg)!=0);
+ telnetport = atoi(optarg);
+ break;
+ case 'm':
+ assert(atoi(optarg)!=0);
+ maxConnections = atoi(optarg);
+ break;
+ case 'p':
+ assert(!controllerPlugin.empty());
+ databasePath = std::string(optarg);
+ break;
+ case 'd':
+ daemonize();
+ break;
+ case 'l':
+ listCommandPluginDirs.clear();
+ listCommandPluginDirs.push_back(std::string(optarg));
+ break;
+ case 'r':
+ listRoutingPluginDirs.clear();
+ listRoutingPluginDirs.push_back(std::string(optarg));
+ break;
+ case 'L':
+ listCommandPluginDirs.push_back(std::string(optarg));
+ break;
+ case 'R':
+ listRoutingPluginDirs.push_back(std::string(optarg));
+ break;
+ case 'c':
+ controllerPlugin = std::string(optarg);
+ assert(!controllerPlugin.empty());
+ assert(controllerPlugin.find(".so")!=std::string::npos);
+ break;
+ case 'v':
+ printf("AudioManagerDaemon Version: %s\n", DAEMONVERSION);
+ exit(-1);
+ break;
+ case 'h':
default:
- printf("AudioManagerDaemon Version: %s\n",DAEMONVERSION);
+ printf("AudioManagerDaemon Version: %s\n", DAEMONVERSION);
puts(USAGE_DESCRIPTION);
exit(-1);
- }
- }
+ }
+ }
}
-static void signalHandler (int sig, siginfo_t *siginfo, void *context)
+static void signalHandler(int sig, siginfo_t *siginfo, void *context)
{
- (void)sig;
- (void)siginfo;
- (void)context;
- DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("signal handler was called, exit now..."));
- gDispatchDone=1;
- //todo: maually fire the mainloop
- //todo: ifdef no sockethandler
- exit(1);
+ (void) sig;
+ (void) siginfo;
+ (void) context;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("signal handler was called, exit now..."));
+ gDispatchDone = 1;
+ //todo: maually fire the mainloop
+ //todo: ifdef no sockethandler
+ exit(1);
}
-
int main(int argc, char *argv[])
{
- DLT_REGISTER_APP("AudioManagerDeamon","AudioManagerDeamon");
- DLT_REGISTER_CONTEXT(AudioManager,"Main","Main Context");
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("The AudioManager is started, "), DLT_STRING(DAEMONVERSION));
-
- listCommandPluginDirs.push_back(std::string(DEFAULT_PLUGIN_COMMAND_DIR));
- listRoutingPluginDirs.push_back(std::string(DEFAULT_PLUGIN_ROUTING_DIR));
-
- //parse the commandline options
- parseCommandLine(argc, (char**) argv);
-
- //now the signal handler:
- struct sigaction signalAction;
- memset (&signalAction, '\0', sizeof(signalAction));
- signalAction.sa_sigaction = &signalHandler;
- signalAction.sa_flags = SA_SIGINFO;
- sigaction(SIGINT, &signalAction, NULL);
- sigaction(SIGQUIT, &signalAction, NULL);
- sigaction(SIGTERM, &signalAction, NULL);
- sigaction(SIGHUP, &signalAction, NULL);
- sigaction(SIGQUIT, &signalAction, NULL);
-
- struct sigaction signalChildAction;
- memset (&signalChildAction, '\0', sizeof(signalChildAction));
- signalChildAction.sa_flags = SA_NOCLDWAIT;
- sigaction (SIGCHLD, &signalChildAction, NULL);
-
- //Instantiate all classes. Keep in same order !
+ DLT_REGISTER_APP("AudioManagerDeamon", "AudioManagerDeamon");
+ DLT_REGISTER_CONTEXT(AudioManager, "Main", "Main Context");
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("The AudioManager is started, "), DLT_STRING(DAEMONVERSION));
+
+ listCommandPluginDirs.push_back(std::string(DEFAULT_PLUGIN_COMMAND_DIR));
+ listRoutingPluginDirs.push_back(std::string(DEFAULT_PLUGIN_ROUTING_DIR));
+
+ //parse the commandline options
+ parseCommandLine(argc, (char**) argv);
+
+ //now the signal handler:
+ struct sigaction signalAction;
+ memset(&signalAction, '\0', sizeof(signalAction));
+ signalAction.sa_sigaction = &signalHandler;
+ signalAction.sa_flags = SA_SIGINFO;
+ sigaction(SIGINT, &signalAction, NULL);
+ sigaction(SIGQUIT, &signalAction, NULL);
+ sigaction(SIGTERM, &signalAction, NULL);
+ sigaction(SIGHUP, &signalAction, NULL);
+ sigaction(SIGQUIT, &signalAction, NULL);
+
+ struct sigaction signalChildAction;
+ memset(&signalChildAction, '\0', sizeof(signalChildAction));
+ signalChildAction.sa_flags = SA_NOCLDWAIT;
+ sigaction(SIGCHLD, &signalChildAction, NULL);
+
+ //Instantiate all classes. Keep in same order !
#ifdef WITH_SOCKETHANDLER_LOOP
- SocketHandler iSocketHandler;
+ SocketHandler iSocketHandler;
#endif
#ifdef WITH_DBUS_WRAPPER
#ifdef WITH_SOCKETHANDLER_LOOP
- DBusWrapper iDBusWrapper(&iSocketHandler);
+ DBusWrapper iDBusWrapper(&iSocketHandler);
#else /*WITH_SOCKETHANDLER_LOOP*/
- DBusWrapper iDBusWrapper;
+ DBusWrapper iDBusWrapper;
#endif /*WITH_SOCKETHANDLER_LOOP*/
#endif /*WITH_DBUS_WRAPPER */
- DatabaseHandler iDatabaseHandler(databasePath);
- RoutingSender iRoutingSender(listRoutingPluginDirs);
- CommandSender iCommandSender(listCommandPluginDirs);
- ControlSender iControlSender(controllerPlugin);
+ DatabaseHandler iDatabaseHandler(databasePath);
+ RoutingSender iRoutingSender(listRoutingPluginDirs);
+ CommandSender iCommandSender(listCommandPluginDirs);
+ ControlSender iControlSender(controllerPlugin);
#ifdef WITH_DBUS_WRAPPER
#ifdef WITH_SOCKETHANDLER_LOOP
- CommandReceiver iCommandReceiver(&iDatabaseHandler,&iControlSender,&iSocketHandler,&iDBusWrapper);
- RoutingReceiver iRoutingReceiver(&iDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler,&iDBusWrapper);
- ControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler);
+ CommandReceiver iCommandReceiver(&iDatabaseHandler, &iControlSender, &iSocketHandler, &iDBusWrapper);
+ RoutingReceiver iRoutingReceiver(&iDatabaseHandler, &iRoutingSender, &iControlSender, &iSocketHandler, &iDBusWrapper);
+ ControlReceiver iControlReceiver(&iDatabaseHandler, &iRoutingSender, &iCommandSender, &iSocketHandler);
#ifdef WITH_TELNET
- TelnetServer iTelnetServer(&iSocketHandler,&iCommandSender,&iCommandReceiver,&iRoutingSender,&iRoutingReceiver,&iControlSender,&iControlReceiver,&iDatabaseHandler,telnetport,maxConnections);
+ TelnetServer iTelnetServer(&iSocketHandler,&iCommandSender,&iCommandReceiver,&iRoutingSender,&iRoutingReceiver,&iControlSender,&iControlReceiver,&iDatabaseHandler,telnetport,maxConnections);
#endif
#else /*WITH_SOCKETHANDLER_LOOP */
- CommandReceiver iCommandReceiver(&iDatabaseHandler,&iControlSender,&iDBusWrapper);
- RoutingReceiver iRoutingReceiver(&iDatabaseHandler,&iRoutingSender,&iControlSender,&iDBusWrapper);
- ControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender);
+ CommandReceiver iCommandReceiver(&iDatabaseHandler,&iControlSender,&iDBusWrapper);
+ RoutingReceiver iRoutingReceiver(&iDatabaseHandler,&iRoutingSender,&iControlSender,&iDBusWrapper);
+ ControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender);
#endif /*WITH_SOCKETHANDLER_LOOP*/
#else /*WITH_DBUS_WRAPPER*/
- CommandReceiver iCommandReceiver(&iDatabaseHandler,&iControlSender,&iSocketHandler);
- RoutingReceiver iRoutingReceiver(&iDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler);
- ControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler);
+ CommandReceiver iCommandReceiver(&iDatabaseHandler,&iControlSender,&iSocketHandler);
+ RoutingReceiver iRoutingReceiver(&iDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler);
+ ControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler);
#ifdef WITH_TELNET
- TelnetServer iTelnetServer(&iSocketHandler,telnetport,maxConnections);
+ TelnetServer iTelnetServer(&iSocketHandler,telnetport,maxConnections);
#endif
#endif /*WITH_DBUS_WRAPPER*/
#ifdef WITH_TELNET
- DatabaseObserver iObserver(&iCommandSender, &iRoutingSender,&iTelnetServer);
+ DatabaseObserver iObserver(&iCommandSender, &iRoutingSender,&iTelnetServer);
#else
- DatabaseObserver iObserver(&iCommandSender, &iRoutingSender);
+ DatabaseObserver iObserver(&iCommandSender, &iRoutingSender);
#endif
+ //since the plugins have been loaded by the *Senders before, we can tell the Controller this:
+ iControlSender.hookAllPluginsLoaded();
- //since the plugins have been loaded by the *Senders before, we can tell the Controller this:
- iControlSender.hookAllPluginsLoaded();
-
- //the controller should startup the interfaces - this is just for testing
- iCommandSender.startupInterface(&iCommandReceiver);
- iRoutingSender.startupRoutingInterface(&iRoutingReceiver);
- iRoutingSender.routingInterfacesReady();
+ //the controller should startup the interfaces - this is just for testing
+ iCommandSender.startupInterface(&iCommandReceiver);
+ iRoutingSender.startupRoutingInterface(&iRoutingReceiver);
+ iRoutingSender.routingInterfacesReady();
#ifdef WITH_SOCKETHANDLER_LOOP
- iSocketHandler.start_listenting();
+ iSocketHandler.start_listenting();
#endif /*WITH_SOCKETHANDLER_LOOP*/
#ifdef WITH_DBUS_WRAPPER
#ifdef WITH_SIMPLEDBUS_LOOP
- iDBusWrapper.dbusMainLoop();
+ iDBusWrapper.dbusMainLoop();
#endif/*WITH_SIMPLEDBUS_LOOP*/
#endif /*WITH_DBUS_WRAPPER*/
-exit(0);
+ exit(0);
}
-
-
-
diff --git a/AudioManagerDaemon/test/CommandInterfaceBackdoor.h b/AudioManagerDaemon/test/CommandInterfaceBackdoor.h
index ab57a62..5d06fb1 100644
--- a/AudioManagerDaemon/test/CommandInterfaceBackdoor.h
+++ b/AudioManagerDaemon/test/CommandInterfaceBackdoor.h
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file CommandInterfaceBackdoor.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file CommandInterfaceBackdoor.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#ifndef COMMANDINTERFACEBACKDOOR_H_
#define COMMANDINTERFACEBACKDOOR_H_
@@ -29,16 +29,18 @@
#include <command/CommandSendInterface.h>
#include "CommandSender.h"
-namespace am {
+namespace am
+{
class CommandSender;
-class CommandInterfaceBackdoor {
+class CommandInterfaceBackdoor
+{
public:
- CommandInterfaceBackdoor();
- virtual ~CommandInterfaceBackdoor();
- bool unloadPlugins(CommandSender *CommandSender);
- bool injectInterface(CommandSender* CommandSender, CommandSendInterface* CommandSendInterface);
+ CommandInterfaceBackdoor();
+ virtual ~CommandInterfaceBackdoor();
+ bool unloadPlugins(CommandSender *CommandSender);
+ bool injectInterface(CommandSender* CommandSender, CommandSendInterface* CommandSendInterface);
};
}
diff --git a/AudioManagerDaemon/test/CommonFunctions.cpp b/AudioManagerDaemon/test/CommonFunctions.cpp
index b62169e..2a5c8cf 100644
--- a/AudioManagerDaemon/test/CommonFunctions.cpp
+++ b/AudioManagerDaemon/test/CommonFunctions.cpp
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file CommonFunctions.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file CommonFunctions.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#include "CommonFunctions.h"
#include "CommandInterfaceBackdoor.h"
@@ -32,359 +32,305 @@
using namespace am;
-CommandInterfaceBackdoor::CommandInterfaceBackdoor() {
+CommandInterfaceBackdoor::CommandInterfaceBackdoor()
+{
}
-CommandInterfaceBackdoor::~CommandInterfaceBackdoor() {
+CommandInterfaceBackdoor::~CommandInterfaceBackdoor()
+{
}
-bool CommandInterfaceBackdoor::unloadPlugins(CommandSender *CommandSender) {
- assert(CommandSender != NULL);
- CommandSender->unloadLibraries();
- CommandSender->mListInterfaces.clear();
- if (CommandSender->mListInterfaces.empty())
- return true;
- return false;
+bool CommandInterfaceBackdoor::unloadPlugins(CommandSender *CommandSender)
+{
+ assert(CommandSender != NULL);
+ CommandSender->unloadLibraries();
+ CommandSender->mListInterfaces.clear();
+ if (CommandSender->mListInterfaces.empty())
+ return true;
+ return false;
}
-bool CommandInterfaceBackdoor::injectInterface(CommandSender *CommandSender,
- CommandSendInterface *CommandSendInterface) {
- assert(CommandSender != NULL);
- assert(CommandSendInterface != NULL);
- CommandSender->mListInterfaces.push_back(CommandSendInterface);
- return true; //todo: check if it worked
+bool CommandInterfaceBackdoor::injectInterface(CommandSender *CommandSender, CommandSendInterface *CommandSendInterface)
+{
+ assert(CommandSender != NULL);
+ assert(CommandSendInterface != NULL);
+ CommandSender->mListInterfaces.push_back(CommandSendInterface);
+ return true; //todo: check if it worked
}
-RoutingInterfaceBackdoor::RoutingInterfaceBackdoor() {
+RoutingInterfaceBackdoor::RoutingInterfaceBackdoor()
+{
}
-RoutingInterfaceBackdoor::~RoutingInterfaceBackdoor() {
+RoutingInterfaceBackdoor::~RoutingInterfaceBackdoor()
+{
}
-bool RoutingInterfaceBackdoor::unloadPlugins(RoutingSender *RoutingSender) {
- assert(RoutingSender != NULL);
- RoutingSender->unloadLibraries();
- RoutingSender->mListInterfaces.clear();
- if (RoutingSender->mListInterfaces.empty())
- return true;
- return false;
+bool RoutingInterfaceBackdoor::unloadPlugins(RoutingSender *RoutingSender)
+{
+ assert(RoutingSender != NULL);
+ RoutingSender->unloadLibraries();
+ RoutingSender->mListInterfaces.clear();
+ if (RoutingSender->mListInterfaces.empty())
+ return true;
+ return false;
}
-bool RoutingInterfaceBackdoor::injectInterface(RoutingSender *RoutingSender,
- RoutingSendInterface *newInterface, const std::string& busname) {
- assert(RoutingSender != NULL);
- assert(newInterface != NULL);
-
- RoutingSender::InterfaceNamePairs newInterfacePair;
- newInterfacePair.routingInterface = newInterface;
- newInterfacePair.busName = busname;
- RoutingSender->mListInterfaces.push_back(newInterfacePair);
- return true; //todo: check if it worked
+bool RoutingInterfaceBackdoor::injectInterface(RoutingSender *RoutingSender, RoutingSendInterface *newInterface, const std::string& busname)
+{
+ assert(RoutingSender != NULL);
+ assert(newInterface != NULL);
+
+ RoutingSender::InterfaceNamePairs newInterfacePair;
+ newInterfacePair.routingInterface = newInterface;
+ newInterfacePair.busName = busname;
+ RoutingSender->mListInterfaces.push_back(newInterfacePair);
+ return true; //todo: check if it worked
}
-ControlInterfaceBackdoor::ControlInterfaceBackdoor() {}
+ControlInterfaceBackdoor::ControlInterfaceBackdoor()
+{
+}
-ControlInterfaceBackdoor::~ControlInterfaceBackdoor() {}
+ControlInterfaceBackdoor::~ControlInterfaceBackdoor()
+{
+}
bool ControlInterfaceBackdoor::replaceController(ControlSender *controlSender, ControlSendInterface *newController)
{
- controlSender->mController=newController;
- return true;
+ controlSender->mController = newController;
+ return true;
}
-
//int GetRandomNumber(int nLow, int nHigh) {
// return (rand() % (nHigh - nLow + 1)) + nLow;
//}
-bool equalSoundProperty(const am_SoundProperty_s a,
- const am_SoundProperty_s b) {
- return (a.type == b.type && a.value == b.value);
-}
-
-bool equalMainSoundProperty(const am_MainSoundProperty_s a,
- const am_MainSoundProperty_s b) {
- return (a.type == b.type && a.value == b.value);
-}
-
-bool equalRoutingElement(const am_RoutingElement_s a,
- const am_RoutingElement_s b) {
- return (a.connectionFormat == b.connectionFormat && a.domainID == b.domainID
- && a.sinkID == b.sinkID && a.sourceID == b.sourceID);
-}
-
-bool equalClassProperties(const am_ClassProperty_s a,
- const am_ClassProperty_s b) {
- return (a.classProperty == b.classProperty && a.value == b.value);
-}
-
-std::string int2string(int i) {
- std::stringstream out;
- out << i;
- return out.str();
-}
-
-bool CommonFunctions::compareSource(
- std::vector<am_Source_s>::iterator listIterator,
- const am_Source_s& sourceData) {
- return (listIterator->available.availability
- == sourceData.available.availability)
- && (listIterator->available.availabilityReason
- == sourceData.available.availabilityReason)
- && (listIterator->sourceClassID == sourceData.sourceClassID)
- && (listIterator->domainID == sourceData.domainID)
- && (listIterator->interruptState == sourceData.interruptState)
- && (listIterator->visible == sourceData.visible)
- && (listIterator->name.compare(sourceData.name) == 0)
- && (listIterator->volume == sourceData.volume)
- && std::equal(listIterator->listConnectionFormats.begin(),
- listIterator->listConnectionFormats.end(),
- sourceData.listConnectionFormats.begin())
- && std::equal(listIterator->listMainSoundProperties.begin(),
- listIterator->listMainSoundProperties.end(),
- sourceData.listMainSoundProperties.begin(),
- equalMainSoundProperty)
- && std::equal(listIterator->listSoundProperties.begin(),
- listIterator->listSoundProperties.end(),
- sourceData.listSoundProperties.begin(), equalSoundProperty);
-}
-
-bool CommonFunctions::compareSink(std::vector<am_Sink_s>::iterator listIterator,
- const am_Sink_s& sinkData) {
- return (listIterator->available.availability
- == sinkData.available.availability)
- && (listIterator->available.availabilityReason
- == sinkData.available.availabilityReason)
- && (listIterator->sinkClassID == sinkData.sinkClassID)
- && (listIterator->domainID == sinkData.domainID)
- && (listIterator->mainVolume == sinkData.mainVolume)
- && (listIterator->muteState == sinkData.muteState)
- && (listIterator->visible == sinkData.visible)
- && (listIterator->name.compare(sinkData.name) == 0)
- && (listIterator->volume == sinkData.volume)
- && std::equal(listIterator->listConnectionFormats.begin(),
- listIterator->listConnectionFormats.end(),
- sinkData.listConnectionFormats.begin())
- && std::equal(listIterator->listMainSoundProperties.begin(),
- listIterator->listMainSoundProperties.end(),
- sinkData.listMainSoundProperties.begin(),
- equalMainSoundProperty)
- && std::equal(listIterator->listSoundProperties.begin(),
- listIterator->listSoundProperties.end(),
- sinkData.listSoundProperties.begin(), equalSoundProperty);
-}
-
-bool CommonFunctions::compareGateway(
- std::vector<am_Gateway_s>::iterator listIterator,
- const am_Gateway_s& gatewayData) {
- return (listIterator->name.compare(gatewayData.name) == 0)
- && (listIterator->sinkID == gatewayData.sinkID)
- && (listIterator->sourceID == gatewayData.sourceID)
- && (listIterator->controlDomainID == gatewayData.controlDomainID)
- && (listIterator->domainSinkID == gatewayData.domainSinkID)
- && (listIterator->domainSourceID == gatewayData.domainSourceID)
- && std::equal(listIterator->convertionMatrix.begin(),
- listIterator->convertionMatrix.end(),
- gatewayData.convertionMatrix.begin())
- && std::equal(listIterator->listSourceFormats.begin(),
- listIterator->listSourceFormats.end(),
- gatewayData.listSourceFormats.begin())
- && std::equal(listIterator->listSinkFormats.begin(),
- listIterator->listSinkFormats.end(),
- gatewayData.listSinkFormats.begin());
-}
-
-bool CommonFunctions::compareGateway1(const am_Gateway_s gateway1,
- const am_Gateway_s gatewayData) {
- return (gateway1.name.compare(gatewayData.name) == 0)
- && (gateway1.sinkID == gatewayData.sinkID)
- && (gateway1.sourceID == gatewayData.sourceID)
- && (gateway1.controlDomainID == gatewayData.controlDomainID)
- && (gateway1.domainSinkID == gatewayData.domainSinkID)
- && (gateway1.domainSourceID == gatewayData.domainSourceID)
- && std::equal(gateway1.convertionMatrix.begin(),
- gateway1.convertionMatrix.end(),
- gatewayData.convertionMatrix.begin())
- && std::equal(gateway1.listSourceFormats.begin(),
- gateway1.listSourceFormats.end(),
- gatewayData.listSourceFormats.begin())
- && std::equal(gateway1.listSinkFormats.begin(),
- gateway1.listSinkFormats.end(),
- gatewayData.listSinkFormats.begin());
-}
-
-bool CommonFunctions::compareSinkMainSink(
- std::vector<am_SinkType_s>::iterator listIterator,
- const std::vector<am_Sink_s>& sinkList) {
- std::vector<am_Sink_s>::const_iterator sinkListIterator = sinkList.begin();
- for (; sinkListIterator < sinkList.end(); ++sinkListIterator) {
- if (listIterator->sinkID == sinkListIterator->sinkID) {
- return (listIterator->name.compare(sinkListIterator->name) == 0)
- && (listIterator->availability.availability
- == sinkListIterator->available.availability)
- && (listIterator->availability.availabilityReason
- == sinkListIterator->available.availabilityReason)
- && (listIterator->muteState == sinkListIterator->muteState)
- && (listIterator->volume == sinkListIterator->mainVolume)
- && (listIterator->sinkClassID
- == sinkListIterator->sinkClassID);
- }
- }
- return false;
-}
-
-bool CommonFunctions::compareSinkMainSource(
- std::vector<am_SourceType_s>::iterator listIterator,
- const std::vector<am_Source_s>& sourceList) {
- std::vector<am_Source_s>::const_iterator sinkListIterator =
- sourceList.begin();
- for (; sinkListIterator < sourceList.end(); ++sinkListIterator) {
- if (listIterator->sourceID == sinkListIterator->sourceID) {
- return (listIterator->name.compare(sinkListIterator->name) == 0)
- && (listIterator->availability.availability
- == sinkListIterator->available.availability)
- && (listIterator->availability.availabilityReason
- == sinkListIterator->available.availabilityReason)
- && (listIterator->sourceClassID
- == sinkListIterator->sourceClassID);
- }
- }
- return false;
-}
-
-std::vector<am_ConnectionFormat_e> CommonFunctions::getStandardConnectionFormatList() {
- std::vector < am_ConnectionFormat_e > list;
- list.push_back(CF_ANALOG);
- list.push_back(CF_STEREO);
- return list;
-}
-
-std::vector<am_SoundProperty_s> CommonFunctions::getStandardSoundPropertyList() {
- std::vector < am_SoundProperty_s > soundPropertyList;
- am_SoundProperty_s soundProperty;
- soundProperty.type = SP_BASS;
- soundProperty.value = 23;
- soundPropertyList.push_back(soundProperty);
- soundProperty.type = SP_MID;
- soundProperty.value = 2;
- soundPropertyList.push_back(soundProperty);
- return soundPropertyList;
-}
-
-std::vector<am_MainSoundProperty_s> CommonFunctions::getStandardMainSoundPropertyList() {
- std::vector < am_MainSoundProperty_s > mainSoundPropertyList;
- am_MainSoundProperty_s mainSoundProperty;
- mainSoundProperty.type = MSP_NAVIGATION_OFFSET;
- mainSoundProperty.value = 23;
- mainSoundPropertyList.push_back(mainSoundProperty);
- mainSoundProperty.type = MSP_TEST;
- mainSoundProperty.value = 3;
- mainSoundPropertyList.push_back(mainSoundProperty);
- return mainSoundPropertyList;
-}
-
-void CommonFunctions::createSink(am_Sink_s& sink) const {
- sink.name = "AnySink";
- sink.domainID = 4;
- sink.available.availability = A_AVAILABLE;
- sink.available.availabilityReason = AR_NEWMEDIA;
- sink.sinkClassID = 1;
- sink.listConnectionFormats = getStandardConnectionFormatList();
- sink.listSoundProperties = getStandardSoundPropertyList();
- sink.listMainSoundProperties = getStandardMainSoundPropertyList();
- sink.mainVolume = 12;
- sink.muteState = MS_UNMUTED;
- sink.visible = true;
- sink.volume = 23;
- sink.sinkID = 0;
-}
-
-void CommonFunctions::createSource(am_Source_s& source) const {
- source.name = "AnySource";
- source.domainID = 4;
- source.available.availability = A_AVAILABLE;
- source.available.availabilityReason = AR_NEWMEDIA;
- source.sourceClassID = 1;
- source.listConnectionFormats = getStandardConnectionFormatList();
- source.listSoundProperties = getStandardSoundPropertyList();
- source.listMainSoundProperties = getStandardMainSoundPropertyList();
- source.interruptState = IS_OFF;
- source.visible = true;
- source.volume = 23;
- source.sourceID = 0;
- source.sourceState = SS_ON;
-}
-
-void CommonFunctions::createDomain(am_Domain_s & domain) const {
-
- domain.domainID = 0;
- domain.name = "AnyDomain";
- domain.nodename = "AnyNode";
- domain.busname = "AnyBusname";
- domain.complete = true;
- domain.early = true;
- domain.state = DS_CONTROLLED;
-}
-
-void CommonFunctions::createGateway(am_Gateway_s & gateway) {
- gateway.name = "AnyGateway";
- gateway.sinkID = 1;
- gateway.sourceID = 2;
- gateway.controlDomainID = 1;
- gateway.domainSinkID = 3;
- gateway.domainSourceID = 4;
- gateway.convertionMatrix = getStandardConvertionMatrix();
- gateway.listSourceFormats = getStandardConnectionFormatList();
- gateway.listSinkFormats = getStandardConnectionFormatList();
- gateway.gatewayID = 0;
-
-}
-
-void CommonFunctions::createConnection(am_Connection_s & connection) const {
- connection.connectionID = 0;
- connection.sinkID = 1;
- connection.sourceID = 2;
- connection.delay = -1;
- connection.connectionFormat = CF_ANALOG;
-}
-
-void CommonFunctions::createMainConnection(am_MainConnection_s & mainConnection,
- am_Route_s route) const {
- mainConnection.connectionID = 0;
- mainConnection.connectionState = CS_CONNECTED;
- mainConnection.route = route;
- mainConnection.delay = -1;
-}
-
-std::vector<bool> CommonFunctions::getStandardConvertionMatrix() {
- std::vector<bool> convMatrix;
- convMatrix.push_back(true);
- convMatrix.push_back(false);
- convMatrix.push_back(true);
- convMatrix.push_back(false);
- convMatrix.push_back(true);
- convMatrix.push_back(true);
- return convMatrix;
-}
-
-void CommonFunctions::connectionList2RoutingList(
- std::vector<am_RoutingElement_s> & routingList,
- const std::vector<am_Connection_s>& connectionList) {
- am_RoutingElement_s routingElement;
- std::vector<am_Connection_s>::const_iterator cIterator =
- connectionList.begin();
- for (; cIterator < connectionList.end(); ++cIterator) {
- routingElement.sinkID = cIterator->sinkID;
- routingElement.sourceID = cIterator->sourceID;
- routingElement.connectionFormat = cIterator->connectionFormat;
- routingElement.domainID = 4; //todo: make this test read out the real value
- routingList.push_back(routingElement);
- }
+bool equalSoundProperty(const am_SoundProperty_s a, const am_SoundProperty_s b)
+{
+ return (a.type == b.type && a.value == b.value);
+}
+
+bool equalMainSoundProperty(const am_MainSoundProperty_s a, const am_MainSoundProperty_s b)
+{
+ return (a.type == b.type && a.value == b.value);
+}
+
+bool equalRoutingElement(const am_RoutingElement_s a, const am_RoutingElement_s b)
+{
+ return (a.connectionFormat == b.connectionFormat && a.domainID == b.domainID && a.sinkID == b.sinkID && a.sourceID == b.sourceID);
}
+bool equalClassProperties(const am_ClassProperty_s a, const am_ClassProperty_s b)
+{
+ return (a.classProperty == b.classProperty && a.value == b.value);
+}
+std::string int2string(int i)
+{
+ std::stringstream out;
+ out << i;
+ return out.str();
+}
+bool CommonFunctions::compareSource(std::vector<am_Source_s>::iterator listIterator, const am_Source_s& sourceData)
+{
+ return (listIterator->available.availability == sourceData.available.availability) && (listIterator->available.availabilityReason == sourceData.available.availabilityReason) && (listIterator->sourceClassID == sourceData.sourceClassID) && (listIterator->domainID == sourceData.domainID) && (listIterator->interruptState == sourceData.interruptState) && (listIterator->visible == sourceData.visible) && (listIterator->name.compare(sourceData.name) == 0) && (listIterator->volume == sourceData.volume) && std::equal(listIterator->listConnectionFormats.begin(), listIterator->listConnectionFormats.end(), sourceData.listConnectionFormats.begin())
+ && std::equal(listIterator->listMainSoundProperties.begin(), listIterator->listMainSoundProperties.end(), sourceData.listMainSoundProperties.begin(), equalMainSoundProperty) && std::equal(listIterator->listSoundProperties.begin(), listIterator->listSoundProperties.end(), sourceData.listSoundProperties.begin(), equalSoundProperty);
+}
+bool CommonFunctions::compareSink(std::vector<am_Sink_s>::iterator listIterator, const am_Sink_s& sinkData)
+{
+ return (listIterator->available.availability == sinkData.available.availability) && (listIterator->available.availabilityReason == sinkData.available.availabilityReason) && (listIterator->sinkClassID == sinkData.sinkClassID) && (listIterator->domainID == sinkData.domainID) && (listIterator->mainVolume == sinkData.mainVolume) && (listIterator->muteState == sinkData.muteState) && (listIterator->visible == sinkData.visible) && (listIterator->name.compare(sinkData.name) == 0) && (listIterator->volume == sinkData.volume) && std::equal(listIterator->listConnectionFormats.begin(), listIterator->listConnectionFormats.end(), sinkData.listConnectionFormats.begin())
+ && std::equal(listIterator->listMainSoundProperties.begin(), listIterator->listMainSoundProperties.end(), sinkData.listMainSoundProperties.begin(), equalMainSoundProperty) && std::equal(listIterator->listSoundProperties.begin(), listIterator->listSoundProperties.end(), sinkData.listSoundProperties.begin(), equalSoundProperty);
+}
+bool CommonFunctions::compareGateway(std::vector<am_Gateway_s>::iterator listIterator, const am_Gateway_s& gatewayData)
+{
+ return (listIterator->name.compare(gatewayData.name) == 0) && (listIterator->sinkID == gatewayData.sinkID) && (listIterator->sourceID == gatewayData.sourceID) && (listIterator->controlDomainID == gatewayData.controlDomainID) && (listIterator->domainSinkID == gatewayData.domainSinkID) && (listIterator->domainSourceID == gatewayData.domainSourceID) && std::equal(listIterator->convertionMatrix.begin(), listIterator->convertionMatrix.end(), gatewayData.convertionMatrix.begin()) && std::equal(listIterator->listSourceFormats.begin(), listIterator->listSourceFormats.end(), gatewayData.listSourceFormats.begin()) && std::equal(listIterator->listSinkFormats.begin(), listIterator->listSinkFormats.end(), gatewayData.listSinkFormats.begin());
+}
+bool CommonFunctions::compareGateway1(const am_Gateway_s gateway1, const am_Gateway_s gatewayData)
+{
+ return (gateway1.name.compare(gatewayData.name) == 0) && (gateway1.sinkID == gatewayData.sinkID) && (gateway1.sourceID == gatewayData.sourceID) && (gateway1.controlDomainID == gatewayData.controlDomainID) && (gateway1.domainSinkID == gatewayData.domainSinkID) && (gateway1.domainSourceID == gatewayData.domainSourceID) && std::equal(gateway1.convertionMatrix.begin(), gateway1.convertionMatrix.end(), gatewayData.convertionMatrix.begin()) && std::equal(gateway1.listSourceFormats.begin(), gateway1.listSourceFormats.end(), gatewayData.listSourceFormats.begin()) && std::equal(gateway1.listSinkFormats.begin(), gateway1.listSinkFormats.end(), gatewayData.listSinkFormats.begin());
+}
+bool CommonFunctions::compareSinkMainSink(std::vector<am_SinkType_s>::iterator listIterator, const std::vector<am_Sink_s>& sinkList)
+{
+ std::vector<am_Sink_s>::const_iterator sinkListIterator = sinkList.begin();
+ for (; sinkListIterator < sinkList.end(); ++sinkListIterator)
+ {
+ if (listIterator->sinkID == sinkListIterator->sinkID)
+ {
+ return (listIterator->name.compare(sinkListIterator->name) == 0) && (listIterator->availability.availability == sinkListIterator->available.availability) && (listIterator->availability.availabilityReason == sinkListIterator->available.availabilityReason) && (listIterator->muteState == sinkListIterator->muteState) && (listIterator->volume == sinkListIterator->mainVolume) && (listIterator->sinkClassID == sinkListIterator->sinkClassID);
+ }
+ }
+ return false;
+}
+
+bool CommonFunctions::compareSinkMainSource(std::vector<am_SourceType_s>::iterator listIterator, const std::vector<am_Source_s>& sourceList)
+{
+ std::vector<am_Source_s>::const_iterator sinkListIterator = sourceList.begin();
+ for (; sinkListIterator < sourceList.end(); ++sinkListIterator)
+ {
+ if (listIterator->sourceID == sinkListIterator->sourceID)
+ {
+ return (listIterator->name.compare(sinkListIterator->name) == 0) && (listIterator->availability.availability == sinkListIterator->available.availability) && (listIterator->availability.availabilityReason == sinkListIterator->available.availabilityReason) && (listIterator->sourceClassID == sinkListIterator->sourceClassID);
+ }
+ }
+ return false;
+}
+bool CommonFunctions::compareRoute(am_Route_s a, am_Route_s b)
+{
+ bool retVal = true;
+ std::vector<am_RoutingElement_s>::iterator itA = a.route.begin(), itB = b.route.begin();
+ retVal &= a.sourceID == b.sourceID;
+ retVal &= a.sinkID == b.sinkID;
+ for (; itA != a.route.end(); ++itA)
+ {
+ retVal &= itA->sinkID == itB->sinkID;
+ retVal &= itA->sourceID == itB->sourceID;
+ retVal &= itA->connectionFormat == itB->connectionFormat;
+ retVal &= itA->domainID == itB->domainID;
+ itB++;
+ }
+ return retVal;
+}
+
+std::vector<am_ConnectionFormat_e> CommonFunctions::getStandardConnectionFormatList()
+{
+ std::vector<am_ConnectionFormat_e> list;
+ list.push_back(CF_ANALOG);
+ list.push_back(CF_STEREO);
+ return list;
+}
+
+std::vector<am_SoundProperty_s> CommonFunctions::getStandardSoundPropertyList()
+{
+ std::vector<am_SoundProperty_s> soundPropertyList;
+ am_SoundProperty_s soundProperty;
+ soundProperty.type = SP_BASS;
+ soundProperty.value = 23;
+ soundPropertyList.push_back(soundProperty);
+ soundProperty.type = SP_MID;
+ soundProperty.value = 2;
+ soundPropertyList.push_back(soundProperty);
+ return soundPropertyList;
+}
+
+std::vector<am_MainSoundProperty_s> CommonFunctions::getStandardMainSoundPropertyList()
+{
+ std::vector<am_MainSoundProperty_s> mainSoundPropertyList;
+ am_MainSoundProperty_s mainSoundProperty;
+ mainSoundProperty.type = MSP_NAVIGATION_OFFSET;
+ mainSoundProperty.value = 23;
+ mainSoundPropertyList.push_back(mainSoundProperty);
+ mainSoundProperty.type = MSP_TEST;
+ mainSoundProperty.value = 3;
+ mainSoundPropertyList.push_back(mainSoundProperty);
+ return mainSoundPropertyList;
+}
+
+void CommonFunctions::createSink(am_Sink_s& sink) const
+{
+ sink.name = "AnySink";
+ sink.domainID = 4;
+ sink.available.availability = A_AVAILABLE;
+ sink.available.availabilityReason = AR_NEWMEDIA;
+ sink.sinkClassID = 1;
+ sink.listConnectionFormats = getStandardConnectionFormatList();
+ sink.listSoundProperties = getStandardSoundPropertyList();
+ sink.listMainSoundProperties = getStandardMainSoundPropertyList();
+ sink.mainVolume = 12;
+ sink.muteState = MS_UNMUTED;
+ sink.visible = true;
+ sink.volume = 23;
+ sink.sinkID = 0;
+}
+
+void CommonFunctions::createSource(am_Source_s& source) const
+{
+ source.name = "AnySource";
+ source.domainID = 4;
+ source.available.availability = A_AVAILABLE;
+ source.available.availabilityReason = AR_NEWMEDIA;
+ source.sourceClassID = 1;
+ source.listConnectionFormats = getStandardConnectionFormatList();
+ source.listSoundProperties = getStandardSoundPropertyList();
+ source.listMainSoundProperties = getStandardMainSoundPropertyList();
+ source.interruptState = IS_OFF;
+ source.visible = true;
+ source.volume = 23;
+ source.sourceID = 0;
+ source.sourceState = SS_ON;
+}
+
+void CommonFunctions::createDomain(am_Domain_s & domain) const
+{
+
+ domain.domainID = 0;
+ domain.name = "AnyDomain";
+ domain.nodename = "AnyNode";
+ domain.busname = "AnyBusname";
+ domain.complete = true;
+ domain.early = true;
+ domain.state = DS_CONTROLLED;
+}
+
+void CommonFunctions::createGateway(am_Gateway_s & gateway)
+{
+ gateway.name = "AnyGateway";
+ gateway.sinkID = 1;
+ gateway.sourceID = 2;
+ gateway.controlDomainID = 1;
+ gateway.domainSinkID = 3;
+ gateway.domainSourceID = 4;
+ gateway.convertionMatrix = getStandardConvertionMatrix();
+ gateway.listSourceFormats = getStandardConnectionFormatList();
+ gateway.listSinkFormats = getStandardConnectionFormatList();
+ gateway.gatewayID = 0;
+
+}
+
+void CommonFunctions::createConnection(am_Connection_s & connection) const
+{
+ connection.connectionID = 0;
+ connection.sinkID = 1;
+ connection.sourceID = 2;
+ connection.delay = -1;
+ connection.connectionFormat = CF_ANALOG;
+}
+
+void CommonFunctions::createMainConnection(am_MainConnection_s & mainConnection, am_Route_s route) const
+{
+ mainConnection.connectionID = 0;
+ mainConnection.connectionState = CS_CONNECTED;
+ mainConnection.route = route;
+ mainConnection.delay = -1;
+}
+
+std::vector<bool> CommonFunctions::getStandardConvertionMatrix()
+{
+ std::vector<bool> convMatrix;
+ convMatrix.push_back(true);
+ convMatrix.push_back(false);
+ convMatrix.push_back(true);
+ convMatrix.push_back(false);
+ convMatrix.push_back(true);
+ convMatrix.push_back(true);
+ return convMatrix;
+}
+
+void CommonFunctions::connectionList2RoutingList(std::vector<am_RoutingElement_s> & routingList, const std::vector<am_Connection_s>& connectionList)
+{
+ am_RoutingElement_s routingElement;
+ std::vector<am_Connection_s>::const_iterator cIterator = connectionList.begin();
+ for (; cIterator < connectionList.end(); ++cIterator)
+ {
+ routingElement.sinkID = cIterator->sinkID;
+ routingElement.sourceID = cIterator->sourceID;
+ routingElement.connectionFormat = cIterator->connectionFormat;
+ routingElement.domainID = 4; //todo: make this test read out the real value
+ routingList.push_back(routingElement);
+ }
+}
diff --git a/AudioManagerDaemon/test/CommonFunctions.h b/AudioManagerDaemon/test/CommonFunctions.h
index af6d43b..7bc7e04 100644
--- a/AudioManagerDaemon/test/CommonFunctions.h
+++ b/AudioManagerDaemon/test/CommonFunctions.h
@@ -1,91 +1,92 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file CommonFunctions.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file CommonFunctions.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#ifndef COMMONHEADERS_H_
#define COMMONHEADERS_H_
#include "audiomanagertypes.h"
-namespace am {
+namespace am
+{
class CommonFunctions
{
public:
- static std::vector<am_ConnectionFormat_e> getStandardConnectionFormatList();
- static std::vector<am_SoundProperty_s> getStandardSoundPropertyList();
- static std::vector<am_MainSoundProperty_s> getStandardMainSoundPropertyList();
- static std::vector<bool> getStandardConvertionMatrix();
- bool compareSource(std::vector<am_Source_s>::iterator listIterator, const am_Source_s& sourceData);
- bool compareSink(std::vector<am_Sink_s>::iterator listIterator, const am_Sink_s& sinkData);
- bool compareGateway(std::vector<am_Gateway_s>::iterator listIterator, const am_Gateway_s& gatewayData);
- bool compareGateway1(const am_Gateway_s gateway1, const am_Gateway_s gatewayData);
- bool compareSinkMainSink(std::vector<am_SinkType_s>::iterator listIterator, const std::vector<am_Sink_s>& sinkList);
- bool compareSinkMainSource(std::vector<am_SourceType_s>::iterator listIterator, const std::vector<am_Source_s>& sourceList);
- void createSink(am_Sink_s& sink) const;
- void createSource(am_Source_s& source) const ;
- void createDomain(am_Domain_s& domain) const;
- void createGateway(am_Gateway_s& gateway);
- void createConnection(am_Connection_s& connection) const ;
- void createMainConnection(am_MainConnection_s& mainConnection, am_Route_s route) const;
- void connectionList2RoutingList(std::vector<am_RoutingElement_s>& routingList, const std::vector<am_Connection_s>& connectionList);
+ static std::vector<am_ConnectionFormat_e> getStandardConnectionFormatList();
+ static std::vector<am_SoundProperty_s> getStandardSoundPropertyList();
+ static std::vector<am_MainSoundProperty_s> getStandardMainSoundPropertyList();
+ static std::vector<bool> getStandardConvertionMatrix();
+ bool compareSource(std::vector<am_Source_s>::iterator listIterator, const am_Source_s& sourceData);
+ bool compareSink(std::vector<am_Sink_s>::iterator listIterator, const am_Sink_s& sinkData);
+ bool compareGateway(std::vector<am_Gateway_s>::iterator listIterator, const am_Gateway_s& gatewayData);
+ bool compareGateway1(const am_Gateway_s gateway1, const am_Gateway_s gatewayData);
+ bool compareSinkMainSink(std::vector<am_SinkType_s>::iterator listIterator, const std::vector<am_Sink_s>& sinkList);
+ bool compareSinkMainSource(std::vector<am_SourceType_s>::iterator listIterator, const std::vector<am_Source_s>& sourceList);
+ bool compareRoute(am_Route_s a, am_Route_s b);
+ void createSink(am_Sink_s& sink) const;
+ void createSource(am_Source_s& source) const;
+ void createDomain(am_Domain_s& domain) const;
+ void createGateway(am_Gateway_s& gateway);
+ void createConnection(am_Connection_s& connection) const;
+ void createMainConnection(am_MainConnection_s& mainConnection, am_Route_s route) const;
+ void connectionList2RoutingList(std::vector<am_RoutingElement_s>& routingList, const std::vector<am_Connection_s>& connectionList);
- struct sortBySinkID
- {
- bool operator()(const am_RoutingElement_s & a, const am_RoutingElement_s & b) const
- {
- return (a.sinkID < b.sinkID);
- }
- };
+ struct sortBySinkID
+ {
+ bool operator()(const am_RoutingElement_s & a, const am_RoutingElement_s & b) const
+ {
+ return (a.sinkID < b.sinkID);
+ }
+ };
- struct sortByConnectionFormat
- {
- bool operator()(const am_ConnectionFormat_e & a, const am_ConnectionFormat_e & b) const
- {
- return (a < b);
- }
- };
+ struct sortByConnectionFormat
+ {
+ bool operator()(const am_ConnectionFormat_e & a, const am_ConnectionFormat_e & b) const
+ {
+ return (a < b);
+ }
+ };
- struct sortByMainSoundProperty
- {
- bool operator()(const am_MainSoundProperty_s & a, const am_MainSoundProperty_s & b) const
- {
- return (a.type > b.type);
- }
- };
+ struct sortByMainSoundProperty
+ {
+ bool operator()(const am_MainSoundProperty_s & a, const am_MainSoundProperty_s & b) const
+ {
+ return (a.type > b.type);
+ }
+ };
- struct sortBySoundProperty
- {
- bool operator()(const am_SoundProperty_s & a, const am_SoundProperty_s & b) const
- {
- return (a.type < b.type);
- }
- };
+ struct sortBySoundProperty
+ {
+ bool operator()(const am_SoundProperty_s & a, const am_SoundProperty_s & b) const
+ {
+ return (a.type < b.type);
+ }
+ };
};
}
-
#endif /* COMMONHEADERS_H_ */
diff --git a/AudioManagerDaemon/test/ControlInterfaceBackdoor.h b/AudioManagerDaemon/test/ControlInterfaceBackdoor.h
index b07f3ad..135bc48 100644
--- a/AudioManagerDaemon/test/ControlInterfaceBackdoor.h
+++ b/AudioManagerDaemon/test/ControlInterfaceBackdoor.h
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file ControlInterfaceBackdoor.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file ControlInterfaceBackdoor.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#ifndef CONTROLINTERFACEBACKDOOR_H_
#define CONTROLINTERFACEBACKDOOR_H_
@@ -29,15 +29,17 @@
#include "control/ControlSendInterface.h"
#include "ControlSender.h"
-namespace am {
+namespace am
+{
class ControlSender;
-class ControlInterfaceBackdoor {
+class ControlInterfaceBackdoor
+{
public:
- ControlInterfaceBackdoor();
- virtual ~ControlInterfaceBackdoor();
- bool replaceController(ControlSender *controlSender, ControlSendInterface *newController);
+ ControlInterfaceBackdoor();
+ virtual ~ControlInterfaceBackdoor();
+ bool replaceController(ControlSender *controlSender, ControlSendInterface *newController);
};
}
diff --git a/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h b/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h
index b7e7624..ff7ffdb 100644
--- a/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h
+++ b/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h
@@ -1,43 +1,45 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file RoutingInterfaceBackdoor.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file RoutingInterfaceBackdoor.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#ifndef ROUTINGINTERFACEBACKDOOR_H_
#define ROUTINGINTERFACEBACKDOOR_H_
#include "RoutingSender.h"
-namespace am {
+namespace am
+{
class RoutingSender;
-class RoutingInterfaceBackdoor {
+class RoutingInterfaceBackdoor
+{
public:
- RoutingInterfaceBackdoor();
- virtual ~RoutingInterfaceBackdoor();
- bool unloadPlugins(RoutingSender *RoutingSender);
- bool injectInterface(RoutingSender *RoutingSender, RoutingSendInterface *newInterface, const std::string& busname);
+ RoutingInterfaceBackdoor();
+ virtual ~RoutingInterfaceBackdoor();
+ bool unloadPlugins(RoutingSender *RoutingSender);
+ bool injectInterface(RoutingSender *RoutingSender, RoutingSendInterface *newInterface, const std::string& busname);
};
}
diff --git a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp
index 2efcc64..5d3a4f1 100644
--- a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp
+++ b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file controlInterfaceTest.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file controlInterfaceTest.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#include "controlInterfaceTest.h"
#include <algorithm>
@@ -33,26 +33,26 @@ using namespace testing;
DLT_DECLARE_CONTEXT(DLT_CONTEXT)
-controlInterfaceTest::controlInterfaceTest()
- :pDBusWrapper((DBusWrapper*)1), //to get rid of assert
- plistCommandPluginDirs(),
- plistRoutingPluginDirs(),
- pDatabaseHandler(std::string(":memory:")),
- pRoutingSender(plistRoutingPluginDirs),
- pCommandSender(plistCommandPluginDirs),
- pMockControlInterface(),
- pMockRoutingInterface(),
- pControlSender(std::string("")),
- pRoutingInterfaceBackdoor(),
- pCommandInterfaceBackdoor(),
- pControlInterfaceBackdoor(),
- pDatabaseObserver(&pCommandSender,&pRoutingSender),
- pControlReceiver(&pDatabaseHandler,&pRoutingSender,&pCommandSender),
- pRoutingReceiver(&pDatabaseHandler,&pRoutingSender,&pControlSender,pDBusWrapper)
+controlInterfaceTest::controlInterfaceTest() :
+ pDBusWrapper((DBusWrapper*) 1), //
+ plistCommandPluginDirs(), //
+ plistRoutingPluginDirs(), //
+ pDatabaseHandler(std::string(":memory:")), //
+ pRoutingSender(plistRoutingPluginDirs), //
+ pCommandSender(plistCommandPluginDirs), //
+ pMockControlInterface(), //
+ pMockRoutingInterface(), //
+ pControlSender(std::string("")), //
+ pRoutingInterfaceBackdoor(), //
+ pCommandInterfaceBackdoor(), //
+ pControlInterfaceBackdoor(), //
+ pDatabaseObserver(&pCommandSender, &pRoutingSender), //
+ pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), //
+ pRoutingReceiver(&pDatabaseHandler, &pRoutingSender, &pControlSender, pDBusWrapper)
{
- pDatabaseHandler.registerObserver(&pDatabaseObserver);
- pControlInterfaceBackdoor.replaceController(&pControlSender,&pMockControlInterface);
- pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender,&pMockRoutingInterface,"mock");
+ pDatabaseHandler.registerObserver(&pDatabaseObserver);
+ pControlInterfaceBackdoor.replaceController(&pControlSender, &pMockControlInterface);
+ pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender, &pMockRoutingInterface, "mock");
}
@@ -62,473 +62,472 @@ controlInterfaceTest::~controlInterfaceTest()
void controlInterfaceTest::SetUp()
{
- DLT_REGISTER_APP("Rtest","RoutingInterfacetest");
- DLT_REGISTER_CONTEXT(DLT_CONTEXT,"Main","Main Context");
- DLT_LOG(DLT_CONTEXT,DLT_LOG_INFO, DLT_STRING("RoutingSendInterface Test started "));
+ DLT_REGISTER_APP("Rtest", "RoutingInterfacetest");
+ DLT_REGISTER_CONTEXT(DLT_CONTEXT, "Main", "Main Context");
+ DLT_LOG(DLT_CONTEXT, DLT_LOG_INFO, DLT_STRING("RoutingSendInterface Test started "));
}
void controlInterfaceTest::TearDown()
{
- DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
+ DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
}
TEST_F(controlInterfaceTest,registerDomain)
{
- am_Domain_s domain;
- am_domainID_t domainID;
- pCF.createDomain(domain);
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ pCF.createDomain(domain);
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemRegisterDomain(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2),Return(E_OK)));
- ASSERT_EQ(E_OK,pRoutingReceiver.registerDomain(domain,domainID));
- ASSERT_EQ(domainID,2);
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemRegisterDomain(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2), Return(E_OK)));
+ ASSERT_EQ(E_OK, pRoutingReceiver.registerDomain(domain,domainID));
+ ASSERT_EQ(domainID, 2);
}
TEST_F(controlInterfaceTest,deregisterDomain)
{
- am_domainID_t domainID=34;
+ am_domainID_t domainID = 34;
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemDeregisterDomain(34)).WillRepeatedly(Return(E_OK));
- ASSERT_EQ(E_OK,pRoutingReceiver.deregisterDomain(domainID));
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemDeregisterDomain(34)).WillRepeatedly(Return(E_OK));
+ ASSERT_EQ(E_OK, pRoutingReceiver.deregisterDomain(domainID));
}
TEST_F(controlInterfaceTest,registerSink)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- pCF.createSink(sink);
-
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemRegisterSink(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2),Return(E_OK)));
- ASSERT_EQ(E_OK,pRoutingReceiver.registerSink(sink,sinkID));
- ASSERT_EQ(sinkID,2);
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemRegisterSink(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2), Return(E_OK)));
+ ASSERT_EQ(E_OK, pRoutingReceiver.registerSink(sink,sinkID));
+ ASSERT_EQ(sinkID, 2);
}
TEST_F(controlInterfaceTest,deregisterSink)
{
- am_sinkID_t sinkID=12;
+ am_sinkID_t sinkID = 12;
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemDeregisterSink(12)).WillRepeatedly(Return(E_OK));
- ASSERT_EQ(E_OK,pRoutingReceiver.deregisterSink(sinkID));
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemDeregisterSink(12)).WillRepeatedly(Return(E_OK));
+ ASSERT_EQ(E_OK, pRoutingReceiver.deregisterSink(sinkID));
}
TEST_F(controlInterfaceTest,registerSource)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- pCF.createSource(source);
-
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemRegisterSource(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2),Return(E_OK)));
- ASSERT_EQ(E_OK,pRoutingReceiver.registerSource(source,sourceID));
- ASSERT_EQ(sourceID,2);
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemRegisterSource(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2), Return(E_OK)));
+ ASSERT_EQ(E_OK, pRoutingReceiver.registerSource(source,sourceID));
+ ASSERT_EQ(sourceID, 2);
}
TEST_F(controlInterfaceTest,deregisterSource)
{
- am_sourceID_t sourceID=12;
+ am_sourceID_t sourceID = 12;
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemDeregisterSource(12)).WillRepeatedly(Return(E_OK));
- ASSERT_EQ(E_OK,pRoutingReceiver.deregisterSource(sourceID));
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemDeregisterSource(12)).WillRepeatedly(Return(E_OK));
+ ASSERT_EQ(E_OK, pRoutingReceiver.deregisterSource(sourceID));
}
TEST_F(controlInterfaceTest,registerGateway)
{
- am_Gateway_s gateway;
- am_gatewayID_t gatewayID;
- pCF.createGateway(gateway);
-
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemRegisterGateway(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2),Return(E_OK)));
- ASSERT_EQ(E_OK,pRoutingReceiver.registerGateway(gateway,gatewayID));
- ASSERT_EQ(gatewayID,2);
+ am_Gateway_s gateway;
+ am_gatewayID_t gatewayID;
+ pCF.createGateway(gateway);
+
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemRegisterGateway(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2), Return(E_OK)));
+ ASSERT_EQ(E_OK, pRoutingReceiver.registerGateway(gateway,gatewayID));
+ ASSERT_EQ(gatewayID, 2);
}
TEST_F(controlInterfaceTest,deregisterGateway)
{
- am_gatewayID_t gatewayID=12;
+ am_gatewayID_t gatewayID = 12;
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemDeregisterGateway(12)).WillRepeatedly(Return(E_OK));
- ASSERT_EQ(E_OK,pRoutingReceiver.deregisterGateway(gatewayID));
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemDeregisterGateway(12)).WillRepeatedly(Return(E_OK));
+ ASSERT_EQ(E_OK, pRoutingReceiver.deregisterGateway(gatewayID));
}
-
TEST_F(controlInterfaceTest,ackConnect)
{
- am_connectionID_t connectionID;
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
- std::vector<am_Connection_s> connectionList;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
-
- //prepare the stage
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //when asyncConnect is called, we expect a call on the routingInterface
- EXPECT_CALL(pMockRoutingInterface,asyncConnect(_,1,2,2,CF_STEREO)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_STEREO,2,2));
-
- //The handle should have the correct type
- ASSERT_EQ(handle.handleType,H_CONNECT);
- ASSERT_EQ(handle.handle,1);
- ASSERT_EQ(connectionID,1);
-
- //The list of handles shall have the handle inside
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_EQ(handlesList[0].handle,handle.handle);
- ASSERT_EQ(handlesList[0].handleType,handle.handleType);
-
- //we check the list of connections - but it must be empty because the ack did not arrive yet
- ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
- ASSERT_TRUE(connectionList.empty());
-
- //finally we answer via the RoutingInterface and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckConnect(_,E_OK)).Times(1);
- pRoutingReceiver.ackConnect(handle,connectionID,E_OK);
-
- //the list of handles must be empty now
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //but the connection must be in the connectionlist
- ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
- ASSERT_TRUE(!connectionList.empty());
-
- //no we try the same, but do expect a no_change answer directly and no call because connection already exists
- ASSERT_EQ(E_ALREADY_EXISTS,pControlReceiver.connect(handle,connectionID,CF_STEREO,2,2));
+ am_connectionID_t connectionID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Connection_s> connectionList;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+
+ //prepare the stage
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ //when asyncConnect is called, we expect a call on the routingInterface
+ EXPECT_CALL(pMockRoutingInterface,asyncConnect(_,1,2,2,CF_STEREO)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.connect(handle,connectionID,CF_STEREO,2,2));
+
+ //The handle should have the correct type
+ ASSERT_EQ(handle.handleType, H_CONNECT);
+ ASSERT_EQ(handle.handle, 1);
+ ASSERT_EQ(connectionID, 1);
+
+ //The list of handles shall have the handle inside
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_EQ(handlesList[0].handle, handle.handle);
+ ASSERT_EQ(handlesList[0].handleType, handle.handleType);
+
+ //we check the list of connections - but it must be empty because the ack did not arrive yet
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ ASSERT_TRUE(connectionList.empty());
+
+ //finally we answer via the RoutingInterface and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckConnect(_,E_OK)).Times(1);
+ pRoutingReceiver.ackConnect(handle, connectionID, E_OK);
+
+ //the list of handles must be empty now
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //but the connection must be in the connectionlist
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ ASSERT_TRUE(!connectionList.empty());
+
+ //no we try the same, but do expect a no_change answer directly and no call because connection already exists
+ ASSERT_EQ(E_ALREADY_EXISTS, pControlReceiver.connect(handle,connectionID,CF_STEREO,2,2));
}
TEST_F(controlInterfaceTest,ackDisconnect)
{
- am_connectionID_t connectionID;
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
- std::vector<am_Connection_s> connectionList;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
-
- //prepare the stage
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //now we first need to connect, we expect a call on the routing interface
- EXPECT_CALL(pMockRoutingInterface,asyncConnect(_,1,2,2,CF_STEREO)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_STEREO,2,2));
-
- //answer with an ack to insert the connection in the database
- EXPECT_CALL(pMockControlInterface,cbAckConnect(_,E_OK)).Times(1);
- pRoutingReceiver.ackConnect(handle,connectionID,E_OK);
-
- //now we can start to disconnect and expect a call on the routing interface
- EXPECT_CALL(pMockRoutingInterface,asyncDisconnect(_,1)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.disconnect(handle,1));
-
- //during the disconnection, the connection is still in the list!
- ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
- ASSERT_TRUE(!connectionList.empty());
-
- //then we fire the ack and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckDisconnect(_,E_OK)).Times(1);
- pRoutingReceiver.ackDisconnect(handle,connectionID,E_OK);
-
- //make sure the handle is gone
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //make sure the connection is gone
- ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
- ASSERT_TRUE(connectionList.empty());
-
- //Now let's try to disconnect what is not existing...
- ASSERT_EQ(E_NON_EXISTENT,pControlReceiver.disconnect(handle,2));
+ am_connectionID_t connectionID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Connection_s> connectionList;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+
+ //prepare the stage
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ //now we first need to connect, we expect a call on the routing interface
+ EXPECT_CALL(pMockRoutingInterface,asyncConnect(_,1,2,2,CF_STEREO)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.connect(handle,connectionID,CF_STEREO,2,2));
+
+ //answer with an ack to insert the connection in the database
+ EXPECT_CALL(pMockControlInterface,cbAckConnect(_,E_OK)).Times(1);
+ pRoutingReceiver.ackConnect(handle, connectionID, E_OK);
+
+ //now we can start to disconnect and expect a call on the routing interface
+ EXPECT_CALL(pMockRoutingInterface,asyncDisconnect(_,1)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.disconnect(handle,1));
+
+ //during the disconnection, the connection is still in the list!
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ ASSERT_TRUE(!connectionList.empty());
+
+ //then we fire the ack and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckDisconnect(_,E_OK)).Times(1);
+ pRoutingReceiver.ackDisconnect(handle, connectionID, E_OK);
+
+ //make sure the handle is gone
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //make sure the connection is gone
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ ASSERT_TRUE(connectionList.empty());
+
+ //Now let's try to disconnect what is not existing...
+ ASSERT_EQ(E_NON_EXISTENT, pControlReceiver.disconnect(handle,2));
}
TEST_F(controlInterfaceTest,setSourceState)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- am_Domain_s domain;
- am_domainID_t domainID;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- am_SourceState_e state;
- pCF.createSource(source);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- source.sourceID=2;
- source.domainID=1;
-
- //prepare the stage
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
-
- //we set the sourcestate and expect a call on the routingInterface
- EXPECT_CALL(pMockRoutingInterface,asyncSetSourceState(_,2,SS_PAUSED)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSourceState(handle,source.sourceID,SS_PAUSED));
-
- //we want our handle in the list and let the type be the right one
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_EQ(handlesList[0].handle,handle.handle);
- ASSERT_EQ(handlesList[0].handleType,H_SETSOURCESTATE);
-
- //the state must be unchanged because did not get the ack
- ASSERT_EQ(E_OK,pDatabaseHandler.getSoureState(source.sourceID,state));
- ASSERT_EQ(state,SS_ON);
-
- //now we sent out the ack and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckSetSourceState(_,E_OK)).Times(1);
- pRoutingReceiver.ackSetSourceState(handle,E_OK);
-
- //finally we need the sourcestate to be changed
- ASSERT_EQ(E_OK,pDatabaseHandler.getSoureState(source.sourceID,state));
- ASSERT_EQ(state,SS_PAUSED);
-
- //make sure the handle is gone
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //we try again but expect a no change error
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSourceState(handle,source.sourceID,SS_PAUSED));
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ am_SourceState_e state;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ source.sourceID = 2;
+ source.domainID = 1;
+
+ //prepare the stage
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+
+ //we set the sourcestate and expect a call on the routingInterface
+ EXPECT_CALL(pMockRoutingInterface,asyncSetSourceState(_,2,SS_PAUSED)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.setSourceState(handle,source.sourceID,SS_PAUSED));
+
+ //we want our handle in the list and let the type be the right one
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_EQ(handlesList[0].handle, handle.handle);
+ ASSERT_EQ(handlesList[0].handleType, H_SETSOURCESTATE);
+
+ //the state must be unchanged because did not get the ack
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSoureState(source.sourceID,state));
+ ASSERT_EQ(state, SS_ON);
+
+ //now we sent out the ack and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckSetSourceState(_,E_OK)).Times(1);
+ pRoutingReceiver.ackSetSourceState(handle, E_OK);
+
+ //finally we need the sourcestate to be changed
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSoureState(source.sourceID,state));
+ ASSERT_EQ(state, SS_PAUSED);
+
+ //make sure the handle is gone
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //we try again but expect a no change error
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSourceState(handle,source.sourceID,SS_PAUSED));
}
TEST_F(controlInterfaceTest,SetSinkVolumeChange)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
- am_volume_t volume;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
- sink.volume=10;
-
- //setup environment, we need a domain and a sink
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //set the volume and expect a call on the routing interface
- EXPECT_CALL(pMockRoutingInterface,asyncSetSinkVolume(_,2,11,RAMP_DIRECT,23)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSinkVolume(handle,sinkID,11,RAMP_DIRECT,23));
-
- //check the list of handles. The handle must be in there and have the right type
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_EQ(handlesList[0].handle,handle.handle);
- ASSERT_EQ(handlesList[0].handleType,H_SETSINKVOLUME);
-
- //now we read out the volume, but we expect no change because the ack did not arrive yet
- ASSERT_EQ(E_OK,pDatabaseHandler.getSinkVolume(sinkID,volume));
- ASSERT_EQ(sink.volume,volume);
-
- //lets send the answer and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckSetSinkVolumeChange(_,11,E_OK)).Times(1);
- pRoutingReceiver.ackSetSinkVolumeChange(handle,11,E_OK);
-
- //finally, the new value must be in the database
- ASSERT_EQ(E_OK,pDatabaseHandler.getSinkVolume(sinkID,volume));
- ASSERT_EQ(11,volume);
-
- //and the handle must be destroyed
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //Now we try again, but the value is unchanged
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSinkVolume(handle,sinkID,11,RAMP_DIRECT,23));
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_volume_t volume;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+ sink.volume = 10;
+
+ //setup environment, we need a domain and a sink
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ //set the volume and expect a call on the routing interface
+ EXPECT_CALL(pMockRoutingInterface,asyncSetSinkVolume(_,2,11,RAMP_DIRECT,23)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkVolume(handle,sinkID,11,RAMP_DIRECT,23));
+
+ //check the list of handles. The handle must be in there and have the right type
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_EQ(handlesList[0].handle, handle.handle);
+ ASSERT_EQ(handlesList[0].handleType, H_SETSINKVOLUME);
+
+ //now we read out the volume, but we expect no change because the ack did not arrive yet
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkVolume(sinkID,volume));
+ ASSERT_EQ(sink.volume, volume);
+
+ //lets send the answer and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckSetSinkVolumeChange(_,11,E_OK)).Times(1);
+ pRoutingReceiver.ackSetSinkVolumeChange(handle, 11, E_OK);
+
+ //finally, the new value must be in the database
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkVolume(sinkID,volume));
+ ASSERT_EQ(11, volume);
+
+ //and the handle must be destroyed
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //Now we try again, but the value is unchanged
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSinkVolume(handle,sinkID,11,RAMP_DIRECT,23));
}
TEST_F(controlInterfaceTest,ackSetSourceVolumeChange)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- am_Domain_s domain;
- am_domainID_t domainID;
- am_volume_t volume;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- pCF.createSource(source);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- source.sourceID=2;
- source.domainID=1;
- source.volume=12;
-
- //prepare the scene
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
-
- //change the sinkVolume, expect a call on the routingInterface
- EXPECT_CALL(pMockRoutingInterface,asyncSetSourceVolume(_,2,11,RAMP_DIRECT,23)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSourceVolume(handle,source.sourceID,11,RAMP_DIRECT,23));
-
- //check the list of handles. The handle must be in there and have the right type
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_EQ(handlesList[0].handle,handle.handle);
- ASSERT_EQ(handlesList[0].handleType,H_SETSOURCEVOLUME);
-
- //now we read out the volume, but we expect no change because the ack did not arrive yet
- ASSERT_EQ(E_OK,pDatabaseHandler.getSourceVolume(sourceID,volume));
- ASSERT_EQ(source.volume,volume);
-
- //lets send the answer and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckSetSourceVolumeChange(_,11,E_OK)).Times(1);
- pRoutingReceiver.ackSetSourceVolumeChange(handle,11,E_OK);
-
- //finally, the new value must be in the database
- ASSERT_EQ(E_OK,pDatabaseHandler.getSourceVolume(sourceID,volume));
- ASSERT_EQ(11,volume);
-
- //and the handle must be destroyed
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //Now we try again, but the value is unchanged
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSourceVolume(handle,source.sourceID,11,RAMP_DIRECT,23));
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_volume_t volume;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ source.sourceID = 2;
+ source.domainID = 1;
+ source.volume = 12;
+
+ //prepare the scene
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+
+ //change the sinkVolume, expect a call on the routingInterface
+ EXPECT_CALL(pMockRoutingInterface,asyncSetSourceVolume(_,2,11,RAMP_DIRECT,23)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.setSourceVolume(handle,source.sourceID,11,RAMP_DIRECT,23));
+
+ //check the list of handles. The handle must be in there and have the right type
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_EQ(handlesList[0].handle, handle.handle);
+ ASSERT_EQ(handlesList[0].handleType, H_SETSOURCEVOLUME);
+
+ //now we read out the volume, but we expect no change because the ack did not arrive yet
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceVolume(sourceID,volume));
+ ASSERT_EQ(source.volume, volume);
+
+ //lets send the answer and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckSetSourceVolumeChange(_,11,E_OK)).Times(1);
+ pRoutingReceiver.ackSetSourceVolumeChange(handle, 11, E_OK);
+
+ //finally, the new value must be in the database
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceVolume(sourceID,volume));
+ ASSERT_EQ(11, volume);
+
+ //and the handle must be destroyed
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //Now we try again, but the value is unchanged
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSourceVolume(handle,source.sourceID,11,RAMP_DIRECT,23));
}
TEST_F(controlInterfaceTest,ackSetSinkSoundProperty)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- am_SoundProperty_s soundProperty;
- uint16_t oldvalue;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
- soundProperty.type=SP_BASS;
- soundProperty.value=244;
-
- //setup environment, we need a domain and a sink
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //change the soundproperty, expect a call on the routinginterface
- EXPECT_CALL(pMockRoutingInterface,asyncSetSinkSoundProperty(_,_,2)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSinkSoundProperty(handle,sink.sinkID,soundProperty));
-
- //check the list of handles. The handle must be in there and have the right type
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_EQ(handlesList[0].handle,handle.handle);
- ASSERT_EQ(handlesList[0].handleType,H_SETSINKSOUNDPROPERTY);
-
- //read out this property. There is no change, because the ack did not arrive yet.
- ASSERT_EQ(E_OK,pDatabaseHandler.getSinkSoundPropertyValue(2,SP_BASS,oldvalue));
- ASSERT_EQ(sink.listSoundProperties[0].value,oldvalue);
-
- //lets send the answer and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckSetSinkSoundProperty(_,E_OK)).Times(1);
- pRoutingReceiver.ackSetSinkSoundProperty(handle,E_OK);
-
- //finally, the new value must be in the database
- ASSERT_EQ(E_OK,pDatabaseHandler.getSinkSoundPropertyValue(sinkID,SP_BASS,oldvalue));
- ASSERT_EQ(soundProperty.value,oldvalue);
-
- //and the handle must be destroyed
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //Now we try again, but the value is unchanged
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSinkSoundProperty(handle,sink.sinkID,soundProperty));
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ am_SoundProperty_s soundProperty;
+ uint16_t oldvalue;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+ soundProperty.type = SP_BASS;
+ soundProperty.value = 244;
+
+ //setup environment, we need a domain and a sink
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ //change the soundproperty, expect a call on the routinginterface
+ EXPECT_CALL(pMockRoutingInterface,asyncSetSinkSoundProperty(_,_,2)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sink.sinkID,soundProperty));
+
+ //check the list of handles. The handle must be in there and have the right type
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_EQ(handlesList[0].handle, handle.handle);
+ ASSERT_EQ(handlesList[0].handleType, H_SETSINKSOUNDPROPERTY);
+
+ //read out this property. There is no change, because the ack did not arrive yet.
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkSoundPropertyValue(2,SP_BASS,oldvalue));
+ ASSERT_EQ(sink.listSoundProperties[0].value, oldvalue);
+
+ //lets send the answer and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckSetSinkSoundProperty(_,E_OK)).Times(1);
+ pRoutingReceiver.ackSetSinkSoundProperty(handle, E_OK);
+
+ //finally, the new value must be in the database
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkSoundPropertyValue(sinkID,SP_BASS,oldvalue));
+ ASSERT_EQ(soundProperty.value, oldvalue);
+
+ //and the handle must be destroyed
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //Now we try again, but the value is unchanged
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSinkSoundProperty(handle,sink.sinkID,soundProperty));
}
TEST_F(controlInterfaceTest,ackSetSourceSoundProperty)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- am_Domain_s domain;
- am_domainID_t domainID;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- am_SoundProperty_s soundProperty;
- uint16_t oldvalue;
- pCF.createSource(source);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- source.sourceID=2;
- source.domainID=1;
- soundProperty.type=SP_BASS;
- soundProperty.value=244;
-
- //prepare the scene
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
-
- //we trigger the change and wait for a call on the routinginterface
- EXPECT_CALL(pMockRoutingInterface,asyncSetSourceSoundProperty(_,_,2)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSourceSoundProperty(handle,source.sourceID,soundProperty));
-
- //check the list of handles. The handle must be in there and have the right type
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_EQ(handlesList[0].handle,handle.handle);
- ASSERT_EQ(handlesList[0].handleType,H_SETSOURCESOUNDPROPERTY);
-
- //read out this property. There is no change, because the ack did not arrive yet.
- ASSERT_EQ(E_OK,pDatabaseHandler.getSourceSoundPropertyValue(2,SP_BASS,oldvalue));
- ASSERT_EQ(source.listSoundProperties[0].value,oldvalue);
-
- //lets send the answer and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckSetSourceSoundProperty(_,E_OK)).Times(1);
- pRoutingReceiver.ackSetSourceSoundProperty(handle,E_OK);
-
- //finally, the new value must be in the database
- ASSERT_EQ(E_OK,pDatabaseHandler.getSourceSoundPropertyValue(sourceID,SP_BASS,oldvalue));
- ASSERT_EQ(soundProperty.value,oldvalue);
-
- //and the handle must be destroyed
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //Now we try again, but the value is unchanged
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSourceSoundProperty(handle,source.sourceID,soundProperty));
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ am_SoundProperty_s soundProperty;
+ uint16_t oldvalue;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ source.sourceID = 2;
+ source.domainID = 1;
+ soundProperty.type = SP_BASS;
+ soundProperty.value = 244;
+
+ //prepare the scene
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+
+ //we trigger the change and wait for a call on the routinginterface
+ EXPECT_CALL(pMockRoutingInterface,asyncSetSourceSoundProperty(_,_,2)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.setSourceSoundProperty(handle,source.sourceID,soundProperty));
+
+ //check the list of handles. The handle must be in there and have the right type
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_EQ(handlesList[0].handle, handle.handle);
+ ASSERT_EQ(handlesList[0].handleType, H_SETSOURCESOUNDPROPERTY);
+
+ //read out this property. There is no change, because the ack did not arrive yet.
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceSoundPropertyValue(2,SP_BASS,oldvalue));
+ ASSERT_EQ(source.listSoundProperties[0].value, oldvalue);
+
+ //lets send the answer and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckSetSourceSoundProperty(_,E_OK)).Times(1);
+ pRoutingReceiver.ackSetSourceSoundProperty(handle, E_OK);
+
+ //finally, the new value must be in the database
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceSoundPropertyValue(sourceID,SP_BASS,oldvalue));
+ ASSERT_EQ(soundProperty.value, oldvalue);
+
+ //and the handle must be destroyed
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //Now we try again, but the value is unchanged
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSourceSoundProperty(handle,source.sourceID,soundProperty));
}
TEST_F(controlInterfaceTest,crossFading)
{
- //todo: implement crossfading test
+ //todo: implement crossfading test
}
int main(int argc, char **argv)
{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
diff --git a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h
index 5b1bd99..1bc3ce8 100644
--- a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h
+++ b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file controlInterfaceTest.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file controlInterfaceTest.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ */
#ifndef ROUTINGINTERFACETEST_H_
#define ROUTINGINTERFACETEST_H_
@@ -41,31 +41,32 @@
#include "../ControlInterfaceBackdoor.h"
#include "../CommonFunctions.h"
+namespace am
+{
-namespace am {
-
-class controlInterfaceTest : public ::testing::Test{
+class controlInterfaceTest: public ::testing::Test
+{
public:
- controlInterfaceTest();
- ~controlInterfaceTest();
- DBusWrapper* pDBusWrapper;
- std::vector<std::string> plistCommandPluginDirs;
- std::vector<std::string> plistRoutingPluginDirs;
- DatabaseHandler pDatabaseHandler;
- RoutingSender pRoutingSender;
- CommandSender pCommandSender;
- MockControlSendInterface pMockControlInterface;
- MockRoutingSendInterface pMockRoutingInterface;
- ControlSender pControlSender;
- RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
- CommandInterfaceBackdoor pCommandInterfaceBackdoor;
- ControlInterfaceBackdoor pControlInterfaceBackdoor;
- DatabaseObserver pDatabaseObserver;
- ControlReceiver pControlReceiver;
- RoutingReceiver pRoutingReceiver;
- CommonFunctions pCF;
- void SetUp();
- void TearDown();
+ controlInterfaceTest();
+ ~controlInterfaceTest();
+ DBusWrapper* pDBusWrapper;
+ std::vector<std::string> plistCommandPluginDirs;
+ std::vector<std::string> plistRoutingPluginDirs;
+ DatabaseHandler pDatabaseHandler;
+ RoutingSender pRoutingSender;
+ CommandSender pCommandSender;
+ MockControlSendInterface pMockControlInterface;
+ MockRoutingSendInterface pMockRoutingInterface;
+ ControlSender pControlSender;
+ RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
+ CommandInterfaceBackdoor pCommandInterfaceBackdoor;
+ ControlInterfaceBackdoor pControlInterfaceBackdoor;
+ DatabaseObserver pDatabaseObserver;
+ ControlReceiver pControlReceiver;
+ RoutingReceiver pRoutingReceiver;
+ CommonFunctions pCF;
+ void SetUp();
+ void TearDown();
};
}
diff --git a/AudioManagerDaemon/test/database/databaseTest.cpp b/AudioManagerDaemon/test/database/databaseTest.cpp
index 1a0075c..5d53610 100644
--- a/AudioManagerDaemon/test/database/databaseTest.cpp
+++ b/AudioManagerDaemon/test/database/databaseTest.cpp
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file databasetest.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file databasetest.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#include "databaseTest.h"
#include "MockInterfaces.h"
@@ -40,1493 +40,1546 @@ DLT_DECLARE_CONTEXT(DLT_CONTEXT)
//extern int GetRandomNumber(int nLow, int nHigh);
//extern bool equalSoundProperty (const am_SoundProperty_s a, const am_SoundProperty_s b);
-extern bool equalMainSoundProperty (const am_MainSoundProperty_s a, const am_MainSoundProperty_s b);
-extern bool equalRoutingElement (const am_RoutingElement_s a,const am_RoutingElement_s b);
-extern bool equalClassProperties (const am_ClassProperty_s a,const am_ClassProperty_s b);
+extern bool equalMainSoundProperty(const am_MainSoundProperty_s a, const am_MainSoundProperty_s b);
+extern bool equalRoutingElement(const am_RoutingElement_s a, const am_RoutingElement_s b);
+extern bool equalClassProperties(const am_ClassProperty_s a, const am_ClassProperty_s b);
extern std::string int2string(int i);
-databaseTest::databaseTest()
- :plistRoutingPluginDirs(),
- plistCommandPluginDirs(),
- pDatabaseHandler(std::string(":memory:")),
- pRoutingSender(plistRoutingPluginDirs),
- pCommandSender(plistCommandPluginDirs),
- pMockInterface(),
- pRoutingInterfaceBackdoor(),
- pCommandInterfaceBackdoor(),
- pControlReceiver(&pDatabaseHandler,&pRoutingSender,&pCommandSender),
- pObserver(&pCommandSender,&pRoutingSender)
-{
- pDatabaseHandler.registerObserver(&pObserver);
- pCommandInterfaceBackdoor.injectInterface(&pCommandSender,&pMockInterface);
-}
+routingTest::routingTest() :
+ plistRoutingPluginDirs(), //
+ plistCommandPluginDirs(), //
+ pDatabaseHandler(std::string(":memory:")), //
+ pRoutingSender(plistRoutingPluginDirs), //
+ pCommandSender(plistCommandPluginDirs), //
+ pMockInterface(), //
+ pRoutingInterfaceBackdoor(),//
+ pCommandInterfaceBackdoor(), //
+ pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), //
+ pObserver(&pCommandSender, &pRoutingSender)
+{
+ pDatabaseHandler.registerObserver(&pObserver);
+ pCommandInterfaceBackdoor.injectInterface(&pCommandSender, &pMockInterface);
+}
-databaseTest::~databaseTest()
+routingTest::~routingTest()
{
}
-void databaseTest::createMainConnectionSetup()
+void routingTest::createMainConnectionSetup()
{
- //fill the connection database
- am_Connection_s connection;
- am_Source_s source;
- am_Sink_s sink;
- std::vector<am_Connection_s> connectionList;
+ //fill the connection database
+ am_Connection_s connection;
+ am_Source_s source;
+ am_Sink_s sink;
+ std::vector<am_Connection_s> connectionList;
- //we create 9 sources and sinks:
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
+ //we create 9 sources and sinks:
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
- for (uint16_t i=1;i<10;i++)
- {
- am_sinkID_t forgetSink;
- am_sourceID_t forgetSource;
- am_connectionID_t forgetConnection;
+ for (uint16_t i = 1; i < 10; i++)
+ {
+ am_sinkID_t forgetSink;
+ am_sourceID_t forgetSource;
+ am_connectionID_t forgetConnection;
- pCF.createConnection(connection);
- connection.sinkID=i;
- connection.sourceID=i;
- connectionList.push_back(connection);
+ pCF.createConnection(connection);
+ connection.sinkID = i;
+ connection.sourceID = i;
+ connectionList.push_back(connection);
- pCF.createSink(sink);
- sink.sinkID=i;
- sink.name="sink" + int2string(i);
- sink.domainID=4;
- pCF.createSource(source);
- source.sourceID=i;
- source.name="source" + int2string(i);
- source.domainID=4;
+ pCF.createSink(sink);
+ sink.sinkID = i;
+ sink.name = "sink" + int2string(i);
+ sink.domainID = 4;
+ pCF.createSource(source);
+ source.sourceID = i;
+ source.name = "source" + int2string(i);
+ source.domainID = 4;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(forgetConnection));
- }
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(forgetConnection));
+ }
- //fill the route
- std::vector<am_RoutingElement_s> routingList;
- pCF.connectionList2RoutingList(routingList,connectionList);
+ //fill the route
+ std::vector<am_RoutingElement_s> routingList;
+ pCF.connectionList2RoutingList(routingList, connectionList);
- //create the Route
- am_Route_s route;
- route.route=routingList;
- route.sinkID=1;
- route.sourceID=1;
+ //create the Route
+ am_Route_s route;
+ route.route = routingList;
+ route.sinkID = 1;
+ route.sourceID = 1;
- //create a mainConnection
- am_MainConnection_s mainConnection;
- am_mainConnectionID_t mainConnectionID;
- std::vector<am_MainConnection_s> mainConnectionList;
- pCF.createMainConnection(mainConnection,route);
+ //create a mainConnection
+ am_MainConnection_s mainConnection;
+ am_mainConnectionID_t mainConnectionID;
+ std::vector<am_MainConnection_s> mainConnectionList;
+ pCF.createMainConnection(mainConnection, route);
- //enter mainconnection in database
- EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
- EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID))<< "ERROR: database error";
- ASSERT_NE(0,mainConnectionID)<< "ERROR: connectionID zero";
+ //enter mainconnection in database
+ EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
+ EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID))
+ << "ERROR: database error";
+ ASSERT_NE(0,mainConnectionID)
+ << "ERROR: connectionID zero";
- //read out the mainconnections and check if they are equal to the data written.
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(mainConnectionList));
- bool equal=true;
- std::vector<am_MainConnection_s>::iterator listIterator=mainConnectionList.begin();
- for(;listIterator<mainConnectionList.end();++listIterator)
- {
- if(listIterator->connectionID==mainConnectionID) {
- equal= equal && (listIterator->connectionState == mainConnection.connectionState)
- && (listIterator->route.sinkID == mainConnection.route.sinkID)
- && (listIterator->route.sourceID == mainConnection.route.sourceID)
- && (listIterator->delay == mainConnection.delay)
- && (std::equal(listIterator->route.route.begin(),listIterator->route.route.end(),routingList.begin(),equalRoutingElement));
- }
- }
- ASSERT_EQ(true,equal);
+ //read out the mainconnections and check if they are equal to the data written.
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListMainConnections(mainConnectionList));
+ bool equal = true;
+ std::vector<am_MainConnection_s>::iterator listIterator = mainConnectionList.begin();
+ for (; listIterator < mainConnectionList.end(); ++listIterator)
+ {
+ if (listIterator->connectionID == mainConnectionID)
+ {
+ equal = equal && (listIterator->connectionState == mainConnection.connectionState) && (listIterator->route.sinkID == mainConnection.route.sinkID) && (listIterator->route.sourceID == mainConnection.route.sourceID) && (listIterator->delay == mainConnection.delay) && (std::equal(listIterator->route.route.begin(), listIterator->route.route.end(), routingList.begin(), equalRoutingElement));
+ }
+ }
+ ASSERT_EQ(true, equal);
}
-void databaseTest::SetUp()
-{
- DLT_REGISTER_APP("Dtest","AudioManagerDeamon");
- DLT_REGISTER_CONTEXT(DLT_CONTEXT,"Main","Main Context");
- DLT_LOG(DLT_CONTEXT,DLT_LOG_INFO, DLT_STRING("Database Test started "));
+void routingTest::SetUp()
+{
+ DLT_REGISTER_APP("Dtest", "AudioManagerDeamon");
+ DLT_REGISTER_CONTEXT(DLT_CONTEXT, "Main", "Main Context");
+ DLT_LOG(DLT_CONTEXT, DLT_LOG_INFO, DLT_STRING("Database Test started "));
}
-void databaseTest::TearDown()
+void routingTest::TearDown()
{
- DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
+ DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
}
-TEST_F(databaseTest,crossfaders)
+TEST_F(routingTest,crossfaders)
{
- //todo:implement crossfader tests
+ //todo:implement crossfader tests
}
-TEST_F(databaseTest,sourceState)
+TEST_F(routingTest,sourceState)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- std::vector<am_Source_s> listSources;
- pCF.createSource(source);
- source.sourceState=SS_OFF;
-
- //prepare the test
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
-
- //change the source state
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceState(sourceID,SS_ON));
-
- //read out the changed values
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_EQ(listSources[0].sourceState,SS_ON);
-}
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ std::vector<am_Source_s> listSources;
+ pCF.createSource(source);
+ source.sourceState = SS_OFF;
+
+ //prepare the test
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+
+ //change the source state
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceState(sourceID,SS_ON));
+
+ //read out the changed values
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(listSources[0].sourceState, SS_ON);
+}
-TEST_F(databaseTest,sinkVolumeChange)
+TEST_F(routingTest,sinkVolumeChange)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- std::vector<am_Sink_s> listSinks;
- pCF.createSink(sink);
- sink.volume=23;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ std::vector<am_Sink_s> listSinks;
+ pCF.createSink(sink);
+ sink.volume = 23;
+
+ //prepare the test
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- //prepare the test
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //change the volume and check the read out
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkVolume(sinkID,34));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_EQ(listSinks[0].volume,34);
+ //change the volume and check the read out
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkVolume(sinkID,34));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(listSinks[0].volume, 34);
}
-TEST_F(databaseTest,sourceVolumeChange)
+TEST_F(routingTest,sourceVolumeChange)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- std::vector<am_Source_s> listSources;
- pCF.createSource(source);
- source.volume=23;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ std::vector<am_Source_s> listSources;
+ pCF.createSource(source);
+ source.volume = 23;
- //prepare test
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ //prepare test
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- //change the volume and check the read out
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceVolume(sourceID,34));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_EQ(listSources[0].volume,34);
+ //change the volume and check the read out
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceVolume(sourceID,34));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(listSources[0].volume, 34);
}
-TEST_F(databaseTest, peekSource)
+TEST_F(routingTest, peekSource)
{
- std::vector<am_Source_s> listSources;
- am_sourceID_t sourceID, source2ID, source3ID;
- am_Source_s source;
- pCF.createSource(source);
-
- //peek a source that does not exits
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
-
- //make sure it is not in the list
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_TRUE(listSources.empty());
- ASSERT_EQ(sourceID,100);
-
- //now enter the source with the same name and make sure it does not get a new ID
- source.name="newsource";
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,source2ID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_EQ(sourceID,source2ID);
- ASSERT_TRUE(listSources[0].sourceID==sourceID);
-
- //now we peek again. This time, the source exists
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(source.name,source3ID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_TRUE(listSources.size()==1);
- ASSERT_EQ(source3ID,source2ID);
-}
-
-TEST_F(databaseTest, peekSourceDouble)
-{
- std::vector<am_Source_s> listSources;
- am_sourceID_t sourceID;
- am_sourceID_t source2ID;
- am_sourceID_t source3ID;
- am_Source_s source;
- pCF.createSource(source);
-
- //peek a source that does not exits
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
-
- //peek a second source that does not exits
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource2"),source2ID));
-
- //make sure they are is not in the list
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_TRUE(listSources.empty());
- ASSERT_EQ(sourceID,100);
- source.name="newsource";
-
- //now enter the source with the same name than the first peek and make sure it does not get a new ID
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,source3ID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_EQ(sourceID,source3ID);
- ASSERT_TRUE(listSources[0].sourceID==sourceID);
-}
-
-TEST_F(databaseTest, peekSink)
-{
- std::vector<am_Sink_s> listSinks;
- am_sinkID_t sinkID,sink2ID, sink3ID;
- am_Sink_s sink;
- pCF.createSink(sink);
-
- //peek a sink that does not exits
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
-
- //make sure it is not in the list
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_TRUE(listSinks.empty());
- ASSERT_EQ(sinkID,100);
- sink.name="newsink";
-
- //now enter the source with the same name and make sure it does not get a new ID
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sink2ID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_EQ(sinkID,sink2ID);
- ASSERT_TRUE(listSinks[0].sinkID==sinkID);
-
- //now we peek again, this time, the sink exists
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(sink.name,sink3ID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_TRUE(listSinks.size()==1);
- ASSERT_EQ(sink3ID,sink2ID);
-}
-
-TEST_F(databaseTest, peekSinkDouble)
-{
- std::vector<am_Sink_s> listSinks;
- am_sinkID_t sinkID;
- am_sinkID_t sink2ID;
- am_sinkID_t sink3ID;
- am_Sink_s sink;
- pCF.createSink(sink);
-
- //peek a sink that does not exits
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
-
- //peek again
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("nextsink"),sink2ID));
-
- //make sure they are is not in the list
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_TRUE(listSinks.empty());
- ASSERT_EQ(sinkID,100);
- sink.name="newsink";
-
- //now enter the sink with the same name than the first peek and make sure it does not get a new ID
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sink3ID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_EQ(sinkID,sink3ID);
- ASSERT_TRUE(listSinks[0].sinkID==sinkID);
-}
-
-TEST_F(databaseTest,changeConnectionTimingInformationCheckMainConnection)
-{
- am_Connection_s connection;
- std::vector<am_Connection_s> connectionList;
- std::vector<am_MainConnectionType_s> mainList;
- pCF.createConnection(connection);
-
- //prepare the test, it is one mainconnection, so we expect one callback
- createMainConnectionSetup();
- EXPECT_CALL(pMockInterface,cbTimingInformationChanged(1,216)).Times(1);
-
- //first get all visible mainconnections and make sure, the delay is set to -1 for the first entry
- ASSERT_EQ(E_OK,pDatabaseHandler.getListVisibleMainConnections(mainList));
- ASSERT_EQ(mainList[0].delay,-1);
-
- //no go through all connections and set the delay time to 24 for each connection
- ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
- std::vector<am_Connection_s>::iterator iteratorConnectionList=connectionList.begin();
- for(;iteratorConnectionList<connectionList.end();++iteratorConnectionList)
- {
- ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionTimingInformation(iteratorConnectionList->sinkID,24));
- }
-
- //we read the result again and expect that the value is now different from -1
- ASSERT_EQ(E_OK,pDatabaseHandler.getListVisibleMainConnections(mainList));
- ASSERT_EQ(mainList[0].delay,216);
-}
-
-TEST_F(databaseTest,changeConnectionTimingInformation)
-{
- am_Connection_s connection;
- am_connectionID_t connectionID;
- std::vector<am_Connection_s> connectionList;
- pCF.createConnection(connection);
-
- //enter a connection
- ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID));
- ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
-
- //change the timing and check it
- ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionTimingInformation(connectionID,24));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
- ASSERT_TRUE(connectionList[0].delay==24);
-}
-
-TEST_F(databaseTest,getSinkClassOfSink)
-{
- std::vector<am_SinkClass_s> sinkClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SinkClass_s sinkClass, returnClass;
- am_ClassProperty_s classProperty;
- am_sinkClass_t sinkClassID;
- am_Sink_s sink;
- am_sinkID_t sinkID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sinkClass.name="test";
- sinkClass.sinkClassID=4;
- sinkClass.listClassProperties=classPropertyList;
- pCF.createSink(sink);
- sink.sinkClassID=4;
-
- //prepare test
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //enter a new sinkclass, read out again and check
- EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,4);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.getSinkClassInfoDB(sinkID,returnClass));
- ASSERT_EQ(sinkClassList[0].name,returnClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,returnClass.sinkClassID);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),returnClass.listClassProperties.begin(),equalClassProperties));
-}
-
-
-TEST_F(databaseTest,getSourceClassOfSource)
-{
- std::vector<am_SourceClass_s> sourceClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SourceClass_s sourceClass, sinkSourceClass;
- am_ClassProperty_s classProperty;
- am_sourceClass_t sourceClassID;
- am_Source_s source;
- am_sourceID_t sourceID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sourceClass.name="test";
- sourceClass.sourceClassID=1;
- sourceClass.listClassProperties=classPropertyList;
- pCF.createSource(source);
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
- EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,1);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.getSourceClassInfoDB(sourceID,sinkSourceClass));
- ASSERT_EQ(sourceClassList[0].name,sinkSourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,sinkSourceClass.sourceClassID);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),sinkSourceClass.listClassProperties.begin(),equalClassProperties));
-}
-
-
-TEST_F(databaseTest,removeSourceClass)
-{
- std::vector<am_SourceClass_s> sourceClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SourceClass_s sourceClass;
- am_ClassProperty_s classProperty;
- am_sourceClass_t sourceClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sourceClass.name="test";
- sourceClass.sourceClassID=3;
- sourceClass.listClassProperties=classPropertyList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(2);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,3);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceClassDB(3));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_TRUE(sourceClassList.empty());
-}
-
-TEST_F(databaseTest,updateSourceClass)
-{
- std::vector<am_SourceClass_s> sourceClassList;
- std::vector<am_ClassProperty_s> classPropertyList,changedPropertyList;
- am_SourceClass_s sourceClass, changedClass;
- am_ClassProperty_s classProperty;
- am_sourceClass_t sourceClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sourceClass.name="test";
- sourceClass.sourceClassID=0;
- sourceClass.listClassProperties=classPropertyList;
- changedClass=sourceClass;
- changedClass.listClassProperties[1].value=6;
- changedPropertyList=changedClass.listClassProperties;
- EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
- changedClass.sourceClassID=sourceClassID;
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,100);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceClassInfoDB(changedClass));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,100);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
-}
-
-TEST_F(databaseTest,enterSourceClass)
-{
- std::vector<am_SourceClass_s> sourceClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SourceClass_s sourceClass;
- am_ClassProperty_s classProperty;
- am_sourceClass_t sourceClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sourceClass.name="test";
- sourceClass.sourceClassID=0;
- sourceClass.listClassProperties=classPropertyList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,100);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
-}
-
-TEST_F(databaseTest,enterSourceClassStatic)
-{
- std::vector<am_SourceClass_s> sourceClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SourceClass_s sourceClass;
- am_ClassProperty_s classProperty;
- am_sourceClass_t sourceClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sourceClass.name="test";
- sourceClass.sourceClassID=3;
- sourceClass.listClassProperties=classPropertyList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,3);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
-}
-
-
-TEST_F(databaseTest,removeSinkClass)
-{
- std::vector<am_SinkClass_s> sinkClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SinkClass_s sinkClass;
- am_ClassProperty_s classProperty;
- am_sinkClass_t sinkClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sinkClass.name="test";
- sinkClass.sinkClassID=0;
- sinkClass.listClassProperties=classPropertyList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(2);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,100);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkClassDB(sinkClassID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_TRUE(sinkClassList.empty());
-}
-
-TEST_F(databaseTest,updateSinkClass)
-{
- std::vector<am_SinkClass_s> sinkClassList;
- std::vector<am_ClassProperty_s> classPropertyList, changedPropertyList;
- am_SinkClass_s sinkClass, changedClass;
- am_ClassProperty_s classProperty;
- am_sinkClass_t sinkClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sinkClass.name="test";
- sinkClass.sinkClassID=0;
- sinkClass.listClassProperties=classPropertyList;
- changedClass=sinkClass;
- changedClass.listClassProperties[1].value=6;
- changedPropertyList=changedClass.listClassProperties;
- EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
- changedClass.sinkClassID=sinkClassID;
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,100);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkClassInfoDB(changedClass));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,100);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
-}
-
-TEST_F(databaseTest,enterSinkClass)
-{
- std::vector<am_SinkClass_s> sinkClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SinkClass_s sinkClass;
- am_ClassProperty_s classProperty;
- am_sinkClass_t sinkClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sinkClass.name="test";
- sinkClass.sinkClassID=0;
- sinkClass.listClassProperties=classPropertyList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,100);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
-}
-
-TEST_F(databaseTest,enterSinkClassStatic)
-{
- std::vector<am_SinkClass_s> sinkClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SinkClass_s sinkClass;
- am_ClassProperty_s classProperty;
- am_sinkClass_t sinkClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sinkClass.name="test";
- sinkClass.sinkClassID=4;
- sinkClass.listClassProperties=classPropertyList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,4);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
-}
-
-
-TEST_F(databaseTest, changeSystemProperty)
-{
- std::vector<am_SystemProperty_s> listSystemProperties,listReturn;
- am_SystemProperty_s systemProperty;
-
- systemProperty.type=SYP_TEST;
- systemProperty.value=33;
- listSystemProperties.push_back(systemProperty);
- EXPECT_CALL(pMockInterface,cbSystemPropertyChanged(_)).Times(1); //todo: check the exact value here
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSystemProperties(listSystemProperties));
- systemProperty.value=444;
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSystemPropertyDB(systemProperty));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSystemProperties(listReturn));
- ASSERT_EQ(listReturn[0].type,systemProperty.type);
- ASSERT_EQ(listReturn[0].value,systemProperty.value);
-}
-
-TEST_F(databaseTest, systemProperties)
-{
- std::vector<am_SystemProperty_s> listSystemProperties,listReturn;
- am_SystemProperty_s systemProperty;
-
- systemProperty.type=SYP_TEST;
- systemProperty.value=33;
- listSystemProperties.push_back(systemProperty);
-
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSystemProperties(listSystemProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSystemProperties(listReturn));
- ASSERT_EQ(listReturn[0].type,systemProperty.type);
- ASSERT_EQ(listReturn[0].value,systemProperty.value);
-}
-
-
-TEST_F(databaseTest,enterSourcesCorrect)
-{
- //fill the connection database
- am_Source_s staticSource,firstDynamicSource,secondDynamicSource;
- am_sourceID_t staticSourceID,firstDynamicSourceID,secondDynamicSourceID;
- std::vector<am_Source_s> sourceList;
-
- pCF.createSource(staticSource);
- staticSource.sourceID=4;
- staticSource.name="Static";
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))<< "ERROR: database error";
- ASSERT_EQ(staticSource.sourceID,staticSourceID)<< "ERROR: ID not the one given in staticSource";
-
- pCF.createSource(firstDynamicSource);
- firstDynamicSource.name="firstDynamicSource";
-
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(firstDynamicSource,firstDynamicSourceID))<< "ERROR: database error";
- ASSERT_EQ(firstDynamicSourceID,DYNAMIC_ID_BOUNDARY)<< "ERROR: ID not the one given in firstDynamicSink";
-
- pCF.createSource(secondDynamicSource);
- secondDynamicSource.name="secondDynamicSource";
-
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(secondDynamicSource,secondDynamicSourceID))<< "ERROR: database error";
- ASSERT_NEAR(secondDynamicSourceID,DYNAMIC_ID_BOUNDARY,10)<< "ERROR: ID not the one given in secondDynamicSink";
-
- //now read back and check the returns agains the given values
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(sourceList))<< "ERROR: database error";
- bool equal=true;
-
- std::vector<am_Source_s>::iterator listIterator=sourceList.begin();
- for(;listIterator<sourceList.end();++listIterator)
- {
- if(listIterator->sourceID==staticSourceID)
- {
- equal = equal && pCF.compareSource(listIterator,staticSource);
- }
-
- if(listIterator->sourceID==firstDynamicSourceID)
- {
- equal = equal && pCF.compareSource(listIterator,firstDynamicSource);
- }
-
- if(listIterator->sourceID==secondDynamicSourceID)
- {
- equal = equal && pCF.compareSource(listIterator,secondDynamicSource);
- }
-
- }
- ASSERT_EQ(true,equal);
-}
-
-
-TEST_F(databaseTest, changeSourceMainSoundProperty)
-{
- std::vector<am_Source_s> listSources;
- am_Source_s source;
- am_sourceID_t sourceID;
- pCF.createSource(source);
- am_MainSoundProperty_s property;
- property.type=MSP_NAVIGATION_OFFSET;
- property.value=33;
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
-
- EXPECT_CALL(pMockInterface,cbMainSourceSoundPropertyChanged(sourceID,_)).Times(1); //todo: check in detail
- ASSERT_EQ(E_OK,pDatabaseHandler.changeMainSourceSoundPropertyDB(property,sourceID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- std::vector<am_MainSoundProperty_s>::iterator listIterator=listSources[0].listMainSoundProperties.begin();
- for(;listIterator<listSources[0].listMainSoundProperties.end();++listIterator)
- {
- if(listIterator->type==property.type)
- {
- ASSERT_EQ(listIterator->value,property.value);
- }
- }
-}
-
-TEST_F(databaseTest, changeSinkMuteState)
-{
- std::vector<am_Sink_s> listSinks;
- am_Sink_s sink;
- am_sinkID_t sinkID;
- pCF.createSink(sink);
- am_MuteState_e muteState=MS_MUTED;
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- EXPECT_CALL(pMockInterface,cbSinkMuteStateChanged(sinkID,muteState)).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkMuteStateDB(muteState,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_EQ(muteState,listSinks[0].muteState);
-}
-
-TEST_F(databaseTest, changeSinkMainSoundProperty)
-{
- std::vector<am_Sink_s> listSinks;
- am_Sink_s sink;
- am_sinkID_t sinkID;
- pCF.createSink(sink);
- am_MainSoundProperty_s property;
- property.type=MSP_NAVIGATION_OFFSET;
- property.value=33;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- EXPECT_CALL(pMockInterface,cbMainSinkSoundPropertyChanged(sinkID,_)).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.changeMainSinkSoundPropertyDB(property,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- std::vector<am_MainSoundProperty_s>::iterator listIterator=listSinks[0].listMainSoundProperties.begin();
- for(;listIterator<listSinks[0].listMainSoundProperties.end();++listIterator)
- {
- if(listIterator->type==property.type)
- {
- ASSERT_EQ(listIterator->value,property.value);
- }
- }
-}
-
-TEST_F(databaseTest, peekDomain)
-{
- std::vector<am_Domain_s> listDomains;
- am_Domain_s domain;
- am_domainID_t domainID;
- am_domainID_t domain2ID;
- pCF.createDomain(domain);
- ASSERT_EQ(E_OK,pDatabaseHandler.peekDomain(std::string("newdomain"),domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
- ASSERT_TRUE(listDomains.empty());
- ASSERT_EQ(domainID,1);
- domain.name="newdomain";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domain2ID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
- ASSERT_EQ(domainID,domain2ID);
- ASSERT_TRUE(listDomains[0].domainID==domainID);
-}
-
-TEST_F(databaseTest, peekDomainFirstEntered)
-{
- std::vector<am_Domain_s> listDomains;
- am_Domain_s domain;
- am_domainID_t domainID;
- am_domainID_t domain2ID;
- pCF.createDomain(domain);
- domain.name="newdomain";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.peekDomain(std::string("newdomain"),domain2ID));
- ASSERT_EQ(domainID,domain2ID);
- ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
- ASSERT_TRUE(listDomains.size()==1);
-}
-
-TEST_F(databaseTest, changeDomainState)
-{
- std::vector<am_Domain_s> listDomains;
- am_Domain_s domain;
- am_domainID_t domainID;
- pCF.createDomain(domain);
- am_DomainState_e newState=DS_INDEPENDENT_STARTUP;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.changDomainStateDB(newState,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
- ASSERT_EQ(newState,listDomains[0].state);
-}
-
-
-TEST_F(databaseTest, changeMainConnectionState)
-{
- std::vector<am_MainConnection_s> listMainConnections;
- createMainConnectionSetup();
- EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.changeMainConnectionStateDB(1,CS_DISCONNECTING))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(listMainConnections));
- ASSERT_EQ(CS_DISCONNECTING,listMainConnections[0].connectionState);
-}
-
-TEST_F(databaseTest, changeSinkAvailability)
-{
- std::vector<am_Sink_s> listSinks;
- am_Sink_s sink;
- am_sinkID_t sinkID;
- pCF.createSink(sink);
- am_Availability_s availability;
- availability.availability=A_UNKNOWN;
- availability.availabilityReason=AR_TEMPERATURE;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkAvailabilityDB(availability,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_EQ(availability.availability,listSinks[0].available.availability);
- ASSERT_EQ(availability.availabilityReason,listSinks[0].available.availabilityReason);
-}
-
-TEST_F(databaseTest, changeSourceAvailability)
-{
- std::vector<am_Source_s> listSources;
- am_Source_s source;
- am_sourceID_t sourceID;
- pCF.createSource(source);
- am_Availability_s availability;
- availability.availability=A_UNKNOWN;
- availability.availabilityReason=AR_TEMPERATURE;
- source.visible=true;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceAvailabilityDB(availability,sourceID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_EQ(availability.availability,listSources[0].available.availability);
- ASSERT_EQ(availability.availabilityReason,listSources[0].available.availabilityReason);
-}
-
-
-TEST_F(databaseTest,changeMainConnectionRoute)
-{
- std::vector<am_MainConnection_s> originalList;
- std::vector<am_MainConnection_s> newList;
- createMainConnectionSetup();
- //fill the connection database
- am_Connection_s connection;
- am_Source_s source;
- am_Sink_s sink;
- std::vector<am_Connection_s> connectionList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
- for (uint16_t i=1;i<10;i++)
- {
- am_sinkID_t forgetSink;
- am_sourceID_t forgetSource;
- am_connectionID_t forgetConnection;
-
- pCF.createConnection(connection);
- connection.sinkID=i+20;
- connection.sourceID=i+20;
- connection.delay=-1;
- connectionList.push_back(connection);
-
- pCF.createSink(sink);
- sink.sinkID=i+20;
- sink.name="sink" + int2string(i+20);
- sink.domainID=4;
- pCF.createSource(source);
- source.sourceID=i+20;
- source.name="source" + int2string(i+30);
- source.domainID=4;
-
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(originalList))<< "ERROR: database error";
-
- }
-
- //fill the route
- std::vector<am_RoutingElement_s> routingList;
- pCF.connectionList2RoutingList(routingList,connectionList);
-
- //create the Route
- am_Route_s route;
- route.route=routingList;
- route.sinkID=2;
- route.sourceID=2;
-
- ASSERT_EQ(E_OK,pDatabaseHandler.changeMainConnectionRouteDB(1,route));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(newList))<< "ERROR: database error";
- ASSERT_TRUE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),routingList.begin(),equalRoutingElement));
- ASSERT_FALSE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),originalList[0].route.route.begin(),equalRoutingElement));
-}
-
-TEST_F(databaseTest,changeMainSinkVolume)
-{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_mainVolume_t newVol=20;
- std::vector<am_Sink_s> listSinks;
- pCF.createSink(sink);
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
-
- EXPECT_CALL(pMockInterface,cbVolumeChanged(sinkID,newVol)).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkMainVolumeDB(newVol,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_EQ(listSinks[0].mainVolume,newVol);
-}
-
-TEST_F(databaseTest,getMainSourceSoundProperties)
-{
- am_Source_s source;
- am_sourceID_t sourceID;
- pCF.createSource(source);
- std::vector<am_MainSoundProperty_s> mainSoundProperties=source.listMainSoundProperties;
- std::vector<am_MainSoundProperty_s> listMainSoundProperties;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSourceSoundProperties(sourceID,listMainSoundProperties));
- ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
-}
-
-TEST_F(databaseTest,getMainSinkSoundProperties)
- {
- am_Sink_s sink;
- am_sinkID_t sinkID;
- pCF.createSink(sink);
- std::vector<am_MainSoundProperty_s> mainSoundProperties=sink.listMainSoundProperties;
- std::vector<am_MainSoundProperty_s> listMainSoundProperties;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSinkSoundProperties(sinkID,listMainSoundProperties));
- ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
- }
-
-TEST_F(databaseTest,getMainSources)
-{
- am_Source_s source, source1,source2;
- am_sourceID_t sourceID;
- pCF.createSource(source);
- pCF.createSource(source1);
- pCF.createSource(source2);
- source1.name="source1";
- source2.name="source2";
- bool equal=true;
- source1.visible=false;
- std::vector<am_SourceType_s> listMainSources;
- std::vector<am_Source_s> listSources;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
-
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
- source.sourceID=sourceID;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source1,sourceID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source2,sourceID));
- source2.sourceID=sourceID;
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSources(listMainSources));
- listSources.push_back(source);
- listSources.push_back(source2);
- std::vector<am_SourceType_s>::iterator listIterator=listMainSources.begin();
- for(;listIterator<listMainSources.end();++listIterator)
- {
- equal = equal && pCF.compareSinkMainSource(listIterator,listSources);
- }
- ASSERT_TRUE(equal);
-}
-
-TEST_F(databaseTest,getMainSinks)
-{
- am_Sink_s sink, sink1,sink2;
- am_sinkID_t sinkID;
- pCF.createSink(sink);
- pCF.createSink(sink1);
- pCF.createSink(sink2);
- sink1.name="sink1";
- sink2.name="sink2";
- bool equal=true;
- sink1.visible=false;
- std::vector<am_SinkType_s> listMainSinks;
- std::vector<am_Sink_s> listSinks;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
- sink.sinkID=sinkID;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink1,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink2,sinkID));
- sink2.sinkID=sinkID;
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSinks(listMainSinks));
- listSinks.push_back(sink);
- listSinks.push_back(sink2);
- std::vector<am_SinkType_s>::iterator listIterator=listMainSinks.begin();
- for(;listIterator<listMainSinks.end();++listIterator)
- {
- equal = equal && pCF.compareSinkMainSink(listIterator,listSinks);
- }
- ASSERT_TRUE(equal);
-}
-
-TEST_F(databaseTest,getVisibleMainConnections)
-{
- createMainConnectionSetup();
- am_MainConnection_s mainConnection;
- am_Route_s route;
- pCF.createMainConnection(mainConnection,route);
- std::vector<am_MainConnectionType_s> visibleMainConnection;
- ASSERT_EQ(E_OK,pDatabaseHandler.getListVisibleMainConnections(visibleMainConnection));
- ASSERT_TRUE(1==visibleMainConnection[0].mainConnectionID);
- ASSERT_TRUE(mainConnection.connectionState==visibleMainConnection[0].connectionState);
- ASSERT_TRUE(mainConnection.delay==visibleMainConnection[0].delay);
- ASSERT_TRUE(1==visibleMainConnection[0].sinkID);
- ASSERT_TRUE(1==visibleMainConnection[0].sourceID);
-}
-
-TEST_F(databaseTest,getListSourcesOfDomain)
-{
- am_Source_s source, source2;
- am_Domain_s domain;
- am_domainID_t domainID;
- am_sourceID_t sourceID;
- std::vector<am_sourceID_t> sourceList,sourceCheckList;
- pCF.createSource(source);
- source.sourceID=1;
- source.name="testSource";
- source.domainID=1;
- pCF.createSource(source2);
- source2.sourceID=0;
- source2.name="testSource2";
- source2.domainID=5;
- pCF.createDomain(domain);
- sourceCheckList.push_back(1);//sink.sinkID);
-
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source2,sourceID))<< "ERROR: database error";
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSourcesOfDomain(2,sourceList))<< "ERROR: database error";
- ASSERT_TRUE(sourceList.empty());
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourcesOfDomain(1,sourceList))<< "ERROR: database error";
- ASSERT_TRUE(std::equal(sourceList.begin(),sourceList.end(),sourceCheckList.begin()) && !sourceList.empty());
-}
-
-TEST_F(databaseTest,getListSinksOfDomain)
-{
- am_Sink_s sink, sink2;
- am_Domain_s domain;
- am_domainID_t domainID;
- am_sinkID_t sinkID;
- std::vector<am_sinkID_t> sinkList,sinkCheckList;
- pCF.createSink(sink);
- sink.sinkID=1;
- sink.domainID=1;
- pCF.createSink(sink2);
- sink2.domainID=5;
- sink2.name="sink2";
- pCF.createDomain(domain);
- sinkCheckList.push_back(1);//sink.sinkID);
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink2,sinkID))<< "ERROR: database error";
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSinksOfDomain(2,sinkList))<< "ERROR: database error";
- ASSERT_TRUE(sinkList.empty());
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinksOfDomain(1,sinkList))<< "ERROR: database error";
- ASSERT_TRUE(std::equal(sinkList.begin(),sinkList.end(),sinkCheckList.begin()) && !sinkList.empty());
-}
-
-TEST_F(databaseTest,getListGatewaysOfDomain)
-{
- am_Gateway_s gateway, gateway2;
- am_gatewayID_t gatewayID;
- am_domainID_t domainID;
- am_Domain_s domain;
- std::vector<am_gatewayID_t> gatewayList,gatewayCheckList;
- pCF.createGateway(gateway);
- gateway.gatewayID=1;
- gateway.name="testGateway";
- gateway.controlDomainID=1;
- gateway.sourceID=1;
- gateway.sinkID=1;
- gateway.domainSinkID=1;
- gateway.domainSourceID=1;
- pCF.createGateway(gateway2);
- gateway2.gatewayID=2;
- gateway2.name="testGateway2";
- gateway2.controlDomainID=4;
- gateway2.sourceID=1;
- gateway2.sinkID=1;
- gateway2.domainSinkID=1;
- gateway2.domainSourceID=1;
- pCF.createDomain(domain);
- gatewayCheckList.push_back(gateway.gatewayID);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID))<< "ERROR: database error";
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListGatewaysOfDomain(2,gatewayList))<< "ERROR: database error";
- ASSERT_TRUE(gatewayList.empty());
- ASSERT_EQ(E_OK,pDatabaseHandler.getListGatewaysOfDomain(1,gatewayList))<< "ERROR: database error";
- ASSERT_TRUE(std::equal(gatewayList.begin(),gatewayList.end(),gatewayCheckList.begin()) && !gatewayList.empty());
-}
-
-TEST_F(databaseTest,removeDomain)
-{
- am_Domain_s domain;
- am_domainID_t domainID;
- std::vector<am_Domain_s> listDomains;
- pCF.createDomain(domain);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.removeDomainDB(domainID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains))<< "ERROR: database error";
- ASSERT_TRUE(listDomains.empty());
-}
-
-TEST_F(databaseTest,removeGateway)
-{
- am_Gateway_s gateway;
- am_gatewayID_t gatewayID;
- std::vector<am_Gateway_s> listGateways;
- pCF.createGateway(gateway);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.removeGatewayDB(gatewayID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(listGateways))<< "ERROR: database error";
- ASSERT_TRUE(listGateways.empty());
-}
-
-TEST_F(databaseTest,removeSink)
-{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- std::vector<am_Sink_s> listSinks;
- pCF.createSink(sink);
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkDB(sinkID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks))<< "ERROR: database error";
- ASSERT_TRUE(listSinks.empty());
-}
+ std::vector<am_Source_s> listSources;
+ am_sourceID_t sourceID, source2ID, source3ID;
+ am_Source_s source;
+ pCF.createSource(source);
-TEST_F(databaseTest,removeSource)
-{
- //fill the connection database
- am_Source_s source;
- am_sourceID_t sourceID;
- std::vector<am_Source_s> listSources;
- pCF.createSource(source);
+ //peek a source that does not exits
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceDB(sourceID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources))<< "ERROR: database error";
- ASSERT_TRUE(listSources.empty());
-}
+ //make sure it is not in the list
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.empty());
+ ASSERT_EQ(sourceID, 100);
-TEST_F(databaseTest, removeMainConnection)
-{
- createMainConnectionSetup();
- EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
- EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.removeMainConnectionDB(1))<< "ERROR: database error";
-}
+ //now enter the source with the same name and make sure it does not get a new ID
+ source.name = "newsource";
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,source2ID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(sourceID, source2ID);
+ ASSERT_TRUE(listSources[0].sourceID==sourceID);
-TEST_F(databaseTest,removeNonexistentMainConnectionFail)
-{
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeMainConnectionDB(34))<< "ERROR: database error";
+ //now we peek again. This time, the source exists
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(source.name,source3ID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.size()==1);
+ ASSERT_EQ(source3ID, source2ID);
}
-TEST_F(databaseTest,removeNonexistentSource)
+TEST_F(routingTest, peekSourceDouble)
{
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSourceDB(3))<< "ERROR: database error";
-}
+ std::vector<am_Source_s> listSources;
+ am_sourceID_t sourceID;
+ am_sourceID_t source2ID;
+ am_sourceID_t source3ID;
+ am_Source_s source;
+ pCF.createSource(source);
-TEST_F(databaseTest,removeNonexistentSink)
-{
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSinkDB(2))<< "ERROR: database error";
-}
+ //peek a source that does not exits
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
+
+ //peek a second source that does not exits
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource2"),source2ID));
+
+ //make sure they are is not in the list
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.empty());
+ ASSERT_EQ(sourceID, 100);
+ source.name = "newsource";
-TEST_F(databaseTest,removeNonexistentGateway)
-{
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeGatewayDB(12))<< "ERROR: database error";
+ //now enter the source with the same name than the first peek and make sure it does not get a new ID
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,source3ID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(sourceID, source3ID);
+ ASSERT_TRUE(listSources[0].sourceID==sourceID);
+}
+
+TEST_F(routingTest, peekSink)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_sinkID_t sinkID, sink2ID, sink3ID;
+ am_Sink_s sink;
+ pCF.createSink(sink);
+
+ //peek a sink that does not exits
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
+
+ //make sure it is not in the list
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.empty());
+ ASSERT_EQ(sinkID, 100);
+ sink.name = "newsink";
+
+ //now enter the source with the same name and make sure it does not get a new ID
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sink2ID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(sinkID, sink2ID);
+ ASSERT_TRUE(listSinks[0].sinkID==sinkID);
+
+ //now we peek again, this time, the sink exists
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(sink.name,sink3ID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.size()==1);
+ ASSERT_EQ(sink3ID, sink2ID);
+}
+
+TEST_F(routingTest, peekSinkDouble)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_sinkID_t sinkID;
+ am_sinkID_t sink2ID;
+ am_sinkID_t sink3ID;
+ am_Sink_s sink;
+ pCF.createSink(sink);
+
+ //peek a sink that does not exits
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
+
+ //peek again
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("nextsink"),sink2ID));
+
+ //make sure they are is not in the list
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.empty());
+ ASSERT_EQ(sinkID, 100);
+ sink.name = "newsink";
+
+ //now enter the sink with the same name than the first peek and make sure it does not get a new ID
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sink3ID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(sinkID, sink3ID);
+ ASSERT_TRUE(listSinks[0].sinkID==sinkID);
+}
+
+TEST_F(routingTest,changeConnectionTimingInformationCheckMainConnection)
+{
+ am_Connection_s connection;
+ std::vector<am_Connection_s> connectionList;
+ std::vector<am_MainConnectionType_s> mainList;
+ pCF.createConnection(connection);
+
+ //prepare the test, it is one mainconnection, so we expect one callback
+ createMainConnectionSetup();
+ EXPECT_CALL(pMockInterface,cbTimingInformationChanged(1,216)).Times(1);
+
+ //first get all visible mainconnections and make sure, the delay is set to -1 for the first entry
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListVisibleMainConnections(mainList));
+ ASSERT_EQ(mainList[0].delay, -1);
+
+ //no go through all connections and set the delay time to 24 for each connection
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ std::vector<am_Connection_s>::iterator iteratorConnectionList = connectionList.begin();
+ for (; iteratorConnectionList < connectionList.end(); ++iteratorConnectionList)
+ {
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionTimingInformation(iteratorConnectionList->sinkID,24));
+ }
+
+ //we read the result again and expect that the value is now different from -1
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListVisibleMainConnections(mainList));
+ ASSERT_EQ(mainList[0].delay, 216);
+}
+
+TEST_F(routingTest,changeConnectionTimingInformation)
+{
+ am_Connection_s connection;
+ am_connectionID_t connectionID;
+ std::vector<am_Connection_s> connectionList;
+ pCF.createConnection(connection);
+
+ //enter a connection
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterConnectionDB(connection,connectionID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(connectionID));
+
+ //change the timing and check it
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionTimingInformation(connectionID,24));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ ASSERT_TRUE(connectionList[0].delay==24);
+}
+
+TEST_F(routingTest,getSinkClassOfSink)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SinkClass_s sinkClass, returnClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name = "test";
+ sinkClass.sinkClassID = 4;
+ sinkClass.listClassProperties = classPropertyList;
+ pCF.createSink(sink);
+ sink.sinkClassID = 4;
+
+ //prepare test
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ //enter a new sinkclass, read out again and check
+ EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, 4);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkClassInfoDB(sinkID,returnClass));
+ ASSERT_EQ(sinkClassList[0].name, returnClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, returnClass.sinkClassID);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),returnClass.listClassProperties.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,getSourceClassOfSource)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SourceClass_s sourceClass, sinkSourceClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name = "test";
+ sourceClass.sourceClassID = 1;
+ sourceClass.listClassProperties = classPropertyList;
+ pCF.createSource(source);
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, 1);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceClassInfoDB(sourceID,sinkSourceClass));
+ ASSERT_EQ(sourceClassList[0].name, sinkSourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, sinkSourceClass.sourceClassID);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),sinkSourceClass.listClassProperties.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,removeSourceClass)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SourceClass_s sourceClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name = "test";
+ sourceClass.sourceClassID = 3;
+ sourceClass.listClassProperties = classPropertyList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(2);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, 3);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.removeSourceClassDB(3));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_TRUE(sourceClassList.empty());
+}
+
+TEST_F(routingTest,updateSourceClass)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList, changedPropertyList;
+ am_SourceClass_s sourceClass, changedClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name = "test";
+ sourceClass.sourceClassID = 0;
+ sourceClass.listClassProperties = classPropertyList;
+ changedClass = sourceClass;
+ changedClass.listClassProperties[1].value = 6;
+ changedPropertyList = changedClass.listClassProperties;
+ EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ changedClass.sourceClassID = sourceClassID;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, 100);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceClassInfoDB(changedClass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, 100);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,enterSourceClass)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SourceClass_s sourceClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name = "test";
+ sourceClass.sourceClassID = 0;
+ sourceClass.listClassProperties = classPropertyList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, 100);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,enterSourceClassStatic)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SourceClass_s sourceClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name = "test";
+ sourceClass.sourceClassID = 3;
+ sourceClass.listClassProperties = classPropertyList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, 3);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,removeSinkClass)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SinkClass_s sinkClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name = "test";
+ sinkClass.sinkClassID = 0;
+ sinkClass.listClassProperties = classPropertyList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(2);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.removeSinkClassDB(sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_TRUE(sinkClassList.empty());
+}
+
+TEST_F(routingTest,updateSinkClass)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList, changedPropertyList;
+ am_SinkClass_s sinkClass, changedClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name = "test";
+ sinkClass.sinkClassID = 0;
+ sinkClass.listClassProperties = classPropertyList;
+ changedClass = sinkClass;
+ changedClass.listClassProperties[1].value = 6;
+ changedPropertyList = changedClass.listClassProperties;
+ EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ changedClass.sinkClassID = sinkClassID;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkClassInfoDB(changedClass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,enterSinkClass)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SinkClass_s sinkClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name = "test";
+ sinkClass.sinkClassID = 0;
+ sinkClass.listClassProperties = classPropertyList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,enterSinkClassStatic)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SinkClass_s sinkClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name = "test";
+ sinkClass.sinkClassID = 4;
+ sinkClass.listClassProperties = classPropertyList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, 4);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest, changeSystemProperty)
+{
+ std::vector<am_SystemProperty_s> listSystemProperties, listReturn;
+ am_SystemProperty_s systemProperty;
+
+ systemProperty.type = SYP_TEST;
+ systemProperty.value = 33;
+ listSystemProperties.push_back(systemProperty);
+ EXPECT_CALL(pMockInterface,cbSystemPropertyChanged(_)).Times(1); //todo: check the exact value here
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSystemProperties(listSystemProperties));
+ systemProperty.value = 444;
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSystemPropertyDB(systemProperty));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSystemProperties(listReturn));
+ ASSERT_EQ(listReturn[0].type, systemProperty.type);
+ ASSERT_EQ(listReturn[0].value, systemProperty.value);
+}
+
+TEST_F(routingTest, systemProperties)
+{
+ std::vector<am_SystemProperty_s> listSystemProperties, listReturn;
+ am_SystemProperty_s systemProperty;
+
+ systemProperty.type = SYP_TEST;
+ systemProperty.value = 33;
+ listSystemProperties.push_back(systemProperty);
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSystemProperties(listSystemProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSystemProperties(listReturn));
+ ASSERT_EQ(listReturn[0].type, systemProperty.type);
+ ASSERT_EQ(listReturn[0].value, systemProperty.value);
+}
+
+TEST_F(routingTest,enterSourcesCorrect)
+{
+ //fill the connection database
+ am_Source_s staticSource, firstDynamicSource, secondDynamicSource;
+ am_sourceID_t staticSourceID, firstDynamicSourceID, secondDynamicSourceID;
+ std::vector<am_Source_s> sourceList;
+
+ pCF.createSource(staticSource);
+ staticSource.sourceID = 4;
+ staticSource.name = "Static";
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))
+ << "ERROR: database error";
+ ASSERT_EQ(staticSource.sourceID,staticSourceID)
+ << "ERROR: ID not the one given in staticSource";
+
+ pCF.createSource(firstDynamicSource);
+ firstDynamicSource.name = "firstDynamicSource";
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(firstDynamicSource,firstDynamicSourceID))
+ << "ERROR: database error";
+ ASSERT_EQ(firstDynamicSourceID,DYNAMIC_ID_BOUNDARY)
+ << "ERROR: ID not the one given in firstDynamicSink";
+
+ pCF.createSource(secondDynamicSource);
+ secondDynamicSource.name = "secondDynamicSource";
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(secondDynamicSource,secondDynamicSourceID))
+ << "ERROR: database error";
+ ASSERT_NEAR(secondDynamicSourceID,DYNAMIC_ID_BOUNDARY,10)
+ << "ERROR: ID not the one given in secondDynamicSink";
+
+ //now read back and check the returns agains the given values
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(sourceList))
+ << "ERROR: database error";
+ bool equal = true;
+
+ std::vector<am_Source_s>::iterator listIterator = sourceList.begin();
+ for (; listIterator < sourceList.end(); ++listIterator)
+ {
+ if (listIterator->sourceID == staticSourceID)
+ {
+ equal = equal && pCF.compareSource(listIterator, staticSource);
+ }
+
+ if (listIterator->sourceID == firstDynamicSourceID)
+ {
+ equal = equal && pCF.compareSource(listIterator, firstDynamicSource);
+ }
+
+ if (listIterator->sourceID == secondDynamicSourceID)
+ {
+ equal = equal && pCF.compareSource(listIterator, secondDynamicSource);
+ }
+
+ }
+ ASSERT_EQ(true, equal);
+}
+
+TEST_F(routingTest, changeSourceMainSoundProperty)
+{
+ std::vector<am_Source_s> listSources;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+ am_MainSoundProperty_s property;
+ property.type = MSP_NAVIGATION_OFFSET;
+ property.value = 33;
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+
+ EXPECT_CALL(pMockInterface,cbMainSourceSoundPropertyChanged(sourceID,_)).Times(1); //todo: check in detail
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSourceSoundPropertyDB(property,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ std::vector<am_MainSoundProperty_s>::iterator listIterator = listSources[0].listMainSoundProperties.begin();
+ for (; listIterator < listSources[0].listMainSoundProperties.end(); ++listIterator)
+ {
+ if (listIterator->type == property.type)
+ {
+ ASSERT_EQ(listIterator->value, property.value);
+ }
+ }
+}
+
+TEST_F(routingTest, changeSinkMuteState)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ am_MuteState_e muteState = MS_MUTED;
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ EXPECT_CALL(pMockInterface,cbSinkMuteStateChanged(sinkID,muteState)).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkMuteStateDB(muteState,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(muteState, listSinks[0].muteState);
+}
+
+TEST_F(routingTest, changeSinkMainSoundProperty)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ am_MainSoundProperty_s property;
+ property.type = MSP_NAVIGATION_OFFSET;
+ property.value = 33;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ EXPECT_CALL(pMockInterface,cbMainSinkSoundPropertyChanged(sinkID,_)).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSinkSoundPropertyDB(property,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ std::vector<am_MainSoundProperty_s>::iterator listIterator = listSinks[0].listMainSoundProperties.begin();
+ for (; listIterator < listSinks[0].listMainSoundProperties.end(); ++listIterator)
+ {
+ if (listIterator->type == property.type)
+ {
+ ASSERT_EQ(listIterator->value, property.value);
+ }
+ }
+}
+
+TEST_F(routingTest, peekDomain)
+{
+ std::vector<am_Domain_s> listDomains;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_domainID_t domain2ID;
+ pCF.createDomain(domain);
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekDomain(std::string("newdomain"),domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_TRUE(listDomains.empty());
+ ASSERT_EQ(domainID, 1);
+ domain.name = "newdomain";
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domain2ID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_EQ(domainID, domain2ID);
+ ASSERT_TRUE(listDomains[0].domainID==domainID);
+}
+
+TEST_F(routingTest, peekDomainFirstEntered)
+{
+ std::vector<am_Domain_s> listDomains;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_domainID_t domain2ID;
+ pCF.createDomain(domain);
+ domain.name = "newdomain";
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekDomain(std::string("newdomain"),domain2ID));
+ ASSERT_EQ(domainID, domain2ID);
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_TRUE(listDomains.size()==1);
+}
+
+TEST_F(routingTest, changeDomainState)
+{
+ std::vector<am_Domain_s> listDomains;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ pCF.createDomain(domain);
+ am_DomainState_e newState = DS_INDEPENDENT_STARTUP;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changDomainStateDB(newState,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_EQ(newState, listDomains[0].state);
+}
+
+TEST_F(routingTest, changeMainConnectionState)
+{
+ std::vector<am_MainConnection_s> listMainConnections;
+ createMainConnectionSetup();
+ EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeMainConnectionStateDB(1,CS_DISCONNECTING))
+ << "ERROR: database error";ASSERT_EQ(E_OK, pDatabaseHandler.getListMainConnections(listMainConnections));
+ ASSERT_EQ(CS_DISCONNECTING, listMainConnections[0].connectionState);
+}
+
+TEST_F(routingTest, changeSinkAvailability)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ am_Availability_s availability;
+ availability.availability = A_UNKNOWN;
+ availability.availabilityReason = AR_TEMPERATURE;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkAvailabilityDB(availability,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(availability.availability, listSinks[0].available.availability);
+ ASSERT_EQ(availability.availabilityReason, listSinks[0].available.availabilityReason);
+}
+
+TEST_F(routingTest, changeSourceAvailability)
+{
+ std::vector<am_Source_s> listSources;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+ am_Availability_s availability;
+ availability.availability = A_UNKNOWN;
+ availability.availabilityReason = AR_TEMPERATURE;
+ source.visible = true;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceAvailabilityDB(availability,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(availability.availability, listSources[0].available.availability);
+ ASSERT_EQ(availability.availabilityReason, listSources[0].available.availabilityReason);
+}
+
+TEST_F(routingTest,changeMainConnectionRoute)
+{
+ std::vector<am_MainConnection_s> originalList;
+ std::vector<am_MainConnection_s> newList;
+ createMainConnectionSetup();
+ //fill the connection database
+ am_Connection_s connection;
+ am_Source_s source;
+ am_Sink_s sink;
+ std::vector<am_Connection_s> connectionList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
+ for (uint16_t i = 1; i < 10; i++)
+ {
+ am_sinkID_t forgetSink;
+ am_sourceID_t forgetSource;
+ am_connectionID_t forgetConnection;
+
+ pCF.createConnection(connection);
+ connection.sinkID = i + 20;
+ connection.sourceID = i + 20;
+ connection.delay = -1;
+ connectionList.push_back(connection);
+
+ pCF.createSink(sink);
+ sink.sinkID = i + 20;
+ sink.name = "sink" + int2string(i + 20);
+ sink.domainID = 4;
+ pCF.createSource(source);
+ source.sourceID = i + 20;
+ source.name = "source" + int2string(i + 30);
+ source.domainID = 4;
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(originalList))
+ << "ERROR: database error";
+
+ }
+
+ //fill the route
+ std::vector<am_RoutingElement_s> routingList;
+ pCF.connectionList2RoutingList(routingList, connectionList);
+
+ //create the Route
+ am_Route_s route;
+ route.route = routingList;
+ route.sinkID = 2;
+ route.sourceID = 2;
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeMainConnectionRouteDB(1,route));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(newList))
+ << "ERROR: database error";ASSERT_TRUE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),routingList.begin(),equalRoutingElement));
+ ASSERT_FALSE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),originalList[0].route.route.begin(),equalRoutingElement));
+}
+
+TEST_F(routingTest,changeMainSinkVolume)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_mainVolume_t newVol = 20;
+ std::vector<am_Sink_s> listSinks;
+ pCF.createSink(sink);
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ EXPECT_CALL(pMockInterface,cbVolumeChanged(sinkID,newVol)).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkMainVolumeDB(newVol,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(listSinks[0].mainVolume, newVol);
+}
+
+TEST_F(routingTest,getMainSourceSoundProperties)
+{
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+ std::vector<am_MainSoundProperty_s> mainSoundProperties = source.listMainSoundProperties;
+ std::vector<am_MainSoundProperty_s> listMainSoundProperties;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSourceSoundProperties(sourceID,listMainSoundProperties));
+ ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
+}
+
+TEST_F(routingTest,getMainSinkSoundProperties)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ std::vector<am_MainSoundProperty_s> mainSoundProperties = sink.listMainSoundProperties;
+ std::vector<am_MainSoundProperty_s> listMainSoundProperties;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSinkSoundProperties(sinkID,listMainSoundProperties));
+ ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
+}
+
+TEST_F(routingTest,getMainSources)
+{
+ am_Source_s source, source1, source2;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+ pCF.createSource(source1);
+ pCF.createSource(source2);
+ source1.name = "source1";
+ source2.name = "source2";
+ bool equal = true;
+ source1.visible = false;
+ std::vector<am_SourceType_s> listMainSources;
+ std::vector<am_Source_s> listSources;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+ source.sourceID = sourceID;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source1,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source2,sourceID));
+ source2.sourceID = sourceID;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSources(listMainSources));
+ listSources.push_back(source);
+ listSources.push_back(source2);
+ std::vector<am_SourceType_s>::iterator listIterator = listMainSources.begin();
+ for (; listIterator < listMainSources.end(); ++listIterator)
+ {
+ equal = equal && pCF.compareSinkMainSource(listIterator, listSources);
+ }
+ ASSERT_TRUE(equal);
+}
+
+TEST_F(routingTest,getMainSinks)
+{
+ am_Sink_s sink, sink1, sink2;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ pCF.createSink(sink1);
+ pCF.createSink(sink2);
+ sink1.name = "sink1";
+ sink2.name = "sink2";
+ bool equal = true;
+ sink1.visible = false;
+ std::vector<am_SinkType_s> listMainSinks;
+ std::vector<am_Sink_s> listSinks;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+ sink.sinkID = sinkID;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink1,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink2,sinkID));
+ sink2.sinkID = sinkID;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSinks(listMainSinks));
+ listSinks.push_back(sink);
+ listSinks.push_back(sink2);
+ std::vector<am_SinkType_s>::iterator listIterator = listMainSinks.begin();
+ for (; listIterator < listMainSinks.end(); ++listIterator)
+ {
+ equal = equal && pCF.compareSinkMainSink(listIterator, listSinks);
+ }
+ ASSERT_TRUE(equal);
+}
+
+TEST_F(routingTest,getVisibleMainConnections)
+{
+ createMainConnectionSetup();
+ am_MainConnection_s mainConnection;
+ am_Route_s route;
+ pCF.createMainConnection(mainConnection, route);
+ std::vector<am_MainConnectionType_s> visibleMainConnection;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListVisibleMainConnections(visibleMainConnection));
+ ASSERT_TRUE(1==visibleMainConnection[0].mainConnectionID);
+ ASSERT_TRUE(mainConnection.connectionState==visibleMainConnection[0].connectionState);
+ ASSERT_TRUE(mainConnection.delay==visibleMainConnection[0].delay);
+ ASSERT_TRUE(1==visibleMainConnection[0].sinkID);
+ ASSERT_TRUE(1==visibleMainConnection[0].sourceID);
+}
+
+TEST_F(routingTest,getListSourcesOfDomain)
+{
+ am_Source_s source, source2;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_sourceID_t sourceID;
+ std::vector<am_sourceID_t> sourceList, sourceCheckList;
+ pCF.createSource(source);
+ source.sourceID = 1;
+ source.name = "testSource";
+ source.domainID = 1;
+ pCF.createSource(source2);
+ source2.sourceID = 0;
+ source2.name = "testSource2";
+ source2.domainID = 5;
+ pCF.createDomain(domain);
+ sourceCheckList.push_back(1); //sink.sinkID);
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source2,sourceID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSourcesOfDomain(2,sourceList))
+ << "ERROR: database error";ASSERT_TRUE(sourceList.empty());
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSourcesOfDomain(1,sourceList))
+ << "ERROR: database error";
+ ASSERT_TRUE(std::equal(sourceList.begin(),sourceList.end(),sourceCheckList.begin()) && !sourceList.empty());
+}
+
+TEST_F(routingTest,getListSinksOfDomain)
+{
+ am_Sink_s sink, sink2;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_sinkID_t sinkID;
+ std::vector<am_sinkID_t> sinkList, sinkCheckList;
+ pCF.createSink(sink);
+ sink.sinkID = 1;
+ sink.domainID = 1;
+ pCF.createSink(sink2);
+ sink2.domainID = 5;
+ sink2.name = "sink2";
+ pCF.createDomain(domain);
+ sinkCheckList.push_back(1); //sink.sinkID);
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink2,sinkID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSinksOfDomain(2,sinkList))
+ << "ERROR: database error";ASSERT_TRUE(sinkList.empty());
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinksOfDomain(1,sinkList))
+ << "ERROR: database error";
+ ASSERT_TRUE(std::equal(sinkList.begin(),sinkList.end(),sinkCheckList.begin()) && !sinkList.empty());
+}
+
+TEST_F(routingTest,getListGatewaysOfDomain)
+{
+ am_Gateway_s gateway, gateway2;
+ am_gatewayID_t gatewayID;
+ am_domainID_t domainID;
+ am_Domain_s domain;
+ std::vector<am_gatewayID_t> gatewayList, gatewayCheckList;
+ pCF.createGateway(gateway);
+ gateway.gatewayID = 1;
+ gateway.name = "testGateway";
+ gateway.controlDomainID = 1;
+ gateway.sourceID = 1;
+ gateway.sinkID = 1;
+ gateway.domainSinkID = 1;
+ gateway.domainSourceID = 1;
+ pCF.createGateway(gateway2);
+ gateway2.gatewayID = 2;
+ gateway2.name = "testGateway2";
+ gateway2.controlDomainID = 4;
+ gateway2.sourceID = 1;
+ gateway2.sinkID = 1;
+ gateway2.domainSinkID = 1;
+ gateway2.domainSourceID = 1;
+ pCF.createDomain(domain);
+ gatewayCheckList.push_back(gateway.gatewayID);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListGatewaysOfDomain(2,gatewayList))
+ << "ERROR: database error";ASSERT_TRUE(gatewayList.empty());
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListGatewaysOfDomain(1,gatewayList))
+ << "ERROR: database error";
+ ASSERT_TRUE(std::equal(gatewayList.begin(),gatewayList.end(),gatewayCheckList.begin()) && !gatewayList.empty());
+}
+
+TEST_F(routingTest,removeDomain)
+{
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Domain_s> listDomains;
+ pCF.createDomain(domain);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeDomainDB(domainID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains))
+ << "ERROR: database error";
+ ASSERT_TRUE(listDomains.empty());
+}
+
+TEST_F(routingTest,removeGateway)
+{
+ am_Gateway_s gateway;
+ am_gatewayID_t gatewayID;
+ std::vector<am_Gateway_s> listGateways;
+ pCF.createGateway(gateway);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeGatewayDB(gatewayID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(listGateways))
+ << "ERROR: database error";
+ ASSERT_TRUE(listGateways.empty());
+}
+
+TEST_F(routingTest,removeSink)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ std::vector<am_Sink_s> listSinks;
+ pCF.createSink(sink);
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkDB(sinkID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks))
+ << "ERROR: database error";
+ ASSERT_TRUE(listSinks.empty());
+}
+
+TEST_F(routingTest,removeSource)
+{
+ //fill the connection database
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ std::vector<am_Source_s> listSources;
+ pCF.createSource(source);
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceDB(sourceID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources))
+ << "ERROR: database error";
+ ASSERT_TRUE(listSources.empty());
+}
+
+TEST_F(routingTest, removeMainConnection)
+{
+ createMainConnectionSetup();
+ EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
+ EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeMainConnectionDB(1))
+ << "ERROR: database error";
+}
+
+TEST_F(routingTest,removeNonexistentMainConnectionFail)
+{
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeMainConnectionDB(34))
+ << "ERROR: database error";
+}
+
+TEST_F(routingTest,removeNonexistentSource)
+{
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSourceDB(3))
+ << "ERROR: database error";
+}
+
+TEST_F(routingTest,removeNonexistentSink)
+{
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSinkDB(2))
+ << "ERROR: database error";
}
-TEST_F(databaseTest,registerGatewayCorrect)
+TEST_F(routingTest,removeNonexistentGateway)
{
- //initialize gateway
- std::vector<am_Gateway_s> returnList;
- am_Gateway_s gateway, gateway1, gateway2;
- am_gatewayID_t gatewayID=0,gatewayID1=0,gatewayID2=0;
-
- pCF.createGateway(gateway);
- pCF.createGateway(gateway1);
- gateway1.gatewayID=20;
- pCF.createGateway(gateway2);
-
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
- ASSERT_EQ(100,gatewayID)<< "ERROR: domainID zero";
-
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))<< "ERROR: database error";
- ASSERT_EQ(gateway1.gatewayID,gatewayID1)<< "ERROR: domainID zero";
-
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))<< "ERROR: database error";
- ASSERT_EQ(101,gatewayID2)<< "ERROR: domainID zero";
-
- //now check if we read out the correct values
- ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(returnList));
- bool equal=true;
- std::vector<am_Gateway_s>::iterator listIterator=returnList.begin();
-
- for(;listIterator<returnList.end();++listIterator)
- {
- if(listIterator->gatewayID==gatewayID)
- {
- equal= equal && pCF.compareGateway(listIterator,gateway);
- }
-
- if(listIterator->gatewayID==gatewayID1)
- {
- equal= equal && pCF.compareGateway(listIterator,gateway1);
- }
-
- if(listIterator->gatewayID==gatewayID2)
- {
- equal= equal && pCF.compareGateway(listIterator,gateway2);
- }
- }
-
- ASSERT_EQ(true,equal);
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeGatewayDB(12))
+ << "ERROR: database error";
}
-TEST_F(databaseTest,getGatewayInfo)
+TEST_F(routingTest,registerGatewayCorrect)
{
- //initialize gateway
- std::vector<am_Gateway_s> returnList;
- am_Gateway_s gateway, gateway1, gateway2;
- am_gatewayID_t gatewayID=0,gatewayID1=0,gatewayID2=0;
-
- pCF.createGateway(gateway);
- pCF.createGateway(gateway1);
- gateway1.gatewayID=20;
- pCF.createGateway(gateway2);
+ //initialize gateway
+ std::vector<am_Gateway_s> returnList;
+ am_Gateway_s gateway, gateway1, gateway2;
+ am_gatewayID_t gatewayID = 0, gatewayID1 = 0, gatewayID2 = 0;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
- ASSERT_EQ(100,gatewayID)<< "ERROR: domainID zero";
+ pCF.createGateway(gateway);
+ pCF.createGateway(gateway1);
+ gateway1.gatewayID = 20;
+ pCF.createGateway(gateway2);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))<< "ERROR: database error";
- ASSERT_EQ(gateway1.gatewayID,gatewayID1)<< "ERROR: domainID zero";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
+ << "ERROR: database error";
+ ASSERT_EQ(100,gatewayID)
+ << "ERROR: domainID zero";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))<< "ERROR: database error";
- ASSERT_EQ(101,gatewayID2)<< "ERROR: domainID zero";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))
+ << "ERROR: database error";
+ ASSERT_EQ(gateway1.gatewayID,gatewayID1)
+ << "ERROR: domainID zero";
- //now check if we read out the correct values
- ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(returnList));
- bool equal=true;
- std::vector<am_Gateway_s>::iterator listIterator=returnList.begin();
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))
+ << "ERROR: database error";
+ ASSERT_EQ(101,gatewayID2)
+ << "ERROR: domainID zero";
- for(;listIterator<returnList.end();++listIterator)
- {
- if(listIterator->gatewayID==gatewayID)
- {
- equal= equal && pCF.compareGateway(listIterator,gateway);
- }
+ //now check if we read out the correct values
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListGateways(returnList));
+ bool equal = true;
+ std::vector<am_Gateway_s>::iterator listIterator = returnList.begin();
- if(listIterator->gatewayID==gatewayID1)
- {
- equal= equal && pCF.compareGateway(listIterator,gateway1);
- }
+ for (; listIterator < returnList.end(); ++listIterator)
+ {
+ if (listIterator->gatewayID == gatewayID)
+ {
+ equal = equal && pCF.compareGateway(listIterator, gateway);
+ }
- if(listIterator->gatewayID==gatewayID2)
- {
- equal= equal && pCF.compareGateway(listIterator,gateway2);
- }
- }
+ if (listIterator->gatewayID == gatewayID1)
+ {
+ equal = equal && pCF.compareGateway(listIterator, gateway1);
+ }
- ASSERT_EQ(true,equal);
-
- am_Gateway_s gatewayInfo;
- ASSERT_EQ(E_OK,pDatabaseHandler.getGatewayInfoDB(20,gatewayInfo));
- ASSERT_TRUE(pCF.compareGateway1(gateway1,gatewayInfo));
+ if (listIterator->gatewayID == gatewayID2)
+ {
+ equal = equal && pCF.compareGateway(listIterator, gateway2);
+ }
+ }
+ ASSERT_EQ(true, equal);
}
-TEST_F(databaseTest,enterSinkThatAlreadyExistFail)
+TEST_F(routingTest,getGatewayInfo)
{
- //fill the connection database
- am_Sink_s staticSink,SecondSink;
- am_sinkID_t staticSinkID,SecondSinkID;
+ //initialize gateway
+ std::vector<am_Gateway_s> returnList;
+ am_Gateway_s gateway, gateway1, gateway2;
+ am_gatewayID_t gatewayID = 0, gatewayID1 = 0, gatewayID2 = 0;
- pCF.createSink(staticSink);
- staticSink.sinkID=43;
- staticSink.name="Static";
+ pCF.createGateway(gateway);
+ pCF.createGateway(gateway1);
+ gateway1.gatewayID = 20;
+ pCF.createGateway(gateway2);
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))<< "ERROR: database error";
- ASSERT_EQ(staticSink.sinkID,staticSinkID)<< "ERROR: ID not the one given in staticSink";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
+ << "ERROR: database error";
+ ASSERT_EQ(100,gatewayID)
+ << "ERROR: domainID zero";
- pCF.createSink(SecondSink);
- SecondSink.sinkID=43;
- SecondSink.name="SecondSink";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))
+ << "ERROR: database error";
+ ASSERT_EQ(gateway1.gatewayID,gatewayID1)
+ << "ERROR: domainID zero";
- ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSinkDB(SecondSink,SecondSinkID))<< "ERROR: database error";
-}
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))
+ << "ERROR: database error";
+ ASSERT_EQ(101,gatewayID2)
+ << "ERROR: domainID zero";
-TEST_F(databaseTest,enterSourcesThatAlreadyExistFail)
-{
- //fill the connection database
- am_Source_s staticSource,SecondSource;
- am_sourceID_t staticSourceID,SecondSourceID;
- pCF.createSource(staticSource);
- staticSource.sourceID=4;
+ //now check if we read out the correct values
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListGateways(returnList));
+ bool equal = true;
+ std::vector<am_Gateway_s>::iterator listIterator = returnList.begin();
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))<< "ERROR: database error";
- ASSERT_EQ(staticSource.sourceID,staticSourceID)<< "ERROR: ID not the one given in staticSource";
+ for (; listIterator < returnList.end(); ++listIterator)
+ {
+ if (listIterator->gatewayID == gatewayID)
+ {
+ equal = equal && pCF.compareGateway(listIterator, gateway);
+ }
- pCF.createSource(SecondSource);
- SecondSource.sourceID=4;
+ if (listIterator->gatewayID == gatewayID1)
+ {
+ equal = equal && pCF.compareGateway(listIterator, gateway1);
+ }
+
+ if (listIterator->gatewayID == gatewayID2)
+ {
+ equal = equal && pCF.compareGateway(listIterator, gateway2);
+ }
+ }
+
+ ASSERT_EQ(true, equal);
+
+ am_Gateway_s gatewayInfo;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getGatewayInfoDB(20,gatewayInfo));
+ ASSERT_TRUE(pCF.compareGateway1(gateway1,gatewayInfo));
+
+}
+
+TEST_F(routingTest,enterSinkThatAlreadyExistFail)
+{
+ //fill the connection database
+ am_Sink_s staticSink, SecondSink;
+ am_sinkID_t staticSinkID, SecondSinkID;
- ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSourceDB(SecondSource,SecondSourceID))<< "ERROR: database error";
-}
+ pCF.createSink(staticSink);
+ staticSink.sinkID = 43;
+ staticSink.name = "Static";
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))
+ << "ERROR: database error";
+ ASSERT_EQ(staticSink.sinkID,staticSinkID)
+ << "ERROR: ID not the one given in staticSink";
-TEST_F(databaseTest,registerDomainCorrect)
-{
- //initialize domain
- std::vector<am_Domain_s> returnList;
- am_Domain_s domain;
- am_domainID_t domainID=0;
- pCF.createDomain(domain);
+ pCF.createSink(SecondSink);
+ SecondSink.sinkID = 43;
+ SecondSink.name = "SecondSink";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))<< "ERROR: database error";
- ASSERT_NE(0,domainID)<< "ERROR: domainID zero";
+ ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSinkDB(SecondSink,SecondSinkID))
+ << "ERROR: database error";
+}
+
+TEST_F(routingTest,enterSourcesThatAlreadyExistFail)
+{
+ //fill the connection database
+ am_Source_s staticSource, SecondSource;
+ am_sourceID_t staticSourceID, SecondSourceID;
+ pCF.createSource(staticSource);
+ staticSource.sourceID = 4;
- //now check if we read out the correct values
- ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(returnList));
- bool equal=true;
- std::vector<am_Domain_s>::iterator listIterator=returnList.begin();
- for(;listIterator<returnList.end();++listIterator)
- {
- if(listIterator->domainID==domainID) {
- equal= equal && (listIterator->name.compare(domain.name)==0)
- && (listIterator->busname.compare(domain.busname)==0)
- && (listIterator->complete == domain.complete)
- && (listIterator->early == domain.early)
- && (listIterator->state == domain.state);
- }
- }
- ASSERT_EQ(true,equal);
-}
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))
+ << "ERROR: database error";
+ ASSERT_EQ(staticSource.sourceID,staticSourceID)
+ << "ERROR: ID not the one given in staticSource";
-TEST_F(databaseTest,registerConnectionCorrect)
-{
- am_Connection_s connection;
- am_connectionID_t connectionID;
- std::vector<am_Connection_s> returnList;
- pCF.createConnection(connection);
+ pCF.createSource(SecondSource);
+ SecondSource.sourceID = 4;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID))<< "ERROR: database error";;
- ASSERT_NE(0,connectionID)<< "ERROR: connectionID zero";
+ ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSourceDB(SecondSource,SecondSourceID))
+ << "ERROR: database error";
+}
+
+TEST_F(routingTest,registerDomainCorrect)
+{
+ //initialize domain
+ std::vector<am_Domain_s> returnList;
+ am_Domain_s domain;
+ am_domainID_t domainID = 0;
+ pCF.createDomain(domain);
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))
+ << "ERROR: database error";
+ ASSERT_NE(0,domainID)
+ << "ERROR: domainID zero";
+
+ //now check if we read out the correct values
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(returnList));
+ bool equal = true;
+ std::vector<am_Domain_s>::iterator listIterator = returnList.begin();
+ for (; listIterator < returnList.end(); ++listIterator)
+ {
+ if (listIterator->domainID == domainID)
+ {
+ equal = equal && (listIterator->name.compare(domain.name) == 0) && (listIterator->busname.compare(domain.busname) == 0) && (listIterator->complete == domain.complete) && (listIterator->early == domain.early) && (listIterator->state == domain.state);
+ }
+ }
+ ASSERT_EQ(true, equal);
+}
+
+TEST_F(routingTest,registerConnectionCorrect)
+{
+ am_Connection_s connection;
+ am_connectionID_t connectionID;
+ std::vector<am_Connection_s> returnList;
+ pCF.createConnection(connection);
- //now check if we read out the correct values
- ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(returnList));
- bool equal=false;
- std::vector<am_Connection_s>::iterator listIterator=returnList.begin();
- for(;listIterator<returnList.end();++listIterator)
- {
- if(listIterator->connectionID==connectionID) {
- equal= (listIterator->sourceID == connection.sourceID)
- && (listIterator->sinkID == connection.sinkID)
- && (listIterator->delay == connection.delay)
- && (listIterator->connectionFormat = connection.connectionFormat);
- }
- }
- ASSERT_EQ(true,equal);
-}
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID))
+ << "ERROR: database error";;
+ ASSERT_NE(0,connectionID)
+ << "ERROR: connectionID zero";
-TEST_F(databaseTest,enterMainConnectionCorrect)
-{
- createMainConnectionSetup();
+ //now check if we read out the correct values
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(connectionID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(returnList));
+ bool equal = false;
+ std::vector<am_Connection_s>::iterator listIterator = returnList.begin();
+ for (; listIterator < returnList.end(); ++listIterator)
+ {
+ if (listIterator->connectionID == connectionID)
+ {
+ equal = (listIterator->sourceID == connection.sourceID) && (listIterator->sinkID == connection.sinkID) && (listIterator->delay == connection.delay) && (listIterator->connectionFormat = connection.connectionFormat);
+ }
+ }
+ ASSERT_EQ(true, equal);
}
-TEST_F(databaseTest,enterSinksCorrect)
-{
- //fill the connection database
- am_Sink_s staticSink,firstDynamicSink,secondDynamicSink;
- am_sinkID_t staticSinkID,firstDynamicSinkID,secondDynamicSinkID;
- std::vector<am_Sink_s> sinkList;
-
- pCF.createSink(staticSink);
- staticSink.sinkID=4;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))<< "ERROR: database error";
- ASSERT_EQ(staticSink.sinkID,staticSinkID)<< "ERROR: ID not the one given in staticSink";
-
- pCF.createSink(firstDynamicSink);
- firstDynamicSink.name="firstdynamic";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(firstDynamicSink,firstDynamicSinkID))<< "ERROR: database error";
- ASSERT_EQ(firstDynamicSinkID,DYNAMIC_ID_BOUNDARY)<< "ERROR: ID not the one given in firstDynamicSink";
-
- pCF.createSink(secondDynamicSink);
- secondDynamicSink.name="seconddynamic";
-
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(secondDynamicSink,secondDynamicSinkID))<< "ERROR: database error";
- ASSERT_NEAR(secondDynamicSinkID,DYNAMIC_ID_BOUNDARY,10)<< "ERROR: ID not the one given in secondDynamicSink";
-
- //now read back and check the returns agains the given values
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(sinkList))<< "ERROR: database error";
- bool equal=true;
-
- std::vector<am_Sink_s>::iterator listIterator=sinkList.begin();
- for(;listIterator<sinkList.end();++listIterator)
- {
- if(listIterator->sinkID==staticSinkID)
- {
- equal = equal && pCF.compareSink(listIterator,staticSink);
- }
-
- if(listIterator->sinkID==firstDynamicSinkID)
- {
- equal = equal && pCF.compareSink(listIterator,firstDynamicSink);
- }
-
- if(listIterator->sinkID==secondDynamicSinkID)
- {
- equal = equal && pCF.compareSink(listIterator,secondDynamicSink);
- }
- }
- ASSERT_EQ(true,equal);
+TEST_F(routingTest,enterMainConnectionCorrect)
+{
+ createMainConnectionSetup();
+}
+
+TEST_F(routingTest,enterSinksCorrect)
+{
+ //fill the connection database
+ am_Sink_s staticSink, firstDynamicSink, secondDynamicSink;
+ am_sinkID_t staticSinkID, firstDynamicSinkID, secondDynamicSinkID;
+ std::vector<am_Sink_s> sinkList;
+
+ pCF.createSink(staticSink);
+ staticSink.sinkID = 4;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))
+ << "ERROR: database error";
+ ASSERT_EQ(staticSink.sinkID,staticSinkID)
+ << "ERROR: ID not the one given in staticSink";
+
+ pCF.createSink(firstDynamicSink);
+ firstDynamicSink.name = "firstdynamic";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(firstDynamicSink,firstDynamicSinkID))
+ << "ERROR: database error";
+ ASSERT_EQ(firstDynamicSinkID,DYNAMIC_ID_BOUNDARY)
+ << "ERROR: ID not the one given in firstDynamicSink";
+
+ pCF.createSink(secondDynamicSink);
+ secondDynamicSink.name = "seconddynamic";
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(secondDynamicSink,secondDynamicSinkID))
+ << "ERROR: database error";
+ ASSERT_NEAR(secondDynamicSinkID,DYNAMIC_ID_BOUNDARY,10)
+ << "ERROR: ID not the one given in secondDynamicSink";
+
+ //now read back and check the returns agains the given values
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(sinkList))
+ << "ERROR: database error";
+ bool equal = true;
+
+ std::vector<am_Sink_s>::iterator listIterator = sinkList.begin();
+ for (; listIterator < sinkList.end(); ++listIterator)
+ {
+ if (listIterator->sinkID == staticSinkID)
+ {
+ equal = equal && pCF.compareSink(listIterator, staticSink);
+ }
+
+ if (listIterator->sinkID == firstDynamicSinkID)
+ {
+ equal = equal && pCF.compareSink(listIterator, firstDynamicSink);
+ }
+
+ if (listIterator->sinkID == secondDynamicSinkID)
+ {
+ equal = equal && pCF.compareSink(listIterator, secondDynamicSink);
+ }
+ }
+ ASSERT_EQ(true, equal);
}
//Commented out - gives always a warning..
@@ -1539,18 +1592,9 @@ TEST_F(databaseTest,enterSinksCorrect)
// ASSERT_DEATH(pDatabaseHandler.enterDomainDB(domain,domainID),"Assertion `domainData.domainID==0'");
//}
-
int main(int argc, char **argv)
{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
-
-
-
-
-
-
-
-
diff --git a/AudioManagerDaemon/test/database/databaseTest.h b/AudioManagerDaemon/test/database/databaseTest.h
index 4098dc0..0d46b68 100644
--- a/AudioManagerDaemon/test/database/databaseTest.h
+++ b/AudioManagerDaemon/test/database/databaseTest.h
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file databasetest.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file databasetest.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#ifndef DATABASETEST_H_
#define DATABASETEST_H_
@@ -45,28 +45,29 @@
#include "../CommandInterfaceBackdoor.h"
#include "../CommonFunctions.h"
-namespace am {
+namespace am
+{
-
-class databaseTest : public ::testing::Test {
+class routingTest: public ::testing::Test
+{
public:
- databaseTest();
- ~databaseTest();
- std::vector<std::string> plistRoutingPluginDirs;
- std::vector<std::string> plistCommandPluginDirs;
- DatabaseHandler pDatabaseHandler;
- RoutingSender pRoutingSender;
- CommandSender pCommandSender;
- MockCommandSendInterface pMockInterface;
- RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
- CommandInterfaceBackdoor pCommandInterfaceBackdoor;
- ControlReceiver pControlReceiver;
- DatabaseObserver pObserver;
- CommonFunctions pCF;
- void SetUp();
- void TearDown();
+ routingTest();
+ ~routingTest();
+ std::vector<std::string> plistRoutingPluginDirs;
+ std::vector<std::string> plistCommandPluginDirs;
+ DatabaseHandler pDatabaseHandler;
+ RoutingSender pRoutingSender;
+ CommandSender pCommandSender;
+ MockCommandSendInterface pMockInterface;
+ RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
+ CommandInterfaceBackdoor pCommandInterfaceBackdoor;
+ ControlReceiver pControlReceiver;
+ DatabaseObserver pObserver;
+ CommonFunctions pCF;
+ void SetUp();
+ void TearDown();
- void createMainConnectionSetup();
+ void createMainConnectionSetup();
};
}
diff --git a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp
index 8a66d57..6ebd99d 100644
--- a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp
+++ b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file routingInterfaces.cpp
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file routingInterfaces.cpp
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#include "routingInterfaceTest.h"
@@ -30,22 +30,22 @@ using namespace testing;
DLT_DECLARE_CONTEXT(DLT_CONTEXT);
-routingInterfaceTest::routingInterfaceTest()
- :plistRoutingPluginDirs(),
- plistCommandPluginDirs(),
- pDatabaseHandler(std::string(":memory:")),
- pRoutingSender(plistRoutingPluginDirs),
- pCommandSender(plistCommandPluginDirs),
- pMockInterface(),
- pRoutingInterfaceBackdoor(),
- pCommandInterfaceBackdoor(),
- pControlReceiver(&pDatabaseHandler,&pRoutingSender,&pCommandSender),
- pObserver(&pCommandSender,&pRoutingSender)
+routingInterfaceTest::routingInterfaceTest() :
+ plistRoutingPluginDirs(), //
+ plistCommandPluginDirs(), //
+ pDatabaseHandler(std::string(":memory:")), //
+ pRoutingSender(plistRoutingPluginDirs), //
+ pCommandSender(plistCommandPluginDirs), //
+ pMockInterface(), //
+ pRoutingInterfaceBackdoor(), //
+ pCommandInterfaceBackdoor(), //
+ pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), //
+ pObserver(&pCommandSender, &pRoutingSender)
{
- pDatabaseHandler.registerObserver(&pObserver);
- pRoutingInterfaceBackdoor.unloadPlugins(&pRoutingSender);
- pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender,&pMockInterface,"mock");
- pCommandInterfaceBackdoor.unloadPlugins(&pCommandSender);
+ pDatabaseHandler.registerObserver(&pObserver);
+ pRoutingInterfaceBackdoor.unloadPlugins(&pRoutingSender);
+ pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender, &pMockInterface, "mock");
+ pCommandInterfaceBackdoor.unloadPlugins(&pCommandSender);
}
routingInterfaceTest::~routingInterfaceTest()
@@ -54,389 +54,387 @@ routingInterfaceTest::~routingInterfaceTest()
void routingInterfaceTest::SetUp()
{
- DLT_REGISTER_APP("Rtest","RoutingInterfacetest");
- DLT_REGISTER_CONTEXT(DLT_CONTEXT,"Main","Main Context");
- DLT_LOG(DLT_CONTEXT,DLT_LOG_INFO, DLT_STRING("RoutingSendInterface Test started "));
+ DLT_REGISTER_APP("Rtest", "RoutingInterfacetest");
+ DLT_REGISTER_CONTEXT(DLT_CONTEXT, "Main", "Main Context");
+ DLT_LOG(DLT_CONTEXT, DLT_LOG_INFO, DLT_STRING("RoutingSendInterface Test started "));
}
void routingInterfaceTest::TearDown()
{
- DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
+ DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
}
TEST_F(routingInterfaceTest,abort)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
am_Handle_s handle;
am_connectionID_t connectionID;
- std::vector<am_Handle_s>listHandles;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
-
- //prepare the stage
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //start a connect, expect a call on the routingInterface
+ std::vector<am_Handle_s> listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+
+ //prepare the stage
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ //start a connect, expect a call on the routingInterface
EXPECT_CALL(pMockInterface,asyncConnect(_,_,1,sinkID,CF_ANALOG)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_EQ(E_OK, pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
//check the correctness of the handle
- ASSERT_NE(handle.handle,0);
- ASSERT_EQ(handle.handleType,H_CONNECT);
+ ASSERT_NE(handle.handle, 0);
+ ASSERT_EQ(handle.handleType, H_CONNECT);
//the handle must be inside the handlelist
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(listHandles));
ASSERT_TRUE(listHandles[0].handle==handle.handle);
ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
//send an abort expect a call on the routing interface
EXPECT_CALL(pMockInterface,asyncAbort(_)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.abortAction(handle));
+ ASSERT_EQ(E_OK, pControlReceiver.abortAction(handle));
//the reaction on the abort is specific for every function
//now we try to abort a handle that does not exist
- handle.handle=24;
- ASSERT_EQ(E_NON_EXISTENT,pControlReceiver.abortAction(handle));
+ handle.handle = 24;
+ ASSERT_EQ(E_NON_EXISTENT, pControlReceiver.abortAction(handle));
}
TEST_F(routingInterfaceTest,abortNonExistent)
{
EXPECT_CALL(pMockInterface,asyncAbort(_)).Times(0);
am_Handle_s handle;
- ASSERT_EQ(E_NON_EXISTENT,pControlReceiver.abortAction(handle));
+ ASSERT_EQ(E_NON_EXISTENT, pControlReceiver.abortAction(handle));
}
TEST_F(routingInterfaceTest,alreadyConnected)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
EXPECT_CALL(pMockInterface,asyncConnect(_,_,1,sinkID,CF_ANALOG)).WillOnce(Return(E_OK));
am_Handle_s handle;
am_connectionID_t connectionID;
- ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
- ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
- ASSERT_EQ(E_ALREADY_EXISTS,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
- ASSERT_NE(handle.handle,0);
- ASSERT_EQ(handle.handleType,H_CONNECT);
+ ASSERT_EQ(E_OK, pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(connectionID));
+ ASSERT_EQ(E_ALREADY_EXISTS, pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_NE(handle.handle, 0);
+ ASSERT_EQ(handle.handleType, H_CONNECT);
}
TEST_F(routingInterfaceTest,setSinkSoundPropertyNoChange)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
am_Handle_s handle;
am_SoundProperty_s soundProperty;
- soundProperty.type=SP_TREBLE;
- soundProperty.value=23;
- std::vector<am_Handle_s>listHandles;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
- sink.listSoundProperties.push_back(soundProperty);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ soundProperty.type = SP_TREBLE;
+ soundProperty.value = 23;
+ std::vector<am_Handle_s> listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+ sink.listSoundProperties.push_back(soundProperty);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,_,sinkID)).Times(0);
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty));
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty));
}
TEST_F(routingInterfaceTest,setSourceState)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- am_Domain_s domain;
- am_domainID_t domainID;
- am_Handle_s handle;
- handle.handle=0;
- am_SourceState_e state=SS_PAUSED;
- pCF.createSource(source);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- source.domainID=1;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
- EXPECT_CALL(pMockInterface,asyncSetSourceState(_,sourceID,state)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSourceState(handle,sourceID,state));
- ASSERT_NE(handle.handle,0);
- ASSERT_EQ(handle.handleType,H_SETSOURCESTATE);
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ handle.handle = 0;
+ am_SourceState_e state = SS_PAUSED;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ source.domainID = 1;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,asyncSetSourceState(_,sourceID,state)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.setSourceState(handle,sourceID,state));
+ ASSERT_NE(handle.handle, 0);
+ ASSERT_EQ(handle.handleType, H_SETSOURCESTATE);
}
TEST_F(routingInterfaceTest,setSourceSoundProperty)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- am_Domain_s domain;
- am_domainID_t domainID;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
am_Handle_s handle;
am_SoundProperty_s soundProperty;
- std::vector<am_Handle_s>listHandles;
- pCF.createSource(source);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- source.sourceID=2;
- source.domainID=1;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ std::vector<am_Handle_s> listHandles;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ source.sourceID = 2;
+ source.domainID = 1;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
EXPECT_CALL(pMockInterface,asyncSetSourceSoundProperty(_,_,sourceID)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSourceSoundProperty(handle,sourceID,soundProperty));
- ASSERT_NE(handle.handle,0);
- ASSERT_EQ(handle.handleType,H_SETSOURCESOUNDPROPERTY);
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_EQ(E_OK, pControlReceiver.setSourceSoundProperty(handle,sourceID,soundProperty));
+ ASSERT_NE(handle.handle, 0);
+ ASSERT_EQ(handle.handleType, H_SETSOURCESOUNDPROPERTY);
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(listHandles));
ASSERT_TRUE(listHandles[0].handle==handle.handle);
ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
}
TEST_F(routingInterfaceTest,setSinkSoundProperty)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
am_Handle_s handle;
am_SoundProperty_s soundProperty;
- std::vector<am_Handle_s>listHandles;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ std::vector<am_Handle_s> listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,_,sinkID)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty));
- ASSERT_NE(handle.handle,0);
- ASSERT_EQ(handle.handleType,H_SETSINKSOUNDPROPERTY);
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty));
+ ASSERT_NE(handle.handle, 0);
+ ASSERT_EQ(handle.handleType, H_SETSINKSOUNDPROPERTY);
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(listHandles));
ASSERT_TRUE(listHandles[0].handle==handle.handle);
ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
}
TEST_F(routingInterfaceTest,setSourceVolumeNoChange)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- am_Domain_s domain;
- am_domainID_t domainID;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
am_Handle_s handle;
- am_volume_t volume=34;
- am_RampType_e rampType=RAMP_DIRECT;
- am_time_t rampTime=300;
- std::vector<am_Handle_s>listHandles;
- pCF.createSource(source);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- source.sourceID=2;
- source.domainID=1;
- source.volume=volume;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ am_volume_t volume = 34;
+ am_RampType_e rampType = RAMP_DIRECT;
+ am_time_t rampTime = 300;
+ std::vector<am_Handle_s> listHandles;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ source.sourceID = 2;
+ source.domainID = 1;
+ source.volume = volume;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
EXPECT_CALL(pMockInterface,asyncSetSourceVolume(_,2,volume,rampType,rampTime)).Times(0);
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSourceVolume(handle,2,volume,rampType,rampTime));
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSourceVolume(handle,2,volume,rampType,rampTime));
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(listHandles));
ASSERT_TRUE(listHandles.empty());
}
TEST_F(routingInterfaceTest,setSourceVolume)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- am_Domain_s domain;
- am_domainID_t domainID;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
am_Handle_s handle;
- am_volume_t volume=34;
- am_RampType_e rampType=RAMP_DIRECT;
- am_time_t rampTime=300;
- std::vector<am_Handle_s>listHandles;
- pCF.createSource(source);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- source.sourceID=2;
- source.domainID=1;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ am_volume_t volume = 34;
+ am_RampType_e rampType = RAMP_DIRECT;
+ am_time_t rampTime = 300;
+ std::vector<am_Handle_s> listHandles;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ source.sourceID = 2;
+ source.domainID = 1;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
EXPECT_CALL(pMockInterface,asyncSetSourceVolume(_,2,volume,rampType,rampTime)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSourceVolume(handle,2,volume,rampType,rampTime));
- ASSERT_NE(handle.handle,0);
- ASSERT_EQ(handle.handleType,H_SETSOURCEVOLUME);
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_EQ(E_OK, pControlReceiver.setSourceVolume(handle,2,volume,rampType,rampTime));
+ ASSERT_NE(handle.handle, 0);
+ ASSERT_EQ(handle.handleType, H_SETSOURCEVOLUME);
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(listHandles));
ASSERT_TRUE(listHandles[0].handle==handle.handle);
ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
}
TEST_F(routingInterfaceTest,setSinkVolumeNoChange)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
am_Handle_s handle;
- am_volume_t volume=34;
- am_RampType_e rampType=RAMP_DIRECT;
- am_time_t rampTime=300;
- std::vector<am_Handle_s>listHandles;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
- sink.volume=volume;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ am_volume_t volume = 34;
+ am_RampType_e rampType = RAMP_DIRECT;
+ am_time_t rampTime = 300;
+ std::vector<am_Handle_s> listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+ sink.volume = volume;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
EXPECT_CALL(pMockInterface,asyncSetSinkVolume(_,2,volume,rampType,rampTime)).Times(0);
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSinkVolume(handle,2,volume,rampType,rampTime));
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSinkVolume(handle,2,volume,rampType,rampTime));
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(listHandles));
ASSERT_TRUE(listHandles.empty());
}
TEST_F(routingInterfaceTest,setSinkVolume)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
am_Handle_s handle;
- am_volume_t volume=34;
- am_RampType_e rampType=RAMP_DIRECT;
- am_time_t rampTime=300;
- std::vector<am_Handle_s>listHandles;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ am_volume_t volume = 34;
+ am_RampType_e rampType = RAMP_DIRECT;
+ am_time_t rampTime = 300;
+ std::vector<am_Handle_s> listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
EXPECT_CALL(pMockInterface,asyncSetSinkVolume(_,2,volume,rampType,rampTime)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSinkVolume(handle,2,volume,rampType,rampTime));
- ASSERT_NE(handle.handle,0);
- ASSERT_EQ(handle.handleType,H_SETSINKVOLUME);
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkVolume(handle,2,volume,rampType,rampTime));
+ ASSERT_NE(handle.handle, 0);
+ ASSERT_EQ(handle.handleType, H_SETSINKVOLUME);
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(listHandles));
ASSERT_TRUE(listHandles[0].handle==handle.handle);
ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
}
TEST_F(routingInterfaceTest,connect)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
am_Handle_s handle;
am_connectionID_t connectionID;
- std::vector<am_Handle_s>listHandles;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ std::vector<am_Handle_s> listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
EXPECT_CALL(pMockInterface,asyncConnect(_,_,1,sinkID,CF_ANALOG)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
- ASSERT_NE(handle.handle,0);
- ASSERT_EQ(handle.handleType,H_CONNECT);
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_EQ(E_OK, pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_NE(handle.handle, 0);
+ ASSERT_EQ(handle.handleType, H_CONNECT);
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(listHandles));
ASSERT_TRUE(listHandles[0].handle==handle.handle);
ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
}
TEST_F(routingInterfaceTest,disconnect)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
am_Handle_s handle;
am_connectionID_t connectionID;
- std::vector<am_Handle_s>listHandles;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ std::vector<am_Handle_s> listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
EXPECT_CALL(pMockInterface,asyncConnect(_,_,1,sinkID,CF_ANALOG)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
- ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
+ ASSERT_EQ(E_OK, pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(connectionID));
EXPECT_CALL(pMockInterface,asyncDisconnect(_,connectionID)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.disconnect(handle,connectionID));
- ASSERT_NE(handle.handle,0);
- ASSERT_EQ(handle.handleType,H_DISCONNECT);
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_EQ(E_OK, pControlReceiver.disconnect(handle,connectionID));
+ ASSERT_NE(handle.handle, 0);
+ ASSERT_EQ(handle.handleType, H_DISCONNECT);
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(listHandles));
ASSERT_TRUE(listHandles[1].handle==handle.handle);
ASSERT_TRUE(listHandles[1].handleType==handle.handleType);
}
TEST_F(routingInterfaceTest,nothingTodisconnect)
{
- am_Handle_s handle;
- am_connectionID_t connectionID=4;
- std::vector<am_Handle_s>listHandles;
- ASSERT_EQ(E_NON_EXISTENT,pControlReceiver.disconnect(handle,connectionID));
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ am_Handle_s handle;
+ am_connectionID_t connectionID = 4;
+ std::vector<am_Handle_s> listHandles;
+ ASSERT_EQ(E_NON_EXISTENT, pControlReceiver.disconnect(handle,connectionID));
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(listHandles));
ASSERT_TRUE(listHandles.empty());
}
-
TEST_F(routingInterfaceTest,setSourceStateNoChange)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- am_Domain_s domain;
- am_domainID_t domainID;
- am_Handle_s handle;
- handle.handle=0;
- am_SourceState_e state=SS_PAUSED;
- pCF.createSource(source);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- source.domainID=1;
- source.sourceState=state;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
- EXPECT_CALL(pMockInterface,asyncSetSourceState(_,sourceID,state)).Times(0);
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSourceState(handle,sourceID,state));
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ handle.handle = 0;
+ am_SourceState_e state = SS_PAUSED;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ source.domainID = 1;
+ source.sourceState = state;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,asyncSetSourceState(_,sourceID,state)).Times(0);
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSourceState(handle,sourceID,state));
}
-
int main(int argc, char **argv)
{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
diff --git a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h
index acd1264..4da9643 100644
--- a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h
+++ b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file routingInterfaces.h
-*
-* \date 20-Oct-2011 3:42:04 PM
-* \author Christian Mueller (christian.ei.mueller@bmw.de)
-*
-* \section License
-* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
-* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
-*
-* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
-* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
-* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
-* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
-* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
-* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
-* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file routingInterfaces.h
+ *
+ * \date 20-Oct-2011 3:42:04 PM
+ * \author Christian Mueller (christian.ei.mueller@bmw.de)
+ *
+ * \section License
+ * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+ * Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+ * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+ * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+ * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+ * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+ * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#ifndef ROUTINGINTERFACETEST_H_
#define ROUTINGINTERFACETEST_H_
@@ -42,26 +42,27 @@
#include "../CommandInterfaceBackdoor.h"
#include "../CommonFunctions.h"
+namespace am
+{
-namespace am {
-
-class routingInterfaceTest : public ::testing::Test{
+class routingInterfaceTest: public ::testing::Test
+{
public:
- routingInterfaceTest();
- ~routingInterfaceTest();
- std::vector<std::string> plistRoutingPluginDirs;
- std::vector<std::string> plistCommandPluginDirs;
- DatabaseHandler pDatabaseHandler;
- RoutingSender pRoutingSender;
- CommandSender pCommandSender;
- MockRoutingSendInterface pMockInterface;
- RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
- CommandInterfaceBackdoor pCommandInterfaceBackdoor;
- ControlReceiver pControlReceiver;
- DatabaseObserver pObserver;
- CommonFunctions pCF;
- void SetUp();
- void TearDown();
+ routingInterfaceTest();
+ ~routingInterfaceTest();
+ std::vector<std::string> plistRoutingPluginDirs;
+ std::vector<std::string> plistCommandPluginDirs;
+ DatabaseHandler pDatabaseHandler;
+ RoutingSender pRoutingSender;
+ CommandSender pCommandSender;
+ MockRoutingSendInterface pMockInterface;
+ RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
+ CommandInterfaceBackdoor pCommandInterfaceBackdoor;
+ ControlReceiver pControlReceiver;
+ DatabaseObserver pObserver;
+ CommonFunctions pCF;
+ void SetUp();
+ void TearDown();
};
}
diff --git a/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp b/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp
index cf551aa..5c23789 100644
--- a/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp
+++ b/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp
@@ -23,7 +23,7 @@ using namespace am;
DLT_DECLARE_CONTEXT(AudioManager)
-static volatile sig_atomic_t gDispatch = 1; //this global is used to stop the mainloop
+static volatile sig_atomic_t gDispatch = 1; //this global is used to stop the mainloop
sockethandlerTest::sockethandlerTest()
{
@@ -33,89 +33,83 @@ sockethandlerTest::~sockethandlerTest()
{
}
-am::timerCallBack::timerCallBack(SocketHandler *myHandler)
- :pTimer1Callback(this, &timerCallBack::timer1Callback),
- pTimer2Callback(this, &timerCallBack::timer2Callback),
- pTimer3Callback(this, &timerCallBack::timer3Callback),
- pTimer4Callback(this, &timerCallBack::timer4Callback),
- mSocketHandler(myHandler)
+timerCallBack::timerCallBack(SocketHandler *myHandler) :
+ pTimer1Callback(this, &timerCallBack::timer1Callback), //
+ pTimer2Callback(this, &timerCallBack::timer2Callback), //
+ pTimer3Callback(this, &timerCallBack::timer3Callback), //
+ pTimer4Callback(this, &timerCallBack::timer4Callback), //
+ mSocketHandler(myHandler)
{
}
-
-
am::timerCallBack::~timerCallBack()
{
}
-
-
void am::timerCallBack::timer1Callback(sh_timerHandle_t handle, void* userData)
{
- std::cout<<"callback1 called"<<std::endl;
- timespec timeout;
- timeout.tv_nsec=0;
- timeout.tv_sec=1;
- shTimerCallBack *buf=&pTimer1Callback;
- sh_timerHandle_t handle_;
- mSocketHandler->addTimer(timeout,buf,handle_,NULL);
+ std::cout << "callback1 called" << std::endl;
+ timespec timeout;
+ timeout.tv_nsec = 0;
+ timeout.tv_sec = 1;
+ shTimerCallBack *buf = &pTimer1Callback;
+ sh_timerHandle_t handle_;
+ mSocketHandler->addTimer(timeout, buf, handle_, NULL);
}
-
-
void am::timerCallBack::timer2Callback(sh_timerHandle_t handle, void* userData)
{
- std::cout<<"callback2 called"<<std::endl;
- timespec timeout;
- timeout.tv_nsec=0;
- timeout.tv_sec=1;
- shTimerCallBack *buf=&pTimer2Callback;
- sh_timerHandle_t handle_;
- mSocketHandler->addTimer(timeout,buf,handle_,NULL);
+ std::cout << "callback2 called" << std::endl;
+ timespec timeout;
+ timeout.tv_nsec = 0;
+ timeout.tv_sec = 1;
+ shTimerCallBack *buf = &pTimer2Callback;
+ sh_timerHandle_t handle_;
+ mSocketHandler->addTimer(timeout, buf, handle_, NULL);
}
void am::timerCallBack::timer3Callback(sh_timerHandle_t, void* userData)
{
- std::cout<<"callback3 called"<<std::endl;
+ std::cout << "callback3 called" << std::endl;
}
void am::timerCallBack::timer4Callback(sh_timerHandle_t, void* userData)
{
- std::cout<<"callback4 called"<<std::endl;
- mSocketHandler->stop_listening();
+ std::cout << "callback4 called" << std::endl;
+ mSocketHandler->stop_listening();
}
void* playWithSocketServer(void* data)
{
- SocketHandler myHandler;
- SamplePlugin::sockType_e type=SamplePlugin::INET;
- SamplePlugin myplugin(&myHandler,type);
- myHandler.start_listenting();
+ SocketHandler myHandler;
+ SamplePlugin::sockType_e type = SamplePlugin::INET;
+ SamplePlugin myplugin(&myHandler, type);
+ myHandler.start_listenting();
}
void* playWithUnixSocketServer(void* data)
{
- SocketHandler myHandler;
- SamplePlugin::sockType_e type=SamplePlugin::UNIX;
- SamplePlugin myplugin(&myHandler,type);
- myHandler.start_listenting();
+ SocketHandler myHandler;
+ SamplePlugin::sockType_e type = SamplePlugin::UNIX;
+ SamplePlugin myplugin(&myHandler, type);
+ myHandler.start_listenting();
}
TEST(sockethandlerTest,playWithUNIXSockets)
{
- pthread_t serverThread;
- char buffer[3000];
- struct sockaddr_un servAddr;
- int socket_;
+ pthread_t serverThread;
+ char buffer[3000];
+ struct sockaddr_un servAddr;
+ int socket_;
- //creates a thread that handles the serverpart
- pthread_create(&serverThread,NULL,playWithUnixSocketServer,NULL);
+ //creates a thread that handles the serverpart
+ pthread_create(&serverThread, NULL, playWithUnixSocketServer, NULL);
- sleep(1); //we need that here because the port needs to be opened
+ sleep(1); //we need that here because the port needs to be opened
if ((socket_ = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{
- std::cout<<"socket problem"<<std::endl;
+ std::cout << "socket problem" << std::endl;
}
@@ -124,90 +118,90 @@ TEST(sockethandlerTest,playWithUNIXSockets)
servAddr.sun_family = AF_UNIX;
if (connect(socket_, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0)
{
- std::cout<<"ERROR: connect() failed\n"<<std::endl;
+ std::cout << "ERROR: connect() failed\n" << std::endl;
}
- for (int i=0;i<=1000;i++)
- {
- std::string string("Got It?");
- send(socket_,string.c_str(),string.size(),0);
- }
- std::string string("finish!");
- send(socket_,string.c_str(),string.size(),0);
+ for (int i = 0; i <= 1000; i++)
+ {
+ std::string string("Got It?");
+ send(socket_, string.c_str(), string.size(), 0);
+ }
+ std::string string("finish!");
+ send(socket_, string.c_str(), string.size(), 0);
- pthread_join(serverThread,NULL);
+ pthread_join(serverThread, NULL);
}
TEST(sockethandlerTest,playWithSockets)
{
- pthread_t serverThread;
- char buffer[3000];
- struct sockaddr_in servAddr;
- unsigned short servPort = 6060;
- struct hostent *host;
- int socket_;
+ pthread_t serverThread;
+ char buffer[3000];
+ struct sockaddr_in servAddr;
+ unsigned short servPort = 6060;
+ struct hostent *host;
+ int socket_;
- //creates a thread that handles the serverpart
- pthread_create(&serverThread,NULL,playWithSocketServer,NULL);
+ //creates a thread that handles the serverpart
+ pthread_create(&serverThread, NULL, playWithSocketServer, NULL);
- sleep(1); //we need that here because the port needs to be opened
+ sleep(1); //we need that here because the port needs to be opened
if ((socket_ = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
{
- std::cout<<"socket problem"<<std::endl;
+ std::cout << "socket problem" << std::endl;
}
if ((host = (struct hostent*) gethostbyname("localhost")) == 0)
{
- std::cout<<"ERROR: gethostbyname() failed\n"<<std::endl;
+ std::cout << "ERROR: gethostbyname() failed\n" << std::endl;
}
memset(&servAddr, 0, sizeof(servAddr));
- servAddr.sin_family = AF_INET;
- servAddr.sin_addr.s_addr = inet_addr(inet_ntoa(*( struct in_addr*)( host -> h_addr_list[0])));
- servAddr.sin_port = htons(servPort);
+ servAddr.sin_family = AF_INET;
+ servAddr.sin_addr.s_addr = inet_addr(inet_ntoa(*(struct in_addr*) (host->h_addr_list[0])));
+ servAddr.sin_port = htons(servPort);
if (connect(socket_, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0)
{
- std::cout<<"ERROR: connect() failed\n"<<std::endl;
+ std::cout << "ERROR: connect() failed\n" << std::endl;
}
- for (int i=0;i<=1000;i++)
- {
- std::string string("Got It?");
- send(socket_,string.c_str(),string.size(),0);
- }
- std::string string("finish!");
- send(socket_,string.c_str(),string.size(),0);
+ for (int i = 0; i <= 1000; i++)
+ {
+ std::string string("Got It?");
+ send(socket_, string.c_str(), string.size(), 0);
+ }
+ std::string string("finish!");
+ send(socket_, string.c_str(), string.size(), 0);
- pthread_join(serverThread,NULL);
+ pthread_join(serverThread, NULL);
}
TEST(sockethandlerTest,playWithTimers)
{
- gDispatchDone=0;
- SocketHandler myHandler;
- timerCallBack testCallback(&myHandler);
- timespec timeoutTime, timeout2, timeout3, timeout4;
- timeoutTime.tv_sec=3;
- timeoutTime.tv_nsec=0;
- timeout2.tv_nsec=0;
- timeout2.tv_sec=1;
- timeout3.tv_nsec=000000000;
- timeout3.tv_sec=2;
- timeout4.tv_nsec=0;
- timeout4.tv_sec=13;
- shTimerCallBack* buf=&testCallback.pTimer1Callback;
- shTimerCallBack* buf2=&testCallback.pTimer2Callback;
- shTimerCallBack* buf3=&testCallback.pTimer3Callback;
- shTimerCallBack* buf4=&testCallback.pTimer4Callback;
- sh_timerHandle_t handle;
- myHandler.addTimer(timeoutTime,buf,handle,NULL);
- myHandler.addTimer(timeout2,buf2,handle,NULL);
- myHandler.addTimer(timeout3,buf3,handle,NULL);
- myHandler.addTimer(timeout4,buf4,handle,NULL);
- myHandler.start_listenting();
+ gDispatchDone = 0;
+ SocketHandler myHandler;
+ timerCallBack testCallback(&myHandler);
+ timespec timeoutTime, timeout2, timeout3, timeout4;
+ timeoutTime.tv_sec = 3;
+ timeoutTime.tv_nsec = 0;
+ timeout2.tv_nsec = 0;
+ timeout2.tv_sec = 1;
+ timeout3.tv_nsec = 000000000;
+ timeout3.tv_sec = 2;
+ timeout4.tv_nsec = 0;
+ timeout4.tv_sec = 13;
+ shTimerCallBack* buf = &testCallback.pTimer1Callback;
+ shTimerCallBack* buf2 = &testCallback.pTimer2Callback;
+ shTimerCallBack* buf3 = &testCallback.pTimer3Callback;
+ shTimerCallBack* buf4 = &testCallback.pTimer4Callback;
+ sh_timerHandle_t handle;
+ myHandler.addTimer(timeoutTime, buf, handle, NULL);
+ myHandler.addTimer(timeout2, buf2, handle, NULL);
+ myHandler.addTimer(timeout3, buf3, handle, NULL);
+ myHandler.addTimer(timeout4, buf4, handle, NULL);
+ myHandler.start_listenting();
}
@@ -221,131 +215,118 @@ void sockethandlerTest::TearDown()
int main(int argc, char **argv)
{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
-am::SamplePlugin::SamplePlugin(SocketHandler *mySocketHandler, sockType_e socketType)
- :connectFiredCB(this,&SamplePlugin::connectSocket),
- receiveFiredCB(this,&SamplePlugin::receiveData),
- sampleDispatchCB(this,&SamplePlugin::dispatchData),
- sampleCheckCB(this,&SamplePlugin::check),
- mSocketHandler(mySocketHandler),
- mConnecthandle(),
- mReceiveHandle(),
- msgList()
+am::SamplePlugin::SamplePlugin(SocketHandler *mySocketHandler, sockType_e socketType) :
+ connectFiredCB(this, &SamplePlugin::connectSocket), //
+ receiveFiredCB(this, &SamplePlugin::receiveData), //
+ sampleDispatchCB(this, &SamplePlugin::dispatchData), //
+ sampleCheckCB(this, &SamplePlugin::check), //
+ mSocketHandler(mySocketHandler), //
+ mConnecthandle(), //
+ mReceiveHandle(), //
+ msgList()
{
- int ret;
- int yes = 1;
-
- int socketHandle;
- struct sockaddr_in servAddr;
- struct sockaddr_un unixAddr;
- unsigned int servPort = 6060;
-
- switch (socketType)
- {
- case UNIX:
- socketHandle = socket(AF_UNIX, SOCK_STREAM, 0);
- unixAddr.sun_family = AF_UNIX;
- strcpy(unixAddr.sun_path,SOCK_PATH);
- unlink(unixAddr.sun_path);
- bind(socketHandle, (struct sockaddr *)&unixAddr, strlen(unixAddr.sun_path) + sizeof(unixAddr.sun_family));
- break;
- case INET:
- socketHandle = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
- setsockopt(socketHandle, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
- memset(&servAddr, 0, sizeof(servAddr));
- servAddr.sin_family = AF_INET;
- servAddr.sin_addr.s_addr = INADDR_ANY;
- servAddr.sin_port = htons(servPort);
- bind(socketHandle, (struct sockaddr *) &servAddr, sizeof(servAddr));
- break;
- default:
- break;
- }
+ int ret;
+ int yes = 1;
+
+ int socketHandle;
+ struct sockaddr_in servAddr;
+ struct sockaddr_un unixAddr;
+ unsigned int servPort = 6060;
+
+ switch (socketType)
+ {
+ case UNIX:
+ socketHandle = socket(AF_UNIX, SOCK_STREAM, 0);
+ unixAddr.sun_family = AF_UNIX;
+ strcpy(unixAddr.sun_path, SOCK_PATH);
+ unlink(unixAddr.sun_path);
+ bind(socketHandle, (struct sockaddr *) &unixAddr, strlen(unixAddr.sun_path) + sizeof(unixAddr.sun_family));
+ break;
+ case INET:
+ socketHandle = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ setsockopt(socketHandle, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
+ memset(&servAddr, 0, sizeof(servAddr));
+ servAddr.sin_family = AF_INET;
+ servAddr.sin_addr.s_addr = INADDR_ANY;
+ servAddr.sin_port = htons(servPort);
+ bind(socketHandle, (struct sockaddr *) &servAddr, sizeof(servAddr));
+ break;
+ default:
+ break;
+ }
if (listen(socketHandle, 3) < 0)
{
- std::cout<<"listen ok"<<std::endl;
+ std::cout << "listen ok" << std::endl;
} /* if */
- int a=1;
- ioctl (socketHandle, FIONBIO, (char *) &a);
- setsockopt (socketHandle, SOL_SOCKET, SO_KEEPALIVE, (char *) &a, sizeof (a));
+ int a = 1;
+ ioctl(socketHandle, FIONBIO, (char *) &a);
+ setsockopt(socketHandle, SOL_SOCKET, SO_KEEPALIVE, (char *) &a, sizeof(a));
- short events=0;
- events |= POLLIN;
- mySocketHandler->addFDPoll(socketHandle,events,NULL,&connectFiredCB,NULL,NULL,NULL,mConnecthandle);
- std::cout<<"setup server - listening"<<std::endl;
+ short events = 0;
+ events |= POLLIN;
+ mySocketHandler->addFDPoll(socketHandle, events, NULL, &connectFiredCB, NULL, NULL, NULL, mConnecthandle);
+ std::cout << "setup server - listening" << std::endl;
}
-
-
void am::SamplePlugin::connectSocket(const pollfd pollfd1, const sh_pollHandle_t handle, void *userData)
{
- //first, accept the connection, create a new filedescriptor
- std::cout<<"Got a connection request !"<<std::endl;
- struct sockaddr answer;
- socklen_t len=sizeof(answer);
- int receiveFD = accept(pollfd1.fd, (struct sockaddr*)&answer, &len);
+ //first, accept the connection, create a new filedescriptor
+ std::cout << "Got a connection request !" << std::endl;
+ struct sockaddr answer;
+ socklen_t len = sizeof(answer);
+ int receiveFD = accept(pollfd1.fd, (struct sockaddr*) &answer, &len);
- //set the correct event:
- short event = 0;
- event |=POLLIN;
+ //set the correct event:
+ short event = 0;
+ event |= POLLIN;
- //aded the filedescriptor to the sockethandler and register the callbacks for receiving the data
- mSocketHandler->addFDPoll(receiveFD,event,NULL,&receiveFiredCB,&sampleCheckCB,&sampleDispatchCB,NULL,mReceiveHandle);
+ //aded the filedescriptor to the sockethandler and register the callbacks for receiving the data
+ mSocketHandler->addFDPoll(receiveFD, event, NULL, &receiveFiredCB, &sampleCheckCB, &sampleDispatchCB, NULL, mReceiveHandle);
}
-
-
void am::SamplePlugin::receiveData(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
{
- //initialize buffer
- char buffer[10];
- //read until buffer is full or no more data is there
- int read=recv(pollfd.fd,buffer,7,NULL);
- if (read>1)
- {
- //read the message and store it in a queue
- std::string msg=std::string(buffer,read);
- msgList.push(msg);
- std::cout<<"Got a message !"<<std::endl;
- }
+ //initialize buffer
+ char buffer[10];
+ //read until buffer is full or no more data is there
+ int read = recv(pollfd.fd, buffer, 7, NULL);
+ if (read > 1)
+ {
+ //read the message and store it in a queue
+ std::string msg = std::string(buffer, read);
+ msgList.push(msg);
+ std::cout << "Got a message !" << std::endl;
+ }
}
-
-
bool am::SamplePlugin::dispatchData(const sh_pollHandle_t handle, void *userData)
{
- //read data from the queue
- std::cout<<"Data:"<<msgList.front()<<std::endl;
-
- //if the message was our finish message, we quit the poll loop
- if (msgList.front().compare("finish!")==0)
- {
- mSocketHandler->stop_listening();
- }
- //remove the message from the queue and return false if there is no more message to read.
- msgList.pop();
- if (msgList.size()!=0) return true;
- return false;
+ //read data from the queue
+ std::cout << "Data:" << msgList.front() << std::endl;
+
+ //if the message was our finish message, we quit the poll loop
+ if (msgList.front().compare("finish!") == 0)
+ {
+ mSocketHandler->stop_listening();
+ }
+ //remove the message from the queue and return false if there is no more message to read.
+ msgList.pop();
+ if (msgList.size() != 0) return true;
+ return false;
}
bool am::SamplePlugin::check(const sh_pollHandle_t handle, void *userData)
{
- //checks if there is data to dispatch
- std::cout<<"check!:"<<std::endl;
- if (msgList.size()!=0) return true;
- return false;
+ //checks if there is data to dispatch
+ std::cout << "check!:" << std::endl;
+ if (msgList.size() != 0) return true;
+ return false;
}
-
-
-
-
-
-
-
diff --git a/AudioManagerDaemon/test/sockethandler/sockethandlerTest.h b/AudioManagerDaemon/test/sockethandler/sockethandlerTest.h
index 18eff7e..faf604b 100644
--- a/AudioManagerDaemon/test/sockethandler/sockethandlerTest.h
+++ b/AudioManagerDaemon/test/sockethandler/sockethandlerTest.h
@@ -12,56 +12,58 @@
#include <queue>
#include "SocketHandler.h"
-namespace am {
+namespace am
+{
class SamplePlugin
{
public:
- enum sockType_e
- {
- UNIX,
- INET
- };
- SamplePlugin(SocketHandler *mySocketHandler,sockType_e socketType);
- virtual ~SamplePlugin() {};
- void connectSocket(const pollfd pollfd,const sh_pollHandle_t handle, void* userData);
- void receiveData(const pollfd pollfd,const sh_pollHandle_t handle, void* userData);
- bool dispatchData(const sh_pollHandle_t handle, void* userData);
- bool check(const sh_pollHandle_t handle, void* userData);
- shPollFired_T<SamplePlugin> connectFiredCB;
- shPollFired_T<SamplePlugin> receiveFiredCB;
- shPollDispatch_T<SamplePlugin> sampleDispatchCB;
- shPollCheck_T<SamplePlugin> sampleCheckCB;
+ enum sockType_e
+ {
+ UNIX, INET
+ };
+ SamplePlugin(SocketHandler *mySocketHandler, sockType_e socketType);
+ virtual ~SamplePlugin()
+ {
+ }
+ ;
+ void connectSocket(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
+ void receiveData(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
+ bool dispatchData(const sh_pollHandle_t handle, void* userData);
+ bool check(const sh_pollHandle_t handle, void* userData);
+ shPollFired_T<SamplePlugin> connectFiredCB;
+ shPollFired_T<SamplePlugin> receiveFiredCB;
+ shPollDispatch_T<SamplePlugin> sampleDispatchCB;
+ shPollCheck_T<SamplePlugin> sampleCheckCB;
private:
- SocketHandler *mSocketHandler;
- sh_pollHandle_t mConnecthandle,mReceiveHandle;
- std::queue<std::string> msgList;
+ SocketHandler *mSocketHandler;
+ sh_pollHandle_t mConnecthandle, mReceiveHandle;
+ std::queue<std::string> msgList;
};
-
class timerCallBack
{
public:
- timerCallBack(SocketHandler *SocketHandler);
- virtual ~timerCallBack();
- void timer1Callback(sh_timerHandle_t handle,void * userData);
- void timer2Callback(sh_timerHandle_t handle,void * userData);
- void timer3Callback(sh_timerHandle_t handle,void * userData);
- void timer4Callback(sh_timerHandle_t handle,void * userData);
- shTimerCallBack_T<timerCallBack> pTimer1Callback;
- shTimerCallBack_T<timerCallBack> pTimer2Callback;
- shTimerCallBack_T<timerCallBack> pTimer3Callback;
- shTimerCallBack_T<timerCallBack> pTimer4Callback;
- SocketHandler *mSocketHandler;
+ timerCallBack(SocketHandler *SocketHandler);
+ virtual ~timerCallBack();
+ void timer1Callback(sh_timerHandle_t handle, void * userData);
+ void timer2Callback(sh_timerHandle_t handle, void * userData);
+ void timer3Callback(sh_timerHandle_t handle, void * userData);
+ void timer4Callback(sh_timerHandle_t handle, void * userData);
+ shTimerCallBack_T<timerCallBack> pTimer1Callback;
+ shTimerCallBack_T<timerCallBack> pTimer2Callback;
+ shTimerCallBack_T<timerCallBack> pTimer3Callback;
+ shTimerCallBack_T<timerCallBack> pTimer4Callback;
+ SocketHandler *mSocketHandler;
};
class sockethandlerTest: public ::testing::Test
{
public:
- sockethandlerTest();
- virtual ~sockethandlerTest();
- void SetUp();
- void TearDown();
+ sockethandlerTest();
+ virtual ~sockethandlerTest();
+ void SetUp();
+ void TearDown();
};
} /* namespace am */