Add Bye URI

This commit is contained in:
Julien Wadel 2021-01-13 17:18:02 +01:00
parent dcdfbea1e0
commit 8bedf19521
4 changed files with 34 additions and 2 deletions

View file

@ -477,6 +477,10 @@ Server URL not configured.</translation>
<source>callFunctionDescription</source>
<translation>Initiate a call to the sip-address.</translation>
</message>
<message>
<source>byeFunctionDescription</source>
<translation>End a specific call, all calls or current call.</translation>
</message>
<message>
<source>initiateConferenceFunctionDescription</source>
<translation>Initiate a conference.</translation>

View file

@ -61,6 +61,17 @@ static void cliCall (QHash<QString, QString> &args) {
CoreManager::getInstance()->getCallsListModel()->launchAudioCall(args["sip-address"]);
}
static void cliBye (QHash<QString, QString> &args) {
if(args.size() > 0) {
if( args["sip-address"] == "*")// Call with options
CoreManager::getInstance()->getCallsListModel()->terminateAllCalls();
else
CoreManager::getInstance()->getCallsListModel()->terminateCall(args["sip-address"]);
}else if( CoreManager::getInstance()->getCore()->getCurrentCall()){
CoreManager::getInstance()->getCore()->getCurrentCall()->terminate();
}
}
static void cliJoinConference (QHash<QString, QString> &args) {
const QString sipAddress = args.take("sip-address");
@ -399,7 +410,8 @@ QMap<QString, Cli::Command> Cli::mCommands = {
}),
createCommand("join-conference-as", QT_TR_NOOP("joinConferenceAsFunctionDescription"), cliJoinConferenceAs, {
{ "sip-address", {} }, { "conference-id", {} }, { "guest-sip-address", {} }
})
}),
createCommand("bye", QT_TR_NOOP("byeFunctionDescription"), cliBye, QHash<QString, Argument>(), true),
};
// -----------------------------------------------------------------------------

View file

@ -160,7 +160,22 @@ int CallsListModel::getRunningCallsNumber () const {
void CallsListModel::terminateAllCalls () const {
CoreManager::getInstance()->getCore()->terminateAllCalls();
}
void CallsListModel::terminateCall (const QString& sipAddress) const{
auto coreManager = CoreManager::getInstance();
shared_ptr<linphone::Address> address = coreManager->getCore()->interpretUrl(Utils::appStringToCoreString(sipAddress));
if (!address)
qWarning() << "Cannot terminate Call. The address cannot be parsed : " << sipAddress;
else{
std::shared_ptr<linphone::Call> call = coreManager->getCore()->getCallByRemoteAddress2(address);
if( call){
coreManager->lockVideoRender();
call->terminate();
coreManager->unlockVideoRender();
}else{
qWarning() << "Cannot terminate call as it doesn't exist : " << sipAddress;
}
}
}
// -----------------------------------------------------------------------------
static void joinConference (const shared_ptr<linphone::Call> &call) {

View file

@ -48,6 +48,7 @@ public:
Q_INVOKABLE int getRunningCallsNumber () const;
Q_INVOKABLE void terminateAllCalls () const;
Q_INVOKABLE void terminateCall (const QString& sipAddress) const;
signals:
void callRunning (int index, CallModel *callModel);