* fixed typo in addpackagedependencies.sh used for package management
[profile/ivi/audiomanager.git] / AudioManagerDaemon / src / CAmTelnetMenuHelper.cpp
1 /**
2  * Copyright (C) 2012, BMW AG
3  *
4  * This file is part of GENIVI Project AudioManager.
5  *
6  * Contributions are licensed to the GENIVI Alliance under one or more
7  * Contribution License Agreements.
8  *
9  * \copyright
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/.
13  *
14  *
15  * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
16  * \author Frank Herchet, frank.fh.herchet@bmw.de BMW 2012
17  *
18  * \file CAmTelnetMenuHelper.cpp
19  * For further information see http://www.genivi.org/.
20  *
21  */
22
23 #include "CAmTelnetMenuHelper.h"
24 #include <cassert>
25 #include "config.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"
36
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");
40
41
42 namespace am {
43
44 CAmTelnetMenuHelper* CAmTelnetMenuHelper::instance = NULL;
45
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)
50 {
51     instance = this;
52     createCommandMaps();
53 }
54
55 /****************************************************************************/
56 CAmTelnetMenuHelper::~CAmTelnetMenuHelper()
57 /****************************************************************************/
58 {
59 }
60
61 /****************************************************************************/
62 void CAmTelnetMenuHelper::createCommandMaps()
63 /****************************************************************************/
64 {
65     // ROOT commands
66
67     mRootCommands.clear();
68
69     mRootCommands.insert(std::make_pair("help", sCommandPrototypeInfo("show all possible commands", &CAmTelnetMenuHelper::helpCommand)));
70     mRootCommands.insert(std::make_pair("list", sCommandPrototypeInfo("Go into 'list'-submenu", &CAmTelnetMenuHelper::rootListCommand)));
71     mRootCommands.insert(std::make_pair("info", sCommandPrototypeInfo("Go into 'info'-submenu", &CAmTelnetMenuHelper::rootInfoCommand)));
72     mRootCommands.insert(std::make_pair("set", sCommandPrototypeInfo("Go into 'set'-submenu", &CAmTelnetMenuHelper::rootSetCommand)));
73     mRootCommands.insert(std::make_pair("get", sCommandPrototypeInfo("Go into 'get'-submenu", &CAmTelnetMenuHelper::rootGetCommand)));
74     mRootCommands.insert(std::make_pair("exit", sCommandPrototypeInfo("quit telnet session", &CAmTelnetMenuHelper::exitCommand)));
75
76     // List commands
77     mListCommands.insert(std::make_pair("help", sCommandPrototypeInfo(std::string("show all possible commands"), &CAmTelnetMenuHelper::helpCommand)));
78     mListCommands.insert(std::make_pair("conn", sCommandPrototypeInfo("list all connections", &CAmTelnetMenuHelper::listConnectionsCommand)));
79     mListCommands.insert(std::make_pair("sources", sCommandPrototypeInfo("list all available sources", &CAmTelnetMenuHelper::listSourcesCommand)));
80     mListCommands.insert(std::make_pair("sinks", sCommandPrototypeInfo("list all available sinks", &CAmTelnetMenuHelper::listSinksCommands)));
81     mListCommands.insert(std::make_pair("crfaders", sCommandPrototypeInfo("list all crossfaders", &CAmTelnetMenuHelper::listCrossfaders)));
82     mListCommands.insert(std::make_pair("domains", sCommandPrototypeInfo("list all domains", &CAmTelnetMenuHelper::listDomainsCommand)));
83     mListCommands.insert(std::make_pair("gws", sCommandPrototypeInfo("list all gateways", &CAmTelnetMenuHelper::listGatewaysCommand)));
84     mListCommands.insert(std::make_pair("mainconn", sCommandPrototypeInfo("list all main connections", &CAmTelnetMenuHelper::listMainConnectionsCommand)));
85     mListCommands.insert(std::make_pair("mainsinks", sCommandPrototypeInfo("list all main sinks", &CAmTelnetMenuHelper::listMainSinksCommand)));
86     mListCommands.insert(std::make_pair("mainsources", sCommandPrototypeInfo("list all main sources", &CAmTelnetMenuHelper::listMainSourcesCommand)));
87     mListCommands.insert(std::make_pair("..", sCommandPrototypeInfo("one step back in menu tree (back to root folder)", &CAmTelnetMenuHelper::oneStepBackCommand)));
88     mListCommands.insert(std::make_pair("exit", sCommandPrototypeInfo("close telnet session", &CAmTelnetMenuHelper::exitCommand)));
89
90     // Set commands
91     mSetCommands.insert(std::make_pair("help", sCommandPrototypeInfo(std::string("show all possible commands"), &CAmTelnetMenuHelper::helpCommand)));
92     mSetCommands.insert(std::make_pair("..", sCommandPrototypeInfo("one step back in menu tree (back to root folder)", &CAmTelnetMenuHelper::oneStepBackCommand)));
93     mSetCommands.insert(std::make_pair("exit", sCommandPrototypeInfo("close telnet session", &CAmTelnetMenuHelper::exitCommand)));
94     mSetCommands.insert(std::make_pair("conn", sCommandPrototypeInfo("use 'conn sourceId sinkId' to connect a source and a sink", &CAmTelnetMenuHelper::setConnection)));
95     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)));
96     mSetCommands.insert(std::make_pair("disc", sCommandPrototypeInfo("use 'disc connectionID' to disconnect \n\t  this connection", &CAmTelnetMenuHelper::setDisconnectConnId)));
97
98     // Get commands
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)));
105
106     // Info comands
107     mInfoCommands.insert(std::make_pair("help", sCommandPrototypeInfo(std::string("show all possible commands"), &CAmTelnetMenuHelper::helpCommand)));
108     mInfoCommands.insert(std::make_pair("sysprop", sCommandPrototypeInfo("show all systemproperties", &CAmTelnetMenuHelper::infoSystempropertiesCommand)));
109     mInfoCommands.insert(std::make_pair("..", sCommandPrototypeInfo("one step back in menu tree (back to root folder)", &CAmTelnetMenuHelper::oneStepBackCommand)));
110     mInfoCommands.insert(std::make_pair("exit", sCommandPrototypeInfo("close telnet session", &CAmTelnetMenuHelper::exitCommand)));
111 }
112
113 /****************************************************************************/
114 void CAmTelnetMenuHelper::newSocketConnection(int filedescriptor)
115 /****************************************************************************/
116 {
117     EMainState state = eRootState;
118     std::map<int, EMainState>::iterator it;
119     std::stringstream welcome;
120
121     it = mCurrentMainStateMap.find(filedescriptor);
122     if (it != mCurrentMainStateMap.end())
123     {
124         // socket connection already exists, delete entry and go back to root state
125         mCurrentMainStateMap.erase(it);
126     }
127
128     it = mCurrentMainStateMap.begin();
129
130     // insert new socket connection
131     mCurrentMainStateMap.insert(it, std::make_pair<int, EMainState>(filedescriptor, state));
132
133     // Send welcome message
134     welcome << COLOR_WELCOME << "Welcome to GENIVI AudioManager " << DAEMONVERSION << COLOR_DEFAULT << "\n>";
135     send(filedescriptor, welcome.str().c_str(), welcome.str().size(), 0);
136     logInfo("[TN] New connection: ",filedescriptor);
137 }
138
139 /****************************************************************************/
140 void CAmTelnetMenuHelper::socketConnectionsClosed(int filedescriptor)
141 /****************************************************************************/
142 {
143     std::map<int, EMainState>::iterator it;
144
145     it = mCurrentMainStateMap.find(filedescriptor);
146     if (it != mCurrentMainStateMap.end())
147     {
148         mCurrentMainStateMap.erase(it);
149     }
150     else
151     {
152         logError("[TN] socketConnectionsClosed, fd not found, ",filedescriptor);
153     }
154 }
155
156 /****************************************************************************/
157 void CAmTelnetMenuHelper::enterCmdQueue(std::queue<std::string> & CmdQueue, int & filedescriptor)
158 /****************************************************************************/
159 {
160     std::map<int, EMainState>::iterator it;
161     std::string cmd;
162     tCommandMap::iterator cmditer;
163
164     // find current filedescriptor to get the current state of the telnet session
165     it = mCurrentMainStateMap.find(filedescriptor);
166     while (!CmdQueue.empty())
167     {
168         cmd = CmdQueue.front();
169
170         // Now remove the first command, it's stored in 'cmd'
171         CmdQueue.pop();
172         // telnet session found. depending on the current state, different commands are available
173         switch (it->second)
174         {
175         case eRootState:
176             cmditer = mRootCommands.find(cmd);
177             if (mRootCommands.end() != cmditer)
178                 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
179             else
180                 sendError(filedescriptor, "Command not found\n");
181             break;
182         case eListState:
183             cmditer = mListCommands.find(cmd);
184             if (mListCommands.end() != cmditer)
185                 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
186             else
187                 sendError(filedescriptor, "Command not found\n");
188             break;
189         case eInfoState:
190             cmditer = mInfoCommands.find(cmd);
191             if (mInfoCommands.end() != cmditer)
192                 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
193             else
194                 sendError(filedescriptor, "Command not found\n");
195             break;
196         case eGetState:
197             cmditer = mGetCommands.find(cmd);
198             if (mGetCommands.end() != cmditer)
199                 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
200             else
201                 sendError(filedescriptor, "Command not found\n");
202             break;
203         case eSetState:
204             cmditer = mSetCommands.find(cmd);
205             if (mSetCommands.end() != cmditer)
206                 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
207             else
208                 sendError(filedescriptor, "Command not found\n");
209             break;
210         default:
211             break;
212         }
213     }
214
215     sendCurrentCmdPrompt(filedescriptor);
216 }
217
218 /****************************************************************************/
219 void CAmTelnetMenuHelper::sendError(int & filedescriptor, std::string error_string)
220 /****************************************************************************/
221 {
222     send(filedescriptor, error_string.c_str(), error_string.size(), 0);
223 }
224
225 /****************************************************************************/
226 void CAmTelnetMenuHelper::sendTelnetLine(int & filedescriptor, std::stringstream &line)
227 /****************************************************************************/
228 {
229     send(filedescriptor, line.str().c_str(), line.str().size(), 0);
230 }
231
232 /****************************************************************************/
233 void CAmTelnetMenuHelper::sendCurrentCmdPrompt(int & filedescriptor)
234 /****************************************************************************/
235 {
236     std::map<int, EMainState>::iterator it;
237     std::stringstream outputstream;
238     outputstream << std::endl;
239
240     it = mCurrentMainStateMap.find(filedescriptor);
241     if (it != mCurrentMainStateMap.end())
242     {
243         switch (it->second)
244         {
245         case eRootState:
246             outputstream << "\\>";
247             break;
248         case eListState:
249             outputstream << "\\List>";
250             break;
251         case eGetState:
252             outputstream << "\\Get>";
253             break;
254         case eSetState:
255             outputstream << "\\Set>";
256             break;
257         case eInfoState:
258             outputstream << "\\Info>";
259             break;
260         default:
261             break;
262         }
263
264         send(filedescriptor, outputstream.str().c_str(), outputstream.str().size(), 0);
265
266     }
267     else
268     {
269         logInfo("[TN] sendCurrentCmdPrompt, fd not found: ",filedescriptor);
270     }
271 }
272
273 /****************************************************************************/
274 void CAmTelnetMenuHelper::exitCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
275 /****************************************************************************/
276 {
277     instance->exitCommandExec(CmdQueue, filedescriptor);
278 }
279
280 /****************************************************************************/
281 void CAmTelnetMenuHelper::oneStepBackCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
282 /****************************************************************************/
283 {
284     (void) CmdQueue;
285     std::map<int, EMainState>::iterator it;
286     it = mCurrentMainStateMap.find(filedescriptor);
287     if (it != mCurrentMainStateMap.end())
288     {
289         switch (it->second)
290         {
291         case eRootState:
292             it->second = eRootState;
293             break;
294         case eListState:
295             it->second = eRootState;
296             ;
297             break;
298         case eGetState:
299             it->second = eRootState;
300             ;
301             break;
302         case eSetState:
303             it->second = eRootState;
304             ;
305             break;
306         case eInfoState:
307             it->second = eRootState;
308             ;
309             break;
310         default:
311             it->second = eRootState;
312             break;
313         }
314
315         logInfo("[TN] oneStepBackCommandExec, state: ",it->second);
316     }
317 }
318
319 /****************************************************************************/
320 void CAmTelnetMenuHelper::oneStepBackCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
321 /****************************************************************************/
322 {
323     instance->oneStepBackCommandExec(CmdQueue, filedescriptor);
324 }
325
326 /****************************************************************************/
327 void CAmTelnetMenuHelper::exitCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
328 /****************************************************************************/
329 {
330     (void) CmdQueue;
331     std::map<int, EMainState>::iterator it;
332     std::stringstream line;
333     std::stringstream output;
334
335     // Sending a last message to the client
336     output << "bye!" << COLOR_DEFAULT << std::endl;
337     sendTelnetLine(filedescriptor, output);
338
339     tCommandMap::iterator iter;
340     it = mCurrentMainStateMap.find(filedescriptor);
341     if (it != mCurrentMainStateMap.end())
342     {
343         if (NULL != mpTelenetServer)
344         {
345             logInfo("[TN] exitCommandExec, removing fd ",filedescriptor);
346             mpTelenetServer->disconnectClient(filedescriptor);
347             mCurrentMainStateMap.erase(it);
348         }
349         else
350         {
351             logError("[TN] exitCommandExec, mpTelenetServer == NULL, fd ",filedescriptor);
352         }
353     }
354 }
355
356 /****************************************************************************/
357 void CAmTelnetMenuHelper::helpCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
358 /****************************************************************************/
359 {
360     instance->helpCommandExec(CmdQueue, filedescriptor);
361 }
362
363 /****************************************************************************/
364 void CAmTelnetMenuHelper::helpCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
365 /****************************************************************************/
366 {
367     (void) CmdQueue;
368     std::map<int, EMainState>::iterator it;
369     std::stringstream line;
370     tCommandMap::iterator cmdIter;
371     it = mCurrentMainStateMap.find(filedescriptor);
372     if (it != mCurrentMainStateMap.end())
373     {
374         line << COLOR_HEAD << "###################################################" << COLOR_DEFAULT << std::endl;
375         line << COLOR_HEAD << "###### The following commands are supported: ######" << COLOR_DEFAULT << std::endl;
376         line << COLOR_HEAD << "###################################################" << COLOR_DEFAULT << std::endl << std::endl;
377         switch (it->second)
378         {
379         case eRootState:
380
381             cmdIter = mRootCommands.begin();
382             while (cmdIter != mRootCommands.end())
383             {
384                 line << cmdIter->first << "\t\t- " << cmdIter->second.info << std::endl;
385                 cmdIter++;
386             }
387             break;
388         case eListState:
389             cmdIter = mListCommands.begin();
390             while (cmdIter != mListCommands.end())
391             {
392                 line << cmdIter->first << "\t\t- " << cmdIter->second.info << std::endl;
393                 cmdIter++;
394             }
395             break;
396         case eGetState:
397             cmdIter = mGetCommands.begin();
398             while (cmdIter != mGetCommands.end())
399             {
400                 line << cmdIter->first << "\t\t- " << cmdIter->second.info << std::endl;
401                 cmdIter++;
402             }
403             break;
404         case eSetState:
405             cmdIter = mSetCommands.begin();
406             while (cmdIter != mSetCommands.end())
407             {
408                 line << cmdIter->first << "\t\t- " << cmdIter->second.info << std::endl;
409                 cmdIter++;
410             }
411             break;
412         case eInfoState:
413             cmdIter = mInfoCommands.begin();
414             while (cmdIter != mInfoCommands.end())
415             {
416                 line << cmdIter->first << "\t\t- " << cmdIter->second.info << std::endl;
417                 cmdIter++;
418             }
419             break;
420         default:
421             break;
422         }
423         sendTelnetLine(filedescriptor, line);
424     }
425 }
426
427 /****************************************************************************/
428 void CAmTelnetMenuHelper::rootGetCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
429 /****************************************************************************/
430 {
431     instance->rootGetCommandExec(CmdQueue, filedescriptor);
432 }
433
434 /****************************************************************************/
435 void CAmTelnetMenuHelper::rootGetCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
436 /****************************************************************************/
437 {
438     (void) CmdQueue;
439     std::map<int, EMainState>::iterator it;
440     it = mCurrentMainStateMap.find(filedescriptor);
441     if (it != mCurrentMainStateMap.end())
442     {
443         it->second = eGetState;
444     }
445 }
446
447 /****************************************************************************/
448 void CAmTelnetMenuHelper::rootSetCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
449 /****************************************************************************/
450 {
451     instance->rootSetCommandExec(CmdQueue, filedescriptor);
452 }
453
454 /****************************************************************************/
455 void CAmTelnetMenuHelper::rootSetCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
456 /****************************************************************************/
457 {
458     (void) CmdQueue;
459     std::map<int, EMainState>::iterator it;
460     it = mCurrentMainStateMap.find(filedescriptor);
461     if (it != mCurrentMainStateMap.end())
462     {
463         it->second = eSetState;
464     }
465 }
466
467 /****************************************************************************/
468 void CAmTelnetMenuHelper::rootListCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
469 /****************************************************************************/
470 {
471     instance->rootListCommandExec(CmdQueue, filedescriptor);
472 }
473
474 /****************************************************************************/
475 void CAmTelnetMenuHelper::rootListCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
476 /****************************************************************************/
477 {
478     (void) CmdQueue;
479     std::map<int, EMainState>::iterator it;
480     it = mCurrentMainStateMap.find(filedescriptor);
481     if (it != mCurrentMainStateMap.end())
482     {
483         it->second = eListState;
484     }
485 }
486
487 /****************************************************************************/
488 void CAmTelnetMenuHelper::rootInfoCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
489 /****************************************************************************/
490 {
491     instance->rootInfoCommandExec(CmdQueue, filedescriptor);
492 }
493
494 /****************************************************************************/
495 void CAmTelnetMenuHelper::rootInfoCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
496 /****************************************************************************/
497 {
498     (void) CmdQueue;
499     std::map<int, EMainState>::iterator it;
500     it = mCurrentMainStateMap.find(filedescriptor);
501     if (it != mCurrentMainStateMap.end())
502     {
503         it->second = eInfoState;
504     }
505 }
506
507 /****************************************************************************/
508 void CAmTelnetMenuHelper::listConnectionsCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
509 /****************************************************************************/
510 {
511     instance->listConnectionsCommandExec(CmdQueue, filedescriptor);
512 }
513
514 /****************************************************************************/
515 void CAmTelnetMenuHelper::listConnectionsCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
516 /****************************************************************************/
517 {
518     (void) CmdQueue;
519
520     std::vector<am_Connection_s> listConnections;
521     if(E_OK == mpDatabasehandler->getListConnections(listConnections))
522     {
523         std::stringstream output;
524         output << "\tConnections: " << listConnections.size() << std::endl;
525         for (std::vector<am_Connection_s>::iterator iter(listConnections.begin()); iter < listConnections.end(); iter++)
526         {
527             output << "\tID: " << iter->connectionID
528                    << "\tSrcID: " << iter->sourceID
529                    << "\tSinkID: " << iter->sinkID
530                    << "\tFormat: " << iter->connectionFormat
531                    << "\tdelay: " << iter->delay << std::endl;
532         }
533         sendTelnetLine(filedescriptor, output);
534     }
535     else
536     {
537         sendError(filedescriptor,"ERROR: mDatabasehandler->getListConnections");
538     }
539 }
540
541 /****************************************************************************/
542 void CAmTelnetMenuHelper::listSourcesCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
543 /****************************************************************************/
544 {
545     instance->listSourcesCommandExec(CmdQueue, filedescriptor);
546 }
547
548 /****************************************************************************/
549 void CAmTelnetMenuHelper::listSourcesCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
550 /****************************************************************************/
551 {
552     (void) CmdQueue;
553
554     std::vector<am_Source_s> listSources;
555     if(E_OK == mpDatabasehandler->getListSources(listSources))
556     {
557         std::stringstream output;
558         output << "\tSources: " << listSources.size() << std::endl;
559         for (std::vector<am_Source_s>::iterator iter(listSources.begin()); iter < listSources.end(); iter++)
560         {
561             output << "\tID: " << iter->sourceID
562                    << "\tName: " << iter->name
563                    << "\tDomainID: " << iter->domainID
564                    << "\tState: " << iter->sourceState
565                    << "\tVolume: " << iter->volume << std::endl;
566         }
567         sendTelnetLine(filedescriptor, output);
568     }
569     else
570     {
571         sendError(filedescriptor,"ERROR: mDatabasehandler->getListSources");
572     }
573 }
574
575 /****************************************************************************/
576 void CAmTelnetMenuHelper::listSinksCommands(std::queue<std::string> & CmdQueue, int & filedescriptor)
577 /****************************************************************************/
578 {
579     instance->listSinksCommandsExec(CmdQueue, filedescriptor);
580 }
581
582 /****************************************************************************/
583 void CAmTelnetMenuHelper::listSinksCommandsExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
584 /****************************************************************************/
585 {
586     (void) CmdQueue;
587
588     std::vector<am_Sink_s> listSinks;
589     if(E_OK == mpDatabasehandler->getListSinks(listSinks))
590     {
591         std::stringstream output;
592         output << "\tSinks: " << listSinks.size() << std::endl;
593         for (std::vector<am_Sink_s>::iterator iter(listSinks.begin()); iter < listSinks.end(); iter++)
594         {
595             output << "\tID: " << iter->sinkID
596                    << "\tDomainID: " << iter->domainID
597                    << "\tName: " << iter->name
598                    << "\tAvailable: " << iter->available.availability
599                    << "\tVolume: " << iter->volume << std::endl;
600         }
601
602         sendTelnetLine(filedescriptor, output);
603     }
604     else
605     {
606         sendError(filedescriptor,"ERROR: mDatabasehandler->getListSinks");
607     }
608 }
609
610 /****************************************************************************/
611 void CAmTelnetMenuHelper::listCrossfaders(std::queue<std::string> & CmdQueue, int & filedescriptor)
612 /****************************************************************************/
613 {
614     instance->listCrossfadersExec(CmdQueue, filedescriptor);
615 }
616
617 /****************************************************************************/
618 void CAmTelnetMenuHelper::listCrossfadersExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
619 /****************************************************************************/
620 {
621     (void) CmdQueue;
622
623     std::vector<am_Crossfader_s> listCrossfaders;
624     if(E_OK == mpDatabasehandler->getListCrossfaders(listCrossfaders))
625     {
626         std::stringstream output;
627         output << "\tCrossfaders: " << listCrossfaders.size() << std::endl;
628         for (std::vector<am_Crossfader_s>::iterator iter(listCrossfaders.begin()); iter < listCrossfaders.end(); iter++)
629         {
630             output << "\tID: " << iter->crossfaderID
631                    << "\tName: " << iter->name
632                    << "\tSourceID: " << iter->sourceID << std::endl;
633         }
634
635         sendTelnetLine(filedescriptor, output);
636     }
637     else
638     {
639         sendError(filedescriptor,"ERROR: mDatabasehandler->getListCrossfaders");
640     }
641 }
642
643 /****************************************************************************/
644 void CAmTelnetMenuHelper::listDomainsCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
645 /****************************************************************************/
646 {
647     instance->listDomainsCommandExec(CmdQueue, filedescriptor);
648 }
649
650 /****************************************************************************/
651 void CAmTelnetMenuHelper::listDomainsCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
652 /****************************************************************************/
653 {
654     (void) CmdQueue;
655
656     std::vector<am_Domain_s> listDomains;
657     if(E_OK == mpDatabasehandler->getListDomains(listDomains))
658     {
659         std::stringstream output;
660         output << "\tDomains: " << listDomains.size() << std::endl;
661         for (std::vector<am_Domain_s>::iterator iter(listDomains.begin()); iter < listDomains.end(); iter++)
662         {
663             output << "\tID: " << iter->domainID
664                    << "\tName: " << iter->name
665                    << "\tBusname: " << iter->busname
666                    << "\tNodename: " << iter->nodename
667                    << "\tState: " << static_cast<int>(iter->state) << std::endl;
668         }
669
670         sendTelnetLine(filedescriptor, output);
671     }
672     else
673     {
674         sendError(filedescriptor,"ERROR: mDatabasehandler->getListDomains");
675     }
676 }
677
678 /****************************************************************************/
679 void CAmTelnetMenuHelper::listGatewaysCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
680 /****************************************************************************/
681 {
682     instance->listGatewaysCommandExec(CmdQueue, filedescriptor);
683 }
684
685 /****************************************************************************/
686 void CAmTelnetMenuHelper::listGatewaysCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
687 /****************************************************************************/
688 {
689     (void) CmdQueue;
690
691     std::vector<am_Gateway_s> listGateways;
692     if(E_OK == mpDatabasehandler->getListGateways(listGateways))
693     {
694         std::stringstream output;
695         output << "\tGateways: " << listGateways.size();
696
697         for( std::vector<am_Gateway_s>::iterator iter(listGateways.begin()); iter < listGateways.end(); iter++)
698         {
699             output << "\tID: " << iter->gatewayID
700                    << "\tName: " << iter->name
701                    << "\tSourceID: " << iter->sourceID
702                    << "\tSinkID: " << iter->sinkID << std::endl;
703         }
704         sendTelnetLine(filedescriptor, output);
705     }
706     else
707     {
708         sendError(filedescriptor,"ERROR: mDatabasehandler->getListGateways");
709     }
710 }
711
712 /****************************************************************************/
713 void CAmTelnetMenuHelper::getRoutingCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
714 /****************************************************************************/
715 {
716     instance->getRoutingCommandExec(CmdQueue, filedescriptor);
717 }
718
719 /****************************************************************************/
720 void CAmTelnetMenuHelper::getRoutingCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
721 /****************************************************************************/
722 {
723     (void) CmdQueue;
724     (void) filedescriptor;
725     //TODO: fill with function
726 }
727
728 /****************************************************************************/
729 void CAmTelnetMenuHelper::getSenderversionCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
730 /****************************************************************************/
731 {
732     instance->getSenderversionCommandExec(CmdQueue, filedescriptor);
733 }
734
735 /****************************************************************************/
736 void CAmTelnetMenuHelper::getSenderversionCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
737 /****************************************************************************/
738 {
739     (void) CmdQueue;
740
741     std::stringstream output;
742     std::string versionCommand;
743     std::string versionRouting;
744     std::string versionControl;
745     mpControlSender->getInterfaceVersion(versionControl);
746     mpRoutingSender->getInterfaceVersion(versionRouting);
747     mpCommandSender->getInterfaceVersion(versionCommand);
748     output << "\tSender versions:" << std::endl << "\tCtrl: " << versionControl << " | " << "Cmd: " << versionCommand << " | " << "Routing: " << versionRouting << std::endl;
749
750     sendTelnetLine(filedescriptor, output);
751 }
752
753 /****************************************************************************/
754 void CAmTelnetMenuHelper::getReceiverversionCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
755 /****************************************************************************/
756 {
757     instance->getReceiverversionCommandExec(CmdQueue, filedescriptor);
758 }
759
760 /****************************************************************************/
761 void CAmTelnetMenuHelper::getReceiverversionCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
762 /****************************************************************************/
763 {
764     (void) CmdQueue;
765
766     std::stringstream output;
767     std::string versionCommand;
768     std::string versionRouting;
769     std::string versionControl;
770     mpControlReceiver->getInterfaceVersion(versionControl);
771     mpRoutingReceiver->getInterfaceVersion(versionRouting);
772     mpCommandReceiver->getInterfaceVersion(versionCommand);
773     output << "\tReceiver versions:" << std::endl << "\tCtrl: " << versionControl << " | " << "Cmd: " <<  versionCommand << " | " << "Routing: " << versionRouting << std::endl;
774
775     sendTelnetLine(filedescriptor, output);
776
777 }
778
779 /****************************************************************************/
780 void CAmTelnetMenuHelper::infoSystempropertiesCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
781 /****************************************************************************/
782 {
783     instance->infoSystempropertiesCommandExec(CmdQueue, filedescriptor);
784 }
785
786 /****************************************************************************/
787 void CAmTelnetMenuHelper::infoSystempropertiesCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
788 /****************************************************************************/
789 {
790     (void) CmdQueue;
791     std::vector<am_SystemProperty_s> listSystemProperties;
792
793     if(E_OK == mpDatabasehandler->getListSystemProperties(listSystemProperties))
794     {
795         std::stringstream output;
796         output << "\tSystemproperties: " << listSystemProperties.size() << std::endl;
797
798         std::vector<am_SystemProperty_s>::iterator it;
799         for (it = listSystemProperties.begin(); it < listSystemProperties.end(); it++)
800         {
801             output << "\tType: " << it->type << " Value: " << it->value << std::endl;
802         }
803
804         sendTelnetLine(filedescriptor, output);
805     }
806     else
807     {
808         sendError(filedescriptor,"ERROR: mDatabasehandler->getListSystemProperties");
809     }
810
811
812 }
813
814 /****************************************************************************/
815 void CAmTelnetMenuHelper::setRoutingCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
816 /****************************************************************************/
817 {
818     instance->setRoutingCommandExec(CmdQueue, filedescriptor);
819 }
820
821 /****************************************************************************/
822 void CAmTelnetMenuHelper::setRoutingCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
823 /****************************************************************************/
824 {
825     if (CmdQueue.size() >= 2)
826     {
827         bool error = false;
828
829         std::istringstream istream_sourceID(CmdQueue.front());
830         CmdQueue.pop();
831         std::istringstream istream_sinkID(CmdQueue.front());
832         CmdQueue.pop();
833
834         am_sourceID_t sourceID = 0;
835         if (!(istream_sourceID >> sourceID))
836             error = true;
837
838         am_sinkID_t sinkID = 0;
839         if (!(istream_sinkID >> sinkID))
840             error = true;
841
842         if (error)
843         {
844             sendError(filedescriptor, "Error parsing sourcID and sinkID");
845             return;
846         }
847
848         std::vector<am_Route_s> routingList;
849         if (E_OK == mpRouter->getRoute(true, sourceID, sinkID, routingList))
850         {
851             std::stringstream output;
852
853             std::vector<am_Route_s>::iterator rlIter = routingList.begin();
854             for (int rlCnt = 1; rlIter < routingList.end(); rlIter++)
855             {
856                 output << "#" << rlCnt << " ";
857
858                 std::vector<am_RoutingElement_s>::iterator reIter = rlIter->route.begin();
859                 for (; reIter < rlIter->route.end(); reIter++)
860                 {
861                     reIter->connectionFormat;
862                     reIter->domainID;
863                     output << ">(" << reIter->sourceID << ")->--[D:" << reIter->domainID << "][F:" << reIter->connectionFormat << "]-->-(" << reIter->sinkID << ")" << std::endl;
864                 }
865
866                 rlCnt++;
867             }
868
869             sendTelnetLine(filedescriptor, output);
870         }
871         else
872         {
873             sendError(filedescriptor, "Error getting route");
874         }
875
876     }
877     else
878     {
879         if(!CmdQueue.empty())
880            CmdQueue.pop();
881
882         sendError(filedescriptor,"Not enough arguments to set routing. Please enter sourceID and sinkID after command");
883     }
884
885 }
886
887 /****************************************************************************/
888 void CAmTelnetMenuHelper::setConnection(std::queue<std::string> & CmdQueue, int & filedescriptor)
889 /****************************************************************************/
890 {
891     instance->setConnectionExec(CmdQueue, filedescriptor);
892 }
893
894 /****************************************************************************/
895 void CAmTelnetMenuHelper::setConnectionExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
896 /****************************************************************************/
897 {
898     bool error = false;
899     am_Error_e rError = E_OK;
900
901     if (CmdQueue.size() >= 2)
902     {
903         std::istringstream istream_sourceID(CmdQueue.front());
904         CmdQueue.pop();
905
906         std::istringstream istream_sinkID(CmdQueue.front());
907         CmdQueue.pop();
908
909         am_sourceID_t sourceID = 0;
910         if (!(istream_sourceID >> sourceID))
911             error = true;
912
913         am_sinkID_t sinkID = 0;
914         if (!(istream_sinkID >> sinkID))
915             error = true;
916
917         if (error)
918         {
919             sendError(filedescriptor, "Error parsing sinkID and/or sourceID");
920             return;
921         }
922
923         // Try to set up connection
924         am_mainConnectionID_t connID = 0;
925         rError = mpCommandReceiver->connect(sourceID, sinkID, connID);
926
927         if (E_OK == rError)
928         {
929             std::stringstream output;
930             output << "ConnID: " << connID << "\tSrc: " << sourceID << " ---> Sink: " << sinkID << std::endl;
931             sendTelnetLine(filedescriptor, output);
932         }
933         else
934         {
935             sendError(filedescriptor, "Error connecting sourceID and sinkID");
936         }
937
938     }
939     else
940     {
941         // remove 1 element if list is not empty
942         if(!CmdQueue.empty())
943            CmdQueue.pop();
944
945         sendError(filedescriptor, "Not enough arguments to set routing. Please enter sourceID and sinkID after command");
946         return;
947     }
948 }
949
950 /****************************************************************************/
951 void CAmTelnetMenuHelper::setDisconnectConnId(std::queue<std::string> & CmdQueue, int & filedescriptor)
952 /****************************************************************************/
953 {
954     instance->setDisconnectConnIdExec(CmdQueue, filedescriptor);
955 }
956
957 /****************************************************************************/
958 void CAmTelnetMenuHelper::setDisconnectConnIdExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
959 /****************************************************************************/
960 {
961     am_mainConnectionID_t connID = 0;
962
963     bool error = false;
964     am_Error_e rError = E_OK;
965
966     if (CmdQueue.size() >= 1)
967     {
968         std::istringstream istream_connID(CmdQueue.front());
969         CmdQueue.pop();
970
971         if (!(istream_connID >> connID))
972             error = true;
973
974         if (error)
975         {
976             sendError(filedescriptor, "Error parsing connID");
977             return;
978         }
979
980         // Try to disconnect connection id
981         rError = mpCommandReceiver->disconnect(connID);
982
983         if (E_OK == rError)
984         {
985             std::stringstream output;
986             output << "ConnID " << connID << " closed successfully! " << std::endl;
987             sendTelnetLine(filedescriptor, output);
988         }
989         else
990         {
991             sendError(filedescriptor, "Error disconnecting connectionID");
992         }
993     }
994     else
995     {
996         sendError(filedescriptor, "Not enough arguments to disconnect a Main Connection, please enter 'connectionID' after command");
997         return;
998     }
999 }
1000
1001 /****************************************************************************/
1002 void CAmTelnetMenuHelper::setSourceSoundProperties(std::queue<std::string> & CmdQueue, int & filedescriptor)
1003 /****************************************************************************/
1004 {
1005     instance->setConnectionExec(CmdQueue, filedescriptor);
1006 }
1007
1008 /****************************************************************************/
1009 void CAmTelnetMenuHelper::setSourceSoundPropertiesExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
1010 /****************************************************************************/
1011 {
1012     if (CmdQueue.size() >= 3)
1013     {
1014         bool error = false;
1015
1016         std::istringstream istream_sourceID(CmdQueue.front());
1017         CmdQueue.pop();
1018
1019         std::istringstream istream_type(CmdQueue.front());
1020         CmdQueue.pop();
1021
1022         std::istringstream istream_value(CmdQueue.front());
1023         CmdQueue.pop();
1024
1025         unsigned int tmpType = 0;
1026         if (!(istream_type >> tmpType))
1027             error = true;
1028
1029         am_MainSoundProperty_s soundProperty;
1030         if (tmpType < MSP_MAX)
1031             soundProperty.type = static_cast<am_MainSoundPropertyType_e>(tmpType);
1032         else
1033             error = true;
1034
1035         if (!(istream_value >> soundProperty.value))
1036             error = true;
1037
1038         am_sinkID_t sourceID = 0;
1039         if (!(istream_sourceID >> sourceID))
1040             error = true;
1041
1042         if (error)
1043         {
1044             sendError(filedescriptor, "Error parsing MainSinkSoundProperty 'type', 'value' or 'sourceID'");
1045             return;
1046         }
1047
1048         if (E_OK == mpCommandReceiver->setMainSourceSoundProperty(soundProperty, sourceID))
1049         {
1050             std::stringstream output;
1051             output << "MainSourceSoundProperty set: " << soundProperty.type << "->" << soundProperty.value << std::endl;
1052             sendTelnetLine(filedescriptor, output);
1053         }
1054         else
1055         {
1056             sendError(filedescriptor, "Error setMainSourceSoundProperty");
1057         }
1058     }
1059     else
1060     {
1061         sendError(filedescriptor, "Not enough arguments to set MainSourceSoundProperty, please enter 'sourceID', 'type' and 'value' after command");
1062         return;
1063     }
1064 }
1065
1066 /****************************************************************************/
1067 void CAmTelnetMenuHelper::setSinkSoundProperties(std::queue<std::string> & CmdQueue, int & filedescriptor)
1068 /****************************************************************************/
1069 {
1070     instance->setConnectionExec(CmdQueue, filedescriptor);
1071 }
1072
1073 /****************************************************************************/
1074 void CAmTelnetMenuHelper::setSinkSoundPropertiesExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
1075 /****************************************************************************/
1076 {
1077     unsigned int tmpType = 0;
1078     bool error = false;
1079
1080     if (CmdQueue.size() >= 3)
1081     {
1082         std::istringstream istream_sinkID(CmdQueue.front());
1083         CmdQueue.pop();
1084
1085         std::istringstream istream_type(CmdQueue.front());
1086         CmdQueue.pop();
1087
1088         std::istringstream istream_value(CmdQueue.front());
1089         CmdQueue.pop();
1090
1091         if (!(istream_type >> tmpType))
1092             error = true;
1093
1094         am_MainSoundProperty_s soundProperty;
1095         if (tmpType < MSP_MAX)
1096             soundProperty.type = static_cast<am_MainSoundPropertyType_e>(tmpType);
1097         else
1098             error = true;
1099
1100         if (!(istream_value >> soundProperty.value))
1101             error = true;
1102
1103         am_sinkID_t sinkID = 0;
1104         if (!(istream_sinkID >> sinkID))
1105             error = true;
1106
1107         if (error)
1108         {
1109             sendError(filedescriptor, "Error parsing MainSinkSoundProperty 'type', 'value' or 'sinkID'");
1110             return;
1111         }
1112
1113         if (E_OK == mpCommandReceiver->setMainSinkSoundProperty(soundProperty, sinkID))
1114         {
1115             std::stringstream output;
1116             output << "MainSinkSoundProperty set: " << soundProperty.type << "->" << soundProperty.value << std::endl;
1117             sendTelnetLine(filedescriptor, output);
1118         }
1119         else
1120         {
1121             sendError(filedescriptor, "Error setMainSinkSoundProperty");
1122         }
1123     }
1124     else
1125     {
1126         sendError(filedescriptor, "Not enough arguments to set MainSinkSoundProperty, please enter 'sinkID', 'type' and 'value' after command");
1127         return;
1128     }
1129 }
1130
1131 /****************************************************************************/
1132 void CAmTelnetMenuHelper::listPluginsCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
1133 /****************************************************************************/
1134 {
1135     instance->listPluginsCommandExec(CmdQueue, filedescriptor);
1136 }
1137
1138 /****************************************************************************/
1139 void CAmTelnetMenuHelper::listPluginsCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
1140 /****************************************************************************/
1141 {
1142     (void) CmdQueue;
1143     std::vector<std::string> PlugInNames;
1144     std::vector<std::string>::iterator iter;
1145     std::stringstream output;
1146
1147
1148     if(E_OK == mpCommandSender->getListPlugins(PlugInNames))
1149     {
1150         output << "\tCommandSender Plugins loaded: " << PlugInNames.size() << std::endl;
1151
1152         for (iter = PlugInNames.begin(); iter < PlugInNames.end(); iter++)
1153         {
1154             output << iter->c_str() << std::endl;
1155         }
1156     }
1157     else
1158     {
1159         sendError(filedescriptor,"ERROR: mCommandSender->getListPlugins");
1160     }
1161
1162
1163     if(E_OK == mpRoutingSender->getListPlugins(PlugInNames))
1164     {
1165         output << std::endl << "\tRoutingSender Plugins loaded: " << PlugInNames.size() << std::endl;
1166
1167         for (iter = PlugInNames.begin(); iter < PlugInNames.end(); iter++)
1168         {
1169             output << iter->c_str() << std::endl;
1170         }
1171     }
1172     else
1173     {
1174         sendError(filedescriptor,"ERROR: mRoutingSender->getListPlugins");
1175     }
1176
1177     sendTelnetLine(filedescriptor, output);
1178 }
1179
1180
1181 /****************************************************************************/
1182 void CAmTelnetMenuHelper::listMainSourcesCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
1183 /****************************************************************************/
1184 {
1185     instance->listMainSourcesCommandExec(CmdQueue,filedescriptor);
1186 }
1187
1188 /****************************************************************************/
1189 void CAmTelnetMenuHelper::listMainSourcesCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
1190 /****************************************************************************/
1191 {
1192     (void) CmdQueue;
1193     std::vector<am_SourceType_s> listMainSources;
1194
1195     if(E_OK == mpDatabasehandler->getListMainSources(listMainSources))
1196     {
1197         std::stringstream output;
1198         output << std::endl << "\tMainSources:  " << listMainSources.size() << std::endl;
1199
1200         std::vector<am_SourceType_s>::iterator iter;
1201         for (iter = listMainSources.begin(); iter < listMainSources.end(); iter++)
1202         {
1203             output << "\t" << iter->name << "\tID: " << iter->sourceID
1204                            << "\tClassID: " << iter->sourceClassID
1205                            << "\tavailability: " << static_cast<int>(iter->availability.availability)
1206                            << "\tavailabilityReason: " << static_cast<int>(iter->availability.availabilityReason) << std::endl;
1207         }
1208         sendTelnetLine(filedescriptor,output);
1209     }
1210     else
1211     {
1212         sendError(filedescriptor,"ERROR: mDatabasehandler->getListMainSources");
1213     }
1214 }
1215
1216 /****************************************************************************/
1217 void CAmTelnetMenuHelper::listMainSinksCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
1218 /****************************************************************************/
1219 {
1220     instance->listMainSinksCommandExec(CmdQueue,filedescriptor);
1221 }
1222
1223 /****************************************************************************/
1224 void CAmTelnetMenuHelper::listMainSinksCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
1225 /****************************************************************************/
1226 {
1227     (void) CmdQueue;
1228     std::vector<am_SinkType_s> listMainSinks;
1229
1230     if(E_OK == mpDatabasehandler->getListMainSinks(listMainSinks))
1231     {
1232         std::stringstream output;
1233         output << std::endl << "\tMainSinks: " << listMainSinks.size() << std::endl;
1234
1235         std::vector<am_SinkType_s>::iterator iter;
1236         for (   iter = listMainSinks.begin(); iter < listMainSinks.end(); iter++)
1237         {
1238             output << "\t" << iter->name << "\tID: " << iter->sinkID
1239                            << "\tClassID: " << iter->sinkClassID
1240                            << "\tavailability: " << static_cast<int>(iter->availability.availability)
1241                            << "\tavailabilityReason: " << static_cast<int>(iter->availability.availabilityReason)
1242                            << "\tMuteState: " << iter->muteState
1243                            << "\tVolume: " << iter->volume << std::endl;
1244         }
1245         sendTelnetLine(filedescriptor,output);
1246     }
1247     else
1248     {
1249         sendError(filedescriptor,"ERROR: mDatabasehandler->getListMainSinks");
1250     }
1251 }
1252
1253 /****************************************************************************/
1254 void CAmTelnetMenuHelper::listMainConnectionsCommand(std::queue<std::string> & CmdQueue, int & filedescriptor)
1255 /****************************************************************************/
1256 {
1257     instance->listMainConnectionsCommandExec(CmdQueue,filedescriptor);
1258 }
1259
1260 /****************************************************************************/
1261 void CAmTelnetMenuHelper::listMainConnectionsCommandExec(std::queue<std::string> & CmdQueue, int & filedescriptor)
1262 /****************************************************************************/
1263 {
1264     (void) CmdQueue;
1265     std::vector<am_MainConnection_s> listMainConnections;
1266
1267     if(E_OK == mpDatabasehandler->getListMainConnections(listMainConnections))
1268     {
1269         std::stringstream output;
1270         output << std::endl << "\tMainConnections: " << listMainConnections.size() << std::endl;
1271
1272         std::vector<am_MainConnection_s>::iterator iter;
1273         for (iter = listMainConnections.begin(); iter < listMainConnections.end(); iter++)
1274         {
1275             output << "\tID: " << iter->mainConnectionID
1276                    << "\tState: " << iter->connectionState
1277                    << "\tDelay: " << iter->delay
1278                    << "\tsourceID: " << iter->sourceID
1279                    << "\tsinkID: " << iter->sinkID << std::endl;
1280
1281             output << "ConnectionIDs: ";
1282             std::vector<am_connectionID_t>::iterator list_connIDs_iter = iter->listConnectionID.begin();
1283             for(;list_connIDs_iter < iter->listConnectionID.end();list_connIDs_iter++)
1284             {
1285                 output << *list_connIDs_iter << " ";
1286             }
1287
1288             output << std::endl;
1289         }
1290         sendTelnetLine(filedescriptor,output);
1291     }
1292     else
1293     {
1294         sendError(filedescriptor,"ERROR: mDatabasehandler->getListMainSinks");
1295     }
1296 }
1297 }
1298
1299
1300
1301
1302