Add forgotten password link

This commit is contained in:
Julien Wadel 2021-08-24 19:52:10 +02:00
parent 12e1726da4
commit 1c265b71cc
4 changed files with 139 additions and 114 deletions

View file

@ -673,6 +673,7 @@ void App::registerToolTypes () {
registerToolType<Units>("Units");
registerToolType<ContactsImporterPluginsManager>("ContactsImporterPluginsManager");
registerToolType<Utils>("UtilsCpp");
registerToolType<Constants>("ConstantsCpp");
//registerToolType<Colors>("ColorsCpp");
}

View file

@ -96,6 +96,7 @@ constexpr char Constants::LinphoneDomain[];
constexpr char Constants::DefaultContactParameters[];
constexpr int Constants::DefaultExpires;
constexpr char Constants::DownloadUrl[];
constexpr char Constants::PasswordRecoveryUrl[];
constexpr char Constants::LinphoneBZip2_exe[];

View file

@ -54,7 +54,8 @@ public:
static constexpr char DefaultContactParameters[] = "message-expires=604800";
static constexpr int DefaultExpires = 3600;
static constexpr char DownloadUrl[] = "https://www.linphone.org/technical-corner/linphone";
static constexpr char PasswordRecoveryUrl[] = "https://subscribe.linphone.org/login";
Q_PROPERTY(QString PasswordRecoveryUrl MEMBER PasswordRecoveryUrl CONSTANT)
static constexpr char LinphoneBZip2_exe[] = "http://www.linphone.org/releases/windows/tools/bzip2/bzip2.exe";
static constexpr char LinphoneBZip2_dll[] = "http://www.linphone.org/releases/windows/tools/bzip2/bzip2.dll";
@ -62,6 +63,7 @@ public:
static constexpr char DefaultLogsEmail[] = "linphone-desktop@belledonne-communications.com";
static constexpr char DefaultConferenceURI[] = "sip:conference-factory@sip.linphone.org";
// Max image size in bytes. (100Kb)
static constexpr qint64 MaxImageSize = 102400;// In Bytes.
static constexpr qint64 FileSizeLimit = 524288000;// In Bytes.

View file

