diff --git a/CHANGELOG.md b/CHANGELOG.md index 06949d8c4..c98cdb59f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/linphone-app/src/utils/Utils.cpp b/linphone-app/src/utils/Utils.cpp index cf74df505..8f768aa47 100644 --- a/linphone-app/src/utils/Utils.cpp +++ b/linphone-app/src/utils/Utils.cpp @@ -538,17 +538,30 @@ QString Utils::getDisplayName(const std::shared_ptr& 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& 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& 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()); + } } } }