Commit 71b04c5e authored by Ronan Abhamon's avatar Ronan Abhamon

feat(src/components/assistant): lock view on account validation

parent c5a719f4
...@@ -398,6 +398,10 @@ Server url not configured.</translation> ...@@ -398,6 +398,10 @@ Server url not configured.</translation>
<source>passwordConfirmationError</source> <source>passwordConfirmationError</source>
<translation>The passwords you entered do not match.</translation> <translation>The passwords you entered do not match.</translation>
</message> </message>
<message>
<source>quitWarning</source>
<translation>Your account has been created but is not yet validated. If you quit this view, you should add manually your account and validate it within 24 hours.</translation>
</message>
</context> </context>
<context> <context>
<name>CreateLinphoneSipAccountWithPhoneNumber</name> <name>CreateLinphoneSipAccountWithPhoneNumber</name>
......
...@@ -398,6 +398,10 @@ Url du serveur non configurée.</translation> ...@@ -398,6 +398,10 @@ Url du serveur non configurée.</translation>
<source>passwordConfirmationError</source> <source>passwordConfirmationError</source>
<translation>Les mots de passe ne correspondent pas.</translation> <translation>Les mots de passe ne correspondent pas.</translation>
</message> </message>
<message>
<source>quitWarning</source>
<translation>Votre compte a été crée mais il n&apos;a pas été validé. Si vous quittez cette vue, vous devrez ajouter manuellement votre compte et le valider dans les 24 heures.</translation>
</message>
</context> </context>
<context> <context>
<name>CreateLinphoneSipAccountWithPhoneNumber</name> <name>CreateLinphoneSipAccountWithPhoneNumber</name>
......
...@@ -281,7 +281,6 @@ void App::registerTypes () { ...@@ -281,7 +281,6 @@ void App::registerTypes () {
"Linphone", 1, 0, "VcardModel", "VcardModel is uncreatable." "Linphone", 1, 0, "VcardModel", "VcardModel is uncreatable."
); );
registerSingletonType<AccountSettingsModel>("AccountSettingsModel");
registerSingletonType<AudioCodecsModel>("AudioCodecsModel"); registerSingletonType<AudioCodecsModel>("AudioCodecsModel");
registerSingletonType<OwnPresenceModel>("OwnPresenceModel"); registerSingletonType<OwnPresenceModel>("OwnPresenceModel");
registerSingletonType<Presence>("Presence"); registerSingletonType<Presence>("Presence");
...@@ -291,6 +290,7 @@ void App::registerTypes () { ...@@ -291,6 +290,7 @@ void App::registerTypes () {
registerSharedSingletonType(App, "App", App::getInstance); registerSharedSingletonType(App, "App", App::getInstance);
registerSharedSingletonType(CoreManager, "CoreManager", CoreManager::getInstance); registerSharedSingletonType(CoreManager, "CoreManager", CoreManager::getInstance);
registerSharedSingletonType(SettingsModel, "SettingsModel", CoreManager::getInstance()->getSettingsModel); registerSharedSingletonType(SettingsModel, "SettingsModel", CoreManager::getInstance()->getSettingsModel);
registerSharedSingletonType(AccountSettingsModel, "AccountSettingsModel", CoreManager::getInstance()->getAccountSettingsModel);
registerSharedSingletonType(SipAddressesModel, "SipAddressesModel", CoreManager::getInstance()->getSipAddressesModel); registerSharedSingletonType(SipAddressesModel, "SipAddressesModel", CoreManager::getInstance()->getSipAddressesModel);
registerSharedSingletonType(CallsListModel, "CallsListModel", CoreManager::getInstance()->getCallsListModel); registerSharedSingletonType(CallsListModel, "CallsListModel", CoreManager::getInstance()->getCallsListModel);
registerSharedSingletonType(ContactsListModel, "ContactsListModel", CoreManager::getInstance()->getContactsListModel); registerSharedSingletonType(ContactsListModel, "ContactsListModel", CoreManager::getInstance()->getContactsListModel);
......
...@@ -89,13 +89,15 @@ public: ...@@ -89,13 +89,15 @@ public:
} }
void onIsAccountActivated ( void onIsAccountActivated (
const shared_ptr<linphone::AccountCreator> &, const shared_ptr<linphone::AccountCreator> &creator,
linphone::AccountCreatorStatus status, linphone::AccountCreatorStatus status,
const string & const string &
) override { ) override {
if (status == linphone::AccountCreatorStatusAccountActivated) if (status == linphone::AccountCreatorStatusAccountActivated) {
CoreManager::getInstance()->getAccountSettingsModel()->addOrUpdateProxyConfig(creator->configure());
emit m_assistant->activateStatusChanged(""); emit m_assistant->activateStatusChanged("");
else { } else {
if (status == linphone::AccountCreatorStatusRequestFailed) if (status == linphone::AccountCreatorStatusRequestFailed)
emit m_assistant->activateStatusChanged(tr("requestFailed")); emit m_assistant->activateStatusChanged(tr("requestFailed"));
else else
......
...@@ -45,6 +45,7 @@ CoreManager::CoreManager (QObject *parent, const QString &config_path) : QObject ...@@ -45,6 +45,7 @@ CoreManager::CoreManager (QObject *parent, const QString &config_path) : QObject
m_instance->m_contacts_list_model = new ContactsListModel(m_instance); m_instance->m_contacts_list_model = new ContactsListModel(m_instance);
m_instance->m_sip_addresses_model = new SipAddressesModel(m_instance); m_instance->m_sip_addresses_model = new SipAddressesModel(m_instance);
m_instance->m_settings_model = new SettingsModel(m_instance); m_instance->m_settings_model = new SettingsModel(m_instance);
m_instance->m_account_settings_model = new AccountSettingsModel(m_instance);
emit m_instance->linphoneCoreCreated(); emit m_instance->linphoneCoreCreated();
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "../calls/CallsListModel.hpp" #include "../calls/CallsListModel.hpp"
#include "../contacts/ContactsListModel.hpp" #include "../contacts/ContactsListModel.hpp"
#include "../settings/AccountSettingsModel.hpp"
#include "../settings/SettingsModel.hpp" #include "../settings/SettingsModel.hpp"
#include "../sip-addresses/SipAddressesModel.hpp" #include "../sip-addresses/SipAddressesModel.hpp"
...@@ -86,6 +87,10 @@ public: ...@@ -86,6 +87,10 @@ public:
return m_settings_model; return m_settings_model;
} }
AccountSettingsModel *getAccountSettingsModel () const {
return m_account_settings_model;
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Initialization. // Initialization.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -125,6 +130,7 @@ private: ...@@ -125,6 +130,7 @@ private:
ContactsListModel *m_contacts_list_model; ContactsListModel *m_contacts_list_model;
SipAddressesModel *m_sip_addresses_model; SipAddressesModel *m_sip_addresses_model;
SettingsModel *m_settings_model; SettingsModel *m_settings_model;
AccountSettingsModel *m_account_settings_model;
QTimer *m_cbs_timer; QTimer *m_cbs_timer;
......
...@@ -31,7 +31,28 @@ using namespace std; ...@@ -31,7 +31,28 @@ using namespace std;
// ============================================================================= // =============================================================================
QVariantMap AccountSettingsModel::getProxyConfigDescription (const std::shared_ptr<linphone::ProxyConfig> &proxy_config) { bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxy_config) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
list<shared_ptr<linphone::ProxyConfig> > proxy_configs = core->getProxyConfigList();
if (find(proxy_configs.cbegin(), proxy_configs.cend(), proxy_config) != proxy_configs.cend()) {
if (proxy_config->done() == -1) {
qWarning() << QStringLiteral("Unable to update proxy config: `%1`.")
.arg(::Utils::linphoneStringToQString(proxy_config->getIdentityAddress()->asString()));
return false;
}
} else if (core->addProxyConfig(proxy_config) == -1) {
qWarning() << QStringLiteral("Unable to add proxy config: `%1`.")
.arg(::Utils::linphoneStringToQString(proxy_config->getIdentityAddress()->asString()));
return false;
}
emit accountSettingsUpdated();
return true;
}
QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<linphone::ProxyConfig> &proxy_config) {
Q_ASSERT(proxy_config != nullptr); Q_ASSERT(proxy_config != nullptr);
QVariantMap map; QVariantMap map;
...@@ -67,10 +88,9 @@ void AccountSettingsModel::removeProxyConfig (const shared_ptr<linphone::ProxyCo ...@@ -67,10 +88,9 @@ void AccountSettingsModel::removeProxyConfig (const shared_ptr<linphone::ProxyCo
} }
bool AccountSettingsModel::addOrUpdateProxyConfig ( bool AccountSettingsModel::addOrUpdateProxyConfig (
const std::shared_ptr<linphone::ProxyConfig> &proxy_config, const shared_ptr<linphone::ProxyConfig> &proxy_config,
const QVariantMap &data const QVariantMap &data
) { ) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
QString literal = data["sipAddress"].toString(); QString literal = data["sipAddress"].toString();
// Sip address. // Sip address.
...@@ -107,23 +127,10 @@ bool AccountSettingsModel::addOrUpdateProxyConfig ( ...@@ -107,23 +127,10 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
: linphone::AVPFMode::AVPFModeDefault : linphone::AVPFMode::AVPFModeDefault
); );
list<shared_ptr<linphone::ProxyConfig> > proxy_configs = core->getProxyConfigList(); return addOrUpdateProxyConfig(proxy_config);
if (find(proxy_configs.cbegin(), proxy_configs.cend(), proxy_config) != proxy_configs.cend()) {
if (proxy_config->done() == -1) {
qWarning() << QStringLiteral("Unable to update proxy config: `%1`.").arg(literal);
return false;
}
} else if (core->addProxyConfig(proxy_config) == -1) {
qWarning() << QStringLiteral("Unable to add proxy config: `%1`.").arg(literal);
return false;
}
emit accountSettingsUpdated();
return true;
} }
std::shared_ptr<linphone::ProxyConfig> AccountSettingsModel::createProxyConfig () { shared_ptr<linphone::ProxyConfig> AccountSettingsModel::createProxyConfig () {
return CoreManager::getInstance()->getCore()->createProxyConfig(); return CoreManager::getInstance()->getCore()->createProxyConfig();
} }
...@@ -223,7 +230,7 @@ QVariantList AccountSettingsModel::getAccounts () const { ...@@ -223,7 +230,7 @@ QVariantList AccountSettingsModel::getAccounts () const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void AccountSettingsModel::setUsedSipAddress (const std::shared_ptr<const linphone::Address> &address) { void AccountSettingsModel::setUsedSipAddress (const shared_ptr<const linphone::Address> &address) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::ProxyConfig> proxy_config = core->getDefaultProxyConfig(); shared_ptr<linphone::ProxyConfig> proxy_config = core->getDefaultProxyConfig();
......
...@@ -43,6 +43,8 @@ class AccountSettingsModel : public QObject { ...@@ -43,6 +43,8 @@ class AccountSettingsModel : public QObject {
public: public:
AccountSettingsModel (QObject *parent = Q_NULLPTR) : QObject(parent) {} AccountSettingsModel (QObject *parent = Q_NULLPTR) : QObject(parent) {}
bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config);
Q_INVOKABLE QVariantMap getProxyConfigDescription (const std::shared_ptr<linphone::ProxyConfig> &proxy_config); Q_INVOKABLE QVariantMap getProxyConfigDescription (const std::shared_ptr<linphone::ProxyConfig> &proxy_config);
Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config); Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config);
......
...@@ -18,13 +18,13 @@ QtObject { ...@@ -18,13 +18,13 @@ QtObject {
} }
property QtObject confirmDialog: QtObject { property QtObject confirmDialog: QtObject {
property int height: 150 property int height: 200
property int width: 370 property int width: 400
} }
property QtObject description: QtObject { property QtObject description: QtObject {
property color color: Colors.l property color color: Colors.l
property int fontSize: 12 property int fontSize: 11
property int verticalMargin: 25 property int verticalMargin: 25
} }
} }
...@@ -50,6 +50,7 @@ AssistantAbstractView { ...@@ -50,6 +50,7 @@ AssistantAbstractView {
onActivateStatusChanged: { onActivateStatusChanged: {
requestBlock.stop(error) requestBlock.stop(error)
if (!error.length) { if (!error.length) {
window.unlockView()
window.setView('Home') window.setView('Home')
} }
} }
......
...@@ -89,7 +89,13 @@ AssistantAbstractView { ...@@ -89,7 +89,13 @@ AssistantAbstractView {
RequestBlock { RequestBlock {
id: requestBlock id: requestBlock
action: assistantModel.create action: function () {
window.lockView({
descriptionText: qsTr('quitWarning')
})
assistantModel.create()
}
width: parent.width width: parent.width
} }
} }
...@@ -111,6 +117,8 @@ AssistantAbstractView { ...@@ -111,6 +117,8 @@ AssistantAbstractView {
assistant.pushView('ActivateLinphoneSipAccountWithEmail', { assistant.pushView('ActivateLinphoneSipAccountWithEmail', {
assistantModel: assistantModel assistantModel: assistantModel
}) })
} else {
window.unlockView()
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment