2 * Copyright (C) 2012, BMW AG
4 * This file is part of GENIVI Project AudioManager.
6 * Contributions are licensed to the GENIVI Alliance under one or more
7 * Contribution License Agreements.
10 * This Source Code Form is subject to the terms of the
11 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
12 * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
16 * \author Frank Herchet, frank.fh.herchet@bmw.de BMW 2012
18 * \file CAmTelnetMenuHelper.cpp
19 * For further information see http://www.genivi.org/.
23 #include "CAmTelnetMenuHelper.h"
26 #include "CAmRouter.h"
27 #include "CAmTelnetServer.h"
28 #include "CAmDatabaseHandler.h"
29 #include "CAmControlSender.h"
30 #include "CAmCommandSender.h"
31 #include "CAmRoutingSender.h"
32 #include "CAmRoutingReceiver.h"
33 #include "CAmCommandReceiver.h"
34 #include "CAmControlReceiver.h"
35 #include "shared/CAmDltWrapper.h"
37 static const std::string COLOR_WELCOME("\033[1;33m\033[44m");
38 static const std::string COLOR_HEAD("\033[1m\033[42m");
39 static const std::string COLOR_DEFAULT("\033[0m");
44 CAmTelnetMenuHelper* CAmTelnetMenuHelper::instance = NULL;
46 /****************************************************************************/
47 CAmTelnetMenuHelper::CAmTelnetMenuHelper(CAmSocketHandler *iSocketHandler, CAmCommandSender *iCommandSender, CAmCommandReceiver *iCommandReceiver, CAmRoutingSender *iRoutingSender, CAmRoutingReceiver *iRoutingReceiver, CAmControlSender *iControlSender, CAmControlReceiver *iControlReceiver, CAmDatabaseHandler *iDatabasehandler, CAmRouter *iRouter, CAmTelnetServer *iTelnetServer)
48 /****************************************************************************/
49 :mpTelenetServer(iTelnetServer), mpSocketHandler(iSocketHandler), mpCommandSender(iCommandSender), mpCommandReceiver(iCommandReceiver), mpRoutingSender(iRoutingSender), mpRoutingReceiver(iRoutingReceiver), mpControlSender(iControlSender), mpControlReceiver(iControlReceiver), mpDatabasehandler(iDatabasehandler), mpRouter(iRouter)
55 /****************************************************************************/
56 CAmTelnetMenuHelper::~CAmTelnetMenuHelper()
57 /****************************************************************************/
61 /****************************************************************************/
62 void CAmTelnetMenuHelper::createCommandMaps()
63 /****************************************************************************/
66 mRootCommands.clear();
67 mRootCommands.insert(std::make_pair("help", sCommandPrototypeInfo("show all possible commands", &CAmTelnetMenuHelper::helpCommand)));
68 mRootCommands.insert(std::make_pair("list", sCommandPrototypeInfo("Go into 'list'-submenu", &CAmTelnetMenuHelper::rootListCommand)));
69 mRootCommands.insert(std::make_pair("info", sCommandPrototypeInfo("Go into 'info'-submenu", &CAmTelnetMenuHelper::rootInfoCommand)));
70 mRootCommands.insert(std::make_pair("set", sCommandPrototypeInfo("Go into 'set'-submenu", &CAmTelnetMenuHelper::rootSetCommand)));
71 mRootCommands.insert(std::make_pair("get", sCommandPrototypeInfo("Go into 'get'-submenu", &CAmTelnetMenuHelper::rootGetCommand)));
72 mRootCommands.insert(std::make_pair("exit", sCommandPrototypeInfo("quit telnet session", &CAmTelnetMenuHelper::exitCommand)));
74 mListCommands.insert(std::make_pair("help", sCommandPrototypeInfo(std::string("show all possible commands"), &CAmTelnetMenuHelper::helpCommand)));
75 mListCommands.insert(std::make_pair("conn", sCommandPrototypeInfo("list all connections", &CAmTelnetMenuHelper::listConnectionsCommand)));
76 mListCommands.insert(std::make_pair("sources", sCommandPrototypeInfo("list all available sources", &CAmTelnetMenuHelper::listSourcesCommand)));
77 mListCommands.insert(std::make_pair("sinks", sCommandPrototypeInfo("list all available sinks", &CAmTelnetMenuHelper::listSinksCommands)));
78 mListCommands.insert(std::make_pair("crfader", sCommandPrototypeInfo("list all crossfaders", &CAmTelnetMenuHelper::listCrossfaders)));
79 mListCommands.insert(std::make_pair("domains", sCommandPrototypeInfo("list all domains", &CAmTelnetMenuHelper::listDomainsCommand)));
80 mListCommands.insert(std::make_pair("gws", sCommandPrototypeInfo("list all gateways", &CAmTelnetMenuHelper::listGatewaysCommand)));
81 mListCommands.insert(std::make_pair("mainconn", sCommandPrototypeInfo("list all main connections", &CAmTelnetMenuHelper::listMainConnectionsCommand)));
82 mListCommands.insert(std::make_pair("mainsinks", sCommandPrototypeInfo("list all main sinks", &CAmTelnetMenuHelper::listMainSinksCommand)));
83 mListCommands.insert(std::make_pair("mainsources", sCommandPrototypeInfo("list all main sources", &CAmTelnetMenuHelper::listMainSourcesCommand)));
84 mListCommands.insert(std::make_pair("..", sCommandPrototypeInfo("one step back in menu tree (back to root folder)", &CAmTelnetMenuHelper::oneStepBackCommand)));
85 mListCommands.insert(std::make_pair("exit", sCommandPrototypeInfo("close telnet session", &CAmTelnetMenuHelper::exitCommand)));
87 mSetCommands.insert(std::make_pair("help", sCommandPrototypeInfo(std::string("show all possible commands"), &CAmTelnetMenuHelper::helpCommand)));
88 mSetCommands.insert(std::make_pair("..", sCommandPrototypeInfo("one step back in menu tree (back to root folder)", &CAmTelnetMenuHelper::oneStepBackCommand)));
89 mSetCommands.insert(std::make_pair("exit", sCommandPrototypeInfo("close telnet session", &CAmTelnetMenuHelper::exitCommand)));
90 mSetCommands.insert(std::make_pair("conn", sCommandPrototypeInfo("use 'conn sourceId sinkId' to connect a source and a sink", &CAmTelnetMenuHelper::setConnection)));
91 mSetCommands.insert(std::make_pair("routing", sCommandPrototypeInfo("use 'routing sourceId sinkId' to get all\n\t possible routes between a sourceID and a sinkID", &CAmTelnetMenuHelper::setRoutingCommand)));
92 mSetCommands.insert(std::make_pair("disc", sCommandPrototypeInfo("use 'disc connectionID' to disconnect \n\t this connection", &CAmTelnetMenuHelper::setDisconnectConnId)));
93 mSetCommands.insert(std::make_pair("sinkvolume", sCommandPrototypeInfo("use 'sinkvolume sinkID volume' to set \n\t absorption in db of sink", &CAmTelnetMenuHelper::setSinkVolume)));
94 mSetCommands.insert(std::make_pair("sinkvolstep", sCommandPrototypeInfo("use 'sinkvolstep sinkID volumestep' to increment \n\t or decrement volume", &CAmTelnetMenuHelper::setVolumeStep)));
95 mSetCommands.insert(std::make_pair("sinkprop", sCommandPrototypeInfo("use 'sinkprop type value' to set \n\t a specific sinksoundproperty", &CAmTelnetMenuHelper::setSinkSoundProperty)));
96 mSetCommands.insert(std::make_pair("sinkmute", sCommandPrototypeInfo("use 'sinkmute sinkid mutestate' to mute \n\t or unmute", &CAmTelnetMenuHelper::setSinkMuteState)));
97 mSetCommands.insert(std::make_pair("sourceprop", sCommandPrototypeInfo("use 'sourceprop type value' to set \n\t a specific sinksoundproperty", &CAmTelnetMenuHelper::setSourceSoundProperty)));
99 mGetCommands.insert(std::make_pair("help", sCommandPrototypeInfo(std::string("show all possible commands"), &CAmTelnetMenuHelper::helpCommand)));
100 mGetCommands.insert(std::make_pair("routing", sCommandPrototypeInfo("show current routing", &CAmTelnetMenuHelper::getRoutingCommand)));
101 mGetCommands.insert(std::make_pair("sendv", sCommandPrototypeInfo("show senderversion", &CAmTelnetMenuHelper::getSenderversionCommand)));
102 mGetCommands.insert(std::make_pair("recv", sCommandPrototypeInfo("show receiverversion ", &CAmTelnetMenuHelper::getReceiverversionCommand)));
103 mGetCommands.insert(std::make_pair("..", sCommandPrototypeInfo("one step back in menu tree (back to root folder)", &CAmTelnetMenuHelper::oneStepBackCommand)));
104 mGetCommands.insert(std::make_pair("exit", sCommandPrototypeInfo("close telnet session", &CAmTelnetMenuHelper::exitCommand)));
106 mInfoCommands.insert(std::make_pair("help", sCommandPrototypeInfo(std::string("show all possible commands"), &CAmTelnetMenuHelper::helpCommand)));
107 mInfoCommands.insert(std::make_pair("sysprop", sCommandPrototypeInfo("show all systemproperties", &CAmTelnetMenuHelper::infoSystempropertiesCommand)));
108 mInfoCommands.insert(std::make_pair("..", sCommandPrototypeInfo("one step back in menu tree (back to root folder)", &CAmTelnetMenuHelper::oneStepBackCommand)));
109 mInfoCommands.insert(std::make_pair("exit", sCommandPrototypeInfo("close telnet session", &CAmTelnetMenuHelper::exitCommand)));
112 /****************************************************************************/
113 void CAmTelnetMenuHelper::newSocketConnection(int filedescriptor)
114 /****************************************************************************/
116 EMainState state = eRootState;
117 std::map<int, EMainState>::iterator it;
118 std::stringstream welcome;
119 it = mCurrentMainStateMap.find(filedescriptor);
120 if (it != mCurrentMainStateMap.end())
122 // socket connection already exists, delete entry and go back to root state
123 mCurrentMainStateMap.erase(it);
125 it = mCurrentMainStateMap.begin();
126 // insert new socket connection
127 mCurrentMainStateMap.insert(it, std::make_pair(filedescriptor, state));
128 // Send welcome message
129 welcome << COLOR_WELCOME << "Welcome to GENIVI AudioManager " << DAEMONVERSION << COLOR_DEFAULT << "\n>";
130 assert(send(filedescriptor, welcome.str().c_str(), welcome.str().size(), 0)>=0);
131 logInfo("[TN] New connection: ", filedescriptor);
134 /****************************************************************************/
135 void CAmTelnetMenuHelper::socketConnectionsClosed(int filedescriptor)
136 /****************************************************************************/
138 std::map<int, EMainState>::iterator it;
139 it = mCurrentMainStateMap.find(filedescriptor);
140 if (it != mCurrentMainStateMap.end())
142 mCurrentMainStateMap.erase(it);
146 logError("[TN] socketConnectionsClosed, fd not found, ", filedescriptor);
150 /****************************************************************************/
151 void CAmTelnetMenuHelper::enterCmdQueue(std::queue<std::string>& CmdQueue, int& filedescriptor)
152 /****************************************************************************/
154 std::map<int, EMainState>::iterator it;
156 tCommandMap::iterator cmditer;
157 // find current filedescriptor to get the current state of the telnet session
158 it = mCurrentMainStateMap.find(filedescriptor);
159 while (!CmdQueue.empty())
161 cmd = CmdQueue.front();
162 // Now remove the first command, it's stored in 'cmd'
164 // telnet session found. depending on the current state, different commands are available
168 cmditer = mRootCommands.find(cmd);
169 if (mRootCommands.end() != cmditer)
170 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
172 sendError(filedescriptor, "Command not found\n");
176 cmditer = mListCommands.find(cmd);
177 if (mListCommands.end() != cmditer)
178 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
180 sendError(filedescriptor, "Command not found\n");
184 cmditer = mInfoCommands.find(cmd);
185 if (mInfoCommands.end() != cmditer)
186 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
188 sendError(filedescriptor, "Command not found\n");
192 cmditer = mGetCommands.find(cmd);
193 if (mGetCommands.end() != cmditer)
194 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
196 sendError(filedescriptor, "Command not found\n");
200 cmditer = mSetCommands.find(cmd);
201 if (mSetCommands.end() != cmditer)
202 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
204 sendError(filedescriptor, "Command not found\n");
212 sendCurrentCmdPrompt(filedescriptor);
215 /****************************************************************************/
216 void CAmTelnetMenuHelper::sendError(int& filedescriptor, std::string error_string)
217 /****************************************************************************/
219 assert(send(filedescriptor, error_string.c_str(), error_string.size(), 0)>=0);
222 /****************************************************************************/
223 void CAmTelnetMenuHelper::sendTelnetLine(int& filedescriptor, std::stringstream& line)
224 /****************************************************************************/
226 assert(send(filedescriptor, line.str().c_str(), line.str().size(), 0)>=0);
229 /****************************************************************************/
230 void CAmTelnetMenuHelper::sendCurrentCmdPrompt(int& filedescriptor)
231 /****************************************************************************/
233 std::map<int, EMainState>::iterator it;
234 std::stringstream outputstream;
235 outputstream << std::endl;
236 it = mCurrentMainStateMap.find(filedescriptor);
237 if (it != mCurrentMainStateMap.end())
242 outputstream << "\\>";
245 outputstream << "\\List>";
248 outputstream << "\\Get>";
251 outputstream << "\\Set>";
254 outputstream << "\\Info>";
259 assert(send(filedescriptor, outputstream.str().c_str(), outputstream.str().size(), 0)>=0);
263 logInfo("[TN] sendCurrentCmdPrompt, fd not found: ", filedescriptor);
267 /****************************************************************************/
268 void CAmTelnetMenuHelper::exitCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
269 /****************************************************************************/
271 instance->exitCommandExec(CmdQueue, filedescriptor);
274 /****************************************************************************/
275 void CAmTelnetMenuHelper::oneStepBackCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
276 /****************************************************************************/
279 std::map<int, EMainState>::iterator it;
280 it = mCurrentMainStateMap.find(filedescriptor);
281 if (it != mCurrentMainStateMap.end())
286 it->second = eRootState;
289 it->second = eRootState;
293 it->second = eRootState;
297 it->second = eRootState;
301 it->second = eRootState;
305 it->second = eRootState;
308 logInfo("[TN] oneStepBackCommandExec, state: ", it->second);
313 /****************************************************************************/
314 void CAmTelnetMenuHelper::oneStepBackCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
315 /****************************************************************************/
317 instance->oneStepBackCommandExec(CmdQueue, filedescriptor);
320 /****************************************************************************/
321 void CAmTelnetMenuHelper::exitCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
322 /****************************************************************************/
325 std::map<int, EMainState>::iterator it;
326 std::stringstream line;
327 std::stringstream output;
328 // Sending a last message to the client
329 output << "bye!" << COLOR_DEFAULT << std::endl;
330 sendTelnetLine(filedescriptor, output);
331 tCommandMap::iterator iter;
332 it = mCurrentMainStateMap.find(filedescriptor);
333 if (it != mCurrentMainStateMap.end())
335 if (NULL != mpTelenetServer)
337 logInfo("[TN] exitCommandExec, removing fd ", filedescriptor);
338 mpTelenetServer->disconnectClient(filedescriptor);
339 mCurrentMainStateMap.erase(it);
343 logError("[TN] exitCommandExec, mpTelenetServer == NULL, fd ", filedescriptor);
348 /****************************************************************************/
349 void CAmTelnetMenuHelper::helpCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
350 /****************************************************************************/
352 instance->helpCommandExec(CmdQueue, filedescriptor);
355 /****************************************************************************/
356 void CAmTelnetMenuHelper::helpCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
357 /****************************************************************************/
360 std::map<int, EMainState>::iterator it;
361 std::stringstream line;
362 tCommandMap::iterator cmdIter;
363 it = mCurrentMainStateMap.find(filedescriptor);
364 if (it != mCurrentMainStateMap.end())
366 line << COLOR_HEAD << "###################################################" << COLOR_DEFAULT << std::endl;
367 line << COLOR_HEAD << "###### The following commands are supported: ######" << COLOR_DEFAULT << std::endl;
368 line << COLOR_HEAD << "###################################################" << COLOR_DEFAULT << std::endl << std::endl;
372 cmdIter = mRootCommands.begin();
373 while (cmdIter != mRootCommands.end())
375 line << cmdIter->first << "\t\t- " << cmdIter->second.info << std::endl;
380 cmdIter = mListCommands.begin();
381 while (cmdIter != mListCommands.end())
383 line << cmdIter->first << "\t\t- " << cmdIter->second.info << std::endl;
388 cmdIter = mGetCommands.begin();
389 while (cmdIter != mGetCommands.end())
391 line << cmdIter->first << "\t\t- " << cmdIter->second.info << std::endl;
396 cmdIter = mSetCommands.begin();
397 while (cmdIter != mSetCommands.end())
399 line << cmdIter->first << "\t\t- " << cmdIter->second.info << std::endl;
404 cmdIter = mInfoCommands.begin();
405 while (cmdIter != mInfoCommands.end())
407 line << cmdIter->first << "\t\t- " << cmdIter->second.info << std::endl;
415 sendTelnetLine(filedescriptor, line);
420 /****************************************************************************/
421 void CAmTelnetMenuHelper::rootGetCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
422 /****************************************************************************/
424 instance->rootGetCommandExec(CmdQueue, filedescriptor);
427 /****************************************************************************/
428 void CAmTelnetMenuHelper::rootGetCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
429 /****************************************************************************/
432 std::map<int, EMainState>::iterator it;
433 it = mCurrentMainStateMap.find(filedescriptor);
434 if (it != mCurrentMainStateMap.end())
436 it->second = eGetState;
440 /****************************************************************************/
441 void CAmTelnetMenuHelper::rootSetCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
442 /****************************************************************************/
444 instance->rootSetCommandExec(CmdQueue, filedescriptor);
447 /****************************************************************************/
448 void CAmTelnetMenuHelper::rootSetCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
449 /****************************************************************************/
452 std::map<int, EMainState>::iterator it;
453 it = mCurrentMainStateMap.find(filedescriptor);
454 if (it != mCurrentMainStateMap.end())
456 it->second = eSetState;
460 /****************************************************************************/
461 void CAmTelnetMenuHelper::rootListCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
462 /****************************************************************************/
464 instance->rootListCommandExec(CmdQueue, filedescriptor);
467 /****************************************************************************/
468 void CAmTelnetMenuHelper::rootListCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
469 /****************************************************************************/
472 std::map<int, EMainState>::iterator it;
473 it = mCurrentMainStateMap.find(filedescriptor);
474 if (it != mCurrentMainStateMap.end())
476 it->second = eListState;
480 /****************************************************************************/
481 void CAmTelnetMenuHelper::rootInfoCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
482 /****************************************************************************/
484 instance->rootInfoCommandExec(CmdQueue, filedescriptor);
487 /****************************************************************************/
488 void CAmTelnetMenuHelper::rootInfoCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
489 /****************************************************************************/
492 std::map<int, EMainState>::iterator it;
493 it = mCurrentMainStateMap.find(filedescriptor);
494 if (it != mCurrentMainStateMap.end())
496 it->second = eInfoState;
500 /****************************************************************************/
501 void CAmTelnetMenuHelper::listConnectionsCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
502 /****************************************************************************/
504 instance->listConnectionsCommandExec(CmdQueue, filedescriptor);
507 /****************************************************************************/
508 void CAmTelnetMenuHelper::listConnectionsCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
509 /****************************************************************************/
512 std::vector < am_Connection_s > listConnections;
513 if (E_OK == mpDatabasehandler->getListConnections(listConnections))
515 std::stringstream output;
516 output << "\tConnections: " << listConnections.size() << std::endl;
517 for (std::vector<am_Connection_s>::iterator iter(listConnections.begin()); iter < listConnections.end(); iter++)
519 output << "\tID: " << iter->connectionID << "\tSrcID: " << iter->sourceID << "\tSinkID: " << iter->sinkID << "\tFormat: " << iter->connectionFormat << "\tdelay: " << iter->delay << std::endl;
521 sendTelnetLine(filedescriptor, output);
525 sendError(filedescriptor, "ERROR: mDatabasehandler->getListConnections");
529 /****************************************************************************/
530 void CAmTelnetMenuHelper::listSourcesCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
531 /****************************************************************************/
533 instance->listSourcesCommandExec(CmdQueue, filedescriptor);
536 /****************************************************************************/
537 void CAmTelnetMenuHelper::listSourcesCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
538 /****************************************************************************/
541 std::vector < am_Source_s > listSources;
542 if (E_OK == mpDatabasehandler->getListSources(listSources))
544 std::stringstream output;
545 output << "\tSources: " << listSources.size() << std::endl;
546 for (std::vector<am_Source_s>::iterator iter(listSources.begin()); iter < listSources.end(); iter++)
548 output << "\tID: " << iter->sourceID << "\tName: " << iter->name << "\tDomainID: " << iter->domainID << "\tState: " << iter->sourceState << "\tVolume: " << iter->volume << std::endl;
550 sendTelnetLine(filedescriptor, output);
554 sendError(filedescriptor, "ERROR: mDatabasehandler->getListSources");
558 /****************************************************************************/
559 void CAmTelnetMenuHelper::listSinksCommands(std::queue<std::string>& CmdQueue, int& filedescriptor)
560 /****************************************************************************/
562 instance->listSinksCommandsExec(CmdQueue, filedescriptor);
565 /****************************************************************************/
566 void CAmTelnetMenuHelper::listSinksCommandsExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
567 /****************************************************************************/
570 std::vector < am_Sink_s > listSinks;
571 if (E_OK == mpDatabasehandler->getListSinks(listSinks))
573 std::stringstream output;
574 output << "\tSinks: " << listSinks.size() << std::endl;
575 for (std::vector<am_Sink_s>::iterator iter(listSinks.begin()); iter < listSinks.end(); iter++)
577 output << "\tID: " << iter->sinkID << "\tDomainID: " << iter->domainID << "\tName: " << iter->name << "\tAvailable: " << iter->available.availability << "\tVolume: " << iter->volume << std::endl;
579 sendTelnetLine(filedescriptor, output);
583 sendError(filedescriptor, "ERROR: mDatabasehandler->getListSinks");
587 /****************************************************************************/
588 void CAmTelnetMenuHelper::listCrossfaders(std::queue<std::string>& CmdQueue, int& filedescriptor)
589 /****************************************************************************/
591 instance->listCrossfadersExec(CmdQueue, filedescriptor);
594 /****************************************************************************/
595 void CAmTelnetMenuHelper::listCrossfadersExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
596 /****************************************************************************/
599 std::vector < am_Crossfader_s > listCrossfaders;
600 if (E_OK == mpDatabasehandler->getListCrossfaders(listCrossfaders))
602 std::stringstream output;
603 output << "\tCrossfader: " << listCrossfaders.size() << std::endl;
604 for (std::vector<am_Crossfader_s>::iterator iter(listCrossfaders.begin()); iter < listCrossfaders.end(); iter++)
606 output << "\tID: " << iter->crossfaderID << "\tName: " << iter->name << "\tSinkA: " << iter->sinkID_A << "\tSinkB: " << iter->sinkID_B << "\tSourceID: " << iter->sourceID << std::endl;
608 sendTelnetLine(filedescriptor, output);
612 sendError(filedescriptor, "ERROR: mDatabasehandler->getListCrossfaders");
616 /****************************************************************************/
617 void CAmTelnetMenuHelper::listDomainsCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
618 /****************************************************************************/
620 instance->listDomainsCommandExec(CmdQueue, filedescriptor);
623 /****************************************************************************/
624 void CAmTelnetMenuHelper::listDomainsCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
625 /****************************************************************************/
628 std::vector < am_Domain_s > listDomains;
629 if (E_OK == mpDatabasehandler->getListDomains(listDomains))
631 std::stringstream output;
632 output << "\tDomains: " << listDomains.size() << std::endl;
633 for (std::vector<am_Domain_s>::iterator iter(listDomains.begin()); iter < listDomains.end(); iter++)
635 output << "\tID: " << iter->domainID << "\tName: " << iter->name << "\tBusname: " << iter->busname << "\tNodename: " << iter->nodename << "\tState: " << static_cast<int>(iter->state) << std::endl;
637 sendTelnetLine(filedescriptor, output);
641 sendError(filedescriptor, "ERROR: mDatabasehandler->getListDomains");
645 /****************************************************************************/
646 void CAmTelnetMenuHelper::listGatewaysCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
647 /****************************************************************************/
649 instance->listGatewaysCommandExec(CmdQueue, filedescriptor);
652 /****************************************************************************/
653 void CAmTelnetMenuHelper::listGatewaysCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
654 /****************************************************************************/
657 std::vector < am_Gateway_s > listGateways;
658 if (E_OK == mpDatabasehandler->getListGateways(listGateways))
660 std::stringstream output;
661 output << "\tGateways: " << listGateways.size();
662 for (std::vector<am_Gateway_s>::iterator iter(listGateways.begin()); iter < listGateways.end(); iter++)
664 output << "\tID: " << iter->gatewayID << "\tName: " << iter->name << "\tSourceID: " << iter->sourceID << "\tSinkID: " << iter->sinkID << std::endl;
666 sendTelnetLine(filedescriptor, output);
670 sendError(filedescriptor, "ERROR: mDatabasehandler->getListGateways");
674 /****************************************************************************/
675 void CAmTelnetMenuHelper::getRoutingCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
676 /****************************************************************************/
678 instance->getRoutingCommandExec(CmdQueue, filedescriptor);
681 /****************************************************************************/
682 void CAmTelnetMenuHelper::getRoutingCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
683 /****************************************************************************/
686 (void) (filedescriptor);
687 //TODO: fill with function
690 /****************************************************************************/
691 void CAmTelnetMenuHelper::getSenderversionCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
692 /****************************************************************************/
694 instance->getSenderversionCommandExec(CmdQueue, filedescriptor);
697 /****************************************************************************/
698 void CAmTelnetMenuHelper::getSenderversionCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
699 /****************************************************************************/
702 std::stringstream output;
703 std::string versionCommand;
704 std::string versionRouting;
705 std::string versionControl;
706 mpControlSender->getInterfaceVersion(versionControl);
707 mpRoutingSender->getInterfaceVersion(versionRouting);
708 mpCommandSender->getInterfaceVersion(versionCommand);
709 output << "\tSender versions:" << std::endl << "\tCtrl: " << versionControl << " | " << "Cmd: " << versionCommand << " | " << "Routing: " << versionRouting << std::endl;
710 sendTelnetLine(filedescriptor, output);
713 /****************************************************************************/
714 void CAmTelnetMenuHelper::getReceiverversionCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
715 /****************************************************************************/
717 instance->getReceiverversionCommandExec(CmdQueue, filedescriptor);
720 /****************************************************************************/
721 void CAmTelnetMenuHelper::getReceiverversionCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
722 /****************************************************************************/
725 std::stringstream output;
726 std::string versionCommand;
727 std::string versionRouting;
728 std::string versionControl;
729 mpControlReceiver->getInterfaceVersion(versionControl);
730 mpRoutingReceiver->getInterfaceVersion(versionRouting);
731 mpCommandReceiver->getInterfaceVersion(versionCommand);
732 output << "\tReceiver versions:" << std::endl << "\tCtrl: " << versionControl << " | " << "Cmd: " << versionCommand << " | " << "Routing: " << versionRouting << std::endl;
733 sendTelnetLine(filedescriptor, output);
736 /****************************************************************************/
737 void CAmTelnetMenuHelper::infoSystempropertiesCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
738 /****************************************************************************/
740 instance->infoSystempropertiesCommandExec(CmdQueue, filedescriptor);
743 /****************************************************************************/
744 void CAmTelnetMenuHelper::setVolumeStep(std::queue<std::string>& CmdQueue, int& filedescriptor)
745 /****************************************************************************/
747 instance->setSinkVolumeExec(CmdQueue,filedescriptor);
750 /****************************************************************************/
751 void CAmTelnetMenuHelper::setVolumeStepExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
752 /****************************************************************************/
754 if (CmdQueue.size() >= 2)
756 int16_t volumestep = 0;
757 am_sinkID_t sinkID = 0;
759 std::istringstream istream_sinkID(CmdQueue.front());
761 std::istringstream istream_volumestep(CmdQueue.front());
763 if (!(istream_volumestep >> volumestep))
766 if (!(istream_sinkID >> sinkID))
771 sendError(filedescriptor, "Error parsing setVolumeStep 'sinkID' or 'volumestep'");
774 if (E_OK == mpCommandReceiver->volumeStep(sinkID,volumestep))
776 std::stringstream output;
777 output << "SetSinkVolumeStep set: " << sinkID << "->" << volumestep << std::endl;
778 sendTelnetLine(filedescriptor, output);
782 sendError(filedescriptor, "Error SetSinkVolumeStep");
787 sendError(filedescriptor, "Not enough arguments to set SetSinkVolumeStep, please enter 'sinkID' and 'volumestep' after command");
792 /****************************************************************************/
793 void CAmTelnetMenuHelper::setSinkMuteState(std::queue<std::string>& CmdQueue, int& filedescriptor)
794 /****************************************************************************/
796 instance->setSinkMuteStateExec(CmdQueue,filedescriptor);
799 /****************************************************************************/
800 void CAmTelnetMenuHelper::setSinkMuteStateExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
801 /****************************************************************************/
803 if (CmdQueue.size() >= 2)
806 am_MuteState_e MuteState = MS_UNKNOWN;
807 am_sinkID_t sinkID = 0;
809 std::istringstream istream_sinkID(CmdQueue.front());
811 std::istringstream istream_mutestate(CmdQueue.front());
813 if (!(istream_mutestate >> tmp))
816 if (!(istream_sinkID >> sinkID))
821 MuteState = static_cast<am_MuteState_e>(tmp);
825 sendError(filedescriptor, "You tried to set an invalid am_MuteState_e");
831 sendError(filedescriptor, "Error parsing setSinkMuteState 'sinkID' or 'mutestate'");
834 if (E_OK == mpCommandReceiver->setSinkMuteState(sinkID,MuteState))
836 std::stringstream output;
837 output << "setSinkMuteState set: " << sinkID << "->" << MuteState << std::endl;
838 sendTelnetLine(filedescriptor, output);
842 sendError(filedescriptor, "Error setSinkMuteState");
847 sendError(filedescriptor, "Not enough arguments to set setSinkMuteState, please enter 'sinkID' and 'mutestate' after command");
852 /****************************************************************************/
853 void CAmTelnetMenuHelper::setSourceSoundProperty(std::queue<std::string>& CmdQueue, int& filedescriptor)
854 /****************************************************************************/
856 instance->setSourceSoundPropertiesExec(CmdQueue,filedescriptor);
859 /****************************************************************************/
860 void CAmTelnetMenuHelper::setSourceSoundPropertyExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
861 /****************************************************************************/
863 unsigned int tmpType = 0;
865 if (CmdQueue.size() >= 3)
867 std::istringstream istream_sourceID(CmdQueue.front());
869 std::istringstream istream_type(CmdQueue.front());
871 std::istringstream istream_value(CmdQueue.front());
873 if (!(istream_type >> tmpType))
876 am_MainSoundProperty_s soundProperty;
877 if (tmpType < MSP_MAX)
878 soundProperty.type = static_cast<am_MainSoundPropertyType_e>(tmpType);
882 if (!(istream_value >> soundProperty.value))
885 am_sourceID_t sourceID = 0;
886 if (!(istream_sourceID >> sourceID))
891 sendError(filedescriptor, "Error parsing setMainSourceSoundProperty 'type', 'value' or 'sourceID'");
894 if (E_OK == mpCommandReceiver->setMainSourceSoundProperty(soundProperty, sourceID))
896 std::stringstream output;
897 output << "setMainSourceSoundProperty set: " << soundProperty.type << "->" << soundProperty.value << std::endl;
898 sendTelnetLine(filedescriptor, output);
902 sendError(filedescriptor, "Error setMainSourceSoundProperty");
907 sendError(filedescriptor, "Not enough arguments to set setMainSourceSoundProperty, please enter 'sourceID', 'type' and 'value' after command");
912 /****************************************************************************/
913 void CAmTelnetMenuHelper::infoSystempropertiesCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
914 /****************************************************************************/
917 std::vector < am_SystemProperty_s > listSystemProperties;
918 if (E_OK == mpDatabasehandler->getListSystemProperties(listSystemProperties))
920 std::stringstream output;
921 output << "\tSystemproperties: " << listSystemProperties.size() << std::endl;
922 std::vector<am_SystemProperty_s>::iterator it;
923 for (it = listSystemProperties.begin(); it < listSystemProperties.end(); it++)
925 output << "\tType: " << it->type << " Value: " << it->value << std::endl;
927 sendTelnetLine(filedescriptor, output);
931 sendError(filedescriptor, "ERROR: mDatabasehandler->getListSystemProperties");
935 /****************************************************************************/
936 void CAmTelnetMenuHelper::setRoutingCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
937 /****************************************************************************/
939 instance->setRoutingCommandExec(CmdQueue, filedescriptor);
942 /****************************************************************************/
943 void CAmTelnetMenuHelper::setRoutingCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
944 /****************************************************************************/
946 if (CmdQueue.size() >= 2)
949 std::istringstream istream_sourceID(CmdQueue.front());
951 std::istringstream istream_sinkID(CmdQueue.front());
953 am_sourceID_t sourceID = 0;
954 if (!(istream_sourceID >> sourceID))
957 am_sinkID_t sinkID = 0;
958 if (!(istream_sinkID >> sinkID))
963 sendError(filedescriptor, "Error parsing sourcID and sinkID");
966 std::vector < am_Route_s > routingList;
967 if (E_OK == mpRouter->getRoute(true, sourceID, sinkID, routingList))
969 std::stringstream output;
970 std::vector<am_Route_s>::iterator rlIter = routingList.begin();
971 for (int rlCnt = 1; rlIter < routingList.end(); rlIter++)
973 output << "#" << rlCnt << " ";
974 std::vector<am_RoutingElement_s>::iterator reIter = rlIter->route.begin();
975 for (; reIter < rlIter->route.end(); reIter++)
977 output << ">(" << reIter->sourceID << ")->--[D:" << reIter->domainID << "][F:" << reIter->connectionFormat << "]-->-(" << reIter->sinkID << ")" << std::endl;
982 sendTelnetLine(filedescriptor, output);
986 sendError(filedescriptor, "Error getting route");
991 if (!CmdQueue.empty())
994 sendError(filedescriptor, "Not enough arguments to set routing. Please enter sourceID and sinkID after command");
998 /****************************************************************************/
999 void CAmTelnetMenuHelper::setConnection(std::queue<std::string>& CmdQueue, int& filedescriptor)
1000 /****************************************************************************/
1002 instance->setConnectionExec(CmdQueue, filedescriptor);
1005 /****************************************************************************/
1006 void CAmTelnetMenuHelper::setConnectionExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
1007 /****************************************************************************/
1010 am_Error_e rError = E_OK;
1011 if (CmdQueue.size() >= 2)
1013 std::istringstream istream_sourceID(CmdQueue.front());
1015 std::istringstream istream_sinkID(CmdQueue.front());
1017 am_sourceID_t sourceID = 0;
1018 if (!(istream_sourceID >> sourceID))
1021 am_sinkID_t sinkID = 0;
1022 if (!(istream_sinkID >> sinkID))
1027 sendError(filedescriptor, "Error parsing sinkID and/or sourceID");
1030 // Try to set up connection
1031 am_mainConnectionID_t connID = 0;
1032 rError = mpCommandReceiver->connect(sourceID, sinkID, connID);
1035 std::stringstream output;
1036 output << "ConnID: " << connID << "\tSrc: " << sourceID << " ---> Sink: " << sinkID << std::endl;
1037 sendTelnetLine(filedescriptor, output);
1041 sendError(filedescriptor, "Error connecting sourceID and sinkID");
1046 // remove 1 element if list is not empty
1047 if (!CmdQueue.empty())
1050 sendError(filedescriptor, "Not enough arguments to set routing. Please enter sourceID and sinkID after command");
1055 /****************************************************************************/
1056 void CAmTelnetMenuHelper::setDisconnectConnId(std::queue<std::string>& CmdQueue, int& filedescriptor)
1057 /****************************************************************************/
1059 instance->setDisconnectConnIdExec(CmdQueue, filedescriptor);
1062 /****************************************************************************/
1063 void CAmTelnetMenuHelper::setDisconnectConnIdExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
1064 /****************************************************************************/
1066 am_mainConnectionID_t connID = 0;
1068 am_Error_e rError = E_OK;
1069 if (CmdQueue.size() >= 1)
1071 std::istringstream istream_connID(CmdQueue.front());
1073 if (!(istream_connID >> connID))
1078 sendError(filedescriptor, "Error parsing connID");
1081 // Try to disconnect connection id
1082 rError = mpCommandReceiver->disconnect(connID);
1085 std::stringstream output;
1086 output << "ConnID " << connID << " closed successfully! " << std::endl;
1087 sendTelnetLine(filedescriptor, output);
1091 sendError(filedescriptor, "Error disconnecting connectionID");
1096 sendError(filedescriptor, "Not enough arguments to disconnect a Main Connection, please enter 'connectionID' after command");
1101 /****************************************************************************/
1102 void CAmTelnetMenuHelper::setSourceSoundProperties(std::queue<std::string>& CmdQueue, int& filedescriptor)
1103 /****************************************************************************/
1105 instance->setConnectionExec(CmdQueue, filedescriptor);
1108 /****************************************************************************/
1109 void CAmTelnetMenuHelper::setSourceSoundPropertiesExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
1110 /****************************************************************************/
1112 if (CmdQueue.size() >= 3)
1115 std::istringstream istream_sourceID(CmdQueue.front());
1117 std::istringstream istream_type(CmdQueue.front());
1119 std::istringstream istream_value(CmdQueue.front());
1121 unsigned int tmpType = 0;
1122 if (!(istream_type >> tmpType))
1125 am_MainSoundProperty_s soundProperty;
1126 if (tmpType < MSP_MAX)
1127 soundProperty.type = static_cast<am_MainSoundPropertyType_e>(tmpType);
1131 if (!(istream_value >> soundProperty.value))
1134 am_sinkID_t sourceID = 0;
1135 if (!(istream_sourceID >> sourceID))
1140 sendError(filedescriptor, "Error parsing MainSinkSoundProperty 'type', 'value' or 'sourceID'");
1143 if (E_OK == mpCommandReceiver->setMainSourceSoundProperty(soundProperty, sourceID))
1145 std::stringstream output;
1146 output << "MainSourceSoundProperty set: " << soundProperty.type << "->" << soundProperty.value << std::endl;
1147 sendTelnetLine(filedescriptor, output);
1151 sendError(filedescriptor, "Error setMainSourceSoundProperty");
1156 sendError(filedescriptor, "Not enough arguments to set MainSourceSoundProperty, please enter 'sourceID', 'type' and 'value' after command");
1161 /****************************************************************************/
1162 void CAmTelnetMenuHelper::setSinkSoundProperty(std::queue<std::string>& CmdQueue, int& filedescriptor)
1163 /****************************************************************************/
1165 instance->setSinkSoundPropertyExec(CmdQueue, filedescriptor);
1168 /****************************************************************************/
1169 void CAmTelnetMenuHelper::setSinkSoundPropertyExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
1170 /****************************************************************************/
1172 unsigned int tmpType = 0;
1174 if (CmdQueue.size() >= 3)
1176 std::istringstream istream_sinkID(CmdQueue.front());
1178 std::istringstream istream_type(CmdQueue.front());
1180 std::istringstream istream_value(CmdQueue.front());
1182 if (!(istream_type >> tmpType))
1185 am_MainSoundProperty_s soundProperty;
1186 if (tmpType < MSP_MAX)
1187 soundProperty.type = static_cast<am_MainSoundPropertyType_e>(tmpType);
1191 if (!(istream_value >> soundProperty.value))
1194 am_sinkID_t sinkID = 0;
1195 if (!(istream_sinkID >> sinkID))
1200 sendError(filedescriptor, "Error parsing MainSinkSoundProperty 'type', 'value' or 'sinkID'");
1203 if (E_OK == mpCommandReceiver->setMainSinkSoundProperty(soundProperty, sinkID))
1205 std::stringstream output;
1206 output << "MainSinkSoundProperty set: " << soundProperty.type << "->" << soundProperty.value << std::endl;
1207 sendTelnetLine(filedescriptor, output);
1211 sendError(filedescriptor, "Error setMainSinkSoundProperty");
1216 sendError(filedescriptor, "Not enough arguments to set MainSinkSoundProperty, please enter 'sinkID', 'type' and 'value' after command");
1221 /****************************************************************************/
1222 void CAmTelnetMenuHelper::setSinkVolume(std::queue<std::string>& CmdQueue, int& filedescriptor)
1223 /****************************************************************************/
1225 instance->setSinkVolumeExec(CmdQueue, filedescriptor);
1228 /****************************************************************************/
1229 void CAmTelnetMenuHelper::setSinkVolumeExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
1230 /****************************************************************************/
1232 if (CmdQueue.size() >= 2)
1234 am_volume_t volume = 0;
1235 am_sinkID_t sinkID = 0;
1237 std::istringstream istream_sinkID(CmdQueue.front());
1239 std::istringstream istream_volume(CmdQueue.front());
1241 if (!(istream_volume >> volume))
1244 if (!(istream_sinkID >> sinkID))
1249 sendError(filedescriptor, "Error parsing SetSinkVolume 'sinkID' or 'volume'");
1252 if (E_OK == mpCommandReceiver->setVolume(sinkID,volume))
1254 std::stringstream output;
1255 output << "setVolume set: " << sinkID << "->" << volume << std::endl;
1256 sendTelnetLine(filedescriptor, output);
1260 sendError(filedescriptor, "Error setVolume");
1265 sendError(filedescriptor, "Not enough arguments to set setVolume, please enter 'sinkID' and 'volume' after command");
1270 /****************************************************************************/
1271 void CAmTelnetMenuHelper::listPluginsCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
1272 /****************************************************************************/
1274 instance->listPluginsCommandExec(CmdQueue, filedescriptor);
1277 /****************************************************************************/
1278 void CAmTelnetMenuHelper::listPluginsCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
1279 /****************************************************************************/
1282 std::vector < std::string > PlugInNames;
1283 std::vector<std::string>::iterator iter;
1284 std::stringstream output;
1285 if (E_OK == mpCommandSender->getListPlugins(PlugInNames))
1287 output << "\tCommandSender Plugins loaded: " << PlugInNames.size() << std::endl;
1288 for (iter = PlugInNames.begin(); iter < PlugInNames.end(); iter++)
1290 output << iter->c_str() << std::endl;
1295 sendError(filedescriptor, "ERROR: mCommandSender->getListPlugins");
1297 if (E_OK == mpRoutingSender->getListPlugins(PlugInNames))
1299 output << std::endl << "\tRoutingSender Plugins loaded: " << PlugInNames.size() << std::endl;
1300 for (iter = PlugInNames.begin(); iter < PlugInNames.end(); iter++)
1302 output << iter->c_str() << std::endl;
1307 sendError(filedescriptor, "ERROR: mRoutingSender->getListPlugins");
1309 sendTelnetLine(filedescriptor, output);
1312 /****************************************************************************/
1313 void CAmTelnetMenuHelper::listMainSourcesCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
1314 /****************************************************************************/
1316 instance->listMainSourcesCommandExec(CmdQueue, filedescriptor);
1319 /****************************************************************************/
1320 void CAmTelnetMenuHelper::listMainSourcesCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
1321 /****************************************************************************/
1324 std::vector < am_SourceType_s > listMainSources;
1325 if (E_OK == mpDatabasehandler->getListMainSources(listMainSources))
1327 std::stringstream output;
1328 output << std::endl << "\tMainSources: " << listMainSources.size() << std::endl;
1329 std::vector<am_SourceType_s>::iterator iter;
1330 for (iter = listMainSources.begin(); iter < listMainSources.end(); iter++)
1332 output << "\tID: " << iter->sourceID << "\tName: " << iter->name << "\tsourceClassID: " << iter->sourceClassID << "\tavailability: " << iter->availability.availability << std::endl;
1334 sendTelnetLine(filedescriptor, output);
1338 sendError(filedescriptor, "ERROR: mDatabasehandler->getListMainSources");
1342 /****************************************************************************/
1343 void CAmTelnetMenuHelper::listMainSinksCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
1344 /****************************************************************************/
1346 instance->listMainSinksCommandExec(CmdQueue, filedescriptor);
1349 /****************************************************************************/
1350 void CAmTelnetMenuHelper::listMainSinksCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
1351 /****************************************************************************/
1354 std::vector < am_SinkType_s > listMainSinks;
1355 if (E_OK == mpDatabasehandler->getListMainSinks(listMainSinks))
1357 std::stringstream output;
1358 output << std::endl << "\tMainSinks: " << listMainSinks.size() << std::endl;
1359 std::vector<am_SinkType_s>::iterator iter;
1360 for (iter = listMainSinks.begin(); iter < listMainSinks.end(); iter++)
1362 output << "\tID: " << iter->sinkID << "\tsinkClassID: " << iter->sinkClassID << "\tName: " << iter->name << "\tAvailable: " << iter->availability.availability << "\tVolume: " << iter->volume << std::endl;
1364 sendTelnetLine(filedescriptor, output);
1368 sendError(filedescriptor, "ERROR: mDatabasehandler->getListMainSinks");
1372 /****************************************************************************/
1373 void CAmTelnetMenuHelper::listMainConnectionsCommand(std::queue<std::string>& CmdQueue, int& filedescriptor)
1374 /****************************************************************************/
1376 instance->listMainConnectionsCommandExec(CmdQueue, filedescriptor);
1379 /****************************************************************************/
1380 void CAmTelnetMenuHelper::listMainConnectionsCommandExec(std::queue<std::string>& CmdQueue, int& filedescriptor)
1381 /****************************************************************************/
1384 std::vector<am_MainConnection_s> listMainConnections;
1386 if(E_OK == mpDatabasehandler->getListMainConnections(listMainConnections))
1388 std::stringstream output;
1389 output << std::endl << "\tMainConnections: " << listMainConnections.size() << std::endl;
1391 std::vector<am_MainConnection_s>::iterator iter;
1392 for (iter = listMainConnections.begin(); iter < listMainConnections.end(); iter++)
1394 output << "\tID: " << iter->mainConnectionID
1395 << "\tState: " << iter->connectionState
1396 << "\tDelay: " << iter->delay
1397 << "\tsourceID: " << iter->sourceID
1398 << "\tsinkID: " << iter->sinkID << std::endl;
1400 output << "ConnectionIDs: ";
1401 std::vector<am_connectionID_t>::iterator list_connIDs_iter = iter->listConnectionID.begin();
1402 for(;list_connIDs_iter < iter->listConnectionID.end();list_connIDs_iter++)
1404 output << *list_connIDs_iter << " ";
1407 output << std::endl;
1409 sendTelnetLine(filedescriptor,output);
1413 sendError(filedescriptor,"ERROR: mDatabasehandler->getListMainSinks");