linphone-ios/daemon/commands/dtmf.cc
Ghislain MARY fec1c8ca74 Improve help.
- Add examples for each command
 - Add the --dump-commands-help option to output the entire help
2012-10-26 17:18:30 +02:00

32 lines
1 KiB
C++

#include "dtmf.h"
using namespace std;
DtmfCommand::DtmfCommand() :
DaemonCommand("dtmf", "dtmf <digit>", "Generate a DTMF (one of: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, *, #.") {
addExample(new DaemonCommandExample("dtmf 4",
"Status: Ok"));
addExample(new DaemonCommandExample("dtmf B",
"Status: Ok"));
addExample(new DaemonCommandExample("dtmf #",
"Status: Ok"));
}
void DtmfCommand::exec(Daemon *app, const char *args) {
string digit_str;
char digit;
istringstream ist(args);
ist >> digit_str;
if (ist.fail()) {
app->sendResponse(Response("Missing digit parameter.", Response::Error));
} else {
digit = digit_str.at(0);
if (isdigit(digit) || (digit == 'A') || (digit == 'B') || (digit == 'C') || (digit == 'D') || (digit == '*') || (digit == '#')) {
linphone_core_play_dtmf(app->getCore(), digit, 100);
linphone_core_send_dtmf(app->getCore(), digit);
app->sendResponse(Response());
} else {
app->sendResponse(Response("Incorrect digit parameter.", Response::Error));
}
}
}