Generic sorting of commands in linphone-daemon (so that commands dump function are also sorted).

This commit is contained in:
Ghislain MARY 2016-11-29 10:29:02 +01:00
parent dc597140e1
commit 22ac40902b
2 changed files with 6 additions and 7 deletions

View file

@ -25,10 +25,6 @@ HelpCommand::HelpCommand() :
DaemonCommand("help", "help <command>", "Show <command> help notice, if command is unspecified or inexistent show all commands.") {
}
static bool compareCommand(const DaemonCommand *command1, const DaemonCommand *command2) {
return (command1->getProto() < command2->getProto());
}
void HelpCommand::exec(Daemon *app, const char *args) {
ostringstream ost;
list<DaemonCommand*>::const_iterator it;
@ -44,9 +40,7 @@ void HelpCommand::exec(Daemon *app, const char *args) {
}
if (args==NULL){
list<DaemonCommand*> lcopy = l;
lcopy.sort(compareCommand);
for (it = lcopy.begin(); it != lcopy.end(); ++it) {
for (it = l.begin(); it != l.end(); ++it) {
ost << (*it)->getProto() << endl;
}
}

View file

@ -457,6 +457,10 @@ void Daemon::removeAudioStream(int id) {
}
}
static bool compareCommands(const DaemonCommand *command1, const DaemonCommand *command2) {
return (command1->getProto() < command2->getProto());
}
void Daemon::initCommands() {
mCommands.push_back(new RegisterCommand());
mCommands.push_back(new ContactCommand());
@ -503,6 +507,7 @@ void Daemon::initCommands() {
mCommands.push_back(new ConfigSetCommand());
mCommands.push_back(new NetsimCommand());
mCommands.push_back(new CNCommand());
mCommands.sort(compareCommands);
}
void Daemon::uninitCommands() {