From 9e8b1d5dd93ce152e54a5e34bbd29e0ac87ecdd8 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Wed, 29 May 2024 14:33:40 +0200 Subject: [PATCH] merge calls --- Linphone/core/call/CallList.cpp | 43 ++++++++++++++++++++++++++++ Linphone/core/call/CallList.hpp | 1 + Linphone/core/call/CallProxy.cpp | 1 + Linphone/core/call/CallProxy.hpp | 1 + Linphone/view/App/CallsWindow.qml | 39 +++++++++++++++++++++++-- Linphone/view/Page/Main/CallPage.qml | 2 +- Linphone/view/Style/AppIcons.qml | 1 + 7 files changed, 84 insertions(+), 4 deletions(-) diff --git a/Linphone/core/call/CallList.cpp b/Linphone/core/call/CallList.cpp index c63225588..e6729d57c 100644 --- a/Linphone/core/call/CallList.cpp +++ b/Linphone/core/call/CallList.cpp @@ -78,6 +78,49 @@ void CallList::setSelf(QSharedPointer me) { }); }); }); + mModelConnection->makeConnectToCore(&CallList::lMergeAll, [this]() { + mModelConnection->invokeToModel([this]() { + auto core = CoreModel::getInstance()->getCore(); + auto currentCalls = CoreModel::getInstance()->getCore()->getCalls(); + std::shared_ptr conference = nullptr; + + // Search a managable conference from calls + for (auto call : currentCalls) { + auto dbConference = call->getConference(); + if (dbConference && dbConference->getMe()->isAdmin()) { + conference = dbConference; + break; + } + } + + auto currentCall = CoreModel::getInstance()->getCore()->getCurrentCall(); + bool enablingVideo = false; + if (currentCall) enablingVideo = currentCall->getCurrentParams()->videoEnabled(); + if (!conference) { + auto parameters = core->createConferenceParams(conference); + parameters->enableVideo(enablingVideo); + parameters->setSubject("Meeting"); + conference = core->createConferenceWithParams(parameters); + } + + std::list> allLinphoneAddresses; + std::list> newCalls; + std::list> runningCallsToAdd; + + for (auto call : currentCalls) { + if (!call->getConference()) { + runningCallsToAdd.push_back(call); + } + } + + // 1) Add running calls + if (runningCallsToAdd.size() > 0) { + conference->addParticipants(runningCallsToAdd); + } + + // emit lUpdate(); + }); + }); mModelConnection->makeConnectToModel(&CoreModel::firstCallStarted, [this]() { mModelConnection->invokeToCore([this]() { setHaveCall(true); }); }); diff --git a/Linphone/core/call/CallList.hpp b/Linphone/core/call/CallList.hpp index 1589c77d1..9b8d69506 100644 --- a/Linphone/core/call/CallList.hpp +++ b/Linphone/core/call/CallList.hpp @@ -56,6 +56,7 @@ public: virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; signals: void lUpdate(); + void lMergeAll(); void haveCallChanged(); void currentCallChanged(); diff --git a/Linphone/core/call/CallProxy.cpp b/Linphone/core/call/CallProxy.cpp index 81b66ba2a..711004cc6 100644 --- a/Linphone/core/call/CallProxy.cpp +++ b/Linphone/core/call/CallProxy.cpp @@ -28,6 +28,7 @@ CallProxy::CallProxy(QObject *parent) : SortFilterProxy(parent) { mList = CallList::create(); connect(mList.get(), &CallList::currentCallChanged, this, &CallProxy::resetCurrentCall); connect(mList.get(), &CallList::haveCallChanged, this, &CallProxy::haveCallChanged); + connect(this, &CallProxy::lMergeAll, mList.get(), &CallList::lMergeAll); setSourceModel(mList.get()); sort(0); } diff --git a/Linphone/core/call/CallProxy.hpp b/Linphone/core/call/CallProxy.hpp index 7bd30262d..119551e7d 100644 --- a/Linphone/core/call/CallProxy.hpp +++ b/Linphone/core/call/CallProxy.hpp @@ -51,6 +51,7 @@ public: bool getHaveCall() const; signals: + void lMergeAll(); void filterTextChanged(); void currentCallChanged(); void haveCallChanged(); diff --git a/Linphone/view/App/CallsWindow.qml b/Linphone/view/App/CallsWindow.qml index 4540cb8a9..55a26a5bc 100644 --- a/Linphone/view/App/CallsWindow.qml +++ b/Linphone/view/App/CallsWindow.qml @@ -556,8 +556,38 @@ AppWindow { Component { id: callsListPanel ColumnLayout { - Control.StackView.onActivated: rightPanel.headerTitleText = qsTr("Liste d'appel") + Control.StackView.onActivated: { + rightPanel.headerTitleText = qsTr("Liste d'appel") + rightPanel.customHeaderButtons = mergeCallPopupButton.createObject(rightPanel) + } spacing: 0 + Component { + id: mergeCallPopupButton + PopupButton { + visible: callsModel.count >= 2 + id: popupbutton + popup.contentItem: Button { + background: Item{} + contentItem: RowLayout { + spacing: 5 * DefaultStyle.dp + EffectImage { + colorizationColor: DefaultStyle.main2_600 + imageSource: AppIcons.arrowsMerge + Layout.preferredWidth: 32 * DefaultStyle.dp + Layout.preferredHeight: 32 * DefaultStyle.dp + } + Text { + text: qsTr("Merger tous les appels") + font.pixelSize: 14 * DefaultStyle.dp + } + } + onClicked: { + callsModel.lMergeAll() + popupbutton.close() + } + } + } + } RoundedBackgroundControl { Layout.fillWidth: true Layout.maximumHeight: rightPanel.height @@ -598,7 +628,9 @@ AppWindow { Text { id: delegateName property var remoteAddress: UtilsCpp.getDisplayName(modelData.core.peerAddress) - text: remoteAddress ? remoteAddress.value : "" + text: modelData.core.isConference + ? modelData.core.conference.core.subject + : remoteAddress ? remoteAddress.value : "" Layout.leftMargin: 8 * DefaultStyle.dp Connections { target: modelData.core @@ -758,10 +790,11 @@ AppWindow { } Control.StackView.onActivated: { rightPanel.customHeaderButtons = headerbutton.createObject(rightPanel) + rightPanel.headerTitleText = qsTr("Participants (%1)").arg(count) } call: mainWindow.call onAddParticipantRequested: participantsStack.push(addParticipantComp) - onCountChanged: if (participantsStack.Control.StackView.status === Control.StackView.Active && participantsStack.currentItem == participantListComp) { + onCountChanged: { rightPanel.headerTitleText = qsTr("Participants (%1)").arg(count) } Connections { diff --git a/Linphone/view/Page/Main/CallPage.qml b/Linphone/view/Page/Main/CallPage.qml index 8c42c06d0..d35028677 100644 --- a/Linphone/view/Page/Main/CallPage.qml +++ b/Linphone/view/Page/Main/CallPage.qml @@ -488,7 +488,7 @@ AbstractMainPage { onStartGroupCallRequested: { if (groupName.length === 0) { UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("Un nom doit être donné à l'appel de groupe"), false) - } if(!mainItem.isRegistered) { + } else if(!mainItem.isRegistered) { UtilsCpp.showInformationPopup(qsTr("Erreur"), qsTr("Vous n'etes pas connecté"), false) } else { mainItem.confInfoGui = Qt.createQmlObject('import Linphone diff --git a/Linphone/view/Style/AppIcons.qml b/Linphone/view/Style/AppIcons.qml index 35deb2bd7..059c241c5 100644 --- a/Linphone/view/Style/AppIcons.qml +++ b/Linphone/view/Style/AppIcons.qml @@ -14,6 +14,7 @@ QtObject { property string rightArrow: "image://internal/caret-right.svg" property string upArrow: "image://internal/caret-up.svg" property string reloadArrow: "image://internal/arrow-clockwise.svg" + property string arrowsMerge: "image://internal/arrows-merge.svg" property string info: "image://internal/info.svg" property string loginImage: "image://internal/login_image.svg" property string belledonne: "image://internal/belledonne.svg"