diff --git a/linphone-app/src/components/core/CoreHandlers.cpp b/linphone-app/src/components/core/CoreHandlers.cpp index aff12c458..b6d70f658 100644 --- a/linphone-app/src/components/core/CoreHandlers.cpp +++ b/linphone-app/src/components/core/CoreHandlers.cpp @@ -81,11 +81,18 @@ void CoreHandlers::notifyCoreStarted () { // ----------------------------------------------------------------------------- void CoreHandlers::onAuthenticationRequested ( - const shared_ptr &, + const shared_ptr & core, const shared_ptr &authInfo, linphone::AuthMethod ) { - emit authenticationRequested(authInfo); + auto configList = core->getProxyConfigList(); + auto config = configList.begin() ; + std::string username = authInfo->getUsername(); + std::string domain = authInfo->getDomain(); + while(config != configList.end() && ((*config)->getContact()->getUsername() != username || (*config)->getContact()->getDomain() != domain)) + ++config; + if( config != configList.end() ) + emit authenticationRequested(authInfo);// Send authentification request only if a proxy still exists } void CoreHandlers::onCallEncryptionChanged ( diff --git a/linphone-app/src/components/settings/AccountSettingsModel.cpp b/linphone-app/src/components/settings/AccountSettingsModel.cpp index bd7734797..9d4751d42 100644 --- a/linphone-app/src/components/settings/AccountSettingsModel.cpp +++ b/linphone-app/src/components/settings/AccountSettingsModel.cpp @@ -80,7 +80,7 @@ void AccountSettingsModel::setUsedSipAddress (const shared_ptrasStringUriOnly()); + return Utils::coreStringToAppString(getUsedSipAddress()->asStringUriOnly()); } // ----------------------------------------------------------------------------- @@ -188,12 +188,17 @@ void AccountSettingsModel::setDefaultProxyConfigFromSipAddress (const QString &s qWarning() << "Unable to set default proxy config from:" << sipAddress; } - void AccountSettingsModel::removeProxyConfig (const shared_ptr &proxyConfig) { Q_CHECK_PTR(proxyConfig); - + CoreManager *coreManager = CoreManager::getInstance(); - coreManager->getCore()->removeProxyConfig(proxyConfig); + std::list> allProxies = coreManager->getCore()->getProxyConfigList(); + std::shared_ptr proxyAddress = proxyConfig->getIdentityAddress(); + + coreManager->getCore()->removeProxyConfig(proxyConfig);// Remove first to avoid requesting password when deleting it + if(proxyConfig->findAuthInfo()) + coreManager->getCore()->removeAuthInfo(proxyConfig->findAuthInfo());// Remove passwords + coreManager->getSettingsModel()->configureRlsUri(); emit accountSettingsUpdated(); @@ -339,7 +344,7 @@ void AccountSettingsModel::setUsername (const QString &username) { AccountSettingsModel::RegistrationState AccountSettingsModel::getRegistrationState () const { shared_ptr proxyConfig = CoreManager::getInstance()->getCore()->getDefaultProxyConfig(); - return proxyConfig ? mapLinphoneRegistrationStateToUi(proxyConfig->getState()) : RegistrationStateNotRegistered; + return proxyConfig ? mapLinphoneRegistrationStateToUi(proxyConfig->getState()) : RegistrationStateNoProxy; } // ----------------------------------------------------------------------------- @@ -394,6 +399,7 @@ QVariantList AccountSettingsModel::getAccounts () const { QVariantMap account; account["sipAddress"] = Utils::coreStringToAppString(core->createPrimaryContactParsed()->asStringUriOnly()); account["unreadMessageCount"] = core->getUnreadChatMessageCountFromLocal(core->createPrimaryContactParsed()); + account["proxyConfig"].setValue(nullptr); accounts << account; } diff --git a/linphone-app/src/components/settings/AccountSettingsModel.hpp b/linphone-app/src/components/settings/AccountSettingsModel.hpp index 98c54704e..e1bbe868c 100644 --- a/linphone-app/src/components/settings/AccountSettingsModel.hpp +++ b/linphone-app/src/components/settings/AccountSettingsModel.hpp @@ -48,7 +48,8 @@ public: enum RegistrationState { RegistrationStateRegistered, RegistrationStateNotRegistered, - RegistrationStateInProgress + RegistrationStateInProgress, + RegistrationStateNoProxy, }; Q_ENUM(RegistrationState); @@ -63,7 +64,7 @@ public: Q_INVOKABLE QVariantMap getProxyConfigDescription (const std::shared_ptr &proxyConfig); - Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr &proxyConfig); + Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr &proxyConfig = nullptr); Q_INVOKABLE void setDefaultProxyConfigFromSipAddress (const QString &sipAddress); Q_INVOKABLE bool addOrUpdateProxyConfig (const std::shared_ptr &proxyConfig, const QVariantMap &data); diff --git a/linphone-app/ui/modules/Linphone/Account/AccountStatus.qml b/linphone-app/ui/modules/Linphone/Account/AccountStatus.qml index 6d0233642..940332047 100644 --- a/linphone-app/ui/modules/Linphone/Account/AccountStatus.qml +++ b/linphone-app/ui/modules/Linphone/Account/AccountStatus.qml @@ -1,4 +1,5 @@ import QtQuick 2.7 +import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import Common 1.0 @@ -48,7 +49,10 @@ Item { Icon { iconSize: parent.width icon: 'generic_error' - visible: AccountSettingsModel.registrationState === AccountSettingsModel.RegistrationStateNotRegistered + visible: AccountSettingsModel.registrationState === AccountSettingsModel.RegistrationStateNotRegistered || AccountSettingsModel.registrationState === AccountSettingsModel.RegistrationStateNoProxy + TooltipArea{ + text : 'Not Registered' + } } } diff --git a/linphone-app/ui/views/App/Main/Dialogs/ManageAccounts.qml b/linphone-app/ui/views/App/Main/Dialogs/ManageAccounts.qml index 773e8d5ac..be4575cfe 100644 --- a/linphone-app/ui/views/App/Main/Dialogs/ManageAccounts.qml +++ b/linphone-app/ui/views/App/Main/Dialogs/ManageAccounts.qml @@ -81,17 +81,20 @@ DialogPlus { itemIcon: Logic.getItemIcon(flattenedModel) width: parent.width - ActionButton { - icon: 'options' - iconSize: 30 - anchors.fill: parent - visible:false + ActionButton { + icon: 'options' + iconSize: 30 + anchors.fill: parent + visible:false //TODO handle click and jump to proxy config settings - } + } onClicked: { container.currentIndex = index - AccountSettingsModel.setDefaultProxyConfig(flattenedModel.proxyConfig) + if(flattenedModel.proxyConfig) + AccountSettingsModel.setDefaultProxyConfig(flattenedModel.proxyConfig) + else + AccountSettingsModel.setDefaultProxyConfig() } MessageCounter { diff --git a/linphone-app/ui/views/App/Main/MainWindow.qml b/linphone-app/ui/views/App/Main/MainWindow.qml index b92cbeb1e..fd195ad0e 100644 --- a/linphone-app/ui/views/App/Main/MainWindow.qml +++ b/linphone-app/ui/views/App/Main/MainWindow.qml @@ -112,7 +112,10 @@ ApplicationWindow { text: AccountSettingsModel.sipAddress } - onClicked: Logic.manageAccounts() + onClicked: {if(AccountSettingsModel.registrationState !== AccountSettingsModel.RegistrationStateRegistered && AccountSettingsModel.registrationState !== AccountSettingsModel.RegistrationStateNoProxy) + CoreManager.forceRefreshRegisters() + Logic.manageAccounts() + } } Column { @@ -279,28 +282,6 @@ ApplicationWindow { } } - // --------------------------------------------------------------------------- - // Hiden button to force registration. - // --------------------------------------------------------------------------- - - Button { - anchors { - top: parent.top - left: parent.left - } - - background: Rectangle { - color: 'transparent' // Not a style. - } - - flat: true - - height: MainWindowStyle.toolBar.height - width: MainWindowStyle.toolBar.leftMargin - - onClicked: CoreManager.forceRefreshRegisters() - } - // --------------------------------------------------------------------------- // Url handlers. // ---------------------------------------------------------------------------