mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-07 05:23:06 +00:00
feat(src/components/assistant): deal correctly with phone numbers
This commit is contained in:
parent
a9607f6ae2
commit
3633ee5009
9 changed files with 128 additions and 38 deletions
|
|
@ -12,7 +12,7 @@
|
|||
<name>ActivateLinphoneSipAccountWithEmail</name>
|
||||
<message>
|
||||
<source>activateLinphoneSipAccount</source>
|
||||
<translation>CREATE A LINPHONE ACCOUNT</translation>
|
||||
<translation>ACTIVATE A LINPHONE ACCOUNT</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>confirmAction</source>
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
<name>ActivateLinphoneSipAccountWithPhoneNumber</name>
|
||||
<message>
|
||||
<source>activateLinphoneSipAccount</source>
|
||||
<translation>CREATE A LINPHONE ACCOUNT</translation>
|
||||
<translation>ACTIVATE A LINPHONE ACCOUNT</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>confirmAction</source>
|
||||
|
|
@ -159,7 +159,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>smsActivationFailed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>SMS activation failed!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>emailActivationFailed</source>
|
||||
|
|
@ -181,6 +181,10 @@
|
|||
<source>phoneNumberStatusInvalidCountryCode</source>
|
||||
<translation>Invalid country code!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>loginWithPhoneNumberFailed</source>
|
||||
<translation>Login failed. Please check your phone number.</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AuthenticationRequest</name>
|
||||
|
|
@ -1341,6 +1345,10 @@ your friend's SIP address or username.</translation>
|
|||
<source>useUsernameToLogin</source>
|
||||
<translation>Use username and password rather than your phone number.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>quitWarning</source>
|
||||
<translation>Your account has been created but is not yet validated. Are you sure you want to quit this view?</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>UseLinphoneSipAccountWithPhoneNumber</name>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
<name>ActivateLinphoneSipAccountWithEmail</name>
|
||||
<message>
|
||||
<source>activateLinphoneSipAccount</source>
|
||||
<translation>CRÉER UN COMPTE LINPHONE</translation>
|
||||
<translation>ACTIVER UN COMPTE LINPHONE</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>confirmAction</source>
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
<name>ActivateLinphoneSipAccountWithPhoneNumber</name>
|
||||
<message>
|
||||
<source>activateLinphoneSipAccount</source>
|
||||
<translation>CRÉER UN COMPTE LINPHONE</translation>
|
||||
<translation>ACTIVER UN COMPTE LINPHONE</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>confirmAction</source>
|
||||
|
|
@ -159,7 +159,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>smsActivationFailed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>L'activation par SMS a échoué !</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>emailActivationFailed</source>
|
||||
|
|
@ -181,6 +181,10 @@
|
|||
<source>phoneNumberStatusInvalidCountryCode</source>
|
||||
<translation>Indicatif tél. invalide !</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>loginWithPhoneNumberFailed</source>
|
||||
<translation>La connection a échouée. Merci de vérifier votre numéro de tél.</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AuthenticationRequest</name>
|
||||
|
|
@ -1340,6 +1344,10 @@ un chat ou ajouter un contact.</translation>
|
|||
<source>useUsernameToLogin</source>
|
||||
<translation>Utiliser un nom et mot de passe plutôt que votre numéro de téléphone.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>quitWarning</source>
|
||||
<translation>Votre compte a été crée mais il n'a pas été validé. Êtes-vous sûr de vouloir quitter cette vue ?</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>UseLinphoneSipAccountWithPhoneNumber</name>
|
||||
|
|
|
|||
|
|
@ -75,16 +75,21 @@ private:
|
|||
}
|
||||
|
||||
void onActivateAccount (
|
||||
const shared_ptr<linphone::AccountCreator> &,
|
||||
const shared_ptr<linphone::AccountCreator> &creator,
|
||||
linphone::AccountCreatorStatus status,
|
||||
const string &
|
||||
) override {
|
||||
if (
|
||||
status == linphone::AccountCreatorStatusAccountActivated ||
|
||||
status == linphone::AccountCreatorStatusAccountAlreadyActivated
|
||||
)
|
||||
) {
|
||||
if (creator->getEmail().empty()) {
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = creator->createProxyConfig();
|
||||
Q_ASSERT(proxyConfig != nullptr);
|
||||
}
|
||||
|
||||
emit mAssistant->activateStatusChanged("");
|
||||
else {
|
||||
} else {
|
||||
if (status == linphone::AccountCreatorStatusRequestFailed)
|
||||
emit mAssistant->activateStatusChanged(tr("requestFailed"));
|
||||
else
|
||||
|
|
@ -110,6 +115,23 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void onRecoverAccount (
|
||||
const shared_ptr<linphone::AccountCreator> &,
|
||||
linphone::AccountCreatorStatus status,
|
||||
const string &
|
||||
) override {
|
||||
if (status == linphone::AccountCreatorStatusRequestOk) {
|
||||
emit mAssistant->recoverStatusChanged("");
|
||||
} else {
|
||||
if (status == linphone::AccountCreatorStatusRequestFailed)
|
||||
emit mAssistant->recoverStatusChanged(tr("requestFailed"));
|
||||
else if (status == linphone::AccountCreatorStatusServerError)
|
||||
emit mAssistant->recoverStatusChanged(tr("cannotSendSms"));
|
||||
else
|
||||
emit mAssistant->recoverStatusChanged(tr("loginWithPhoneNumberFailed"));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
AssistantModel *mAssistant;
|
||||
};
|
||||
|
|
@ -140,7 +162,10 @@ void AssistantModel::create () {
|
|||
}
|
||||
|
||||
void AssistantModel::login () {
|
||||
mAccountCreator->isAccountExist();
|
||||
if (mAccountCreator->getEmail().empty())
|
||||
mAccountCreator->recoverAccount();
|
||||
else
|
||||
mAccountCreator->isAccountExist();
|
||||
}
|
||||
|
||||
void AssistantModel::reset () {
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ signals:
|
|||
void activateStatusChanged (const QString &error);
|
||||
void createStatusChanged (const QString &error);
|
||||
void loginStatusChanged (const QString &error);
|
||||
void recoverStatusChanged (const QString &error);
|
||||
|
||||
void configFilenameChanged (const QString &configFilename);
|
||||
|
||||
|
|
|
|||
|
|
@ -97,13 +97,7 @@ AssistantAbstractView {
|
|||
RequestBlock {
|
||||
id: requestBlock
|
||||
|
||||
action: function () {
|
||||
window.lockView({
|
||||
descriptionText: qsTr('quitWarning')
|
||||
})
|
||||
assistantModel.create()
|
||||
}
|
||||
|
||||
action: assistantModel.create
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
|
@ -123,13 +117,16 @@ AssistantAbstractView {
|
|||
|
||||
onCreateStatusChanged: {
|
||||
requestBlock.stop(error)
|
||||
if (!error.length) {
|
||||
assistant.pushView('ActivateLinphoneSipAccountWithEmail', {
|
||||
assistantModel: assistantModel
|
||||
})
|
||||
} else {
|
||||
window.unlockView()
|
||||
if (error.length) {
|
||||
return
|
||||
}
|
||||
|
||||
window.lockView({
|
||||
descriptionText: qsTr('quitWarning')
|
||||
})
|
||||
assistant.pushView('ActivateLinphoneSipAccountWithEmail', {
|
||||
assistantModel: assistantModel
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,13 +96,7 @@ AssistantAbstractView {
|
|||
RequestBlock {
|
||||
id: requestBlock
|
||||
|
||||
action: function () {
|
||||
window.lockView({
|
||||
descriptionText: qsTr('quitWarning')
|
||||
})
|
||||
assistantModel.create()
|
||||
}
|
||||
|
||||
action: assistantModel.create
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
|
@ -123,13 +117,16 @@ AssistantAbstractView {
|
|||
|
||||
onCreateStatusChanged: {
|
||||
requestBlock.stop(error)
|
||||
if (!error.length) {
|
||||
assistant.pushView('ActivateLinphoneSipAccountWithPhoneNumber', {
|
||||
assistantModel: assistantModel
|
||||
})
|
||||
} else {
|
||||
window.unlockView()
|
||||
if (error.length) {
|
||||
return
|
||||
}
|
||||
|
||||
window.lockView({
|
||||
descriptionText: qsTr('quitWarning')
|
||||
})
|
||||
assistant.pushView('ActivateLinphoneSipAccountWithPhoneNumber', {
|
||||
assistantModel: assistantModel
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,14 +58,27 @@ AssistantAbstractView {
|
|||
AssistantModel {
|
||||
id: assistantModel
|
||||
|
||||
function setCountryCode (index) {
|
||||
var model = telephoneNumbersModel
|
||||
assistantModel.countryCode = model.data(model.index(index, 0)).countryCode
|
||||
}
|
||||
|
||||
configFilename: 'use-linphone-sip-account.rc'
|
||||
|
||||
countryCode: setCountryCode(telephoneNumbersModel.defaultIndex)
|
||||
|
||||
onPasswordChanged: {
|
||||
if (checkBox.checked) {
|
||||
loader.item.passwordError = error
|
||||
}
|
||||
}
|
||||
|
||||
onPhoneNumberChanged: {
|
||||
if (!checkBox.checked) {
|
||||
loader.item.phoneNumberError = error
|
||||
}
|
||||
}
|
||||
|
||||
onUsernameChanged: {
|
||||
if (checkBox.checked) {
|
||||
loader.item.usernameError = error
|
||||
|
|
@ -78,5 +91,26 @@ AssistantAbstractView {
|
|||
window.setView('Home')
|
||||
}
|
||||
}
|
||||
|
||||
onRecoverStatusChanged: {
|
||||
if (checkBox.checked) {
|
||||
requestBlock.stop('')
|
||||
return
|
||||
}
|
||||
|
||||
requestBlock.stop(error)
|
||||
if (!error.length) {
|
||||
window.lockView({
|
||||
descriptionText: qsTr('quitWarning')
|
||||
})
|
||||
assistant.pushView('ActivateLinphoneSipAccountWithPhoneNumber', {
|
||||
assistantModel: assistantModel
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TelephoneNumbersModel {
|
||||
id: telephoneNumbersModel
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
import Common 1.0
|
||||
import Linphone 1.0
|
||||
|
||||
// =============================================================================
|
||||
|
||||
Form {
|
||||
property bool mainActionEnabled: country.currentIndex !== -1 && phoneNumber.text
|
||||
property alias phoneNumberError: phoneNumber.error
|
||||
|
||||
property bool mainActionEnabled: phoneNumber.text.length &&
|
||||
!phoneNumberError.length
|
||||
|
||||
dealWithErrors: true
|
||||
orientation: Qt.Vertical
|
||||
|
|
@ -14,6 +18,18 @@ Form {
|
|||
|
||||
ComboBox {
|
||||
id: country
|
||||
|
||||
currentIndex: model.defaultIndex
|
||||
model: telephoneNumbersModel
|
||||
textRole: 'countryName'
|
||||
|
||||
onActivated: {
|
||||
assistantModel.setCountryCode(index)
|
||||
var text = phoneNumber.text
|
||||
if (text.length > 0) {
|
||||
assistantModel.phoneNumber = text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +40,10 @@ Form {
|
|||
|
||||
TextField {
|
||||
id: phoneNumber
|
||||
|
||||
inputMethodHints: Qt.ImhDialableCharactersOnly
|
||||
|
||||
onTextChanged: assistantModel.phoneNumber = text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 4b0eb84c8e738a606cfd5da35d2a673853b4b13a
|
||||
Subproject commit bd792338c47c3849cce3661d4e693df0177873c0
|
||||
Loading…
Add table
Reference in a new issue