From 5c66f193d529eb5f01013071d74e8191ce3dfca3 Mon Sep 17 00:00:00 2001 From: nicolas Date: Wed, 16 Aug 2017 16:27:22 +0200 Subject: [PATCH] feat(Cli): 2 method to join conference: with if there is not a sip address linked to the database, with if there is one --- assets/languages/en.ts | 4 ++++ assets/languages/fr.ts | 4 ++++ src/app/cli/Cli.cpp | 36 +++++++++++++++++++++++++----------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/assets/languages/en.ts b/assets/languages/en.ts index 611dd1558..247d44e24 100644 --- a/assets/languages/en.ts +++ b/assets/languages/en.ts @@ -429,6 +429,10 @@ Server url not configured. initiateConferenceFunctionDescription + + joinConferenceAsFunctionDescription + + CodecsViewer diff --git a/assets/languages/fr.ts b/assets/languages/fr.ts index aecb03bf3..7d858f22b 100644 --- a/assets/languages/fr.ts +++ b/assets/languages/fr.ts @@ -429,6 +429,10 @@ Url du serveur non configurée. initiateConferenceFunctionDescription + + joinConferenceAsFunctionDescription + + CodecsViewer diff --git a/src/app/cli/Cli.cpp b/src/app/cli/Cli.cpp index 6bc21eec8..c9ead512f 100644 --- a/src/app/cli/Cli.cpp +++ b/src/app/cli/Cli.cpp @@ -43,20 +43,31 @@ static void cliCall (QHash &args) { static void cliJoinConference (QHash &args) { const QString sipAddress = args.take("sip-address"); - if (!args["default-display-name"].isEmpty()) { - const shared_ptr core = CoreManager::getInstance()->getCore(); - const shared_ptr defaultProxyConfig = core->getDefaultProxyConfig(); - shared_ptr address; - if (!defaultProxyConfig) { - address = core->getPrimaryContactParsed(); - address->setDisplayName(::Utils::appStringToCoreString(args.take("default-display-name"))); - core->setPrimaryContact(address->asString()); - } - } + const shared_ptr core = CoreManager::getInstance()->getCore(); + shared_ptr address; + address = core->getPrimaryContactParsed(); + address->setDisplayName(::Utils::appStringToCoreString(args.take("display-name"))); + core->setPrimaryContact(address->asString()); args["method"] = QStringLiteral("join-conference"); CoreManager::getInstance()->getCallsListModel()->launchAudioCall(sipAddress, args); } + +static void cliJoinConferenceAs (QHash &args) { + const QString toSipAddress = args.take("sip-address"); + const QString fromSipAddress = args.take("guest-sip-address"); + shared_ptr core = CoreManager::getInstance()->getCore(); + shared_ptr currentSipAddress = core->getDefaultProxyConfig()->getIdentityAddress()->clone(); + currentSipAddress->clean(); + if (fromSipAddress!=::Utils::coreStringToAppString(currentSipAddress->asStringUriOnly())) { + qWarning() << QStringLiteral("guest sip address `%1` is not one of yours.") + .arg(fromSipAddress); + return; + } + args["method"] = QStringLiteral("join-conference"); + CoreManager::getInstance()->getCallsListModel()->launchAudioCall(toSipAddress, args); +} + static void cliInitiateConference (QHash &args) { shared_ptr core = CoreManager::getInstance()->getCore(); @@ -182,7 +193,10 @@ Cli::Cli (QObject *parent) : QObject(parent) { { "sip-address", {} }, { "conference-id", {} } }); addCommand("join-conference", tr("joinConferenceFunctionDescription"), ::cliJoinConference, { - { "sip-address", {} }, { "conference-id", {} }, { "default-display-name", {STRING, true} } + { "sip-address", {} }, { "conference-id", {} }, { "display-name", {} } + }); + addCommand("join-conference-as", tr("joinConferenceAsFunctionDescription"), ::cliJoinConferenceAs, { + { "sip-address", {} }, { "conference-id", {} }, { "guest-sip-address", {} } }); }