From 77cf08e99845f8147706b137f39d2cdc924e7a78 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 6 Jun 2017 14:31:26 +0200 Subject: [PATCH] feat(src/components/call/CallModel): add a tooltip on call encryption --- linphone-desktop/assets/languages/en.ts | 4 ++ linphone-desktop/assets/languages/fr.ts | 4 ++ linphone-desktop/src/Utils.hpp | 12 ++++++ .../src/components/call/CallModel.cpp | 38 +++++++++++-------- .../src/components/call/CallModel.hpp | 19 ++++++---- .../single-application/SingleApplication.cpp | 22 ++++------- .../ui/views/App/Calls/Incall.qml | 5 +++ .../App/Calls/ZrtpTokenAuthentication.qml | 4 +- 8 files changed, 67 insertions(+), 41 deletions(-) diff --git a/linphone-desktop/assets/languages/en.ts b/linphone-desktop/assets/languages/en.ts index 8fa8b42ee..01b7792a0 100644 --- a/linphone-desktop/assets/languages/en.ts +++ b/linphone-desktop/assets/languages/en.ts @@ -315,6 +315,10 @@ callErrorNotAcceptable + + noMediaEncryption + None + CallSipAddress diff --git a/linphone-desktop/assets/languages/fr.ts b/linphone-desktop/assets/languages/fr.ts index 55fbe0a16..f0827c41a 100644 --- a/linphone-desktop/assets/languages/fr.ts +++ b/linphone-desktop/assets/languages/fr.ts @@ -315,6 +315,10 @@ callErrorNotAcceptable + + noMediaEncryption + Aucun + CallSipAddress diff --git a/linphone-desktop/src/Utils.hpp b/linphone-desktop/src/Utils.hpp index ca058fa52..1ebcd0c71 100644 --- a/linphone-desktop/src/Utils.hpp +++ b/linphone-desktop/src/Utils.hpp @@ -27,6 +27,18 @@ // ============================================================================= +/* + * Define telling G++ that a 'break' statement has been deliberately omitted + * in switch block. + */ +#ifndef UTILS_NO_BREAK + #if defined(__GNUC__) && __GNUC__ >= 7 + #define UTILS_NO_BREAK __attribute__((fallthrough)) + #else + #define UTILS_NO_BREAK + #endif // if defined(__GNUC__) && __GNUC__ >= 7 +#endif // ifndef UTILS_NO_BREAK + namespace Utils { inline QString coreStringToAppString (const std::string &string) { return QString::fromLocal8Bit(string.c_str(), static_cast(string.size())); diff --git a/linphone-desktop/src/components/call/CallModel.cpp b/linphone-desktop/src/components/call/CallModel.cpp index 09bd8d44b..56ba5127a 100644 --- a/linphone-desktop/src/components/call/CallModel.cpp +++ b/linphone-desktop/src/components/call/CallModel.cpp @@ -504,18 +504,7 @@ void CallModel::verifyAuthenticationToken (bool verify) { // ----------------------------------------------------------------------------- CallModel::CallEncryption CallModel::getEncryption () const { - switch (mCall->getCurrentParams()->getMediaEncryption()) { - case linphone::MediaEncryptionSRTP: - return CallEncryptionSRTP; - case linphone::MediaEncryptionZRTP: - return CallEncryptionZRTP; - case linphone::MediaEncryptionDTLS: - return CallEncryptionDTLS; - case linphone::MediaEncryptionNone: - break; - } - - return CallEncryptionNone; + return static_cast(mCall->getCurrentParams()->getMediaEncryption()); } bool CallModel::isSecured () const { @@ -528,18 +517,35 @@ bool CallModel::isSecured () const { // ----------------------------------------------------------------------------- -QString CallModel::getLocalSAS () const { +QString CallModel::getLocalSas () const { QString token = ::Utils::coreStringToAppString(mCall->getAuthenticationToken()); return mCall->getDir() == linphone::CallDirIncoming ? token.left(2).toUpper() : token.right(2).toUpper(); } -QString CallModel::getRemoteSAS () const { +QString CallModel::getRemoteSas () const { QString token = ::Utils::coreStringToAppString(mCall->getAuthenticationToken()); return mCall->getDir() != linphone::CallDirIncoming ? token.left(2).toUpper() : token.right(2).toUpper(); } // ----------------------------------------------------------------------------- +QString CallModel::getSecuredString () const { + switch (mCall->getCurrentParams()->getMediaEncryption()) { + case linphone::MediaEncryptionSRTP: + return QStringLiteral("SRTP"); + case linphone::MediaEncryptionZRTP: + return QStringLiteral("ZRTP"); + case linphone::MediaEncryptionDTLS: + return QStringLiteral("DTLS"); + case linphone::MediaEncryptionNone: + break; + } + + return tr("noMediaEncryption"); +} + +// ----------------------------------------------------------------------------- + QVariantList CallModel::getAudioStats () const { return mAudioStats; } @@ -619,8 +625,8 @@ void CallModel::updateStats (const shared_ptr &callSt statsList << createStat(tr("callStatsReceivedVideoDefinition"), receivedVideoDefinition == receivedVideoDefinitionName ? receivedVideoDefinition : QString("%1 (%2)").arg(receivedVideoDefinition).arg(receivedVideoDefinitionName)); - } - break; + } break; + default: break; } diff --git a/linphone-desktop/src/components/call/CallModel.hpp b/linphone-desktop/src/components/call/CallModel.hpp index ad7aec7d2..03d3c0cc7 100644 --- a/linphone-desktop/src/components/call/CallModel.hpp +++ b/linphone-desktop/src/components/call/CallModel.hpp @@ -57,8 +57,9 @@ class CallModel : public QObject { Q_PROPERTY(CallEncryption encryption READ getEncryption NOTIFY securityUpdated); Q_PROPERTY(bool isSecured READ isSecured NOTIFY securityUpdated); - Q_PROPERTY(QString localSAS READ getLocalSAS NOTIFY securityUpdated); - Q_PROPERTY(QString remoteSAS READ getRemoteSAS NOTIFY securityUpdated); + Q_PROPERTY(QString localSas READ getLocalSas NOTIFY securityUpdated); + Q_PROPERTY(QString remoteSas READ getRemoteSas NOTIFY securityUpdated); + Q_PROPERTY(QString securedString READ getSecuredString NOTIFY securityUpdated); public: enum CallStatus { @@ -73,10 +74,10 @@ public: Q_ENUM(CallStatus); enum CallEncryption { - CallEncryptionNone, - CallEncryptionSRTP, - CallEncryptionZRTP, - CallEncryptionDTLS + CallEncryptionNone = linphone::MediaEncryptionNone, + CallEncryptionDtls = linphone::MediaEncryptionDTLS, + CallEncryptionSrtp = linphone::MediaEncryptionSRTP, + CallEncryptionZrtp = linphone::MediaEncryptionZRTP }; Q_ENUM(CallEncryption); @@ -165,8 +166,10 @@ private: CallEncryption getEncryption () const; bool isSecured () const; - QString getLocalSAS () const; - QString getRemoteSAS () const; + QString getLocalSas () const; + QString getRemoteSas () const; + + QString getSecuredString () const; QVariantList getAudioStats () const; QVariantList getVideoStats () const; diff --git a/linphone-desktop/src/externals/single-application/SingleApplication.cpp b/linphone-desktop/src/externals/single-application/SingleApplication.cpp index c45f64234..dc1591683 100644 --- a/linphone-desktop/src/externals/single-application/SingleApplication.cpp +++ b/linphone-desktop/src/externals/single-application/SingleApplication.cpp @@ -43,6 +43,8 @@ #include #endif // ifdef Q_OS_WIN +#include "../../Utils.hpp" + #include "SingleApplication.hpp" #include "SingleApplicationPrivate.hpp" @@ -302,7 +304,7 @@ void SingleApplicationPrivate::slotConnectionEstablished () { tmp = nextConnSocket->read(checksum.length()); if (checksum == tmp) break; // Otherwise set to invalid connection (next line) - } + } UTILS_NO_BREAK; default: connectionType = InvalidConnection; } @@ -315,23 +317,13 @@ void SingleApplicationPrivate::slotConnectionEstablished () { return; } - QObject::connect( - nextConnSocket, - &QLocalSocket::aboutToClose, - this, - [nextConnSocket, instanceId, this]() { + QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose, this, [nextConnSocket, instanceId, this]() { Q_EMIT this->slotClientConnectionClosed(nextConnSocket, instanceId); - } - ); + }); - QObject::connect( - nextConnSocket, - &QLocalSocket::readyRead, - this, - [nextConnSocket, instanceId, this]() { + QObject::connect(nextConnSocket, &QLocalSocket::readyRead, this, [nextConnSocket, instanceId, this]() { Q_EMIT this->slotDataAvailable(nextConnSocket, instanceId); - } - ); + }); if (connectionType == NewInstance || ( connectionType == SecondaryInstance && diff --git a/linphone-desktop/ui/views/App/Calls/Incall.qml b/linphone-desktop/ui/views/App/Calls/Incall.qml index 97b32de6c..875acad4b 100644 --- a/linphone-desktop/ui/views/App/Calls/Incall.qml +++ b/linphone-desktop/ui/views/App/Calls/Incall.qml @@ -107,7 +107,12 @@ Rectangle { id: callSecure icon: incall.call.isSecured ? 'call_chat_secure' : 'call_chat_unsecure' + onClicked: zrtp.visible = (incall.call.encryption === CallModel.CallEncryptionZRTP) + + TooltipArea { + text: incall.call.securedString + } } } diff --git a/linphone-desktop/ui/views/App/Calls/ZrtpTokenAuthentication.qml b/linphone-desktop/ui/views/App/Calls/ZrtpTokenAuthentication.qml index 8e7103e19..aa7f77185 100644 --- a/linphone-desktop/ui/views/App/Calls/ZrtpTokenAuthentication.qml +++ b/linphone-desktop/ui/views/App/Calls/ZrtpTokenAuthentication.qml @@ -62,7 +62,7 @@ ColumnLayout { pointSize: CallStyle.zrtpArea.text.fontSize } - text: zrtp.call.localSAS + text: zrtp.call.localSas } Text { @@ -85,7 +85,7 @@ ColumnLayout { pointSize: CallStyle.zrtpArea.text.fontSize } - text: zrtp.call.remoteSAS + text: zrtp.call.remoteSas } }