mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-02-07 15:08:24 +00:00
feat(ui/views/App/Main/Assistant): handle linphone account creation
This commit is contained in:
parent
af0b20455c
commit
074edf1281
14 changed files with 256 additions and 65 deletions
|
|
@ -1,6 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>ActivateLinphoneSipAccountWithEmail</name>
|
||||
<message>
|
||||
<source>activateLinphoneSipAccount</source>
|
||||
<translation>CREATE A LINPHONE ACCOUNT</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>confirmAction</source>
|
||||
<translation>ACTIVATE</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>activationSteps</source>
|
||||
<translation>To activate your account: Follow the instructions that we sent you at %1, then click on the button below.</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>App</name>
|
||||
<message>
|
||||
|
|
@ -120,6 +135,14 @@
|
|||
<source>accountAlreadyExists</source>
|
||||
<translation>Account already exists.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>smsActivationFailed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>emailActivationFailed</source>
|
||||
<translation>Please verify that you have validated your account or try again.</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Calls</name>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>ActivateLinphoneSipAccountWithEmail</name>
|
||||
<message>
|
||||
<source>activateLinphoneSipAccount</source>
|
||||
<translation>CRÉER UN COMPTE LINPHONE</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>confirmAction</source>
|
||||
<translation>ACTIVER</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>activationSteps</source>
|
||||
<translation>Pour activer votre compte : Suivez les instructions que vous avez reçues à %1, puis cliquez sur le bouton plus bas.</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>App</name>
|
||||
<message>
|
||||
|
|
@ -120,6 +135,14 @@
|
|||
<source>accountAlreadyExists</source>
|
||||
<translation>Le compte existe déjà.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>smsActivationFailed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>emailActivationFailed</source>
|
||||
<translation>Merci de vérifier que vous avez validé votre compte ou réessayez plus tard.</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Calls</name>
|
||||
|
|
|
|||
|
|
@ -333,6 +333,7 @@
|
|||
<file>ui/views/App/Calls/Incall.qml</file>
|
||||
<file>ui/views/App/Calls/IncomingCall.qml</file>
|
||||
<file>ui/views/App/Calls/OutgoingCall.qml</file>
|
||||
<file>ui/views/App/Main/Assistant/ActivateLinphoneSipAccountWithEmail.qml</file>
|
||||
<file>ui/views/App/Main/Assistant/AssistantAbstractView.qml</file>
|
||||
<file>ui/views/App/Main/Assistant/AssistantHome.qml</file>
|
||||
<file>ui/views/App/Main/Assistant/CreateLinphoneSipAccount.qml</file>
|
||||
|
|
@ -368,6 +369,7 @@
|
|||
<file>ui/views/App/SplashScreen/SplashScreen.qml</file>
|
||||
<file>ui/views/App/Styles/Calls/CallStyle.qml</file>
|
||||
<file>ui/views/App/Styles/Calls/CallsWindowStyle.qml</file>
|
||||
<file>ui/views/App/Styles/Main/Assistant/ActivateLinphoneSipAccountWithEmailStyle.qml</file>
|
||||
<file>ui/views/App/Styles/Main/Assistant/AssistantAbstractViewStyle.qml</file>
|
||||
<file>ui/views/App/Styles/Main/Assistant/AssistantHomeStyle.qml</file>
|
||||
<file>ui/views/App/Styles/Main/Assistant/CreateLinphoneSipAccountStyle.qml</file>
|
||||
|
|
|
|||
|
|
@ -70,18 +70,39 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// void onActivateAccount (
|
||||
// const shared_ptr<linphone::AccountCreator> &creator,
|
||||
// linphone::AccountCreatorStatus status,
|
||||
// const string &resp
|
||||
// ) override {}
|
||||
//
|
||||
// void onIsAccountActivated (
|
||||
// const shared_ptr<linphone::AccountCreator> &creator,
|
||||
// linphone::AccountCreatorStatus status,
|
||||
// const string &resp
|
||||
// ) override {}
|
||||
//
|
||||
void onActivateAccount (
|
||||
const shared_ptr<linphone::AccountCreator> &,
|
||||
linphone::AccountCreatorStatus status,
|
||||
const string &
|
||||
) override {
|
||||
if (
|
||||
status == linphone::AccountCreatorStatusAccountActivated ||
|
||||
status == linphone::AccountCreatorStatusAccountAlreadyActivated
|
||||
)
|
||||
emit m_assistant->activateStatusChanged("");
|
||||
else {
|
||||
if (status == linphone::AccountCreatorStatusRequestFailed)
|
||||
emit m_assistant->activateStatusChanged(tr("requestFailed"));
|
||||
else
|
||||
emit m_assistant->activateStatusChanged(tr("smsActivationFailed"));
|
||||
}
|
||||
}
|
||||
|
||||
void onIsAccountActivated (
|
||||
const shared_ptr<linphone::AccountCreator> &,
|
||||
linphone::AccountCreatorStatus status,
|
||||
const string &
|
||||
) override {
|
||||
if (status == linphone::AccountCreatorStatusAccountActivated)
|
||||
emit m_assistant->activateStatusChanged("");
|
||||
else {
|
||||
if (status == linphone::AccountCreatorStatusRequestFailed)
|
||||
emit m_assistant->activateStatusChanged(tr("requestFailed"));
|
||||
else
|
||||
emit m_assistant->activateStatusChanged(tr("emailActivationFailed"));
|
||||
}
|
||||
}
|
||||
|
||||
// void onLinkAccount (
|
||||
// const shared_ptr<linphone::AccountCreator> &creator,
|
||||
// linphone::AccountCreatorStatus status,
|
||||
|
|
@ -136,6 +157,36 @@ AssistantModel::AssistantModel (QObject *parent) : QObject(parent) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void AssistantModel::activate () {
|
||||
if (m_account_creator->getEmail().empty())
|
||||
m_account_creator->activateAccount();
|
||||
else
|
||||
m_account_creator->isAccountActivated();
|
||||
}
|
||||
|
||||
void AssistantModel::create () {
|
||||
m_account_creator->createAccount();
|
||||
}
|
||||
|
||||
void AssistantModel::login () {
|
||||
m_account_creator->isAccountExist();
|
||||
}
|
||||
|
||||
void AssistantModel::reset () {
|
||||
m_account_creator->reset();
|
||||
|
||||
emit emailChanged("", "");
|
||||
emit passwordChanged("", "");
|
||||
emit phoneNumberChanged("", "");
|
||||
emit usernameChanged("", "");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getEmail () const {
|
||||
return ::Utils::linphoneStringToQString(m_account_creator->getEmail());
|
||||
}
|
||||
|
||||
void AssistantModel::setEmail (const QString &email) {
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
|
@ -154,6 +205,10 @@ void AssistantModel::setEmail (const QString &email) {
|
|||
emit emailChanged(email, error);
|
||||
}
|
||||
|
||||
QString AssistantModel::getPassword () const {
|
||||
return ::Utils::linphoneStringToQString(m_account_creator->getPassword());
|
||||
}
|
||||
|
||||
void AssistantModel::setPassword (const QString &password) {
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
|
@ -180,6 +235,10 @@ void AssistantModel::setPassword (const QString &password) {
|
|||
emit passwordChanged(password, error);
|
||||
}
|
||||
|
||||
QString AssistantModel::getPhoneNumber () const {
|
||||
return ::Utils::linphoneStringToQString(m_account_creator->getPhoneNumber());
|
||||
}
|
||||
|
||||
void AssistantModel::setPhoneNumber (const QString &phone_number) {
|
||||
// shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
|
@ -189,6 +248,10 @@ void AssistantModel::setPhoneNumber (const QString &phone_number) {
|
|||
emit phoneNumberChanged(phone_number, error);
|
||||
}
|
||||
|
||||
QString AssistantModel::getUsername () const {
|
||||
return ::Utils::linphoneStringToQString(m_account_creator->getUsername());
|
||||
}
|
||||
|
||||
void AssistantModel::setUsername (const QString &username) {
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
|
@ -213,22 +276,3 @@ void AssistantModel::setUsername (const QString &username) {
|
|||
|
||||
emit usernameChanged(username, error);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void AssistantModel::create () {
|
||||
m_account_creator->createAccount();
|
||||
}
|
||||
|
||||
void AssistantModel::login () {
|
||||
m_account_creator->isAccountExist();
|
||||
}
|
||||
|
||||
void AssistantModel::reset () {
|
||||
m_account_creator->reset();
|
||||
|
||||
emit emailChanged("", "");
|
||||
emit passwordChanged("", "");
|
||||
emit phoneNumberChanged("", "");
|
||||
emit usernameChanged("", "");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,16 +33,18 @@ class AssistantModel : public QObject {
|
|||
|
||||
Q_OBJECT;
|
||||
|
||||
Q_PROPERTY(QString email READ getEmail WRITE setEmail NOTIFY emailChanged);
|
||||
Q_PROPERTY(QString password READ getPassword WRITE setPassword NOTIFY passwordChanged);
|
||||
Q_PROPERTY(QString phoneNumber READ getPhoneNumber WRITE setPhoneNumber NOTIFY phoneNumberChanged);
|
||||
Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY usernameChanged);
|
||||
|
||||
public:
|
||||
AssistantModel (QObject *parent = Q_NULLPTR);
|
||||
|
||||
Q_INVOKABLE void setEmail (const QString &email);
|
||||
Q_INVOKABLE void setPassword (const QString &password);
|
||||
Q_INVOKABLE void setPhoneNumber (const QString &phone_number);
|
||||
Q_INVOKABLE void setUsername (const QString &username);
|
||||
|
||||
Q_INVOKABLE void activate ();
|
||||
Q_INVOKABLE void create ();
|
||||
Q_INVOKABLE void login ();
|
||||
|
||||
Q_INVOKABLE void reset ();
|
||||
|
||||
signals:
|
||||
|
|
@ -51,10 +53,23 @@ signals:
|
|||
void phoneNumberChanged (const QString &phone_number, const QString &error);
|
||||
void usernameChanged (const QString &username, const QString &error);
|
||||
|
||||
void activateStatusChanged (const QString &error);
|
||||
void createStatusChanged (const QString &error);
|
||||
void loginStatusChanged (const QString &error);
|
||||
|
||||
private:
|
||||
QString getEmail () const;
|
||||
void setEmail (const QString &email);
|
||||
|
||||
QString getPassword () const;
|
||||
void setPassword (const QString &password);
|
||||
|
||||
QString getPhoneNumber () const;
|
||||
void setPhoneNumber (const QString &phone_number);
|
||||
|
||||
QString getUsername () const;
|
||||
void setUsername (const QString &username);
|
||||
|
||||
std::shared_ptr<linphone::AccountCreator> m_account_creator;
|
||||
std::shared_ptr<Handlers> m_handlers;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,12 +27,11 @@
|
|||
char *Utils::rstrstr (const char *a, const char *b) {
|
||||
size_t a_len = strlen(a);
|
||||
size_t b_len = strlen(b);
|
||||
const char *s;
|
||||
|
||||
if (b_len > a_len)
|
||||
return nullptr;
|
||||
|
||||
for (s = a + a_len - b_len; s >= a; --s) {
|
||||
for (const char *s = a + a_len - b_len; s >= a; --s) {
|
||||
if (!strncmp(s, b, b_len))
|
||||
return const_cast<char *>(s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,15 +12,21 @@ Item {
|
|||
id: assistant
|
||||
|
||||
readonly property string viewsPath: 'qrc:/ui/views/App/Main/Assistant/'
|
||||
readonly property alias nViews: stack.depth
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function pushView (view) {
|
||||
function pushView (view, properties) {
|
||||
stack.push(
|
||||
Utils.isString(view) ? viewsPath + view + '.qml' : view
|
||||
Utils.isString(view) ? viewsPath + view + '.qml' : view,
|
||||
properties
|
||||
)
|
||||
}
|
||||
|
||||
function getView (index) {
|
||||
return stack.get(index)
|
||||
}
|
||||
|
||||
function popView () {
|
||||
stack.pop()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
import QtQuick 2.7
|
||||
|
||||
import Common 1.0
|
||||
import Linphone 1.0
|
||||
|
||||
import App.Styles 1.0
|
||||
|
||||
// =============================================================================
|
||||
|
||||
AssistantAbstractView {
|
||||
property var assistantModel
|
||||
|
||||
backEnabled: false
|
||||
|
||||
title: qsTr('activateLinphoneSipAccount')
|
||||
|
||||
mainAction: requestBlock.execute
|
||||
mainActionEnabled: !requestBlock.loading
|
||||
mainActionLabel: qsTr('confirmAction')
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: ActivateLinphoneSipAccountWithEmailStyle.spacing
|
||||
width: parent.width
|
||||
|
||||
Text {
|
||||
color: ActivateLinphoneSipAccountWithEmailStyle.activationSteps.color
|
||||
font.pointSize: ActivateLinphoneSipAccountWithEmailStyle.activationSteps.fontSize
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: qsTr('activationSteps').replace('%1', assistantModel.email)
|
||||
width: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
RequestBlock {
|
||||
id: requestBlock
|
||||
|
||||
action: assistantModel.activate
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Assistant.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Connections {
|
||||
target: assistantModel
|
||||
|
||||
onActivateStatusChanged: {
|
||||
requestBlock.stop(error)
|
||||
if (!error.length) {
|
||||
window.setView('Home')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,6 +19,8 @@ Item {
|
|||
property alias description: description.text
|
||||
property alias title: title.text
|
||||
|
||||
property bool backEnabled: true
|
||||
|
||||
default property alias _content: content.data
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
@ -94,6 +96,8 @@ Item {
|
|||
|
||||
TextButtonA {
|
||||
text: qsTr('back')
|
||||
visible: view.backEnabled
|
||||
|
||||
onClicked: assistant.popView()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ AssistantAbstractView {
|
|||
TextField {
|
||||
id: username
|
||||
|
||||
onTextChanged: assistantModel.setUsername(text)
|
||||
onTextChanged: assistantModel.username = text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ AssistantAbstractView {
|
|||
TextField {
|
||||
id: email
|
||||
|
||||
onTextChanged: assistantModel.setEmail(text)
|
||||
onTextChanged: assistantModel.email = text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ AssistantAbstractView {
|
|||
TextField {
|
||||
id: password
|
||||
|
||||
onTextChanged: assistantModel.setPassword(text)
|
||||
onTextChanged: assistantModel.password = text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -108,7 +108,9 @@ AssistantAbstractView {
|
|||
onCreateStatusChanged: {
|
||||
requestBlock.stop(error)
|
||||
if (!error.length) {
|
||||
// TODO.
|
||||
assistant.pushView('ActivateLinphoneSipAccountWithEmail', {
|
||||
assistantModel: assistantModel
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ AssistantAbstractView {
|
|||
TextField {
|
||||
id: username
|
||||
|
||||
onTextChanged: assistantModel.setUsername(text)
|
||||
onTextChanged: assistantModel.username = text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ Form {
|
|||
TextField {
|
||||
id: username
|
||||
|
||||
onTextChanged: assistantModel.setUsername(text)
|
||||
onTextChanged: assistantModel.username = text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ Form {
|
|||
TextField {
|
||||
id: password
|
||||
|
||||
onTextChanged: assistantModel.setPassword(text)
|
||||
onTextChanged: assistantModel.password = text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
pragma Singleton
|
||||
import QtQuick 2.7
|
||||
|
||||
import Common 1.0
|
||||
|
||||
// =============================================================================
|
||||
|
||||
QtObject {
|
||||
property int spacing: 20
|
||||
|
||||
property QtObject activationSteps: QtObject {
|
||||
property color color: Colors.g
|
||||
property int fontSize: 10
|
||||
}
|
||||
}
|
||||
|
|
@ -4,24 +4,25 @@ module App.Styles
|
|||
|
||||
# Views styles -----------------------------------------------------------------
|
||||
|
||||
singleton CallStyle 1.0 Calls/CallStyle.qml
|
||||
singleton CallsWindowStyle 1.0 Calls/CallsWindowStyle.qml
|
||||
singleton CallStyle 1.0 Calls/CallStyle.qml
|
||||
singleton CallsWindowStyle 1.0 Calls/CallsWindowStyle.qml
|
||||
|
||||
singleton AssistantAbstractViewStyle 1.0 Main/Assistant/AssistantAbstractViewStyle.qml
|
||||
singleton AssistantHomeStyle 1.0 Main/Assistant/AssistantHomeStyle.qml
|
||||
singleton CreateLinphoneSipAccountStyle 1.0 Main/Assistant/CreateLinphoneSipAccountStyle.qml
|
||||
singleton UseLinphoneSipAccountStyle 1.0 Main/Assistant/UseLinphoneSipAccountStyle.qml
|
||||
singleton ActivateLinphoneSipAccountWithEmailStyle 1.0 Main/Assistant/ActivateLinphoneSipAccountWithEmailStyle.qml
|
||||
singleton AssistantAbstractViewStyle 1.0 Main/Assistant/AssistantAbstractViewStyle.qml
|
||||
singleton AssistantHomeStyle 1.0 Main/Assistant/AssistantHomeStyle.qml
|
||||
singleton CreateLinphoneSipAccountStyle 1.0 Main/Assistant/CreateLinphoneSipAccountStyle.qml
|
||||
singleton UseLinphoneSipAccountStyle 1.0 Main/Assistant/UseLinphoneSipAccountStyle.qml
|
||||
|
||||
singleton AssistantStyle 1.0 Main/AssistantStyle.qml
|
||||
singleton ContactEditStyle 1.0 Main/ContactEditStyle.qml
|
||||
singleton ContactsStyle 1.0 Main/ContactsStyle.qml
|
||||
singleton ConversationStyle 1.0 Main/ConversationStyle.qml
|
||||
singleton HomeStyle 1.0 Main/HomeStyle.qml
|
||||
singleton InviteFriendsStyle 1.0 Main/InviteFriendsStyle.qml
|
||||
singleton MainWindowMenuBarStyle 1.0 Main/MainWindowMenuBarStyle.qml
|
||||
singleton MainWindowStyle 1.0 Main/MainWindowStyle.qml
|
||||
singleton ManageAccountsStyle 1.0 Main/ManageAccountsStyle.qml
|
||||
singleton AssistantStyle 1.0 Main/AssistantStyle.qml
|
||||
singleton ContactEditStyle 1.0 Main/ContactEditStyle.qml
|
||||
singleton ContactsStyle 1.0 Main/ContactsStyle.qml
|
||||
singleton ConversationStyle 1.0 Main/ConversationStyle.qml
|
||||
singleton HomeStyle 1.0 Main/HomeStyle.qml
|
||||
singleton InviteFriendsStyle 1.0 Main/InviteFriendsStyle.qml
|
||||
singleton MainWindowMenuBarStyle 1.0 Main/MainWindowMenuBarStyle.qml
|
||||
singleton MainWindowStyle 1.0 Main/MainWindowStyle.qml
|
||||
singleton ManageAccountsStyle 1.0 Main/ManageAccountsStyle.qml
|
||||
|
||||
singleton SettingsWindowStyle 1.0 Settings/SettingsWindowStyle.qml
|
||||
singleton SettingsSipAccountsEditStyle 1.0 Settings/SettingsSipAccountsEditStyle.qml
|
||||
singleton SplashScreenStyle 1.0 SplashScreen/SplashScreenStyle.qml
|
||||
singleton SettingsWindowStyle 1.0 Settings/SettingsWindowStyle.qml
|
||||
singleton SettingsSipAccountsEditStyle 1.0 Settings/SettingsSipAccountsEditStyle.qml
|
||||
singleton SplashScreenStyle 1.0 SplashScreen/SplashScreenStyle.qml
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue