mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
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:
18
bin/main.cpp
18
bin/main.cpp
@ -52,6 +52,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;
|
||||
}
|
||||
|
||||
@ -61,21 +62,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;
|
||||
@ -129,6 +132,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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,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;
|
||||
}
|
||||
|
||||
@ -71,21 +72,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;
|
||||
@ -139,6 +142,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;
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,9 @@ namespace DRing {
|
||||
|
||||
/* flags for initialization */
|
||||
enum InitFlag {
|
||||
DRING_FLAG_DEBUG=1,
|
||||
DRING_FLAG_CONSOLE_LOG=2,
|
||||
DRING_FLAG_DEBUG = 1<<0,
|
||||
DRING_FLAG_CONSOLE_LOG = 1<<1,
|
||||
DRING_FLAG_AUTOANSWER = 1<<2,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -195,6 +195,12 @@ Manager::instance()
|
||||
return instance_;
|
||||
}
|
||||
|
||||
void
|
||||
Manager::setAutoAnswer(bool enable)
|
||||
{
|
||||
autoAnswer_ = enable;
|
||||
}
|
||||
|
||||
void
|
||||
Manager::loadDefaultAccountMap()
|
||||
{
|
||||
@ -1603,6 +1609,9 @@ Manager::incomingCall(Call &call, const std::string& accountId)
|
||||
std::string from("<" + number + ">");
|
||||
|
||||
emitSignal<DRing::CallSignal::IncomingCall>(accountId, callID, call.getPeerDisplayName() + " " + from);
|
||||
|
||||
if (autoAnswer_)
|
||||
runOnMainThread([this, callID]{ answerCall(callID); });
|
||||
}
|
||||
|
||||
//THREAD=VoIP
|
||||
|
@ -91,6 +91,8 @@ class Manager {
|
||||
|
||||
static Manager& instance();
|
||||
|
||||
void setAutoAnswer(bool enable);
|
||||
|
||||
/**
|
||||
* General preferences configuration
|
||||
*/
|
||||
@ -760,6 +762,8 @@ class Manager {
|
||||
std::vector<std::string> loadAccountOrder() const;
|
||||
|
||||
private:
|
||||
std::atomic_bool autoAnswer_ {false};
|
||||
|
||||
void removeAccounts();
|
||||
|
||||
bool parseConfiguration();
|
||||
|
@ -54,7 +54,9 @@ init(enum InitFlag flags) noexcept
|
||||
|
||||
try {
|
||||
// current implementation use static variable
|
||||
return &ring::Manager::instance() != nullptr;
|
||||
auto& manager = ring::Manager::instance();
|
||||
manager.setAutoAnswer(flags & DRING_FLAG_AUTOANSWER);
|
||||
return true;
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user