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