#include "ControlReceiver.h"
#include "Router.h"
#include "config.h"
+#include "DLTWrapper.h"
#include <cassert>
#define DEBUG_ON false
+static const std::string COLOR_WELCOME("\033[1;33m\033[44m");
+static const std::string COLOR_HEAD("\033[1m\033[42m");
+static const std::string COLOR_DEFAULT("\033[0m");
+
using namespace am;
/****************************************************************************/
CAmTelnetMenuHelper::CAmTelnetMenuHelper(SocketHandler *iSocketHandler, CommandSender *iCommandSender, CommandReceiver *iCommandReceiver, RoutingSender *iRoutingSender, RoutingReceiver *iRoutingReceiver, ControlSender *iControlSender, ControlReceiver *iControlReceiver, DatabaseHandler *iDatabasehandler, Router *iRouter, TelnetServer *iTelnetServer)
/****************************************************************************/
-:mTelenetServer(iTelnetServer), mSocketHandler(iSocketHandler), mCommandSender(iCommandSender), mCommandReceiver(iCommandReceiver), mRoutingSender(iRoutingSender), mRoutingReceiver(iRoutingReceiver), mControlSender(iControlSender), mControlReceiver(iControlReceiver), mDatabasehandler(iDatabasehandler), mRouter(iRouter)
+:mpTelenetServer(iTelnetServer), mpSocketHandler(iSocketHandler), mpCommandSender(iCommandSender), mpCommandReceiver(iCommandReceiver), mpRoutingSender(iRoutingSender), mpRoutingReceiver(iRoutingReceiver), mpControlSender(iControlSender), mpControlReceiver(iControlReceiver), mpDatabasehandler(iDatabasehandler), mpRouter(iRouter)
{
instance = this;
createCommandMaps();
void CAmTelnetMenuHelper::setTelnetServer(TelnetServer* iTelnetServer)
/****************************************************************************/
{
- mTelenetServer = iTelnetServer;
+ mpTelenetServer = iTelnetServer;
}
/****************************************************************************/
mCurrentMainStateMap.insert(it, std::make_pair<int, EMainState>(filedescriptor, state));
// Send welcome message
- welcome << "Welcome to GENIVI AudioManager " << DAEMONVERSION << "\n>";
+ welcome << COLOR_WELCOME << "Welcome to GENIVI AudioManager " << DAEMONVERSION << "\n>";
send(filedescriptor, welcome.str().c_str(), welcome.str().size(), 0);
+ logInfo("[TN] New connection: ",filedescriptor);
}
/****************************************************************************/
}
else
{
- // connection not found
+ logError("[TN] socketConnectionsClosed, fd not found, ",filedescriptor);
}
}
}
else
{
- // connection not found
+ logError("[TN] sendCurrentCmdPrompt, fd not found",filedescriptor);
}
}
std::stringstream output;
// Sending a last message to the client
- output << "Your wish is my command ... bye!" << std::endl;
+ output << "bye!" << COLOR_DEFAULT << std::endl;
sendTelnetLine(filedescriptor, output);
tCommandMap::iterator iter;
if (DEBUG_ON)
std::cout << "removing client connection " << filedescriptor << std::endl;
- if (NULL != mTelenetServer)
+ if (NULL != mpTelenetServer)
{
- mTelenetServer->disconnectClient(filedescriptor);
+ mpTelenetServer->disconnectClient(filedescriptor);
mCurrentMainStateMap.erase(it);
}
else
{
- // ASSERT mTelenetServer == NULL
- if (DEBUG_ON)
- std::cout << "mTelenetServer";
+ logError("[TN] exitCommandExec, mpTelenetServer == NULL, fd ",filedescriptor);
}
}
}
(void) CmdQueue;
std::vector<am_Connection_s> listConnections;
- if(E_OK == mDatabasehandler->getListConnections(listConnections))
+ if(E_OK == mpDatabasehandler->getListConnections(listConnections))
{
std::stringstream output;
output << "\tConnections: " << listConnections.size() << std::endl;
(void) CmdQueue;
std::vector<am_Source_s> listSources;
- if(E_OK == mDatabasehandler->getListSources(listSources))
+ if(E_OK == mpDatabasehandler->getListSources(listSources))
{
std::stringstream output;
output << "\tSources: " << listSources.size() << std::endl;
(void) CmdQueue;
std::vector<am_Sink_s> listSinks;
- if(E_OK == mDatabasehandler->getListSinks(listSinks))
+ if(E_OK == mpDatabasehandler->getListSinks(listSinks))
{
std::stringstream output;
output << "\tSinks: " << listSinks.size() << std::endl;
(void) CmdQueue;
std::vector<am_Crossfader_s> listCrossfaders;
- if(E_OK == mDatabasehandler->getListCrossfaders(listCrossfaders))
+ if(E_OK == mpDatabasehandler->getListCrossfaders(listCrossfaders))
{
std::stringstream output;
output << "\tCrossfaders: " << listCrossfaders.size() << std::endl;
(void) CmdQueue;
std::vector<am_Domain_s> listDomains;
- if(E_OK == mDatabasehandler->getListDomains(listDomains))
+ if(E_OK == mpDatabasehandler->getListDomains(listDomains))
{
std::stringstream output;
output << "\tDomains: " << listDomains.size() << std::endl;
(void) CmdQueue;
std::vector<am_Gateway_s> listGateways;
- if(E_OK == mDatabasehandler->getListGateways(listGateways))
+ if(E_OK == mpDatabasehandler->getListGateways(listGateways))
{
std::stringstream output;
output << "\tGateways: " << listGateways.size();
(void) CmdQueue;
std::stringstream output;
- output << "\tSender versions:" << std::endl << "\tCtrl: " << mControlSender->getInterfaceVersion() << " | " << "Cmd: " << mCommandSender->getInterfaceVersion() << " | " << "Routing: " << mRoutingSender->getInterfaceVersion() << std::endl;
+ output << "\tSender versions:" << std::endl << "\tCtrl: " << mpControlSender->getInterfaceVersion() << " | " << "Cmd: " << mpCommandSender->getInterfaceVersion() << " | " << "Routing: " << mpRoutingSender->getInterfaceVersion() << std::endl;
sendTelnetLine(filedescriptor, output);
}
(void) CmdQueue;
std::stringstream output;
- output << "\tReceiver versions:" << std::endl << "\tCtrl: " << mControlReceiver->getInterfaceVersion() << " | " << "Cmd: " << mCommandReceiver->getInterfaceVersion() << " | " << "Routing: " << mRoutingReceiver->getInterfaceVersion() << std::endl;
+ output << "\tReceiver versions:" << std::endl << "\tCtrl: " << mpControlReceiver->getInterfaceVersion() << " | " << "Cmd: " << mpCommandReceiver->getInterfaceVersion() << " | " << "Routing: " << mpRoutingReceiver->getInterfaceVersion() << std::endl;
sendTelnetLine(filedescriptor, output);
(void) CmdQueue;
std::vector<am_SystemProperty_s> listSystemProperties;
- if(E_OK == mDatabasehandler->getListSystemProperties(listSystemProperties))
+ if(E_OK == mpDatabasehandler->getListSystemProperties(listSystemProperties))
{
std::stringstream output;
output << "\tSystemproperties: " << listSystemProperties.size() << std::endl;
std::cout << "setRoutingCommandExec(sourceID: " << sourceID << ",sinkID: " << sinkID << ")" << std::endl;
std::vector<am_Route_s> routingList;
- if (E_OK == mRouter->getRoute(true, sourceID, sinkID, routingList))
+ if (E_OK == mpRouter->getRoute(true, sourceID, sinkID, routingList))
{
std::stringstream output;
// Try to set up connection
am_mainConnectionID_t connID = 0;
- rError = mCommandReceiver->connect(sourceID, sinkID, connID);
+ rError = mpCommandReceiver->connect(sourceID, sinkID, connID);
if (E_OK == rError)
{
}
// Try to disconnect connection id
- rError = mCommandReceiver->disconnect(connID);
+ rError = mpCommandReceiver->disconnect(connID);
if (E_OK == rError)
{
return;
}
- if (E_OK == mCommandReceiver->setMainSourceSoundProperty(soundProperty, sourceID))
+ if (E_OK == mpCommandReceiver->setMainSourceSoundProperty(soundProperty, sourceID))
{
std::stringstream output;
output << "MainSourceSoundProperty set: " << soundProperty.type << "->" << soundProperty.value << std::endl;
return;
}
- if (E_OK == mCommandReceiver->setMainSinkSoundProperty(soundProperty, sinkID))
+ if (E_OK == mpCommandReceiver->setMainSinkSoundProperty(soundProperty, sinkID))
{
std::stringstream output;
output << "MainSinkSoundProperty set: " << soundProperty.type << "->" << soundProperty.value << std::endl;
std::stringstream output;
- if(E_OK == mCommandSender->getListPlugins(PlugInNames))
+ if(E_OK == mpCommandSender->getListPlugins(PlugInNames))
{
output << "\tCommandSender Plugins loaded: " << PlugInNames.size() << std::endl;
}
- if(E_OK == mRoutingSender->getListPlugins(PlugInNames))
+ if(E_OK == mpRoutingSender->getListPlugins(PlugInNames))
{
output << std::endl << "\tRoutingSender Plugins loaded: " << PlugInNames.size() << std::endl;
(void) CmdQueue;
std::vector<am_SourceType_s> listMainSources;
- if(E_OK == mDatabasehandler->getListMainSources(listMainSources))
+ if(E_OK == mpDatabasehandler->getListMainSources(listMainSources))
{
std::stringstream output;
- output << std::endl << "\tMainSources: " << listMainSources.size() << std::endl;
+ output << std::endl << "\tMainSources: " << listMainSources.size() << std::endl;
std::vector<am_SourceType_s>::iterator iter;
for (iter = listMainSources.begin(); iter < listMainSources.end(); iter++)
(void) CmdQueue;
std::vector<am_SinkType_s> listMainSinks;
- if(E_OK == mDatabasehandler->getListMainSinks(listMainSinks))
+ if(E_OK == mpDatabasehandler->getListMainSinks(listMainSinks))
{
std::stringstream output;
output << std::endl << "\tMainSinks: " << listMainSinks.size() << std::endl;
(void) CmdQueue;
std::vector<am_MainConnection_s> listMainConnections;
- if(E_OK == mDatabasehandler->getListMainConnections(listMainConnections))
+ if(E_OK == mpDatabasehandler->getListMainConnections(listMainConnections))
{
std::stringstream output;
output << std::endl << "\tMainConnections: " << listMainConnections.size() << std::endl;