update display name in call history when ldap friends cache cleared

This commit is contained in:
gaelle 2025-04-09 16:15:22 +02:00
parent 9c89394631
commit 03e187fef6
10 changed files with 56 additions and 10 deletions

View file

@ -127,6 +127,16 @@ void CallHistoryCore::setSelf(QSharedPointer<CallHistoryCore> me) {
mCoreModelConnection->makeConnectToModel(&CoreModel::friendCreated, update);
mCoreModelConnection->makeConnectToModel(&CoreModel::friendUpdated, update);
mCoreModelConnection->makeConnectToModel(&CoreModel::friendRemoved, &CallHistoryCore::onRemoved);
// Update display name when display name has been requested from magic search cause not found in linphone friends
// (required to get the right display name if ldap friends cleared)
mCoreModelConnection->makeConnectToModel(&CoreModel::magicSearchResultReceived, [this, remoteAddress = mRemoteAddress] {
auto displayName = ToolModel::getDisplayName(remoteAddress);
mCoreModelConnection->invokeToCore([this, displayName]() {
mDisplayName = displayName;
emit displayNameChanged();
});
});
}
ConferenceInfoGui *CallHistoryCore::getConferenceInfoGui() const {

View file

@ -44,7 +44,7 @@ ParticipantDeviceCore::ParticipantDeviceCore(const std::shared_ptr<linphone::Par
mustBeInLinphoneThread(getClassName());
if (device) {
mName = Utils::coreStringToAppString(device->getName());
auto deviceAddress = device->getAddress();
auto deviceAddress = device->getAddress()->clone();
mUniqueAddress = Utils::coreStringToAppString(deviceAddress->asString());
mAddress = Utils::coreStringToAppString(deviceAddress->asStringUriOnly());
// the display name of the device himself may be the uncleaned sip uri

View file

@ -110,7 +110,7 @@ linphone::ConferenceInfo::State ConferenceInfoModel::getState() const {
QString ConferenceInfoModel::getOrganizerName() const {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
auto organizer = mConferenceInfo->getOrganizer();
auto organizer = mConferenceInfo->getOrganizer()->clone();
auto name = Utils::coreStringToAppString(organizer->getDisplayName());
if (name.isEmpty()) name = ToolModel::getDisplayName(organizer);
return name;

View file

@ -118,6 +118,14 @@ void CoreModel::start() {
if (mCore->getLogCollectionUploadServerUrl().empty())
mCore->setLogCollectionUploadServerUrl(Constants::DefaultUploadLogsServer);
mIterateTimer->start();
auto linphoneSearch = mCore->createMagicSearch();
linphoneSearch->setLimitedSearch(true);
mMagicSearch = Utils::makeQObject_ptr<MagicSearchModel>(linphoneSearch);
mMagicSearch->setSelf(mMagicSearch);
connect(mMagicSearch.get(), &MagicSearchModel::searchResultsReceived, this, [this] {
emit magicSearchResultReceived(mMagicSearch->mLastSearch);
});
}
// -----------------------------------------------------------------------------
@ -345,6 +353,12 @@ void CoreModel::migrate() {
config->setInt(SettingsModel::UiSection, Constants::RcVersionName, Constants::RcVersionCurrent);
}
void CoreModel::searchInMagicSearch(QString filter, int sourceFlags,
LinphoneEnums::MagicSearchAggregation aggregation,
int maxResults) {
mMagicSearch->search(filter, sourceFlags, aggregation, maxResults);
}
//---------------------------------------------------------------------------------------------------------------------------
void CoreModel::onAccountAdded(const std::shared_ptr<linphone::Core> &core,

View file

@ -35,6 +35,7 @@
#include "model/listener/Listener.hpp"
#include "model/logger/LoggerModel.hpp"
#include "tool/AbstractObject.hpp"
#include "model/search/MagicSearchModel.hpp"
// =============================================================================
@ -59,6 +60,11 @@ public:
bool setFetchConfig(QString filePath);
void migrate();
void searchInMagicSearch(QString filter,
int sourceFlags,
LinphoneEnums::MagicSearchAggregation aggregation,
int maxResults);
bool mEnd = false;
std::shared_ptr<linphone::Core> mCore;
@ -75,11 +81,13 @@ signals:
void requestFetchConfig(QString path);
void requestRestart();
void enabledLdapAddressBookSaved();
void magicSearchResultReceived(QString filter);
private:
QString mConfigPath;
QTimer *mIterateTimer = nullptr;
QMap<QString, OIDCModel *> mOpenIdConnections;
std::shared_ptr<MagicSearchModel> mMagicSearch;
void setPathBeforeCreation();
void setPathsAfterCreation();

View file

@ -77,5 +77,5 @@ void VariantObject::setDefaultValue(QVariant value) {
mCoreObject->setDefaultValue(value);
}
void VariantObject::requestValue() {
emit mCoreObject->requestValue();
if (mCoreObject) emit mCoreObject->requestValue();
}

View file

@ -78,10 +78,10 @@ std::shared_ptr<linphone::AudioDevice> ToolModel::findAudioDevice(const QString
return nullptr;
}
QString ToolModel::getDisplayName(const std::shared_ptr<const linphone::Address> &address) {
QString ToolModel::getDisplayName(const std::shared_ptr<linphone::Address> &address) {
QString displayName;
if (address) {
auto linFriend = CoreModel::getInstance()->getCore()->findFriend(address);
auto linFriend = ToolModel::findFriendByAddress(address);
if (linFriend) {
if (displayName.isEmpty()) displayName = Utils::coreStringToAppString(linFriend->getName());
}
@ -119,11 +119,22 @@ std::shared_ptr<linphone::Friend> ToolModel::findFriendByAddress(const QString &
auto defaultFriendList = CoreModel::getInstance()->getCore()->getDefaultFriendList();
if (!defaultFriendList) return nullptr;
auto linphoneAddr = ToolModel::interpretUrl(address);
return CoreModel::getInstance()->getCore()->findFriend(linphoneAddr);
if (linphoneAddr)
return ToolModel::findFriendByAddress(linphoneAddr);
else
return nullptr;
}
std::shared_ptr<linphone::Friend> ToolModel::findFriendByAddress(std::shared_ptr<linphone::Address> linphoneAddr) {
return CoreModel::getInstance()->getCore()->findFriend(linphoneAddr);
auto f = CoreModel::getInstance()->getCore()->findFriend(linphoneAddr);
if (!f) {
qDebug() << "Couldn't find friend" << linphoneAddr->asStringUriOnly() << "in core, use magic search";
CoreModel::getInstance()->searchInMagicSearch(Utils::coreStringToAppString(linphoneAddr->asStringUriOnly()),
(int)linphone::MagicSearch::Source::LdapServers
| (int)linphone::MagicSearch::Source::RemoteCardDAV
, LinphoneEnums::MagicSearchAggregation::Friend, 50);
}
return f;
}
bool ToolModel::createCall(const QString &sipAddress,

View file

@ -47,7 +47,7 @@ public:
static bool isLocal(const std::shared_ptr<linphone::Conference> &conference,
const std::shared_ptr<const linphone::ParticipantDevice> &device);
static QString getDisplayName(const std::shared_ptr<const linphone::Address> &address);
static QString getDisplayName(const std::shared_ptr<linphone::Address> &address);
static QString getDisplayName(QString address);
static std::shared_ptr<linphone::Friend> findFriendByAddress(const QString &address);

View file

@ -225,6 +225,8 @@ VariantObject *Utils::haveAccount() {
return CoreModel::getInstance()->getCore()->getAccountList().size() > 0;
});
result->makeUpdate(CoreModel::getInstance().get(), &CoreModel::accountAdded);
result->makeUpdate(CoreModel::getInstance().get(), &CoreModel::accountRemoved);
result->requestValue();
return result;
}
@ -418,6 +420,7 @@ VariantObject *Utils::findFriendByAddress(const QString &address) {
};
data->makeUpdateCond(CoreModel::getInstance().get(), &CoreModel::friendCreated, updateValue); // New Friend
data->makeUpdateCond(CoreModel::getInstance().get(), &CoreModel::friendRemoved, updateValue); // New Friend
data->makeUpdateCond(CoreModel::getInstance().get(), &CoreModel::friendUpdated, updateValue);
data->requestValue();
return data;
}

View file

@ -104,8 +104,8 @@ ListView {
//----------------------------------------------------------------
onVisibleChanged: {
if (!visible)
currentIndex = -1
// if (!visible)
// currentIndex = -1
}
BusyIndicator {