mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Align account parameter setting with Android + sdk crash workaround
This commit is contained in:
parent
017b22bcc7
commit
0acb7b6736
4 changed files with 21 additions and 55 deletions
|
|
@ -189,8 +189,10 @@ void AccountModel::setNotificationsAllowed(bool value) {
|
|||
void AccountModel::setMwiServerAddress(QString value) {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
auto params = mMonitor->getParams()->clone();
|
||||
auto address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(value));
|
||||
if (address) {
|
||||
auto address = value.isEmpty()
|
||||
? nullptr
|
||||
: CoreModel::getInstance()->getCore()->interpretUrl(Utils::appStringToCoreString(value), false);
|
||||
if (value.isEmpty() || address) {
|
||||
params->setMwiServerAddress(address);
|
||||
mMonitor->setParams(params);
|
||||
emit mwiServerAddressChanged(value);
|
||||
|
|
@ -208,7 +210,7 @@ void AccountModel::setTransport(linphone::TransportType value) {
|
|||
void AccountModel::setServerAddress(QString value) {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
auto params = mMonitor->getParams()->clone();
|
||||
auto address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(value));
|
||||
auto address = CoreModel::getInstance()->getCore()->interpretUrl(Utils::appStringToCoreString(value), false);
|
||||
if (address) {
|
||||
params->setServerAddress(address);
|
||||
mMonitor->setParams(params);
|
||||
|
|
@ -230,6 +232,7 @@ void AccountModel::setStunServer(QString value) {
|
|||
auto policy = params->getNatPolicy();
|
||||
if (!policy) policy = mMonitor->getCore()->createNatPolicy();
|
||||
policy->setStunServer(Utils::appStringToCoreString(value));
|
||||
policy->enableStun(!value.isEmpty());
|
||||
params->setNatPolicy(policy);
|
||||
mMonitor->setParams(params);
|
||||
emit stunServerChanged(value);
|
||||
|
|
@ -273,8 +276,10 @@ void AccountModel::setExpire(int value) {
|
|||
void AccountModel::setConferenceFactoryAddress(QString value) {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
auto params = mMonitor->getParams()->clone();
|
||||
auto address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(value));
|
||||
if (address) {
|
||||
auto address = value.isEmpty()
|
||||
? nullptr
|
||||
: CoreModel::getInstance()->getCore()->interpretUrl(Utils::appStringToCoreString(value), false);
|
||||
if (value.isEmpty() || address) {
|
||||
params->setConferenceFactoryAddress(address);
|
||||
mMonitor->setParams(params);
|
||||
emit conferenceFactoryAddressChanged(value);
|
||||
|
|
@ -284,8 +289,10 @@ void AccountModel::setConferenceFactoryAddress(QString value) {
|
|||
void AccountModel::setAudioVideoConferenceFactoryAddress(QString value) {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
auto params = mMonitor->getParams()->clone();
|
||||
auto address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(value));
|
||||
if (address) {
|
||||
auto address = value.isEmpty()
|
||||
? nullptr
|
||||
: CoreModel::getInstance()->getCore()->interpretUrl(Utils::appStringToCoreString(value), false);
|
||||
if (value.isEmpty() || address) {
|
||||
params->setAudioVideoConferenceFactoryAddress(address);
|
||||
mMonitor->setParams(params);
|
||||
emit audioVideoConferenceFactoryAddressChanged(value);
|
||||
|
|
@ -296,7 +303,6 @@ void AccountModel::setAudioVideoConferenceFactoryAddress(QString value) {
|
|||
void AccountModel::setLimeServerUrl(QString value) {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
auto params = mMonitor->getParams()->clone();
|
||||
auto address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(value));
|
||||
params->setLimeServerUrl(Utils::appStringToCoreString(value));
|
||||
mMonitor->setParams(params);
|
||||
emit limeServerUrlChanged(value);
|
||||
|
|
@ -323,8 +329,10 @@ bool AccountModel::getShowMwi() {
|
|||
void AccountModel::setVoicemailAddress(QString value) {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
auto params = mMonitor->getParams()->clone();
|
||||
auto address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(value));
|
||||
if (address) {
|
||||
auto address = value.isEmpty()
|
||||
? nullptr
|
||||
: CoreModel::getInstance()->getCore()->interpretUrl(Utils::appStringToCoreString(value), false);
|
||||
if (value.isEmpty() || address) {
|
||||
params->setVoicemailAddress(address);
|
||||
mMonitor->setParams(params);
|
||||
emit voicemailAddressChanged(value);
|
||||
|
|
|
|||
|
|
@ -339,33 +339,6 @@ VariantObject *Utils::interpretUrl(QString uri) {
|
|||
return data;
|
||||
}
|
||||
|
||||
VariantObject *Utils::isValidSIPAddress(QString uri) {
|
||||
VariantObject *data = new VariantObject(QVariant(false));
|
||||
if (!data) return nullptr;
|
||||
data->makeRequest([uri]() -> QVariant {
|
||||
return QVariant(linphone::Factory::get()->createAddress(Utils::appStringToCoreString(uri)) != nullptr);
|
||||
});
|
||||
data->requestValue();
|
||||
return data;
|
||||
}
|
||||
|
||||
bool Utils::isValidIPAddress(const QString &host) {
|
||||
QHostAddress address;
|
||||
return address.setAddress(host);
|
||||
}
|
||||
|
||||
bool Utils::isValidHostname(const QString &hostname) {
|
||||
QRegularExpression regex("^[a-zA-Z0-9]([a-zA-Z0-9-]{0,62}[a-zA-Z0-9])?$");
|
||||
QStringList labels = hostname.split('.');
|
||||
if (labels.size() > 127) // More than 127 labels is invalid
|
||||
return false;
|
||||
foreach (const QString &label, labels) {
|
||||
if (!regex.match(label).hasMatch() || label.length() > 63) // Label length must be between 1 and 63
|
||||
return false;
|
||||
}
|
||||
return hostname.length() <= 253; // Total length should be <= 253
|
||||
}
|
||||
|
||||
bool Utils::isValidURL(const QString &url) {
|
||||
return QUrl(url).isValid();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,9 +117,6 @@ public:
|
|||
Q_INVOKABLE static int timeOffset(QDateTime start, QDateTime end);
|
||||
Q_INVOKABLE static int daysOffset(QDateTime start, QDateTime end);
|
||||
Q_INVOKABLE static VariantObject *interpretUrl(QString uri);
|
||||
Q_INVOKABLE static VariantObject *isValidSIPAddress(QString uri);
|
||||
Q_INVOKABLE static bool isValidIPAddress(const QString &host);
|
||||
Q_INVOKABLE static bool isValidHostname(const QString &hostname);
|
||||
Q_INVOKABLE static bool isValidURL(const QString &url);
|
||||
Q_INVOKABLE static VariantObject *findAvatarByAddress(const QString &address);
|
||||
Q_INVOKABLE static VariantObject *findFriendByAddress(const QString &address);
|
||||
|
|
|
|||
|
|
@ -36,16 +36,14 @@ AbstractSettingsLayout {
|
|||
propertyName: "mwiServerAddress"
|
||||
propertyOwner: account.core
|
||||
title: qsTr("URI du serveur de messagerie vocale")
|
||||
isValid: function(text) { return UtilsCpp.isValidSIPAddress(text); }
|
||||
toValidate: true
|
||||
Layout.fillWidth: true
|
||||
isValid: function(text) { return text.length == 0 || !text.endsWith(".") } // work around sdk crash when adress ends with .
|
||||
toValidate: true
|
||||
}
|
||||
DecoratedTextField {
|
||||
propertyName: "voicemailAddress"
|
||||
propertyOwner: account.core
|
||||
title: qsTr("URI de messagerie vocale")
|
||||
isValid: function(text) { return UtilsCpp.isValidSIPAddress(text); }
|
||||
toValidate: true
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
|
@ -76,8 +74,6 @@ AbstractSettingsLayout {
|
|||
title: qsTr("URL du serveur mandataire")
|
||||
propertyName: "serverAddress"
|
||||
propertyOwner: account.core
|
||||
isValid: function(text) { return UtilsCpp.isValidSIPAddress(text); }
|
||||
toValidate: true
|
||||
}
|
||||
SwitchSetting {
|
||||
titleText: qsTr("Serveur mandataire sortant")
|
||||
|
|
@ -89,8 +85,6 @@ AbstractSettingsLayout {
|
|||
propertyName: "stunServer"
|
||||
propertyOwner: account.core
|
||||
title: qsTr("Adresse du serveur STUN")
|
||||
isValid: function(text) { return UtilsCpp.isValidIPAddress(text) || UtilsCpp.isValidHostname(text); }
|
||||
toValidate: true
|
||||
}
|
||||
SwitchSetting {
|
||||
titleText: qsTr("Activer ICE")
|
||||
|
|
@ -113,7 +107,7 @@ AbstractSettingsLayout {
|
|||
propertyOwner: account.core
|
||||
title: qsTr("Expiration (en seconde)")
|
||||
canBeEmpty: false
|
||||
isValid: function(text) { return !isNaN(Number(text)); }
|
||||
isValid: function(text) { return !isNaN(Number(text)) }
|
||||
toValidate: true
|
||||
}
|
||||
DecoratedTextField {
|
||||
|
|
@ -121,25 +115,19 @@ AbstractSettingsLayout {
|
|||
title: qsTr("URI de l’usine à conversations")
|
||||
propertyName: "conferenceFactoryAddress"
|
||||
propertyOwner: account.core
|
||||
isValid: function(text) { return UtilsCpp.isValidSIPAddress(text); }
|
||||
toValidate: true
|
||||
}
|
||||
DecoratedTextField {
|
||||
Layout.fillWidth: true
|
||||
title: qsTr("URI de l’usine à réunions")
|
||||
propertyName: "audioVideoConferenceFactoryAddress"
|
||||
propertyOwner: account.core
|
||||
isValid: function(text) { return UtilsCpp.isValidSIPAddress(text); }
|
||||
visible: !SettingsCpp.disableMeetingsFeature
|
||||
toValidate: true
|
||||
}
|
||||
DecoratedTextField {
|
||||
Layout.fillWidth: true
|
||||
title: qsTr("URL du serveur d’échange de clés de chiffrement")
|
||||
propertyName: "limeServerUrl"
|
||||
propertyOwner: account.core
|
||||
isValid: function(text) { return UtilsCpp.isValidURL(text); }
|
||||
toValidate: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue