From 0ab22a41ae0c64bd689b188f1a0a9e1e7bca5364 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 25 Oct 2012 14:33:08 +0200 Subject: [PATCH] Add the version command. --- daemon/Makefile.am | 4 +++- daemon/commands/version.cc | 22 ++++++++++++++++++++++ daemon/commands/version.h | 12 ++++++++++++ daemon/daemon.cc | 2 ++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 daemon/commands/version.cc create mode 100644 daemon/commands/version.h diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 942fb1ea8..8c9397246 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -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 diff --git a/daemon/commands/version.cc b/daemon/commands/version.cc new file mode 100644 index 000000000..c274b8f44 --- /dev/null +++ b/daemon/commands/version.cc @@ -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())); +} diff --git a/daemon/commands/version.h b/daemon/commands/version.h new file mode 100644 index 000000000..492147448 --- /dev/null +++ b/daemon/commands/version.h @@ -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_ diff --git a/daemon/daemon.cc b/daemon/daemon.cc index c043d1e92..d68af6e2c 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -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());