mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
fix login
This commit is contained in:
parent
05b7251797
commit
2e93b769d0
4 changed files with 38 additions and 16 deletions
|
|
@ -70,18 +70,21 @@ bool AccountManager::login(QString username,
|
|||
auto params = account->getParams()->clone();
|
||||
// Sip address.
|
||||
auto identity = params->getIdentityAddress()->clone();
|
||||
username = Utils::getUsername(username);
|
||||
identity->setUsername(Utils::appStringToCoreString(username));
|
||||
|
||||
if (mAccountModel) return false;
|
||||
auto accounts = core->getAccountList();
|
||||
for (auto account : accounts) {
|
||||
if (account->getParams()->getIdentityAddress()->getUsername() == Utils::appStringToCoreString(username)) {
|
||||
|
||||
auto otherAccounts = core->getAccountList();
|
||||
for (auto otherAccount : otherAccounts) {
|
||||
auto otherParams = otherAccount->getParams();
|
||||
if (otherParams->getIdentityAddress()->getUsername() == Utils::appStringToCoreString(username) &&
|
||||
otherParams->getDomain() == Utils::appStringToCoreString(domain)) {
|
||||
*errorMessage = tr("Le compte est déjà connecté");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
username = Utils::getUsername(username);
|
||||
identity->setUsername(Utils::appStringToCoreString(username));
|
||||
if (!displayName.isEmpty()) identity->setDisplayName(Utils::appStringToCoreString(displayName));
|
||||
if (!domain.isEmpty()) {
|
||||
identity->setDomain(Utils::appStringToCoreString(domain));
|
||||
|
|
@ -110,17 +113,26 @@ bool AccountManager::login(QString username,
|
|||
*errorMessage = tr("Impossible de configurer les paramètres du compte.");
|
||||
return false;
|
||||
}
|
||||
core->addAuthInfo(factory->createAuthInfo(Utils::appStringToCoreString(username), // Username.
|
||||
"", // User ID.
|
||||
Utils::appStringToCoreString(password), // Password.
|
||||
"", // HA1.
|
||||
"", // Realm.
|
||||
identity->getDomain() // Domain.
|
||||
));
|
||||
auto authInfo = factory->createAuthInfo(Utils::appStringToCoreString(username), // Username.
|
||||
"", // User ID.
|
||||
Utils::appStringToCoreString(password), // Password.
|
||||
"", // HA1.
|
||||
"", // Realm.
|
||||
identity->getDomain() // Domain.
|
||||
);
|
||||
core->addAuthInfo(authInfo);
|
||||
mAccountModel = Utils::makeQObject_ptr<AccountModel>(account);
|
||||
mAccountModel->setSelf(mAccountModel);
|
||||
connect(mAccountModel.get(), &AccountModel::registrationStateChanged, this,
|
||||
&AccountManager::onRegistrationStateChanged);
|
||||
[this, authInfo](const std::shared_ptr<linphone::Account> &account, linphone::RegistrationState state,
|
||||
const std::string &message) {
|
||||
if (account == mAccountModel->getAccount() && state == linphone::RegistrationState::Failed) {
|
||||
auto core = CoreModel::getInstance()->getCore();
|
||||
core->removeAuthInfo(authInfo);
|
||||
core->removeAccount(account);
|
||||
}
|
||||
emit onRegistrationStateChanged(account, state, message);
|
||||
});
|
||||
auto status = core->addAccount(account);
|
||||
if (status == -1) {
|
||||
*errorMessage = tr("Impossible d'ajouter le compte.");
|
||||
|
|
|
|||
|
|
@ -107,11 +107,20 @@ void AccountModel::setDefault() {
|
|||
}
|
||||
|
||||
void AccountModel::removeAccount() {
|
||||
CoreModel::getInstance()->getCore()->removeAccount(mMonitor);
|
||||
auto core = CoreModel::getInstance()->getCore();
|
||||
auto authInfo = mMonitor->findAuthInfo();
|
||||
if (authInfo) {
|
||||
core->removeAuthInfo(authInfo);
|
||||
}
|
||||
core->removeAccount(mMonitor);
|
||||
removeUserData(mMonitor);
|
||||
emit removed();
|
||||
}
|
||||
|
||||
std::shared_ptr<linphone::Account> AccountModel::getAccount() const {
|
||||
return mMonitor;
|
||||
}
|
||||
|
||||
void AccountModel::resetMissedCallsCount() {
|
||||
mMonitor->resetMissedCallsCount();
|
||||
emit unreadNotificationsChanged(0 /*mMonitor->getUnreadChatMessageCount()*/,
|
||||
|
|
@ -189,7 +198,7 @@ void AccountModel::setNotificationsAllowed(bool value) {
|
|||
QString AccountModel::getMwiServerAddress() const {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
auto mwiAddress = mMonitor->getParams()->getMwiServerAddress();
|
||||
return mwiAddress ? Utils::coreStringToAppString(mwiAddress->asString()): "";
|
||||
return mwiAddress ? Utils::coreStringToAppString(mwiAddress->asString()) : "";
|
||||
}
|
||||
|
||||
void AccountModel::setMwiServerAddress(QString value) {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ public:
|
|||
void setPictureUri(QString uri);
|
||||
void setDefault();
|
||||
void removeAccount();
|
||||
std::shared_ptr<linphone::Account> getAccount() const;
|
||||
void resetMissedCallsCount();
|
||||
void refreshUnreadNotifications();
|
||||
int getMissedCallsCount() const;
|
||||
|
|
|
|||
|
|
@ -680,7 +680,7 @@ AbstractMainPage {
|
|||
anchors.fill: parent
|
||||
IconLabelButton {
|
||||
Layout.fillWidth: true
|
||||
text: detailOptions.friendGui ? qsTr("Voir le contact") : qsTr("Ajouter aux contacts")
|
||||
text: contactDetail.contact ? qsTr("Voir le contact") : qsTr("Ajouter aux contacts")
|
||||
icon.source: AppIcons.plusCircle
|
||||
icon.width: 32 * DefaultStyle.dp
|
||||
icon.height: 32 * DefaultStyle.dp
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue