From 1c265b71cc4f009fc6171b38af7f4f8a498b148e Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Tue, 24 Aug 2021 19:52:10 +0200 Subject: [PATCH] Add forgotten password link --- linphone-app/src/app/App.cpp | 1 + linphone-app/src/utils/Constants.cpp | 1 + linphone-app/src/utils/Constants.hpp | 4 +- .../App/Main/Assistant/UseAppSipAccount.qml | 247 ++++++++++-------- 4 files changed, 139 insertions(+), 114 deletions(-) diff --git a/linphone-app/src/app/App.cpp b/linphone-app/src/app/App.cpp index 9e410cea8..ada828a34 100644 --- a/linphone-app/src/app/App.cpp +++ b/linphone-app/src/app/App.cpp @@ -673,6 +673,7 @@ void App::registerToolTypes () { registerToolType("Units"); registerToolType("ContactsImporterPluginsManager"); registerToolType("UtilsCpp"); + registerToolType("ConstantsCpp"); //registerToolType("ColorsCpp"); } diff --git a/linphone-app/src/utils/Constants.cpp b/linphone-app/src/utils/Constants.cpp index 3f857c53c..588dcef08 100644 --- a/linphone-app/src/utils/Constants.cpp +++ b/linphone-app/src/utils/Constants.cpp @@ -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[]; diff --git a/linphone-app/src/utils/Constants.hpp b/linphone-app/src/utils/Constants.hpp index 20a55647c..132d79492 100644 --- a/linphone-app/src/utils/Constants.hpp +++ b/linphone-app/src/utils/Constants.hpp @@ -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. diff --git a/linphone-app/ui/views/App/Main/Assistant/UseAppSipAccount.qml b/linphone-app/ui/views/App/Main/Assistant/UseAppSipAccount.qml index 09573d1d4..daf1c9792 100644 --- a/linphone-app/ui/views/App/Main/Assistant/UseAppSipAccount.qml +++ b/linphone-app/ui/views/App/Main/Assistant/UseAppSipAccount.qml @@ -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: ''+qsTr("passwordRecovery")+'' + + 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 + } }