Commit 234a8cc9 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Settings/SettingsCallsChat): supports media encryption and lime

parent 11b12e2d
...@@ -42,6 +42,34 @@ SettingsModel::SettingsModel (QObject *parent) : QObject(parent) { ...@@ -42,6 +42,34 @@ SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
// Chat & calls. // 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 { SettingsModel::MediaEncryption SettingsModel::getMediaEncryption () const {
return static_cast<SettingsModel::MediaEncryption>( return static_cast<SettingsModel::MediaEncryption>(
CoreManager::getInstance()->getCore()->getMediaEncryption() CoreManager::getInstance()->getCore()->getMediaEncryption()
...@@ -49,12 +77,41 @@ SettingsModel::MediaEncryption SettingsModel::getMediaEncryption () const { ...@@ -49,12 +77,41 @@ SettingsModel::MediaEncryption SettingsModel::getMediaEncryption () const {
} }
void SettingsModel::setMediaEncryption (MediaEncryption encryption) { void SettingsModel::setMediaEncryption (MediaEncryption encryption) {
if (encryption == getMediaEncryption())
return;
if (encryption != SettingsModel::MediaEncryptionZrtp)
setLimeState(SettingsModel::LimeStateDisabled);
CoreManager::getInstance()->getCore()->setMediaEncryption( CoreManager::getInstance()->getCore()->setMediaEncryption(
static_cast<linphone::MediaEncryption>(encryption) static_cast<linphone::MediaEncryption>(encryption)
); );
emit mediaEncryptionChanged(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. // Network.
// ============================================================================= // =============================================================================
......
...@@ -37,7 +37,11 @@ class SettingsModel : public QObject { ...@@ -37,7 +37,11 @@ class SettingsModel : public QObject {
// Chat & calls. ------------------------------------------------------------- // 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(MediaEncryption mediaEncryption READ getMediaEncryption WRITE setMediaEncryption NOTIFY mediaEncryptionChanged);
Q_PROPERTY(LimeState limeState READ getLimeState WRITE setLimeState NOTIFY limeStateChanged);
// Network. ------------------------------------------------------------------ // Network. ------------------------------------------------------------------
...@@ -83,14 +87,22 @@ class SettingsModel : public QObject { ...@@ -83,14 +87,22 @@ class SettingsModel : public QObject {
public: public:
enum MediaEncryption { enum MediaEncryption {
MediaEncryptionDtls = linphone::MediaEncryptionDTLS,
MediaEncryptionNone = linphone::MediaEncryptionNone, MediaEncryptionNone = linphone::MediaEncryptionNone,
MediaEncryptionDtls = linphone::MediaEncryptionDTLS,
MediaEncryptionSrtp = linphone::MediaEncryptionSRTP, MediaEncryptionSrtp = linphone::MediaEncryptionSRTP,
MediaEncryptionZrtp = linphone::MediaEncryptionZRTP MediaEncryptionZrtp = linphone::MediaEncryptionZRTP
}; };
Q_ENUM(MediaEncryption); Q_ENUM(MediaEncryption);
enum LimeState {
LimeStateDisabled = linphone::LimeStateDisabled,
LimeStateMandatory = linphone::LimeStateMandatory,
LimeStatePreferred = linphone::LimeStatePreferred
};
Q_ENUM(LimeState);
SettingsModel (QObject *parent = Q_NULLPTR); SettingsModel (QObject *parent = Q_NULLPTR);
// =========================================================================== // ===========================================================================
...@@ -99,9 +111,15 @@ public: ...@@ -99,9 +111,15 @@ public:
// Chat & calls. ------------------------------------------------------------- // Chat & calls. -------------------------------------------------------------
bool getLimeIsSupported () const;
QVariantList getSupportedMediaEncryptions () const;
MediaEncryption getMediaEncryption () const; MediaEncryption getMediaEncryption () const;
void setMediaEncryption (MediaEncryption encryption); void setMediaEncryption (MediaEncryption encryption);
LimeState getLimeState () const;
void setLimeState (LimeState state);
// Network. ------------------------------------------------------------------ // Network. ------------------------------------------------------------------
bool getUseSipInfoForDtmfs () const; bool getUseSipInfoForDtmfs () const;
...@@ -181,6 +199,7 @@ signals: ...@@ -181,6 +199,7 @@ signals:
// Chat & calls. ------------------------------------------------------------- // Chat & calls. -------------------------------------------------------------
void mediaEncryptionChanged (MediaEncryption encryption); void mediaEncryptionChanged (MediaEncryption encryption);
void limeStateChanged (LimeState state);
// Network. ------------------------------------------------------------------ // Network. ------------------------------------------------------------------
......
...@@ -18,29 +18,34 @@ TabContainer { ...@@ -18,29 +18,34 @@ TabContainer {
width: parent.width width: parent.width
FormLine { FormLine {
visible: !!encryption.encryptions.length
FormGroup { FormGroup {
label: qsTr('encryptionLabel') label: qsTr('encryptionLabel')
ExclusiveButtons { ExclusiveButtons {
property var _resolveButton id: encryption
texts: [
qsTr('noEncryption'), // 0. property var encryptions: (function () {
'SRTP', // 1. var encryptions = SettingsModel.supportedMediaEncryptions
'ZRTP', // 2. if (encryptions.length) {
'DTLS' // 3. encryptions.unshift([ SettingsModel.MediaEncryptionNone, qsTr('noEncryption') ])
] }
Component.onCompleted: { return encryptions
var map = _resolveButton = {} })()
map[SettingsModel.MediaEncryptionNone] = 0
map[SettingsModel.MediaEncryptionSrtp] = 1
map[SettingsModel.MediaEncryptionZrtp] = 2
map[SettingsModel.MediaEncryptionDtls] = 3
selectedButton = Utils.invert(map)[SettingsModel.mediaEncryption]
}
onClicked: SettingsModel.mediaEncryption = _resolveButton[button] texts: encryptions.map(function (value) {
return value[1]
})
onClicked: SettingsModel.mediaEncryption = encryptions[button][0]
Binding {
property: 'selectedButton'
target: encryption
value: SettingsModel.mediaEncryption
}
} }
} }
} }
...@@ -77,15 +82,31 @@ TabContainer { ...@@ -77,15 +82,31 @@ TabContainer {
} }
FormLine { FormLine {
visible: SettingsModel.limeIsSupported
FormGroup { FormGroup {
label: qsTr('encryptWithLimeLabel') label: qsTr('encryptWithLimeLabel')
ExclusiveButtons { ExclusiveButtons {
texts: [ id: lime
qsTr('limeDisabled'),
qsTr('limeRequired'), property var limeStates: ([
qsTr('limePreferred') [ 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
}
} }
} }
} }
......
linphone @ 8599aec3
Subproject commit e71c6a8c10b53bec9501eee689c7a37c27cc9ba7 Subproject commit 8599aec3e5cf04afa3780885ffd78a3063abed22
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment