fix contact name + avatar initials

fix #LINQT-1339 persistent waiting room + warnings

fix #LINQT-1334 remote name in call
This commit is contained in:
Gaelle Braud 2024-10-10 16:45:12 +02:00
parent 1d0e9f145b
commit 9cf975518f
19 changed files with 109 additions and 68 deletions

View file

@ -122,7 +122,12 @@ CallCore::CallCore(const std::shared_ptr<linphone::Call> &call) : QObject(nullpt
mRemoteVideoEnabled =
videoDirection == linphone::MediaDirection::SendOnly || videoDirection == linphone::MediaDirection::SendRecv;
mState = LinphoneEnums::fromLinphone(call->getState());
mPeerAddress = Utils::coreStringToAppString(call->getRemoteAddress()->asStringUriOnly());
mRemoteAddress = Utils::coreStringToAppString(call->getRemoteAddress()->asStringUriOnly());
auto linphoneFriend = ToolModel::findFriendByAddress(mRemoteAddress);
if (linphoneFriend)
mRemoteName = Utils::coreStringToAppString(
linphoneFriend->getVcard() ? linphoneFriend->getVcard()->getFullName() : linphoneFriend->getName());
if (mRemoteName.isEmpty()) mRemoteName = ToolModel::getDisplayName(mRemoteAddress);
mLocalAddress = Utils::coreStringToAppString(call->getCallLog()->getLocalAddress()->asStringUriOnly());
mStatus = LinphoneEnums::fromLinphone(call->getCallLog()->getStatus());
mTransferState = LinphoneEnums::fromLinphone(call->getTransferState());
@ -454,8 +459,12 @@ void CallCore::setSelf(QSharedPointer<CallCore> me) {
});
}
QString CallCore::getPeerAddress() const {
return mPeerAddress;
QString CallCore::getRemoteName() const {
return mRemoteName;
}
QString CallCore::getRemoteAddress() const {
return mRemoteAddress;
}
QString CallCore::getLocalAddress() const {

View file

@ -95,7 +95,6 @@ public:
class CallCore : public QObject, public AbstractObject {
Q_OBJECT
// Q_PROPERTY(QString peerDisplayName MEMBER mPeerDisplayName)
Q_PROPERTY(LinphoneEnums::CallStatus status READ getStatus NOTIFY statusChanged)
Q_PROPERTY(LinphoneEnums::CallDir dir READ getDir NOTIFY dirChanged)
Q_PROPERTY(LinphoneEnums::CallState state READ getState NOTIFY stateChanged)
@ -105,7 +104,8 @@ class CallCore : public QObject, public AbstractObject {
Q_PROPERTY(bool speakerMuted READ getSpeakerMuted WRITE lSetSpeakerMuted NOTIFY speakerMutedChanged)
Q_PROPERTY(bool microphoneMuted READ getMicrophoneMuted WRITE lSetMicrophoneMuted NOTIFY microphoneMutedChanged)
Q_PROPERTY(bool paused READ getPaused WRITE lSetPaused NOTIFY pausedChanged)
Q_PROPERTY(QString peerAddress READ getPeerAddress CONSTANT)
Q_PROPERTY(QString remoteName READ getRemoteName CONSTANT)
Q_PROPERTY(QString remoteAddress READ getRemoteAddress CONSTANT)
Q_PROPERTY(QString localAddress READ getLocalAddress CONSTANT)
Q_PROPERTY(bool tokenVerified READ getTokenVerified WRITE setTokenVerified NOTIFY securityUpdated)
Q_PROPERTY(bool isMismatch READ isMismatch WRITE setIsMismatch NOTIFY securityUpdated)
@ -144,7 +144,8 @@ public:
~CallCore();
void setSelf(QSharedPointer<CallCore> me);
QString getPeerAddress() const;
QString getRemoteName() const;
QString getRemoteAddress() const;
QString getLocalAddress() const;
LinphoneEnums::CallStatus getStatus() const;
@ -301,7 +302,7 @@ signals:
Q_INVOKABLE void askForTransfer();
Q_INVOKABLE void askForAttendedTransfer();
Q_INVOKABLE bool transferTo(const QString &sipAddress);
Q_INVOKABLE bool transferToAnother(const QString &peerAddress);
Q_INVOKABLE bool transferToAnother(const QString &remoteAddress);
Q_INVOKABLE bool getRemoteVideoEnabled() const;
Q_INVOKABLE void acceptVideoRequest();
@ -324,7 +325,8 @@ private:
LinphoneEnums::MediaEncryption mEncryption;
QString mLastErrorMessage;
QString mPeerAddress;
QString mRemoteName;
QString mRemoteAddress;
QString mLocalAddress;
bool mTokenVerified = false;
bool mIsSecured = false;

View file

@ -74,7 +74,7 @@ bool CallProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QModelInde
QRegularExpression::UseUnicodePropertiesOption);
auto call = qobject_cast<CallList *>(sourceModel())->getAt<CallCore>(sourceRow);
show = call->getPeerAddress().contains(search);
show = call->getRemoteAddress().contains(search);
}
return show;
@ -84,5 +84,5 @@ bool CallProxy::SortFilterList::lessThan(const QModelIndex &sourceLeft, const QM
auto l = getItemAtSource<CallList, CallCore>(sourceLeft.row());
auto r = getItemAtSource<CallList, CallCore>(sourceRight.row());
return l->getPeerAddress() < r->getPeerAddress();
return l->getRemoteAddress() < r->getRemoteAddress();
}

View file

@ -329,8 +329,8 @@ void Notifier::notifyReceivedMessages(const list<shared_ptr<linphone::ChatMessag
map["timelineModel"].setValue(
CoreManager::getInstance()->getTimelineListModel()->getTimeline(chatRoom, true).get());
if (messages.size() == 1) { // Display only sender on mono message.
map["peerAddress"] = Utils::coreStringToAppString(message->getFromAddress()->asStringUriOnly());
map["fullPeerAddress"] = Utils::coreStringToAppString(message->getFromAddress()->asString());
map["remoteAddress"] = Utils::coreStringToAppString(message->getFromAddress()->asStringUriOnly());
map["fullremoteAddress"] = Utils::coreStringToAppString(message->getFromAddress()->asString());
}
map["localAddress"] = Utils::coreStringToAppString(message->getToAddress()->asStringUriOnly());
map["fullLocalAddress"] = Utils::coreStringToAppString(message->getToAddress()->asString());
@ -381,8 +381,8 @@ void Notifier::notifyReceivedReactions(
map["timelineModel"].setValue(timelineModel.get());
if (reactions.size() == 1) { // Display only sender on mono message.
map["peerAddress"] = Utils::coreStringToAppString(reaction.second->getFromAddress()->asStringUriOnly());
map["fullPeerAddress"] = Utils::coreStringToAppString(reaction.second->getFromAddress()->asString());
map["remoteAddress"] = Utils::coreStringToAppString(reaction.second->getFromAddress()->asStringUriOnly());
map["fullremoteAddress"] = Utils::coreStringToAppString(reaction.second->getFromAddress()->asString());
}
map["localAddress"] = Utils::coreStringToAppString(chatRoom->getLocalAddress()->asStringUriOnly());
map["fullLocalAddress"] = Utils::coreStringToAppString(chatRoom->getLocalAddress()->asString());

View file

@ -144,8 +144,8 @@ bool ParticipantProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QMo
}
bool ParticipantProxy::SortFilterList::lessThan(const QModelIndex &left, const QModelIndex &right) const {
const ParticipantCore *a = sourceModel()->data(left).value<ParticipantCore *>();
const ParticipantCore *b = sourceModel()->data(right).value<ParticipantCore *>();
auto l = getItemAtSource<ParticipantList, ParticipantCore>(left.row());
auto r = getItemAtSource<ParticipantList, ParticipantCore>(right.row());
return a->getCreationTime() > b->getCreationTime() || b->isMe();
return l->getCreationTime() > r->getCreationTime() || r->isMe();
}

View file

@ -101,6 +101,13 @@ QString ToolModel::getDisplayName(QString address) {
return nameSplitted.join(" ");
}
std::shared_ptr<linphone::Friend> ToolModel::findFriendByAddress(const QString &address) {
auto defaultFriendList = CoreModel::getInstance()->getCore()->getDefaultFriendList();
if (!defaultFriendList) return nullptr;
auto linphoneAddr = ToolModel::interpretUrl(address);
return CoreModel::getInstance()->getCore()->findFriend(linphoneAddr);
}
bool ToolModel::createCall(const QString &sipAddress,
const QVariantMap &options,
const QString &prepareTransfertAddress,

View file

@ -48,6 +48,8 @@ public:
static QString getDisplayName(const std::shared_ptr<const linphone::Address> &address);
static QString getDisplayName(QString address);
static std::shared_ptr<linphone::Friend> findFriendByAddress(const QString &address);
static bool createCall(const QString &sipAddress,
const QVariantMap &options = {},
const QString &prepareTransfertAddress = "",

View file

@ -363,10 +363,7 @@ VariantObject *Utils::findFriendByAddress(const QString &address) {
VariantObject *data = new VariantObject();
if (!data) return nullptr;
data->makeRequest([address]() {
auto defaultFriendList = CoreModel::getInstance()->getCore()->getDefaultFriendList();
if (!defaultFriendList) return QVariant();
auto linphoneAddr = ToolModel::interpretUrl(address);
auto linFriend = CoreModel::getInstance()->getCore()->findFriend(linphoneAddr);
auto linFriend = ToolModel::findFriendByAddress(address);
if (!linFriend) return QVariant();
auto friendCore = FriendCore::create(linFriend);
return QVariant::fromValue(new FriendGui(friendCore));

View file

@ -95,7 +95,7 @@ Item{
textColor: DefaultStyle.main2_400
onClicked: {
if (mainItem.conference) {
UtilsCpp.copyToClipboard(mainItem.call.core.peerAddress)
UtilsCpp.copyToClipboard(mainItem.call.core.remoteAddress)
showInformationPopup(qsTr("Copié"), qsTr("Le lien de la réunion a été copié dans le presse-papier"), true)
}
}

View file

@ -50,7 +50,7 @@ Item {
? qsTr("Vous avez terminé l'appel")
: qsTr("Votre correspondant a terminé l'appel")
: call.core.lastErrorMessage
: call.core.lastErrorMessage
: call && call.core.lastErrorMessage || ""
color: DefaultStyle.grey_0
font {
pixelSize: 22 * DefaultStyle.dp

View file

@ -46,7 +46,7 @@ Mosaic {
displayAll: false
displayPresence: false
participantDevice: avatarCell.currentDevice
Component.onCompleted: console.log(qmlName + " is " +(call ? call.core.peerAddress : currentDevice ? currentDevice.core.address : 'addr_NotDefined'))
Component.onCompleted: console.log(qmlName + " is " +(call ? call.core.remoteAddress : currentDevice ? currentDevice.core.address : 'addr_NotDefined'))
}
}
}

View file

@ -14,7 +14,13 @@ ColumnLayout {
property ConferenceInfoGui conferenceInfo
property bool isConference: conferenceInfo != undefined && conferenceInfo != null
property string contactAddress: specificAddress != "" ? specificAddress : contact && contact.core.defaultAddress || ""
property string contactName: contact && contact.core.displayName || ""
property var computedContactNameObj: UtilsCpp.getDisplayName(contactAddress)
property string computedContactName: computedContactNameObj ? computedContactNameObj.value: ""
property string contactName: contact
? contact.core.displayName
: conferenceInfo
? conferenceInfo.core.subject
: computedContactName
// Set this property to get the security informations
// for a specific address and not for the entire contact
@ -60,14 +66,13 @@ ColumnLayout {
Item {
Layout.preferredWidth: 360 * DefaultStyle.dp
Layout.preferredHeight: detailAvatar.height
// Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
Avatar {
id: detailAvatar
anchors.horizontalCenter: parent.horizontalCenter
width: 100 * DefaultStyle.dp
height: 100 * DefaultStyle.dp
contact: mainItem.specificAddress == "" ? mainItem.contact : null
contact: mainItem.contact || null
_address: mainItem.conferenceInfo
? mainItem.conferenceInfo.core.subject
: mainItem.contactAddress || mainItem.contactName
@ -85,11 +90,11 @@ ColumnLayout {
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: 360 * DefaultStyle.dp
spacing: 2 * DefaultStyle.dp
Text {
Layout.preferredWidth: implicitWidth
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WrapAnywhere
elide: Text.ElideRight
text: mainItem.contactName
maximumLineCount: 1
@ -116,6 +121,7 @@ ColumnLayout {
property var mode : contact ? contact.core.consolidatedPresence : -1
Layout.alignment: Qt.AlignHCenter
horizontalAlignment: Text.AlignHCenter
Layout.fillWidth: true
visible: mainItem.contact
text: mode === LinphoneEnums.ConsolidatedPresence.Online
? qsTr("En ligne")

View file

@ -16,15 +16,19 @@ Loader{
property FriendGui contact: null
property CallGui call: null
property string _address: account
? account.core?.identityAddress || ""
: call
? call.core.peerAddress
: contact
? contact.core.defaultAddress
: ''
? account.core?.identityAddress || ""
: call
? call.core.remoteAddress
: contact
? contact.core.defaultAddress
: ''
readonly property string address: SettingsCpp.onlyDisplaySipUriUsername ? UtilsCpp.getUsername(_address) : _address
property var displayNameObj: UtilsCpp.getDisplayName(_address)
property string displayNameVal: displayNameObj ? displayNameObj.value : ""
property string displayNameVal: contact
? contact.core.displayName
: displayNameObj
? displayNameObj.value
: ""
property bool haveAvatar: (account && account.core?.pictureUri || false)
|| (contact && contact.core.pictureUri)
|| computedAvatarUri.length != 0

View file

@ -30,15 +30,28 @@ Item {
: previewEnabled
? callState === LinphoneEnums.CallState.Paused
: callState === LinphoneEnums.CallState.PausedByRemote
property var peerAddressObj: previewEnabled && (call || account)
? UtilsCpp.getDisplayName(account ? account.core.identityAddress : call.core.localAddress)
: participantDevice && participantDevice.core
? UtilsCpp.getDisplayName(participantDevice.core.address)
: !previewEnabled && call && call.core
? UtilsCpp.getDisplayName(call.core.peerAddress)
: null
property string peerAddress:peerAddressObj ? peerAddressObj.value : ""
property string remoteAddress: account
? account.core.identityAddress
: participantDevice
? participantDevice.core.address
: call
? call.core.remoteAddress
: ""
property var localNameObj: previewEnabled && call
? UtilsCpp.getDisplayName(call.core.localAddress)
: null
property string localName: localNameObj ? localNameObj.value : ""
property string displayName: account
? account.core.displayName
: participantDevice
? participantDevice.core.displayName
: call
? previewEnabled
? localName
: call.core.remoteName
: ""
property var identityAddress: account ? UtilsCpp.getDisplayName(account.core.identityAddress) : null
property bool videoEnabled: (previewEnabled && call && call.core.localVideoEnabled)
|| (participantDevice && participantDevice.core.videoEnabled)
@ -87,7 +100,7 @@ Item {
}
Text {
id: waitingTime
property var isMeObj: UtilsCpp.isMe(mainItem.peerAddress)
property var isMeObj: UtilsCpp.isMe(mainItem.remoteAddress)
visible: isMeObj ? !isMeObj.value : false
property int seconds
text: UtilsCpp.formatElapsedTime(seconds)
@ -118,7 +131,7 @@ Item {
visible: !joiningView.visible
account: mainItem.account
call: !mainItem.previewEnabled ? mainItem.call : null
_address: mainItem.peerAddress
displayNameVal: mainItem.displayName
}
ColumnLayout{
id: joiningView
@ -176,7 +189,7 @@ Item {
Text {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
text: mainItem.peerAddress
text: mainItem.displayName
color: DefaultStyle.grey_0
font {
pixelSize: 22 * DefaultStyle.dp
@ -187,7 +200,7 @@ Item {
Text {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
property string _text: mainItem.call && mainItem.call.core.peerAddress
property string _text: mainItem.call && mainItem.call.core.remoteAddress
text: SettingsCpp.onlyDisplaySipUriUsername ? UtilsCpp.getUsername(_text) : _text
color: DefaultStyle.grey_0
font {
@ -258,8 +271,8 @@ Item {
anchors.leftMargin: 10 * DefaultStyle.dp
anchors.bottomMargin: 10 * DefaultStyle.dp
width: implicitWidth
property string _text: mainItem.peerAddress != ''
? mainItem.peerAddress
property string _text: mainItem.displayName != ''
? mainItem.displayName
: mainItem.account && mainItem.identityAddress
? mainItem.identityAddress.value
: ""

View file

@ -48,7 +48,7 @@ Notification {
}
ColumnLayout {
Text {
property var remoteAddress: UtilsCpp.getDisplayName(call.core.peerAddress)
property var remoteAddress: UtilsCpp.getDisplayName(call.core.remoteAddress)
text: remoteAddress ? remoteAddress.value : ""
color: DefaultStyle.grey_600
font {
@ -67,7 +67,7 @@ Notification {
Text {
Layout.fillWidth: true
property var localAddress: UtilsCpp.getDisplayName(call.core.localAddress)
text: qsTr("Appel entrant")//.arg(localAddress ? qsTr(" pour %1").arg(localAddress.value) : "") //call.core.peerAddress
text: qsTr("Appel entrant")//.arg(localAddress ? qsTr(" pour %1").arg(localAddress.value) : "") //call.core.remoteAddress
color: DefaultStyle.grey_600
font {
pixelSize: 13 * DefaultStyle.dp

View file

@ -50,7 +50,7 @@ Window {
Text{
id: addressText
anchors.fill: parent
text: modelData.core.peerAddress
text: modelData.core.remoteAddress
onTextChanged: console.log(addressText.text)
Component.onCompleted: console.log(addressText.text)
}

View file

@ -90,13 +90,12 @@ Item {
x: mainItem.width/2 - width/2
y: contentItem.height/2
property var currentCall: callsModel.currentCall ? callsModel.currentCall : null
property var peerNameObj: currentCall ? UtilsCpp.getDisplayName(currentCall.core.peerAddress) : null
property string peerName:peerNameObj ? peerNameObj.value : ""
property string remoteName: currentCall ? currentCall.core.remoteName : ""
contentItem: Button {
text: currentCallNotif.currentCall
? currentCallNotif.currentCall.core.conference
? ("Réunion en cours : ") + currentCallNotif.currentCall.core.conference.core.subject
: (("Appel en cours : ") + currentCallNotif.peerName) : "appel en cours"
: (("Appel en cours : ") + currentCallNotif.remoteName) : "appel en cours"
color: DefaultStyle.success_500main
onClicked: {
var callsWindow = UtilsCpp.getCallsWindow(currentCallNotif.currentCall)

View file

@ -283,6 +283,8 @@ AbstractMainPage {
spacing: 10 * DefaultStyle.dp
Avatar {
id: historyAvatar
property var contactObj: UtilsCpp.findFriendByAddress(modelData.core.remoteAddress)
contact: contactObj && contactObj.value || null
_address: modelData.core.remoteAddress
width: 45 * DefaultStyle.dp
height: 45 * DefaultStyle.dp
@ -662,7 +664,6 @@ AbstractMainPage {
contact: contactObj && contactObj.value || null
conferenceInfo: mainItem.selectedRowHistoryGui && mainItem.selectedRowHistoryGui.core.conferenceInfo || null
specificAddress: mainItem.selectedRowHistoryGui && mainItem.selectedRowHistoryGui.core.remoteAddress || ""
contactName: mainItem.selectedRowHistoryGui ? mainItem.selectedRowHistoryGui.core.displayName : ""
buttonContent: PopupButton {
id: detailOptions

View file

@ -59,6 +59,7 @@ AbstractWindow {
close.accepted = false
terminateAllCallsDialog.open()
}
if (middleItemStackView.currentItem.objectName === "waitingRoom") middleItemStackView.replace(inCallItem)
}
function changeLayout(layoutIndex) {
@ -340,12 +341,9 @@ AbstractWindow {
}
Text {
id: callStatusText
property var remoteNameObj: mainWindow.call ? UtilsCpp.getDisplayName(mainWindow.call.core.peerAddress) : null
property string remoteName: remoteNameObj
? mainWindow.callState === LinphoneEnums.CallState.Connected || mainWindow.callState === LinphoneEnums.CallState.StreamsRunning
? remoteNameObj.value
: EnumsToStringCpp.dirToString(mainWindow.call.core.dir) + qsTr(" call")
: ""
property string remoteName: mainWindow.callState === LinphoneEnums.CallState.Connected || mainWindow.callState === LinphoneEnums.CallState.StreamsRunning
? mainWindow.call.core.remoteName
: EnumsToStringCpp.dirToString(mainWindow.call.core.dir) + qsTr(" call")
text: (mainWindow.callState === LinphoneEnums.CallState.End || mainWindow.callState === LinphoneEnums.CallState.Released)
? qsTr("Fin d'appel")
: mainWindow.call && (mainWindow.call.core.paused
@ -816,13 +814,13 @@ AbstractWindow {
spacing: 0
Avatar {
id: delegateAvatar
_address: modelData.core.peerAddress
_address: modelData.core.remoteAddress
Layout.preferredWidth: 45 * DefaultStyle.dp
Layout.preferredHeight: 45 * DefaultStyle.dp
}
Text {
id: delegateName
property var remoteAddress: UtilsCpp.getDisplayName(modelData.core.peerAddress)
property var remoteAddress: UtilsCpp.getDisplayName(modelData.core.remoteAddress)
text: modelData.core.isConference
? modelData.core.conference.core.subject
: remoteAddress ? remoteAddress.value : ""
@ -1006,7 +1004,7 @@ AbstractWindow {
}
}
onClicked: {
UtilsCpp.copyToClipboard(mainWindow.call.core.peerAddress)
UtilsCpp.copyToClipboard(mainWindow.call.core.remoteAddress)
showInformationPopup(qsTr("Copié"), qsTr("Le lien de la réunion a été copié dans le presse-papier"), true)
}
}
@ -1558,7 +1556,6 @@ AbstractWindow {
id: participantListButton
visible: mainWindow.conference
iconUrl: AppIcons.usersTwo
checked: rightPanel.visible && rightPanel.currentItem?.objectName == "participantListPanel"
checkedColor: DefaultStyle.main2_400
Layout.preferredWidth: 55 * DefaultStyle.dp
Layout.preferredHeight: 55 * DefaultStyle.dp
@ -1572,6 +1569,10 @@ AbstractWindow {
rightPanel.visible = false
}
}
Connections {
target: rightPanel
onVisibleChanged: if (!rightPanel.visible) participantListButton.checked = false
}
}
PopupButton {
id: moreOptionsButton