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>
<source>passwordConfirmationError</source>
<translation>The passwords you entered do not match.</translation>
</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>
<name>CreateLinphoneSipAccountWithPhoneNumber</name>
......
......@@ -398,6 +398,10 @@ Url du serveur non configurée.</translation>
<source>passwordConfirmationError</source>
<translation>Les mots de passe ne correspondent pas.</translation>
</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>
<name>CreateLinphoneSipAccountWithPhoneNumber</name>
......
......@@ -281,7 +281,6 @@ void App::registerTypes () {
"Linphone", 1, 0, "VcardModel", "VcardModel is uncreatable."
);
registerSingletonType<AccountSettingsModel>("AccountSettingsModel");
registerSingletonType<AudioCodecsModel>("AudioCodecsModel");
registerSingletonType<OwnPresenceModel>("OwnPresenceModel");
registerSingletonType<Presence>("Presence");
......@@ -291,6 +290,7 @@ void App::registerTypes () {
registerSharedSingletonType(App, "App", App::getInstance);
registerSharedSingletonType(CoreManager, "CoreManager", CoreManager::getInstance);
registerSharedSingletonType(SettingsModel, "SettingsModel", CoreManager::getInstance()->getSettingsModel);
registerSharedSingletonType(AccountSettingsModel, "AccountSettingsModel", CoreManager::getInstance()->getAccountSettingsModel);
registerSharedSingletonType(SipAddressesModel, "SipAddressesModel", CoreManager::getInstance()->getSipAddressesModel);
registerSharedSingletonType(CallsListModel, "CallsListModel", CoreManager::getInstance()->getCallsListModel);
registerSharedSingletonType(ContactsListModel, "ContactsListModel", CoreManager::getInstance()->getContactsListModel);
......
......@@ -89,13 +89,15 @@ public:
}
void onIsAccountActivated (
const shared_ptr<linphone::AccountCreator> &,
const shared_ptr<linphone::AccountCreator> &creator,
linphone::AccountCreatorStatus status,
const string &
) override {
if (status == linphone::AccountCreatorStatusAccountActivated)
if (status == linphone::AccountCreatorStatusAccountActivated) {
CoreManager::getInstance()->getAccountSettingsModel()->addOrUpdateProxyConfig(creator->configure());
emit m_assistant->activateStatusChanged("");
else {
} else {
if (status == linphone::AccountCreatorStatusRequestFailed)
emit m_assistant->activateStatusChanged(tr("requestFailed"));
else
......
......@@ -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_sip_addresses_model = new SipAddressesModel(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();
}
......
......@@ -25,6 +25,7 @@
#include "../calls/CallsListModel.hpp"
#include "../contacts/ContactsListModel.hpp"
#include "../settings/AccountSettingsModel.hpp"
#include "../settings/SettingsModel.hpp"
#include "../sip-addresses/SipAddressesModel.hpp"
......@@ -86,6 +87,10 @@ public:
return m_settings_model;
}
AccountSettingsModel *getAccountSettingsModel () const {
return m_account_settings_model;
}
// ---------------------------------------------------------------------------
// Initialization.
// ---------------------------------------------------------------------------
......@@ -125,6 +130,7 @@ private:
ContactsListModel *m_contacts_list_model;
SipAddressesModel *m_sip_addresses_model;
SettingsModel *m_settings_model;
AccountSettingsModel *m_account_settings_model;
QTimer *m_cbs_timer;
......
......@@ -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);
QVariantMap map;
......@@ -67,10 +88,9 @@ void AccountSettingsModel::removeProxyConfig (const shared_ptr<linphone::ProxyCo
}
bool AccountSettingsModel::addOrUpdateProxyConfig (
const std::shared_ptr<linphone::ProxyConfig> &proxy_config,
const shared_ptr<linphone::ProxyConfig> &proxy_config,
const QVariantMap &data
) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
QString literal = data["sipAddress"].toString();
// Sip address.
......@@ -107,23 +127,10 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
: linphone::AVPFMode::AVPFModeDefault
);
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(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;
return addOrUpdateProxyConfig(proxy_config);
}
std::shared_ptr<linphone::ProxyConfig> AccountSettingsModel::createProxyConfig () {
shared_ptr<linphone::ProxyConfig> AccountSettingsModel::createProxyConfig () {
return CoreManager::getInstance()->getCore()->createProxyConfig();
}
......@@ -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::ProxyConfig> proxy_config = core->getDefaultProxyConfig();
......
......@@ -43,6 +43,8 @@ class AccountSettingsModel : public QObject {
public:
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 void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxy_config);
......
......@@ -18,13 +18,13 @@ QtObject {
}
property QtObject confirmDialog: QtObject {
property int height: 150
property int width: 370
property int height: 200
property int width: 400
}
property QtObject description: QtObject {
property color color: Colors.l
property int fontSize: 12
property int fontSize: 11
property int verticalMargin: 25
}
}
......@@ -50,6 +50,7 @@ AssistantAbstractView {
onActivateStatusChanged: {
requestBlock.stop(error)
if (!error.length) {
window.unlockView()
window.setView('Home')
}
}
......
......@@ -89,7 +89,13 @@ AssistantAbstractView {
RequestBlock {
id: requestBlock
action: assistantModel.create
action: function () {
window.lockView({
descriptionText: qsTr('quitWarning')
})
assistantModel.create()
}
width: parent.width
}
}
......@@ -111,6 +117,8 @@ AssistantAbstractView {
assistant.pushView('ActivateLinphoneSipAccountWithEmail', {
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