Show local accounts display name instead of username.

This commit is contained in:
Julien Wadel 2023-03-07 12:08:46 +01:00
parent b13e88b523
commit 66982bd0c3
2 changed files with 25 additions and 11 deletions

View file

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Crash on chat rooms with default account.
- Show display name for local accounts.
## 5.0.12 - 2023-03-01

View file

@ -538,17 +538,30 @@ QString Utils::getDisplayName(const std::shared_ptr<const linphone::Address>& ad
// Try to get display from full address
displayName = QString::fromStdString(address->getDisplayName());
if( displayName == ""){
// Try to get display name from logs
auto callHistory = CoreManager::getInstance()->getCore()->getCallLogs();
auto callLog = std::find_if(callHistory.begin(), callHistory.end(), [address](std::shared_ptr<linphone::CallLog>& cl){
return cl->getRemoteAddress()->weakEqual(address);
});
if(callLog != callHistory.end())
displayName = QString::fromStdString((*callLog)->getRemoteAddress()->getDisplayName());
if(displayName == "")
displayName = QString::fromStdString(address->getDisplayName());
if(displayName == "")
displayName = Utils::coreStringToAppString(address->getUsername());
// Try to get display name from proxies
auto accounts = CoreManager::getInstance()->getCore()->getAccountList();
for(auto accountIt = accounts.begin() ; displayName=="" && accountIt != accounts.end() ; ++accountIt){
auto params = accountIt->get()->getParams();
if(params){
auto accountAddress = params->getIdentityAddress();
if(accountAddress && accountAddress->weakEqual(address)){
displayName = Utils::coreStringToAppString(accountAddress->getDisplayName());
}
}
}
if(displayName == ""){
// Try to get display name from logs
auto callHistory = CoreManager::getInstance()->getCore()->getCallLogs();
auto callLog = std::find_if(callHistory.begin(), callHistory.end(), [address](std::shared_ptr<linphone::CallLog>& cl){
return cl->getRemoteAddress()->weakEqual(address);
});
if(callLog != callHistory.end())
displayName = QString::fromStdString((*callLog)->getRemoteAddress()->getDisplayName());
if(displayName == "")
displayName = QString::fromStdString(address->getDisplayName());
if(displayName == "")
displayName = Utils::coreStringToAppString(address->getUsername());
}
}
}
}