@ -3,123 +3,144 @@ import QtQuick 2.7
import Common 1.0
import Linphone 1.0
import LinphoneUtils 1.0
import ConstantsCpp 1.0
import App.Styles 1.0
// =============================================================================
AssistantAbstractView {
id: view
readonly property bool usePhoneNumber: SettingsModel.assistantSupportsPhoneNumbers && !checkBox.checked
mainAction: requestBlock.execute
mainActionEnabled: {
var item = loader.item
return item && item.mainActionEnabled && !requestBlock.loading
}
mainActionLabel: qsTr('confirmAction')
title: qsTr('useAppSipAccountTitle').replace('%1', Qt.application.name.toUpperCase())
// ---------------------------------------------------------------------------
Column {
anchors.fill: parent
Loader {
id: loader
source: 'UseAppSipAccountWith' + (view.usePhoneNumber ? 'PhoneNumber' : 'Username') + '.qml'
width: parent.width
}
CheckBoxText {
id: checkBox
text: qsTr('useUsernameToLogin')
visible: SettingsModel.assistantSupportsPhoneNumbers
width: UseAppSipAccountStyle.checkBox.width
onClicked: {
assistantModel.reset()
requestBlock.stop('')
if (!checked) {
assistantModel.setCountryCode(telephoneNumbersModel.defaultIndex)
}
}
}
RequestBlock {
id: requestBlock
action: assistantModel.login
width: parent.width
}
}
// ---------------------------------------------------------------------------
// Assistant.
// ---------------------------------------------------------------------------
AssistantModel {
id: assistantModel
function setCountryCode (index) {
var model = telephoneNumbersModel
assistantModel.countryCode = index !== -1 ? model.data(model.index(index, 0)).countryCode : ''
}
configFilename: 'use-app-sip-account.rc'
countryCode: setCountryCode(view.usePhoneNumber ? telephoneNumbersModel.defaultIndex : -1)
onPasswordChanged: {
if (!view.usePhoneNumber) {
loader.item.passwordError = error
}
}
onPhoneNumberChanged: {
if (view.usePhoneNumber) {
loader.item.phoneNumberError = error
}
}
onLoginStatusChanged: {
requestBlock.stop(error)
if (!error.length) {
var codecInfo = VideoCodecsModel.getCodecInfo('H264')
if (codecInfo.downloadUrl) {
LinphoneUtils.openCodecOnlineInstallerDialog(window, codecInfo, function cb (window) {
window.setView('Home')
})
} else {
window.setView('Home')
}
}
}
onRecoverStatusChanged: {
if (!view.usePhoneNumber) {
requestBlock.stop('')
return
}
requestBlock.stop(error)
if (!error.length) {
window.lockView({
descriptionText: qsTr('quitWarning')
})
assistant.pushView('ActivateAppSipAccountWithPhoneNumber', {
assistantModel: assistantModel
})
}
}
}
TelephoneNumbersModel {
id: telephoneNumbersModel
}
id: view
readonly property bool usePhoneNumber: SettingsModel.assistantSupportsPhoneNumbers && !checkBox.checked
mainAction: requestBlock.execute
mainActionEnabled: {
var item = loader.item
return item && item.mainActionEnabled && !requestBlock.loading
}
mainActionLabel: qsTr('confirmAction')
title: qsTr('useAppSipAccountTitle').replace('%1', Qt.application.name.toUpperCase())
// ---------------------------------------------------------------------------
Column {
anchors.fill: parent
Loader {
id: loader
source: 'UseAppSipAccountWith' + (view.usePhoneNumber ? 'PhoneNumber' : 'Username') + '.qml'
width: parent.width
}
CheckBoxText {
id: checkBox
text: qsTr('useUsernameToLogin')
visible: SettingsModel.assistantSupportsPhoneNumbers
width: UseAppSipAccountStyle.checkBox.width
onClicked: {
assistantModel.reset()
requestBlock.stop('')
if (!checked) {
assistantModel.setCountryCode(telephoneNumbersModel.defaultIndex)
}
}
}
Text {
anchors.right:parent.right
elide: Text.ElideRight
font.pointSize: AboutStyle.copyrightBlock.url.pointSize
linkColor: AboutStyle.copyrightBlock.url.color
//: 'Forgotten password?' : text for an url shortcut to change the password
text: '<a href="'+ConstantsCpp.PasswordRecoveryUrl+'">'+qsTr("passwordRecovery")+'</a>'
horizontalAlignment: Text.AlignHCenter
onLinkActivated: Qt.openUrlExternally(link)
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
cursorShape: parent.hoveredLink
? Qt.PointingHandCursor
: Qt.IBeamCursor
}
}
RequestBlock {
id: requestBlock
action: assistantModel.login
width: parent.width
}
}
// ---------------------------------------------------------------------------
// Assistant.
// ---------------------------------------------------------------------------
AssistantModel {
id: assistantModel
function setCountryCode (index) {
var model = telephoneNumbersModel
assistantModel.countryCode = index !== -1 ? model.data(model.index(index, 0)).countryCode : ''
}
configFilename: 'use-app-sip-account.rc'
countryCode: setCountryCode(view.usePhoneNumber ? telephoneNumbersModel.defaultIndex : -1)
onPasswordChanged: {
if (!view.usePhoneNumber) {
loader.item.passwordError = error
}
}
onPhoneNumberChanged: {
if (view.usePhoneNumber) {
loader.item.phoneNumberError = error
}
}
onLoginStatusChanged: {
requestBlock.stop(error)
if (!error.length) {
var codecInfo = VideoCodecsModel.getCodecInfo('H264')
if (codecInfo.downloadUrl) {
LinphoneUtils.openCodecOnlineInstallerDialog(window, codecInfo, function cb (window) {
window.setView('Home')
})
} else {
window.setView('Home')
}
}
}
onRecoverStatusChanged: {
if (!view.usePhoneNumber) {
requestBlock.stop('')
return
}
requestBlock.stop(error)
if (!error.length) {
window.lockView({
descriptionText: qsTr('quitWarning')
})
assistant.pushView('ActivateAppSipAccountWithPhoneNumber', {
assistantModel: assistantModel
})
}
}
}
TelephoneNumbersModel {
id: telephoneNumbersModel
}
}