mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-07 14:44:01 +00:00
feat(ui/views/App/Settings/SettingsCallsChat): supports media encryption and lime
This commit is contained in:
parent
11b12e2d76
commit
234a8cc9dd
4 changed files with 120 additions and 23 deletions
|
|
@ -42,6 +42,34 @@ SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
|
|||
// Chat & calls.
|
||||
// =============================================================================
|
||||
|
||||
bool SettingsModel::getLimeIsSupported () const {
|
||||
return CoreManager::getInstance()->getCore()->limeAvailable();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
inline QVariant buildEncryptionDescription (SettingsModel::MediaEncryption encryption, const char *description) {
|
||||
return QVariantList() << encryption << description;
|
||||
}
|
||||
|
||||
QVariantList SettingsModel::getSupportedMediaEncryptions () const {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
QVariantList list;
|
||||
|
||||
if (core->mediaEncryptionSupported(linphone::MediaEncryptionDTLS))
|
||||
list << buildEncryptionDescription(MediaEncryptionDtls, "DTLS");
|
||||
|
||||
if (core->mediaEncryptionSupported(linphone::MediaEncryptionSRTP))
|
||||
list << buildEncryptionDescription(MediaEncryptionSrtp, "SRTP");
|
||||
|
||||
if (core->mediaEncryptionSupported(linphone::MediaEncryptionZRTP))
|
||||
list << buildEncryptionDescription(MediaEncryptionZrtp, "ZRTP");
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
SettingsModel::MediaEncryption SettingsModel::getMediaEncryption () const {
|
||||
return static_cast<SettingsModel::MediaEncryption>(
|
||||
CoreManager::getInstance()->getCore()->getMediaEncryption()
|
||||
|
|
@ -49,12 +77,41 @@ SettingsModel::MediaEncryption SettingsModel::getMediaEncryption () const {
|
|||
}
|
||||
|
||||
void SettingsModel::setMediaEncryption (MediaEncryption encryption) {
|
||||
if (encryption == getMediaEncryption())
|
||||
return;
|
||||
|
||||
if (encryption != SettingsModel::MediaEncryptionZrtp)
|
||||
setLimeState(SettingsModel::LimeStateDisabled);
|
||||
|
||||
CoreManager::getInstance()->getCore()->setMediaEncryption(
|
||||
static_cast<linphone::MediaEncryption>(encryption)
|
||||
);
|
||||
|
||||
emit mediaEncryptionChanged(encryption);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
SettingsModel::LimeState SettingsModel::getLimeState () const {
|
||||
return static_cast<SettingsModel::LimeState>(
|
||||
CoreManager::getInstance()->getCore()->limeEnabled()
|
||||
);
|
||||
}
|
||||
|
||||
void SettingsModel::setLimeState (LimeState state) {
|
||||
if (state == getLimeState())
|
||||
return;
|
||||
|
||||
if (state != SettingsModel::LimeStateDisabled)
|
||||
setMediaEncryption(SettingsModel::MediaEncryptionZrtp);
|
||||
|
||||
CoreManager::getInstance()->getCore()->enableLime(
|
||||
static_cast<linphone::LimeState>(state)
|
||||
);
|
||||
|
||||
emit limeStateChanged(state);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Network.
|
||||
// =============================================================================
|
||||
|
|
|
|||
|
|
@ -37,7 +37,11 @@ class SettingsModel : public QObject {
|
|||
|
||||
// Chat & calls. -------------------------------------------------------------
|
||||
|
||||
Q_PROPERTY(bool limeIsSupported READ getLimeIsSupported CONSTANT);
|
||||
Q_PROPERTY(QVariantList supportedMediaEncryptions READ getSupportedMediaEncryptions CONSTANT);
|
||||
|
||||
Q_PROPERTY(MediaEncryption mediaEncryption READ getMediaEncryption WRITE setMediaEncryption NOTIFY mediaEncryptionChanged);
|
||||
Q_PROPERTY(LimeState limeState READ getLimeState WRITE setLimeState NOTIFY limeStateChanged);
|
||||
|
||||
// Network. ------------------------------------------------------------------
|
||||
|
||||
|
|
@ -83,14 +87,22 @@ class SettingsModel : public QObject {
|
|||
|
||||
public:
|
||||
enum MediaEncryption {
|
||||
MediaEncryptionDtls = linphone::MediaEncryptionDTLS,
|
||||
MediaEncryptionNone = linphone::MediaEncryptionNone,
|
||||
MediaEncryptionDtls = linphone::MediaEncryptionDTLS,
|
||||
MediaEncryptionSrtp = linphone::MediaEncryptionSRTP,
|
||||
MediaEncryptionZrtp = linphone::MediaEncryptionZRTP
|
||||
};
|
||||
|
||||
Q_ENUM(MediaEncryption);
|
||||
|
||||
enum LimeState {
|
||||
LimeStateDisabled = linphone::LimeStateDisabled,
|
||||
LimeStateMandatory = linphone::LimeStateMandatory,
|
||||
LimeStatePreferred = linphone::LimeStatePreferred
|
||||
};
|
||||
|
||||
Q_ENUM(LimeState);
|
||||
|
||||
SettingsModel (QObject *parent = Q_NULLPTR);
|
||||
|
||||
// ===========================================================================
|
||||
|
|
@ -99,9 +111,15 @@ public:
|
|||
|
||||
// Chat & calls. -------------------------------------------------------------
|
||||
|
||||
bool getLimeIsSupported () const;
|
||||
QVariantList getSupportedMediaEncryptions () const;
|
||||
|
||||
MediaEncryption getMediaEncryption () const;
|
||||
void setMediaEncryption (MediaEncryption encryption);
|
||||
|
||||
LimeState getLimeState () const;
|
||||
void setLimeState (LimeState state);
|
||||
|
||||
// Network. ------------------------------------------------------------------
|
||||
|
||||
bool getUseSipInfoForDtmfs () const;
|
||||
|
|
@ -181,6 +199,7 @@ signals:
|
|||
// Chat & calls. -------------------------------------------------------------
|
||||
|
||||
void mediaEncryptionChanged (MediaEncryption encryption);
|
||||
void limeStateChanged (LimeState state);
|
||||
|
||||
// Network. ------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -18,29 +18,34 @@ TabContainer {
|
|||
width: parent.width
|
||||
|
||||
FormLine {
|
||||
visible: !!encryption.encryptions.length
|
||||
|
||||
FormGroup {
|
||||
label: qsTr('encryptionLabel')
|
||||
|
||||
ExclusiveButtons {
|
||||
property var _resolveButton
|
||||
texts: [
|
||||
qsTr('noEncryption'), // 0.
|
||||
'SRTP', // 1.
|
||||
'ZRTP', // 2.
|
||||
'DTLS' // 3.
|
||||
]
|
||||
id: encryption
|
||||
|
||||
Component.onCompleted: {
|
||||
var map = _resolveButton = {}
|
||||
map[SettingsModel.MediaEncryptionNone] = 0
|
||||
map[SettingsModel.MediaEncryptionSrtp] = 1
|
||||
map[SettingsModel.MediaEncryptionZrtp] = 2
|
||||
map[SettingsModel.MediaEncryptionDtls] = 3
|
||||
property var encryptions: (function () {
|
||||
var encryptions = SettingsModel.supportedMediaEncryptions
|
||||
if (encryptions.length) {
|
||||
encryptions.unshift([ SettingsModel.MediaEncryptionNone, qsTr('noEncryption') ])
|
||||
}
|
||||
|
||||
selectedButton = Utils.invert(map)[SettingsModel.mediaEncryption]
|
||||
return encryptions
|
||||
})()
|
||||
|
||||
texts: encryptions.map(function (value) {
|
||||
return value[1]
|
||||
})
|
||||
|
||||
onClicked: SettingsModel.mediaEncryption = encryptions[button][0]
|
||||
|
||||
Binding {
|
||||
property: 'selectedButton'
|
||||
target: encryption
|
||||
value: SettingsModel.mediaEncryption
|
||||
}
|
||||
|
||||
onClicked: SettingsModel.mediaEncryption = _resolveButton[button]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -77,15 +82,31 @@ TabContainer {
|
|||
}
|
||||
|
||||
FormLine {
|
||||
visible: SettingsModel.limeIsSupported
|
||||
|
||||
FormGroup {
|
||||
label: qsTr('encryptWithLimeLabel')
|
||||
|
||||
ExclusiveButtons {
|
||||
texts: [
|
||||
qsTr('limeDisabled'),
|
||||
qsTr('limeRequired'),
|
||||
qsTr('limePreferred')
|
||||
]
|
||||
id: lime
|
||||
|
||||
property var limeStates: ([
|
||||
[ SettingsModel.LimeStateDisabled, qsTr('limeDisabled') ],
|
||||
[ SettingsModel.LimeStateMandatory, qsTr('limeRequired') ],
|
||||
[ SettingsModel.LimeStatePreferred, qsTr('limePreferred') ]
|
||||
])
|
||||
|
||||
texts: limeStates.map(function (value) {
|
||||
return value[1]
|
||||
})
|
||||
|
||||
onClicked: SettingsModel.limeState = limeStates[button][0]
|
||||
|
||||
Binding {
|
||||
property: 'selectedButton'
|
||||
target: lime
|
||||
value: SettingsModel.limeState
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit e71c6a8c10b53bec9501eee689c7a37c27cc9ba7
|
||||
Subproject commit 8599aec3e5cf04afa3780885ffd78a3063abed22
|
||||
Loading…
Add table
Reference in a new issue