- Send authentification request only if a proxy still exists for this auth

- remove auth infos when removing proxy
- add a "Not Proxy" state for registration to know if the current proxy is a candidate to registration
- Adapt Account Model to ensure to use pointer when mixing javascript/C++
- When clicking on Accounts, force authentification request if the current proxy is not registered
This commit is contained in:
Julien Wadel 2020-05-03 22:58:24 +02:00
parent 2b1c4bb771
commit dbf1f6801a
6 changed files with 42 additions and 40 deletions

View file

@ -81,11 +81,18 @@ void CoreHandlers::notifyCoreStarted () {
// -----------------------------------------------------------------------------
void CoreHandlers::onAuthenticationRequested (
const shared_ptr<linphone::Core> &,
const shared_ptr<linphone::Core> & core,
const shared_ptr<linphone::AuthInfo> &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 (

View file

@ -80,7 +80,7 @@ void AccountSettingsModel::setUsedSipAddress (const shared_ptr<const linphone::A
}
QString AccountSettingsModel::getUsedSipAddressAsString () const {
return Utils::coreStringToAppString(getUsedSipAddress()->asStringUriOnly());
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<linphone::ProxyConfig> &proxyConfig) {
Q_CHECK_PTR(proxyConfig);
CoreManager *coreManager = CoreManager::getInstance();
coreManager->getCore()->removeProxyConfig(proxyConfig);
std::list<std::shared_ptr<linphone::ProxyConfig>> allProxies = coreManager->getCore()->getProxyConfigList();
std::shared_ptr<const linphone::Address> 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<linphone::ProxyConfig> 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;
}

View file

@ -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<linphone::ProxyConfig> &proxyConfig);
Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig = nullptr);
Q_INVOKABLE void setDefaultProxyConfigFromSipAddress (const QString &sipAddress);
Q_INVOKABLE bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig, const QVariantMap &data);

View file

@ -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'
}
}
}

View file

@ -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 {

View file

@ -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.
// ---------------------------------------------------------------------------