clean participant device name with new sdk api

use utils fonction to set me display name in call grid
This commit is contained in:
Gaelle Braud 2025-02-04 13:39:21 +01:00 committed by Gaëlle Braud
parent 9f5350c0e0
commit e6fe32cfee
10 changed files with 15 additions and 98 deletions

View file

@ -45,12 +45,6 @@ void AccountProxy::resetDefaultAccount() {
emit this->defaultAccountChanged(); // Warn the UI
}
AccountGui *AccountProxy::findAccountByAddress(const QString &address) {
auto model = getListModel<AccountList>();
if (model) return new AccountGui(model->findAccountByAddress(address));
else return nullptr;
}
AccountGui *AccountProxy::firstAccount() {
auto model = getListModel<AccountList>();
if (model) return model->firstAccount();

View file

@ -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;

View file

@ -43,8 +43,6 @@ ConferenceCore::ConferenceCore(const std::shared_ptr<linphone::Conference> &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<ConferenceCore> me) {
[this](const std::shared_ptr<linphone::Conference> &conference,
const std::shared_ptr<linphone::ParticipantDevice> &participantDevice) {
auto device = ParticipantDeviceCore::create(participantDevice);
QSharedPointer<ParticipantCore> 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<ConferenceCore> me) {
[this](const std::shared_ptr<linphone::Conference> &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> 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> 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<ConferenceCore> me) {
[this](const std::shared_ptr<linphone::Conference> &conference, int count) {
if (auto participantDevice = conference->getActiveSpeakerParticipantDevice()) {
auto device = ParticipantDeviceCore::create(participantDevice);
QSharedPointer<ParticipantCore> 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> 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<ParticipantDevi
emit activeSpeakerDeviceChanged();
}
}
void ConferenceCore::setActiveSpeaker(const QSharedPointer<ParticipantCore> &participant) {
if (mActiveSpeaker != participant) {
mActiveSpeaker = participant;
qDebug() << log().arg("Changing active speaker to %1").arg(participant ? participant->getSipAddress() : "None");
emit activeSpeakerChanged();
}
}

View file

@ -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<ParticipantDeviceCore> &device);
void setActiveSpeaker(const QSharedPointer<ParticipantCore> &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<SafeConnection<ConferenceCore, ConferenceModel>> mConferenceModelConnection;
std::shared_ptr<ConferenceModel> mConferenceModel;
QSharedPointer<ParticipantCore> mActiveSpeaker;
QSharedPointer<ParticipantDeviceCore> mActiveSpeakerDevice;
QSharedPointer<ParticipantCore> mMe;
int mParticipantDeviceCount = 0;

View file

@ -47,7 +47,9 @@ ParticipantDeviceCore::ParticipantDeviceCore(const std::shared_ptr<linphone::Par
auto deviceAddress = device->getAddress();
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);
}

View file

@ -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,

View file

@ -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,

View file

@ -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

View file

@ -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'))
}
}

View file

@ -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