Add the version command.

This commit is contained in:
Ghislain MARY 2012-10-25 14:33:08 +02:00
parent dc00f66f82
commit 0ab22a41ae
4 changed files with 39 additions and 1 deletions

View file

@ -28,6 +28,7 @@ linphone_daemon_SOURCES=daemon.cc \
commands/terminate.cc \
commands/unregister.cc \
commands/quit.cc \
commands/version.cc \
daemon.h \
commands/adaptive-jitter-compensation.h \
commands/answer.h \
@ -53,7 +54,8 @@ linphone_daemon_SOURCES=daemon.cc \
commands/register-status.h \
commands/terminate.h \
commands/unregister.h \
commands/quit.h
commands/quit.h \
commands/version.h
linphone_daemon_pipetest_SOURCES=daemon-pipetest.c

View file

@ -0,0 +1,22 @@
#include "version.h"
using namespace std;
class VersionResponse : public Response {
public:
VersionResponse(LinphoneCore *core);
};
VersionResponse::VersionResponse(LinphoneCore *core) : Response() {
ostringstream ost;
ost << "Version: " << linphone_core_get_version();
setBody(ost.str().c_str());
}
VersionCommand::VersionCommand() :
DaemonCommand("version", "version", "Get the version number.") {
}
void VersionCommand::exec(Daemon *app, const char *args) {
app->sendResponse(VersionResponse(app->getCore()));
}

12
daemon/commands/version.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef COMMAND_VERSION_H_
#define COMMAND_VERSION_H_
#include "../daemon.h"
class VersionCommand: public DaemonCommand {
public:
VersionCommand();
virtual void exec(Daemon *app, const char *args);
};
#endif //COMMAND_VERSION_H_

View file

@ -35,6 +35,7 @@
#include "commands/terminate.h"
#include "commands/unregister.h"
#include "commands/quit.h"
#include "commands/version.h"
using namespace std;
@ -350,6 +351,7 @@ void Daemon::initCommands() {
mCommands.push_back(new MediaEncryptionCommand());
mCommands.push_back(new PortCommand());
mCommands.push_back(new AdaptiveBufferCompensationCommand());
mCommands.push_back(new VersionCommand());
mCommands.push_back(new QuitCommand());
mCommands.push_back(new HelpCommand());