From b6d4abe3eaa9c59c479d5efca43aabc21e2b3900 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Fri, 14 Oct 2022 11:47:14 +0200 Subject: [PATCH] Display security icon in conference. Use a loader for zrtp authentification to avoid useless memory (and keep the case if athentication code need to be restarted) --- .../src/components/call/CallModel.cpp | 10 +++++++-- linphone-app/ui/views/App/Calls/Incall.qml | 21 +++++++++--------- .../ui/views/App/Calls/IncallFullscreen.qml | 22 +++++++++++-------- .../App/Calls/ZrtpTokenAuthentication.qml | 12 +++++++--- 4 files changed, 41 insertions(+), 24 deletions(-) diff --git a/linphone-app/src/components/call/CallModel.cpp b/linphone-app/src/components/call/CallModel.cpp index 78e3c6778..333f76ad0 100644 --- a/linphone-app/src/components/call/CallModel.cpp +++ b/linphone-app/src/components/call/CallModel.cpp @@ -1060,7 +1060,10 @@ bool CallModel::isSecured () const { QString CallModel::getLocalSas () const { if(mCall){ QString token = Utils::coreStringToAppString(mCall->getAuthenticationToken()); - return mCall->getDir() == linphone::Call::Dir::Incoming ? token.left(2).toUpper() : token.right(2).toUpper(); + if(token.isEmpty()) + return ""; + else + return mCall->getDir() == linphone::Call::Dir::Incoming ? token.left(2).toUpper() : token.right(2).toUpper(); }else return ""; } @@ -1068,7 +1071,10 @@ QString CallModel::getLocalSas () const { QString CallModel::getRemoteSas () const { if(mCall){ QString token = Utils::coreStringToAppString(mCall->getAuthenticationToken()); - return mCall->getDir() != linphone::Call::Dir::Incoming ? token.left(2).toUpper() : token.right(2).toUpper(); + if(token.isEmpty()) + return ""; + else + return mCall->getDir() != linphone::Call::Dir::Incoming ? token.left(2).toUpper() : token.right(2).toUpper(); }else return ""; } diff --git a/linphone-app/ui/views/App/Calls/Incall.qml b/linphone-app/ui/views/App/Calls/Incall.qml index 06bbd56fe..28114fd3d 100644 --- a/linphone-app/ui/views/App/Calls/Incall.qml +++ b/linphone-app/ui/views/App/Calls/Incall.qml @@ -374,20 +374,22 @@ Rectangle { } } } - - ZrtpTokenAuthentication { + Loader{ id: zrtp - + active: call && !call.isSecured && call.encryption === CallModel.CallEncryptionZrtp anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: actionsButtons.top anchors.leftMargin: CallStyle.container.margins anchors.rightMargin: CallStyle.container.margins anchors.bottomMargin: CallStyle.container.margins - height: visible ? implicitHeight : 0 - - call: callModel - visible: !call.isSecured && call.encryption !== CallModel.CallEncryptionNone - z: Constants.zPopup + height: active ? implicitHeight : 0 + sourceComponent:Component{ + ZrtpTokenAuthentication { + call: callModel + z: Constants.zPopup + onClose: {zrtp.active = false} + } + } } // ------------------------------------------------------------------------- // Action Buttons. @@ -396,7 +398,6 @@ Rectangle { // Security ActionButton{ id: securityButton - visible: callModel && !callModel.isConference anchors.left: parent.left anchors.verticalCenter: actionsButtons.verticalCenter anchors.leftMargin: 25 @@ -412,7 +413,7 @@ Rectangle { : IncallStyle.buttons.secure : IncallStyle.buttons.unsecure - onClicked: zrtp.visible = (callModel.encryption === CallModel.CallEncryptionZrtp) + onClicked: zrtp.active =(callModel.encryption === CallModel.CallEncryptionZrtp) tooltipText: Logic.makeReadableSecuredString(callModel.securedString) } diff --git a/linphone-app/ui/views/App/Calls/IncallFullscreen.qml b/linphone-app/ui/views/App/Calls/IncallFullscreen.qml index 67852707f..9d6b3b093 100644 --- a/linphone-app/ui/views/App/Calls/IncallFullscreen.qml +++ b/linphone-app/ui/views/App/Calls/IncallFullscreen.qml @@ -337,17 +337,21 @@ Window { // ------------------------------------------------------------------------- // Action Buttons. // ------------------------------------------------------------------------- - ZrtpTokenAuthentication { + + Loader{ id: zrtp - + active: call && !call.isSecured && call.encryption === CallModel.CallEncryptionZrtp anchors.horizontalCenter: parent.horizontalCenter - anchors.margins: CallStyle.container.margins anchors.bottom: actionsButtons.top - height: visible ? implicitHeight : 0 - - call: callModel - visible: !call.isSecured && call.encryption !== CallModel.CallEncryptionNone - z: Constants.zPopup + anchors.margins: CallStyle.container.margins + height: active ? implicitHeight : 0 + sourceComponent:Component{ + ZrtpTokenAuthentication { + call: callModel + z: Constants.zPopup + onClose: {zrtp.active = false} + } + } } // Security ActionButton{ @@ -363,7 +367,7 @@ Window { colorSet: callModel.isSecured ? IncallStyle.buttons.secure : IncallStyle.buttons.unsecure - onClicked: zrtp.visible = (callModel.encryption === CallModel.CallEncryptionZrtp) + onClicked: zrtp.active = (callModel.encryption === CallModel.CallEncryptionZrtp) tooltipText: Logic.makeReadableSecuredString(callModel.securedString) } diff --git a/linphone-app/ui/views/App/Calls/ZrtpTokenAuthentication.qml b/linphone-app/ui/views/App/Calls/ZrtpTokenAuthentication.qml index 26638a58e..75f7cff09 100644 --- a/linphone-app/ui/views/App/Calls/ZrtpTokenAuthentication.qml +++ b/linphone-app/ui/views/App/Calls/ZrtpTokenAuthentication.qml @@ -10,13 +10,17 @@ import App.Styles 1.0 Rectangle{ id: zrtp property var call - visible: false + property alias localSas: localSasText.text + property alias remoteSas : remoteSasText.text + + signal close() color:"transparent" implicitWidth: columnLayout.implicitWidth implicitHeight: columnLayout.implicitHeight+CallStyle.container.margins radius: 10 + Component.onCompleted: if( !localSas || !remoteSas) zrtp.close() ColumnLayout { id:columnLayout @@ -70,6 +74,7 @@ Rectangle{ } Text { + id: localSasText color: CallStyle.zrtpArea.text.colorB font { @@ -93,6 +98,7 @@ Rectangle{ } Text { + id: remoteSasText color: CallStyle.zrtpArea.text.colorB font { @@ -116,16 +122,16 @@ Rectangle{ TextButtonA { text: qsTr('deny') onClicked: { - zrtp.visible = false zrtp.call.verifyAuthenticationToken(false) + zrtp.close() } } TextButtonB { text: qsTr('accept') onClicked: { - zrtp.visible = false zrtp.call.verifyAuthenticationToken(true) + zrtp.close() } } }