mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 03:18:07 +00:00
do not display cached ldap friend if we are not doing ldap research
This commit is contained in:
parent
fb009fa17a
commit
b607cac0d1
4 changed files with 35 additions and 16 deletions
|
|
@ -57,10 +57,13 @@ void MagicSearchList::setSelf(QSharedPointer<MagicSearchList> me) {
|
|||
auto haveContact =
|
||||
std::find_if(mList.begin(), mList.end(), [friendCore](const QSharedPointer<QObject> &item) {
|
||||
auto itemCore = item.objectCast<FriendCore>();
|
||||
auto itemModel = itemCore->getFriendModel();
|
||||
auto friendModel = friendCore->getFriendModel();
|
||||
return itemCore->getDefaultAddress().length() > 0 &&
|
||||
itemCore->getDefaultAddress() == friendCore->getDefaultAddress() ||
|
||||
itemCore->getFriendModel() && friendCore->getFriendModel() &&
|
||||
itemCore->getFriendModel()->getFriend() == friendCore->getFriendModel()->getFriend();
|
||||
itemModel && friendModel && itemModel->getFriend() == friendModel->getFriend() &&
|
||||
itemModel->getFriend()->getFriendList()->getDisplayName() ==
|
||||
friendModel->getFriend()->getFriendList()->getDisplayName();
|
||||
});
|
||||
if (haveContact == mList.end()) {
|
||||
connect(friendCore.get(), &FriendCore::removed, this, qOverload<QObject *>(&MagicSearchList::remove));
|
||||
|
|
@ -118,19 +121,20 @@ void MagicSearchList::setSelf(QSharedPointer<MagicSearchList> me) {
|
|||
address->asString())); // linphone Friend object remove specific address.
|
||||
contacts->append(contact);
|
||||
} else if (!it->getPhoneNumber().empty()) {
|
||||
auto phoneNumber = it->getPhoneNumber();
|
||||
auto phoneNumber = it->getPhoneNumber();
|
||||
linphoneFriend = CoreModel::getInstance()->getCore()->createFriend();
|
||||
linphoneFriend->addPhoneNumber(phoneNumber);
|
||||
linphoneFriend->addPhoneNumber(phoneNumber);
|
||||
contact = FriendCore::create(linphoneFriend, isStored, it->getSourceFlags());
|
||||
contact->setGivenName(Utils::coreStringToAppString(it->getPhoneNumber()));
|
||||
contact->appendPhoneNumber(tr("device_id"), Utils::coreStringToAppString(it->getPhoneNumber()));
|
||||
contact->appendPhoneNumber(tr("device_id"),
|
||||
Utils::coreStringToAppString(it->getPhoneNumber()));
|
||||
contacts->append(contact);
|
||||
}
|
||||
}
|
||||
mModelConnection->invokeToCore([this, contacts]() {
|
||||
setResults(*contacts);
|
||||
delete contacts;
|
||||
emit resultsProcessed();
|
||||
emit resultsProcessed();
|
||||
});
|
||||
});
|
||||
qDebug() << log().arg("Initialized");
|
||||
|
|
|
|||
|
|
@ -75,26 +75,43 @@ void MagicSearchModel::setMaxResults(int maxResults) {
|
|||
}
|
||||
}
|
||||
|
||||
bool isContactTemporary(std::shared_ptr<linphone::Friend> f, bool allowNullFriendList = false) {
|
||||
auto friendList = f ? f->getFriendList() : nullptr;
|
||||
if (friendList == nullptr && !allowNullFriendList) return true;
|
||||
return friendList && (friendList == ToolModel::getLdapFriendList());
|
||||
}
|
||||
|
||||
void MagicSearchModel::onSearchResultsReceived(const std::shared_ptr<linphone::MagicSearch> &magicSearch) {
|
||||
auto results = magicSearch->getLastSearch();
|
||||
qDebug() << log().arg("SDK send callback: onSearchResultsReceived : %1 results.").arg(results.size());
|
||||
auto appFriends = ToolModel::getAppFriendList();
|
||||
auto ldapFriends = ToolModel::getLdapFriendList();
|
||||
std::list<std::shared_ptr<linphone::SearchResult>> finalResults;
|
||||
emit searchResultsReceived(results);
|
||||
for (auto result : results) {
|
||||
auto f = result->getFriend();
|
||||
bool isFromRemoteDirectory = result->hasSourceFlag(linphone::MagicSearch::Source::LdapServers) ||
|
||||
result->hasSourceFlag(linphone::MagicSearch::Source::RemoteCardDAV);
|
||||
if (!isFromRemoteDirectory && isContactTemporary(f, true)) {
|
||||
qDebug() << "Do not show friend " << f->getName() << "which is in a temporary friend list";
|
||||
continue;
|
||||
}
|
||||
finalResults.push_back(result);
|
||||
}
|
||||
emit searchResultsReceived(finalResults);
|
||||
for (auto result : results) {
|
||||
auto f = result->getFriend();
|
||||
auto fList = f ? f->getFriendList() : nullptr;
|
||||
|
||||
// qDebug() << log().arg("") << (f ? f->getName().c_str() : "NoFriend") << ", "
|
||||
// << (result->getAddress() ? result->getAddress()->asString().c_str() : "NoAddr") << " / "
|
||||
// << (fList ? fList->getDisplayName().c_str() : "NoList") << result->getSourceFlags() << " / "
|
||||
// << (fList ? fList->getDisplayName().c_str() : "NoList") << result->getSourceFlags() << " /
|
||||
//"
|
||||
// << (f ? f.get() : nullptr);
|
||||
|
||||
bool isLdap = (result->getSourceFlags() & (int)linphone::MagicSearch::Source::LdapServers) != 0;
|
||||
// Do not add it into ldap_friends if it already exists in app_friends.
|
||||
if (isLdap && f && (!fList || fList->getDisplayName() != "app_friends")) { // Double check because of SDK merging that lead to
|
||||
// use a ldap result as of app_friends/ldap_friends.
|
||||
if (isLdap && f &&
|
||||
(!fList || fList->getDisplayName() != "app_friends")) { // Double check because of SDK merging that lead to
|
||||
// use a ldap result as of app_friends/ldap_friends.
|
||||
updateFriendListWithFriend(f, ldapFriends);
|
||||
}
|
||||
}
|
||||
|
|
@ -134,5 +151,5 @@ void MagicSearchModel::updateFriendListWithFriend(const std::shared_ptr<linphone
|
|||
}
|
||||
qDebug() << log().arg("Adding Friend:") << linphoneFriend.get();
|
||||
friendList->addFriend(linphoneFriend);
|
||||
emit CoreModel::getInstance() -> friendCreated(linphoneFriend);
|
||||
emit CoreModel::getInstance()->friendCreated(linphoneFriend);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,8 +63,7 @@ Flickable {
|
|||
signal contactSelected(FriendGui contact)
|
||||
|
||||
function selectContact(address) {
|
||||
var index = contactsProxy.loadUntil(
|
||||
address) // Be sure to have this address in proxy if it exists
|
||||
var index = contactsProxy.loadUntil(address) // Be sure to have this address in proxy if it exists
|
||||
if (index != -1) {
|
||||
contactsList.selectIndex(index)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ AbstractMainPage {
|
|||
property FriendGui selectedContact
|
||||
property string initialFriendToDisplay
|
||||
onInitialFriendToDisplayChanged: {
|
||||
if (initialFriendToDisplay != '' && contactList.selectContact(
|
||||
initialFriendToDisplay) != -1)
|
||||
if (initialFriendToDisplay != '' && contactList.selectContact(initialFriendToDisplay) != -1)
|
||||
initialFriendToDisplay = ""
|
||||
else if (initialFriendToDisplay != '')
|
||||
console.warn("Abstract not selected yet: ", initialFriendToDisplay)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue