From e6fe32cfee95bcf476bc5c9d77443265ea89a7bb Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Tue, 4 Feb 2025 13:39:21 +0100 Subject: [PATCH] clean participant device name with new sdk api use utils fonction to set me display name in call grid --- Linphone/core/account/AccountProxy.cpp | 6 -- Linphone/core/account/AccountProxy.hpp | 1 - Linphone/core/conference/ConferenceCore.cpp | 59 +++---------------- Linphone/core/conference/ConferenceCore.hpp | 5 -- .../participant/ParticipantDeviceCore.cpp | 4 +- Linphone/tool/Utils.cpp | 24 -------- Linphone/tool/Utils.hpp | 1 - .../Container/Call/ActiveSpeakerLayout.qml | 3 - .../Control/Container/Call/CallGridLayout.qml | 5 +- Linphone/view/Control/Display/Sticker.qml | 5 +- 10 files changed, 15 insertions(+), 98 deletions(-) diff --git a/Linphone/core/account/AccountProxy.cpp b/Linphone/core/account/AccountProxy.cpp index 5cd9de3bb..4b363e191 100644 --- a/Linphone/core/account/AccountProxy.cpp +++ b/Linphone/core/account/AccountProxy.cpp @@ -45,12 +45,6 @@ void AccountProxy::resetDefaultAccount() { emit this->defaultAccountChanged(); // Warn the UI } -AccountGui *AccountProxy::findAccountByAddress(const QString &address) { - auto model = getListModel(); - if (model) return new AccountGui(model->findAccountByAddress(address)); - else return nullptr; -} - AccountGui *AccountProxy::firstAccount() { auto model = getListModel(); if (model) return model->firstAccount(); diff --git a/Linphone/core/account/AccountProxy.hpp b/Linphone/core/account/AccountProxy.hpp index 078453470..69e39db02 100644 --- a/Linphone/core/account/AccountProxy.hpp +++ b/Linphone/core/account/AccountProxy.hpp @@ -43,7 +43,6 @@ public: AccountGui *getDefaultAccount(); // Get a new object from List or give the stored one. void resetDefaultAccount(); // Reset the default account to let UI build its new object if needed. - Q_INVOKABLE AccountGui *findAccountByAddress(const QString &address); Q_INVOKABLE AccountGui *firstAccount(); bool getHaveAccount() const; diff --git a/Linphone/core/conference/ConferenceCore.cpp b/Linphone/core/conference/ConferenceCore.cpp index 93aa93cfd..624715fee 100644 --- a/Linphone/core/conference/ConferenceCore.cpp +++ b/Linphone/core/conference/ConferenceCore.cpp @@ -43,8 +43,6 @@ ConferenceCore::ConferenceCore(const std::shared_ptr &conf auto activeSpeaker = conference->getActiveSpeakerParticipantDevice(); if (activeSpeaker) { mActiveSpeakerDevice = ParticipantDeviceCore::create(activeSpeaker); - auto participant = conference->findParticipant(activeSpeaker->getAddress()); - if (participant) mActiveSpeaker = ParticipantCore::create(participant); } mIsLocalScreenSharing = mConferenceModel->isLocalScreenSharing(); mIsScreenSharingEnabled = mConferenceModel->isScreenSharingEnabled(); @@ -66,15 +64,7 @@ void ConferenceCore::setSelf(QSharedPointer me) { [this](const std::shared_ptr &conference, const std::shared_ptr &participantDevice) { auto device = ParticipantDeviceCore::create(participantDevice); - QSharedPointer participantCore; - if (participantDevice) { - auto participant = conference->findParticipant(participantDevice->getAddress()); - if (participant) participantCore = ParticipantCore::create(participant); - } - mConferenceModelConnection->invokeToCore([this, device, participantCore]() { - setActiveSpeaker(participantCore); - setActiveSpeakerDevice(device); - }); + mConferenceModelConnection->invokeToCore([this, device]() { setActiveSpeakerDevice(device); }); }); mConferenceModelConnection->makeConnectToModel( @@ -82,27 +72,17 @@ void ConferenceCore::setSelf(QSharedPointer me) { [this](const std::shared_ptr &conference, linphone::Conference::State newState) { int count = mConferenceModel->getParticipantDeviceCount(); mConferenceModelConnection->invokeToCore([this, count]() { setParticipantDeviceCount(count); }); - if (newState == linphone::Conference::State::Created && !mActiveSpeaker) { + if (newState == linphone::Conference::State::Created) { if (auto participantDevice = conference->getActiveSpeakerParticipantDevice()) { auto device = ParticipantDeviceCore::create(participantDevice); - QSharedPointer participantCore; - auto participant = conference->findParticipant(participantDevice->getAddress()); - if (participant) participantCore = ParticipantCore::create(participant); - mConferenceModelConnection->invokeToCore([this, device, participantCore]() { - setActiveSpeaker(participantCore); - setActiveSpeakerDevice(device); - }); + mConferenceModelConnection->invokeToCore([this, device]() { setActiveSpeakerDevice(device); }); } else if (conference->getParticipantDeviceList().size() > 1) { for (auto &device : conference->getParticipantDeviceList()) { if (!ToolModel::isMe(device->getAddress())) { auto activeSpeakerDevice = ParticipantDeviceCore::create(device); - QSharedPointer participantCore; auto participant = conference->findParticipant(device->getAddress()); - if (participant) participantCore = ParticipantCore::create(participant); - mConferenceModelConnection->invokeToCore([this, activeSpeakerDevice, participantCore]() { - setActiveSpeaker(participantCore); - setActiveSpeakerDevice(activeSpeakerDevice); - }); + mConferenceModelConnection->invokeToCore( + [this, activeSpeakerDevice]() { setActiveSpeakerDevice(activeSpeakerDevice); }); break; } } @@ -115,25 +95,14 @@ void ConferenceCore::setSelf(QSharedPointer me) { [this](const std::shared_ptr &conference, int count) { if (auto participantDevice = conference->getActiveSpeakerParticipantDevice()) { auto device = ParticipantDeviceCore::create(participantDevice); - QSharedPointer participantCore; - auto participant = conference->findParticipant(participantDevice->getAddress()); - if (participant) participantCore = ParticipantCore::create(participant); setActiveSpeakerDevice(device); - mConferenceModelConnection->invokeToCore([this, device, participantCore]() { - setActiveSpeaker(participantCore); - setActiveSpeakerDevice(device); - }); + mConferenceModelConnection->invokeToCore([this, device]() { setActiveSpeakerDevice(device); }); } else if (conference->getParticipantDeviceList().size() > 1) { for (auto &device : conference->getParticipantDeviceList()) { if (!ToolModel::isMe(device->getAddress())) { auto activeSpeaker = ParticipantDeviceCore::create(device); - QSharedPointer participantCore; - auto participant = conference->findParticipant(device->getAddress()); - if (participant) participantCore = ParticipantCore::create(participant); - mConferenceModelConnection->invokeToCore([this, activeSpeaker, participantCore]() { - setActiveSpeaker(participantCore); - setActiveSpeakerDevice(activeSpeaker); - }); + mConferenceModelConnection->invokeToCore( + [this, activeSpeaker]() { setActiveSpeakerDevice(activeSpeaker); }); break; } } @@ -233,10 +202,6 @@ ParticipantDeviceCore *ConferenceCore::getActiveSpeakerDevice() const { return mActiveSpeakerDevice.get(); } -ParticipantGui *ConferenceCore::getActiveSpeakerGui() const { - return mActiveSpeaker ? new ParticipantGui(mActiveSpeaker) : nullptr; -} - ParticipantDeviceGui *ConferenceCore::getActiveSpeakerDeviceGui() const { return mActiveSpeakerDevice ? new ParticipantDeviceGui(mActiveSpeakerDevice) : nullptr; } @@ -252,11 +217,3 @@ void ConferenceCore::setActiveSpeakerDevice(const QSharedPointer &participant) { - if (mActiveSpeaker != participant) { - mActiveSpeaker = participant; - qDebug() << log().arg("Changing active speaker to %1").arg(participant ? participant->getSipAddress() : "None"); - emit activeSpeakerChanged(); - } -} diff --git a/Linphone/core/conference/ConferenceCore.hpp b/Linphone/core/conference/ConferenceCore.hpp index b45299a3a..51e636c1c 100644 --- a/Linphone/core/conference/ConferenceCore.hpp +++ b/Linphone/core/conference/ConferenceCore.hpp @@ -48,7 +48,6 @@ public: Q_PROPERTY(bool isScreenSharingEnabled MEMBER mIsScreenSharingEnabled WRITE setIsScreenSharingEnabled NOTIFY isScreenSharingEnabledChanged) Q_PROPERTY(int participantDeviceCount READ getParticipantDeviceCount NOTIFY participantDeviceCountChanged) - Q_PROPERTY(ParticipantGui *activeSpeaker READ getActiveSpeakerGui NOTIFY activeSpeakerChanged) Q_PROPERTY( ParticipantDeviceGui *activeSpeakerDevice READ getActiveSpeakerDeviceGui NOTIFY activeSpeakerDeviceChanged) Q_PROPERTY(ParticipantGui *me READ getMeGui) @@ -73,9 +72,7 @@ public: ParticipantDeviceCore *getActiveSpeakerDevice() const; ParticipantDeviceGui *getActiveSpeakerDeviceGui() const; - ParticipantGui *getActiveSpeakerGui() const; void setActiveSpeakerDevice(const QSharedPointer &device); - void setActiveSpeaker(const QSharedPointer &participant); ParticipantGui *getMeGui() const; void setIsReady(bool state); @@ -92,7 +89,6 @@ signals: void isLocalScreenSharingChanged(); void isScreenSharingEnabledChanged(); void participantDeviceCountChanged(); - void activeSpeakerChanged(); void activeSpeakerDeviceChanged(); void subjectChanged(); void isRecordingChanged(); @@ -102,7 +98,6 @@ signals: private: QSharedPointer> mConferenceModelConnection; std::shared_ptr mConferenceModel; - QSharedPointer mActiveSpeaker; QSharedPointer mActiveSpeakerDevice; QSharedPointer mMe; int mParticipantDeviceCount = 0; diff --git a/Linphone/core/participant/ParticipantDeviceCore.cpp b/Linphone/core/participant/ParticipantDeviceCore.cpp index a3d871be7..11f4dd655 100644 --- a/Linphone/core/participant/ParticipantDeviceCore.cpp +++ b/Linphone/core/participant/ParticipantDeviceCore.cpp @@ -47,7 +47,9 @@ ParticipantDeviceCore::ParticipantDeviceCore(const std::shared_ptrgetAddress(); mUniqueAddress = Utils::coreStringToAppString(deviceAddress->asString()); mAddress = Utils::coreStringToAppString(deviceAddress->asStringUriOnly()); - mDisplayName = Utils::coreStringToAppString(deviceAddress->getDisplayName()); + // the display name of the device himself may be the uncleaned sip uri + // Use the participant name instead + mDisplayName = Utils::coreStringToAppString(device->getParticipant()->getAddress()->getDisplayName()); if (mDisplayName.isEmpty()) { mDisplayName = ToolModel::getDisplayName(mAddress); } diff --git a/Linphone/tool/Utils.cpp b/Linphone/tool/Utils.cpp index 72e91a8b0..2323a7607 100644 --- a/Linphone/tool/Utils.cpp +++ b/Linphone/tool/Utils.cpp @@ -132,30 +132,6 @@ VariantObject *Utils::findLocalAccountByAddress(const QString &address) { return data; } -VariantObject *Utils::findParticipantFromDevice(QString conferenceAddress, QString deviceAddress) { - VariantObject *data = new VariantObject("findParticipantFromDevice"); - if (!data) return nullptr; - data->makeRequest([conferenceAddress, deviceAddress]() { - auto linCall = ToolModel::getCallByRemoteAddress(conferenceAddress); - if (linCall) { - auto linConf = linCall->getConference(); - if (linConf) { - auto linAddress = ToolModel::interpretUrl(deviceAddress); - if (linAddress) { - auto participant = linConf->findParticipant(linAddress); - if (participant) { - auto participantCore = ParticipantCore::create(participant); - return QVariant::fromValue(new ParticipantGui(participantCore)); - } - } - } - } - return QVariant(); - }); - data->requestValue(); - return data; -} - void Utils::createCall(const QString &sipAddress, QVariantMap options, LinphoneEnums::MediaEncryption mediaEncryption, diff --git a/Linphone/tool/Utils.hpp b/Linphone/tool/Utils.hpp index 74470c59a..df4cd7fea 100644 --- a/Linphone/tool/Utils.hpp +++ b/Linphone/tool/Utils.hpp @@ -64,7 +64,6 @@ public: Q_INVOKABLE static QString getFamilyNameFromFullName(const QString &fullName); Q_INVOKABLE static QString getInitials(const QString &username); // Support UTF32 Q_INVOKABLE static VariantObject *findLocalAccountByAddress(const QString &address); - Q_INVOKABLE static VariantObject *findParticipantFromDevice(QString conferenceAddress, QString deviceAddress); Q_INVOKABLE static void createCall(const QString &sipAddress, diff --git a/Linphone/view/Control/Container/Call/ActiveSpeakerLayout.qml b/Linphone/view/Control/Container/Call/ActiveSpeakerLayout.qml index 2c6deeb51..9c10ef0ca 100644 --- a/Linphone/view/Control/Container/Call/ActiveSpeakerLayout.qml +++ b/Linphone/view/Control/Container/Call/ActiveSpeakerLayout.qml @@ -43,7 +43,6 @@ Item { call: mainItem.call displayAll: !mainItem.conference participantDevice: mainItem.conference && mainItem.conference.core.activeSpeakerDevice - participant: mainItem.conference && mainItem.conference.core.activeSpeaker property var address: participantDevice && participantDevice.core.address videoEnabled: (participantDevice && participantDevice.core.videoEnabled) || (!participantDevice && call && call.core.remoteVideoEnabled) qmlName: 'AS' @@ -78,8 +77,6 @@ Item { anchors.bottomMargin: 15 * DefaultStyle.dp// Spacing qmlName: 'S_'+index visible: parent.visible - property var participantObj: mainItem.call && $modelData ? UtilsCpp.findParticipantFromDevice(mainItem.call.core.remoteAddress, $modelData.core.address) : null - participant: participantObj ? participantObj.value : null participantDevice: $modelData displayAll: false displayPresence: false diff --git a/Linphone/view/Control/Container/Call/CallGridLayout.qml b/Linphone/view/Control/Container/Call/CallGridLayout.qml index b7745df57..f7a463ddd 100644 --- a/Linphone/view/Control/Container/Call/CallGridLayout.qml +++ b/Linphone/view/Control/Container/Call/CallGridLayout.qml @@ -45,12 +45,11 @@ Mosaic { anchors.fill: parent qmlName: 'G_'+index call: grid.call && !grid.call.core.isConference ? grid.call : null - account: index == 0 ? accountProxy.findAccountByAddress(mainItem.localAddress) : null + property var accountObj: UtilsCpp.findLocalAccountByAddress(mainItem.localAddress) + account: (index == 0 && accountObj) ? accountObj.value : null displayAll: false displayPresence: false participantDevice: avatarCell.currentDevice - property var participantObj: (mainItem.call && avatarCell.currentDevice) ? UtilsCpp.findParticipantFromDevice(mainItem.call.core.remoteAddress, avatarCell.currentDevice.core.address) : null - participant: participantObj ? participantObj.value : null Component.onCompleted: console.log(qmlName + " is " +(call ? call.core.remoteAddress : currentDevice ? currentDevice.core.address : 'addr_NotDefined')) } } diff --git a/Linphone/view/Control/Display/Sticker.qml b/Linphone/view/Control/Display/Sticker.qml index 73f0e98d6..5db38d3dd 100644 --- a/Linphone/view/Control/Display/Sticker.qml +++ b/Linphone/view/Control/Display/Sticker.qml @@ -22,7 +22,6 @@ Item { property var callState: call && call.core.state || undefined property AccountGui account: null property ParticipantDeviceGui participantDevice: null - property ParticipantGui participant: null property bool displayBorder : participantDevice && participantDevice.core.isSpeaking || false property alias displayPresence: avatar.displayPresence property color color: DefaultStyle.grey_600 @@ -46,8 +45,8 @@ Item { property string localName: localNameObj ? localNameObj.value : "" property string displayName: account ? account.core.displayName - : participant - ? participant.core.displayName + : participantDevice + ? participantDevice.core.displayName : call ? previewEnabled ? localName