mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
update chat participant display name when friend created/updated/removed #LINQT-2347
This commit is contained in:
parent
c756217b16
commit
83675dd9bb
4 changed files with 49 additions and 3 deletions
|
|
@ -20,10 +20,8 @@
|
|||
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
#include "core/App.hpp"
|
||||
|
||||
#include "ParticipantCore.hpp"
|
||||
// #include "ParticipantDeviceList.hpp"
|
||||
#include "core/App.hpp"
|
||||
#include "model/participant/ParticipantModel.hpp"
|
||||
#include "model/tool/ToolModel.hpp"
|
||||
#include "tool/Utils.hpp"
|
||||
|
|
@ -77,6 +75,48 @@ void ParticipantCore::setSelf(QSharedPointer<ParticipantCore> me) {
|
|||
QTimer::singleShot(secs * 1000, this, &ParticipantCore::onEndOfInvitation);
|
||||
});
|
||||
connect(this, &ParticipantCore::sipAddressChanged, this, &ParticipantCore::updateIsMe);
|
||||
auto update = [this, remoteAddress = mSipAddress](const std::shared_ptr<linphone::Friend> &updatedFriend) {
|
||||
bool isThisFriend = false;
|
||||
std::shared_ptr<linphone::Address> friendAddress;
|
||||
auto participantAddress = mParticipantModel->getAddress();
|
||||
for (auto address : updatedFriend->getAddresses()) {
|
||||
if (address->weakEqual(participantAddress)) {
|
||||
isThisFriend = true;
|
||||
friendAddress = address;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isThisFriend) {
|
||||
auto displayName = friendAddress->getDisplayName();
|
||||
mCoreModelConnection->invokeToCore([this, displayName] {
|
||||
auto me = mCoreModelConnection->mCore.mQData; // Locked from previous call.
|
||||
setDisplayName(Utils::coreStringToAppString(displayName));
|
||||
});
|
||||
}
|
||||
};
|
||||
auto onRemoved = [this](const std::shared_ptr<linphone::Friend> &updatedFriend) {
|
||||
bool isThisFriend = false;
|
||||
std::shared_ptr<linphone::Address> friendAddress;
|
||||
auto participantAddress = mParticipantModel->getAddress();
|
||||
for (auto address : updatedFriend->getAddresses()) {
|
||||
if (address->weakEqual(participantAddress)) {
|
||||
isThisFriend = true;
|
||||
friendAddress = address;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isThisFriend) {
|
||||
auto displayName = ToolModel::getDisplayName(participantAddress);
|
||||
mCoreModelConnection->invokeToCore([this, displayName] {
|
||||
auto me = mCoreModelConnection->mCore.mQData; // Locked from previous call.
|
||||
setDisplayName(displayName);
|
||||
});
|
||||
}
|
||||
};
|
||||
mCoreModelConnection = SafeConnection<ParticipantCore, CoreModel>::create(me, CoreModel::getInstance());
|
||||
mCoreModelConnection->makeConnectToModel(&CoreModel::friendCreated, update);
|
||||
mCoreModelConnection->makeConnectToModel(&CoreModel::friendUpdated, update);
|
||||
mCoreModelConnection->makeConnectToModel(&CoreModel::friendRemoved, onRemoved);
|
||||
}
|
||||
|
||||
LinphoneEnums::SecurityLevel ParticipantCore::getSecurityLevel() const {
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ signals:
|
|||
private:
|
||||
std::shared_ptr<ParticipantModel> mParticipantModel;
|
||||
QSharedPointer<SafeConnection<ParticipantCore, ParticipantModel>> mParticipantConnection;
|
||||
QSharedPointer<SafeConnection<ParticipantCore, CoreModel>> mCoreModelConnection;
|
||||
|
||||
QList<QVariant> mParticipantDevices;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@ QString ParticipantModel::getSipAddress() const {
|
|||
return Utils::coreStringToAppString(mParticipant->getAddress()->asString());
|
||||
}
|
||||
|
||||
std::shared_ptr<const linphone::Address> ParticipantModel::getAddress() const {
|
||||
return mParticipant ? mParticipant->getAddress() : nullptr;
|
||||
}
|
||||
|
||||
QDateTime ParticipantModel::getCreationTime() const {
|
||||
return QDateTime::fromSecsSinceEpoch(mParticipant->getCreationTime());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public:
|
|||
~ParticipantModel();
|
||||
|
||||
QString getSipAddress() const;
|
||||
std::shared_ptr<const linphone::Address> getAddress() const;
|
||||
QDateTime getCreationTime() const;
|
||||
bool getAdminStatus() const;
|
||||
bool isFocus() const;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue