Fix ldap results: do not synchronized ldap list if already exist in local to avoid losing data on SDK merge.
Prioritize app_friends list in results. Update SDK.
This commit is contained in:
parent
d24a68e2a7
commit
0b193de0bb
3 changed files with 29 additions and 16 deletions
|
|
@ -197,7 +197,7 @@ bool MagicSearchProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QMo
|
||||||
// if (!toShow) return false;
|
// if (!toShow) return false;
|
||||||
}
|
}
|
||||||
if (!toShow && (mFilterType & (int)FilteringTypes::App) > 0) {
|
if (!toShow && (mFilterType & (int)FilteringTypes::App) > 0) {
|
||||||
toShow = friendCore->getIsStored();
|
toShow = friendCore->getIsStored() && !friendCore->isLdap();
|
||||||
// if (!toShow) return false;
|
// if (!toShow) return false;
|
||||||
}
|
}
|
||||||
if (!toShow && (mFilterType & (int)FilteringTypes::Other) > 0) {
|
if (!toShow && (mFilterType & (int)FilteringTypes::Other) > 0) {
|
||||||
|
|
|
||||||
|
|
@ -74,24 +74,34 @@ void MagicSearchModel::setMaxResults(int maxResults) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MagicSearchModel::onSearchResultsReceived(const std::shared_ptr<linphone::MagicSearch> &magicSearch) {
|
void MagicSearchModel::onSearchResultsReceived(const std::shared_ptr<linphone::MagicSearch> &magicSearch) {
|
||||||
qDebug() << log().arg("SDK send callback: onSearchResultsReceived");
|
|
||||||
auto results = magicSearch->getLastSearch();
|
auto results = magicSearch->getLastSearch();
|
||||||
|
qDebug() << log().arg("SDK send callback: onSearchResultsReceived : %1 results.").arg(results.size());
|
||||||
auto appFriends = ToolModel::getAppFriendList();
|
auto appFriends = ToolModel::getAppFriendList();
|
||||||
|
auto ldapFriends = ToolModel::getLdapFriendList();
|
||||||
std::list<std::shared_ptr<linphone::SearchResult>> finalResults;
|
std::list<std::shared_ptr<linphone::SearchResult>> finalResults;
|
||||||
for (auto it : results) {
|
for (auto result : results) {
|
||||||
bool isLdap = (it->getSourceFlags() & (int)LinphoneEnums::MagicSearchSource::LdapServers) != 0;
|
auto f = result->getFriend();
|
||||||
bool toAdd = true;
|
auto fList = f ? f->getFriendList() : nullptr;
|
||||||
if (isLdap && it->getFriend()) {
|
|
||||||
updateLdapFriendListWithFriend(it->getFriend());
|
qDebug() << log().arg("") << (f ? f->getName().c_str() : "NoFriend") << ", "
|
||||||
if (appFriends->findFriendByAddress(it->getFriend()->getAddress())) { // Already exist in app list
|
<< (result->getAddress() ? result->getAddress()->asString().c_str() : "NoAddr") << " / "
|
||||||
toAdd = false;
|
<< (fList ? fList->getDisplayName().c_str() : "NoList") << result->getSourceFlags() << " / "
|
||||||
|
<< (f ? f.get() : nullptr);
|
||||||
|
|
||||||
|
bool isLdap = (result->getSourceFlags() & (int)LinphoneEnums::MagicSearchSource::LdapServers) != 0;
|
||||||
|
// Do not add it into ldap_friends if it already exists in app_friends.
|
||||||
|
if (isLdap && f && (!fList || fList->getDisplayName() != "app_friends") &&
|
||||||
|
!ToolModel::friendIsInFriendList(appFriends, f)) { // Double check because of SDK merging that lead to
|
||||||
|
// use a ldap result as of app_friends/ldap_friends.
|
||||||
|
updateLdapFriendListWithFriend(f);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (toAdd &&
|
auto resultIt =
|
||||||
std::find_if(finalResults.begin(), finalResults.end(), [it](std::shared_ptr<linphone::SearchResult> r) {
|
std::find_if(finalResults.begin(), finalResults.end(), [result](std::shared_ptr<linphone::SearchResult> r) {
|
||||||
return r->getAddress()->weakEqual(it->getAddress());
|
return r->getAddress()->weakEqual(result->getAddress());
|
||||||
}) == finalResults.end())
|
});
|
||||||
finalResults.push_back(it);
|
if (resultIt == finalResults.end()) finalResults.push_back(result);
|
||||||
|
else if (fList && fList->getDisplayName() == "app_friends") *resultIt = result; // replace if local friend
|
||||||
}
|
}
|
||||||
emit searchResultsReceived(finalResults);
|
emit searchResultsReceived(finalResults);
|
||||||
}
|
}
|
||||||
|
|
@ -110,6 +120,8 @@ void MagicSearchModel::updateLdapFriendListWithFriend(const std::shared_ptr<linp
|
||||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||||
auto core = CoreModel::getInstance()->getCore();
|
auto core = CoreModel::getInstance()->getCore();
|
||||||
auto ldapFriendList = ToolModel::getLdapFriendList();
|
auto ldapFriendList = ToolModel::getLdapFriendList();
|
||||||
|
if (ToolModel::friendIsInFriendList(ldapFriendList, linphoneFriend))
|
||||||
|
return; // Already exist. We don't need to manipulate list.
|
||||||
for (auto address : linphoneFriend->getAddresses()) {
|
for (auto address : linphoneFriend->getAddresses()) {
|
||||||
auto existingFriend = ldapFriendList->findFriendByAddress(address);
|
auto existingFriend = ldapFriendList->findFriendByAddress(address);
|
||||||
if (existingFriend) {
|
if (existingFriend) {
|
||||||
|
|
@ -126,6 +138,7 @@ void MagicSearchModel::updateLdapFriendListWithFriend(const std::shared_ptr<linp
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
qDebug() << log().arg("Adding Friend:") << linphoneFriend.get();
|
||||||
ldapFriendList->addFriend(linphoneFriend);
|
ldapFriendList->addFriend(linphoneFriend);
|
||||||
emit CoreModel::getInstance()->friendCreated(linphoneFriend);
|
emit CoreModel::getInstance()->friendCreated(linphoneFriend);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
external/linphone-sdk
vendored
2
external/linphone-sdk
vendored
|
|
@ -1 +1 @@
|
||||||
Subproject commit b9b42aff89f650a5a1bd67d45bddb7dcc1b60481
|
Subproject commit bc6747f61ebc40ab1432966414cfce0e2b832206
|
||||||
Loading…
Reference in a new issue