login with non linphone sip account
This commit is contained in:
parent
5adf150d2d
commit
4ec344130d
15 changed files with 105 additions and 110 deletions
|
|
@ -52,7 +52,10 @@ AccountCore::AccountCore(const std::shared_ptr<linphone::Account> &account) : QO
|
||||||
mRegisterEnabled = params->registerEnabled();
|
mRegisterEnabled = params->registerEnabled();
|
||||||
mMwiServerAddress =
|
mMwiServerAddress =
|
||||||
params->getMwiServerAddress() ? Utils::coreStringToAppString(params->getMwiServerAddress()->asString()) : "";
|
params->getMwiServerAddress() ? Utils::coreStringToAppString(params->getMwiServerAddress()->asString()) : "";
|
||||||
mTransports << "TCP" << "UDP" << "TLS" << "DTLS";
|
mTransports << "TCP"
|
||||||
|
<< "UDP"
|
||||||
|
<< "TLS"
|
||||||
|
<< "DTLS";
|
||||||
mTransport = LinphoneEnums::toString(LinphoneEnums::fromLinphone(params->getTransport()));
|
mTransport = LinphoneEnums::toString(LinphoneEnums::fromLinphone(params->getTransport()));
|
||||||
mServerAddress =
|
mServerAddress =
|
||||||
params->getServerAddress() ? Utils::coreStringToAppString(params->getServerAddress()->asString()) : "";
|
params->getServerAddress() ? Utils::coreStringToAppString(params->getServerAddress()->asString()) : "";
|
||||||
|
|
@ -98,76 +101,76 @@ void AccountCore::setSelf(QSharedPointer<AccountCore> me) {
|
||||||
&AccountModel::registrationStateChanged, [this](const std::shared_ptr<linphone::Account> &account,
|
&AccountModel::registrationStateChanged, [this](const std::shared_ptr<linphone::Account> &account,
|
||||||
linphone::RegistrationState state, const std::string &message) {
|
linphone::RegistrationState state, const std::string &message) {
|
||||||
mAccountModelConnection->invokeToCore(
|
mAccountModelConnection->invokeToCore(
|
||||||
[this, account, state, message]() { this->onRegistrationStateChanged(account, state, message); });
|
[this, account, state, message]() { onRegistrationStateChanged(account, state, message); });
|
||||||
});
|
});
|
||||||
// From Model
|
// From Model
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::defaultAccountChanged, [this](bool isDefault) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::defaultAccountChanged, [this](bool isDefault) {
|
||||||
mAccountModelConnection->invokeToCore([this, isDefault]() { this->onDefaultAccountChanged(isDefault); });
|
mAccountModelConnection->invokeToCore([this, isDefault]() { onDefaultAccountChanged(isDefault); });
|
||||||
});
|
});
|
||||||
|
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::pictureUriChanged, [this](QString uri) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::pictureUriChanged, [this](QString uri) {
|
||||||
mAccountModelConnection->invokeToCore([this, uri]() { this->onPictureUriChanged(uri); });
|
mAccountModelConnection->invokeToCore([this, uri]() { onPictureUriChanged(uri); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(
|
mAccountModelConnection->makeConnectToModel(
|
||||||
&AccountModel::unreadNotificationsChanged, [this](int unreadMessagesCount, int unreadCallsCount) {
|
&AccountModel::unreadNotificationsChanged, [this](int unreadMessagesCount, int unreadCallsCount) {
|
||||||
mAccountModelConnection->invokeToCore([this, unreadMessagesCount, unreadCallsCount]() {
|
mAccountModelConnection->invokeToCore([this, unreadMessagesCount, unreadCallsCount]() {
|
||||||
this->setUnreadNotifications(unreadMessagesCount + unreadCallsCount);
|
setUnreadNotifications(unreadMessagesCount + unreadCallsCount);
|
||||||
this->setUnreadCallNotifications(unreadCallsCount);
|
setUnreadCallNotifications(unreadCallsCount);
|
||||||
this->setUnreadMessageNotifications(unreadMessagesCount);
|
setUnreadMessageNotifications(unreadMessagesCount);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::displayNameChanged, [this](QString displayName) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::displayNameChanged, [this](QString displayName) {
|
||||||
mAccountModelConnection->invokeToCore([this, displayName]() { this->onDisplayNameChanged(displayName); });
|
mAccountModelConnection->invokeToCore([this, displayName]() { onDisplayNameChanged(displayName); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::dialPlanChanged, [this](int index) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::dialPlanChanged, [this](int index) {
|
||||||
auto dialPlan = mDialPlans[index + 1];
|
auto dialPlan = mDialPlans[index + 1];
|
||||||
mAccountModelConnection->invokeToCore([this, dialPlan]() { this->onDialPlanChanged(dialPlan); });
|
mAccountModelConnection->invokeToCore([this, dialPlan]() { onDialPlanChanged(dialPlan); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::registerEnabledChanged, [this](bool enabled) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::registerEnabledChanged, [this](bool enabled) {
|
||||||
mAccountModelConnection->invokeToCore([this, enabled]() { this->onRegisterEnabledChanged(enabled); });
|
mAccountModelConnection->invokeToCore([this, enabled]() { onRegisterEnabledChanged(enabled); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::notificationsAllowedChanged, [this](bool value) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::notificationsAllowedChanged, [this](bool value) {
|
||||||
mAccountModelConnection->invokeToCore([this, value]() { this->onNotificationsAllowedChanged(value); });
|
mAccountModelConnection->invokeToCore([this, value]() { onNotificationsAllowedChanged(value); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::mwiServerAddressChanged, [this](QString value) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::mwiServerAddressChanged, [this](QString value) {
|
||||||
mAccountModelConnection->invokeToCore([this, value]() { this->onMwiServerAddressChanged(value); });
|
mAccountModelConnection->invokeToCore([this, value]() { onMwiServerAddressChanged(value); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::transportChanged, [this](linphone::TransportType value) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::transportChanged, [this](linphone::TransportType value) {
|
||||||
mAccountModelConnection->invokeToCore(
|
mAccountModelConnection->invokeToCore(
|
||||||
[this, value]() { this->onTransportChanged(LinphoneEnums::toString(LinphoneEnums::fromLinphone(value))); });
|
[this, value]() { onTransportChanged(LinphoneEnums::toString(LinphoneEnums::fromLinphone(value))); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::serverAddressChanged, [this](QString value) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::serverAddressChanged, [this](QString value) {
|
||||||
mAccountModelConnection->invokeToCore([this, value]() { this->onServerAddressChanged(value); });
|
mAccountModelConnection->invokeToCore([this, value]() { onServerAddressChanged(value); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::outboundProxyEnabledChanged, [this](bool value) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::outboundProxyEnabledChanged, [this](bool value) {
|
||||||
mAccountModelConnection->invokeToCore([this, value]() { this->onOutboundProxyEnabledChanged(value); });
|
mAccountModelConnection->invokeToCore([this, value]() { onOutboundProxyEnabledChanged(value); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::stunServerChanged, [this](QString value) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::stunServerChanged, [this](QString value) {
|
||||||
mAccountModelConnection->invokeToCore([this, value]() { this->onStunServerChanged(value); });
|
mAccountModelConnection->invokeToCore([this, value]() { onStunServerChanged(value); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::iceEnabledChanged, [this](bool value) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::iceEnabledChanged, [this](bool value) {
|
||||||
mAccountModelConnection->invokeToCore([this, value]() { this->onIceEnabledChanged(value); });
|
mAccountModelConnection->invokeToCore([this, value]() { onIceEnabledChanged(value); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::avpfEnabledChanged, [this](bool value) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::avpfEnabledChanged, [this](bool value) {
|
||||||
mAccountModelConnection->invokeToCore([this, value]() { this->onAvpfEnabledChanged(value); });
|
mAccountModelConnection->invokeToCore([this, value]() { onAvpfEnabledChanged(value); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::bundleModeEnabledChanged, [this](bool value) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::bundleModeEnabledChanged, [this](bool value) {
|
||||||
mAccountModelConnection->invokeToCore([this, value]() { this->onBundleModeEnabledChanged(value); });
|
mAccountModelConnection->invokeToCore([this, value]() { onBundleModeEnabledChanged(value); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::expireChanged, [this](int value) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::expireChanged, [this](int value) {
|
||||||
mAccountModelConnection->invokeToCore([this, value]() { this->onExpireChanged(value); });
|
mAccountModelConnection->invokeToCore([this, value]() { onExpireChanged(value); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::conferenceFactoryAddressChanged, [this](QString value) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::conferenceFactoryAddressChanged, [this](QString value) {
|
||||||
mAccountModelConnection->invokeToCore([this, value]() { this->onConferenceFactoryAddressChanged(value); });
|
mAccountModelConnection->invokeToCore([this, value]() { onConferenceFactoryAddressChanged(value); });
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::audioVideoConferenceFactoryAddressChanged,
|
mAccountModelConnection->makeConnectToModel(&AccountModel::audioVideoConferenceFactoryAddressChanged,
|
||||||
[this](QString value) {
|
[this](QString value) {
|
||||||
mAccountModelConnection->invokeToCore([this, value]() {
|
mAccountModelConnection->invokeToCore([this, value]() {
|
||||||
this->onAudioVideoConferenceFactoryAddressChanged(value);
|
onAudioVideoConferenceFactoryAddressChanged(value);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
mAccountModelConnection->makeConnectToModel(&AccountModel::limeServerUrlChanged, [this](QString value) {
|
mAccountModelConnection->makeConnectToModel(&AccountModel::limeServerUrlChanged, [this](QString value) {
|
||||||
mAccountModelConnection->invokeToCore([this, value]() { this->onLimeServerUrlChanged(value); });
|
mAccountModelConnection->invokeToCore([this, value]() { onLimeServerUrlChanged(value); });
|
||||||
});
|
});
|
||||||
|
|
||||||
// From GUI
|
// From GUI
|
||||||
|
|
@ -252,6 +255,10 @@ void AccountCore::setSelf(QSharedPointer<AccountCore> me) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::shared_ptr<AccountModel> &AccountCore::getModel() const {
|
||||||
|
return mAccountModel;
|
||||||
|
}
|
||||||
|
|
||||||
QString AccountCore::getContactAddress() const {
|
QString AccountCore::getContactAddress() const {
|
||||||
return mContactAddress;
|
return mContactAddress;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,9 +79,12 @@ public:
|
||||||
~AccountCore();
|
~AccountCore();
|
||||||
void setSelf(QSharedPointer<AccountCore> me);
|
void setSelf(QSharedPointer<AccountCore> me);
|
||||||
|
|
||||||
|
const std::shared_ptr<AccountModel> &getModel() const;
|
||||||
|
|
||||||
QString getContactAddress() const;
|
QString getContactAddress() const;
|
||||||
QString getIdentityAddress() const;
|
QString getIdentityAddress() const;
|
||||||
QString getPictureUri() const;
|
QString getPictureUri() const;
|
||||||
|
void onPictureUriChanged(QString uri);
|
||||||
LinphoneEnums::RegistrationState getRegistrationState() const;
|
LinphoneEnums::RegistrationState getRegistrationState() const;
|
||||||
bool getIsDefaultAccount() const;
|
bool getIsDefaultAccount() const;
|
||||||
int getUnreadNotifications() const;
|
int getUnreadNotifications() const;
|
||||||
|
|
@ -91,7 +94,6 @@ public:
|
||||||
int getUnreadMessageNotifications() const;
|
int getUnreadMessageNotifications() const;
|
||||||
void setUnreadMessageNotifications(int unread);
|
void setUnreadMessageNotifications(int unread);
|
||||||
|
|
||||||
void onPictureUriChanged(QString uri);
|
|
||||||
void onRegistrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
void onRegistrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
||||||
linphone::RegistrationState state,
|
linphone::RegistrationState state,
|
||||||
const std::string &message);
|
const std::string &message);
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,6 @@ QSharedPointer<AccountList> AccountList::create() {
|
||||||
|
|
||||||
AccountList::AccountList(QObject *parent) : ListProxy(parent) {
|
AccountList::AccountList(QObject *parent) : ListProxy(parent) {
|
||||||
mustBeInMainThread(getClassName());
|
mustBeInMainThread(getClassName());
|
||||||
connect(CoreModel::getInstance().get(), &CoreModel::accountAdded, this, &AccountList::lUpdate);
|
|
||||||
connect(CoreModel::getInstance().get(), &CoreModel::accountRemoved, this, &AccountList::lUpdate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountList::~AccountList() {
|
AccountList::~AccountList() {
|
||||||
|
|
@ -82,6 +80,9 @@ void AccountList::setSelf(QSharedPointer<AccountList> me) {
|
||||||
mModelConnection->invokeToCore([this, model]() { setDefaultAccount(model); });
|
mModelConnection->invokeToCore([this, model]() { setDefaultAccount(model); });
|
||||||
} else mModelConnection->invokeToCore([this]() { setDefaultAccount(nullptr); });
|
} else mModelConnection->invokeToCore([this]() { setDefaultAccount(nullptr); });
|
||||||
});
|
});
|
||||||
|
mModelConnection->makeConnectToModel(&CoreModel::accountRemoved, &AccountList::lUpdate);
|
||||||
|
mModelConnection->makeConnectToModel(&CoreModel::accountAdded, &AccountList::lUpdate);
|
||||||
|
|
||||||
lUpdate();
|
lUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,10 @@ QString LoginPage::getErrorMessage() const {
|
||||||
|
|
||||||
void LoginPage::setErrorMessage(const QString &error) {
|
void LoginPage::setErrorMessage(const QString &error) {
|
||||||
// force signal emission to display the error even if it doesn't change
|
// force signal emission to display the error even if it doesn't change
|
||||||
mErrorMessage = error;
|
if (mErrorMessage != error) {
|
||||||
emit errorMessageChanged();
|
mErrorMessage = error;
|
||||||
|
emit errorMessageChanged(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginPage::login(const QString &username,
|
void LoginPage::login(const QString &username,
|
||||||
|
|
@ -65,16 +67,15 @@ void LoginPage::login(const QString &username,
|
||||||
QString domain,
|
QString domain,
|
||||||
LinphoneEnums::TransportType transportType) {
|
LinphoneEnums::TransportType transportType) {
|
||||||
App::postModelAsync([=]() {
|
App::postModelAsync([=]() {
|
||||||
QString *error = new QString(tr("Le couple identifiant mot de passe ne correspond pas"));
|
|
||||||
// Create on Model thread.
|
// Create on Model thread.
|
||||||
AccountManager *accountManager = new AccountManager();
|
AccountManager *accountManager = new AccountManager();
|
||||||
connect(accountManager, &AccountManager::registrationStateChanged, this,
|
connect(accountManager, &AccountManager::registrationStateChanged, this,
|
||||||
[accountManager, this, error](linphone::RegistrationState state) mutable {
|
[accountManager, this](linphone::RegistrationState state) mutable {
|
||||||
// View thread
|
// View thread
|
||||||
setRegistrationState(state);
|
setRegistrationState(state);
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case linphone::RegistrationState::Failed: {
|
case linphone::RegistrationState::Failed: {
|
||||||
emit accountManager->errorMessageChanged(*error);
|
setErrorMessage(QString(tr("Le couple identifiant mot de passe ne correspond pas")));
|
||||||
if (accountManager) {
|
if (accountManager) {
|
||||||
accountManager->deleteLater();
|
accountManager->deleteLater();
|
||||||
accountManager = nullptr;
|
accountManager = nullptr;
|
||||||
|
|
@ -82,7 +83,7 @@ void LoginPage::login(const QString &username,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case linphone::RegistrationState::Ok: {
|
case linphone::RegistrationState::Ok: {
|
||||||
emit accountManager->errorMessageChanged("");
|
// setErrorMessage("");
|
||||||
if (accountManager) {
|
if (accountManager) {
|
||||||
accountManager->deleteLater();
|
accountManager->deleteLater();
|
||||||
accountManager = nullptr;
|
accountManager = nullptr;
|
||||||
|
|
@ -102,14 +103,12 @@ void LoginPage::login(const QString &username,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(accountManager, &AccountManager::errorMessageChanged, this,
|
|
||||||
[this](QString errorMessage) { setErrorMessage(errorMessage); });
|
|
||||||
|
|
||||||
connect(accountManager, &AccountManager::destroyed, [error]() { delete error; });
|
|
||||||
|
|
||||||
|
QString error;
|
||||||
if (!accountManager->login(username, password, displayName, domain, LinphoneEnums::toLinphone(transportType),
|
if (!accountManager->login(username, password, displayName, domain, LinphoneEnums::toLinphone(transportType),
|
||||||
error)) {
|
&error)) {
|
||||||
emit accountManager->registrationStateChanged(linphone::RegistrationState::Failed);
|
setErrorMessage(error);
|
||||||
|
emit accountManager->registrationStateChanged(linphone::RegistrationState::None);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public:
|
||||||
const QString &password,
|
const QString &password,
|
||||||
QString displayName = QString(),
|
QString displayName = QString(),
|
||||||
QString domain = QString(),
|
QString domain = QString(),
|
||||||
LinphoneEnums::TransportType transportType = LinphoneEnums::TransportType::Tcp);
|
LinphoneEnums::TransportType transportType = LinphoneEnums::TransportType::Tls);
|
||||||
|
|
||||||
linphone::RegistrationState getRegistrationState() const;
|
linphone::RegistrationState getRegistrationState() const;
|
||||||
void setRegistrationState(linphone::RegistrationState status);
|
void setRegistrationState(linphone::RegistrationState status);
|
||||||
|
|
@ -50,7 +50,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void registrationStateChanged();
|
void registrationStateChanged();
|
||||||
void errorMessageChanged();
|
void errorMessageChanged(QString error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
linphone::RegistrationState mRegistrationState = linphone::RegistrationState::None;
|
linphone::RegistrationState mRegistrationState = linphone::RegistrationState::None;
|
||||||
|
|
@ -59,4 +59,4 @@ private:
|
||||||
DECLARE_ABSTRACT_OBJECT
|
DECLARE_ABSTRACT_OBJECT
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,10 @@ bool AccountManager::login(QString username,
|
||||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||||
auto core = CoreModel::getInstance()->getCore();
|
auto core = CoreModel::getInstance()->getCore();
|
||||||
auto factory = linphone::Factory::get();
|
auto factory = linphone::Factory::get();
|
||||||
auto account = createAccount("use-app-sip-account.rc");
|
QString assistantFile = (!QString::compare(domain, "sip.linphone.org") || domain.isEmpty())
|
||||||
|
? "use-app-sip-account.rc"
|
||||||
|
: "use-other-sip-account.rc";
|
||||||
|
auto account = createAccount(assistantFile);
|
||||||
auto params = account->getParams()->clone();
|
auto params = account->getParams()->clone();
|
||||||
// Sip address.
|
// Sip address.
|
||||||
auto identity = params->getIdentityAddress()->clone();
|
auto identity = params->getIdentityAddress()->clone();
|
||||||
|
|
@ -80,8 +83,20 @@ bool AccountManager::login(QString username,
|
||||||
username = Utils::getUsername(username);
|
username = Utils::getUsername(username);
|
||||||
identity->setUsername(Utils::appStringToCoreString(username));
|
identity->setUsername(Utils::appStringToCoreString(username));
|
||||||
if (!displayName.isEmpty()) identity->setDisplayName(Utils::appStringToCoreString(displayName));
|
if (!displayName.isEmpty()) identity->setDisplayName(Utils::appStringToCoreString(displayName));
|
||||||
identity->setTransport(transportType);
|
if (!domain.isEmpty()) {
|
||||||
if (!domain.isEmpty()) identity->setDomain(Utils::appStringToCoreString(domain));
|
identity->setDomain(Utils::appStringToCoreString(domain));
|
||||||
|
if (!domain.isEmpty() && QString::compare(domain, "sip.linphone.org")) {
|
||||||
|
params->setLimeServerUrl("");
|
||||||
|
auto serverAddress =
|
||||||
|
factory->createAddress(Utils::appStringToCoreString(QStringLiteral("sip:%1").arg(domain)));
|
||||||
|
if (!serverAddress) {
|
||||||
|
*errorMessage = tr("Impossible de créer l'adresse proxy. Merci de vérifier le nom de domaine.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
serverAddress->setTransport(transportType);
|
||||||
|
params->setServerAddress(serverAddress);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (params->setIdentityAddress(identity)) {
|
if (params->setIdentityAddress(identity)) {
|
||||||
qWarning() << log()
|
qWarning() << log()
|
||||||
.arg(QStringLiteral("Unable to set identity address: `%1`."))
|
.arg(QStringLiteral("Unable to set identity address: `%1`."))
|
||||||
|
|
@ -91,7 +106,10 @@ bool AccountManager::login(QString username,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
account->setParams(params);
|
if (account->setParams(params)) {
|
||||||
|
*errorMessage = tr("Impossible de configurer les paramètres du compte.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
core->addAuthInfo(factory->createAuthInfo(Utils::appStringToCoreString(username), // Username.
|
core->addAuthInfo(factory->createAuthInfo(Utils::appStringToCoreString(username), // Username.
|
||||||
"", // User ID.
|
"", // User ID.
|
||||||
Utils::appStringToCoreString(password), // Password.
|
Utils::appStringToCoreString(password), // Password.
|
||||||
|
|
@ -103,7 +121,11 @@ bool AccountManager::login(QString username,
|
||||||
mAccountModel->setSelf(mAccountModel);
|
mAccountModel->setSelf(mAccountModel);
|
||||||
connect(mAccountModel.get(), &AccountModel::registrationStateChanged, this,
|
connect(mAccountModel.get(), &AccountModel::registrationStateChanged, this,
|
||||||
&AccountManager::onRegistrationStateChanged);
|
&AccountManager::onRegistrationStateChanged);
|
||||||
core->addAccount(account);
|
auto status = core->addAccount(account);
|
||||||
|
if (status == -1) {
|
||||||
|
*errorMessage = tr("Impossible d'ajouter le compte.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,7 +177,7 @@ void AccountManager::registerNewAccount(const QString &username,
|
||||||
"", // User ID.
|
"", // User ID.
|
||||||
Utils::appStringToCoreString(password), // Password.
|
Utils::appStringToCoreString(password), // Password.
|
||||||
"", // HA1.
|
"", // HA1.
|
||||||
"", // Realm.
|
createdSipIdentityAddress->getDomain(), // Realm.
|
||||||
createdSipIdentityAddress->getDomain() // Domain.
|
createdSipIdentityAddress->getDomain() // Domain.
|
||||||
));
|
));
|
||||||
if (type == RegisterType::Email) {
|
if (type == RegisterType::Email) {
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ public:
|
||||||
QString domain = QString(),
|
QString domain = QString(),
|
||||||
linphone::TransportType transportType = linphone::TransportType::Udp,
|
linphone::TransportType transportType = linphone::TransportType::Udp,
|
||||||
QString *errorMessage = nullptr);
|
QString *errorMessage = nullptr);
|
||||||
|
|
||||||
std::shared_ptr<linphone::Account> createAccount(const QString &assistantFile);
|
std::shared_ptr<linphone::Account> createAccount(const QString &assistantFile);
|
||||||
|
|
||||||
enum RegisterType { PhoneNumber = 0, Email = 1 };
|
enum RegisterType { PhoneNumber = 0, Email = 1 };
|
||||||
|
|
@ -58,7 +59,6 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void registrationStateChanged(linphone::RegistrationState state);
|
void registrationStateChanged(linphone::RegistrationState state);
|
||||||
void errorMessageChanged(const QString &errorMessage);
|
|
||||||
void newAccountCreationSucceed(QString sipAddress, RegisterType registerType, const QString ®isterAddress);
|
void newAccountCreationSucceed(QString sipAddress, RegisterType registerType, const QString ®isterAddress);
|
||||||
void registerNewAccountFailed(const QString &error);
|
void registerNewAccountFailed(const QString &error);
|
||||||
void tokenConversionSucceed();
|
void tokenConversionSucceed();
|
||||||
|
|
@ -71,7 +71,6 @@ private:
|
||||||
std::shared_ptr<AccountManagerServicesModel> mAccountManagerServicesModel;
|
std::shared_ptr<AccountManagerServicesModel> mAccountManagerServicesModel;
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
QString mCreatedSipAddress;
|
QString mCreatedSipAddress;
|
||||||
// std::shared_ptr<linphone::Address> mCreatedSipIdentityAddress;
|
|
||||||
DECLARE_ABSTRACT_OBJECT
|
DECLARE_ABSTRACT_OBJECT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,11 +71,12 @@ void AccountModel::setPictureUri(QString uri) {
|
||||||
mMonitor->setParams(params);
|
mMonitor->setParams(params);
|
||||||
// Hack because Account doesn't provide callbacks on updated data
|
// Hack because Account doesn't provide callbacks on updated data
|
||||||
// emit pictureUriChanged(uri);
|
// emit pictureUriChanged(uri);
|
||||||
emit CoreModel::getInstance() -> defaultAccountChanged(CoreModel::getInstance()->getCore(),
|
emit CoreModel::getInstance()->defaultAccountChanged(CoreModel::getInstance()->getCore(),
|
||||||
CoreModel::getInstance()->getCore()->getDefaultAccount());
|
CoreModel::getInstance()->getCore()->getDefaultAccount());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountModel::onDefaultAccountChanged() {
|
void AccountModel::onDefaultAccountChanged() {
|
||||||
|
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||||
emit defaultAccountChanged(CoreModel::getInstance()->getCore()->getDefaultAccount() == mMonitor);
|
emit defaultAccountChanged(CoreModel::getInstance()->getCore()->getDefaultAccount() == mMonitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property bool authenticationPopupOpened: false
|
||||||
Component {
|
Component {
|
||||||
id: authenticationPopupComp
|
id: authenticationPopupComp
|
||||||
AuthenticationDialog{
|
AuthenticationDialog{
|
||||||
|
|
@ -50,6 +51,8 @@ ApplicationWindow {
|
||||||
authenticationDialog ? authenticationDialog.result(password) : callback(password)
|
authenticationDialog ? authenticationDialog.result(password) : callback(password)
|
||||||
close()
|
close()
|
||||||
}
|
}
|
||||||
|
onOpened: mainWindow.authenticationPopupOpened = true
|
||||||
|
onClosed: mainWindow.authenticationPopupOpened = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,6 +240,7 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
function reauthenticateAccount(authenticationDialog){
|
function reauthenticateAccount(authenticationDialog){
|
||||||
|
if (authenticationPopupOpened) return
|
||||||
console.log("Showing authentication dialog")
|
console.log("Showing authentication dialog")
|
||||||
var popup = authenticationPopupComp.createObject(mainWindow, {"authenticationDialog": authenticationDialog})
|
var popup = authenticationPopupComp.createObject(mainWindow, {"authenticationDialog": authenticationDialog})
|
||||||
popup.open()
|
popup.open()
|
||||||
|
|
|
||||||
|
|
@ -168,10 +168,10 @@ AbstractDetailsLayout {
|
||||||
propertyOwner: account.core
|
propertyOwner: account.core
|
||||||
}
|
}
|
||||||
SwitchSetting {
|
SwitchSetting {
|
||||||
titleText: account.core.humaneReadableRegistrationState
|
titleText: account?.core.humaneReadableRegistrationState
|
||||||
subTitleText: account.core.humaneReadableRegistrationStateExplained
|
subTitleText: account?.core.humaneReadableRegistrationStateExplained
|
||||||
propertyName: "registerEnabled"
|
propertyName: "registerEnabled"
|
||||||
propertyOwner: account.core
|
propertyOwner: account?.core
|
||||||
}
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id:mainItem
|
id:mainItem
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,9 @@ AppWindow {
|
||||||
AccountProxy {
|
AccountProxy {
|
||||||
id: accountProxy
|
id: accountProxy
|
||||||
onHaveAccountChanged: {
|
onHaveAccountChanged: {
|
||||||
initStackViewItem()
|
// this function can't be used like this. It will show the main page when
|
||||||
|
// trying to connect and then return to login page if connection fails.
|
||||||
|
// initStackViewItem()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StackView {
|
StackView {
|
||||||
|
|
|
||||||
|
|
@ -7,47 +7,15 @@ import Linphone
|
||||||
Text {
|
Text {
|
||||||
id: mainItem
|
id: mainItem
|
||||||
color: DefaultStyle.danger_500main
|
color: DefaultStyle.danger_500main
|
||||||
opacity: 0
|
|
||||||
font {
|
font {
|
||||||
pixelSize: 12 * DefaultStyle.dp
|
pixelSize: 12 * DefaultStyle.dp
|
||||||
weight: 300 * DefaultStyle.dp
|
weight: 300 * DefaultStyle.dp
|
||||||
}
|
}
|
||||||
states: [
|
|
||||||
State{
|
|
||||||
name: "Visible"
|
|
||||||
PropertyChanges{target: mainItem; opacity: 1.0}
|
|
||||||
},
|
|
||||||
State{
|
|
||||||
name:"Invisible"
|
|
||||||
PropertyChanges{target: mainItem; opacity: 0.0; text: ""}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
transitions: [
|
|
||||||
Transition {
|
|
||||||
from: "Visible"
|
|
||||||
to: "Invisible"
|
|
||||||
NumberAnimation {
|
|
||||||
property: "opacity"
|
|
||||||
duration: 500
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
Timer {
|
Timer {
|
||||||
id: autoHideErrorMessage
|
id: autoHideErrorMessage
|
||||||
interval: 2500
|
interval: 2500
|
||||||
onTriggered: mainItem.state = "Invisible"
|
onTriggered: mainItem.text = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpacityChanged: if (opacity === 1) autoHideErrorMessage.restart()
|
onTextChanged: if (mainItem.text.length > 0) autoHideErrorMessage.restart()
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: mainItem
|
|
||||||
function onTextChanged() {
|
|
||||||
if (mainItem.text.length > 0) {
|
|
||||||
mainItem.state = "Visible"
|
|
||||||
} else {
|
|
||||||
mainItem.state = "Invisible"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -13,7 +13,7 @@ FocusScope{
|
||||||
property alias errorTextItem: errorText
|
property alias errorTextItem: errorText
|
||||||
property alias errorMessage: errorText.text
|
property alias errorMessage: errorText.text
|
||||||
property bool enableErrorText: false
|
property bool enableErrorText: false
|
||||||
property bool errorTextVisible: errorText.opacity > 0
|
property bool errorTextVisible: errorText.text.length > 0
|
||||||
implicitHeight: layout.implicitHeight
|
implicitHeight: layout.implicitHeight
|
||||||
implicitWidth: layout.implicitWidth
|
implicitWidth: layout.implicitWidth
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
|
|
||||||
|
|
@ -92,11 +92,7 @@ LoginLayout {
|
||||||
pixelSize: 14 * DefaultStyle.dp
|
pixelSize: 14 * DefaultStyle.dp
|
||||||
weight: 400* DefaultStyle.dp
|
weight: 400* DefaultStyle.dp
|
||||||
}
|
}
|
||||||
text: "Certaines fonctionnalités nécessitent un compte Linphone, comme la messagerie de groupe, les vidéoconférences...
|
text: "Certaines fonctionnalités nécessitent un compte Linphone, comme la messagerie de groupe, les vidéoconférences..."
|
||||||
|
|
||||||
Ces fonctionnalités sont cachées lorsque vous vous enregistrez avec un compte SIP tiers.
|
|
||||||
|
|
||||||
Pour les activer dans un projet commercial, veuillez nous contacter. "
|
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
@ -250,8 +246,8 @@ LoginLayout {
|
||||||
id: errorText
|
id: errorText
|
||||||
Connections {
|
Connections {
|
||||||
target: LoginPageCpp
|
target: LoginPageCpp
|
||||||
function onErrorMessageChanged() {
|
function onErrorMessageChanged(error) {
|
||||||
errorText.text = LoginPageCpp.errorMessage
|
errorText.text = error
|
||||||
}
|
}
|
||||||
function onRegistrationStateChanged() {
|
function onRegistrationStateChanged() {
|
||||||
if (LoginPageCpp.registrationState === LinphoneEnums.RegistrationState.Ok) {
|
if (LoginPageCpp.registrationState === LinphoneEnums.RegistrationState.Ok) {
|
||||||
|
|
@ -296,9 +292,11 @@ LoginLayout {
|
||||||
connectionButtonContent.currentIndex = 0
|
connectionButtonContent.currentIndex = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onErrorMessageChanged() {
|
function onErrorMessageChanged(error) {
|
||||||
connectionButton.enabled = true
|
if (error.length != 0) {
|
||||||
connectionButtonContent.currentIndex = 0
|
connectionButton.enabled = true
|
||||||
|
connectionButtonContent.currentIndex = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -323,21 +321,13 @@ LoginLayout {
|
||||||
connectionButton.enabled = false
|
connectionButton.enabled = false
|
||||||
connectionButtonContent.currentIndex = 1
|
connectionButtonContent.currentIndex = 1
|
||||||
}
|
}
|
||||||
|
onPressed: trigger()
|
||||||
Shortcut {
|
|
||||||
sequences: ["Return", "Enter"]
|
|
||||||
onActivated: if(domain.activeFocus) connectionButton.trigger()
|
|
||||||
else if(username.activeFocus) password.forceActiveFocus()
|
|
||||||
else if(password.activeFocus) domain.forceActiveFocus()
|
|
||||||
}
|
|
||||||
onPressed: connectionButton.trigger()
|
|
||||||
KeyNavigation.up: transportCbox
|
KeyNavigation.up: transportCbox
|
||||||
}
|
}
|
||||||
Item {
|
Item {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
centerContent: [
|
centerContent: [
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,4 @@ AbstractMasterDetailPage {
|
||||||
{title: qsTr("Général"), layout: "AccountSettingsGeneralLayout", model: account},
|
{title: qsTr("Général"), layout: "AccountSettingsGeneralLayout", model: account},
|
||||||
{title: qsTr("Paramètres de compte"), layout: "AccountSettingsParametersLayout", model: account}
|
{title: qsTr("Paramètres de compte"), layout: "AccountSettingsParametersLayout", model: account}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue