add --auto-answer CLI option

This patch:
- add --auto-answer CLI argument option
- bind it to a new Manager atomic bool
- force a answerCall to be called if an incoming call is created and
if the autoAnswer bool is true

Note: this option is not intended to be use with a client.
Use at your own risk.

Change-Id: I7c3edbbaea5462b2dfda9ec68dd9e41667f00aca
Tuleap: #425
This commit is contained in:
Guillaume Roguez
2016-02-25 16:30:54 -05:00
parent 4d295519b6
commit 5b8940562a
7 changed files with 55 additions and 21 deletions

View File

@ -57,6 +57,7 @@ print_usage()
"-c, --console \t- Log in console (instead of syslog)" << std::endl <<
"-d, --debug \t- Debug mode (more verbose)" << std::endl <<
"-p, --persistent \t- Stay alive after client quits" << std::endl <<
"--auto-answer \t- Force automatic answer to incoming calls" << std::endl <<
"-h, --help \t- Print help" << std::endl;
}
@ -66,21 +67,23 @@ print_usage()
static bool
parse_args(int argc, char *argv[], bool& persistent)
{
static const struct option long_options[] = {
int consoleFlag = false;
int debugFlag = false;
int helpFlag = false;
int versionFlag = false;
int autoAnswer = false;
const struct option long_options[] = {
/* These options set a flag. */
{"debug", no_argument, NULL, 'd'},
{"console", no_argument, NULL, 'c'},
{"persistent", no_argument, NULL, 'p'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{"auto-answer", no_argument, &autoAnswer, true},
{0, 0, 0, 0} /* Sentinel */
};
int consoleFlag = false;
int debugFlag = false;
int helpFlag = false;
int versionFlag = false;
while (true) {
/* getopt_long stores the option index here. */
int option_index = 0;
@ -134,6 +137,9 @@ parse_args(int argc, char *argv[], bool& persistent)
if (debugFlag)
ringFlags |= DRing::DRING_FLAG_DEBUG;
if (autoAnswer)
ringFlags |= DRing::DRING_FLAG_AUTOANSWER;
return false;
}