From aa871c2735e237bf4b790f754ff8ef457577820a Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Wed, 23 Jul 2025 09:51:18 +0200 Subject: [PATCH] fix security circle avatar --- Linphone/tool/Utils.cpp | 21 ++++++++++++++++++- Linphone/tool/Utils.hpp | 1 + .../Control/Display/Call/CallListView.qml | 1 + .../view/Control/Display/Contact/Avatar.qml | 5 +++++ .../Display/Contact/ContactListItem.qml | 5 ++--- .../Participant/ParticipantDeviceListView.qml | 1 + .../Participant/ParticipantListView.qml | 1 + Linphone/view/Control/Display/Sticker.qml | 1 + Linphone/view/Control/Display/Text.qml | 1 - .../Notification/NotificationReceivedCall.qml | 1 + .../Page/Form/Meeting/AddParticipantsForm.qml | 1 + .../view/Page/Form/Meeting/MeetingForm.qml | 1 + .../view/Page/Main/Meeting/MeetingPage.qml | 2 ++ 13 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Linphone/tool/Utils.cpp b/Linphone/tool/Utils.cpp index c58024baa..c847c9175 100644 --- a/Linphone/tool/Utils.cpp +++ b/Linphone/tool/Utils.cpp @@ -425,6 +425,25 @@ VariantObject *Utils::findFriendByAddress(const QString &address) { return data; } +VariantObject *Utils::getFriendSecurityLevel(const QString &address) { + VariantObject *data = new VariantObject("getFriendAddressSecurityLevel"); + if (!data) return nullptr; + data->makeRequest([address]() { + auto defaultFriendList = ToolModel::getAppFriendList(); + if (!defaultFriendList) return QVariant(); + auto linphoneAddr = ToolModel::interpretUrl(address); + auto linFriend = CoreModel::getInstance()->getCore()->findFriend(linphoneAddr); + if (!linFriend) return QVariant(); + auto linAddr = ToolModel::interpretUrl(address); + if (!linAddr) return QVariant(); + auto devices = linFriend->getDevicesForAddress(linphoneAddr); + int verified = 0; + return QVariant::fromValue(LinphoneEnums::fromLinphone(linFriend->getSecurityLevel())); + }); + data->requestValue(); + return data; +} + VariantObject *Utils::getFriendAddressSecurityLevel(const QString &address) { VariantObject *data = new VariantObject("getFriendAddressSecurityLevel"); if (!data) return nullptr; @@ -1440,7 +1459,7 @@ QList Utils::append(const QList a, const QList b) QString Utils::getAddressToDisplay(QVariantList addressList, QString filter, QString defaultAddress) { if (filter.isEmpty()) return defaultAddress; - for (auto& item: addressList) { + for (auto &item : addressList) { QString address = item.toMap()["address"].toString(); if (address.contains(filter)) return address; } diff --git a/Linphone/tool/Utils.hpp b/Linphone/tool/Utils.hpp index 9f81a823b..784d37d3c 100644 --- a/Linphone/tool/Utils.hpp +++ b/Linphone/tool/Utils.hpp @@ -127,6 +127,7 @@ public: Q_INVOKABLE static VariantObject *findAvatarByAddress(const QString &address); Q_INVOKABLE static VariantObject *findFriendByAddress(const QString &address); Q_INVOKABLE static VariantObject *getFriendAddressSecurityLevel(const QString &address); + Q_INVOKABLE static VariantObject *getFriendSecurityLevel(const QString &address); static QString generateSavedFilename(const QString &from, const QString &to); Q_INVOKABLE static VariantObject *isMe(const QString &address); Q_INVOKABLE static VariantObject *isLocal(const QString &address); diff --git a/Linphone/view/Control/Display/Call/CallListView.qml b/Linphone/view/Control/Display/Call/CallListView.qml index 093812cf1..73bb0a2b4 100644 --- a/Linphone/view/Control/Display/Call/CallListView.qml +++ b/Linphone/view/Control/Display/Call/CallListView.qml @@ -32,6 +32,7 @@ ListView { Layout.preferredWidth: Math.round(45 * DefaultStyle.dp) Layout.preferredHeight: Math.round(45 * DefaultStyle.dp) _address: modelData.core.remoteAddress + secured: securityLevel === LinphoneEnums.SecurityLevel.EndToEndEncryptedAndVerified isConference: modelData.core.isConference shadowEnabled: false } diff --git a/Linphone/view/Control/Display/Contact/Avatar.qml b/Linphone/view/Control/Display/Contact/Avatar.qml index f8c62434e..00af10422 100644 --- a/Linphone/view/Control/Display/Contact/Avatar.qml +++ b/Linphone/view/Control/Display/Contact/Avatar.qml @@ -40,6 +40,11 @@ Loader{ : computedAvatarUri.length != 0 property var avatarObj: UtilsCpp.findAvatarByAddress(_address) property string computedAvatarUri: avatarObj ? avatarObj.value : '' + + // To get the secured property for a friend using an address to find it, + // override it as secured: friendSecurityLevel === LinphoneEnums.SecurityLevel.EndToEndEncryptedAndVerified + property var friendSecurityLevelObj: UtilsCpp.getFriendSecurityLevel(_address) + property var friendSecurityLevel: friendSecurityLevelObj ? securityLevelObj.value : LinphoneEnums.SecurityLevel.None // To get the secured property for a specific address, // override it as secured: securityLevel === LinphoneEnums.SecurityLevel.EndToEndEncryptedAndVerified diff --git a/Linphone/view/Control/Display/Contact/ContactListItem.qml b/Linphone/view/Control/Display/Contact/ContactListItem.qml index 54cd73ea6..8386ca746 100644 --- a/Linphone/view/Control/Display/Contact/ContactListItem.qml +++ b/Linphone/view/Control/Display/Contact/ContactListItem.qml @@ -34,8 +34,7 @@ FocusScope { property real itemsRightMargin: Math.round(39 * DefaultStyle.dp) property var displayName: searchResultItem.core.fullName - property string initial: displayName ? displayName[0].toLocaleLowerCase( - ConstantsCpp.DefaultLocale) : '' + property var initial: displayName ? displayName[0].toLocaleLowerCase(ConstantsCpp.DefaultLocale) : '' signal clicked(var mouse) signal contactDeletionRequested(FriendGui contact) @@ -50,7 +49,7 @@ FocusScope { verticalAlignment: Text.AlignVCenter width: Math.round(20 * DefaultStyle.dp) opacity: previousInitial != mainItem.initial ? 1 : 0 - text: mainItem.initial + text: mainItem.initial || "" color: DefaultStyle.main2_400 font { pixelSize: Math.round(20 * DefaultStyle.dp) diff --git a/Linphone/view/Control/Display/Participant/ParticipantDeviceListView.qml b/Linphone/view/Control/Display/Participant/ParticipantDeviceListView.qml index 2151b2800..813043770 100644 --- a/Linphone/view/Control/Display/Participant/ParticipantDeviceListView.qml +++ b/Linphone/view/Control/Display/Participant/ParticipantDeviceListView.qml @@ -47,6 +47,7 @@ ListView { Layout.preferredWidth: Math.round(45 * DefaultStyle.dp) Layout.preferredHeight: Math.round(45 * DefaultStyle.dp) _address: modelData.core.address + secured: securityLevel === LinphoneEnums.SecurityLevel.EndToEndEncryptedAndVerified shadowEnabled: false } Text { diff --git a/Linphone/view/Control/Display/Participant/ParticipantListView.qml b/Linphone/view/Control/Display/Participant/ParticipantListView.qml index b97e7f3e3..adb575d9f 100644 --- a/Linphone/view/Control/Display/Participant/ParticipantListView.qml +++ b/Linphone/view/Control/Display/Participant/ParticipantListView.qml @@ -52,6 +52,7 @@ ListView { Layout.preferredWidth: Math.round(45 * DefaultStyle.dp) Layout.preferredHeight: Math.round(45 * DefaultStyle.dp) _address: modelData.core.sipAddress + secured: friendSecurityLevel === LinphoneEnums.SecurityLevel.EndToEndEncryptedAndVerified shadowEnabled: false } Text { diff --git a/Linphone/view/Control/Display/Sticker.qml b/Linphone/view/Control/Display/Sticker.qml index 5e90f7ae0..402a22e26 100644 --- a/Linphone/view/Control/Display/Sticker.qml +++ b/Linphone/view/Control/Display/Sticker.qml @@ -111,6 +111,7 @@ Item { call: !mainItem.previewEnabled ? mainItem.call : null displayNameVal: mainItem.displayName securityBreach: mainItem.securityBreach ? mainItem.securityBreach : securityLevel === LinphoneEnums.SecurityLevel.Unsafe + secured: securityLevel === LinphoneEnums.SecurityLevel.EndToEndEncryptedAndVerified } ColumnLayout{ id: joiningView diff --git a/Linphone/view/Control/Display/Text.qml b/Linphone/view/Control/Display/Text.qml index e302daef3..fa0b9df4b 100644 --- a/Linphone/view/Control/Display/Text.qml +++ b/Linphone/view/Control/Display/Text.qml @@ -10,7 +10,6 @@ Quick.Text { family: DefaultStyle.defaultFont pixelSize: Math.round(10 * DefaultStyle.dp) weight: Typography.p1.weight - bold: true } color: DefaultStyle.main2_600 wrapMode: Quick.Text.Wrap diff --git a/Linphone/view/Control/Popup/Notification/NotificationReceivedCall.qml b/Linphone/view/Control/Popup/Notification/NotificationReceivedCall.qml index 65d902f7f..7b423d85b 100644 --- a/Linphone/view/Control/Popup/Notification/NotificationReceivedCall.qml +++ b/Linphone/view/Control/Popup/Notification/NotificationReceivedCall.qml @@ -66,6 +66,7 @@ Notification { Layout.preferredHeight: Math.round(60 * DefaultStyle.dp) Layout.alignment: Qt.AlignHCenter call: mainItem.call + secured: securityLevel === LinphoneEnums.SecurityLevel.EndToEndEncryptedAndVerified isConference: mainItem.call && mainItem.call.core.isConference } ColumnLayout { diff --git a/Linphone/view/Page/Form/Meeting/AddParticipantsForm.qml b/Linphone/view/Page/Form/Meeting/AddParticipantsForm.qml index 271741601..4ebedefdb 100644 --- a/Linphone/view/Page/Form/Meeting/AddParticipantsForm.qml +++ b/Linphone/view/Page/Form/Meeting/AddParticipantsForm.qml @@ -50,6 +50,7 @@ FocusScope{ Layout.preferredHeight: Math.round(45 * DefaultStyle.dp) _address: modelData shadowEnabled: false + secured: friendSecurityLevel === LinphoneEnums.SecurityLevel.EndToEndEncryptedAndVerified } Text { Layout.fillWidth: true diff --git a/Linphone/view/Page/Form/Meeting/MeetingForm.qml b/Linphone/view/Page/Form/Meeting/MeetingForm.qml index 09d1ec86c..d16a78770 100644 --- a/Linphone/view/Page/Form/Meeting/MeetingForm.qml +++ b/Linphone/view/Page/Form/Meeting/MeetingForm.qml @@ -288,6 +288,7 @@ FocusScope { Layout.preferredWidth: Math.round(45 * DefaultStyle.dp) Layout.preferredHeight: Math.round(45 * DefaultStyle.dp) _address: modelData.address + secured: friendSecurityLevel === LinphoneEnums.SecurityLevel.EndToEndEncryptedAndVerified shadowEnabled: false } Text { diff --git a/Linphone/view/Page/Main/Meeting/MeetingPage.qml b/Linphone/view/Page/Main/Meeting/MeetingPage.qml index 729181964..7972ad6b4 100644 --- a/Linphone/view/Page/Main/Meeting/MeetingPage.qml +++ b/Linphone/view/Page/Main/Meeting/MeetingPage.qml @@ -764,6 +764,7 @@ AbstractMainPage { Layout.preferredWidth: Math.round(45 * DefaultStyle.dp) Layout.preferredHeight: Math.round(45 * DefaultStyle.dp) _address: mainItem.selectedConference && mainItem.selectedConference.core ? mainItem.selectedConference.core.organizerAddress : "" + secured: friendSecurityLevel === LinphoneEnums.SecurityLevel.EndToEndEncryptedAndVerified } Text { text: mainItem.selectedConference && mainItem.selectedConference.core ? mainItem.selectedConference.core.organizerName : "" @@ -801,6 +802,7 @@ AbstractMainPage { Layout.preferredWidth: Math.round(45 * DefaultStyle.dp) Layout.preferredHeight: Math.round(45 * DefaultStyle.dp) _address: modelData.address + secured: friendSecurityLevel === LinphoneEnums.SecurityLevel.EndToEndEncryptedAndVerified shadowEnabled: false } Text {