update display name in call history when ldap friends cache cleared
This commit is contained in:
parent
9c89394631
commit
03e187fef6
10 changed files with 56 additions and 10 deletions
|
|
@ -127,6 +127,16 @@ void CallHistoryCore::setSelf(QSharedPointer<CallHistoryCore> me) {
|
||||||
mCoreModelConnection->makeConnectToModel(&CoreModel::friendCreated, update);
|
mCoreModelConnection->makeConnectToModel(&CoreModel::friendCreated, update);
|
||||||
mCoreModelConnection->makeConnectToModel(&CoreModel::friendUpdated, update);
|
mCoreModelConnection->makeConnectToModel(&CoreModel::friendUpdated, update);
|
||||||
mCoreModelConnection->makeConnectToModel(&CoreModel::friendRemoved, &CallHistoryCore::onRemoved);
|
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 {
|
ConferenceInfoGui *CallHistoryCore::getConferenceInfoGui() const {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ ParticipantDeviceCore::ParticipantDeviceCore(const std::shared_ptr<linphone::Par
|
||||||
mustBeInLinphoneThread(getClassName());
|
mustBeInLinphoneThread(getClassName());
|
||||||
if (device) {
|
if (device) {
|
||||||
mName = Utils::coreStringToAppString(device->getName());
|
mName = Utils::coreStringToAppString(device->getName());
|
||||||
auto deviceAddress = device->getAddress();
|
auto deviceAddress = device->getAddress()->clone();
|
||||||
mUniqueAddress = Utils::coreStringToAppString(deviceAddress->asString());
|
mUniqueAddress = Utils::coreStringToAppString(deviceAddress->asString());
|
||||||
mAddress = Utils::coreStringToAppString(deviceAddress->asStringUriOnly());
|
mAddress = Utils::coreStringToAppString(deviceAddress->asStringUriOnly());
|
||||||
// the display name of the device himself may be the uncleaned sip uri
|
// the display name of the device himself may be the uncleaned sip uri
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ linphone::ConferenceInfo::State ConferenceInfoModel::getState() const {
|
||||||
|
|
||||||
QString ConferenceInfoModel::getOrganizerName() const {
|
QString ConferenceInfoModel::getOrganizerName() const {
|
||||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||||
auto organizer = mConferenceInfo->getOrganizer();
|
auto organizer = mConferenceInfo->getOrganizer()->clone();
|
||||||
auto name = Utils::coreStringToAppString(organizer->getDisplayName());
|
auto name = Utils::coreStringToAppString(organizer->getDisplayName());
|
||||||
if (name.isEmpty()) name = ToolModel::getDisplayName(organizer);
|
if (name.isEmpty()) name = ToolModel::getDisplayName(organizer);
|
||||||
return name;
|
return name;
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,14 @@ void CoreModel::start() {
|
||||||
if (mCore->getLogCollectionUploadServerUrl().empty())
|
if (mCore->getLogCollectionUploadServerUrl().empty())
|
||||||
mCore->setLogCollectionUploadServerUrl(Constants::DefaultUploadLogsServer);
|
mCore->setLogCollectionUploadServerUrl(Constants::DefaultUploadLogsServer);
|
||||||
mIterateTimer->start();
|
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);
|
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,
|
void CoreModel::onAccountAdded(const std::shared_ptr<linphone::Core> &core,
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
#include "model/listener/Listener.hpp"
|
#include "model/listener/Listener.hpp"
|
||||||
#include "model/logger/LoggerModel.hpp"
|
#include "model/logger/LoggerModel.hpp"
|
||||||
#include "tool/AbstractObject.hpp"
|
#include "tool/AbstractObject.hpp"
|
||||||
|
#include "model/search/MagicSearchModel.hpp"
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
|
|
@ -59,6 +60,11 @@ public:
|
||||||
bool setFetchConfig(QString filePath);
|
bool setFetchConfig(QString filePath);
|
||||||
void migrate();
|
void migrate();
|
||||||
|
|
||||||
|
void searchInMagicSearch(QString filter,
|
||||||
|
int sourceFlags,
|
||||||
|
LinphoneEnums::MagicSearchAggregation aggregation,
|
||||||
|
int maxResults);
|
||||||
|
|
||||||
bool mEnd = false;
|
bool mEnd = false;
|
||||||
|
|
||||||
std::shared_ptr<linphone::Core> mCore;
|
std::shared_ptr<linphone::Core> mCore;
|
||||||
|
|
@ -75,11 +81,13 @@ signals:
|
||||||
void requestFetchConfig(QString path);
|
void requestFetchConfig(QString path);
|
||||||
void requestRestart();
|
void requestRestart();
|
||||||
void enabledLdapAddressBookSaved();
|
void enabledLdapAddressBookSaved();
|
||||||
|
void magicSearchResultReceived(QString filter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mConfigPath;
|
QString mConfigPath;
|
||||||
QTimer *mIterateTimer = nullptr;
|
QTimer *mIterateTimer = nullptr;
|
||||||
QMap<QString, OIDCModel *> mOpenIdConnections;
|
QMap<QString, OIDCModel *> mOpenIdConnections;
|
||||||
|
std::shared_ptr<MagicSearchModel> mMagicSearch;
|
||||||
|
|
||||||
void setPathBeforeCreation();
|
void setPathBeforeCreation();
|
||||||
void setPathsAfterCreation();
|
void setPathsAfterCreation();
|
||||||
|
|
|
||||||
|
|
@ -77,5 +77,5 @@ void VariantObject::setDefaultValue(QVariant value) {
|
||||||
mCoreObject->setDefaultValue(value);
|
mCoreObject->setDefaultValue(value);
|
||||||
}
|
}
|
||||||
void VariantObject::requestValue() {
|
void VariantObject::requestValue() {
|
||||||
emit mCoreObject->requestValue();
|
if (mCoreObject) emit mCoreObject->requestValue();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,10 +78,10 @@ std::shared_ptr<linphone::AudioDevice> ToolModel::findAudioDevice(const QString
|
||||||
return nullptr;
|
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;
|
QString displayName;
|
||||||
if (address) {
|
if (address) {
|
||||||
auto linFriend = CoreModel::getInstance()->getCore()->findFriend(address);
|
auto linFriend = ToolModel::findFriendByAddress(address);
|
||||||
if (linFriend) {
|
if (linFriend) {
|
||||||
if (displayName.isEmpty()) displayName = Utils::coreStringToAppString(linFriend->getName());
|
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();
|
auto defaultFriendList = CoreModel::getInstance()->getCore()->getDefaultFriendList();
|
||||||
if (!defaultFriendList) return nullptr;
|
if (!defaultFriendList) return nullptr;
|
||||||
auto linphoneAddr = ToolModel::interpretUrl(address);
|
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) {
|
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,
|
bool ToolModel::createCall(const QString &sipAddress,
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public:
|
||||||
static bool isLocal(const std::shared_ptr<linphone::Conference> &conference,
|
static bool isLocal(const std::shared_ptr<linphone::Conference> &conference,
|
||||||
const std::shared_ptr<const linphone::ParticipantDevice> &device);
|
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 QString getDisplayName(QString address);
|
||||||
|
|
||||||
static std::shared_ptr<linphone::Friend> findFriendByAddress(const QString &address);
|
static std::shared_ptr<linphone::Friend> findFriendByAddress(const QString &address);
|
||||||
|
|
|
||||||
|
|
@ -225,6 +225,8 @@ VariantObject *Utils::haveAccount() {
|
||||||
return CoreModel::getInstance()->getCore()->getAccountList().size() > 0;
|
return CoreModel::getInstance()->getCore()->getAccountList().size() > 0;
|
||||||
});
|
});
|
||||||
result->makeUpdate(CoreModel::getInstance().get(), &CoreModel::accountAdded);
|
result->makeUpdate(CoreModel::getInstance().get(), &CoreModel::accountAdded);
|
||||||
|
result->makeUpdate(CoreModel::getInstance().get(), &CoreModel::accountRemoved);
|
||||||
|
|
||||||
result->requestValue();
|
result->requestValue();
|
||||||
return result;
|
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::friendCreated, updateValue); // New Friend
|
||||||
data->makeUpdateCond(CoreModel::getInstance().get(), &CoreModel::friendRemoved, updateValue); // New Friend
|
data->makeUpdateCond(CoreModel::getInstance().get(), &CoreModel::friendRemoved, updateValue); // New Friend
|
||||||
|
data->makeUpdateCond(CoreModel::getInstance().get(), &CoreModel::friendUpdated, updateValue);
|
||||||
data->requestValue();
|
data->requestValue();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,8 +104,8 @@ ListView {
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
if (!visible)
|
// if (!visible)
|
||||||
currentIndex = -1
|
// currentIndex = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
BusyIndicator {
|
BusyIndicator {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue